drivers/regulator/da9211-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/da9211-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/da9211-regulator.c- Extension
.c- Size
- 14027 bytes
- Lines
- 567
- 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/gpio/consumer.hlinux/regulator/of_regulator.hlinux/regulator/da9211.hdt-bindings/regulator/dlg,da9211-regulator.hda9211-regulator.h
Detected Declarations
struct da9211function da9211_volatile_regfunction da9211_map_buck_modefunction da9211_buck_get_modefunction da9211_buck_set_modefunction da9211_set_current_limitfunction da9211_get_current_limitfunction da9211_irq_handlerfunction da9211_regulator_initfunction da9211_i2c_probe
Annotated Snippet
struct da9211 {
struct device *dev;
struct regmap *regmap;
struct da9211_pdata *pdata;
struct regulator_dev *rdev[DA9211_MAX_REGULATORS];
int num_regulator;
int chip_irq;
int chip_id;
};
static const struct regmap_range_cfg da9211_regmap_range[] = {
{
.selector_reg = DA9211_REG_PAGE_CON,
.selector_mask = DA9211_REG_PAGE_MASK,
.selector_shift = DA9211_REG_PAGE_SHIFT,
.window_start = 0,
.window_len = 256,
.range_min = 0,
.range_max = 5*128,
},
};
static bool da9211_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case DA9211_REG_STATUS_A:
case DA9211_REG_STATUS_B:
case DA9211_REG_EVENT_A:
case DA9211_REG_EVENT_B:
return true;
}
return false;
}
static const struct regmap_config da9211_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 5 * 128,
.volatile_reg = da9211_volatile_reg,
.cache_type = REGCACHE_MAPLE,
.ranges = da9211_regmap_range,
.num_ranges = ARRAY_SIZE(da9211_regmap_range),
};
/* Default limits measured in millivolts and milliamps */
#define DA9211_MIN_MV 300
#define DA9211_MAX_MV 1570
#define DA9211_STEP_MV 10
/* Current limits for DA9211 buck (uA) indices
* corresponds with register values
*/
static const int da9211_current_limits[] = {
2000000, 2200000, 2400000, 2600000, 2800000, 3000000, 3200000, 3400000,
3600000, 3800000, 4000000, 4200000, 4400000, 4600000, 4800000, 5000000
};
/* Current limits for DA9213 buck (uA) indices
* corresponds with register values
*/
static const int da9213_current_limits[] = {
3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
};
/* Current limits for DA9215 buck (uA) indices
* corresponds with register values
*/
static const int da9215_current_limits[] = {
4000000, 4200000, 4400000, 4600000, 4800000, 5000000, 5200000, 5400000,
5600000, 5800000, 6000000, 6200000, 6400000, 6600000, 6800000, 7000000
};
static unsigned int da9211_map_buck_mode(unsigned int mode)
{
switch (mode) {
case DA9211_BUCK_MODE_SLEEP:
return REGULATOR_MODE_STANDBY;
case DA9211_BUCK_MODE_SYNC:
return REGULATOR_MODE_FAST;
case DA9211_BUCK_MODE_AUTO:
return REGULATOR_MODE_NORMAL;
default:
return REGULATOR_MODE_INVALID;
}
}
static unsigned int da9211_buck_get_mode(struct regulator_dev *rdev)
{
int id = rdev_get_id(rdev);
struct da9211 *chip = rdev_get_drvdata(rdev);
unsigned int data;
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 da9211`, `function da9211_volatile_reg`, `function da9211_map_buck_mode`, `function da9211_buck_get_mode`, `function da9211_buck_set_mode`, `function da9211_set_current_limit`, `function da9211_get_current_limit`, `function da9211_irq_handler`, `function da9211_regulator_init`, `function da9211_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.