linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5
@ 2021-02-11 10:55 Schrempf Frieder
  2021-02-11 10:55 ` [PATCH 2/3] dt-bindings: regulator: pca9450: Add sd-vsel GPIO Schrempf Frieder
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Schrempf Frieder @ 2021-02-11 10:55 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Frieder Schrempf, Axel Lin, Rikard Falkeborn, Robin Gong, linux-kernel

From: Frieder Schrempf <frieder.schrempf@kontron.de>

LDO5 has two separate control registers. LDO5CTRL_L is used if the
input signal SD_VSEL is low and LDO5CTRL_H if it is high.
The current driver implementation only uses LDO5CTRL_H. To make this
work on boards that have SD_VSEL connected to a GPIO, we add support
for specifying an optional GPIO and setting it to high at probe time.

In the future we might also want to add support for boards that have
SD_VSEL set to a fixed low level. In this case we need to change the
driver to be able to use the LDO5CTRL_L register.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 drivers/regulator/pca9450-regulator.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9450-regulator.c
index cb29421d745a..1bba8fdcb7b7 100644
--- a/drivers/regulator/pca9450-regulator.c
+++ b/drivers/regulator/pca9450-regulator.c
@@ -5,6 +5,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -32,6 +33,7 @@ struct pca9450_regulator_desc {
 struct pca9450 {
 	struct device *dev;
 	struct regmap *regmap;
+	struct gpio_desc *sd_vsel_gpio;
 	enum pca9450_chip_type type;
 	unsigned int rcnt;
 	int irq;
@@ -795,6 +797,18 @@ static int pca9450_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
+	/*
+	 * The driver uses the LDO5CTRL_H register to control the LDO5 regulator.
+	 * This is only valid if the SD_VSEL input of the PMIC is high. Let's
+	 * check if the pin is available as GPIO and set it to high.
+	 */
+	pca9450->sd_vsel_gpio = gpiod_get_optional(pca9450->dev, "sd-vsel", GPIOD_OUT_HIGH);
+
+	if (IS_ERR(pca9450->sd_vsel_gpio)) {
+		dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n");
+		return ret;
+	}
+
 	dev_info(&i2c->dev, "%s probed.\n",
 		type == PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc");
 
-- 
2.25.1


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

* [PATCH 2/3] dt-bindings: regulator: pca9450: Add sd-vsel GPIO
  2021-02-11 10:55 [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Schrempf Frieder
@ 2021-02-11 10:55 ` Schrempf Frieder
  2021-02-11 10:55 ` [PATCH 3/3] regulator: pca9450: Enable system reset on WDOG_B assertion Schrempf Frieder
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Schrempf Frieder @ 2021-02-11 10:55 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Robin Gong
  Cc: Frieder Schrempf, Rob Herring, linux-kernel, devicetree

From: Frieder Schrempf <frieder.schrempf@kontron.de>

Add the binding documentation for the optional sd-vsel GPIO.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 .../devicetree/bindings/regulator/nxp,pca9450-regulator.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml b/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
index c2b0a8b6da1e..f70f2e758a00 100644
--- a/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
+++ b/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
@@ -87,6 +87,11 @@ properties:
 
     additionalProperties: false
 
+  sd-vsel-gpios:
+    description: GPIO that is used to switch LDO5 between being configured by
+      LDO5CTRL_L or LDO5CTRL_H register. Use this if the SD_VSEL signal is
+      connected to a host GPIO.
+
 required:
   - compatible
   - reg
-- 
2.25.1


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

* [PATCH 3/3] regulator: pca9450: Enable system reset on WDOG_B assertion
  2021-02-11 10:55 [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Schrempf Frieder
  2021-02-11 10:55 ` [PATCH 2/3] dt-bindings: regulator: pca9450: Add sd-vsel GPIO Schrempf Frieder
