drivers/regulator/max77503-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/max77503-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/max77503-regulator.c- Extension
.c- Size
- 3735 bytes
- Lines
- 130
- Domain
- Driver Families
- Bucket
- drivers/regulator
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.hlinux/util_macros.h
Detected Declarations
function max77503_regulator_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2023 Analog Devices, Inc.
* ADI regulator driver for MAX77503.
*/
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/util_macros.h>
#define MAX77503_REG_CFG 0x00
#define MAX77503_REG_VOUT 0x01
#define MAX77503_BIT_EN BIT(0)
#define MAX77503_BIT_CURR_LIM BIT(3)
#define MAX77503_BIT_ADEN BIT(6)
#define MAX77503_BITS_SOFT_START GENMASK(5, 4)
#define MAX77503_BITS_MX_VOUT GENMASK(7, 0)
#define MAX77503_AD_ENABLED 0x1
#define MAX77503_AD_DISABLED 0x0
static const struct regmap_config max77503_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x2,
};
static const struct regulator_ops max77503_buck_ops = {
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_ascend,
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_current_limit = regulator_get_current_limit_regmap,
.set_current_limit = regulator_set_current_limit_regmap,
.set_active_discharge = regulator_set_active_discharge_regmap,
.set_soft_start = regulator_set_soft_start_regmap,
};
static const struct linear_range max77503_buck_ranges[] = {
REGULATOR_LINEAR_RANGE(800000, 0x00, 0x54, 50000)
};
static const unsigned int max77503_current_limit_table[] = {
500000, 2000000
};
static const struct regulator_desc max77503_regulators_desc = {
.name = "max77503",
.enable_reg = MAX77503_REG_CFG,
.enable_mask = MAX77503_BIT_EN,
.ops = &max77503_buck_ops,
.type = REGULATOR_VOLTAGE,
.linear_ranges = max77503_buck_ranges,
.n_linear_ranges = ARRAY_SIZE(max77503_buck_ranges),
.vsel_reg = MAX77503_REG_VOUT,
.vsel_mask = MAX77503_BITS_MX_VOUT,
.soft_start_reg = MAX77503_REG_CFG,
.soft_start_mask = MAX77503_BITS_SOFT_START,
.active_discharge_reg = MAX77503_REG_CFG,
.active_discharge_mask = MAX77503_BIT_ADEN,
.active_discharge_off = MAX77503_AD_DISABLED,
.active_discharge_on = MAX77503_AD_ENABLED,
.csel_reg = MAX77503_REG_CFG,
.csel_mask = MAX77503_BIT_CURR_LIM,
.curr_table = max77503_current_limit_table,
.n_current_limits = ARRAY_SIZE(max77503_current_limit_table),
.owner = THIS_MODULE,
};
static int max77503_regulator_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct regulator_config config = {};
struct regulator_dev *rdev;
config.dev = dev;
config.of_node = dev->of_node;
config.regmap = devm_regmap_init_i2c(client, &max77503_regmap_config);
if (IS_ERR(config.regmap)) {
dev_err(dev, "Failed to init regmap");
return PTR_ERR(config.regmap);
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`, `linux/regulator/of_regulator.h`, `linux/util_macros.h`.
- Detected declarations: `function max77503_regulator_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.