drivers/regulator/pf8x00-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/pf8x00-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/pf8x00-regulator.c- Extension
.c- Size
- 17210 bytes
- Lines
- 621
- 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/delay.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.h
Detected Declarations
struct pf8x00_regulator_datastruct pf8x00_chipenum pf8x00_regulatorsenum pf8x00_buck_statesenum pf8x00_ldo_statesenum swxilim_bitsenum pf8x00_devidfunction swxilim_selectfunction handle_ilim_propertyfunction handle_shift_propertyfunction pf8x00_of_parse_cbfunction pf8x00_suspend_enablefunction pf8x00_suspend_disablefunction pf8x00_set_suspend_voltagefunction pf8x00_identifyfunction pf8x00_i2c_probe
Annotated Snippet
struct pf8x00_regulator_data {
struct regulator_desc desc;
unsigned int suspend_enable_reg;
unsigned int suspend_enable_mask;
unsigned int suspend_voltage_reg;
unsigned int suspend_voltage_cache;
};
struct pf8x00_chip {
struct regmap *regmap;
struct device *dev;
};
static const struct regmap_config pf8x00_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = PF8X00_PAGE_SELECT,
.cache_type = REGCACHE_MAPLE,
};
/* VLDOx output: 1.5V to 5.0V */
static const int pf8x00_ldo_voltages[] = {
1500000, 1600000, 1800000, 1850000, 2150000, 2500000, 2800000, 3000000,
3100000, 3150000, 3200000, 3300000, 3350000, 1650000, 1700000, 5000000,
};
/* Output: 2.1A to 4.5A */
static const unsigned int pf8x00_sw_current_table[] = {
2100000, 2600000, 3000000, 4500000,
};
/* Output: 0.4V to 1.8V */
#define PF8XOO_SW1_6_VOLTAGE_NUM 0xB2
static const struct linear_range pf8x00_sw1_to_6_voltages[] = {
REGULATOR_LINEAR_RANGE(400000, 0x00, 0xB0, 6250),
REGULATOR_LINEAR_RANGE(1800000, 0xB1, 0xB1, 0),
};
/* Output: 1.0V to 4.1V */
static const int pf8x00_sw7_voltages[] = {
1000000, 1100000, 1200000, 1250000, 1300000, 1350000, 1500000, 1600000,
1800000, 1850000, 2000000, 2100000, 2150000, 2250000, 2300000, 2400000,
2500000, 2800000, 3150000, 3200000, 3250000, 3300000, 3350000, 3400000,
3500000, 3800000, 4000000, 4100000, 4100000, 4100000, 4100000, 4100000,
};
/* Output: 1.8V, 3.0V, or 3.3V */
static const int pf8x00_vsnvs_voltages[] = {
0, 1800000, 3000000, 3300000,
};
static void swxilim_select(struct pf8x00_chip *chip, int id, int ilim)
{
u8 ilim_sel;
u8 reg = PF8X00_SW_BASE(id) + SW_CONFIG2;
switch (ilim) {
case 2100:
ilim_sel = SWXILIM_2100_MA;
break;
case 2600:
ilim_sel = SWXILIM_2600_MA;
break;
case 3000:
ilim_sel = SWXILIM_3000_MA;
break;
case 4500:
ilim_sel = SWXILIM_4500_MA;
break;
default:
ilim_sel = SWXILIM_2100_MA;
break;
}
regmap_update_bits(chip->regmap, reg,
PF8X00_SWXILIM_MASK,
ilim_sel << PF8X00_SWXILIM_SHIFT);
}
static void handle_ilim_property(struct device_node *np,
const struct regulator_desc *desc,
struct regulator_config *config)
{
struct pf8x00_chip *chip = config->driver_data;
int ret;
int val;
if ((desc->id >= PF8X00_BUCK1) && (desc->id <= PF8X00_BUCK7)) {
ret = of_property_read_u32(np, "nxp,ilim-ma", &val);
if (ret) {
Annotation
- Immediate include surface: `linux/delay.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 pf8x00_regulator_data`, `struct pf8x00_chip`, `enum pf8x00_regulators`, `enum pf8x00_buck_states`, `enum pf8x00_ldo_states`, `enum swxilim_bits`, `enum pf8x00_devid`, `function swxilim_select`, `function handle_ilim_property`, `function handle_shift_property`.
- 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.