Lines Matching +full:dcdc +full:- +full:reg
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Author: Chris Zhong <zyw@rock-chips.com>
9 * Author: Zhang Qing <zhangqing@rock-chips.com>
10 * Author: Xu Shengfei <xsf@rock-chips.com>
87 .n_voltages = (((_max) - (_min)) / (_step) + 1), \
111 .n_voltages = (((_max) - (_min)) / (_step) + 1), \
195 u8 reg; member
201 .reg = _reg, \
234 #define RK817_BUCK1_SEL0 ((RK817_BUCK1_MAX0 - RK817_BUCK1_MIN0) /\
236 #define RK817_BUCK1_SEL1 ((RK817_BUCK1_MAX1 - RK817_BUCK1_MIN1) /\
239 #define RK817_BUCK3_SEL1 ((RK817_BUCK3_MAX1 - RK817_BUCK1_MIN1) /\
271 int ctr_bit, reg; in rk806_set_mode_dcdc() local
273 reg = RK806_POWER_FPWM_EN0 + rid / 8; in rk806_set_mode_dcdc()
278 return regmap_update_bits(rdev->regmap, reg, in rk806_set_mode_dcdc()
282 return regmap_update_bits(rdev->regmap, reg, in rk806_set_mode_dcdc()
287 return -EINVAL; in rk806_set_mode_dcdc()
296 int ctr_bit, reg; in rk806_get_mode_dcdc() local
300 reg = RK806_POWER_FPWM_EN0 + rid / 8; in rk806_get_mode_dcdc()
303 err = regmap_read(rdev->regmap, reg, &val); in rk806_get_mode_dcdc()
335 ret = regulator_find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table, in rk806_set_ramp_delay_dcdc()
336 rdev->desc->n_ramp_values, &ramp_value); in rk806_set_ramp_delay_dcdc()
339 "Can't set ramp-delay %u, setting %u\n", ramp_delay, in rk806_set_ramp_delay_dcdc()
340 rdev->desc->ramp_delay_table[ramp_value]); in rk806_set_ramp_delay_dcdc()
343 regval = ramp_value << (ffs(rdev->desc->ramp_mask) - 1); in rk806_set_ramp_delay_dcdc()
345 ret = regmap_update_bits(rdev->regmap, rdev->desc->ramp_reg, in rk806_set_ramp_delay_dcdc()
346 rdev->desc->ramp_mask, regval); in rk806_set_ramp_delay_dcdc()
352 * but that only stores the lower 2 bits for rk806 DCDC ramp. The MSB must in rk806_set_ramp_delay_dcdc()
358 return regmap_update_bits(rdev->regmap, rk806_dcdc_rate2[rid].reg, in rk806_set_ramp_delay_dcdc()
370 unsigned int reg; in rk806_set_suspend_voltage_range() local
373 return -EINVAL; in rk806_set_suspend_voltage_range()
375 reg = rdev->desc->vsel_reg + reg_offset; in rk806_set_suspend_voltage_range()
377 return regmap_update_bits(rdev->regmap, reg, rdev->desc->vsel_mask, sel); in rk806_set_suspend_voltage_range()
399 struct gpio_desc *gpio = pdata->dvs_gpio[id]; in rk808_buck1_2_get_voltage_sel_regmap()
406 ret = regmap_read(rdev->regmap, in rk808_buck1_2_get_voltage_sel_regmap()
407 rdev->desc->vsel_reg + RK808_DVS_REG_OFFSET, in rk808_buck1_2_get_voltage_sel_regmap()
412 val &= rdev->desc->vsel_mask; in rk808_buck1_2_get_voltage_sel_regmap()
413 val >>= ffs(rdev->desc->vsel_mask) - 1; in rk808_buck1_2_get_voltage_sel_regmap()
422 unsigned int old_sel, tmp, val, mask = rdev->desc->vsel_mask; in rk808_buck1_2_i2c_set_voltage_sel()
424 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in rk808_buck1_2_i2c_set_voltage_sel()
430 old_sel >>= ffs(mask) - 1; in rk808_buck1_2_i2c_set_voltage_sel()
431 delta_sel = sel - old_sel; in rk808_buck1_2_i2c_set_voltage_sel()
435 * the risk of overshoot. Put it into a multi-step, can effectively in rk808_buck1_2_i2c_set_voltage_sel()
440 val = old_sel << (ffs(mask) - 1); in rk808_buck1_2_i2c_set_voltage_sel()
449 ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val); in rk808_buck1_2_i2c_set_voltage_sel()
450 delta_sel = sel - old_sel; in rk808_buck1_2_i2c_set_voltage_sel()
453 sel <<= ffs(mask) - 1; in rk808_buck1_2_i2c_set_voltage_sel()
455 ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val); in rk808_buck1_2_i2c_set_voltage_sel()
472 struct gpio_desc *gpio = pdata->dvs_gpio[id]; in rk808_buck1_2_set_voltage_sel()
473 unsigned int reg = rdev->desc->vsel_reg; in rk808_buck1_2_set_voltage_sel() local
482 reg += RK808_DVS_REG_OFFSET; in rk808_buck1_2_set_voltage_sel()
483 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &old_sel); in rk808_buck1_2_set_voltage_sel()
485 ret = regmap_read(rdev->regmap, in rk808_buck1_2_set_voltage_sel()
486 reg + RK808_DVS_REG_OFFSET, in rk808_buck1_2_set_voltage_sel()
493 sel <<= ffs(rdev->desc->vsel_mask) - 1; in rk808_buck1_2_set_voltage_sel()
494 sel |= old_sel & ~rdev->desc->vsel_mask; in rk808_buck1_2_set_voltage_sel()
496 ret = regmap_write(rdev->regmap, reg, sel); in rk808_buck1_2_set_voltage_sel()
511 struct gpio_desc *gpio = pdata->dvs_gpio[id]; in rk808_buck1_2_set_voltage_time_sel()
522 unsigned int reg; in rk808_set_suspend_voltage() local
526 return -EINVAL; in rk808_set_suspend_voltage()
528 reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; in rk808_set_suspend_voltage()
530 return regmap_update_bits(rdev->regmap, reg, in rk808_set_suspend_voltage()
531 rdev->desc->vsel_mask, in rk808_set_suspend_voltage()
537 unsigned int reg; in rk808_set_suspend_voltage_range() local
541 return -EINVAL; in rk808_set_suspend_voltage_range()
543 reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; in rk808_set_suspend_voltage_range()
545 return regmap_update_bits(rdev->regmap, reg, in rk808_set_suspend_voltage_range()
546 rdev->desc->vsel_mask, in rk808_set_suspend_voltage_range()
552 unsigned int reg; in rk805_set_suspend_enable() local
554 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; in rk805_set_suspend_enable()
556 return regmap_update_bits(rdev->regmap, reg, in rk805_set_suspend_enable()
557 rdev->desc->enable_mask, in rk805_set_suspend_enable()
558 rdev->desc->enable_mask); in rk805_set_suspend_enable()
563 unsigned int reg; in rk805_set_suspend_disable() local
565 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; in rk805_set_suspend_disable()
567 return regmap_update_bits(rdev->regmap, reg, in rk805_set_suspend_disable()
568 rdev->desc->enable_mask, in rk805_set_suspend_disable()
600 return regmap_update_bits(rdev->regmap, rk806_suspend_bits[rid].reg, in rk806_set_suspend_enable()
609 return regmap_update_bits(rdev->regmap, rk806_suspend_bits[rid].reg, in rk806_set_suspend_disable()
615 unsigned int reg; in rk808_set_suspend_enable() local
617 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; in rk808_set_suspend_enable()
619 return regmap_update_bits(rdev->regmap, reg, in rk808_set_suspend_enable()
620 rdev->desc->enable_mask, in rk808_set_suspend_enable()
626 unsigned int reg; in rk808_set_suspend_disable() local
628 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; in rk808_set_suspend_disable()
630 return regmap_update_bits(rdev->regmap, reg, in rk808_set_suspend_disable()
631 rdev->desc->enable_mask, in rk808_set_suspend_disable()
632 rdev->desc->enable_mask); in rk808_set_suspend_disable()
638 unsigned int reg; in rk817_set_suspend_enable_ctrl() local
645 id_slp = 8 + (id - RK817_ID_LDO1); in rk817_set_suspend_enable_ctrl()
647 id_slp = 4 + (id - RK817_ID_LDO9); in rk817_set_suspend_enable_ctrl()
649 return -EINVAL; in rk817_set_suspend_enable_ctrl()
651 reg = RK817_POWER_SLP_EN_REG(id_slp / 8); in rk817_set_suspend_enable_ctrl()
659 return regmap_update_bits(rdev->regmap, reg, msk, val); in rk817_set_suspend_enable_ctrl()
674 unsigned int reg; in rk8xx_set_suspend_mode() local
676 reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; in rk8xx_set_suspend_mode()
680 return regmap_update_bits(rdev->regmap, reg, in rk8xx_set_suspend_mode()
683 return regmap_update_bits(rdev->regmap, reg, in rk8xx_set_suspend_mode()
686 dev_err(&rdev->dev, "do not support this mode\n"); in rk8xx_set_suspend_mode()
687 return -EINVAL; in rk8xx_set_suspend_mode()
697 return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in rk8xx_set_mode()
700 return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in rk8xx_set_mode()
703 dev_err(&rdev->dev, "do not support this mode\n"); in rk8xx_set_mode()
704 return -EINVAL; in rk8xx_set_mode()
715 err = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in rk8xx_get_mode()
730 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val); in rk8xx_is_enabled_wmsk_regmap()
735 val |= (rdev->desc->enable_mask & 0xf0); in rk8xx_is_enabled_wmsk_regmap()
736 val &= rdev->desc->enable_mask; in rk8xx_is_enabled_wmsk_regmap()
738 if (rdev->desc->enable_is_inverted) { in rk8xx_is_enabled_wmsk_regmap()
739 if (rdev->desc->enable_val) in rk8xx_is_enabled_wmsk_regmap()
740 return val != rdev->desc->enable_val; in rk8xx_is_enabled_wmsk_regmap()
743 if (rdev->desc->enable_val) in rk8xx_is_enabled_wmsk_regmap()
744 return val == rdev->desc->enable_val; in rk8xx_is_enabled_wmsk_regmap()
1033 RK806_REGULATOR("dcdc-reg1", "vcc1", RK806_ID_DCDC1, rk806_ops_dcdc,
1037 RK806_REGULATOR("dcdc-reg2", "vcc2", RK806_ID_DCDC2, rk806_ops_dcdc,
1041 RK806_REGULATOR("dcdc-reg3", "vcc3", RK806_ID_DCDC3, rk806_ops_dcdc,
1045 RK806_REGULATOR("dcdc-reg4", "vcc4", RK806_ID_DCDC4, rk806_ops_dcdc,
1050 RK806_REGULATOR("dcdc-reg5", "vcc5", RK806_ID_DCDC5, rk806_ops_dcdc,
1054 RK806_REGULATOR("dcdc-reg6", "vcc6", RK806_ID_DCDC6, rk806_ops_dcdc,
1058 RK806_REGULATOR("dcdc-reg7", "vcc7", RK806_ID_DCDC7, rk806_ops_dcdc,
1062 RK806_REGULATOR("dcdc-reg8", "vcc8", RK806_ID_DCDC8, rk806_ops_dcdc,
1067 RK806_REGULATOR("dcdc-reg9", "vcc9", RK806_ID_DCDC9, rk806_ops_dcdc,
1071 RK806_REGULATOR("dcdc-reg10", "vcc10", RK806_ID_DCDC10, rk806_ops_dcdc,
1076 RK806_REGULATOR("nldo-reg1", "vcc13", RK806_ID_NLDO1, rk806_ops_nldo,
1080 RK806_REGULATOR("nldo-reg2", "vcc13", RK806_ID_NLDO2, rk806_ops_nldo,
1084 RK806_REGULATOR("nldo-reg3", "vcc13", RK806_ID_NLDO3, rk806_ops_nldo,
1088 RK806_REGULATOR("nldo-reg4", "vcc14", RK806_ID_NLDO4, rk806_ops_nldo,
1093 RK806_REGULATOR("nldo-reg5", "vcc14", RK806_ID_NLDO5, rk806_ops_nldo,
1098 RK806_REGULATOR("pldo-reg1", "vcc11", RK806_ID_PLDO1, rk806_ops_pldo,
1102 RK806_REGULATOR("pldo-reg2", "vcc11", RK806_ID_PLDO2, rk806_ops_pldo,
1106 RK806_REGULATOR("pldo-reg3", "vcc11", RK806_ID_PLDO3, rk806_ops_pldo,
1111 RK806_REGULATOR("pldo-reg4", "vcc12", RK806_ID_PLDO4, rk806_ops_pldo,
1115 RK806_REGULATOR("pldo-reg5", "vcc12", RK806_ID_PLDO5, rk806_ops_pldo,
1120 RK806_REGULATOR("pldo-reg6", "vcca", RK806_ID_PLDO6, rk806_ops_pldo,
1522 DISABLE_VAL(1), 400, 3500 - 5400),
1637 np = of_get_child_by_name(dev->of_node, "regulators"); in rk808_regulator_dt_parse_pdata()
1639 return -ENXIO; in rk808_regulator_dt_parse_pdata()
1641 for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) { in rk808_regulator_dt_parse_pdata()
1642 pdata->dvs_gpio[i] = in rk808_regulator_dt_parse_pdata()
1645 if (IS_ERR(pdata->dvs_gpio[i])) { in rk808_regulator_dt_parse_pdata()
1646 ret = PTR_ERR(pdata->dvs_gpio[i]); in rk808_regulator_dt_parse_pdata()
1651 if (!pdata->dvs_gpio[i]) { in rk808_regulator_dt_parse_pdata()
1658 gpiod_is_active_low(pdata->dvs_gpio[i]) ? in rk808_regulator_dt_parse_pdata()
1669 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); in rk808_regulator_probe()
1677 pdev->dev.of_node = pdev->dev.parent->of_node; in rk808_regulator_probe()
1678 pdev->dev.of_node_reused = true; in rk808_regulator_probe()
1680 regmap = dev_get_regmap(pdev->dev.parent, NULL); in rk808_regulator_probe()
1682 return -ENODEV; in rk808_regulator_probe()
1684 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in rk808_regulator_probe()
1686 return -ENOMEM; in rk808_regulator_probe()
1688 switch (rk808->variant) { in rk808_regulator_probe()
1699 ret = rk808_regulator_dt_parse_pdata(&pdev->dev, regmap, pdata); in rk808_regulator_probe()
1719 dev_err(&pdev->dev, "unsupported RK8XX ID %lu\n", in rk808_regulator_probe()
1720 rk808->variant); in rk808_regulator_probe()
1721 return -EINVAL; in rk808_regulator_probe()
1726 config.dev = &pdev->dev; in rk808_regulator_probe()
1732 rk808_rdev = devm_regulator_register(&pdev->dev, in rk808_regulator_probe()
1735 return dev_err_probe(&pdev->dev, PTR_ERR(rk808_rdev), in rk808_regulator_probe()
1745 .name = "rk808-regulator",
1753 MODULE_AUTHOR("Tony xie <tony.xie@rock-chips.com>");
1754 MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
1755 MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");
1757 MODULE_AUTHOR("Xu Shengfei <xsf@rock-chips.com>");
1759 MODULE_ALIAS("platform:rk808-regulator");