From patchwork Thu Feb 7 12:10:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 218905 X-Patchwork-Delegate: wd@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 958312C0092 for ; Thu, 7 Feb 2013 23:10:43 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 27E764A10F; Thu, 7 Feb 2013 13:10:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y8FE4AEN0BE6; Thu, 7 Feb 2013 13:10:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CAD274A10D; Thu, 7 Feb 2013 13:10:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 457FB4A10D for ; Thu, 7 Feb 2013 13:10:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BfnHGtb-LiEv for ; Thu, 7 Feb 2013 13:10:37 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mo-p05-ob.rzone.de (mo-p05-ob.rzone.de [81.169.146.182]) by theia.denx.de (Postfix) with ESMTPS id 5344F4A0FD for ; Thu, 7 Feb 2013 13:10:36 +0100 (CET) X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohdvpEkce+Ub40Q/uAFj+9EbzQXT+D3IOO X-RZG-CLASS-ID: mo05 Received: from ubuntu-2012.fritz.box (pD9FFB997.dip.t-dialin.net [217.255.185.151]) by smtp.strato.de (jorabe mo37) (RZmta 31.14 DYNA|AUTH) with ESMTPA id 407a46p17BjndH for ; Thu, 7 Feb 2013 13:10:33 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Date: Thu, 7 Feb 2013 13:10:28 +0100 Message-Id: <1360239028-1926-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.8.1.2 Subject: [U-Boot] [PATCH] mpc5200: a4m2k: Implement custom "dynamic" watchdog support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- 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