public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/2] pmic: pca9450: Make warm reset on WDOG_B assertion
@ 2022-12-09 19:35 Marek Vasut
  2022-12-09 19:35 ` [PATCH 2/2] ARM: imx: Remove PMIC reset configuration from board files Marek Vasut
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Marek Vasut @ 2022-12-09 19:35 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, NXP i.MX U-Boot Team, Ying-Chun Liu (PaulLiu),
	Fabio Estevam, Fabio Estevam, Frieder Schrempf, Manoj Sai,
	Marcel Ziswiler, Matteo Lisi, Peng Fan, Rickard x Andersson,
	Stefano Babic, Tim Harvey

The default configuration of the PMIC behavior makes the PMIC
power cycle most regulators on WDOG_B assertion. This power
cycling causes the memory contents of OCRAM to be lost.
Some systems neeeds some memory that survives reset and
reboot, therefore this patch is created.

The implementation is taken almost verbatim from Linux commit
2364a64d0673f ("regulator: pca9450: Make warm reset on WDOG_B assertion")

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Cc: "Ying-Chun Liu (PaulLiu)" <paul.liu@linaro.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Cc: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Matteo Lisi <matteo.lisi@engicam.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Rickard x Andersson <rickaran@axis.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tim Harvey <tharvey@gateworks.com>
---
 drivers/power/pmic/pca9450.c | 11 ++++++++++-
 include/power/pca9450.h      |  4 ++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
index a186edc08da..2427abfb7a5 100644
--- a/drivers/power/pmic/pca9450.c
+++ b/drivers/power/pmic/pca9450.c
@@ -86,6 +86,7 @@ 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;
 
 	if (CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(DM_REGULATOR_PCA9450)) {
@@ -95,10 +96,18 @@ static int pca9450_probe(struct udevice *dev)
 		if (IS_ERR(priv->sd_vsel_gpio)) {
 			ret = PTR_ERR(priv->sd_vsel_gpio);
 			dev_err(dev, "Failed to request SD_VSEL GPIO: %d\n", ret);
+			if (ret)
+				return ret;
 		}
 	}
 
-	return ret;
+	if (ofnode_read_bool(dev_ofnode(dev), "nxp,wdog_b-warm-reset"))
+		reset_ctrl = PCA9450_PMIC_RESET_WDOG_B_CFG_WARM;
+	else
+		reset_ctrl = PCA9450_PMIC_RESET_WDOG_B_CFG_COLD_LDO12;
+
+	return pmic_clrsetbits(dev, PCA9450_RESET_CTRL,
+			       PCA9450_PMIC_RESET_WDOG_B_CFG_MASK, reset_ctrl);
 }
 
 static struct dm_pmic_ops pca9450_ops = {
diff --git a/include/power/pca9450.h b/include/power/pca9450.h
index fa0405fcb87..6efecee96c8 100644
--- a/include/power/pca9450.h
+++ b/include/power/pca9450.h
@@ -67,4 +67,8 @@ enum {
 #define PCA9450_LDO34_MASK		0x1f
 #define PCA9450_LDO5_MASK		0x0f
 
+#define PCA9450_PMIC_RESET_WDOG_B_CFG_MASK		0xc0
+#define PCA9450_PMIC_RESET_WDOG_B_CFG_WARM		0x40
+#define PCA9450_PMIC_RESET_WDOG_B_CFG_COLD_LDO12	0x80
+
 #endif
-- 
2.35.1


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

end of thread, other threads:[~2023-01-31  9:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-09 19:35 [PATCH 1/2] pmic: pca9450: Make warm reset on WDOG_B assertion Marek Vasut
2022-12-09 19:35 ` [PATCH 2/2] ARM: imx: Remove PMIC reset configuration from board files Marek Vasut
2022-12-10 14:33   ` Fabio Estevam
2022-12-13  7:44   ` Peng Fan
2023-01-31  9:50   ` sbabic
2022-12-10 14:33 ` [PATCH 1/2] pmic: pca9450: Make warm reset on WDOG_B assertion Fabio Estevam
2022-12-13  7:44 ` Peng Fan
2023-01-31  9:50 ` sbabic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox