Skip to contentSkip to conversation

drivers: watchdog: add MAX6373 WDT support

PATCH Superseded rnd4 at dave-tech.it 3 participants 5 messages Jul 23, 2015 – Aug 18, 2015 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: watchdog: add MAX6373 WDT support

From: Andrea Scian <[email protected]>

MAX6373 is a simple WDT which is programmed its configuration pins and reset via another pin, which is usually connected to a GPIO

---
 drivers/watchdog/Makefile      |    1 +
 drivers/watchdog/max6373_wdt.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 drivers/watchdog/max6373_wdt.c
drivers/watchdog/Makefile +1 -0
index 0276a10..6826100 100644
@@ -16,3 +16,4 @@ obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o
 obj-$(CONFIG_BFIN_WATCHDOG)  += bfin_wdt.o
 obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
 obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o
+obj-$(CONFIG_MAX6373_WATCHDOG) += max6373_wdt.o
drivers/watchdog/max6373_wdt.c new file +34 -0
new file mode 100644
index 0000000..cda46af
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 DAVE Embedded Systems <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * MAX6373 is a WDT which uses a simple GPIO to reset its timeout
+ *
+ * Use CONFIG_MAX6373_WDT_GPIO to define the GPIO number to use
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+#include <watchdog.h>
+
+#ifndef CONFIG_MAX6373_WDT_GPIO
+#error "Please use CONFIG_MAX6373_WDT_GPIO to define which GPIO to use"
+#endif
+
+void hw_watchdog_reset(void)
+{
+	gpio_set_value(CONFIG_MAX6373_WDT_GPIO,
+		!gpio_get_value(CONFIG_MAX6373_WDT_GPIO));
+}
+
+void hw_watchdog_init(void)
+{
+	if (gpio_request(CONFIG_MAX6373_WDT_GPIO, "MAX6373 WDT")) {
+		printf("Cannot request GPIO %d for MAX6373 WDT\n",
+			CONFIG_MAX6373_WDT_GPIO);
+		return;
+	}
+	gpio_direction_output(CONFIG_MAX6373_WDT_GPIO, 1);
+}
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 drivers: watchdog: add MAX6373 WDT support

Quoted 11 lines · On Thu, Jul 23, 2015 at 11:33:19PM +0200, rnd4 at dave-tech.it wrote:

From: Andrea Scian <[email protected]>

MAX6373 is a simple WDT which is programmed its configuration pins and reset via another pin, which is usually connected to a GPIO

---
 drivers/watchdog/Makefile      |    1 +
 drivers/watchdog/max6373_wdt.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 drivers/watchdog/max6373_wdt.c

Please Kconfig'ize this, thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150812/5c13031e/attachment.sig>
#2 lore raw

PATCH v2 1/1 drivers: watchdog: add MAX6373 WDT support

From: Andrea Scian <[email protected]>

MAX6373 is a simple WDT which is programmed its configuration pins and reset via another pin, which is usually connected to a GPIO

---

Changes for v2:
- add Kconfig support

 drivers/watchdog/Kconfig       |   17 +++++++++++++++++
 drivers/watchdog/Makefile      |    1 +
 drivers/watchdog/max6373_wdt.c |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 drivers/watchdog/max6373_wdt.c
drivers/watchdog/Kconfig +17 -0
index e69de29..c7c2011 100644
@@ -0,0 +1,17 @@
+menu "Watchdog Timer Support"
+
+config MAX6373_WATCHDOG
+	bool "Maxim MAX6373 Watchdog"
+	depends on DM_GPIO
+	default n
+	help
+	  Enable MAX6373 Watchdog timer driver. This is a simple WDT which is reset
+	  via GPIO
+
+config MAX6373_WDT_GPIO
+	int "Maxim MAX6373 WDT Reset GPIO"
+	depends on MAX6373_WATCHDOG
+	help
+	  GPIO number used by the MAX6373 driver to reset the WDT at runtime
+
+endmenu # menu "Watchdog Timer Support"
drivers/watchdog/Makefile +1 -0
index 482a4bd..5bb5f5b 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o
 obj-$(CONFIG_BFIN_WATCHDOG)  += bfin_wdt.o
 obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
 obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o
