Re: [PATCH v2 2/2] regulator: adp5055: Add driver for adp5055

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 20, 2025 at 02:53:55PM +0800, Alexis Czezar Torreno wrote:
> +#define ADP5055_REG(_name, _id, _ch) \
> +	ADP5055_REG_(_name, _id, _ch, &adp5055_ops)
> +
> +static struct regulator_desc adp5055_regulators[] = {
> +	ADP5055_REG("DCDC0", 0, 0),
> +	ADP5055_REG("DCDC1", 1, 1),
> +	ADP5055_REG("DCDC2", 2, 2),

Nodenames are lowercase, always.

> +};
> +
> +static const struct of_device_id adp5055_dt_ids[] = {
> +	{ .compatible = "adi,adp5055"},
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, adp5055_dt_ids);
> +
> +static int adp5055_probe(struct i2c_client *client)
> +{
> +	struct regulator_init_data *init_data;
> +	struct device *dev = &client->dev;
> +	struct adp5055 *adp5055;
> +	int i, ret;
> +
> +	init_data = of_get_regulator_init_data(dev, client->dev.of_node,
> +					       &adp5055_regulators[0]);
> +	if (!init_data)
> +		return -EINVAL;
> +
> +	adp5055 = devm_kzalloc(dev, sizeof(struct adp5055), GFP_KERNEL);
> +	if (!adp5055)
> +		return -ENOMEM;
> +
> +	adp5055->regmap = devm_regmap_init_i2c(client, &adp5055_regmap_config);
> +	if (IS_ERR(adp5055->regmap))
> +		return dev_err_probe(dev, PTR_ERR(adp5055->regmap), "Failed to allocate reg map");
> +
> +	for (i = 0; i < ADP5055_NUM_CH; i++) {
> +		const struct regulator_desc *desc;
> +		struct regulator_config config = { };
> +		struct regulator_dev *rdev;
> +

Where do you parse the 'reg' which you said is a channel number in the
binding?

> +		if (adp5055->tset == 2600)
> +			adp5055_regulators[i].ramp_delay_table = adp5055_enable_delay_vals_2_6;
> +		else
> +			adp5055_regulators[i].ramp_delay_table = adp5055_enable_delay_vals_20_8;
> +
> +		desc = &adp5055_regulators[i];
> +
> +		config.dev = dev;
> +		config.driver_data = adp5055;
> +		config.regmap = adp5055->regmap;
> +		config.init_data = init_data;
> +
> +		if (adp5055->hw_en_array_gpios)
> +			config.ena_gpiod = adp5055->hw_en_array_gpios->desc[i];

So a GPIO per node thus enable-gpios in each node.

Best regards,
Krzysztof





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux