drivers/regulator/mpq7920.c

Source file repositories/reference/linux-study-clean/drivers/regulator/mpq7920.c

File Facts

System
Linux kernel
Corpus path
drivers/regulator/mpq7920.c
Extension
.c
Size
9713 bytes
Lines
331
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mpq7920_regulator_info {
	struct regmap *regmap;
	struct regulator_desc *rdesc;
};

static const struct regmap_config mpq7920_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
	.max_register = 0x25,
};

/* Current limits array (in uA)
 * ILIM1 & ILIM3
 */
static const unsigned int mpq7920_I_limits1[] = {
	4600000, 6600000, 7600000, 9300000
};

/* ILIM2 & ILIM4 */
static const unsigned int mpq7920_I_limits2[] = {
	2700000, 3900000, 5100000, 6100000
};

/* LDO4 & LDO5 */
static const unsigned int mpq7920_I_limits3[] = {
	300000, 700000
};

static int mpq7920_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay);
static int mpq7920_parse_cb(struct device_node *np,
				const struct regulator_desc *rdesc,
				struct regulator_config *config);

/* RTCLDO not controllable, always ON */
static const struct regulator_ops mpq7920_ldortc_ops = {
	.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,
};

static const struct regulator_ops mpq7920_ldo_wo_current_ops = {
	.enable			= regulator_enable_regmap,
	.disable		= regulator_disable_regmap,
	.is_enabled		= regulator_is_enabled_regmap,
	.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 const struct regulator_ops mpq7920_ldo_ops = {
	.enable			= regulator_enable_regmap,
	.disable		= regulator_disable_regmap,
	.is_enabled		= regulator_is_enabled_regmap,
	.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,
	.get_current_limit	= regulator_get_current_limit_regmap,
	.set_current_limit	= regulator_set_current_limit_regmap,
};

static const struct regulator_ops mpq7920_buck_ops = {
	.enable			= regulator_enable_regmap,
	.disable		= regulator_disable_regmap,
	.is_enabled		= regulator_is_enabled_regmap,
	.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,
	.set_soft_start		= regulator_set_soft_start_regmap,
	.set_ramp_delay		= mpq7920_set_ramp_delay,
};

static struct regulator_desc mpq7920_regulators_desc[MPQ7920_MAX_REGULATORS] = {
	MPQ7920BUCK("buck1", 1, mpq7920_I_limits1),
	MPQ7920BUCK("buck2", 2, mpq7920_I_limits2),
	MPQ7920BUCK("buck3", 3, mpq7920_I_limits1),
	MPQ7920BUCK("buck4", 4, mpq7920_I_limits2),
	MPQ7920LDO("ldortc", 1, &mpq7920_ldortc_ops, NULL, 0, 0, 0),
	MPQ7920LDO("ldo2", 2, &mpq7920_ldo_wo_current_ops, NULL, 0, 0, 0),
	MPQ7920LDO("ldo3", 3, &mpq7920_ldo_wo_current_ops, NULL, 0, 0, 0),
	MPQ7920LDO("ldo4", 4, &mpq7920_ldo_ops, mpq7920_I_limits3,
			ARRAY_SIZE(mpq7920_I_limits3), MPQ7920_LDO4_REG_B,
			MPQ7920_MASK_LDO_ILIM),
	MPQ7920LDO("ldo5", 5, &mpq7920_ldo_ops, mpq7920_I_limits3,

Annotation

Implementation Notes