+obj-$(CONFIG_MAX6373_WATCHDOG) += max6373_wdt.o
drivers/watchdog/max6373_wdt.c new file +34 -0
new file mode 100644
index 0000000..cda46af
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 DAVE Embedded Systems <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * MAX6373 is a WDT which uses a simple GPIO to reset its timeout
+ *
+ * Use CONFIG_MAX6373_WDT_GPIO to define the GPIO number to use
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+#include <watchdog.h>
+
+#ifndef CONFIG_MAX6373_WDT_GPIO
+#error "Please use CONFIG_MAX6373_WDT_GPIO to define which GPIO to use"
+#endif
+
+void hw_watchdog_reset(void)
+{
+	gpio_set_value(CONFIG_MAX6373_WDT_GPIO,
+		!gpio_get_value(CONFIG_MAX6373_WDT_GPIO));
+}
+
+void hw_watchdog_init(void)
+{
+	if (gpio_request(CONFIG_MAX6373_WDT_GPIO, "MAX6373 WDT")) {
+		printf("Cannot request GPIO %d for MAX6373 WDT\n",
+			CONFIG_MAX6373_WDT_GPIO);
+		return;
+	}
+	gpio_direction_output(CONFIG_MAX6373_WDT_GPIO, 1);
+}
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v2 1/1 drivers: watchdog: add MAX6373 WDT support

Hi

Quoted 69 lines · On Tue, Aug 18, 2015 at 3:22 PM, <[email protected]> wrote:

From: Andrea Scian <[email protected]>

MAX6373 is a simple WDT which is programmed its configuration pins and reset via another pin, which is usually connected to a GPIO

---

Changes for v2:
- add Kconfig support

 drivers/watchdog/Kconfig       |   17 +++++++++++++++++
 drivers/watchdog/Makefile      |    1 +
 drivers/watchdog/max6373_wdt.c |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 drivers/watchdog/max6373_wdt.c
drivers/watchdog/Kconfig +17 -0
index e69de29..c7c2011 100644
@@ -0,0 +1,17 @@
+menu "Watchdog Timer Support"
+
+config MAX6373_WATCHDOG
+       bool "Maxim MAX6373 Watchdog"
+       depends on DM_GPIO
+       default n
+       help
+         Enable MAX6373 Watchdog timer driver. This is a simple WDT which is reset
+         via GPIO
+
+config MAX6373_WDT_GPIO
+       int "Maxim MAX6373 WDT Reset GPIO"
+       depends on MAX6373_WATCHDOG
+       help
+         GPIO number used by the MAX6373 driver to reset the WDT at runtime
+
+endmenu # menu "Watchdog Timer Support"
drivers/watchdog/Makefile +1 -0
index 482a4bd..5bb5f5b 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o
 obj-$(CONFIG_BFIN_WATCHDOG)  += bfin_wdt.o
 obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
 obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o
+obj-$(CONFIG_MAX6373_WATCHDOG) += max6373_wdt.o
drivers/watchdog/max6373_wdt.c new file +15 -0
new file mode 100644
index 0000000..cda46af
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 DAVE Embedded Systems <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ *
+ * MAX6373 is a WDT which uses a simple GPIO to reset its timeout
+ *
+ * Use CONFIG_MAX6373_WDT_GPIO to define the GPIO number to use
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+#include <watchdog.h>
+

drivers/watchdog/max6373_wdt.c line 25

Quoted 10 lines
drivers/watchdog/max6373_wdt.c new file +10 -0
+#ifndef CONFIG_MAX6373_WDT_GPIO
+#error "Please use CONFIG_MAX6373_WDT_GPIO to define which GPIO to use"
+#endif
+
+void hw_watchdog_reset(void)
+{
+       gpio_set_value(CONFIG_MAX6373_WDT_GPIO,
+               !gpio_get_value(CONFIG_MAX6373_WDT_GPIO));
+}
+

According to the datasheet timeout can be select from 3 additional pin. Plus if a timeout is defined you can avoid to change the value always. For example if the gpio pin is on an expander you avoid to send an i2c message always. Half of timeout is always enough. Even because this invest a family of device I don't think that we require a name. Can be watchdog-gpio?

Michael

Quoted 16 lines
drivers/watchdog/max6373_wdt.c new file +9 -1
+void hw_watchdog_init(void)
+{
+       if (gpio_request(CONFIG_MAX6373_WDT_GPIO, "MAX6373 WDT")) {
+               printf("Cannot request GPIO %d for MAX6373 WDT\n",
+                       CONFIG_MAX6373_WDT_GPIO);
+               return;
+       }
+       gpio_direction_output(CONFIG_MAX6373_WDT_GPIO, 1);
+}
--

