* [U-Boot] [PATCH] mpc5200: a4m2k: Implement custom "dynamic" watchdog support
@ 2013-02-07 12:10 Stefan Roese
2013-03-09 13:45 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Roese @ 2013-02-07 12:10 UTC (permalink / raw)
To: u-boot
This patch adds a custom U-Boot command "wdogtoggle" which enables the
external hardware watchdog toggling via an GPIO pin on the a4m2k
board. After issuing this commands, the watchdog will be serviced
by U-Boot so that the user can use all U-Boot commands from the
prompt.
Signed-off-by: Stefan Roese <sr@denx.de>
---
board/a3m071/a3m071.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
include/configs/a3m071.h | 5 +++++
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/board/a3m071/a3m071.c b/board/a3m071/a3m071.c
index 0a86e9a..0f9f883 100644
--- a/board/a3m071/a3m071.c
+++ b/board/a3m071/a3m071.c
@@ -255,7 +255,7 @@ void spl_board_init(void)
* MPC5XXX_WU_GPIO_DIR direction is already 0 (INPUT)
* set bit 0(msb) to 1
*/
- setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, 1 << (31 - 0));
+ setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, CONFIG_WDOG_GPIO_PIN);
#if defined(CONFIG_A4M2K)
/* Setup USB[x] as MPCDiag[0..3] GPIO outputs */
@@ -410,3 +410,57 @@ int spl_start_uboot(void)
return 1;
}
#endif
+
+#if defined(CONFIG_HW_WATCHDOG)
+static int watchdog_toggle;
+
+void hw_watchdog_reset(void)
+{
+ int val;
+
+ /*
+ * Check if watchdog is enabled via user command
+ */
+ if ((gd->flags & GD_FLG_RELOC) && watchdog_toggle) {
+ /* Set direction to output */
+ setbits_be32((void *)MPC5XXX_WU_GPIO_DIR, CONFIG_WDOG_GPIO_PIN);
+
+ /*
+ * Toggle watchdog output
+ */
+ val = (in_be32((void *)MPC5XXX_WU_GPIO_DATA_O) &
+ CONFIG_WDOG_GPIO_PIN);
+ if (val) {
+ clrbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O,
+ CONFIG_WDOG_GPIO_PIN);
+ } else {
+ setbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O,
+ CONFIG_WDOG_GPIO_PIN);
+ }
+ }
+}
+
+int do_wdog_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ if (argc != 2)
+ goto usage;
+
+ if (strncmp(argv[1], "on", 2) == 0)
+ watchdog_toggle = 1;
+ else if (strncmp(argv[1], "off", 3) == 0)
+ watchdog_toggle = 0;
+ else
+ goto usage;
+
+ return 0;
+usage:
+ printf("Usage: wdogtoggle %s\n", cmdtp->usage);
+ return 1;
+}
+
+U_BOOT_CMD(
+ wdogtoggle, CONFIG_SYS_MAXARGS, 2, do_wdog_toggle,
+ "toggle GPIO pin to service watchdog",
+ "[on/off] - Switch watchdog toggling via GPIO pin on/off"
+);
+#endif
diff --git a/include/configs/a3m071.h b/include/configs/a3m071.h
index d8559d8..13f3226 100644
--- a/include/configs/a3m071.h
+++ b/include/configs/a3m071.h
@@ -166,6 +166,11 @@
#define CONFIG_SYS_GPS_PORT_CONFIG_2 0x1005C005
#endif
+#define CONFIG_WDOG_GPIO_PIN GPIO_WKUP_7
+#if defined(CONFIG_A4M2K) && !defined(CONFIG_SPL_BUILD)
+#define CONFIG_HW_WATCHDOG /* Use external HW-Watchdog */
+#endif
+
/*
* Configuration matrix
* MSB LSB
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] mpc5200: a4m2k: Implement custom "dynamic" watchdog support
2013-02-07 12:10 [U-Boot] [PATCH] mpc5200: a4m2k: Implement custom "dynamic" watchdog support Stefan Roese
@ 2013-03-09 13:45 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2013-03-09 13:45 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
In message <1360239028-1926-1-git-send-email-sr@denx.de> you wrote:
> This patch adds a custom U-Boot command "wdogtoggle" which enables the
> external hardware watchdog toggling via an GPIO pin on the a4m2k
> board. After issuing this commands, the watchdog will be serviced
> by U-Boot so that the user can use all U-Boot commands from the
> prompt.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> board/a3m071/a3m071.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
> include/configs/a3m071.h | 5 +++++
> 2 files changed, 60 insertions(+), 1 deletion(-)
Applied to u-boot-mpc5xxx repo, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Pray to God, but keep rowing to shore. - Russian Proverb
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-09 13:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 12:10 [U-Boot] [PATCH] mpc5200: a4m2k: Implement custom "dynamic" watchdog support Stefan Roese
2013-03-09 13:45 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.