Lines Matching +full:regulator +full:- +full:v6

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * max1586.c -- Voltage and current regulation for the Maxim 1586
11 #include <linux/regulator/driver.h>
13 #include <linux/regulator/max1586.h>
15 #include <linux/regulator/of_regulator.h>
41 * V6 voltage
43 * set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
44 * As regulator framework doesn't accept voltages to be 0V, we use 1uV.
60 return max1586->v3_curr_sel; in max1586_v3_get_voltage_sel()
67 struct i2c_client *client = max1586->client; in max1586_v3_set_voltage_sel()
71 dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", in max1586_v3_set_voltage_sel()
79 max1586->v3_curr_sel = selector; in max1586_v3_set_voltage_sel()
88 return max1586->v6_curr_sel; in max1586_v6_get_voltage_sel()
95 struct i2c_client *client = max1586->client; in max1586_v6_set_voltage_sel()
99 dev_dbg(&client->dev, "changing voltage v6 to %dmv\n", in max1586_v6_set_voltage_sel()
100 rdev->desc->volt_table[selector] / 1000); in max1586_v6_set_voltage_sel()
107 max1586->v6_curr_sel = selector; in max1586_v6_set_voltage_sel()
113 * The Maxim 1586 controls V3 and V6 voltages, but offers no way of reading back
154 struct device_node *np = dev->of_node; in of_get_max1586_platform_data()
157 if (of_property_read_u32(np, "v3-gain", in of_get_max1586_platform_data()
158 &pdata->v3_gain) < 0) { in of_get_max1586_platform_data()
159 dev_err(dev, "%pOF has no 'v3-gain' property\n", np); in of_get_max1586_platform_data()
160 return -EINVAL; in of_get_max1586_platform_data()
166 return -EINVAL; in of_get_max1586_platform_data()
184 pdata->subdevs = devm_kcalloc(dev, in of_get_max1586_platform_data()
188 if (!pdata->subdevs) in of_get_max1586_platform_data()
189 return -ENOMEM; in of_get_max1586_platform_data()
191 pdata->num_subdevs = matched; in of_get_max1586_platform_data()
192 sub = pdata->subdevs; in of_get_max1586_platform_data()
195 sub->id = i; in of_get_max1586_platform_data()
196 sub->name = rmatch[i].of_node->name; in of_get_max1586_platform_data()
197 sub->platform_data = rmatch[i].init_data; in of_get_max1586_platform_data()
217 pdata = dev_get_platdata(&client->dev); in max1586_pmic_probe()
218 if (client->dev.of_node && !pdata) { in max1586_pmic_probe()
219 ret = of_get_max1586_platform_data(&client->dev, &pdata_of); in max1586_pmic_probe()
225 max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data), in max1586_pmic_probe()
228 return -ENOMEM; in max1586_pmic_probe()
230 max1586->client = client; in max1586_pmic_probe()
232 if (!pdata->v3_gain) in max1586_pmic_probe()
233 return -EINVAL; in max1586_pmic_probe()
235 max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000; in max1586_pmic_probe()
236 max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000; in max1586_pmic_probe()
238 /* Set curr_sel to default voltage on power-up */ in max1586_pmic_probe()
239 max1586->v3_curr_sel = 24; /* 1.3V */ in max1586_pmic_probe()
240 max1586->v6_curr_sel = 0; in max1586_pmic_probe()
242 for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) { in max1586_pmic_probe()
245 id = pdata->subdevs[i].id; in max1586_pmic_probe()
246 if (!pdata->subdevs[i].platform_data) in max1586_pmic_probe()
249 dev_err(&client->dev, "invalid regulator id %d\n", id); in max1586_pmic_probe()
250 return -EINVAL; in max1586_pmic_probe()
254 max1586_reg[id].min_uV = max1586->min_uV; in max1586_pmic_probe()
256 (max1586->max_uV - max1586->min_uV) / in max1586_pmic_probe()
260 config.dev = &client->dev; in max1586_pmic_probe()
261 config.init_data = pdata->subdevs[i].platform_data; in max1586_pmic_probe()
264 rdev = devm_regulator_register(&client->dev, in max1586_pmic_probe()
267 dev_err(&client->dev, "failed to register %s\n", in max1586_pmic_probe()
274 dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); in max1586_pmic_probe()
307 MODULE_DESCRIPTION("MAXIM 1586 voltage regulator driver");