drivers/regulator/max77620-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/max77620-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/max77620-regulator.c- Extension
.c- Size
- 25326 bytes
- Lines
- 928
- 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/init.hlinux/mfd/max77620.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
struct max77620_regulator_infostruct max77620_regulator_pdatastruct max77620_regulatorenum max77620_regulatorsenum max77620_regulator_typefunction max77620_regulator_get_fps_srcfunction max77620_regulator_set_fps_srcfunction max77620_regulator_set_fps_slotsfunction max77620_regulator_set_power_modefunction max77620_regulator_get_power_modefunction max77620_read_slew_ratefunction max77620_set_slew_ratefunction max77620_config_power_okfunction max77620_init_pmicfunction max77620_regulator_enablefunction max77620_regulator_disablefunction max77620_regulator_is_enabledfunction max77620_regulator_set_modefunction max77620_regulator_get_modefunction max77620_regulator_set_ramp_delayfunction max77620_of_parse_cbfunction max77620_regulator_probefunction max77620_regulator_suspendfunction max77620_regulator_resume
Annotated Snippet
struct max77620_regulator_info {
u8 type;
u8 fps_addr;
u8 volt_addr;
u8 cfg_addr;
u8 power_mode_mask;
u8 power_mode_shift;
u8 remote_sense_addr;
u8 remote_sense_mask;
struct regulator_desc desc;
};
struct max77620_regulator_pdata {
int active_fps_src;
int active_fps_pd_slot;
int active_fps_pu_slot;
int suspend_fps_src;
int suspend_fps_pd_slot;
int suspend_fps_pu_slot;
int current_mode;
int power_ok;
int ramp_rate_setting;
};
struct max77620_regulator {
struct device *dev;
struct regmap *rmap;
struct max77620_regulator_info *rinfo[MAX77620_NUM_REGS];
struct max77620_regulator_pdata reg_pdata[MAX77620_NUM_REGS];
int enable_power_mode[MAX77620_NUM_REGS];
int current_power_mode[MAX77620_NUM_REGS];
int active_fps_src[MAX77620_NUM_REGS];
};
#define fps_src_name(fps_src) \
(fps_src == MAX77620_FPS_SRC_0 ? "FPS_SRC_0" : \
fps_src == MAX77620_FPS_SRC_1 ? "FPS_SRC_1" : \
fps_src == MAX77620_FPS_SRC_2 ? "FPS_SRC_2" : "FPS_SRC_NONE")
static int max77620_regulator_get_fps_src(struct max77620_regulator *pmic,
int id)
{
struct max77620_regulator_info *rinfo = pmic->rinfo[id];
unsigned int val;
int ret;
ret = regmap_read(pmic->rmap, rinfo->fps_addr, &val);
if (ret < 0) {
dev_err(pmic->dev, "Reg 0x%02x read failed %d\n",
rinfo->fps_addr, ret);
return ret;
}
return (val & MAX77620_FPS_SRC_MASK) >> MAX77620_FPS_SRC_SHIFT;
}
static int max77620_regulator_set_fps_src(struct max77620_regulator *pmic,
int fps_src, int id)
{
struct max77620_regulator_info *rinfo = pmic->rinfo[id];
unsigned int val;
int ret;
if (!rinfo)
return 0;
switch (fps_src) {
case MAX77620_FPS_SRC_0:
case MAX77620_FPS_SRC_1:
case MAX77620_FPS_SRC_2:
case MAX77620_FPS_SRC_NONE:
break;
case MAX77620_FPS_SRC_DEF:
ret = regmap_read(pmic->rmap, rinfo->fps_addr, &val);
if (ret < 0) {
dev_err(pmic->dev, "Reg 0x%02x read failed %d\n",
rinfo->fps_addr, ret);
return ret;
}
ret = (val & MAX77620_FPS_SRC_MASK) >> MAX77620_FPS_SRC_SHIFT;
pmic->active_fps_src[id] = ret;
return 0;
default:
dev_err(pmic->dev, "Invalid FPS %d for regulator %d\n",
fps_src, id);
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/mfd/max77620.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`.
- Detected declarations: `struct max77620_regulator_info`, `struct max77620_regulator_pdata`, `struct max77620_regulator`, `enum max77620_regulators`, `enum max77620_regulator_type`, `function max77620_regulator_get_fps_src`, `function max77620_regulator_set_fps_src`, `function max77620_regulator_set_fps_slots`, `function max77620_regulator_set_power_mode`, `function max77620_regulator_get_power_mode`.
- 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.