Lines Matching +full:regulator +full:- +full:state +full:- +full:standby

1 // SPDX-License-Identifier: GPL-2.0
9 // Inspired from tps65086-regulator.c
17 #include <linux/regulator/driver.h>
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
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
55 * registers in a generic way or accessing a regulator device by its id.
75 * enum mcp16502_reg - MCP16502 regulators's registers
76 * @MCP16502_REG_A: active state register
77 * @MCP16502_REG_LPM: low power mode state register
78 * @MCP16502_REG_HIB: hibernate state register
79 * @MCP16502_REG_HPM: high-performance mode register
146 * struct mcp16502 - PMIC representation
154 * mcp16502_gpio_set_mode() - set the GPIO corresponding value
162 gpiod_set_value(mcp->lpm, 0); in mcp16502_gpio_set_mode()
166 gpiod_set_value(mcp->lpm, 1); in mcp16502_gpio_set_mode()
174 * mcp16502_get_reg() - get the PMIC's state configuration register for opmode
176 * @rdev: the regulator whose register we are searching
177 * @opmode: the PMIC's operating mode ACTIVE, Low-power, Hibernate
189 return -EINVAL; in mcp16502_get_state_reg()
194 * mcp16502_get_mode() - return the current operating mode of a regulator
196 * Note: all functions that are not part of entering/exiting standby/suspend
200 * MODE bit from the regulator's register.
211 ret = regmap_read(rdev->regmap, reg, &val); in mcp16502_get_mode()
226 * _mcp16502_set_mode() - helper for set_mode and set_suspend_mode
228 * @rdev: the regulator for which we are setting the mode
229 * @mode: the regulator's mode (the one from MODE bit)
230 * @opmode: the PMIC's operating mode: Active/Low-power/Hibernate
250 return -EINVAL; in _mcp16502_set_mode()
253 reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val); in _mcp16502_set_mode()
258 * mcp16502_set_mode() - regulator_ops set_mode
266 * mcp16502_get_status() - regulator_ops get_status
273 ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)), in mcp16502_get_status()
297 ret = regmap_read(rdev->regmap, MCP16502_REG_BASE(id, CFG), &val); in mcp16502_set_voltage_time_sel()
302 uV_delta = abs(new_sel * rdev->desc->linear_ranges->step - in mcp16502_set_voltage_time_sel()
303 old_sel * rdev->desc->linear_ranges->step); in mcp16502_set_voltage_time_sel()
320 return -EINVAL; in mcp16502_set_voltage_time_sel()
328 * mcp16502_suspend_get_target_reg() - get the reg of the target suspend PMIC
340 dev_err(&rdev->dev, "invalid suspend target: %d\n", in mcp16502_suspend_get_target_reg()
344 return -EINVAL; in mcp16502_suspend_get_target_reg()
348 * mcp16502_set_suspend_voltage() - regulator_ops set_suspend_voltage
361 return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel); in mcp16502_set_suspend_voltage()
365 * mcp16502_set_suspend_mode() - regulator_ops set_suspend_mode
377 dev_err(&rdev->dev, "invalid suspend target: %d\n", in mcp16502_set_suspend_mode()
381 return -EINVAL; in mcp16502_set_suspend_mode()
385 * mcp16502_set_suspend_enable() - regulator_ops set_suspend_enable
394 return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN); in mcp16502_set_suspend_enable()
398 * mcp16502_set_suspend_disable() - regulator_ops set_suspend_disable
407 return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0); in mcp16502_set_suspend_disable()
513 dev = &client->dev; in mcp16502_probe()
518 return -ENOMEM; in mcp16502_probe()
531 mcp->lpm = devm_gpiod_get_optional(dev, "lpm", GPIOD_OUT_LOW); in mcp16502_probe()
532 if (IS_ERR(mcp->lpm)) { in mcp16502_probe()
533 dev_err(dev, "failed to get lpm pin: %ld\n", PTR_ERR(mcp->lpm)); in mcp16502_probe()
534 return PTR_ERR(mcp->lpm); in mcp16502_probe()
541 "failed to register %s regulator %ld\n", in mcp16502_probe()
589 .name = "mcp16502-regulator",