2018-11-08 14:44:19 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-04-24 23:21:30 +08:00
|
|
|
/*
|
2021-01-12 17:01:00 +08:00
|
|
|
* ROHM BD9571MWV-M and BD9574MWF-M regulator driver
|
2017-04-24 23:21:30 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>
|
|
|
|
*
|
|
|
|
* Based on the TPS65086 driver
|
|
|
|
*
|
|
|
|
* NOTE: VD09 is missing
|
|
|
|
*/
|
|
|
|
|
2021-01-12 17:01:00 +08:00
|
|
|
#include <linux/mfd/rohm-generic.h>
|
2017-04-24 23:21:30 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/regulator/driver.h>
|
|
|
|
|
|
|
|
#include <linux/mfd/bd9571mwv.h>
|
|
|
|
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
struct bd9571mwv_reg {
|
2021-01-12 17:00:59 +08:00
|
|
|
struct regmap *regmap;
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
|
|
|
|
/* DDR Backup Power */
|
|
|
|
u8 bkup_mode_cnt_keepon; /* from "rohm,ddr-backup-power" */
|
|
|
|
u8 bkup_mode_cnt_saved;
|
2018-07-16 23:30:50 +08:00
|
|
|
bool bkup_mode_enabled;
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
|
|
|
|
/* Power switch type */
|
|
|
|
bool rstbmode_level;
|
|
|
|
bool rstbmode_pulse;
|
|
|
|
};
|
|
|
|
|
2017-04-24 23:21:30 +08:00
|
|
|
enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS };
|
|
|
|
|
|
|
|
#define BD9571MWV_REG(_name, _of, _id, _ops, _vr, _vm, _nv, _min, _step, _lmin)\
|
|
|
|
{ \
|
|
|
|
.name = _name, \
|
|
|
|
.of_match = of_match_ptr(_of), \
|
|
|
|
.regulators_node = "regulators", \
|
|
|
|
.id = _id, \
|
|
|
|
.ops = &_ops, \
|
|
|
|
.n_voltages = _nv, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
.vsel_reg = _vr, \
|
|
|
|
.vsel_mask = _vm, \
|
|
|
|
.min_uV = _min, \
|
|
|
|
.uV_step = _step, \
|
|
|
|
.linear_min_sel = _lmin, \
|
|
|
|
}
|
|
|
|
|
2017-05-28 14:02:17 +08:00
|
|
|
static int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
|
2017-04-24 23:21:30 +08:00
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = regmap_read(rdev->regmap, BD9571MWV_AVS_SET_MONI, &val);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return val & BD9571MWV_AVS_SET_MONI_MASK;
|
|
|
|
}
|
|
|
|
|
2017-05-28 14:02:17 +08:00
|
|
|
static int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
|
|
|
|
unsigned int sel)
|
2017-04-24 23:21:30 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = bd9571mwv_avs_get_moni_state(rdev);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return regmap_write_bits(rdev->regmap, BD9571MWV_AVS_VD09_VID(ret),
|
|
|
|
rdev->desc->vsel_mask, sel);
|
|
|
|
}
|
|
|
|
|
2017-05-28 14:02:17 +08:00
|
|
|
static int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
|
2017-04-24 23:21:30 +08:00
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = bd9571mwv_avs_get_moni_state(rdev);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = regmap_read(rdev->regmap, BD9571MWV_AVS_VD09_VID(ret), &val);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
val &= rdev->desc->vsel_mask;
|
|
|
|
val >>= ffs(rdev->desc->vsel_mask) - 1;
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2017-05-28 14:02:17 +08:00
|
|
|
static int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev,
|
|
|
|
unsigned int sel)
|
2017-04-24 23:21:30 +08:00
|
|
|
{
|
|
|
|
return regmap_write_bits(rdev->regmap, BD9571MWV_DVFS_SETVID,
|
|
|
|
rdev->desc->vsel_mask, sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Operations permitted on AVS voltage regulator */
|
2019-01-24 18:02:09 +08:00
|
|
|
static const struct regulator_ops avs_ops = {
|
2017-04-24 23:21:30 +08:00
|
|
|
.set_voltage_sel = bd9571mwv_avs_set_voltage_sel_regmap,
|
|
|
|
.map_voltage = regulator_map_voltage_linear,
|
|
|
|
.get_voltage_sel = bd9571mwv_avs_get_voltage_sel_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_linear,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Operations permitted on voltage regulators */
|
2019-01-24 18:02:09 +08:00
|
|
|
static const struct regulator_ops reg_ops = {
|
2017-04-24 23:21:30 +08:00
|
|
|
.set_voltage_sel = bd9571mwv_reg_set_voltage_sel_regmap,
|
|
|
|
.map_voltage = regulator_map_voltage_linear,
|
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_linear,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Operations permitted on voltage monitors */
|
2019-01-24 18:02:09 +08:00
|
|
|
static const struct regulator_ops vid_ops = {
|
2017-04-24 23:21:30 +08:00
|
|
|
.map_voltage = regulator_map_voltage_linear,
|
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_linear,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:09 +08:00
|
|
|
static const struct regulator_desc regulators[] = {
|
2017-04-24 23:21:30 +08:00
|
|
|
BD9571MWV_REG("VD09", "vd09", VD09, avs_ops, 0, 0x7f,
|
2021-03-12 21:02:40 +08:00
|
|
|
0x6f, 600000, 10000, 0x3c),
|
2017-04-24 23:21:30 +08:00
|
|
|
BD9571MWV_REG("VD18", "vd18", VD18, vid_ops, BD9571MWV_VD18_VID, 0xf,
|
|
|
|
16, 1625000, 25000, 0),
|
|
|
|
BD9571MWV_REG("VD25", "vd25", VD25, vid_ops, BD9571MWV_VD25_VID, 0xf,
|
|
|
|
16, 2150000, 50000, 0),
|
|
|
|
BD9571MWV_REG("VD33", "vd33", VD33, vid_ops, BD9571MWV_VD33_VID, 0xf,
|
|
|
|
11, 2800000, 100000, 0),
|
|
|
|
BD9571MWV_REG("DVFS", "dvfs", DVFS, reg_ops,
|
|
|
|
BD9571MWV_DVFS_MONIVDAC, 0x7f,
|
2021-03-12 21:02:40 +08:00
|
|
|
0x6f, 600000, 10000, 0x3c),
|
2017-04-24 23:21:30 +08:00
|
|
|
};
|
|
|
|
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2021-01-12 17:00:59 +08:00
|
|
|
static int bd9571mwv_bkup_mode_read(struct bd9571mwv_reg *bdreg,
|
|
|
|
unsigned int *mode)
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2021-01-12 17:00:59 +08:00
|
|
|
ret = regmap_read(bdreg->regmap, BD9571MWV_BKUP_MODE_CNT, mode);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
if (ret) {
|
2021-01-12 17:00:59 +08:00
|
|
|
dev_err(regmap_get_device(bdreg->regmap),
|
|
|
|
"failed to read backup mode (%d)\n", ret);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-01-12 17:00:59 +08:00
|
|
|
static int bd9571mwv_bkup_mode_write(struct bd9571mwv_reg *bdreg,
|
|
|
|
unsigned int mode)
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2021-01-12 17:00:59 +08:00
|
|
|
ret = regmap_write(bdreg->regmap, BD9571MWV_BKUP_MODE_CNT, mode);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
if (ret) {
|
2021-01-12 17:00:59 +08:00
|
|
|
dev_err(regmap_get_device(bdreg->regmap),
|
|
|
|
"failed to configure backup mode 0x%x (%d)\n",
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
mode, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-16 23:30:50 +08:00
|
|
|
static ssize_t backup_mode_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
|
|
|
|
|
2021-03-12 21:02:42 +08:00
|
|
|
return sysfs_emit(buf, "%s\n", bdreg->bkup_mode_enabled ? "on" : "off");
|
2018-07-16 23:30:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t backup_mode_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
|
regulator: bd9571mwv: Add support for toggle power switches
Extend the existing support for backup mode to toggle power switches.
With a toggle power switch (or level signal), the following steps must
be followed exactly:
1. Configure PMIC for backup mode, to change the role of the
accessory power switch from a power switch to a wake-up switch,
2. Switch accessory power switch off, to prepare for system suspend,
which is a manual step not controlled by software,
3. Suspend system,
4. Switch accessory power switch on, to resume the system.
Hence the PMIC is configured for backup mode when "on" or "1" is written
to the PMIC's "backup_mode" virtual file in sysfs. Conversely, writing
"off" or "0" reverts the role of the accessory switch to a power
switch.
Unlike with momentary switches, backup mode is not enabled by default,
as enabling it prevents the board from being powered off using the power
switch, which may confuse the user.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-07-16 23:30:51 +08:00
|
|
|
unsigned int mode;
|
2018-07-16 23:30:50 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!count)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = kstrtobool(buf, &bdreg->bkup_mode_enabled);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
regulator: bd9571mwv: Add support for toggle power switches
Extend the existing support for backup mode to toggle power switches.
With a toggle power switch (or level signal), the following steps must
be followed exactly:
1. Configure PMIC for backup mode, to change the role of the
accessory power switch from a power switch to a wake-up switch,
2. Switch accessory power switch off, to prepare for system suspend,
which is a manual step not controlled by software,
3. Suspend system,
4. Switch accessory power switch on, to resume the system.
Hence the PMIC is configured for backup mode when "on" or "1" is written
to the PMIC's "backup_mode" virtual file in sysfs. Conversely, writing
"off" or "0" reverts the role of the accessory switch to a power
switch.
Unlike with momentary switches, backup mode is not enabled by default,
as enabling it prevents the board from being powered off using the power
switch, which may confuse the user.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-07-16 23:30:51 +08:00
|
|
|
if (!bdreg->rstbmode_level)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure DDR Backup Mode, to change the role of the accessory power
|
|
|
|
* switch from a power switch to a wake-up switch, or vice versa
|
|
|
|
*/
|
2021-01-12 17:00:59 +08:00
|
|
|
ret = bd9571mwv_bkup_mode_read(bdreg, &mode);
|
regulator: bd9571mwv: Add support for toggle power switches
Extend the existing support for backup mode to toggle power switches.
With a toggle power switch (or level signal), the following steps must
be followed exactly:
1. Configure PMIC for backup mode, to change the role of the
accessory power switch from a power switch to a wake-up switch,
2. Switch accessory power switch off, to prepare for system suspend,
which is a manual step not controlled by software,
3. Suspend system,
4. Switch accessory power switch on, to resume the system.
Hence the PMIC is configured for backup mode when "on" or "1" is written
to the PMIC's "backup_mode" virtual file in sysfs. Conversely, writing
"off" or "0" reverts the role of the accessory switch to a power
switch.
Unlike with momentary switches, backup mode is not enabled by default,
as enabling it prevents the board from being powered off using the power
switch, which may confuse the user.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-07-16 23:30:51 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
mode &= ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK;
|
|
|
|
if (bdreg->bkup_mode_enabled)
|
|
|
|
mode |= bdreg->bkup_mode_cnt_keepon;
|
|
|
|
|
2021-01-12 17:00:59 +08:00
|
|
|
ret = bd9571mwv_bkup_mode_write(bdreg, mode);
|
regulator: bd9571mwv: Add support for toggle power switches
Extend the existing support for backup mode to toggle power switches.
With a toggle power switch (or level signal), the following steps must
be followed exactly:
1. Configure PMIC for backup mode, to change the role of the
accessory power switch from a power switch to a wake-up switch,
2. Switch accessory power switch off, to prepare for system suspend,
which is a manual step not controlled by software,
3. Suspend system,
4. Switch accessory power switch on, to resume the system.
Hence the PMIC is configured for backup mode when "on" or "1" is written
to the PMIC's "backup_mode" virtual file in sysfs. Conversely, writing
"off" or "0" reverts the role of the accessory switch to a power
switch.
Unlike with momentary switches, backup mode is not enabled by default,
as enabling it prevents the board from being powered off using the power
switch, which may confuse the user.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-07-16 23:30:51 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-07-16 23:30:50 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-07-24 14:32:59 +08:00
|
|
|
static DEVICE_ATTR_RW(backup_mode);
|
2018-07-16 23:30:50 +08:00
|
|
|
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
static int bd9571mwv_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
|
|
|
|
unsigned int mode;
|
|
|
|
int ret;
|
|
|
|
|
2018-07-16 23:30:50 +08:00
|
|
|
if (!bdreg->bkup_mode_enabled)
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Save DDR Backup Mode */
|
2021-01-12 17:00:59 +08:00
|
|
|
ret = bd9571mwv_bkup_mode_read(bdreg, &mode);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
bdreg->bkup_mode_cnt_saved = mode;
|
|
|
|
|
|
|
|
if (!bdreg->rstbmode_pulse)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Enable DDR Backup Mode */
|
|
|
|
mode &= ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK;
|
|
|
|
mode |= bdreg->bkup_mode_cnt_keepon;
|
|
|
|
|
|
|
|
if (mode != bdreg->bkup_mode_cnt_saved)
|
2021-01-12 17:00:59 +08:00
|
|
|
return bd9571mwv_bkup_mode_write(bdreg, mode);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bd9571mwv_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
|
|
|
|
|
2018-07-16 23:30:50 +08:00
|
|
|
if (!bdreg->bkup_mode_enabled)
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Restore DDR Backup Mode */
|
2021-01-12 17:00:59 +08:00
|
|
|
return bd9571mwv_bkup_mode_write(bdreg, bdreg->bkup_mode_cnt_saved);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dev_pm_ops bd9571mwv_pm = {
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(bd9571mwv_suspend, bd9571mwv_resume)
|
|
|
|
};
|
|
|
|
|
2018-07-16 23:30:50 +08:00
|
|
|
static int bd9571mwv_regulator_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
device_remove_file(&pdev->dev, &dev_attr_backup_mode);
|
|
|
|
return 0;
|
|
|
|
}
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
#define DEV_PM_OPS &bd9571mwv_pm
|
|
|
|
#else
|
|
|
|
#define DEV_PM_OPS NULL
|
2018-07-16 23:30:50 +08:00
|
|
|
#define bd9571mwv_regulator_remove NULL
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
|
|
|
|
2017-04-24 23:21:30 +08:00
|
|
|
static int bd9571mwv_regulator_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct regulator_config config = { };
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
struct bd9571mwv_reg *bdreg;
|
2017-04-24 23:21:30 +08:00
|
|
|
struct regulator_dev *rdev;
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
unsigned int val;
|
2017-04-24 23:21:30 +08:00
|
|
|
int i;
|
2021-01-12 17:01:00 +08:00
|
|
|
enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
|
2017-04-24 23:21:30 +08:00
|
|
|
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
bdreg = devm_kzalloc(&pdev->dev, sizeof(*bdreg), GFP_KERNEL);
|
|
|
|
if (!bdreg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2021-01-12 17:00:59 +08:00
|
|
|
bdreg->regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
|
|
|
|
platform_set_drvdata(pdev, bdreg);
|
2017-04-24 23:21:30 +08:00
|
|
|
|
|
|
|
config.dev = &pdev->dev;
|
2021-01-12 17:00:59 +08:00
|
|
|
config.dev->of_node = pdev->dev.parent->of_node;
|
|
|
|
config.driver_data = bdreg;
|
|
|
|
config.regmap = bdreg->regmap;
|
2017-04-24 23:21:30 +08:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(regulators); i++) {
|
2021-01-12 17:01:00 +08:00
|
|
|
/* BD9574MWF supports DVFS only */
|
|
|
|
if (chip == ROHM_CHIP_TYPE_BD9574 && regulators[i].id != DVFS)
|
|
|
|
continue;
|
2017-04-24 23:21:30 +08:00
|
|
|
rdev = devm_regulator_register(&pdev->dev, ®ulators[i],
|
|
|
|
&config);
|
|
|
|
if (IS_ERR(rdev)) {
|
2021-01-12 17:00:59 +08:00
|
|
|
dev_err(&pdev->dev, "failed to register %s regulator\n",
|
2021-03-12 21:02:41 +08:00
|
|
|
regulators[i].name);
|
2017-04-24 23:21:30 +08:00
|
|
|
return PTR_ERR(rdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
val = 0;
|
2021-01-12 17:00:59 +08:00
|
|
|
of_property_read_u32(config.dev->of_node, "rohm,ddr-backup-power", &val);
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
if (val & ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK) {
|
2021-01-12 17:00:59 +08:00
|
|
|
dev_err(&pdev->dev, "invalid %s mode %u\n",
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
"rohm,ddr-backup-power", val);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
bdreg->bkup_mode_cnt_keepon = val;
|
|
|
|
|
2021-01-12 17:00:59 +08:00
|
|
|
bdreg->rstbmode_level = of_property_read_bool(config.dev->of_node,
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
"rohm,rstbmode-level");
|
2021-01-12 17:00:59 +08:00
|
|
|
bdreg->rstbmode_pulse = of_property_read_bool(config.dev->of_node,
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
"rohm,rstbmode-pulse");
|
|
|
|
if (bdreg->rstbmode_level && bdreg->rstbmode_pulse) {
|
2021-01-12 17:00:59 +08:00
|
|
|
dev_err(&pdev->dev, "only one rohm,rstbmode-* may be specified");
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2018-07-16 23:30:50 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
if (bdreg->bkup_mode_cnt_keepon) {
|
2018-07-16 23:30:50 +08:00
|
|
|
int ret;
|
|
|
|
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
/*
|
2018-07-16 23:30:50 +08:00
|
|
|
* Backup mode is enabled by default in pulse mode, but needs
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
* explicit user setup in level mode.
|
|
|
|
*/
|
2018-07-16 23:30:50 +08:00
|
|
|
bdreg->bkup_mode_enabled = bdreg->rstbmode_pulse;
|
|
|
|
|
|
|
|
ret = device_create_file(&pdev->dev, &dev_attr_backup_mode);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
}
|
2018-07-16 23:30:50 +08:00
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
|
2017-04-24 23:21:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct platform_device_id bd9571mwv_regulator_id_table[] = {
|
2021-01-12 17:01:00 +08:00
|
|
|
{ "bd9571mwv-regulator", ROHM_CHIP_TYPE_BD9571 },
|
|
|
|
{ "bd9574mwf-regulator", ROHM_CHIP_TYPE_BD9574 },
|
2017-04-24 23:21:30 +08:00
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(platform, bd9571mwv_regulator_id_table);
|
|
|
|
|
|
|
|
static struct platform_driver bd9571mwv_regulator_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "bd9571mwv-regulator",
|
regulator: bd9571mwv: Add support for backup mode
The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
rails powered while the main SoC is powered down.
Which DDR rails are to be kept powered is board-specific, and controlled
using the optional "rohm,ddr-backup-power" DT property. In the absence
of this property, backup mode is not available.
Backup mode can be enabled or disabled by the user using the standard
"wakeup" virtual file in sysfs, e.g. to enable:
echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
When the PMIC is configured for backup mode, the role of the accessory
power switch changes from a power switch to a wake-up switch.
Two types of switches (or signals) can be used:
A. With a momentary power switch (or pulse signal), the PMIC is
configured for backup mode in the PMIC driver's suspend callback,
during system suspend.
Backup mode is enabled by default, as there is no further impact
during normal system operation.
B. With a toggle power switch (or level signal), the following steps
must be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system
suspend, which is a manual step not controlled by software,
3. Suspend system.
This mode is not yet supported by the driver.
As the switch type is board-specific, and cannot be determined
automatically, it is obtained from the presence of one of the
"rohm,rstbmode-*" properties in DT.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-18 21:18:04 +08:00
|
|
|
.pm = DEV_PM_OPS,
|
2017-04-24 23:21:30 +08:00
|
|
|
},
|
|
|
|
.probe = bd9571mwv_regulator_probe,
|
2018-07-16 23:30:50 +08:00
|
|
|
.remove = bd9571mwv_regulator_remove,
|
2017-04-24 23:21:30 +08:00
|
|
|
.id_table = bd9571mwv_regulator_id_table,
|
|
|
|
};
|
|
|
|
module_platform_driver(bd9571mwv_regulator_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Marek Vasut <marek.vasut+renesas@gmail.com>");
|
|
|
|
MODULE_DESCRIPTION("BD9571MWV Regulator driver");
|
|
|
|
MODULE_LICENSE("GPL v2");
|