drivers/regulator/rtq6752-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/rtq6752-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/rtq6752-regulator.c- Extension
.c- Size
- 7748 bytes
- Lines
- 291
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/mutex.hlinux/regmap.hlinux/regulator/driver.h
Detected Declarations
struct rtq6752_privfunction rtq6752_set_vdd_enablefunction rtq6752_set_vdd_disablefunction rtq6752_get_error_flagsfunction rtq6752_init_device_propertiesfunction rtq6752_is_volatile_regfunction rtq6752_probe
Annotated Snippet
struct rtq6752_priv {
struct regmap *regmap;
struct gpio_desc *enable_gpio;
struct mutex lock;
unsigned char enable_flag;
};
static int rtq6752_set_vdd_enable(struct regulator_dev *rdev)
{
struct rtq6752_priv *priv = rdev_get_drvdata(rdev);
int rid = rdev_get_id(rdev), ret;
mutex_lock(&priv->lock);
if (!priv->enable_flag) {
if (priv->enable_gpio) {
gpiod_set_value(priv->enable_gpio, 1);
usleep_range(RTQ6752_I2CRDY_TIMEUS,
RTQ6752_I2CRDY_TIMEUS + 100);
}
regcache_cache_only(priv->regmap, false);
ret = regcache_sync(priv->regmap);
if (ret) {
mutex_unlock(&priv->lock);
return ret;
}
}
priv->enable_flag |= BIT(rid);
mutex_unlock(&priv->lock);
return regulator_enable_regmap(rdev);
}
static int rtq6752_set_vdd_disable(struct regulator_dev *rdev)
{
struct rtq6752_priv *priv = rdev_get_drvdata(rdev);
int rid = rdev_get_id(rdev), ret;
ret = regulator_disable_regmap(rdev);
if (ret)
return ret;
mutex_lock(&priv->lock);
priv->enable_flag &= ~BIT(rid);
if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, true);
regcache_mark_dirty(priv->regmap);
if (priv->enable_gpio)
gpiod_set_value(priv->enable_gpio, 0);
}
mutex_unlock(&priv->lock);
return 0;
}
static int rtq6752_get_error_flags(struct regulator_dev *rdev,
unsigned int *flags)
{
unsigned int val, events = 0;
static const unsigned int fault_mask[] = {
RTQ6752_PAVDDF_MASK, RTQ6752_NAVDDF_MASK };
int rid = rdev_get_id(rdev), ret;
ret = regmap_read(rdev->regmap, RTQ6752_REG_FAULT, &val);
if (ret)
return ret;
if (val & fault_mask[rid])
events = REGULATOR_ERROR_REGULATION_OUT;
*flags = events;
return 0;
}
static const struct regulator_ops rtq6752_regulator_ops = {
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.enable = rtq6752_set_vdd_enable,
.disable = rtq6752_set_vdd_disable,
.is_enabled = regulator_is_enabled_regmap,
.set_active_discharge = regulator_set_active_discharge_regmap,
.get_error_flags = rtq6752_get_error_flags,
};
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/regmap.h`.
- Detected declarations: `struct rtq6752_priv`, `function rtq6752_set_vdd_enable`, `function rtq6752_set_vdd_disable`, `function rtq6752_get_error_flags`, `function rtq6752_init_device_properties`, `function rtq6752_is_volatile_reg`, `function rtq6752_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.