From patchwork Mon Nov 19 11:09:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1764431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 5B5193FCAE for ; Mon, 19 Nov 2012 11:13:06 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TaPFe-00034t-L9; Mon, 19 Nov 2012 11:10:54 +0000 Received: from mo6-p05-ob.rzone.de ([2a01:238:20a:202:5305::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TaPEt-0002pp-29 for linux-arm-kernel@lists.infradead.org; Mon, 19 Nov 2012 11:10:08 +0000 X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohdvpEkce+Ub4+ReKfHD+mCZCG4i4= X-RZG-CLASS-ID: mo05 Received: from ubuntu-2012.fritz.box (p57B94205.dip.t-dialin.net [87.185.66.5]) by smtp.strato.de (jored mo34) (RZmta 31.4 DYNA|AUTH) with ESMTPA id j02f1aoAJAVoLL ; Mon, 19 Nov 2012 12:09:56 +0100 (CET) From: Stefan Roese To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] ARM: sunxi: Add sunxi restart function via onchip watchdog Date: Mon, 19 Nov 2012 12:09:43 +0100 Message-Id: <1353323383-11827-4-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1353323383-11827-1-git-send-email-sr@denx.de> References: <1353323383-11827-1-git-send-email-sr@denx.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121119_061007_353856_F0428C48 X-CRM114-Status: GOOD ( 13.11 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Maxime Ripard , Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Signed-off-by: Stefan Roese Cc: Maxime Ripard Cc: Arnd Bergmann Acked-by: Arnd Bergmann --- arch/arm/mach-sunxi/sunxi.c | 1 + arch/arm/mach-sunxi/sunxi.h | 2 ++ drivers/clocksource/sunxi_timer.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c index 13d4d96..6b1186c 100644 --- a/arch/arm/mach-sunxi/sunxi.c +++ b/arch/arm/mach-sunxi/sunxi.c @@ -57,5 +57,6 @@ DT_MACHINE_START(SUNXI_DT, "Allwinner A1X (Device Tree)") .init_irq = sunxi_init_irq, .handle_irq = sunxi_handle_irq, .timer = &sunxi_timer, + .restart = sunxi_restart, .dt_compat = sunxi_board_dt_compat, MACHINE_END diff --git a/arch/arm/mach-sunxi/sunxi.h b/arch/arm/mach-sunxi/sunxi.h index 33b5871..806c5fd 100644 --- a/arch/arm/mach-sunxi/sunxi.h +++ b/arch/arm/mach-sunxi/sunxi.h @@ -17,4 +17,6 @@ #define SUNXI_REGS_VIRT_BASE IOMEM(0xf1c00000) #define SUNXI_REGS_SIZE (SZ_2M + SZ_1M) +void sunxi_restart(char mode, const char *cmd); + #endif /* __MACH_SUNXI_H */ diff --git a/drivers/clocksource/sunxi_timer.c b/drivers/clocksource/sunxi_timer.c index 3c46434..dfbf879 100644 --- a/drivers/clocksource/sunxi_timer.c +++ b/drivers/clocksource/sunxi_timer.c @@ -34,6 +34,8 @@ #define TIMER0_CTL_ONESHOT (1 << 7) #define TIMER0_INTVAL_REG 0x14 #define TIMER0_CNTVAL_REG 0x18 +#define WATCH_DOG_CTRL_REG 0x90 +#define WATCH_DOG_MODE_REG 0x94 #define TIMER_SCAL 16 @@ -103,6 +105,18 @@ static struct of_device_id sunxi_timer_dt_ids[] = { { .compatible = "allwinner,sunxi-timer" }, }; +void sunxi_restart(char mode, const char *cmd) +{ + /* Use watchdog to reset system */ + + /* Enable timer and set reset bit */ + writel(3, timer_base + WATCH_DOG_MODE_REG); + writel(0xa57 << 1 | 1, timer_base + WATCH_DOG_CTRL_REG); + + while(1) + ; +} + static void __init sunxi_timer_init(void) { struct device_node *node;