drivers/regulator/rtq2208-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/rtq2208-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/rtq2208-regulator.c- Extension
.c- Size
- 19882 bytes
- Lines
- 669
- 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/bitops.hlinux/bitfield.hlinux/util_macros.hlinux/module.hlinux/i2c.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.hlinux/mod_devicetable.h
Detected Declarations
struct rtq2208_regulator_descstruct rtq2208_rdev_mapfunction rtq2208_set_modefunction rtq2208_get_modefunction rtq2208_set_ramp_delayfunction rtq2208_set_suspend_enablefunction rtq2208_set_suspend_disablefunction rtq2208_set_suspend_modefunction rtq2208_of_map_modefunction rtq2208_init_irq_maskfunction rtq2208_irq_handlerfunction rtq2208_init_regulator_descfunction rtq2208_parse_regulator_dt_datafunction rtq2208_regulator_checkfunction rtq2208_probe
Annotated Snippet
struct rtq2208_regulator_desc {
struct regulator_desc desc;
unsigned int mtp_sel_reg;
unsigned int mtp_sel_mask;
unsigned int mode_reg;
unsigned int mode_mask;
unsigned int suspend_config_reg;
unsigned int suspend_enable_mask;
unsigned int suspend_mode_mask;
};
struct rtq2208_rdev_map {
struct regulator_dev *rdev[RTQ2208_LDO_MAX];
struct regmap *regmap;
struct device *dev;
};
/* set Normal Auto/FCCM mode */
static int rtq2208_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
const struct rtq2208_regulator_desc *rdesc =
(const struct rtq2208_regulator_desc *)rdev->desc;
unsigned int val, shift;
switch (mode) {
case REGULATOR_MODE_NORMAL:
val = RTQ2208_AUTO_MODE;
break;
case REGULATOR_MODE_FAST:
val = RTQ2208_FCCM;
break;
default:
return -EINVAL;
}
shift = ffs(rdesc->mode_mask) - 1;
return regmap_update_bits(rdev->regmap, rdesc->mode_reg,
rdesc->mode_mask, val << shift);
}
static unsigned int rtq2208_get_mode(struct regulator_dev *rdev)
{
const struct rtq2208_regulator_desc *rdesc =
(const struct rtq2208_regulator_desc *)rdev->desc;
unsigned int mode_val;
int ret;
ret = regmap_read(rdev->regmap, rdesc->mode_reg, &mode_val);
if (ret)
return REGULATOR_MODE_INVALID;
return (mode_val & rdesc->mode_mask) ? REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
}
static int rtq2208_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
{
const struct regulator_desc *desc = rdev->desc;
unsigned int sel = 0, val;
ramp_delay = max(ramp_delay, RTQ2208_RAMP_VALUE_MIN_uV);
ramp_delay = min(ramp_delay, RTQ2208_RAMP_VALUE_MAX_uV);
ramp_delay /= RTQ2208_RAMP_VALUE_MIN_uV;
/*
* fls(ramp_delay) - 1: doing LSB shift, let it starts from 0
*
* RTQ2208_BUCK_RAMP_SEL_MASK - sel: doing descending order shifting.
* Because the relation of seleltion and value is like that
*
* seletion: value
* 010: 16mv
* ...
* 111: 0.5mv
*
* For example, if I would like to select 16mv, the fls(ramp_delay) - 1 will be 0b010,
* and I need to use 0b111 - sel to do the shifting
*/
sel = fls(ramp_delay) - 1;
sel = RTQ2208_BUCK_RAMP_SEL_MASK - sel;
val = FIELD_PREP(RTQ2208_BUCK_RSPUP_MASK, sel) | FIELD_PREP(RTQ2208_BUCK_RSPDN_MASK, sel);
return regmap_update_bits(rdev->regmap, desc->ramp_reg,
RTQ2208_BUCK_RSPUP_MASK | RTQ2208_BUCK_RSPDN_MASK, val);
}
static int rtq2208_set_suspend_enable(struct regulator_dev *rdev)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bitfield.h`, `linux/util_macros.h`, `linux/module.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`.
- Detected declarations: `struct rtq2208_regulator_desc`, `struct rtq2208_rdev_map`, `function rtq2208_set_mode`, `function rtq2208_get_mode`, `function rtq2208_set_ramp_delay`, `function rtq2208_set_suspend_enable`, `function rtq2208_set_suspend_disable`, `function rtq2208_set_suspend_mode`, `function rtq2208_of_map_mode`, `function rtq2208_init_irq_mask`.
- 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.