linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: pfuze100: Allow pfuze3000 to not go to low power mode
@ 2016-08-17 12:36 Fabio Estevam
  2016-08-17 15:41 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2016-08-17 12:36 UTC (permalink / raw)
  To: broonie; +Cc: festevam, linux-kernel, Fabio Estevam

On a imx6ul-pico board, after issuing a "echo mem > /sys/power/state"
the board goes trough a POR reset instead of going into suspend.

This happens because the pfuze3000 goes to low power by default when the
system goes to suspend.

This behaviour is controlled by the STBY_LOWPOWER_B bit of register
LDOGCTL as explained in the pfuze3000 datasheet:

"When STBY_LOWPOWER_B bit is set to 1, the front-end LDO does not enter 
in low-power mode during IC standby mode."

Introduce a "fsl,low-power-mode-disabled" property that allows the
pfuze3000 to not enter low-power mode during system standby.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 .../devicetree/bindings/regulator/pfuze100.txt     |  6 ++++
 drivers/regulator/pfuze100-regulator.c             | 32 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/pfuze100.txt b/Documentation/devicetree/bindings/regulator/pfuze100.txt
index 9b40db8..9d10767 100644
--- a/Documentation/devicetree/bindings/regulator/pfuze100.txt
+++ b/Documentation/devicetree/bindings/regulator/pfuze100.txt
@@ -4,6 +4,12 @@ Required properties:
 - compatible: "fsl,pfuze100", "fsl,pfuze200", "fsl,pfuze3000"
 - reg: I2C slave address
 
+Optional property (only for pfuze3000):
+- fsl,low-power-mode-disabled: This is a boolean property that when present
+			     indicates that the pfzue3000 will not enter
+			     low power mode when the system goes to
+			     suspend.
+
 Required child node:
 - regulators: This is the list of child nodes that specify the regulator
   initialization data for defined regulators. Please refer to below doc
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index cb18b5c..eca3945 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -56,6 +56,8 @@
 #define PFUZE100_VGEN5VOL	0x70
 #define PFUZE100_VGEN6VOL	0x71
 
+#define PFUZE3000_LDOGCTL	0x69
+
 enum chips { PFUZE100, PFUZE200, PFUZE3000 = 3 };
 
 struct pfuze_regulator {
@@ -510,6 +512,32 @@ static const struct regmap_config pfuze_regmap_config = {
 	.cache_type = REGCACHE_RBTREE,
 };
 
+static int set_low_power_mode(struct pfuze_chip *pfuze_chip)
+{
+	struct device *dev = pfuze_chip->dev;
+	struct device_node *np;
+	unsigned int value;
+	int ret;
+
+	np = of_node_get(dev->of_node);
+	if (!np)
+		return -EINVAL;
+
+	if (!of_device_is_compatible(np, "fsl,pfuze3000"))
+		return 0;
+
+	if (of_find_property(np, "fsl,low-power-mode-disabled", NULL))
+		value = 1;
+	else
+		value = 0;
+
+	ret = regmap_write(pfuze_chip->regmap, PFUZE3000_LDOGCTL, value);
+	if (ret)
+		return ret;
+
+	return 0;
+};
+
 static int pfuze100_regulator_probe(struct i2c_client *client,
 				    const struct i2c_device_id *id)
 {
@@ -635,6 +663,10 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
 		}
 	}
 
+	ret = set_low_power_mode(pfuze_chip);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: pfuze100: Allow pfuze3000 to not go to low power mode
  2016-08-17 12:36 [PATCH] regulator: pfuze100: Allow pfuze3000 to not go to low power mode Fabio Estevam
@ 2016-08-17 15:41 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2016-08-17 15:41 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: festevam, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

On Wed, Aug 17, 2016 at 09:36:21AM -0300, Fabio Estevam wrote:
> On a imx6ul-pico board, after issuing a "echo mem > /sys/power/state"
> the board goes trough a POR reset instead of going into suspend.

> This happens because the pfuze3000 goes to low power by default when the
> system goes to suspend.

> This behaviour is controlled by the STBY_LOWPOWER_B bit of register
> LDOGCTL as explained in the pfuze3000 datasheet:

> "When STBY_LOWPOWER_B bit is set to 1, the front-end LDO does not enter 
> in low-power mode during IC standby mode."

> Introduce a "fsl,low-power-mode-disabled" property that allows the
> pfuze3000 to not enter low-power mode during system standby.

We already have suspend mode configuration for regulators, shouldn't
this just be done via that interface?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-17 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-17 12:36 [PATCH] regulator: pfuze100: Allow pfuze3000 to not go to low power mode Fabio Estevam
2016-08-17 15:41 ` 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).