drivers/regulator/max20086-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/max20086-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/max20086-regulator.c- Extension
.c- Size
- 8555 bytes
- Lines
- 336
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.hlinux/slab.h
Detected Declarations
struct max20086_chip_infostruct max20086_regulatorstruct max20086function max20086_regulators_registerfunction max20086_parse_regulators_dtfunction max20086_detectfunction max20086_gen_is_writeable_regfunction max20086_i2c_probe
Annotated Snippet
struct max20086_chip_info {
u8 id;
unsigned int num_outputs;
};
struct max20086_regulator {
struct device_node *of_node;
struct regulator_init_data *init_data;
const struct regulator_desc *desc;
struct regulator_dev *rdev;
};
struct max20086 {
struct device *dev;
struct regmap *regmap;
struct gpio_desc *ena_gpiod;
const struct max20086_chip_info *info;
struct max20086_regulator regulators[MAX20086_MAX_REGULATORS];
};
static const struct regulator_ops max20086_buck_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
};
#define MAX20086_REGULATOR_DESC(n) \
{ \
.name = "OUT"#n, \
.supply_name = "in", \
.id = (n) - 1, \
.ops = &max20086_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.enable_reg = MAX20086_REG_CONFIG, \
.enable_mask = 1 << ((n) - 1), \
.enable_val = 1 << ((n) - 1), \
.disable_val = 0, \
}
static const char * const max20086_output_names[] = {
"OUT1",
"OUT2",
"OUT3",
"OUT4",
};
static const struct regulator_desc max20086_regulators[] = {
MAX20086_REGULATOR_DESC(1),
MAX20086_REGULATOR_DESC(2),
MAX20086_REGULATOR_DESC(3),
MAX20086_REGULATOR_DESC(4),
};
static int max20086_regulators_register(struct max20086 *chip)
{
unsigned int i;
for (i = 0; i < chip->info->num_outputs; i++) {
struct max20086_regulator *reg = &chip->regulators[i];
struct regulator_config config = { };
struct regulator_dev *rdev;
config.dev = chip->dev;
config.init_data = reg->init_data;
config.driver_data = chip;
config.of_node = reg->of_node;
config.regmap = chip->regmap;
config.ena_gpiod = chip->ena_gpiod;
rdev = devm_regulator_register(chip->dev, reg->desc, &config);
if (IS_ERR(rdev)) {
dev_err(chip->dev,
"Failed to register regulator output %s\n",
reg->desc->name);
return PTR_ERR(rdev);
}
reg->rdev = rdev;
}
return 0;
}
static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on)
{
struct of_regulator_match *matches;
unsigned int i;
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`.
- Detected declarations: `struct max20086_chip_info`, `struct max20086_regulator`, `struct max20086`, `function max20086_regulators_register`, `function max20086_parse_regulators_dt`, `function max20086_detect`, `function max20086_gen_is_writeable_reg`, `function max20086_i2c_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.