linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Estevam <fabio.estevam@nxp.com>
To: <broonie@kernel.org>
Cc: <festevam@gmail.com>, <linux-kernel@vger.kernel.org>,
	Fabio Estevam <fabio.estevam@nxp.com>
Subject: [PATCH] regulator: pfuze100: Allow pfuze3000 to not go to low power mode
Date: Wed, 17 Aug 2016 09:36:21 -0300	[thread overview]
Message-ID: <1471437381-1752-1-git-send-email-fabio.estevam@nxp.com> (raw)

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

             reply	other threads:[~2016-08-17 15:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 12:36 Fabio Estevam [this message]
2016-08-17 15:41 ` [PATCH] regulator: pfuze100: Allow pfuze3000 to not go to low power mode Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471437381-1752-1-git-send-email-fabio.estevam@nxp.com \
    --to=fabio.estevam@nxp.com \
    --cc=broonie@kernel.org \
    --cc=festevam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).