Lines Matching +full:low +full:- +full:power +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
9 // Inspired from tps65086-regulator.c
29 * The PMIC has four sets of registers corresponding to four power modes:
30 * Performance, Active, Low-power, Hibernate.
33 * Each regulator has a register for each power mode. To access a register
34 * for a specific regulator and mode BASE_* and OFFSET_* need to be added.
41 * a low-power state while the PMIC is in Active mode. They are supposed to be
42 * configured at startup and then simply transition to/from a global low-power
43 * state by setting the GPIO lpm pin high/low.
45 * This driver keeps the PMIC in Active mode, Low-power state is set for the
46 * regulators by enabling/disabling operating mode (FPWM or Auto PFM).
48 * The PMIC's Low-power and Hibernate modes are used during standby/suspend.
49 * To enter standby/suspend the PMIC will go to Low-power mode. From there, it
50 * will transition to Hibernate when the PWRHLD line is set to low by the MPU.
78 static unsigned int mcp16502_of_map_mode(unsigned int mode) in mcp16502_of_map_mode() argument
80 if (mode == REGULATOR_MODE_NORMAL || mode == REGULATOR_MODE_IDLE) in mcp16502_of_map_mode()
81 return mode; in mcp16502_of_map_mode()
116 * struct mcp16502 - PMIC representation
126 * mcp16502_gpio_set_mode() - set the GPIO corresponding value
130 static void mcp16502_gpio_set_mode(struct mcp16502 *mcp, int mode) in mcp16502_gpio_set_mode() argument
132 switch (mode) { in mcp16502_gpio_set_mode()
134 gpiod_set_value(mcp->lpm, 0); in mcp16502_gpio_set_mode()
138 gpiod_set_value(mcp->lpm, 1); in mcp16502_gpio_set_mode()
141 pr_err("%s: %d invalid\n", __func__, mode); in mcp16502_gpio_set_mode()
146 * mcp16502_get_reg() - get the PMIC's configuration register for opmode
149 * @opmode: the PMIC's operating mode ACTIVE, Low-power, Hibernate
163 return -EINVAL; in mcp16502_get_reg()
168 * mcp16502_get_mode() - return the current operating mode of a regulator
171 * use the Active mode registers.
173 * Note: this is different from the PMIC's operatig mode, it is the
174 * MODE bit from the regulator's register.
185 ret = regmap_read(rdev->regmap, reg, &val); in mcp16502_get_mode()
200 * _mcp16502_set_mode() - helper for set_mode and set_suspend_mode
202 * @rdev: the regulator for which we are setting the mode
203 * @mode: the regulator's mode (the one from MODE bit)
204 * @opmode: the PMIC's operating mode: Active/Low-power/Hibernate
206 static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, in _mcp16502_set_mode() argument
216 switch (mode) { in _mcp16502_set_mode()
224 return -EINVAL; in _mcp16502_set_mode()
227 reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val); in _mcp16502_set_mode()
232 * mcp16502_set_mode() - regulator_ops set_mode
234 static int mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode) in mcp16502_set_mode() argument
236 return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_ACTIVE); in mcp16502_set_mode()
240 * mcp16502_get_status() - regulator_ops get_status
247 ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)), in mcp16502_get_status()
264 * mcp16502_suspend_get_target_reg() - get the reg of the target suspend PMIC
265 * mode
276 dev_err(&rdev->dev, "invalid suspend target: %d\n", in mcp16502_suspend_get_target_reg()
280 return -EINVAL; in mcp16502_suspend_get_target_reg()
284 * mcp16502_set_suspend_voltage() - regulator_ops set_suspend_voltage
297 return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel); in mcp16502_set_suspend_voltage()
301 * mcp16502_set_suspend_mode() - regulator_ops set_suspend_mode
304 unsigned int mode) in mcp16502_set_suspend_mode() argument
308 return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_LPM); in mcp16502_set_suspend_mode()
311 return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_HIB); in mcp16502_set_suspend_mode()
313 dev_err(&rdev->dev, "invalid suspend target: %d\n", in mcp16502_set_suspend_mode()
317 return -EINVAL; in mcp16502_set_suspend_mode()
321 * mcp16502_set_suspend_enable() - regulator_ops set_suspend_enable
330 return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN); in mcp16502_set_suspend_enable()
334 * mcp16502_set_suspend_disable() - regulator_ops set_suspend_disable
343 return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0); in mcp16502_set_suspend_disable()
440 dev = &client->dev; in mcp16502_probe()
445 return -ENOMEM; in mcp16502_probe()
458 mcp->lpm = devm_gpiod_get(dev, "lpm", GPIOD_OUT_LOW); in mcp16502_probe()
459 if (IS_ERR(mcp->lpm)) { in mcp16502_probe()
460 dev_err(dev, "failed to get lpm pin: %ld\n", PTR_ERR(mcp->lpm)); in mcp16502_probe()
461 return PTR_ERR(mcp->lpm); in mcp16502_probe()
516 .name = "mcp16502-regulator",