Even if the driver for the internal watchdog unit is disabled, it gets
enabled again silently if we select an i.MX platform.

This change compiles the driver on user demand only. Barebox can handle one
watchdog and one reset source. This change enables a user to select a
different one if the built-in unit cannot be used due to hardware issues like
power management and voltage changes the internal watchdog cannot reset
correctly.

Signed-off-by: Juergen Borleis <[email protected]>
---
 arch/arm/Kconfig          |  1 -
 drivers/watchdog/Kconfig  | 15 ++++++++++++---
 drivers/watchdog/Makefile |  2 +-
 drivers/watchdog/imxwd.c  |  5 ++++-
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 50f3095..b115d10 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -101,7 +101,6 @@ config ARCH_IMX
        select GPIOLIB
        select COMMON_CLK
        select CLKDEV_LOOKUP
-       select WATCHDOG_IMX_RESET_SOURCE
        select HAS_DEBUG_LL
 
 config ARCH_MVEBU
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 7f7b02e..04fad45 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1,7 +1,4 @@
 
-config WATCHDOG_IMX_RESET_SOURCE
-       bool
-
 menuconfig WATCHDOG
        bool "Watchdog support"
        help
@@ -22,6 +19,18 @@ config WATCHDOG_IMX
        help
          Add support for watchdog found on Freescale i.MX SoCs.
 
+config WATCHDOG_IMX_RESET_SOURCE
+       depends on WATCHDOG_IMX
+       bool "Reset source provider"
+       help
+         This watchdog unit can provide the reset reason.
+
+config WATCHDOG_IMX_RESET_FEATURE
+       depends on WATCHDOG_IMX
+       bool "Use for SoC reset"
+       help
+         This watchdog unit can be used to reset/restart the SoC.
+
 config WATCHDOG_JZ4740
        bool "Ingenic jz4740 SoC hardware watchdog"
        depends on MACH_MIPS_XBURST
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 865fc47..446056d 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_WATCHDOG) += wd_core.o
 obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
 obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o
-obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o
+obj-$(CONFIG_WATCHDOG_IMX) += imxwd.o
diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index 5ffbac7..60e4c59 100644
--- a/drivers/watchdog/imxwd.c
+++ b/drivers/watchdog/imxwd.c
@@ -123,6 +123,7 @@ static int imx_watchdog_set_timeout(struct watchdog *wd, 
unsigned timeout)
 
 static struct imx_wd *reset_wd;
 
+#ifdef CONFIG_WATCHDOG_IMX_RESET_FEATURE
 void __noreturn reset_cpu(unsigned long addr)
 {
        if (reset_wd)
@@ -132,6 +133,7 @@ void __noreturn reset_cpu(unsigned long addr)
 
        hang();
 }
+#endif
 
 static void imx_watchdog_detect_reset_source(struct imx_wd *priv)
 {
@@ -157,7 +159,8 @@ static void imx_watchdog_detect_reset_source(struct imx_wd 
*priv)
 
 static int imx21_wd_init(struct imx_wd *priv)
 {
-       imx_watchdog_detect_reset_source(priv);
+       if (IS_ENABLED(CONFIG_WATCHDOG_IMX_RESET_SOURCE))
+               imx_watchdog_detect_reset_source(priv);
 
        /*
         * Disable watchdog powerdown counter
-- 
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to