public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Thiery <heiko.thiery@gmail.com>
To: u-boot@lists.denx.de
Cc: Jaehoon Chung <jh80.chung@samsung.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Samuel Holland <samuel@sholland.org>,
	Simon Glass <sjg@chromium.org>,
	Kever Yang <kever.yang@rock-chips.com>,
	Quentin Schulz <quentin.schulz@theobroma-systems.com>,
	Lukasz Majewski <lukma@denx.de>,
	Stephan Gerhold <stephan@gerhold.net>,
	Fabio Estevam <festevam@denx.de>, Marek Vasut <marex@denx.de>,
	Heiko Thiery <heiko.thiery@gmail.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>
Subject: [PATCH 1/2] pmic: pca9450: enable system reset on WDOG_B assertion
Date: Tue, 28 Jun 2022 16:06:22 +0200	[thread overview]
Message-ID: <20220628140621.254550-2-heiko.thiery@gmail.com> (raw)
In-Reply-To: <20220628140621.254550-1-heiko.thiery@gmail.com>

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.

This is a port of the same changes in the Linux kernel:
f7684f5a048f ("regulator: pca9450: Enable system reset on WDOG_B assertion")
2364a64d0673 ("regulator: pca9450: Make warm reset on WDOG_B assertion")

Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 drivers/power/pmic/Kconfig   |  4 ++++
 drivers/power/pmic/pca9450.c | 15 +++++++++++++++
 include/power/pca9450.h      |  7 +++++++
 3 files changed, 26 insertions(+)

diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index bb3960020d..d30d6d25c4 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -158,6 +158,8 @@ config SPL_DM_PMIC_MP5416
 
 config DM_PMIC_PCA9450
 	bool "Enable Driver Model for PMIC PCA9450"
+	select REGMAP
+	select SYSCON
 	help
 	  This config enables implementation of driver-model pmic uclass features
 	  for PMIC PCA9450. The driver implements read/write operations.
@@ -165,6 +167,8 @@ config DM_PMIC_PCA9450
 config SPL_DM_PMIC_PCA9450
 	bool "Enable Driver Model for PMIC PCA9450"
 	depends on SPL_DM_PMIC
+	select SPL_REGMAP
+	select SPL_SYSCON
 	help
 	  This config enables implementation of driver-model pmic uclass features
 	  for PMIC PCA9450 in SPL. The driver implements read/write operations.
diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
index a186edc08d..fecab0496f 100644
--- a/drivers/power/pmic/pca9450.c
+++ b/drivers/power/pmic/pca9450.c
@@ -11,6 +11,8 @@
 #include <i2c.h>
 #include <linux/err.h>
 #include <log.h>
+#include <regmap.h>
+#include <syscon.h>
 #include <asm/global_data.h>
 #include <asm-generic/gpio.h>
 #include <power/pmic.h>
@@ -30,6 +32,7 @@ static const struct pmic_child_info pmic_children_info[] = {
 };
 
 struct pca9450_priv {
+	struct regmap *regmap;
 	struct gpio_desc *sd_vsel_gpio;
 };
 
@@ -86,8 +89,20 @@ static int pca9450_bind(struct udevice *dev)
 static int pca9450_probe(struct udevice *dev)
 {
 	struct pca9450_priv *priv = dev_get_priv(dev);
+	unsigned int reset_ctrl;
 	int ret = 0;
 
+	priv->regmap = syscon_node_to_regmap(dev_ofnode(dev));
+
+	if (dev_read_bool(dev, "nxp,wdog_b-warm-reset"))
+		reset_ctrl = WDOG_B_CFG_WARM;
+	else
+		reset_ctrl = WDOG_B_CFG_COLD_LDO12;
+
+	/* Set reset behavior on assertion of WDOG_B signal */
+	ret = regmap_update_bits(priv->regmap, PCA9450_RESET_CTRL,
+				 WDOG_B_CFG_MASK, reset_ctrl);
+
 	if (CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(DM_REGULATOR_PCA9450)) {
 		priv->sd_vsel_gpio = devm_gpiod_get_optional(dev, "sd-vsel",
 							     GPIOD_IS_OUT |
diff --git a/include/power/pca9450.h b/include/power/pca9450.h
index fa0405fcb8..bf9be7d6bb 100644
--- a/include/power/pca9450.h
+++ b/include/power/pca9450.h
@@ -67,4 +67,11 @@ enum {
 #define PCA9450_LDO34_MASK		0x1f
 #define PCA9450_LDO5_MASK		0x0f
 
+/* 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
-- 
2.30.2


  reply	other threads:[~2022-06-28 14:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 14:06 [PATCH 0/2] pmic: pca9450: Initialization of pmic like done in linux Heiko Thiery
2022-06-28 14:06 ` Heiko Thiery [this message]
2022-06-28 19:59   ` [PATCH 1/2] pmic: pca9450: enable system reset on WDOG_B assertion Fabio Estevam
2022-06-29  6:34   ` Frieder Schrempf
2022-06-28 14:06 ` [PATCH 2/2] pmic: pca9450: clear PRESET_EN bit for BUCK1/2/3 voltage settings Heiko Thiery
2022-06-28 20:02   ` Fabio Estevam
2022-06-28 20:11     ` Marek Vasut
2022-06-29  6:36   ` Frieder Schrempf

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=20220628140621.254550-2-heiko.thiery@gmail.com \
    --to=heiko.thiery@gmail.com \
    --cc=andre.przywara@arm.com \
    --cc=festevam@denx.de \
    --cc=frieder.schrempf@kontron.de \
    --cc=jh80.chung@samsung.com \
    --cc=kever.yang@rock-chips.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=quentin.schulz@theobroma-systems.com \
    --cc=samuel@sholland.org \
    --cc=sjg@chromium.org \
    --cc=stephan@gerhold.net \
    --cc=u-boot@lists.denx.de \
    /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