drivers/regulator/rt6190-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/rt6190-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/rt6190-regulator.c- Extension
.c- Size
- 12552 bytes
- Lines
- 497
- 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/bits.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/pm_runtime.hlinux/regmap.hlinux/regulator/consumer.hlinux/regulator/driver.hlinux/regulator/of_regulator.h
Detected Declarations
struct rt6190_datafunction rt6190_out_set_voltage_selfunction rt6190_out_get_voltage_selfunction rt6190_out_enablefunction rt6190_out_disablefunction rt6190_out_set_current_limitfunction rt6190_out_get_current_limitfunction rt6190_out_set_modefunction rt6190_out_get_modefunction rt6190_out_get_error_flagsfunction rt6190_out_of_map_modefunction rt6190_is_volatile_regfunction rt6190_irq_handlerfunction rt6190_init_registersfunction rt6190_probefunction rt6190_runtime_suspendfunction rt6190_runtime_resume
Annotated Snippet
struct rt6190_data {
struct device *dev;
struct regmap *regmap;
struct gpio_desc *enable_gpio;
unsigned int cached_alert_evt;
};
static int rt6190_out_set_voltage_sel(struct regulator_dev *rdev,
unsigned int selector)
{
struct regmap *regmap = rdev_get_regmap(rdev);
__le16 le_sel = cpu_to_le16(selector);
return regmap_raw_write(regmap, RT6190_REG_OUTV, &le_sel,
sizeof(le_sel));
}
static int rt6190_out_get_voltage_sel(struct regulator_dev *rdev)
{
struct regmap *regmap = rdev_get_regmap(rdev);
__le16 le_sel;
int ret;
ret = regmap_raw_read(regmap, RT6190_REG_OUTV, &le_sel, sizeof(le_sel));
return ret ?: le16_to_cpu(le_sel);
}
static int rt6190_out_enable(struct regulator_dev *rdev)
{
struct rt6190_data *data = rdev_get_drvdata(rdev);
struct regmap *regmap = rdev_get_regmap(rdev);
u8 out_cfg[4];
int ret;
pm_runtime_get_sync(data->dev);
/*
* From off to on, vout config will restore to IC default.
* Read vout configs before enable, and restore them after enable
*/
ret = regmap_raw_read(regmap, RT6190_REG_OUTV, out_cfg,
sizeof(out_cfg));
if (ret)
return ret;
ret = regulator_enable_regmap(rdev);
if (ret)
return ret;
ret = regmap_raw_write(regmap, RT6190_REG_OUTV, out_cfg,
sizeof(out_cfg));
if (ret)
return ret;
return regmap_update_bits(regmap, RT6190_REG_SET5, RT6190_ENGCP_MASK,
RT6190_ENGCP_MASK);
}
static int rt6190_out_disable(struct regulator_dev *rdev)
{
struct rt6190_data *data = rdev_get_drvdata(rdev);
struct regmap *regmap = rdev_get_regmap(rdev);
int ret;
ret = regmap_update_bits(regmap, RT6190_REG_SET5, RT6190_ENGCP_MASK, 0);
if (ret)
return ret;
ret = regulator_disable_regmap(rdev);
if (ret)
return ret;
/* cleared cached alert event */
data->cached_alert_evt = 0;
pm_runtime_put(data->dev);
return 0;
}
static int rt6190_out_set_current_limit(struct regulator_dev *rdev, int min_uA,
int max_uA)
{
struct regmap *regmap = rdev_get_regmap(rdev);
int csel, clim;
__le16 le_csel;
if (min_uA < RT6190_OUT_MIN_UA || max_uA > RT6190_OUT_MAX_UA)
return -EINVAL;
Annotation
- Immediate include surface: `linux/bits.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct rt6190_data`, `function rt6190_out_set_voltage_sel`, `function rt6190_out_get_voltage_sel`, `function rt6190_out_enable`, `function rt6190_out_disable`, `function rt6190_out_set_current_limit`, `function rt6190_out_get_current_limit`, `function rt6190_out_set_mode`, `function rt6190_out_get_mode`, `function rt6190_out_get_error_flags`.
- 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.