Lines Matching +full:no +full:- +full:regulator +full:- +full:enable +full:- +full:control

1 // SPDX-License-Identifier: GPL-2.0+
3 // max77802.c - Regulator driver for the Maxim 77802
5 // Copyright (C) 2013-2014 Google, Inc
20 #include <linux/regulator/driver.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/regulator/of_regulator.h>
24 #include <linux/mfd/max77686-private.h>
25 #include <dt-bindings/regulator/maxim,max77802.h>
61 /* Array indexed by regulator id */
83 return -EINVAL; in max77802_get_opmode_shift()
87 * max77802_set_suspend_disable - Disable the regulator during system suspend
88 * @rdev: regulator to mark as disabled
91 * Configure the regulator so the PMIC will turn it OFF during system suspend.
100 if (WARN_ON_ONCE(id >= ARRAY_SIZE(max77802->opmode))) in max77802_set_suspend_disable()
101 return -EINVAL; in max77802_set_suspend_disable()
102 max77802->opmode[id] = val; in max77802_set_suspend_disable()
103 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_set_suspend_disable()
104 rdev->desc->enable_mask, val << shift); in max77802_set_suspend_disable()
127 dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", in max77802_set_mode()
128 rdev->desc->name, mode); in max77802_set_mode()
129 return -EINVAL; in max77802_set_mode()
132 if (WARN_ON_ONCE(id >= ARRAY_SIZE(max77802->opmode))) in max77802_set_mode()
133 return -EINVAL; in max77802_set_mode()
135 max77802->opmode[id] = val; in max77802_set_mode()
136 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_set_mode()
137 rdev->desc->enable_mask, val << shift); in max77802_set_mode()
145 if (WARN_ON_ONCE(id >= ARRAY_SIZE(max77802->opmode))) in max77802_get_mode()
146 return -EINVAL; in max77802_get_mode()
147 return max77802_map_mode(max77802->opmode[id]); in max77802_get_mode()
151 * max77802_set_suspend_mode - set regulator opmode when the system is suspended
152 * @rdev: regulator to change mode
156 * This function is valid for the three different enable control logics:
158 * Enable Control Logic1 by PWRREQ (BUCK 2-4 and LDOs 2, 4-19, 22-35)
159 * Enable Control Logic2 by PWRREQ (LDOs 1, 20, 21)
160 * Enable Control Logic3 by PWRREQ (LDO 3)
162 * If setting the regulator mode fails, the function only warns but does
163 * not return a negative error number to avoid the regulator core to stop
174 if (WARN_ON_ONCE(id >= ARRAY_SIZE(max77802->opmode))) in max77802_set_suspend_mode()
175 return -EINVAL; in max77802_set_suspend_mode()
178 * If the regulator has been disabled for suspend in max77802_set_suspend_mode()
181 if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) { in max77802_set_suspend_mode()
182 dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n", in max77802_set_suspend_mode()
183 rdev->desc->name, mode); in max77802_set_suspend_mode()
190 * If the regulator opmode is normal then enable in max77802_set_suspend_mode()
192 * already Low Power then no action is required. in max77802_set_suspend_mode()
194 if (max77802->opmode[id] == MAX77802_OPMODE_NORMAL) in max77802_set_suspend_mode()
201 * If the regulator operating mode is Low Power then in max77802_set_suspend_mode()
203 * mode is already normal then no action is required. in max77802_set_suspend_mode()
205 if (max77802->opmode[id] == MAX77802_OPMODE_LP) in max77802_set_suspend_mode()
206 dev_warn(&rdev->dev, "%s: in Low Power: 0x%x invalid\n", in max77802_set_suspend_mode()
207 rdev->desc->name, mode); in max77802_set_suspend_mode()
210 dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", in max77802_set_suspend_mode()
211 rdev->desc->name, mode); in max77802_set_suspend_mode()
212 return -EINVAL; in max77802_set_suspend_mode()
215 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_set_suspend_mode()
216 rdev->desc->enable_mask, val << shift); in max77802_set_suspend_mode()
225 if (WARN_ON_ONCE(id >= ARRAY_SIZE(max77802->opmode))) in max77802_enable()
226 return -EINVAL; in max77802_enable()
227 if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) in max77802_enable()
228 max77802->opmode[id] = MAX77802_OPMODE_NORMAL; in max77802_enable()
230 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_enable()
231 rdev->desc->enable_mask, in max77802_enable()
232 max77802->opmode[id] << shift); in max77802_enable()
236 * LDOs 2, 4-19, 22-35
242 .enable = max77802_enable,
258 .enable = max77802_enable,
273 .enable = max77802_enable,
282 /* BUCKs 2-4 */
287 .enable = max77802_enable,
297 /* BUCKs 5, 7-10 */
302 .enable = max77802_enable,
310 /* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */
324 .vsel_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
326 .enable_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
345 .vsel_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
347 .enable_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
377 /* BUCKS 2-4 */
424 /* BUCKs 7-10 */
438 .vsel_reg = MAX77802_REG_BUCK7OUT + (num - 7) * 3, \
440 .enable_reg = MAX77802_REG_BUCK7CTRL + (num - 7) * 3, \
492 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); in max77802_pmic_probe()
497 max77802 = devm_kzalloc(&pdev->dev, in max77802_pmic_probe()
501 return -ENOMEM; in max77802_pmic_probe()
503 config.dev = iodev->dev; in max77802_pmic_probe()
504 config.regmap = iodev->regmap; in max77802_pmic_probe()
514 ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); in max77802_pmic_probe()
516 dev_warn(&pdev->dev, in max77802_pmic_probe()
524 * If the regulator is disabled and the system warm rebooted, in max77802_pmic_probe()
525 * the hardware reports OFF as the regulator operating mode. in max77802_pmic_probe()
528 if (id < ARRAY_SIZE(max77802->opmode)) { in max77802_pmic_probe()
530 max77802->opmode[id] = MAX77802_OPMODE_NORMAL; in max77802_pmic_probe()
532 max77802->opmode[id] = val; in max77802_pmic_probe()
535 rdev = devm_regulator_register(&pdev->dev, in max77802_pmic_probe()
539 dev_err(&pdev->dev, in max77802_pmic_probe()
540 "regulator init failed for %d: %d\n", i, ret); in max77802_pmic_probe()
549 {"max77802-pmic", 0},
556 .name = "max77802-pmic",
565 MODULE_DESCRIPTION("MAXIM 77802 Regulator Driver");