drivers/regulator/max77826-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/max77826-regulator.c
Extension
.c
Size
8070 bytes
Lines
300
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 max77826_regulator_info {
	struct regmap *regmap;
};

static const struct regmap_config max77826_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
	.max_register = MAX77826_REG_DEVICE_ID,
};

static int max77826_set_voltage_time_sel(struct regulator_dev *,
				unsigned int old_selector,
				unsigned int new_selector);

static const struct regulator_ops max77826_most_ops = {
	.enable			= regulator_enable_regmap,
	.disable		= regulator_disable_regmap,
	.is_enabled		= regulator_is_enabled_regmap,
	.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,
};

static const struct regulator_ops max77826_buck_ops = {
	.enable			= regulator_enable_regmap,
	.disable		= regulator_disable_regmap,
	.is_enabled		= regulator_is_enabled_regmap,
	.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_voltage_time_sel	= max77826_set_voltage_time_sel,
};

static const struct regulator_desc max77826_regulators_desc[] = {
	MAX77826_LDO(1, NMOS),
	MAX77826_LDO(2, NMOS),
	MAX77826_LDO(3, NMOS),
	MAX77826_LDO(4, PMOS),
	MAX77826_LDO(5, PMOS),
	MAX77826_LDO(6, PMOS),
	MAX77826_LDO(7, PMOS),
	MAX77826_LDO(8, PMOS),
	MAX77826_LDO(9, PMOS),
	MAX77826_LDO(10, PMOS),
	MAX77826_LDO(11, PMOS),
	MAX77826_LDO(12, PMOS),
	MAX77826_LDO(13, PMOS),
	MAX77826_LDO(14, PMOS),
	MAX77826_LDO(15, PMOS),
	MAX77826_BUCK(0, BUCK, max77826_buck_ops),
	MAX77826_BUCK(1, BUCKBOOST, max77826_most_ops),
};

static int max77826_set_voltage_time_sel(struct regulator_dev *rdev,
				unsigned int old_selector,
				unsigned int new_selector)
{
	if (new_selector > old_selector) {
		return DIV_ROUND_UP(MAX77826_BUCK_VOLT_STEP *
				(new_selector - old_selector),
				MAX77826_BUCK_RAMP_DELAY);
	}

	return 0;
}

static int max77826_read_device_id(struct regmap *regmap, struct device *dev)
{
	unsigned int device_id;
	int res;

	res = regmap_read(regmap, MAX77826_REG_DEVICE_ID, &device_id);
	if (!res)
		dev_dbg(dev, "DEVICE_ID: 0x%x\n", device_id);

	return res;
}

static int max77826_i2c_probe(struct i2c_client *client)
{
	struct device *dev = &client->dev;
	struct max77826_regulator_info *info;
	struct regulator_config config = {};
	struct regulator_dev *rdev;
	struct regmap *regmap;
	int i;

	info = devm_kzalloc(dev, sizeof(struct max77826_regulator_info),

Annotation

Implementation Notes