drivers/regulator/ltc3676.c
Source file repositories/reference/linux-study-clean/drivers/regulator/ltc3676.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/ltc3676.c- Extension
.c- Size
- 11282 bytes
- Lines
- 385
- 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/i2c.hlinux/init.hlinux/interrupt.hlinux/module.hlinux/kernel.hlinux/of.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
struct ltc3676enum ltc3676_regfunction ltc3676_set_suspend_voltagefunction ltc3676_set_suspend_modefunction ltc3676_set_voltage_selfunction ltc3676_scalefunction ltc3676_of_parse_cbfunction ltc3676_readable_writeable_regfunction ltc3676_volatile_regfunction ltc3676_isrfunction ltc3676_regulator_probe
Annotated Snippet
struct ltc3676 {
struct regmap *regmap;
struct device *dev;
struct regulator_desc regulator_descs[LTC3676_NUM_REGULATORS];
struct regulator_dev *regulators[LTC3676_NUM_REGULATORS];
};
static int ltc3676_set_suspend_voltage(struct regulator_dev *rdev, int uV)
{
struct ltc3676 *ltc3676 = rdev_get_drvdata(rdev);
struct device *dev = ltc3676->dev;
int dcdc = rdev_get_id(rdev);
int sel;
dev_dbg(dev, "%s id=%d uV=%d\n", __func__, dcdc, uV);
sel = regulator_map_voltage_linear(rdev, uV, uV);
if (sel < 0)
return sel;
/* DVBB register follows right after the corresponding DVBA register */
return regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg + 1,
rdev->desc->vsel_mask, sel);
}
static int ltc3676_set_suspend_mode(struct regulator_dev *rdev,
unsigned int mode)
{
struct ltc3676 *ltc3676= rdev_get_drvdata(rdev);
struct device *dev = ltc3676->dev;
int mask, val;
int dcdc = rdev_get_id(rdev);
dev_dbg(dev, "%s id=%d mode=%d\n", __func__, dcdc, mode);
mask = LTC3676_DVBxA_REF_SELECT;
switch (mode) {
case REGULATOR_MODE_STANDBY:
val = 0; /* select DVBxA */
break;
case REGULATOR_MODE_NORMAL:
val = LTC3676_DVBxA_REF_SELECT; /* select DVBxB */
break;
default:
dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n",
rdev->desc->name, mode);
return -EINVAL;
}
return regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg,
mask, val);
}
static int ltc3676_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
{
struct ltc3676 *ltc3676 = rdev_get_drvdata(rdev);
struct device *dev = ltc3676->dev;
int ret, dcdc = rdev_get_id(rdev);
dev_dbg(dev, "%s id=%d selector=%d\n", __func__, dcdc, selector);
ret = regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg + 1,
LTC3676_DVBxB_PGOOD_MASK,
LTC3676_DVBxB_PGOOD_MASK);
if (ret)
return ret;
return regulator_set_voltage_sel_regmap(rdev, selector);
}
static inline unsigned int ltc3676_scale(unsigned int uV, u32 r1, u32 r2)
{
uint64_t tmp;
if (uV == 0)
return 0;
tmp = (uint64_t)uV * r1;
do_div(tmp, r2);
return uV + (unsigned int)tmp;
}
static int ltc3676_of_parse_cb(struct device_node *np,
const struct regulator_desc *desc,
struct regulator_config *config)
{
struct ltc3676 *ltc3676 = config->driver_data;
struct regulator_desc *rdesc = <c3676->regulator_descs[desc->id];
u32 r[2];
int ret;
/* LDO3 has a fixed output */
if (desc->id == LTC3676_LDO3)
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/init.h`, `linux/interrupt.h`, `linux/module.h`, `linux/kernel.h`, `linux/of.h`, `linux/regmap.h`, `linux/regulator/driver.h`.
- Detected declarations: `struct ltc3676`, `enum ltc3676_reg`, `function ltc3676_set_suspend_voltage`, `function ltc3676_set_suspend_mode`, `function ltc3676_set_voltage_sel`, `function ltc3676_scale`, `function ltc3676_of_parse_cb`, `function ltc3676_readable_writeable_reg`, `function ltc3676_volatile_reg`, `function ltc3676_isr`.
- 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.