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 max77802->opmode[id] = val; in max77802_set_suspend_disable()
101 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_set_suspend_disable()
102 rdev->desc->enable_mask, val << shift); in max77802_set_suspend_disable()
125 dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", in max77802_set_mode()
126 rdev->desc->name, mode); in max77802_set_mode()
127 return -EINVAL; in max77802_set_mode()
130 max77802->opmode[id] = val; in max77802_set_mode()
131 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_set_mode()
132 rdev->desc->enable_mask, val << shift); in max77802_set_mode()
140 return max77802_map_mode(max77802->opmode[id]); in max77802_get_mode()
144 * max77802_set_suspend_mode - set regulator opmode when the system is suspended
145 * @rdev: regulator to change mode
149 * This function is valid for the three different enable control logics:
151 * Enable Control Logic1 by PWRREQ (BUCK 2-4 and LDOs 2, 4-19, 22-35)
152 * Enable Control Logic2 by PWRREQ (LDOs 1, 20, 21)
153 * Enable Control Logic3 by PWRREQ (LDO 3)
155 * If setting the regulator mode fails, the function only warns but does
156 * not return an error code to avoid the regulator core to stop setting
168 * If the regulator has been disabled for suspend in max77802_set_suspend_mode()
171 if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) { in max77802_set_suspend_mode()
172 dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n", in max77802_set_suspend_mode()
173 rdev->desc->name, mode); in max77802_set_suspend_mode()
180 * If the regulator opmode is normal then enable in max77802_set_suspend_mode()
182 * already Low Power then no action is required. in max77802_set_suspend_mode()
184 if (max77802->opmode[id] == MAX77802_OPMODE_NORMAL) in max77802_set_suspend_mode()
191 * If the regulator operating mode is Low Power then in max77802_set_suspend_mode()
193 * mode is already normal then no action is required. in max77802_set_suspend_mode()
195 if (max77802->opmode[id] == MAX77802_OPMODE_LP) in max77802_set_suspend_mode()
196 dev_warn(&rdev->dev, "%s: in Low Power: 0x%x invalid\n", in max77802_set_suspend_mode()
197 rdev->desc->name, mode); in max77802_set_suspend_mode()
200 dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", in max77802_set_suspend_mode()
201 rdev->desc->name, mode); in max77802_set_suspend_mode()
202 return -EINVAL; in max77802_set_suspend_mode()
205 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_set_suspend_mode()
206 rdev->desc->enable_mask, val << shift); in max77802_set_suspend_mode()
215 if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) in max77802_enable()
216 max77802->opmode[id] = MAX77802_OPMODE_NORMAL; in max77802_enable()
218 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in max77802_enable()
219 rdev->desc->enable_mask, in max77802_enable()
220 max77802->opmode[id] << shift); in max77802_enable()
224 * LDOs 2, 4-19, 22-35
230 .enable = max77802_enable,
246 .enable = max77802_enable,
261 .enable = max77802_enable,
270 /* BUCKs 2-4 */
275 .enable = max77802_enable,
285 /* BUCKs 5, 7-10 */
290 .enable = max77802_enable,
298 /* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */
312 .vsel_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
314 .enable_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
333 .vsel_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
335 .enable_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \
365 /* BUCKS 2-4 */
412 /* BUCKs 7-10 */
426 .vsel_reg = MAX77802_REG_BUCK7OUT + (num - 7) * 3, \
428 .enable_reg = MAX77802_REG_BUCK7CTRL + (num - 7) * 3, \
480 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); in max77802_pmic_probe()
485 max77802 = devm_kzalloc(&pdev->dev, in max77802_pmic_probe()
489 return -ENOMEM; in max77802_pmic_probe()
491 config.dev = iodev->dev; in max77802_pmic_probe()
492 config.regmap = iodev->regmap; in max77802_pmic_probe()
502 ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); in max77802_pmic_probe()
504 dev_warn(&pdev->dev, in max77802_pmic_probe()
512 * If the regulator is disabled and the system warm rebooted, in max77802_pmic_probe()
513 * the hardware reports OFF as the regulator operating mode. in max77802_pmic_probe()
517 max77802->opmode[id] = MAX77802_OPMODE_NORMAL; in max77802_pmic_probe()
519 max77802->opmode[id] = val; in max77802_pmic_probe()
521 rdev = devm_regulator_register(&pdev->dev, in max77802_pmic_probe()
525 dev_err(&pdev->dev, in max77802_pmic_probe()
526 "regulator init failed for %d: %d\n", i, ret); in max77802_pmic_probe()
535 {"max77802-pmic", 0},
542 .name = "max77802-pmic",
550 MODULE_DESCRIPTION("MAXIM 77802 Regulator Driver");