drivers/regulator/pf530x-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/pf530x-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/pf530x-regulator.c- Extension
.c- Size
- 9195 bytes
- Lines
- 376
- 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/consumer.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
struct pf530x_chipenum pf530x_statesenum pf530x_devidfunction pf530x_get_statusfunction pf530x_get_error_flagsfunction pf530x_identifyfunction pf530x_i2c_probe
Annotated Snippet
struct pf530x_chip {
struct regmap *regmap;
struct device *dev;
};
static const struct regmap_config pf530x_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = PF530X_OTP_MODE,
.cache_type = REGCACHE_MAPLE,
};
static int pf530x_get_status(struct regulator_dev *rdev)
{
unsigned int state;
int ret;
ret = regmap_read(rdev->regmap, PF530X_INT_SENSE1, &state);
if (ret != 0)
return ret;
if ((state & (BG_ERR_S | SW1_ILIM_S | VMON_UV_S | VMON_OV_S | VIN_OVLO_S))
!= 0)
return REGULATOR_STATUS_ERROR;
// no errors, check if what non-error state we're in
ret = regmap_read(rdev->regmap, PF530X_STATE, &state);
if (ret != 0)
return ret;
state &= PF530x_STATE_MASK;
switch (state) {
case PF530x_STATE_RUN:
ret = REGULATOR_STATUS_NORMAL;
break;
case PF530x_STATE_STANDBY:
ret = REGULATOR_STATUS_STANDBY;
break;
case PF530x_STATE_LP_OFF:
ret = REGULATOR_STATUS_OFF;
break;
default:
ret = REGULATOR_STATUS_ERROR;
break;
}
return ret;
}
static int pf530x_get_error_flags(struct regulator_dev *rdev, unsigned int *flags)
{
unsigned int status;
int ret;
ret = regmap_read(rdev->regmap, PF530X_INT_STATUS1, &status);
if (ret != 0)
return ret;
*flags = 0;
if (status & PF530X_INT_STATUS_OV)
*flags |= REGULATOR_ERROR_OVER_VOLTAGE_WARN;
if (status & PF530X_INT_STATUS_UV)
*flags |= REGULATOR_ERROR_UNDER_VOLTAGE;
if (status & PF530X_INT_STATUS_ILIM)
*flags |= REGULATOR_ERROR_OVER_CURRENT;
ret = regmap_read(rdev->regmap, PF530X_INT_SENSE2, &status);
if (ret != 0)
return ret;
if ((status & (THERM_155_S |
THERM_140_S |
THERM_125_S |
THERM_110_S)) != 0)
*flags |= REGULATOR_ERROR_OVER_TEMP_WARN;
return 0;
}
static const struct regulator_ops pf530x_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.map_voltage = regulator_map_voltage_linear_range,
.list_voltage = regulator_list_voltage_linear_range,
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/consumer.h`.
- Detected declarations: `struct pf530x_chip`, `enum pf530x_states`, `enum pf530x_devid`, `function pf530x_get_status`, `function pf530x_get_error_flags`, `function pf530x_identify`, `function pf530x_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.