drivers/regulator/tps6594-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/tps6594-regulator.c
Extension
.c
Size
29221 bytes
Lines
846
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 tps6594_regulator_irq_type {
	const char *irq_name;
	const char *regulator_name;
	const char *event_name;
	unsigned long event;
};

static const struct tps6594_regulator_irq_type tps6594_ext_regulator_irq_types[] = {
	{ TPS6594_IRQ_NAME_VCCA_OV, "VCCA", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
	{ TPS6594_IRQ_NAME_VCCA_UV, "VCCA", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
	{ TPS6594_IRQ_NAME_VMON1_OV, "VMON1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
	{ TPS6594_IRQ_NAME_VMON1_UV, "VMON1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
	{ TPS6594_IRQ_NAME_VMON1_RV, "VMON1", "residual voltage",
	  REGULATOR_EVENT_OVER_VOLTAGE_WARN },
	{ TPS6594_IRQ_NAME_VMON2_OV, "VMON2", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
	{ TPS6594_IRQ_NAME_VMON2_UV, "VMON2", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
	{ TPS6594_IRQ_NAME_VMON2_RV, "VMON2", "residual voltage",
	  REGULATOR_EVENT_OVER_VOLTAGE_WARN },
};

static const struct tps6594_regulator_irq_type tps65224_ext_regulator_irq_types[] = {
	{ TPS65224_IRQ_NAME_VCCA_UVOV, "VCCA", "voltage out of range",
	  REGULATOR_EVENT_REGULATION_OUT },
	{ TPS65224_IRQ_NAME_VMON1_UVOV, "VMON1", "voltage out of range",
	  REGULATOR_EVENT_REGULATION_OUT },
	{ TPS65224_IRQ_NAME_VMON2_UVOV, "VMON2", "voltage out of range",
	  REGULATOR_EVENT_REGULATION_OUT },
};

struct tps6594_regulator_irq_data {
	struct device *dev;
	const struct tps6594_regulator_irq_type *type;
	struct regulator_dev *rdev;
};

struct tps6594_ext_regulator_irq_data {
	struct device *dev;
	const struct tps6594_regulator_irq_type *type;
};

#define TPS6594_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \
			   _em, _cr, _cm, _lr, _nlr, _delay, _fuv, \
			   _ct, _ncl, _bpm) \
	{								\
		.name			= _name,			\
		.of_match		= _of,				\
		.regulators_node	= of_match_ptr("regulators"),	\
		.supply_name		= _of,				\
		.id			= _id,				\
		.ops			= &(_ops),			\
		.n_voltages		= _n,				\
		.type			= _type,			\
		.owner			= THIS_MODULE,			\
		.vsel_reg		= _vr,				\
		.vsel_mask		= _vm,				\
		.csel_reg		= _cr,				\
		.csel_mask		= _cm,				\
		.curr_table		= _ct,				\
		.n_current_limits	= _ncl,				\
		.enable_reg		= _er,				\
		.enable_mask		= _em,				\
		.volt_table		= NULL,				\
		.linear_ranges		= _lr,				\
		.n_linear_ranges	= _nlr,				\
		.ramp_delay		= _delay,			\
		.fixed_uV		= _fuv,				\
		.bypass_reg		= _vr,				\
		.bypass_mask		= _bpm,				\
	}								\

static const struct linear_range bucks_ranges[] = {
	REGULATOR_LINEAR_RANGE(300000, 0x0, 0xe, 20000),
	REGULATOR_LINEAR_RANGE(600000, 0xf, 0x72, 5000),
	REGULATOR_LINEAR_RANGE(1100000, 0x73, 0xaa, 10000),
	REGULATOR_LINEAR_RANGE(1660000, 0xab, 0xff, 20000),
};

static const struct linear_range ldos_1_2_3_ranges[] = {
	REGULATOR_LINEAR_RANGE(600000, 0x4, 0x3a, 50000),
};

static const struct linear_range ldos_4_ranges[] = {
	REGULATOR_LINEAR_RANGE(1200000, 0x20, 0x74, 25000),
};

/* Voltage range for TPS65224 Bucks and LDOs */
static const struct linear_range tps65224_bucks_1_ranges[] = {
	REGULATOR_LINEAR_RANGE(500000, 0x0a, 0x0e, 20000),
	REGULATOR_LINEAR_RANGE(600000, 0x0f, 0x72, 5000),
	REGULATOR_LINEAR_RANGE(1100000, 0x73, 0xaa, 10000),

Annotation

Implementation Notes