drivers/regulator/rt6245-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/rt6245-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/rt6245-regulator.c- Extension
.c- Size
- 6879 bytes
- Lines
- 256
- 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.
- 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/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/of_regulator.h
Detected Declarations
struct rt6245_privfunction rt6245_enablefunction rt6245_disablefunction rt6245_is_enabledfunction rt6245_init_device_propertiesfunction rt6245_reg_writefunction rt6245_probe
Annotated Snippet
struct rt6245_priv {
struct gpio_desc *enable_gpio;
bool enable_state;
};
static int rt6245_enable(struct regulator_dev *rdev)
{
struct rt6245_priv *priv = rdev_get_drvdata(rdev);
struct regmap *regmap = rdev_get_regmap(rdev);
int ret;
if (!priv->enable_gpio)
return 0;
gpiod_direction_output(priv->enable_gpio, 1);
usleep_range(RT6245_ENTIME_IN_US, RT6245_ENTIME_IN_US + 1000);
regcache_cache_only(regmap, false);
ret = regcache_sync(regmap);
if (ret)
return ret;
priv->enable_state = true;
return 0;
}
static int rt6245_disable(struct regulator_dev *rdev)
{
struct rt6245_priv *priv = rdev_get_drvdata(rdev);
struct regmap *regmap = rdev_get_regmap(rdev);
if (!priv->enable_gpio)
return -EINVAL;
regcache_cache_only(regmap, true);
regcache_mark_dirty(regmap);
gpiod_direction_output(priv->enable_gpio, 0);
priv->enable_state = false;
return 0;
}
static int rt6245_is_enabled(struct regulator_dev *rdev)
{
struct rt6245_priv *priv = rdev_get_drvdata(rdev);
return priv->enable_state ? 1 : 0;
}
static const struct regulator_ops rt6245_regulator_ops = {
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_ramp_delay = regulator_set_ramp_delay_regmap,
.enable = rt6245_enable,
.disable = rt6245_disable,
.is_enabled = rt6245_is_enabled,
};
/* ramp delay dividend is 12500 uV/uS, and divisor from 1 to 8 */
static const unsigned int rt6245_ramp_delay_table[] = {
12500, 6250, 4167, 3125, 2500, 2083, 1786, 1562
};
static const struct regulator_desc rt6245_regulator_desc = {
.name = "rt6245-regulator",
.ops = &rt6245_regulator_ops,
.type = REGULATOR_VOLTAGE,
.min_uV = RT6245_VOUT_MINUV,
.uV_step = RT6245_VOUT_STEPUV,
.n_voltages = RT6245_NUM_VOUT,
.ramp_delay_table = rt6245_ramp_delay_table,
.n_ramp_values = ARRAY_SIZE(rt6245_ramp_delay_table),
.owner = THIS_MODULE,
.vsel_reg = RT6245_VIRT_VOUT,
.vsel_mask = RT6245_VOUT_MASK,
.ramp_reg = RT6245_VIRT_SLEWRATE,
.ramp_mask = RT6245_SLEW_MASK,
};
static int rt6245_init_device_properties(struct device *dev)
{
const struct {
const char *name;
unsigned int reg;
} rt6245_props[] = {
{ "richtek,oc-level-select", RT6245_VIRT_OCLIMIT },
{ "richtek,ot-level-select", RT6245_VIRT_OTLEVEL },
{ "richtek,pgdly-time-select", RT6245_VIRT_PGDLYTIME },
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/driver.h`.
- Detected declarations: `struct rt6245_priv`, `function rt6245_enable`, `function rt6245_disable`, `function rt6245_is_enabled`, `function rt6245_init_device_properties`, `function rt6245_reg_write`, `function rt6245_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: source implementation candidate.
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.