drivers/regulator/axp20x-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/axp20x-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/axp20x-regulator.c- Extension
.c- Size
- 64812 bytes
- Lines
- 1760
- 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/bitops.hlinux/delay.hlinux/err.hlinux/init.hlinux/mfd/axp20x.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
function axp20x_set_ramp_delayfunction axp20x_regulator_enable_regmapfunction axp20x_set_dcdc_freqfunction axp20x_regulator_parse_dtfunction axp20x_set_dcdc_workmodefunction axp20x_is_polyphase_slavefunction axp20x_regulator_probe
Annotated Snippet
if (id == AXP20X_DCDC2) {
slew_rates = axp209_dcdc2_ldo3_slew_rates;
rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
reg = AXP20X_DCDC2_LDO3_V_RAMP;
mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK |
AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK;
enable = (ramp > 0) ?
AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : 0;
break;
}
if (id == AXP20X_LDO3) {
slew_rates = axp209_dcdc2_ldo3_slew_rates;
rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
reg = AXP20X_DCDC2_LDO3_V_RAMP;
mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK |
AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK;
enable = (ramp > 0) ?
AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : 0;
break;
}
if (rate_count > 0)
break;
fallthrough;
default:
/* Not supported for this regulator */
return -ENOTSUPP;
}
if (ramp == 0) {
cfg = enable;
} else {
int i;
for (i = 0; i < rate_count; i++) {
if (ramp > slew_rates[i])
break;
if (id == AXP20X_DCDC2)
cfg = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(i);
else
cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
}
if (cfg == 0xff) {
dev_err(axp20x->dev, "unsupported ramp value %d", ramp);
return -EINVAL;
}
cfg |= enable;
}
return regmap_update_bits(axp20x->regmap, reg, mask, cfg);
}
static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev)
{
struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
switch (axp20x->variant) {
case AXP209_ID:
if ((id == AXP20X_LDO3) &&
rdev->constraints && rdev->constraints->soft_start) {
int v_out;
int ret;
/*
* On some boards, the LDO3 can be overloaded when
* turning on, causing the entire PMIC to shutdown
* without warning. Turning it on at the minimal voltage
* and then setting the voltage to the requested value
* works reliably.
*/
if (regulator_is_enabled_regmap(rdev))
break;
v_out = regulator_get_voltage_sel_regmap(rdev);
if (v_out < 0)
return v_out;
if (v_out == 0)
break;
ret = regulator_set_voltage_sel_regmap(rdev, 0x00);
/*
* A small pause is needed between
* setting the voltage and enabling the LDO to give the
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/err.h`, `linux/init.h`, `linux/mfd/axp20x.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `function axp20x_set_ramp_delay`, `function axp20x_regulator_enable_regmap`, `function axp20x_set_dcdc_freq`, `function axp20x_regulator_parse_dt`, `function axp20x_set_dcdc_workmode`, `function axp20x_is_polyphase_slave`, `function axp20x_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.