2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-02-05 12:33:30 +08:00
|
|
|
/*
|
|
|
|
* Voltage regulation driver for active-semi ACT8945A PMIC
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Atmel Corporation
|
|
|
|
*
|
|
|
|
* Author: Wenyou Yang <wenyou.yang@atmel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/platform_device.h>
|
2018-12-11 23:56:36 +08:00
|
|
|
#include <linux/regmap.h>
|
2016-02-05 12:33:30 +08:00
|
|
|
#include <linux/regulator/driver.h>
|
|
|
|
#include <linux/regulator/machine.h>
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#include <dt-bindings/regulator/active-semi,8945a-regulator.h>
|
2016-02-05 12:33:30 +08:00
|
|
|
|
2023-01-13 14:44:12 +08:00
|
|
|
/*
|
2016-02-05 12:33:30 +08:00
|
|
|
* ACT8945A Global Register Map.
|
|
|
|
*/
|
|
|
|
#define ACT8945A_SYS_MODE 0x00
|
|
|
|
#define ACT8945A_SYS_CTRL 0x01
|
2018-12-11 23:56:36 +08:00
|
|
|
#define ACT8945A_SYS_UNLK_REGS 0x0b
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_DCDC1_VSET1 0x20
|
|
|
|
#define ACT8945A_DCDC1_VSET2 0x21
|
|
|
|
#define ACT8945A_DCDC1_CTRL 0x22
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_DCDC1_SUS 0x24
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_DCDC2_VSET1 0x30
|
|
|
|
#define ACT8945A_DCDC2_VSET2 0x31
|
|
|
|
#define ACT8945A_DCDC2_CTRL 0x32
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_DCDC2_SUS 0x34
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_DCDC3_VSET1 0x40
|
|
|
|
#define ACT8945A_DCDC3_VSET2 0x41
|
|
|
|
#define ACT8945A_DCDC3_CTRL 0x42
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_DCDC3_SUS 0x44
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_LDO1_VSET 0x50
|
|
|
|
#define ACT8945A_LDO1_CTRL 0x51
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_LDO1_SUS 0x52
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_LDO2_VSET 0x54
|
|
|
|
#define ACT8945A_LDO2_CTRL 0x55
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_LDO2_SUS 0x56
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_LDO3_VSET 0x60
|
|
|
|
#define ACT8945A_LDO3_CTRL 0x61
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_LDO3_SUS 0x62
|
2016-02-05 12:33:30 +08:00
|
|
|
#define ACT8945A_LDO4_VSET 0x64
|
|
|
|
#define ACT8945A_LDO4_CTRL 0x65
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
#define ACT8945A_LDO4_SUS 0x66
|
2016-02-05 12:33:30 +08:00
|
|
|
|
2023-01-13 14:44:12 +08:00
|
|
|
/*
|
2016-02-05 12:33:30 +08:00
|
|
|
* Field Definitions.
|
|
|
|
*/
|
|
|
|
#define ACT8945A_ENA 0x80 /* ON - [7] */
|
|
|
|
#define ACT8945A_VSEL_MASK 0x3F /* VSET - [5:0] */
|
|
|
|
|
2023-01-13 14:44:12 +08:00
|
|
|
/*
|
2016-02-05 12:33:30 +08:00
|
|
|
* ACT8945A Voltage Number
|
|
|
|
*/
|
|
|
|
#define ACT8945A_VOLTAGE_NUM 64
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ACT8945A_ID_DCDC1,
|
|
|
|
ACT8945A_ID_DCDC2,
|
|
|
|
ACT8945A_ID_DCDC3,
|
|
|
|
ACT8945A_ID_LDO1,
|
|
|
|
ACT8945A_ID_LDO2,
|
|
|
|
ACT8945A_ID_LDO3,
|
|
|
|
ACT8945A_ID_LDO4,
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
ACT8945A_ID_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct act8945a_pmic {
|
|
|
|
struct regmap *regmap;
|
|
|
|
u32 op_mode[ACT8945A_ID_MAX];
|
2016-02-05 12:33:30 +08:00
|
|
|
};
|
|
|
|
|
2020-05-08 23:43:36 +08:00
|
|
|
static const struct linear_range act8945a_voltage_ranges[] = {
|
2016-02-05 12:33:30 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(600000, 0, 23, 25000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1200000, 24, 47, 50000),
|
|
|
|
REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000),
|
|
|
|
};
|
|
|
|
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
static int act8945a_set_suspend_state(struct regulator_dev *rdev, bool enable)
|
|
|
|
{
|
|
|
|
struct regmap *regmap = rdev->regmap;
|
2019-01-04 22:42:36 +08:00
|
|
|
int id = rdev_get_id(rdev);
|
|
|
|
int reg, val;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ACT8945A_ID_DCDC1:
|
|
|
|
reg = ACT8945A_DCDC1_SUS;
|
|
|
|
val = 0xa8;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_DCDC2:
|
|
|
|
reg = ACT8945A_DCDC2_SUS;
|
|
|
|
val = 0xa8;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_DCDC3:
|
|
|
|
reg = ACT8945A_DCDC3_SUS;
|
|
|
|
val = 0xa8;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO1:
|
|
|
|
reg = ACT8945A_LDO1_SUS;
|
|
|
|
val = 0xe8;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO2:
|
|
|
|
reg = ACT8945A_LDO2_SUS;
|
|
|
|
val = 0xe8;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO3:
|
|
|
|
reg = ACT8945A_LDO3_SUS;
|
|
|
|
val = 0xe8;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO4:
|
|
|
|
reg = ACT8945A_LDO4_SUS;
|
|
|
|
val = 0xe8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
val |= BIT(4);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the PMIC to enable/disable this output when entering hibernate
|
|
|
|
* mode.
|
|
|
|
*/
|
|
|
|
return regmap_write(regmap, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int act8945a_set_suspend_enable(struct regulator_dev *rdev)
|
|
|
|
{
|
|
|
|
return act8945a_set_suspend_state(rdev, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int act8945a_set_suspend_disable(struct regulator_dev *rdev)
|
|
|
|
{
|
|
|
|
return act8945a_set_suspend_state(rdev, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int act8945a_of_map_mode(unsigned int mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case ACT8945A_REGULATOR_MODE_FIXED:
|
|
|
|
case ACT8945A_REGULATOR_MODE_NORMAL:
|
|
|
|
return REGULATOR_MODE_NORMAL;
|
|
|
|
case ACT8945A_REGULATOR_MODE_LOWPOWER:
|
|
|
|
return REGULATOR_MODE_STANDBY;
|
|
|
|
default:
|
|
|
|
return REGULATOR_MODE_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int act8945a_set_mode(struct regulator_dev *rdev, unsigned int mode)
|
|
|
|
{
|
|
|
|
struct act8945a_pmic *act8945a = rdev_get_drvdata(rdev);
|
|
|
|
struct regmap *regmap = rdev->regmap;
|
2019-01-04 22:42:36 +08:00
|
|
|
int id = rdev_get_id(rdev);
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
int reg, ret, val = 0;
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ACT8945A_ID_DCDC1:
|
|
|
|
reg = ACT8945A_DCDC1_CTRL;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_DCDC2:
|
|
|
|
reg = ACT8945A_DCDC2_CTRL;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_DCDC3:
|
|
|
|
reg = ACT8945A_DCDC3_CTRL;
|
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO1:
|
2019-08-13 02:39:54 +08:00
|
|
|
reg = ACT8945A_LDO1_CTRL;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO2:
|
2019-08-13 02:39:54 +08:00
|
|
|
reg = ACT8945A_LDO2_CTRL;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO3:
|
2019-08-13 02:39:54 +08:00
|
|
|
reg = ACT8945A_LDO3_CTRL;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
break;
|
|
|
|
case ACT8945A_ID_LDO4:
|
2019-08-13 02:39:54 +08:00
|
|
|
reg = ACT8945A_LDO4_CTRL;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case REGULATOR_MODE_STANDBY:
|
2019-01-04 22:42:36 +08:00
|
|
|
if (id > ACT8945A_ID_DCDC3)
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
val = BIT(5);
|
|
|
|
break;
|
|
|
|
case REGULATOR_MODE_NORMAL:
|
2019-01-04 22:42:36 +08:00
|
|
|
if (id <= ACT8945A_ID_DCDC3)
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
val = BIT(5);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = regmap_update_bits(regmap, reg, BIT(5), val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
act8945a->op_mode[id] = mode;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int act8945a_get_mode(struct regulator_dev *rdev)
|
|
|
|
{
|
|
|
|
struct act8945a_pmic *act8945a = rdev_get_drvdata(rdev);
|
2019-01-04 22:42:36 +08:00
|
|
|
int id = rdev_get_id(rdev);
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
|
|
|
|
if (id < ACT8945A_ID_DCDC1 || id >= ACT8945A_ID_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return act8945a->op_mode[id];
|
|
|
|
}
|
|
|
|
|
2017-01-28 21:33:28 +08:00
|
|
|
static const struct regulator_ops act8945a_ops = {
|
2016-02-05 12:33:30 +08:00
|
|
|
.list_voltage = regulator_list_voltage_linear_range,
|
|
|
|
.map_voltage = regulator_map_voltage_linear_range,
|
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
.set_mode = act8945a_set_mode,
|
|
|
|
.get_mode = act8945a_get_mode,
|
2016-02-05 12:33:30 +08:00
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
.set_suspend_enable = act8945a_set_suspend_enable,
|
|
|
|
.set_suspend_disable = act8945a_set_suspend_disable,
|
2016-02-05 12:33:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ACT89xx_REG(_name, _family, _id, _vsel_reg, _supply) \
|
|
|
|
[_family##_ID_##_id] = { \
|
|
|
|
.name = _name, \
|
|
|
|
.supply_name = _supply, \
|
|
|
|
.of_match = of_match_ptr("REG_"#_id), \
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
.of_map_mode = act8945a_of_map_mode, \
|
2016-02-05 12:33:30 +08:00
|
|
|
.regulators_node = of_match_ptr("regulators"), \
|
|
|
|
.id = _family##_ID_##_id, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.ops = &act8945a_ops, \
|
|
|
|
.n_voltages = ACT8945A_VOLTAGE_NUM, \
|
|
|
|
.linear_ranges = act8945a_voltage_ranges, \
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(act8945a_voltage_ranges), \
|
|
|
|
.vsel_reg = _family##_##_id##_##_vsel_reg, \
|
|
|
|
.vsel_mask = ACT8945A_VSEL_MASK, \
|
|
|
|
.enable_reg = _family##_##_id##_CTRL, \
|
|
|
|
.enable_mask = ACT8945A_ENA, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct regulator_desc act8945a_regulators[] = {
|
|
|
|
ACT89xx_REG("DCDC_REG1", ACT8945A, DCDC1, VSET1, "vp1"),
|
|
|
|
ACT89xx_REG("DCDC_REG2", ACT8945A, DCDC2, VSET1, "vp2"),
|
|
|
|
ACT89xx_REG("DCDC_REG3", ACT8945A, DCDC3, VSET1, "vp3"),
|
|
|
|
ACT89xx_REG("LDO_REG1", ACT8945A, LDO1, VSET, "inl45"),
|
|
|
|
ACT89xx_REG("LDO_REG2", ACT8945A, LDO2, VSET, "inl45"),
|
|
|
|
ACT89xx_REG("LDO_REG3", ACT8945A, LDO3, VSET, "inl67"),
|
|
|
|
ACT89xx_REG("LDO_REG4", ACT8945A, LDO4, VSET, "inl67"),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct regulator_desc act8945a_alt_regulators[] = {
|
|
|
|
ACT89xx_REG("DCDC_REG1", ACT8945A, DCDC1, VSET2, "vp1"),
|
|
|
|
ACT89xx_REG("DCDC_REG2", ACT8945A, DCDC2, VSET2, "vp2"),
|
|
|
|
ACT89xx_REG("DCDC_REG3", ACT8945A, DCDC3, VSET2, "vp3"),
|
|
|
|
ACT89xx_REG("LDO_REG1", ACT8945A, LDO1, VSET, "inl45"),
|
|
|
|
ACT89xx_REG("LDO_REG2", ACT8945A, LDO2, VSET, "inl45"),
|
|
|
|
ACT89xx_REG("LDO_REG3", ACT8945A, LDO3, VSET, "inl67"),
|
|
|
|
ACT89xx_REG("LDO_REG4", ACT8945A, LDO4, VSET, "inl67"),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int act8945a_pmic_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct regulator_config config = { };
|
|
|
|
const struct regulator_desc *regulators;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
struct act8945a_pmic *act8945a;
|
2016-02-05 12:33:30 +08:00
|
|
|
struct regulator_dev *rdev;
|
|
|
|
int i, num_regulators;
|
|
|
|
bool voltage_select;
|
|
|
|
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
act8945a = devm_kzalloc(&pdev->dev, sizeof(*act8945a), GFP_KERNEL);
|
|
|
|
if (!act8945a)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
act8945a->regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
|
|
|
if (!act8945a->regmap) {
|
2018-12-11 23:56:36 +08:00
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"could not retrieve regmap from parent device\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-02-05 12:33:30 +08:00
|
|
|
voltage_select = of_property_read_bool(pdev->dev.parent->of_node,
|
|
|
|
"active-semi,vsel-high");
|
|
|
|
|
|
|
|
if (voltage_select) {
|
|
|
|
regulators = act8945a_alt_regulators;
|
|
|
|
num_regulators = ARRAY_SIZE(act8945a_alt_regulators);
|
|
|
|
} else {
|
|
|
|
regulators = act8945a_regulators;
|
|
|
|
num_regulators = ARRAY_SIZE(act8945a_regulators);
|
|
|
|
}
|
|
|
|
|
|
|
|
config.dev = &pdev->dev;
|
|
|
|
config.dev->of_node = pdev->dev.parent->of_node;
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
config.driver_data = act8945a;
|
2016-02-05 12:33:30 +08:00
|
|
|
for (i = 0; i < num_regulators; i++) {
|
2018-12-11 23:56:45 +08:00
|
|
|
rdev = devm_regulator_register(&pdev->dev, ®ulators[i],
|
|
|
|
&config);
|
2016-02-05 12:33:30 +08:00
|
|
|
if (IS_ERR(rdev)) {
|
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"failed to register %s regulator\n",
|
|
|
|
regulators[i].name);
|
|
|
|
return PTR_ERR(rdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
platform_set_drvdata(pdev, act8945a);
|
|
|
|
|
2018-12-11 23:56:36 +08:00
|
|
|
/* Unlock expert registers. */
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
return regmap_write(act8945a->regmap, ACT8945A_SYS_UNLK_REGS, 0xef);
|
2016-02-05 12:33:30 +08:00
|
|
|
}
|
|
|
|
|
2018-12-17 18:37:51 +08:00
|
|
|
static int __maybe_unused act8945a_suspend(struct device *pdev)
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
{
|
|
|
|
struct act8945a_pmic *act8945a = dev_get_drvdata(pdev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the PMIC to enter the suspend mode on the next PWRHLD
|
|
|
|
* transition.
|
|
|
|
*/
|
|
|
|
return regmap_write(act8945a->regmap, ACT8945A_SYS_CTRL, 0x42);
|
|
|
|
}
|
|
|
|
|
2018-12-18 15:10:21 +08:00
|
|
|
static SIMPLE_DEV_PM_OPS(act8945a_pm, act8945a_suspend, NULL);
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
|
2018-12-11 23:56:50 +08:00
|
|
|
static void act8945a_pmic_shutdown(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct act8945a_pmic *act8945a = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the PMIC to shutdown everything on the next PWRHLD transition.
|
|
|
|
*/
|
|
|
|
regmap_write(act8945a->regmap, ACT8945A_SYS_CTRL, 0x0);
|
|
|
|
}
|
|
|
|
|
2016-02-05 12:33:30 +08:00
|
|
|
static struct platform_driver act8945a_pmic_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "act8945a-regulator",
|
regulator: act8945a-regulator: Implement PM functionalities
The regulator supports a dedicated suspend mode.
Implement the appropriate ->set_suspend_xx() hooks, add support for
->set_mode(), and provide basic PM ops functionalities to setup the
regulator in a suspend state when the system is entering suspend.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: remove shutdown function, use dev_pm_ops,
fix checkpatch warning, adapt commit message, add LDO modes support,
move modes constants to active-semi,8945a-regulator.h, remove rdevs from
struct act8945a_pmic, add op_mode to act8945a_pmic]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-11 23:56:41 +08:00
|
|
|
.pm = &act8945a_pm,
|
2016-02-05 12:33:30 +08:00
|
|
|
},
|
|
|
|
.probe = act8945a_pmic_probe,
|
2018-12-11 23:56:50 +08:00
|
|
|
.shutdown = act8945a_pmic_shutdown,
|
2016-02-05 12:33:30 +08:00
|
|
|
};
|
|
|
|
module_platform_driver(act8945a_pmic_driver);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Active-semi ACT8945A voltage regulator driver");
|
|
|
|
MODULE_AUTHOR("Wenyou Yang <wenyou.yang@atmel.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|