drivers/regulator/tps6286x-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/tps6286x-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/tps6286x-regulator.c- Extension
.c- Size
- 4192 bytes
- Lines
- 170
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/i2c.hlinux/module.hlinux/of.hlinux/regmap.hlinux/regulator/of_regulator.hlinux/regulator/machine.hlinux/regulator/driver.hdt-bindings/regulator/ti,tps62864.h
Detected Declarations
function tps6286x_volatile_regfunction tps6286x_set_modefunction tps6286x_get_modefunction tps6286x_of_map_modefunction tps6286x_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Copyright Axis Communications AB
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#include <dt-bindings/regulator/ti,tps62864.h>
#define TPS6286X_VOUT1 0x01
#define TPS6286X_VOUT1_VO1_SET GENMASK(7, 0)
#define TPS6286X_CONTROL 0x03
#define TPS6286X_CONTROL_FPWM BIT(4)
#define TPS6286X_CONTROL_SWEN BIT(5)
#define TPS6286X_STATUS 0x05
#define TPS6286X_MIN_MV 400
#define TPS6286X_MAX_MV 1675
#define TPS6286X_STEP_MV 5
static bool tps6286x_volatile_reg(struct device *dev, unsigned int reg)
{
return reg == TPS6286X_STATUS;
}
static const struct regmap_config tps6286x_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.cache_type = REGCACHE_MAPLE,
.volatile_reg = tps6286x_volatile_reg,
};
static int tps6286x_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
unsigned int val;
switch (mode) {
case REGULATOR_MODE_NORMAL:
val = 0;
break;
case REGULATOR_MODE_FAST:
val = TPS6286X_CONTROL_FPWM;
break;
default:
return -EINVAL;
}
return regmap_update_bits(rdev->regmap, TPS6286X_CONTROL,
TPS6286X_CONTROL_FPWM, val);
}
static unsigned int tps6286x_get_mode(struct regulator_dev *rdev)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, TPS6286X_CONTROL, &val);
if (ret < 0)
return 0;
return (val & TPS6286X_CONTROL_FPWM) ? REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
}
static const struct regulator_ops tps6286x_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.set_mode = tps6286x_set_mode,
.get_mode = tps6286x_get_mode,
.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,
};
static unsigned int tps6286x_of_map_mode(unsigned int mode)
{
switch (mode) {
case TPS62864_MODE_NORMAL:
return REGULATOR_MODE_NORMAL;
case TPS62864_MODE_FPWM:
return REGULATOR_MODE_FAST;
default:
return REGULATOR_MODE_INVALID;
Annotation
- Immediate include surface: `linux/err.h`, `linux/i2c.h`, `linux/module.h`, `linux/of.h`, `linux/regmap.h`, `linux/regulator/of_regulator.h`, `linux/regulator/machine.h`, `linux/regulator/driver.h`.
- Detected declarations: `function tps6286x_volatile_reg`, `function tps6286x_set_mode`, `function tps6286x_get_mode`, `function tps6286x_of_map_mode`, `function tps6286x_i2c_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.