* [PATCH v4 0/5] add PM functionality for act8945a PMIC
@ 2018-12-13 12:49 Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 1/6] regulator: act8945a-regulator: unlock expert registers Claudiu.Beznea
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:49 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, Claudiu.Beznea
From: Claudiu Beznea <claudiu.beznea@microchip.com>
This series implements PM functionality for act8945a PMIC and use that support
on SAMA5D2 Xplained board.
Changes in v4:
- move dt-bindings/regulator/active-semi,8945a-regulator.h in documentation
patch; driver uses macros included in this file; due to this documentation
patch and drivers patches should go through the same tree
- make documentation patch, patch 2 of this series
Changes in v3:
- add patch "unlock expert registers"; it was wrongly missed in previous version
Changes in v2:
- split patch 1/1 from previous series in 3 patches: one adding regmap,
one adding pm functionality, one adding shutdown functionality
- use dev_pm_ops suspend function to set register specific to PWRHLD line: this
is specific to PMIC itself and not to regulators
- add mode support for LDOs
- add constants for mode in dt-bindings/regulator/active-semi,8945a-regulator.h
- document modes and regulator suspend states
- remove rdevs from struct act8945a_pmic since were not used anywhere
- add op_mode field in struct act8945a_pmic, update it when setting mode and
return it when reading mode (avoiding one extra register read while
reading mode)
- add a patch to fix a checkpatch.pl warning
- in shutdown function use directly act8945a->regmap instead of an intermediary
struct regmap variable
Boris Brezillon (2):
regulator: act8945a-regulator: Implement PM functionalities
ARM: dts: at91: sama5d2_xplained: Add proper regulator states for
suspend-to-mem
Claudiu Beznea (3):
regulator: act8945a-regulator: fix line over 80 chars warning
regulator: act8945a-regulator: add shutdown function
regulator: add documentation for regulator modes and suspend states
.../bindings/regulator/act8945a-regulator.txt | 34 ++++
arch/arm/boot/dts/at91-sama5d2_xplained.dts | 54 ++++++
drivers/regulator/act8945a-regulator.c | 200 ++++++++++++++++++++-
.../regulator/active-semi,8945a-regulator.h | 30 ++++
4 files changed, 312 insertions(+), 6 deletions(-)
create mode 100644 include/dt-bindings/regulator/active-semi,8945a-regulator.h
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 1/6] regulator: act8945a-regulator: unlock expert registers
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
@ 2018-12-13 12:49 ` Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 2/6] regulator: add documentation for regulator modes and suspend states Claudiu.Beznea
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:49 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, Claudiu.Beznea
From: Claudiu Beznea <claudiu.beznea@microchip.com>
Unlock expert registers for act8945a.
This is based on orginal work of Boris Brezillon at [1].
[1] https://www.spinics.net/lists/kernel/msg2942960.html
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
drivers/regulator/act8945a-regulator.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/act8945a-regulator.c b/drivers/regulator/act8945a-regulator.c
index 43fda8b4455a..8d71d9893d0d 100644
--- a/drivers/regulator/act8945a-regulator.c
+++ b/drivers/regulator/act8945a-regulator.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
@@ -23,6 +24,7 @@
*/
#define ACT8945A_SYS_MODE 0x00
#define ACT8945A_SYS_CTRL 0x01
+#define ACT8945A_SYS_UNLK_REGS 0x0b
#define ACT8945A_DCDC1_VSET1 0x20
#define ACT8945A_DCDC1_VSET2 0x21
#define ACT8945A_DCDC1_CTRL 0x22
@@ -123,9 +125,17 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
struct regulator_config config = { };
const struct regulator_desc *regulators;
struct regulator_dev *rdev;
+ struct regmap *regmap;
int i, num_regulators;
bool voltage_select;
+ regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!regmap) {
+ dev_err(&pdev->dev,
+ "could not retrieve regmap from parent device\n");
+ return -EINVAL;
+ }
+
voltage_select = of_property_read_bool(pdev->dev.parent->of_node,
"active-semi,vsel-high");
@@ -149,7 +159,8 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
}
}
- return 0;
+ /* Unlock expert registers. */
+ return regmap_write(regmap, ACT8945A_SYS_UNLK_REGS, 0xef);
}
static struct platform_driver act8945a_pmic_driver = {
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/6] regulator: add documentation for regulator modes and suspend states
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 1/6] regulator: act8945a-regulator: unlock expert registers Claudiu.Beznea
@ 2018-12-13 12:49 ` Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 3/6] regulator: act8945a-regulator: Implement PM functionalities Claudiu.Beznea
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:49 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, Claudiu.Beznea
From: Claudiu Beznea <claudiu.beznea@microchip.com>
Add documentation for regulator modes and suspend states.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
.../bindings/regulator/act8945a-regulator.txt | 34 ++++++++++++++++++++++
.../regulator/active-semi,8945a-regulator.h | 30 +++++++++++++++++++
2 files changed, 64 insertions(+)
create mode 100644 include/dt-bindings/regulator/active-semi,8945a-regulator.h
diff --git a/Documentation/devicetree/bindings/regulator/act8945a-regulator.txt b/Documentation/devicetree/bindings/regulator/act8945a-regulator.txt
index ac955dea00d1..4017527619ab 100644
--- a/Documentation/devicetree/bindings/regulator/act8945a-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/act8945a-regulator.txt
@@ -15,11 +15,17 @@ Optional input supply properties:
- inl67-supply: The input supply for REG_LDO3 and REG_LDO4
Any standard regulator properties can be used to configure the single regulator.
+regulator-initial-mode, regulator-allowed-modes and regulator-mode could be
+specified using mode values from dt-bindings/regulator/active-semi,8945a-regulator.h
+file.
The valid names for regulators are:
REG_DCDC1, REG_DCDC2, REG_DCDC3, REG_LDO1, REG_LDO2, REG_LDO3, REG_LDO4.
Example:
+
+#include <dt-bindings/regulator/active-semi,8945a-regulator.h>
+
pmic@5b {
compatible = "active-semi,act8945a";
reg = <0x5b>;
@@ -32,6 +38,18 @@ Example:
regulator-min-microvolt = <1350000>;
regulator-max-microvolt = <1350000>;
regulator-always-on;
+
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ regulator-suspend-min-microvolt=<1400000>;
+ regulator-suspend-max-microvolt=<1400000>;
+ regulator-changeable-in-suspend;
+ regulator-mode=<ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ };
};
vdd_1v2_reg: REG_DCDC2 {
@@ -39,6 +57,14 @@ Example:
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1300000>;
regulator-always-on;
+
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_3v3_reg: REG_DCDC3 {
@@ -53,6 +79,14 @@ Example:
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
regulator-always-on;
+
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_3v3_lp_reg: REG_LDO2 {
diff --git a/include/dt-bindings/regulator/active-semi,8945a-regulator.h b/include/dt-bindings/regulator/active-semi,8945a-regulator.h
new file mode 100644
index 000000000000..9bdba5e3141a
--- /dev/null
+++ b/include/dt-bindings/regulator/active-semi,8945a-regulator.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2018 Microchip Technology, Inc. All rights reserved.
+ *
+ * Device Tree binding constants for the ACT8945A PMIC regulators
+ */
+
+#ifndef _DT_BINDINGS_REGULATOR_ACT8945A_H
+#define _DT_BINDINGS_REGULATOR_ACT8945A_H
+
+/*
+ * These constants should be used to specify regulator modes in device tree for
+ * ACT8945A regulators as follows:
+ * ACT8945A_REGULATOR_MODE_FIXED: It is specific to DCDC regulators and it
+ * specifies the usage of fixed-frequency
+ * PWM.
+ *
+ * ACT8945A_REGULATOR_MODE_NORMAL: It is specific to LDO regulators and it
+ * specifies the usage of normal mode.
+ *
+ * ACT8945A_REGULATOR_MODE_LOWPOWER: For DCDC and LDO regulators; it specify
+ * the usage of proprietary power-saving
+ * mode.
+ */
+
+#define ACT8945A_REGULATOR_MODE_FIXED 1
+#define ACT8945A_REGULATOR_MODE_NORMAL 2
+#define ACT8945A_REGULATOR_MODE_LOWPOWER 3
+
+#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 3/6] regulator: act8945a-regulator: Implement PM functionalities
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 1/6] regulator: act8945a-regulator: unlock expert registers Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 2/6] regulator: add documentation for regulator modes and suspend states Claudiu.Beznea
@ 2018-12-13 12:49 ` Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 4/6] regulator: act8945a-regulator: fix line over 80 chars warning Claudiu.Beznea
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:49 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, boris.brezillon,
Claudiu.Beznea
From: Boris Brezillon <boris.brezillon@bootlin.com>
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>
---
drivers/regulator/act8945a-regulator.c | 186 ++++++++++++++++++++++++++++++++-
1 file changed, 181 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/act8945a-regulator.c b/drivers/regulator/act8945a-regulator.c
index 8d71d9893d0d..f37d1a860407 100644
--- a/drivers/regulator/act8945a-regulator.c
+++ b/drivers/regulator/act8945a-regulator.c
@@ -18,6 +18,7 @@
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
+#include <dt-bindings/regulator/active-semi,8945a-regulator.h>
/**
* ACT8945A Global Register Map.
@@ -28,20 +29,27 @@
#define ACT8945A_DCDC1_VSET1 0x20
#define ACT8945A_DCDC1_VSET2 0x21
#define ACT8945A_DCDC1_CTRL 0x22
+#define ACT8945A_DCDC1_SUS 0x24
#define ACT8945A_DCDC2_VSET1 0x30
#define ACT8945A_DCDC2_VSET2 0x31
#define ACT8945A_DCDC2_CTRL 0x32
+#define ACT8945A_DCDC2_SUS 0x34
#define ACT8945A_DCDC3_VSET1 0x40
#define ACT8945A_DCDC3_VSET2 0x41
#define ACT8945A_DCDC3_CTRL 0x42
+#define ACT8945A_DCDC3_SUS 0x44
#define ACT8945A_LDO1_VSET 0x50
#define ACT8945A_LDO1_CTRL 0x51
+#define ACT8945A_LDO1_SUS 0x52
#define ACT8945A_LDO2_VSET 0x54
#define ACT8945A_LDO2_CTRL 0x55
+#define ACT8945A_LDO2_SUS 0x56
#define ACT8945A_LDO3_VSET 0x60
#define ACT8945A_LDO3_CTRL 0x61
+#define ACT8945A_LDO3_SUS 0x62
#define ACT8945A_LDO4_VSET 0x64
#define ACT8945A_LDO4_CTRL 0x65
+#define ACT8945A_LDO4_SUS 0x66
/**
* Field Definitions.
@@ -62,7 +70,12 @@ enum {
ACT8945A_ID_LDO2,
ACT8945A_ID_LDO3,
ACT8945A_ID_LDO4,
- ACT8945A_REG_NUM,
+ ACT8945A_ID_MAX,
+};
+
+struct act8945a_pmic {
+ struct regmap *regmap;
+ u32 op_mode[ACT8945A_ID_MAX];
};
static const struct regulator_linear_range act8945a_voltage_ranges[] = {
@@ -71,6 +84,143 @@ static const struct regulator_linear_range act8945a_voltage_ranges[] = {
REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000),
};
+static int act8945a_set_suspend_state(struct regulator_dev *rdev, bool enable)
+{
+ struct regmap *regmap = rdev->regmap;
+ int id = rdev->desc->id, reg, val;
+
+ 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;
+ int id = rdev->desc->id;
+ 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:
+ reg = ACT8945A_LDO1_SUS;
+ break;
+ case ACT8945A_ID_LDO2:
+ reg = ACT8945A_LDO2_SUS;
+ break;
+ case ACT8945A_ID_LDO3:
+ reg = ACT8945A_LDO3_SUS;
+ break;
+ case ACT8945A_ID_LDO4:
+ reg = ACT8945A_LDO4_SUS;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ switch (mode) {
+ case REGULATOR_MODE_STANDBY:
+ if (rdev->desc->id > ACT8945A_ID_DCDC3)
+ val = BIT(5);
+ break;
+ case REGULATOR_MODE_NORMAL:
+ if (rdev->desc->id <= ACT8945A_ID_DCDC3)
+ 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);
+ int id = rdev->desc->id;
+
+ if (id < ACT8945A_ID_DCDC1 || id >= ACT8945A_ID_MAX)
+ return -EINVAL;
+
+ return act8945a->op_mode[id];
+}
+
static const struct regulator_ops act8945a_ops = {
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
@@ -78,7 +228,11 @@ static const struct regulator_ops act8945a_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
+ .set_mode = act8945a_set_mode,
+ .get_mode = act8945a_get_mode,
.is_enabled = regulator_is_enabled_regmap,
+ .set_suspend_enable = act8945a_set_suspend_enable,
+ .set_suspend_disable = act8945a_set_suspend_disable,
};
#define ACT89xx_REG(_name, _family, _id, _vsel_reg, _supply) \
@@ -86,6 +240,7 @@ static const struct regulator_ops act8945a_ops = {
.name = _name, \
.supply_name = _supply, \
.of_match = of_match_ptr("REG_"#_id), \
+ .of_map_mode = act8945a_of_map_mode, \
.regulators_node = of_match_ptr("regulators"), \
.id = _family##_ID_##_id, \
.type = REGULATOR_VOLTAGE, \
@@ -124,13 +279,17 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
{
struct regulator_config config = { };
const struct regulator_desc *regulators;
+ struct act8945a_pmic *act8945a;
struct regulator_dev *rdev;
- struct regmap *regmap;
int i, num_regulators;
bool voltage_select;
- regmap = dev_get_regmap(pdev->dev.parent, NULL);
- if (!regmap) {
+ 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) {
dev_err(&pdev->dev,
"could not retrieve regmap from parent device\n");
return -EINVAL;
@@ -149,6 +308,7 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
config.dev = &pdev->dev;
config.dev->of_node = pdev->dev.parent->of_node;
+ config.driver_data = act8945a;
for (i = 0; i < num_regulators; i++) {
rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config);
if (IS_ERR(rdev)) {
@@ -159,13 +319,29 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
}
}
+ platform_set_drvdata(pdev, act8945a);
+
/* Unlock expert registers. */
- return regmap_write(regmap, ACT8945A_SYS_UNLK_REGS, 0xef);
+ return regmap_write(act8945a->regmap, ACT8945A_SYS_UNLK_REGS, 0xef);
}
+static int act8945a_suspend(struct device *pdev)
+{
+ 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);
+}
+
+SIMPLE_DEV_PM_OPS(act8945a_pm, act8945a_suspend, NULL);
+
static struct platform_driver act8945a_pmic_driver = {
.driver = {
.name = "act8945a-regulator",
+ .pm = &act8945a_pm,
},
.probe = act8945a_pmic_probe,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 4/6] regulator: act8945a-regulator: fix line over 80 chars warning
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
` (2 preceding siblings ...)
2018-12-13 12:49 ` [PATCH v4 3/6] regulator: act8945a-regulator: Implement PM functionalities Claudiu.Beznea
@ 2018-12-13 12:49 ` Claudiu.Beznea
2018-12-13 12:50 ` [PATCH v4 5/6] regulator: act8945a-regulator: add shutdown function Claudiu.Beznea
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:49 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, Claudiu.Beznea
From: Claudiu Beznea <claudiu.beznea@microchip.com>
Fix line over 80 chars checkpatch.pl warning.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
drivers/regulator/act8945a-regulator.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/act8945a-regulator.c b/drivers/regulator/act8945a-regulator.c
index f37d1a860407..f4d60743efb3 100644
--- a/drivers/regulator/act8945a-regulator.c
+++ b/drivers/regulator/act8945a-regulator.c
@@ -310,7 +310,8 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
config.dev->of_node = pdev->dev.parent->of_node;
config.driver_data = act8945a;
for (i = 0; i < num_regulators; i++) {
- rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config);
+ rdev = devm_regulator_register(&pdev->dev, ®ulators[i],
+ &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev,
"failed to register %s regulator\n",
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 5/6] regulator: act8945a-regulator: add shutdown function
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
` (3 preceding siblings ...)
2018-12-13 12:49 ` [PATCH v4 4/6] regulator: act8945a-regulator: fix line over 80 chars warning Claudiu.Beznea
@ 2018-12-13 12:50 ` Claudiu.Beznea
2018-12-13 12:50 ` [PATCH v4 6/6] ARM: dts: at91: sama5d2_xplained: Add proper regulator states for suspend-to-mem Claudiu.Beznea
2018-12-13 12:59 ` [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
6 siblings, 0 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:50 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, Claudiu.Beznea
From: Claudiu Beznea <claudiu.beznea@microchip.com>
Implement shutdown method to make sure the PMIC will not enter the suspend
state when the system is shutdown.
This work is based on work done by Borris Brezillon on [1].
[1] https://www.spinics.net/lists/kernel/msg2942960.html
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
drivers/regulator/act8945a-regulator.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/regulator/act8945a-regulator.c b/drivers/regulator/act8945a-regulator.c
index f4d60743efb3..90572b6370c6 100644
--- a/drivers/regulator/act8945a-regulator.c
+++ b/drivers/regulator/act8945a-regulator.c
@@ -339,12 +339,23 @@ static int act8945a_suspend(struct device *pdev)
SIMPLE_DEV_PM_OPS(act8945a_pm, act8945a_suspend, NULL);
+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);
+}
+
static struct platform_driver act8945a_pmic_driver = {
.driver = {
.name = "act8945a-regulator",
.pm = &act8945a_pm,
},
.probe = act8945a_pmic_probe,
+ .shutdown = act8945a_pmic_shutdown,
};
module_platform_driver(act8945a_pmic_driver);
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 6/6] ARM: dts: at91: sama5d2_xplained: Add proper regulator states for suspend-to-mem
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
` (4 preceding siblings ...)
2018-12-13 12:50 ` [PATCH v4 5/6] regulator: act8945a-regulator: add shutdown function Claudiu.Beznea
@ 2018-12-13 12:50 ` Claudiu.Beznea
2018-12-13 12:59 ` [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
6 siblings, 0 replies; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:50 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel, boris.brezillon,
Claudiu.Beznea
From: Boris Brezillon <boris.brezillon@bootlin.com>
When entering suspend-to-mem, all PMIC outputs are disabled except
VDDIODDR which is put in power saving mode, and whose voltage is
increased (probably to counter the poor accuracy of power saving mode).
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[claudiu.beznea@microchip.com: use regulator-changeable-in-suspend,
regulator-suspend-max-microvolt, regulator-suspend-max-microvolt,
use macros for regulators' states, add regulator-inital-state]
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
arch/arm/boot/dts/at91-sama5d2_xplained.dts | 54 +++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index 518e2b095ccf..438e6576cf7c 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -47,6 +47,7 @@
#include "sama5d2-pinfunc.h"
#include <dt-bindings/mfd/atmel-flexcom.h>
#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/regulator/active-semi,8945a-regulator.h>
/ {
model = "Atmel SAMA5D2 Xplained";
@@ -181,49 +182,102 @@
regulator-name = "VDD_1V35";
regulator-min-microvolt = <1350000>;
regulator-max-microvolt = <1350000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ regulator-suspend-min-microvolt=<1400000>;
+ regulator-suspend-max-microvolt=<1400000>;
+ regulator-changeable-in-suspend;
+ regulator-mode=<ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ };
};
vdd_1v2_reg: REG_DCDC2 {
regulator-name = "VDD_1V2";
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_3v3_reg: REG_DCDC3 {
regulator-name = "VDD_3V3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_fuse_reg: REG_LDO1 {
regulator-name = "VDD_FUSE";
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_3v3_lp_reg: REG_LDO2 {
regulator-name = "VDD_3V3_LP";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_led_reg: REG_LDO3 {
regulator-name = "VDD_LED";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
vdd_sdhc_1v8_reg: REG_LDO4 {
regulator-name = "VDD_SDHC_1V8";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
};
};
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 0/5] add PM functionality for act8945a PMIC
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
` (5 preceding siblings ...)
2018-12-13 12:50 ` [PATCH v4 6/6] ARM: dts: at91: sama5d2_xplained: Add proper regulator states for suspend-to-mem Claudiu.Beznea
@ 2018-12-13 12:59 ` Claudiu.Beznea
2018-12-13 15:19 ` Mark Brown
6 siblings, 1 reply; 9+ messages in thread
From: Claudiu.Beznea @ 2018-12-13 12:59 UTC (permalink / raw)
To: lgirdwood, broonie, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches
Cc: linux-kernel, devicetree, linux-arm-kernel
Hi Mark,
I saw that previous version of this series was applied to your tree just
after I've send this new one. The only difference b/w them is in the
documentation patch where I moved the new header. No functionality change.
Sorry for the noise,
Claudiu Beznea
On 13.12.2018 14:49, Claudiu Beznea - M18063 wrote:
> From: Claudiu Beznea <claudiu.beznea@microchip.com>
>
> This series implements PM functionality for act8945a PMIC and use that support
> on SAMA5D2 Xplained board.
>
> Changes in v4:
> - move dt-bindings/regulator/active-semi,8945a-regulator.h in documentation
> patch; driver uses macros included in this file; due to this documentation
> patch and drivers patches should go through the same tree
> - make documentation patch, patch 2 of this series
>
> Changes in v3:
> - add patch "unlock expert registers"; it was wrongly missed in previous version
>
> Changes in v2:
> - split patch 1/1 from previous series in 3 patches: one adding regmap,
> one adding pm functionality, one adding shutdown functionality
> - use dev_pm_ops suspend function to set register specific to PWRHLD line: this
> is specific to PMIC itself and not to regulators
> - add mode support for LDOs
> - add constants for mode in dt-bindings/regulator/active-semi,8945a-regulator.h
> - document modes and regulator suspend states
> - remove rdevs from struct act8945a_pmic since were not used anywhere
> - add op_mode field in struct act8945a_pmic, update it when setting mode and
> return it when reading mode (avoiding one extra register read while
> reading mode)
> - add a patch to fix a checkpatch.pl warning
> - in shutdown function use directly act8945a->regmap instead of an intermediary
> struct regmap variable
>
> Boris Brezillon (2):
> regulator: act8945a-regulator: Implement PM functionalities
> ARM: dts: at91: sama5d2_xplained: Add proper regulator states for
> suspend-to-mem
>
> Claudiu Beznea (3):
> regulator: act8945a-regulator: fix line over 80 chars warning
> regulator: act8945a-regulator: add shutdown function
> regulator: add documentation for regulator modes and suspend states
>
> .../bindings/regulator/act8945a-regulator.txt | 34 ++++
> arch/arm/boot/dts/at91-sama5d2_xplained.dts | 54 ++++++
> drivers/regulator/act8945a-regulator.c | 200 ++++++++++++++++++++-
> .../regulator/active-semi,8945a-regulator.h | 30 ++++
> 4 files changed, 312 insertions(+), 6 deletions(-)
> create mode 100644 include/dt-bindings/regulator/active-semi,8945a-regulator.h
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 0/5] add PM functionality for act8945a PMIC
2018-12-13 12:59 ` [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
@ 2018-12-13 15:19 ` Mark Brown
0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2018-12-13 15:19 UTC (permalink / raw)
To: Claudiu.Beznea
Cc: lgirdwood, robh+dt, mark.rutland, Nicolas.Ferre,
alexandre.belloni, Ludovic.Desroches, linux-kernel, devicetree,
linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 364 bytes --]
On Thu, Dec 13, 2018 at 12:59:00PM +0000, Claudiu.Beznea@microchip.com wrote:
> Hi Mark,
>
> I saw that previous version of this series was applied to your tree just
> after I've send this new one. The only difference b/w them is in the
> documentation patch where I moved the new header. No functionality change.
>
> Sorry for the noise,
No problem.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-12-13 15:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 12:49 [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 1/6] regulator: act8945a-regulator: unlock expert registers Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 2/6] regulator: add documentation for regulator modes and suspend states Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 3/6] regulator: act8945a-regulator: Implement PM functionalities Claudiu.Beznea
2018-12-13 12:49 ` [PATCH v4 4/6] regulator: act8945a-regulator: fix line over 80 chars warning Claudiu.Beznea
2018-12-13 12:50 ` [PATCH v4 5/6] regulator: act8945a-regulator: add shutdown function Claudiu.Beznea
2018-12-13 12:50 ` [PATCH v4 6/6] ARM: dts: at91: sama5d2_xplained: Add proper regulator states for suspend-to-mem Claudiu.Beznea
2018-12-13 12:59 ` [PATCH v4 0/5] add PM functionality for act8945a PMIC Claudiu.Beznea
2018-12-13 15:19 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).