drivers/regulator/mt6370-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/mt6370-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/mt6370-regulator.c- Extension
.c- Size
- 11185 bytes
- Lines
- 392
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bits.hlinux/gpio/consumer.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.h
Detected Declarations
struct mt6370_privfunction mt6370_get_error_flagsfunction mt6370_of_parse_cbfunction mt6370_scp_handlerfunction mt6370_ocp_handlerfunction mt6370_regulator_irq_registerfunction mt6370_regulator_registerfunction mt6370_regulator_probe
Annotated Snippet
struct mt6370_priv {
struct device *dev;
struct regmap *regmap;
struct regulator_dev *rdev[MT6370_MAX_IDX];
bool use_external_ctrl;
};
static const unsigned int mt6370_vpos_ramp_tbl[] = { 8540, 5840, 4830, 3000 };
static const unsigned int mt6370_vneg_ramp_tbl[] = { 10090, 6310, 5050, 3150 };
static int mt6370_get_error_flags(struct regulator_dev *rdev,
unsigned int *flags)
{
struct regmap *regmap = rdev_get_regmap(rdev);
unsigned int stat_reg, stat, rpt_flags = 0;
int rid = rdev_get_id(rdev), ret;
if (rid == MT6370_IDX_VIBLDO)
stat_reg = MT6370_REG_LDO_STAT;
else
stat_reg = MT6370_REG_DB_STAT;
ret = regmap_read(regmap, stat_reg, &stat);
if (ret)
return ret;
switch (rid) {
case MT6370_IDX_DSVBOOST:
if (stat & MT6370_BSTOCP_EVT_MASK)
rpt_flags |= REGULATOR_ERROR_OVER_CURRENT;
break;
case MT6370_IDX_DSVPOS:
if (stat & MT6370_POSSCP_EVT_MASK)
rpt_flags |= REGULATOR_ERROR_UNDER_VOLTAGE;
if (stat & MT6370_POSOCP_EVT_MASK)
rpt_flags |= REGULATOR_ERROR_OVER_CURRENT;
break;
case MT6370_IDX_DSVNEG:
if (stat & MT6370_NEGSCP_EVT_MASK)
rpt_flags |= REGULATOR_ERROR_UNDER_VOLTAGE;
if (stat & MT6370_NEGOCP_EVT_MASK)
rpt_flags |= REGULATOR_ERROR_OVER_CURRENT;
break;
default:
if (stat & MT6370_LDOOC_EVT_MASK)
rpt_flags |= REGULATOR_ERROR_OVER_CURRENT;
break;
}
*flags = rpt_flags;
return 0;
}
static const struct regulator_ops mt6370_dbvboost_ops = {
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
.get_bypass = regulator_get_bypass_regmap,
.set_bypass = regulator_set_bypass_regmap,
.get_error_flags = mt6370_get_error_flags,
};
static const struct regulator_ops mt6370_dbvout_ops = {
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.set_active_discharge = regulator_set_active_discharge_regmap,
.set_ramp_delay = regulator_set_ramp_delay_regmap,
.get_error_flags = mt6370_get_error_flags,
};
static const struct regulator_ops mt6370_ldo_ops = {
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.set_active_discharge = regulator_set_active_discharge_regmap,
.get_error_flags = mt6370_get_error_flags,
};
static int mt6370_of_parse_cb(struct device_node *np,
const struct regulator_desc *desc,
struct regulator_config *config)
Annotation
- Immediate include surface: `linux/bits.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct mt6370_priv`, `function mt6370_get_error_flags`, `function mt6370_of_parse_cb`, `function mt6370_scp_handler`, `function mt6370_ocp_handler`, `function mt6370_regulator_irq_register`, `function mt6370_regulator_register`, `function mt6370_regulator_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.