Lines Matching +full:max8997 +full:- +full:pmic
1 // SPDX-License-Identifier: GPL-2.0+
3 // max77802.c - Regulator driver for the Maxim 77802
5 // Copyright (C) 2013-2014 Google, Inc
12 // This driver is based on max8997.c
24 #include <linux/mfd/max77686-private.h>
25 #include <dt-bindings/regulator/maxim,max77802.h>
83 return -EINVAL; in max77802_get_opmode_shift()
87 * max77802_set_suspend_disable - Disable the regulator during system suspend
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
158 * Enable Control Logic1 by PWRREQ (BUCK 2-4 and LDOs 2, 4-19, 22-35)
174 if (WARN_ON_ONCE(id >= ARRAY_SIZE(max77802->opmode))) in max77802_set_suspend_mode()
175 return -EINVAL; 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()
194 if (max77802->opmode[id] == MAX77802_OPMODE_NORMAL) 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
282 /* BUCKs 2-4 */
297 /* BUCKs 5, 7-10 */
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()
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()
549 {"max77802-pmic", 0},
556 .name = "max77802-pmic",