drivers/regulator/tps65132-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/tps65132-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/tps65132-regulator.c- Extension
.c- Size
- 8110 bytes
- Lines
- 292
- 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/delay.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.h
Detected Declarations
struct tps65132_reg_pdatastruct tps65132_regulatorfunction tps65132_regulator_enablefunction tps65132_regulator_disablefunction tps65132_regulator_is_enabledfunction tps65132_of_parse_cbfunction tps65132_probe
Annotated Snippet
struct tps65132_reg_pdata {
struct gpio_desc *en_gpiod;
struct gpio_desc *act_dis_gpiod;
unsigned int act_dis_time_us;
int ena_gpio_state;
};
struct tps65132_regulator {
struct device *dev;
struct tps65132_reg_pdata reg_pdata[TPS65132_MAX_REGULATORS];
};
static int tps65132_regulator_enable(struct regulator_dev *rdev)
{
struct tps65132_regulator *tps = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[id];
int ret;
if (!IS_ERR(rpdata->en_gpiod)) {
gpiod_set_value_cansleep(rpdata->en_gpiod, 1);
rpdata->ena_gpio_state = 1;
}
/* Hardware automatically enable discharge bit in enable */
if (rdev->constraints->active_discharge ==
REGULATOR_ACTIVE_DISCHARGE_DISABLE) {
ret = regulator_set_active_discharge_regmap(rdev, false);
if (ret < 0) {
dev_err(tps->dev, "Failed to disable active discharge: %d\n",
ret);
return ret;
}
}
return 0;
}
static int tps65132_regulator_disable(struct regulator_dev *rdev)
{
struct tps65132_regulator *tps = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[id];
if (!IS_ERR(rpdata->en_gpiod)) {
gpiod_set_value_cansleep(rpdata->en_gpiod, 0);
rpdata->ena_gpio_state = 0;
}
if (!IS_ERR(rpdata->act_dis_gpiod)) {
gpiod_set_value_cansleep(rpdata->act_dis_gpiod, 1);
usleep_range(rpdata->act_dis_time_us, rpdata->act_dis_time_us +
TPS65132_ACT_DIS_TIME_SLACK);
gpiod_set_value_cansleep(rpdata->act_dis_gpiod, 0);
}
return 0;
}
static int tps65132_regulator_is_enabled(struct regulator_dev *rdev)
{
struct tps65132_regulator *tps = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[id];
if (!IS_ERR(rpdata->en_gpiod))
return rpdata->ena_gpio_state;
return 1;
}
static const struct regulator_ops tps65132_regulator_ops = {
.enable = tps65132_regulator_enable,
.disable = tps65132_regulator_disable,
.is_enabled = tps65132_regulator_is_enabled,
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.set_active_discharge = regulator_set_active_discharge_regmap,
};
static int tps65132_of_parse_cb(struct device_node *np,
const struct regulator_desc *desc,
struct regulator_config *config)
{
struct tps65132_regulator *tps = config->driver_data;
struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[desc->id];
int ret;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`.
- Detected declarations: `struct tps65132_reg_pdata`, `struct tps65132_regulator`, `function tps65132_regulator_enable`, `function tps65132_regulator_disable`, `function tps65132_regulator_is_enabled`, `function tps65132_of_parse_cb`, `function tps65132_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.