drivers/regulator/mt6331-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/mt6331-regulator.c
Extension
.c
Size
17633 bytes
Lines
509
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 mt6331_regulator_info {
	struct regulator_desc desc;
	u32 qi;
	u32 vselon_reg;
	u32 vselctrl_reg;
	u32 vselctrl_mask;
	u32 modeset_reg;
	u32 modeset_mask;
	u32 status_reg;
	u32 status_mask;
};

#define MT6331_BUCK(match, vreg, min, max, step, volt_ranges, enreg,	\
		vosel, vosel_mask, voselon, vosel_ctrl)			\
[MT6331_ID_##vreg] = {							\
	.desc = {							\
		.name = #vreg,						\
		.of_match = of_match_ptr(match),			\
		.ops = &mt6331_volt_range_ops,				\
		.type = REGULATOR_VOLTAGE,				\
		.id = MT6331_ID_##vreg,					\
		.owner = THIS_MODULE,					\
		.n_voltages = (max - min)/step + 1,			\
		.linear_ranges = volt_ranges,				\
		.n_linear_ranges = ARRAY_SIZE(volt_ranges),		\
		.vsel_reg = vosel,					\
		.vsel_mask = vosel_mask,				\
		.enable_reg = enreg,					\
		.enable_mask = BIT(0),					\
	},								\
	.qi = BIT(13),							\
	.vselon_reg = voselon,						\
	.vselctrl_reg = vosel_ctrl,					\
	.vselctrl_mask = BIT(1),					\
	.status_mask = 0,						\
}

#define MT6331_LDO_AO(match, vreg, ldo_volt_table, vosel, vosel_mask)	\
[MT6331_ID_##vreg] = {							\
	.desc = {							\
		.name = #vreg,						\
		.of_match = of_match_ptr(match),			\
		.ops = &mt6331_volt_table_ao_ops,			\
		.type = REGULATOR_VOLTAGE,				\
		.id = MT6331_ID_##vreg,					\
		.owner = THIS_MODULE,					\
		.n_voltages = ARRAY_SIZE(ldo_volt_table),		\
		.volt_table = ldo_volt_table,				\
		.vsel_reg = vosel,					\
		.vsel_mask = vosel_mask,				\
	},								\
}

#define MT6331_LDO_S(match, vreg, ldo_volt_table, enreg, enbit, vosel,	\
		     vosel_mask, _modeset_reg, _modeset_mask,		\
		     _status_reg, _status_mask)				\
[MT6331_ID_##vreg] = {							\
	.desc = {							\
		.name = #vreg,						\
		.of_match = of_match_ptr(match),			\
		.ops = &mt6331_volt_table_no_qi_ops,			\
		.type = REGULATOR_VOLTAGE,				\
		.id = MT6331_ID_##vreg,					\
		.owner = THIS_MODULE,					\
		.n_voltages = ARRAY_SIZE(ldo_volt_table),		\
		.volt_table = ldo_volt_table,				\
		.vsel_reg = vosel,					\
		.vsel_mask = vosel_mask,				\
		.enable_reg = enreg,					\
		.enable_mask = BIT(enbit),				\
	},								\
	.modeset_reg = _modeset_reg,					\
	.modeset_mask = _modeset_mask,					\
	.status_reg = _status_reg,					\
	.status_mask = _status_mask,					\
}

#define MT6331_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel,	\
		   vosel_mask, _modeset_reg, _modeset_mask)		\
[MT6331_ID_##vreg] = {							\
	.desc = {							\
		.name = #vreg,						\
		.of_match = of_match_ptr(match),			\
		.ops = (_modeset_reg ?					\
			&mt6331_volt_table_ops :			\
			&mt6331_volt_table_no_ms_ops),			\
		.type = REGULATOR_VOLTAGE,				\
		.id = MT6331_ID_##vreg,					\
		.owner = THIS_MODULE,					\
		.n_voltages = ARRAY_SIZE(ldo_volt_table),		\

Annotation

Implementation Notes