1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

PATCH v2 1/1 drivers: watchdog: add MAX6373 WDT support

Il 18/08/2015 15:33, Michael Trimarchi ha scritto:

Quoted 79 lines

Hi

Quoted 76 lines · On Tue, Aug 18, 2015 at 3:22 PM, <[email protected]> wrote:

From: Andrea Scian <[email protected]>

MAX6373 is a simple WDT which is programmed its configuration pins and reset via another pin, which is usually connected to a GPIO

---

Changes for v2:
- add Kconfig support

  drivers/watchdog/Kconfig       |   17 +++++++++++++++++
  drivers/watchdog/Makefile      |    1 +
  drivers/watchdog/max6373_wdt.c |   34 ++++++++++++++++++++++++++++++++++
  3 files changed, 52 insertions(+)

create mode 100644 drivers/watchdog/max6373_wdt.c

drivers/watchdog/Kconfig +17 -0
index e69de29..c7c2011 100644
@@ -0,0 +1,17 @@
+menu "Watchdog Timer Support"
+
+config MAX6373_WATCHDOG
+       bool "Maxim MAX6373 Watchdog"
+       depends on DM_GPIO
+       default n
+       help
+         Enable MAX6373 Watchdog timer driver. This is a simple WDT which is reset
+         via GPIO
+
+config MAX6373_WDT_GPIO
+       int "Maxim MAX6373 WDT Reset GPIO"
+       depends on MAX6373_WATCHDOG
+       help
+         GPIO number used by the MAX6373 driver to reset the WDT at runtime
+
+endmenu # menu "Watchdog Timer Support"
drivers/watchdog/Makefile +1 -0
index 482a4bd..5bb5f5b 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o
  obj-$(CONFIG_BFIN_WATCHDOG)  += bfin_wdt.o
  obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
  obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o
+obj-$(CONFIG_MAX6373_WATCHDOG) += max6373_wdt.o
drivers/watchdog/max6373_wdt.c new file +22 -0
new file mode 100644
index 0000000..cda46af
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 DAVE Embedded Systems <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ *
+ * MAX6373 is a WDT which uses a simple GPIO to reset its timeout
+ *
+ * Use CONFIG_MAX6373_WDT_GPIO to define the GPIO number to use
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+#include <watchdog.h>
+
+#ifndef CONFIG_MAX6373_WDT_GPIO
+#error "Please use CONFIG_MAX6373_WDT_GPIO to define which GPIO to use"
+#endif
+
+void hw_watchdog_reset(void)
+{
+       gpio_set_value(CONFIG_MAX6373_WDT_GPIO,
Quoted 8 lines

drivers/watchdog/max6373_wdt.c line 25

Quoted 3 lines
drivers/watchdog/max6373_wdt.c new file +3 -0
+               !gpio_get_value(CONFIG_MAX6373_WDT_GPIO));
+}
+

According to the datasheet timeout can be select from 3 additional pin. Plus if a timeout is defined you can avoid to change the value always. For example if the gpio pin is on an expander you avoid to send an i2c message always. Half of timeout is always enough.

Understood. I think we can add the WDT timeout or WDT ping timeout (in ms?) as an additional Kconfig entry.

Can you please give me some clues about the best way to safely calculate such a timeout in this scenario?

Then I can elaborate on it and test it on hardware (as soon as I find some spare time ;-) )

Quoted 2 lines

Even because this invest a family of device
I don't think that we require a name. Can be watchdog-gpio?

I didn't think about writing a general purpose GPIO WDT driver, but I think it's a nice idea. It may be useful as heartbeat too.

I think we can call it as you suggest.
I can rewrite the code and make it more reusable, if there's no other comments on this.

Quoted 2 lines

Michael

Thanks for your feedback,

Signature · 3 lines
Andrea SCIAN

DAVE Embedded Systems
Quoted 17 lines
Quoted 17 lines
drivers/watchdog/max6373_wdt.c new file +9 -1
+void hw_watchdog_init(void)
+{
+       if (gpio_request(CONFIG_MAX6373_WDT_GPIO, "MAX6373 WDT")) {
+               printf("Cannot request GPIO %d for MAX6373 WDT\n",
+                       CONFIG_MAX6373_WDT_GPIO);
+               return;
+       }
+       gpio_direction_output(CONFIG_MAX6373_WDT_GPIO, 1);
+}
--

1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot