drivers/regulator/pv88060-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/pv88060-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/pv88060-regulator.c- Extension
.c- Size
- 9963 bytes
- Lines
- 391
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/err.hlinux/i2c.hlinux/module.hlinux/init.hlinux/slab.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regmap.hlinux/irq.hlinux/interrupt.hlinux/regulator/of_regulator.hpv88060-regulator.h
Detected Declarations
struct pv88060_regulatorstruct pv88060function pv88060_buck_get_modefunction pv88060_buck_set_modefunction pv88060_irq_handlerfunction pv88060_i2c_probe
Annotated Snippet
struct pv88060_regulator {
struct regulator_desc desc;
unsigned int conf; /* buck configuration register */
};
struct pv88060 {
struct device *dev;
struct regmap *regmap;
struct regulator_dev *rdev[PV88060_MAX_REGULATORS];
};
static const struct regmap_config pv88060_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
/* Current limits array (in uA) for BUCK1
* Entry indexes corresponds to register values.
*/
static const unsigned int pv88060_buck1_limits[] = {
1496000, 2393000, 3291000, 4189000
};
static unsigned int pv88060_buck_get_mode(struct regulator_dev *rdev)
{
struct pv88060_regulator *info = rdev_get_drvdata(rdev);
unsigned int data;
int ret, mode = 0;
ret = regmap_read(rdev->regmap, info->conf, &data);
if (ret < 0)
return ret;
switch (data & PV88060_BUCK_MODE_MASK) {
case PV88060_BUCK_MODE_SYNC:
mode = REGULATOR_MODE_FAST;
break;
case PV88060_BUCK_MODE_AUTO:
mode = REGULATOR_MODE_NORMAL;
break;
case PV88060_BUCK_MODE_SLEEP:
mode = REGULATOR_MODE_STANDBY;
break;
}
return mode;
}
static int pv88060_buck_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
struct pv88060_regulator *info = rdev_get_drvdata(rdev);
int val = 0;
switch (mode) {
case REGULATOR_MODE_FAST:
val = PV88060_BUCK_MODE_SYNC;
break;
case REGULATOR_MODE_NORMAL:
val = PV88060_BUCK_MODE_AUTO;
break;
case REGULATOR_MODE_STANDBY:
val = PV88060_BUCK_MODE_SLEEP;
break;
default:
return -EINVAL;
}
return regmap_update_bits(rdev->regmap, info->conf,
PV88060_BUCK_MODE_MASK, val);
}
static const struct regulator_ops pv88060_buck_ops = {
.get_mode = pv88060_buck_get_mode,
.set_mode = pv88060_buck_set_mode,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
.set_current_limit = regulator_set_current_limit_regmap,
.get_current_limit = regulator_get_current_limit_regmap,
};
static const struct regulator_ops pv88060_ldo_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
Annotation
- Immediate include surface: `linux/err.h`, `linux/i2c.h`, `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`, `linux/regmap.h`.
- Detected declarations: `struct pv88060_regulator`, `struct pv88060`, `function pv88060_buck_get_mode`, `function pv88060_buck_set_mode`, `function pv88060_irq_handler`, `function pv88060_i2c_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.