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

1 // SPDX-License-Identifier: GPL-2.0+
6 * Keerthy <j-keerthy@ti.com>
18 static const char lp873x_buck_ctrl[LP873X_BUCK_NUM] = {0x2, 0x4};
19 static const char lp873x_buck_volt[LP873X_BUCK_NUM] = {0x6, 0x7};
20 static const char lp873x_ldo_ctrl[LP873X_LDO_NUM] = {0x8, 0x9};
21 static const char lp873x_ldo_volt[LP873X_LDO_NUM] = {0xA, 0xB};
23 static int lp873x_buck_enable(struct udevice *dev, int op, bool *enable) in lp873x_buck_enable() argument
30 adr = uc_pdata->ctrl_reg; in lp873x_buck_enable()
32 ret = pmic_reg_read(dev->parent, adr); in lp873x_buck_enable()
40 *enable = true; in lp873x_buck_enable()
42 *enable = false; in lp873x_buck_enable()
46 if (*enable) in lp873x_buck_enable()
50 ret = pmic_reg_write(dev->parent, adr, ret); in lp873x_buck_enable()
58 static int lp873x_buck_volt2hex(int uV) in lp873x_buck_volt2hex()
61 return -EINVAL; in lp873x_buck_volt2hex()
63 return (uV - 1420000) / 20000 + 0x9E; in lp873x_buck_volt2hex()
65 return (uV - 735000) / 5000 + 0x18; in lp873x_buck_volt2hex()
67 return (uV - 700000) / 10000 + 0x1; in lp873x_buck_volt2hex()
69 return -EINVAL; in lp873x_buck_volt2hex()
72 static int lp873x_buck_hex2volt(int hex) in lp873x_buck_hex2volt()
75 return -EINVAL; in lp873x_buck_hex2volt()
77 return 1400000 + (hex - 0x9D) * 20000; in lp873x_buck_hex2volt()
79 return 730000 + (hex - 0x17) * 5000; in lp873x_buck_hex2volt()
81 return 700000 + (hex - 0x14) * 10000; in lp873x_buck_hex2volt()
83 return -EINVAL; in lp873x_buck_hex2volt()
86 static int lp873x_buck_val(struct udevice *dev, int op, int *uV) in lp873x_buck_val()
97 adr = uc_pdata->volt_reg; in lp873x_buck_val()
99 ret = pmic_reg_read(dev->parent, adr); in lp873x_buck_val()
120 ret = pmic_reg_write(dev->parent, adr, ret); in lp873x_buck_val()
125 static int lp873x_ldo_enable(struct udevice *dev, int op, bool *enable) in lp873x_ldo_enable() argument
132 adr = uc_pdata->ctrl_reg; in lp873x_ldo_enable()
134 ret = pmic_reg_read(dev->parent, adr); in lp873x_ldo_enable()
142 *enable = true; in lp873x_ldo_enable()
144 *enable = false; in lp873x_ldo_enable()
148 if (*enable) in lp873x_ldo_enable()
153 ret = pmic_reg_write(dev->parent, adr, ret); in lp873x_ldo_enable()
161 static int lp873x_ldo_volt2hex(int uV) in lp873x_ldo_volt2hex()
164 return -EINVAL; in lp873x_ldo_volt2hex()
166 return (uV - 800000) / 100000; in lp873x_ldo_volt2hex()
169 static int lp873x_ldo_hex2volt(int hex) in lp873x_ldo_hex2volt()
172 return -EINVAL; in lp873x_ldo_hex2volt()
180 static int lp873x_ldo_val(struct udevice *dev, int op, int *uV) in lp873x_ldo_val()
192 adr = uc_pdata->volt_reg; in lp873x_ldo_val()
194 ret = pmic_reg_read(dev->parent, adr); in lp873x_ldo_val()
215 ret = pmic_reg_write(dev->parent, adr, ret); in lp873x_ldo_val()
220 static int lp873x_ldo_probe(struct udevice *dev) in lp873x_ldo_probe()
225 uc_pdata->type = REGULATOR_TYPE_LDO; in lp873x_ldo_probe()
227 int idx = dev->driver_data; in lp873x_ldo_probe()
230 return -1; in lp873x_ldo_probe()
233 uc_pdata->ctrl_reg = lp873x_ldo_ctrl[idx]; in lp873x_ldo_probe()
234 uc_pdata->volt_reg = lp873x_ldo_volt[idx]; in lp873x_ldo_probe()
239 static int ldo_get_value(struct udevice *dev) in ldo_get_value()
251 static int ldo_set_value(struct udevice *dev, int uV) in ldo_set_value()
256 static int ldo_get_enable(struct udevice *dev) in ldo_get_enable()
258 bool enable = false; in ldo_get_enable() local
261 ret = lp873x_ldo_enable(dev, PMIC_OP_GET, &enable); in ldo_get_enable()
265 return enable; in ldo_get_enable()
268 static int ldo_set_enable(struct udevice *dev, bool enable) in ldo_set_enable() argument
270 return lp873x_ldo_enable(dev, PMIC_OP_SET, &enable); in ldo_set_enable()
273 static int lp873x_buck_probe(struct udevice *dev) in lp873x_buck_probe()
279 uc_pdata->type = REGULATOR_TYPE_BUCK; in lp873x_buck_probe()
281 idx = dev->driver_data; in lp873x_buck_probe()
284 return -1; in lp873x_buck_probe()
287 uc_pdata->ctrl_reg = lp873x_buck_ctrl[idx]; in lp873x_buck_probe()
288 uc_pdata->volt_reg = lp873x_buck_volt[idx]; in lp873x_buck_probe()
293 static int buck_get_value(struct udevice *dev) in buck_get_value()
305 static int buck_set_value(struct udevice *dev, int uV) in buck_set_value()
310 static int buck_get_enable(struct udevice *dev) in buck_get_enable()
312 bool enable = false; in buck_get_enable() local
316 ret = lp873x_buck_enable(dev, PMIC_OP_GET, &enable); in buck_get_enable()
320 return enable; in buck_get_enable()
323 static int buck_set_enable(struct udevice *dev, bool enable) in buck_set_enable() argument
325 return lp873x_buck_enable(dev, PMIC_OP_SET, &enable); in buck_set_enable()
328 static const struct dm_regulator_ops lp873x_ldo_ops = {
342 static const struct dm_regulator_ops lp873x_buck_ops = {