All of lore.kernel.org
 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

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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.