Lines Matching +full:static +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0+
6 * Keerthy <j-keerthy@ti.com>
26 static const char palmas_smps_ctrl[][PALMAS_SMPS_NUM] = {
32 static const char palmas_smps_volt[][PALMAS_SMPS_NUM] = {
38 static const char palmas_ldo_ctrl[][PALMAS_LDO_NUM] = {
44 static const char palmas_ldo_volt[][PALMAS_LDO_NUM] = {
50 static int palmas_smps_enable(struct udevice *dev, int op, bool *enable) in palmas_smps_enable() argument
57 adr = uc_pdata->ctrl_reg; in palmas_smps_enable()
59 ret = pmic_reg_read(dev->parent, adr); in palmas_smps_enable()
67 *enable = true; in palmas_smps_enable()
69 *enable = false; in palmas_smps_enable()
73 if (*enable) in palmas_smps_enable()
78 ret = pmic_reg_write(dev->parent, adr, ret); in palmas_smps_enable()
86 static int palmas_smps_volt2hex(int uV) in palmas_smps_volt2hex()
89 return -EINVAL; in palmas_smps_volt2hex()
92 return (uV - 1000000) / 20000 + 0x6; in palmas_smps_volt2hex()
97 return 0x6 + ((uV - 500000) / 10000); in palmas_smps_volt2hex()
100 static int palmas_smps_hex2volt(int hex, bool range) in palmas_smps_hex2volt()
105 return -EINVAL; in palmas_smps_hex2volt()
110 uV = 500000 + (hex - 0x6) * 10000; in palmas_smps_hex2volt()
118 static int palmas_smps_val(struct udevice *dev, int op, int *uV) in palmas_smps_val()
130 adr = uc_pdata->volt_reg; in palmas_smps_val()
132 ret = pmic_reg_read(dev->parent, adr); in palmas_smps_val()
160 return pmic_reg_write(dev->parent, adr, ret); in palmas_smps_val()
163 static int palmas_ldo_bypass_enable(struct udevice *dev, bool enabled) in palmas_ldo_bypass_enable()
172 if (dev->driver_data > 2) in palmas_ldo_bypass_enable()
173 return -ENOTSUPP; in palmas_ldo_bypass_enable()
176 if (dev->driver_data != 9) in palmas_ldo_bypass_enable()
177 return -ENOTSUPP; in palmas_ldo_bypass_enable()
181 adr = p->ctrl_reg; in palmas_ldo_bypass_enable()
183 reg = pmic_reg_read(dev->parent, adr); in palmas_ldo_bypass_enable()
192 return pmic_reg_write(dev->parent, adr, reg); in palmas_ldo_bypass_enable()
195 static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable) in palmas_ldo_enable() argument
202 adr = uc_pdata->ctrl_reg; in palmas_ldo_enable()
204 ret = pmic_reg_read(dev->parent, adr); in palmas_ldo_enable()
212 *enable = true; in palmas_ldo_enable()
214 *enable = false; in palmas_ldo_enable()
218 if (*enable) in palmas_ldo_enable()
223 ret = pmic_reg_write(dev->parent, adr, ret); in palmas_ldo_enable()
228 if (ret && (ret != -ENOTSUPP)) in palmas_ldo_enable()
235 static int palmas_ldo_volt2hex(int uV) in palmas_ldo_volt2hex()
238 return -EINVAL; in palmas_ldo_volt2hex()
240 return (uV - 850000) / 50000; in palmas_ldo_volt2hex()
243 static int palmas_ldo_hex2volt(int hex) in palmas_ldo_hex2volt()
246 return -EINVAL; in palmas_ldo_hex2volt()
254 static int palmas_ldo_val(struct udevice *dev, int op, int *uV) in palmas_ldo_val()
266 adr = uc_pdata->volt_reg; in palmas_ldo_val()
268 ret = pmic_reg_read(dev->parent, adr); in palmas_ldo_val()
290 return pmic_reg_write(dev->parent, adr, ret); in palmas_ldo_val()
293 static int palmas_ldo_probe(struct udevice *dev) in palmas_ldo_probe()
303 uc_pdata->type = REGULATOR_TYPE_LDO; in palmas_ldo_probe()
305 if (dev->driver_data) { in palmas_ldo_probe()
306 u8 idx = dev->driver_data - 1; in palmas_ldo_probe()
307 uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][idx]; in palmas_ldo_probe()
308 uc_pdata->volt_reg = palmas_ldo_volt[type][idx]; in palmas_ldo_probe()
311 if (!strcmp("ldoln", dev->name)) { in palmas_ldo_probe()
312 uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9]; in palmas_ldo_probe()
313 uc_pdata->volt_reg = palmas_ldo_volt[type][9]; in palmas_ldo_probe()
314 } else if (!strcmp("ldousb", dev->name)) { in palmas_ldo_probe()
315 uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10]; in palmas_ldo_probe()
316 uc_pdata->volt_reg = palmas_ldo_volt[type][10]; in palmas_ldo_probe()
323 static int ldo_get_value(struct udevice *dev) in ldo_get_value()
335 static int ldo_set_value(struct udevice *dev, int uV) in ldo_set_value()
340 static int ldo_get_enable(struct udevice *dev) in ldo_get_enable()
342 bool enable = false; in ldo_get_enable() local
345 ret = palmas_ldo_enable(dev, PMIC_OP_GET, &enable); in ldo_get_enable()
349 return enable; in ldo_get_enable()
352 static int ldo_set_enable(struct udevice *dev, bool enable) in ldo_set_enable() argument
354 return palmas_ldo_enable(dev, PMIC_OP_SET, &enable); in ldo_set_enable()
357 static int palmas_smps_probe(struct udevice *dev) in palmas_smps_probe()
368 uc_pdata->type = REGULATOR_TYPE_BUCK; in palmas_smps_probe()
373 switch (dev->driver_data) { in palmas_smps_probe()
376 uc_pdata->ctrl_reg = palmas_smps_ctrl[type][0]; in palmas_smps_probe()
377 uc_pdata->volt_reg = palmas_smps_volt[type][0]; in palmas_smps_probe()
380 uc_pdata->ctrl_reg = palmas_smps_ctrl[type][1]; in palmas_smps_probe()
381 uc_pdata->volt_reg = palmas_smps_volt[type][1]; in palmas_smps_probe()
384 uc_pdata->ctrl_reg = palmas_smps_ctrl[type][2]; in palmas_smps_probe()
385 uc_pdata->volt_reg = palmas_smps_volt[type][2]; in palmas_smps_probe()
392 idx = dev->driver_data - 3; in palmas_smps_probe()
393 uc_pdata->ctrl_reg = palmas_smps_ctrl[type][idx]; in palmas_smps_probe()
394 uc_pdata->volt_reg = palmas_smps_volt[type][idx]; in palmas_smps_probe()
403 switch (dev->driver_data) { in palmas_smps_probe()
409 idx = dev->driver_data - 1; in palmas_smps_probe()
410 uc_pdata->ctrl_reg = palmas_smps_ctrl[type][idx]; in palmas_smps_probe()
411 uc_pdata->volt_reg = palmas_smps_volt[type][idx]; in palmas_smps_probe()
415 uc_pdata->ctrl_reg = palmas_smps_ctrl[type][idx]; in palmas_smps_probe()
416 uc_pdata->volt_reg = palmas_smps_volt[type][idx]; in palmas_smps_probe()
430 static int smps_get_value(struct udevice *dev) in smps_get_value()
442 static int smps_set_value(struct udevice *dev, int uV) in smps_set_value()
447 static int smps_get_enable(struct udevice *dev) in smps_get_enable()
449 bool enable = false; in smps_get_enable() local
452 ret = palmas_smps_enable(dev, PMIC_OP_GET, &enable); in smps_get_enable()
456 return enable; in smps_get_enable()
459 static int smps_set_enable(struct udevice *dev, bool enable) in smps_set_enable() argument
461 return palmas_smps_enable(dev, PMIC_OP_SET, &enable); in smps_set_enable()
464 static const struct dm_regulator_ops palmas_ldo_ops = {
478 static const struct dm_regulator_ops palmas_smps_ops = {