drivers/regulator/max77650-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/max77650-regulator.c
Extension
.c
Size
13144 bytes
Lines
406
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 max77650_regulator_desc {
	struct regulator_desc desc;
	unsigned int regA;
	unsigned int regB;
};

static const unsigned int max77651_sbb1_volt_range_sel[] = {
	0x0, 0x1, 0x2, 0x3
};

static const struct linear_range max77651_sbb1_volt_ranges[] = {
	/* range index 0 */
	REGULATOR_LINEAR_RANGE(2400000, 0x00, 0x0f, 50000),
	/* range index 1 */
	REGULATOR_LINEAR_RANGE(3200000, 0x00, 0x0f, 50000),
	/* range index 2 */
	REGULATOR_LINEAR_RANGE(4000000, 0x00, 0x0f, 50000),
	/* range index 3 */
	REGULATOR_LINEAR_RANGE(4800000, 0x00, 0x09, 50000),
};

static const unsigned int max77650_current_limit_table[] = {
	1000000, 866000, 707000, 500000,
};

static int max77650_regulator_is_enabled(struct regulator_dev *rdev)
{
	const struct max77650_regulator_desc *rdesc;
	struct regmap *map;
	int val, rv, en;

	rdesc = container_of_const(rdev->desc, struct max77650_regulator_desc, desc);
	map = rdev_get_regmap(rdev);

	rv = regmap_read(map, rdesc->regB, &val);
	if (rv)
		return rv;

	en = MAX77650_REGULATOR_EN_CTRL_BITS(val);

	return en != MAX77650_REGULATOR_DISABLED;
}

static int max77650_regulator_enable(struct regulator_dev *rdev)
{
	const struct max77650_regulator_desc *rdesc;
	struct regmap *map;

	rdesc = container_of_const(rdev->desc, struct max77650_regulator_desc, desc);
	map = rdev_get_regmap(rdev);

	return regmap_update_bits(map, rdesc->regB,
				  MAX77650_REGULATOR_EN_CTRL_MASK,
				  MAX77650_REGULATOR_ENABLED);
}

static int max77650_regulator_disable(struct regulator_dev *rdev)
{
	const struct max77650_regulator_desc *rdesc;
	struct regmap *map;

	rdesc = container_of_const(rdev->desc, struct max77650_regulator_desc, desc);
	map = rdev_get_regmap(rdev);

	return regmap_update_bits(map, rdesc->regB,
				  MAX77650_REGULATOR_EN_CTRL_MASK,
				  MAX77650_REGULATOR_DISABLED);
}

static const struct regulator_ops max77650_regulator_LDO_ops = {
	.is_enabled		= max77650_regulator_is_enabled,
	.enable			= max77650_regulator_enable,
	.disable		= max77650_regulator_disable,
	.list_voltage		= regulator_list_voltage_linear,
	.map_voltage		= regulator_map_voltage_linear,
	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
	.set_active_discharge	= regulator_set_active_discharge_regmap,
};

static const struct regulator_ops max77650_regulator_SBB_ops = {
	.is_enabled		= max77650_regulator_is_enabled,
	.enable			= max77650_regulator_enable,
	.disable		= max77650_regulator_disable,
	.list_voltage		= regulator_list_voltage_linear,
	.map_voltage		= regulator_map_voltage_linear,
	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
	.get_current_limit	= regulator_get_current_limit_regmap,
	.set_current_limit	= regulator_set_current_limit_regmap,

Annotation

Implementation Notes