Lines Matching +full:buck +full:- +full:boost
1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
50 for (i = 0, range = output_range->ranges; in stpmu1_output_find_uv()
51 i < output_range->nbranges; i++, range++) { in stpmu1_output_find_uv()
52 if (sel >= range->min_sel && sel <= range->max_sel) in stpmu1_output_find_uv()
53 return range->min_uv + in stpmu1_output_find_uv()
54 (sel - range->min_sel) * range->step; in stpmu1_output_find_uv()
57 return -EINVAL; in stpmu1_output_find_uv()
66 for (i = 0, range = output_range->ranges; in stpmu1_output_find_sel()
67 i < output_range->nbranges; i++, range++) { in stpmu1_output_find_sel()
68 if (uv == range->min_uv && !range->step) in stpmu1_output_find_sel()
69 return range->min_sel; in stpmu1_output_find_sel()
71 if (uv >= range->min_uv && in stpmu1_output_find_sel()
72 uv <= range->min_uv + in stpmu1_output_find_sel()
73 (range->max_sel - range->min_sel) * range->step) in stpmu1_output_find_sel()
74 return range->min_sel + in stpmu1_output_find_sel()
75 (uv - range->min_uv) / range->step; in stpmu1_output_find_sel()
78 return -EINVAL; in stpmu1_output_find_sel()
82 * BUCK regulators
124 /* BUCK: 1,2,3,4 - voltage ranges */
132 /* BUCK modes */
138 static int stpmu1_buck_get_uv(struct udevice *dev, int buck) in stpmu1_buck_get_uv() argument
142 sel = pmic_reg_read(dev, STPMU1_BUCKX_CTRL_REG(buck)); in stpmu1_buck_get_uv()
149 return stpmu1_output_find_uv(sel, &buck_voltage_range[buck]); in stpmu1_buck_get_uv()
154 return stpmu1_buck_get_uv(dev->parent, dev->driver_data - 1); in stpmu1_buck_get_value()
159 int sel, buck = dev->driver_data - 1; in stpmu1_buck_set_value() local
161 sel = stpmu1_output_find_sel(uv, &buck_voltage_range[buck]); in stpmu1_buck_set_value()
165 return pmic_clrsetbits(dev->parent, in stpmu1_buck_set_value()
166 STPMU1_BUCKX_CTRL_REG(buck), in stpmu1_buck_set_value()
175 ret = pmic_reg_read(dev->parent, in stpmu1_buck_get_enable()
176 STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1)); in stpmu1_buck_get_enable()
197 if ((uv < uc_pdata->min_uV) || (uv > uc_pdata->max_uV)) in stpmu1_buck_set_enable()
198 stpmu1_buck_set_value(dev, uc_pdata->min_uV); in stpmu1_buck_set_enable()
201 ret = pmic_clrsetbits(dev->parent, in stpmu1_buck_set_enable()
202 STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1), in stpmu1_buck_set_enable()
213 ret = pmic_reg_read(dev->parent, in stpmu1_buck_get_mode()
214 STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1)); in stpmu1_buck_get_mode()
224 return pmic_clrsetbits(dev->parent, in stpmu1_buck_set_mode()
225 STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1), in stpmu1_buck_set_mode()
234 if (!dev->driver_data || dev->driver_data > STPMU1_MAX_BUCK) in stpmu1_buck_probe()
235 return -EINVAL; in stpmu1_buck_probe()
239 uc_pdata->type = REGULATOR_TYPE_BUCK; in stpmu1_buck_probe()
240 uc_pdata->mode = (struct dm_regulator_mode *)buck_modes; in stpmu1_buck_probe()
241 uc_pdata->mode_count = ARRAY_SIZE(buck_modes); in stpmu1_buck_probe()
290 /* LDO: 1,2,3,4,5,6 - voltage ranges */
312 int sel, ldo = dev->driver_data - 1; in stpmu1_ldo_get_value()
314 sel = pmic_reg_read(dev->parent, STPMU1_LDOX_CTRL_REG(ldo)); in stpmu1_ldo_get_value()
327 return stpmu1_buck_get_uv(dev->parent, STPMU1_BUCK2) / 2; in stpmu1_ldo_get_value()
334 int sel, ldo = dev->driver_data - 1; in stpmu1_ldo_set_value()
338 return -EINVAL; in stpmu1_ldo_set_value()
344 return pmic_clrsetbits(dev->parent, in stpmu1_ldo_set_value()
354 ret = pmic_reg_read(dev->parent, in stpmu1_ldo_get_enable()
355 STPMU1_LDOX_CTRL_REG(dev->driver_data - 1)); in stpmu1_ldo_get_enable()
376 if ((uv < uc_pdata->min_uV) || (uv > uc_pdata->max_uV)) in stpmu1_ldo_set_enable()
377 stpmu1_ldo_set_value(dev, uc_pdata->min_uV); in stpmu1_ldo_set_enable()
380 ret = pmic_clrsetbits(dev->parent, in stpmu1_ldo_set_enable()
381 STPMU1_LDOX_CTRL_REG(dev->driver_data - 1), in stpmu1_ldo_set_enable()
390 int ret, ldo = dev->driver_data - 1; in stpmu1_ldo_get_mode()
393 return -EINVAL; in stpmu1_ldo_get_mode()
395 ret = pmic_reg_read(dev->parent, STPMU1_LDOX_CTRL_REG(ldo)); in stpmu1_ldo_get_mode()
411 int ret, ldo = dev->driver_data - 1; in stpmu1_ldo_set_mode()
414 return -EINVAL; in stpmu1_ldo_set_mode()
416 ret = pmic_reg_read(dev->parent, STPMU1_LDOX_CTRL_REG(ldo)); in stpmu1_ldo_set_mode()
432 return pmic_reg_write(dev->parent, STPMU1_LDOX_CTRL_REG(ldo), ret); in stpmu1_ldo_set_mode()
439 if (!dev->driver_data || dev->driver_data > STPMU1_MAX_LDO) in stpmu1_ldo_probe()
440 return -EINVAL; in stpmu1_ldo_probe()
444 uc_pdata->type = REGULATOR_TYPE_LDO; in stpmu1_ldo_probe()
445 if (dev->driver_data - 1 == STPMU1_LDO3) { in stpmu1_ldo_probe()
446 uc_pdata->mode = (struct dm_regulator_mode *)ldo_modes; in stpmu1_ldo_probe()
447 uc_pdata->mode_count = ARRAY_SIZE(ldo_modes); in stpmu1_ldo_probe()
449 uc_pdata->mode_count = 0; in stpmu1_ldo_probe()
478 return stpmu1_buck_get_uv(dev->parent, STPMU1_BUCK2) / 2; in stpmu1_vref_ddr_get_value()
485 ret = pmic_reg_read(dev->parent, STPMU1_VREF_CTRL_REG); in stpmu1_vref_ddr_get_enable()
502 ret = pmic_clrsetbits(dev->parent, STPMU1_VREF_CTRL_REG, in stpmu1_vref_ddr_set_enable()
515 uc_pdata->type = REGULATOR_TYPE_FIXED; in stpmu1_vref_ddr_probe()
516 uc_pdata->mode_count = 0; in stpmu1_vref_ddr_probe()
535 * BOOST regulator
542 ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG); in stpmu1_boost_get_enable()
553 ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG); in stpmu1_boost_set_enable()
558 return -EINVAL; in stpmu1_boost_set_enable()
564 ret = pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG, in stpmu1_boost_set_enable()
579 uc_pdata->type = REGULATOR_TYPE_FIXED; in stpmu1_boost_probe()
580 uc_pdata->mode_count = 0; in stpmu1_boost_probe()
603 uint mask = 1 << dev->driver_data; in stpmu1_pwr_sw_get_enable()
606 ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG); in stpmu1_pwr_sw_get_enable()
615 uint mask = 1 << dev->driver_data; in stpmu1_pwr_sw_set_enable()
620 ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG); in stpmu1_pwr_sw_set_enable()
628 /* Boost management */ in stpmu1_pwr_sw_set_enable()
630 pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG, in stpmu1_pwr_sw_set_enable()
635 pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG, in stpmu1_pwr_sw_set_enable()
639 ret = pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG, in stpmu1_pwr_sw_set_enable()
650 if (!dev->driver_data || dev->driver_data > STPMU1_MAX_PWR_SW) in stpmu1_pwr_sw_probe()
651 return -EINVAL; in stpmu1_pwr_sw_probe()
655 uc_pdata->type = REGULATOR_TYPE_FIXED; in stpmu1_pwr_sw_probe()
656 uc_pdata->mode_count = 0; in stpmu1_pwr_sw_probe()