drivers/regulator/rt5190a-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/rt5190a-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/rt5190a-regulator.c- Extension
.c- Size
- 13068 bytes
- Lines
- 518
- 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
dt-bindings/regulator/richtek,rt5190a-regulator.hlinux/bits.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/property.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
struct rt5190a_privfunction rt5190a_get_error_flagsfunction rt5190a_fixed_buck_set_modefunction rt5190a_fixed_buck_get_modefunction rt5190a_irq_handlerfunction rt5190a_of_map_modefunction rt5190a_of_parse_cbfunction rt5190a_fillin_regulator_descfunction rt5190a_parse_regulator_dt_datafunction rt5190a_device_initializefunction rt5190a_device_checkfunction rt5190a_probe
Annotated Snippet
struct rt5190a_priv {
struct device *dev;
struct regmap *regmap;
struct regulator_desc rdesc[RT5190A_MAX_IDX];
struct regulator_dev *rdev[RT5190A_MAX_IDX];
};
static int rt5190a_get_error_flags(struct regulator_dev *rdev,
unsigned int *flags)
{
struct regmap *regmap = rdev_get_regmap(rdev);
int rid = rdev_get_id(rdev);
unsigned int pgood_stat;
int ret;
ret = regmap_read(regmap, RT5190A_REG_PGSTAT, &pgood_stat);
if (ret)
return ret;
if (!(pgood_stat & RT5190A_RID_BITMASK(rid)))
*flags = REGULATOR_ERROR_FAIL;
else
*flags = 0;
return 0;
}
static int rt5190a_fixed_buck_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
struct regmap *regmap = rdev_get_regmap(rdev);
int rid = rdev_get_id(rdev);
unsigned int mask = RT5190A_RID_BITMASK(rid), val;
switch (mode) {
case REGULATOR_MODE_FAST:
val = mask;
break;
case REGULATOR_MODE_NORMAL:
val = 0;
break;
default:
return -EINVAL;
}
return regmap_update_bits(regmap, RT5190A_REG_DCDCCNTL, mask, val);
}
static unsigned int rt5190a_fixed_buck_get_mode(struct regulator_dev *rdev)
{
struct regmap *regmap = rdev_get_regmap(rdev);
int rid = rdev_get_id(rdev);
unsigned int val;
int ret;
ret = regmap_read(regmap, RT5190A_REG_DCDCCNTL, &val);
if (ret) {
dev_err(&rdev->dev, "Failed to get mode [%d]\n", ret);
return ret;
}
if (val & RT5190A_RID_BITMASK(rid))
return REGULATOR_MODE_FAST;
return REGULATOR_MODE_NORMAL;
}
static const struct regulator_ops rt5190a_ranged_buck_ops = {
.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_active_discharge = regulator_set_active_discharge_regmap,
.get_error_flags = rt5190a_get_error_flags,
};
static const struct regulator_ops rt5190a_fixed_buck_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.set_active_discharge = regulator_set_active_discharge_regmap,
.set_mode = rt5190a_fixed_buck_set_mode,
.get_mode = rt5190a_fixed_buck_get_mode,
.get_error_flags = rt5190a_get_error_flags,
};
static const struct regulator_ops rt5190a_fixed_ldo_ops = {
.enable = regulator_enable_regmap,
Annotation
- Immediate include surface: `dt-bindings/regulator/richtek,rt5190a-regulator.h`, `linux/bits.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/property.h`.
- Detected declarations: `struct rt5190a_priv`, `function rt5190a_get_error_flags`, `function rt5190a_fixed_buck_set_mode`, `function rt5190a_fixed_buck_get_mode`, `function rt5190a_irq_handler`, `function rt5190a_of_map_mode`, `function rt5190a_of_parse_cb`, `function rt5190a_fillin_regulator_desc`, `function rt5190a_parse_regulator_dt_data`, `function rt5190a_device_initialize`.
- 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.