drivers/regulator/pv88090-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/pv88090-regulator.c
Extension
.c
Size
10477 bytes
Lines
412
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 pv88090_regulator {
	struct regulator_desc desc;
	unsigned int conf;
	unsigned int conf2;
};

struct pv88090 {
	struct device *dev;
	struct regmap *regmap;
	struct regulator_dev *rdev[PV88090_MAX_REGULATORS];
};

struct pv88090_buck_voltage {
	int min_uV;
	int max_uV;
	int uV_step;
};

static const struct regmap_config pv88090_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
};

/* Current limits array (in uA) for BUCK1, BUCK2, BUCK3.
 *  Entry indexes corresponds to register values.
 */

static const unsigned int pv88090_buck1_limits[] = {
	 220000,  440000,  660000,  880000, 1100000, 1320000, 1540000, 1760000,
	1980000, 2200000, 2420000, 2640000, 2860000, 3080000, 3300000, 3520000,
	3740000, 3960000, 4180000, 4400000, 4620000, 4840000, 5060000, 5280000,
	5500000, 5720000, 5940000, 6160000, 6380000, 6600000, 6820000, 7040000
};

static const unsigned int pv88090_buck23_limits[] = {
	1496000, 2393000, 3291000, 4189000
};

static const struct pv88090_buck_voltage pv88090_buck_vol[3] = {
	{
		.min_uV = 600000,
		.max_uV = 1393750,
		.uV_step = 6250,
	},

	{
		.min_uV = 1400000,
		.max_uV = 2193750,
		.uV_step = 6250,
	},
	{
		.min_uV = 1250000,
		.max_uV = 2837500,
		.uV_step = 12500,
	},
};

static unsigned int pv88090_buck_get_mode(struct regulator_dev *rdev)
{
	struct pv88090_regulator *info = rdev_get_drvdata(rdev);
	unsigned int data;
	int ret, mode = 0;

	ret = regmap_read(rdev->regmap, info->conf, &data);
	if (ret < 0)
		return ret;

	switch (data & PV88090_BUCK1_MODE_MASK) {
	case PV88090_BUCK_MODE_SYNC:
		mode = REGULATOR_MODE_FAST;
		break;
	case PV88090_BUCK_MODE_AUTO:
		mode = REGULATOR_MODE_NORMAL;
		break;
	case PV88090_BUCK_MODE_SLEEP:
		mode = REGULATOR_MODE_STANDBY;
		break;
	}

	return mode;
}

static int pv88090_buck_set_mode(struct regulator_dev *rdev,
					unsigned int mode)
{
	struct pv88090_regulator *info = rdev_get_drvdata(rdev);
	int val = 0;

	switch (mode) {
	case REGULATOR_MODE_FAST:

Annotation

Implementation Notes