drivers/regulator/hi6421v530-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/hi6421v530-regulator.c
Extension
.c
Size
5771 bytes
Lines
207
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 hi6421v530_regulator_info {
	struct regulator_desc rdesc;
	u8 mode_mask;
};

/* HI6421v530 regulators */
enum hi6421v530_regulator_id {
	HI6421V530_LDO3,
	HI6421V530_LDO9,
	HI6421V530_LDO11,
	HI6421V530_LDO15,
	HI6421V530_LDO16,
};

static const unsigned int ldo_3_voltages[] = {
	1800000, 1825000, 1850000, 1875000,
	1900000, 1925000, 1950000, 1975000,
	2000000, 2025000, 2050000, 2075000,
	2100000, 2125000, 2150000, 2200000,
};

static const unsigned int ldo_9_11_voltages[] = {
	1750000, 1800000, 1825000, 2800000,
	2850000, 2950000, 3000000, 3300000,
};

static const unsigned int ldo_15_16_voltages[] = {
	1750000, 1800000, 2400000, 2600000,
	2700000, 2850000, 2950000, 3000000,
};

static const struct regulator_ops hi6421v530_ldo_ops;

#define HI6421V530_LDO_ENABLE_TIME (350)

/*
 * _id - LDO id name string
 * v_table - voltage table
 * vreg - voltage select register
 * vmask - voltage select mask
 * ereg - enable register
 * emask - enable mask
 * odelay - off/on delay time in uS
 * ecomask - eco mode mask
 */
#define HI6421V530_LDO(_ID, v_table, vreg, vmask, ereg, emask,		\
		   odelay, ecomask) {					\
	.rdesc = {							\
		.name		 = #_ID,				\
		.of_match        = of_match_ptr(#_ID),			\
		.regulators_node = of_match_ptr("regulators"),		\
		.ops		 = &hi6421v530_ldo_ops,			\
		.type		 = REGULATOR_VOLTAGE,			\
		.id		 = HI6421V530_##_ID,			\
		.owner		 = THIS_MODULE,				\
		.n_voltages	 = ARRAY_SIZE(v_table),			\
		.volt_table	 = v_table,				\
		.vsel_reg	 = HI6421_REG_TO_BUS_ADDR(vreg),	\
		.vsel_mask	 = vmask,				\
		.enable_reg	 = HI6421_REG_TO_BUS_ADDR(ereg),	\
		.enable_mask	 = emask,				\
		.enable_time	 = HI6421V530_LDO_ENABLE_TIME,		\
		.off_on_delay	 = odelay,				\
	},								\
	.mode_mask	= ecomask,					\
}

/* HI6421V530 regulator information */

static const struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
	HI6421V530_LDO(LDO3, ldo_3_voltages, 0x061, 0xf, 0x060, 0x2,
		   20000, 0x6),
	HI6421V530_LDO(LDO9, ldo_9_11_voltages, 0x06b, 0x7, 0x06a, 0x2,
		   40000, 0x6),
	HI6421V530_LDO(LDO11, ldo_9_11_voltages, 0x06f, 0x7, 0x06e, 0x2,
		   40000, 0x6),
	HI6421V530_LDO(LDO15, ldo_15_16_voltages, 0x077, 0x7, 0x076, 0x2,
		   40000, 0x6),
	HI6421V530_LDO(LDO16, ldo_15_16_voltages, 0x079, 0x7, 0x078, 0x2,
		   40000, 0x6),
};

static unsigned int hi6421v530_regulator_ldo_get_mode(
					struct regulator_dev *rdev)
{
	const struct hi6421v530_regulator_info *info;
	unsigned int reg_val;

	info = container_of_const(rdev->desc, struct hi6421v530_regulator_info, rdesc);
	regmap_read(rdev->regmap, rdev->desc->enable_reg, &reg_val);

Annotation

Implementation Notes