]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
misc: pmic_esm: Add support for PMIC ESM driver
authorTero Kristo <t-kristo@ti.com>
Fri, 14 Feb 2020 09:18:16 +0000 (11:18 +0200)
committerLokesh Vutla <lokeshvutla@ti.com>
Tue, 3 Mar 2020 07:38:14 +0000 (13:08 +0530)
The ESM (Error Signal Monitor) is used on certain PMIC versions to
handle error signals propagating from rest of the system. If these
reach the PMIC, it is typically a last resort fatal error which
requires a system reset. The ESM driver does the proper configuration
for the ESM module to reach this end goal. Initially, only TPS65941
PMIC is supported for this.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
doc/device-tree-bindings/misc/esm-pmic.txt [new file with mode: 0644]
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/esm_pmic.c [new file with mode: 0644]

diff --git a/doc/device-tree-bindings/misc/esm-pmic.txt b/doc/device-tree-bindings/misc/esm-pmic.txt
new file mode 100644 (file)
index 0000000..a60ad74
--- /dev/null
@@ -0,0 +1,19 @@
+PMIC ESM Binding
+======================
+
+Certain Power Management ICs contain safety handling logic within them,
+allowing automatic reset of the board in case a safety error is signaled.
+For this purpose, ESM (Error Signal Monitor) is implemented within
+the PMIC running its own state machine.
+
+Required properties :
+- compatible   : "ti,tps659413-esm"
+
+Example
+=======
+
+&tps659413a {
+       esm: esm {
+               compatible = "ti,tps659413-esm";
+       };
+};
index 38588b2cbd8b5eb85bc82ec3b37a4669639c56b5..766402745dddb286a28f356ba3147f03b703d64f 100644 (file)
@@ -486,4 +486,11 @@ config K3_AVS0
          optimized voltage from the efuse, so that it can be programmed
          to the PMIC on board.
 
+config ESM_PMIC
+       bool "Enable PMIC ESM driver"
+       depends on DM_PMIC
+       help
+         Support ESM (Error Signal Monitor) on PMIC devices. ESM is used
+         typically to reboot the board in error condition.
+
 endmenu
index 60406c3e0a309e3d65088b24ba60d9fff9e38d5e..68e0e7ad1726ac2032f23a8f3a41b44182532242 100644 (file)
@@ -73,3 +73,4 @@ obj-$(CONFIG_JZ4780_EFUSE) += jz4780_efuse.o
 obj-$(CONFIG_MICROCHIP_FLEXCOM) += microchip_flexcom.o
 obj-$(CONFIG_K3_AVS0) += k3_avs.o
 obj-$(CONFIG_ESM_K3) += k3_esm.o
+obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
diff --git a/drivers/misc/esm_pmic.c b/drivers/misc/esm_pmic.c
new file mode 100644 (file)
index 0000000..92c8d68
--- /dev/null
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * PMIC Error Signal Monitor driver
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ *      Tero Kristo <t-kristo@ti.com>
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <power/pmic.h>
+#include <dm/device_compat.h>
+
+#define INT_ESM_REG            0x6c
+#define INT_ESM_MASK           0x3f
+
+#define ESM_MCU_START_REG      0x8f
+
+#define ESM_MCU_START          BIT(0)
+
+#define ESM_MCU_MODE_CFG_REG   0x92
+
+#define ESM_MCU_EN             BIT(6)
+#define ESM_MCU_ENDRV          BIT(5)
+
+/**
+ * pmic_esm_probe: configures and enables PMIC ESM functionality
+ *
+ * Configures ESM PMIC support and enables it.
+ */
+static int pmic_esm_probe(struct udevice *dev)
+{
+       int ret;
+
+       ret = pmic_reg_write(dev->parent, INT_ESM_REG, INT_ESM_MASK);
+       if (ret) {
+               dev_err(dev, "clearing ESM irqs failed: %d\n", ret);
+               return ret;
+       }
+
+       ret = pmic_reg_write(dev->parent, ESM_MCU_MODE_CFG_REG,
+                            ESM_MCU_EN | ESM_MCU_ENDRV);
+       if (ret) {
+               dev_err(dev, "setting ESM mode failed: %d\n", ret);
+               return ret;
+       }
+
+       ret = pmic_reg_write(dev->parent, ESM_MCU_START_REG, ESM_MCU_START);
+       if (ret) {
+               dev_err(dev, "starting ESM failed: %d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+static const struct udevice_id pmic_esm_ids[] = {
+       { .compatible = "ti,tps659413-esm" },
+       {}
+};
+
+U_BOOT_DRIVER(pmic_esm) = {
+       .name = "esm_pmic",
+       .of_match = pmic_esm_ids,
+       .id = UCLASS_MISC,
+       .probe = pmic_esm_probe,
+};