@ 2021-02-11 10:55 ` Schrempf Frieder
  2021-02-11 13:04 ` [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Mark Brown
  2021-02-11 15:39 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Schrempf Frieder @ 2021-02-11 10:55 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Frieder Schrempf, Robin Gong, Rikard Falkeborn, Axel Lin, linux-kernel

From: Frieder Schrempf <frieder.schrempf@kontron.de>

By default the PCA9450 doesn't handle the assertion of the WDOG_B
signal, but this is required to guarantee that things like software
resets triggered by the watchdog work reliably.

As we don't want to rely on the bootloader to enable this, we tell
the PMIC to issue a cold reset in case the WDOG_B signal is
asserted (WDOG_B_CFG = 10), just as the NXP U-Boot code does.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 drivers/regulator/pca9450-regulator.c | 8 ++++++++
 include/linux/regulator/pca9450.h     | 7 +++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9450-regulator.c
index 1bba8fdcb7b7..833d398c6aa2 100644
--- a/drivers/regulator/pca9450-regulator.c
+++ b/drivers/regulator/pca9450-regulator.c
@@ -797,6 +797,14 @@ static int pca9450_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
+	/* Set reset behavior on assertion of WDOG_B signal */
+	ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_RESET_CTRL,
+				WDOG_B_CFG_MASK, WDOG_B_CFG_COLD_LDO12);
+	if (ret) {
+		dev_err(&i2c->dev, "Failed to set WDOG_B reset behavior\n");
+		return ret;
+	}
+
 	/*
 	 * The driver uses the LDO5CTRL_H register to control the LDO5 regulator.
 	 * This is only valid if the SD_VSEL input of the PMIC is high. Let's
diff --git a/include/linux/regulator/pca9450.h b/include/linux/regulator/pca9450.h
index 1bbd3014f906..ccdb5320a240 100644
--- a/include/linux/regulator/pca9450.h
+++ b/include/linux/regulator/pca9450.h
@@ -216,4 +216,11 @@ enum {
 #define IRQ_THERM_105			0x02
 #define IRQ_THERM_125			0x01
 
+/* PCA9450_REG_RESET_CTRL bits */
+#define WDOG_B_CFG_MASK			0xC0
+#define WDOG_B_CFG_NONE			0x00
+#define WDOG_B_CFG_WARM			0x40
+#define WDOG_B_CFG_COLD_LDO12		0x80
+#define WDOG_B_CFG_COLD			0xC0
+
 #endif /* __LINUX_REG_PCA9450_H__ */
-- 
2.25.1


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

* Re: [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5
  2021-02-11 10:55 [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Schrempf Frieder
  2021-02-11 10:55 ` [PATCH 2/3] dt-bindings: regulator: pca9450: Add sd-vsel GPIO Schrempf Frieder
  2021-02-11 10:55 ` [PATCH 3/3] regulator: pca9450: Enable system reset on WDOG_B assertion Schrempf Frieder
@ 2021-02-11 13:04 ` Mark Brown
  2021-02-11 15:39 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-02-11 13:04 UTC (permalink / raw)
  To: Schrempf Frieder
  Cc: Liam Girdwood, Axel Lin, Rikard Falkeborn, Robin Gong, linux-kernel

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

On Thu, Feb 11, 2021 at 11:55:28AM +0100, Schrempf Frieder wrote:

> +	if (IS_ERR(pca9450->sd_vsel_gpio)) {
> +		dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n");

Not critical but it's generally better to display the error code when
logging an error to aid in diagnostics.

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

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

* Re: [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5
  2021-02-11 10:55 [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Schrempf Frieder
                   ` (2 preceding siblings ...)
  2021-02-11 13:04 ` [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Mark Brown
@ 2021-02-11 15:39 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-02-11 15:39 UTC (permalink / raw)
  To: Liam Girdwood, Schrempf Frieder
  Cc: linux-kernel, Axel Lin, Robin Gong, Rikard Falkeborn

On Thu, 11 Feb 2021 11:55:28 +0100, Schrempf Frieder wrote:
> LDO5 has two separate control registers. LDO5CTRL_L is used if the
> input signal SD_VSEL is low and LDO5CTRL_H if it is high.
> The current driver implementation only uses LDO5CTRL_H. To make this
> work on boards that have SD_VSEL connected to a GPIO, we add support
> for specifying an optional GPIO and setting it to high at probe time.
> 
> In the future we might also want to add support for boards that have
> SD_VSEL set to a fixed low level. In this case we need to change the
> driver to be able to use the LDO5CTRL_L register.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5
      commit: 8c67a11bae889f51fe5054364c3c789dfae3ad73
[2/3] dt-bindings: regulator: pca9450: Add sd-vsel GPIO
      commit: 27866e3e8a7e93494f8374f48061aa73ee46ceb2
[3/3] regulator: pca9450: Enable system reset on WDOG_B assertion
      commit: f7684f5a048febd2a7bc98ee81d6dce52f7268b8

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2021-02-11 16:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 10:55 [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Schrempf Frieder
2021-02-11 10:55 ` [PATCH 2/3] dt-bindings: regulator: pca9450: Add sd-vsel GPIO Schrempf Frieder
2021-02-11 10:55 ` [PATCH 3/3] regulator: pca9450: Enable system reset on WDOG_B assertion Schrempf Frieder
2021-02-11 13:04 ` [PATCH 1/3] regulator: pca9450: Add SD_VSEL GPIO for LDO5 Mark Brown
2021-02-11 15:39 ` 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).