drivers/regulator/da9121-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/da9121-regulator.c
Extension
.c
Size
35914 bytes
Lines
1226
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 da9121 {
	struct device *dev;
	struct delayed_work work;
	struct da9121_pdata *pdata;
	struct regmap *regmap;
	struct regulator_dev *rdev[DA9121_IDX_MAX];
	unsigned int persistent[2];
	unsigned int passive_delay;
	int chip_irq;
	int variant_id;
	int subvariant_id;
};

/* Define ranges for different variants, enabling translation to/from
 * registers. Maximums give scope to allow for transients.
 */
struct da9121_range {
	int val_min;
	int val_max;
	int val_stp;
	int reg_min;
	int reg_max;
};

static const struct da9121_range da9121_10A_2phase_current = {
	.val_min =  7000000,
	.val_max = 20000000,
	.val_stp =  1000000,
	.reg_min = 1,
	.reg_max = 14,
};

static const struct da9121_range da9121_6A_2phase_current = {
	.val_min =  7000000,
	.val_max = 12000000,
	.val_stp =  1000000,
	.reg_min = 1,
	.reg_max = 6,
};

static const struct da9121_range da9121_5A_1phase_current = {
	.val_min =  3500000,
	.val_max = 10000000,
	.val_stp =   500000,
	.reg_min = 1,
	.reg_max = 14,
};

static const struct da9121_range da9121_3A_1phase_current = {
	.val_min = 3500000,
	.val_max = 6000000,
	.val_stp =  500000,
	.reg_min = 1,
	.reg_max = 6,
};

static const struct da9121_range da914x_40A_4phase_current = {
	.val_min = 26000000,
	.val_max = 78000000,
	.val_stp =  4000000,
	.reg_min = 1,
	.reg_max = 14,
};

static const struct da9121_range da914x_20A_2phase_current = {
	.val_min = 13000000,
	.val_max = 39000000,
	.val_stp =  2000000,
	.reg_min = 1,
	.reg_max = 14,
};

struct da9121_variant_info {
	int num_bucks;
	int num_phases;
	const struct da9121_range *current_range;
};

static const struct da9121_variant_info variant_parameters[] = {
	{ 1, 2, &da9121_10A_2phase_current },	//DA9121_TYPE_DA9121_DA9130
	{ 2, 1, &da9121_3A_1phase_current  },	//DA9121_TYPE_DA9220_DA9132
	{ 2, 1, &da9121_5A_1phase_current  },	//DA9121_TYPE_DA9122_DA9131
	{ 1, 2, &da9121_6A_2phase_current  },	//DA9121_TYPE_DA9217
	{ 1, 4, &da914x_40A_4phase_current },   //DA9121_TYPE_DA9141
	{ 1, 2, &da914x_20A_2phase_current },   //DA9121_TYPE_DA9142
};

struct da9121_field {
	unsigned int reg;
	unsigned int msk;

Annotation

Implementation Notes