drivers/regulator/mtk-dvfsrc-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/mtk-dvfsrc-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/mtk-dvfsrc-regulator.c- Extension
.c- Size
- 5900 bytes
- Lines
- 235
- 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/module.hlinux/platform_device.hlinux/of.hlinux/regulator/driver.hlinux/regulator/of_regulator.hlinux/soc/mediatek/dvfsrc.h
Detected Declarations
struct dvfsrc_regulator_pdataenum dvfsrc_regulator_idfunction dvfsrc_get_cmdfunction dvfsrc_set_voltage_selfunction dvfsrc_get_voltage_selfunction dvfsrc_vcore_regulator_probe
Annotated Snippet
struct dvfsrc_regulator_pdata {
const struct regulator_desc *descs;
u32 size;
};
#define MTK_DVFSRC_VREG(match, _name, _volt_table) \
{ \
.name = match, \
.of_match = match, \
.ops = &dvfsrc_vcore_ops, \
.type = REGULATOR_VOLTAGE, \
.id = DVFSRC_ID_##_name, \
.owner = THIS_MODULE, \
.n_voltages = ARRAY_SIZE(_volt_table), \
.volt_table = _volt_table, \
}
static inline struct device *to_dvfs_regulator_dev(struct regulator_dev *rdev)
{
return rdev_get_dev(rdev)->parent;
}
static inline struct device *to_dvfsrc_dev(struct regulator_dev *rdev)
{
return to_dvfs_regulator_dev(rdev)->parent;
}
static int dvfsrc_get_cmd(int rdev_id, enum mtk_dvfsrc_cmd *cmd)
{
switch (rdev_id) {
case DVFSRC_ID_VCORE:
*cmd = MTK_DVFSRC_CMD_VCORE_LEVEL;
break;
case DVFSRC_ID_VSCP:
*cmd = MTK_DVFSRC_CMD_VSCP_LEVEL;
break;
default:
return -EINVAL;
}
return 0;
}
static int dvfsrc_set_voltage_sel(struct regulator_dev *rdev,
unsigned int selector)
{
struct device *dvfsrc_dev = to_dvfsrc_dev(rdev);
enum mtk_dvfsrc_cmd req_cmd;
int id = rdev_get_id(rdev);
int ret;
ret = dvfsrc_get_cmd(id, &req_cmd);
if (ret)
return ret;
return mtk_dvfsrc_send_request(dvfsrc_dev, req_cmd, selector);
}
static int dvfsrc_get_voltage_sel(struct regulator_dev *rdev)
{
struct device *dvfsrc_dev = to_dvfsrc_dev(rdev);
enum mtk_dvfsrc_cmd query_cmd;
int id = rdev_get_id(rdev);
int val, ret;
ret = dvfsrc_get_cmd(id, &query_cmd);
if (ret)
return ret;
ret = mtk_dvfsrc_query_info(dvfsrc_dev, query_cmd, &val);
if (ret)
return ret;
return val;
}
static const struct regulator_ops dvfsrc_vcore_ops = {
.list_voltage = regulator_list_voltage_table,
.get_voltage_sel = dvfsrc_get_voltage_sel,
.set_voltage_sel = dvfsrc_set_voltage_sel,
};
static const unsigned int mt6873_voltages[] = {
575000,
600000,
650000,
725000,
};
static const struct regulator_desc mt6873_regulators[] = {
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/of.h`, `linux/regulator/driver.h`, `linux/regulator/of_regulator.h`, `linux/soc/mediatek/dvfsrc.h`.
- Detected declarations: `struct dvfsrc_regulator_pdata`, `enum dvfsrc_regulator_id`, `function dvfsrc_get_cmd`, `function dvfsrc_set_voltage_sel`, `function dvfsrc_get_voltage_sel`, `function dvfsrc_vcore_regulator_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.