]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pmic: pca9450: Make warm reset on WDOG_B assertion
authorMarek Vasut <marex@denx.de>
Fri, 9 Dec 2022 19:35:46 +0000 (20:35 +0100)
committerStefano Babic <sbabic@denx.de>
Mon, 30 Jan 2023 22:23:01 +0000 (23:23 +0100)
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>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
drivers/power/pmic/pca9450.c
include/power/pca9450.h

index a186edc08da72443c1ac7cd452a84ddb91cf7884..2427abfb7a5bdb0225080e17bb98b7f0d17be7cf 100644 (file)
@@ -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 = {
index fa0405fcb87ec11ab26c7847b4e27cf048993e17..6efecee96c8f9e72e4d3b0d37926d61fb3780d3e 100644 (file)
@@ -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