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.
75 * enum mcp16502_reg - MCP16502 regulators's registers
77 * @MCP16502_REG_LPM: low power mode state register
79 * @MCP16502_REG_HPM: high-performance mode register
102 static unsigned int mcp16502_of_map_mode(unsigned int mode) in mcp16502_of_map_mode() argument
104 if (mode == REGULATOR_MODE_NORMAL || mode == REGULATOR_MODE_IDLE) in mcp16502_of_map_mode()
105 return mode; in mcp16502_of_map_mode()
145 * struct mcp16502 - PMIC representation
153 * mcp16502_gpio_set_mode() - set the GPIO corresponding value
157 static void mcp16502_gpio_set_mode(struct mcp16502 *mcp, int mode) in mcp16502_gpio_set_mode() argument
159 switch (mode) { in mcp16502_gpio_set_mode()
161 gpiod_set_value(mcp->lpm, 0); in mcp16502_gpio_set_mode()
165 gpiod_set_value(mcp->lpm, 1); in mcp16502_gpio_set_mode()
168 pr_err("%s: %d invalid\n", __func__, mode); in mcp16502_gpio_set_mode()
173 * mcp16502_get_reg() - get the PMIC's state configuration register for opmode
176 * @opmode: the PMIC's operating mode ACTIVE, Low-power, Hibernate
188 return -EINVAL; in mcp16502_get_state_reg()
193 * mcp16502_get_mode() - return the current operating mode of a regulator
196 * use the Active mode registers.
198 * Note: this is different from the PMIC's operatig mode, it is the
199 * MODE bit from the regulator's register.
210 ret = regmap_read(rdev->regmap, reg, &val); in mcp16502_get_mode()
225 * _mcp16502_set_mode() - helper for set_mode and set_suspend_mode
227 * @rdev: the regulator for which we are setting the mode
228 * @mode: the regulator's mode (the one from MODE bit)
229 * @opmode: the PMIC's operating mode: Active/Low-power/Hibernate
231 static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, in _mcp16502_set_mode() argument
241 switch (mode) { in _mcp16502_set_mode()
249 return -EINVAL; in _mcp16502_set_mode()
252 reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val); in _mcp16502_set_mode()
257 * mcp16502_set_mode() - regulator_ops set_mode
259 static int mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode) in mcp16502_set_mode() argument
261 return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_ACTIVE); in mcp16502_set_mode()
265 * mcp16502_get_status() - regulator_ops get_status
272 ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)), in mcp16502_get_status()
296 ret = regmap_read(rdev->regmap, MCP16502_REG_BASE(id, CFG), &val); in mcp16502_set_voltage_time_sel()
301 uV_delta = abs(new_sel * rdev->desc->linear_ranges->step - in mcp16502_set_voltage_time_sel()
302 old_sel * rdev->desc->linear_ranges->step); in mcp16502_set_voltage_time_sel()
319 return -EINVAL; in mcp16502_set_voltage_time_sel()
327 * mcp16502_suspend_get_target_reg() - get the reg of the target suspend PMIC
328 * mode
339 dev_err(&rdev->dev, "invalid suspend target: %d\n", in mcp16502_suspend_get_target_reg()
343 return -EINVAL; in mcp16502_suspend_get_target_reg()
347 * mcp16502_set_suspend_voltage() - regulator_ops set_suspend_voltage
360 return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel); in mcp16502_set_suspend_voltage()
364 * mcp16502_set_suspend_mode() - regulator_ops set_suspend_mode
367 unsigned int mode) in mcp16502_set_suspend_mode() argument
371 return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_LPM); in mcp16502_set_suspend_mode()
374 return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_HIB); in mcp16502_set_suspend_mode()
376 dev_err(&rdev->dev, "invalid suspend target: %d\n", in mcp16502_set_suspend_mode()
380 return -EINVAL; in mcp16502_set_suspend_mode()
384 * mcp16502_set_suspend_enable() - regulator_ops set_suspend_enable
393 return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN); in mcp16502_set_suspend_enable()
397 * mcp16502_set_suspend_disable() - regulator_ops set_suspend_disable
406 return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0); in mcp16502_set_suspend_disable()
512 dev = &client->dev; in mcp16502_probe()
517 return -ENOMEM; in mcp16502_probe()
530 mcp->lpm = devm_gpiod_get_optional(dev, "lpm", GPIOD_OUT_LOW); in mcp16502_probe()
531 if (IS_ERR(mcp->lpm)) { in mcp16502_probe()
532 dev_err(dev, "failed to get lpm pin: %ld\n", PTR_ERR(mcp->lpm)); in mcp16502_probe()
533 return PTR_ERR(mcp->lpm); in mcp16502_probe()
588 .name = "mcp16502-regulator",