drivers/regulator/anatop-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/anatop-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/anatop-regulator.c- Extension
.c- Size
- 9787 bytes
- Lines
- 354
- Domain
- Driver Families
- Bucket
- drivers/regulator
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/slab.hlinux/device.hlinux/module.hlinux/mfd/syscon.hlinux/err.hlinux/io.hlinux/platform_device.hlinux/of.hlinux/of_address.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/of_regulator.hlinux/regulator/machine.h
Detected Declarations
struct anatop_regulatorfunction anatop_regmap_set_voltage_time_selfunction anatop_regmap_enablefunction anatop_regmap_disablefunction anatop_regmap_is_enabledfunction anatop_regmap_core_set_voltage_selfunction anatop_regmap_core_get_voltage_selfunction anatop_regmap_get_bypassfunction anatop_regmap_set_bypassfunction anatop_regulator_probefunction anatop_regulator_initfunction anatop_regulator_exit
Annotated Snippet
struct anatop_regulator {
u32 delay_reg;
int delay_bit_shift;
int delay_bit_width;
struct regulator_desc rdesc;
bool bypass;
int sel;
};
static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg,
unsigned int old_sel,
unsigned int new_sel)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val;
int ret = 0;
/* check whether need to care about LDO ramp up speed */
if (anatop_reg->delay_bit_width && new_sel > old_sel) {
/*
* the delay for LDO ramp up time is
* based on the register setting, we need
* to calculate how many steps LDO need to
* ramp up, and how much delay needed. (us)
*/
regmap_read(reg->regmap, anatop_reg->delay_reg, &val);
val = (val >> anatop_reg->delay_bit_shift) &
((1 << anatop_reg->delay_bit_width) - 1);
ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES <<
val) / LDO_RAMP_UP_FREQ_IN_MHZ + 1;
}
return ret;
}
static int anatop_regmap_enable(struct regulator_dev *reg)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
int sel;
sel = anatop_reg->bypass ? LDO_FET_FULL_ON : anatop_reg->sel;
return regulator_set_voltage_sel_regmap(reg, sel);
}
static int anatop_regmap_disable(struct regulator_dev *reg)
{
return regulator_set_voltage_sel_regmap(reg, LDO_POWER_GATE);
}
static int anatop_regmap_is_enabled(struct regulator_dev *reg)
{
return regulator_get_voltage_sel_regmap(reg) != LDO_POWER_GATE;
}
static int anatop_regmap_core_set_voltage_sel(struct regulator_dev *reg,
unsigned selector)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
int ret;
if (anatop_reg->bypass || !anatop_regmap_is_enabled(reg)) {
anatop_reg->sel = selector;
return 0;
}
ret = regulator_set_voltage_sel_regmap(reg, selector);
if (!ret)
anatop_reg->sel = selector;
return ret;
}
static int anatop_regmap_core_get_voltage_sel(struct regulator_dev *reg)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
if (anatop_reg->bypass || !anatop_regmap_is_enabled(reg))
return anatop_reg->sel;
return regulator_get_voltage_sel_regmap(reg);
}
static int anatop_regmap_get_bypass(struct regulator_dev *reg, bool *enable)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
int sel;
sel = regulator_get_voltage_sel_regmap(reg);
if (sel == LDO_FET_FULL_ON)
WARN_ON(!anatop_reg->bypass);
else if (sel != LDO_POWER_GATE)
Annotation
- Immediate include surface: `linux/slab.h`, `linux/device.h`, `linux/module.h`, `linux/mfd/syscon.h`, `linux/err.h`, `linux/io.h`, `linux/platform_device.h`, `linux/of.h`.
- Detected declarations: `struct anatop_regulator`, `function anatop_regmap_set_voltage_time_sel`, `function anatop_regmap_enable`, `function anatop_regmap_disable`, `function anatop_regmap_is_enabled`, `function anatop_regmap_core_set_voltage_sel`, `function anatop_regmap_core_get_voltage_sel`, `function anatop_regmap_get_bypass`, `function anatop_regmap_set_bypass`, `function anatop_regulator_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: integration 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.