From patchwork Thu Feb 9 19:12:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Brandt X-Patchwork-Id: 9565371 X-Patchwork-Delegate: horms@verge.net.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A1F56020C for ; Thu, 9 Feb 2017 19:13:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E71502853C for ; Thu, 9 Feb 2017 19:13:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB79728550; Thu, 9 Feb 2017 19:13:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32A902853C for ; Thu, 9 Feb 2017 19:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753099AbdBITNQ (ORCPT ); Thu, 9 Feb 2017 14:13:16 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:64280 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751235AbdBITNQ (ORCPT ); Thu, 9 Feb 2017 14:13:16 -0500 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 10 Feb 2017 04:13:14 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 359DF4683D; Fri, 10 Feb 2017 04:13:14 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 33737480A5; Fri, 10 Feb 2017 04:13:14 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 2DB9A48014; Fri, 10 Feb 2017 04:13:14 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id EAN11098; Fri, 10 Feb 2017 04:13:14 +0900 X-IronPort-AV: E=Sophos;i="5.35,137,1483974000"; d="scan'208";a="234084377" Received: from unknown (HELO rtamta01.rta.renesas.com) ([143.103.48.75]) by relmlii2.idc.renesas.com with ESMTP; 10 Feb 2017 04:13:13 +0900 Received: from localhost.localdomain (unknown [143.103.58.175]) by rtamta01.rta.renesas.com (Postfix) with ESMTP id 1B62E45F; Thu, 9 Feb 2017 19:13:08 +0000 (UTC) From: Chris Brandt To: Simon Horman Cc: linux-renesas-soc@vger.kernel.org, Chris Brandt Subject: [PATCH] ARM: shmobile: r7s72100: add restart handler Date: Thu, 9 Feb 2017 14:12:59 -0500 Message-Id: <20170209191259.29774-1-chris.brandt@renesas.com> X-Mailer: git-send-email 2.10.1 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a simple restart handler which enables the watchdog timer with the device reset option enabled. This is the only way SW can cause a reset on this SoC. If someone has a board that needs more specific operations to be done first, they can override this function in another file. Signed-off-by: Chris Brandt --- arch/arm/mach-shmobile/setup-r7s72100.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c index d46639f..cc6237e 100644 --- a/arch/arm/mach-shmobile/setup-r7s72100.c +++ b/arch/arm/mach-shmobile/setup-r7s72100.c @@ -15,11 +15,40 @@ */ #include +#include #include #include "common.h" +/* + * This function is declared weak so if you need to do some board specific stuff + * before the reset occurs, you can override this function. + * + * CAUTION: A reboot command doesn't 'sync' before this function + * is called. See function reboot() in kernel/reboot.c + */ +extern void __attribute__ ((weak)) r7s72100_restart(enum reboot_mode mode, + const char *cmd) +{ +#define WTCSR 0 +#define WTCNT 2 +#define WRCSR 4 + void *base = ioremap(0xFCFE0000, 0x10); + + /* Dummy read (must read WRCSR:WOVF at least once before clearing) */ + readw(base + WRCSR); + + writew(0xA500, base + WRCSR); /* Clear WOVF */ + writew(0x5A5F, base + WRCSR); /* Reset Enable */ + writew(0x5A00, base + WTCNT); /* Counter to 00 */ + writew(0xA578, base + WTCSR); /* Start timer */ + + /* Wait for WDT overflow */ + while (1) + ; +} + static const char *const r7s72100_boards_compat_dt[] __initconst = { "renesas,r7s72100", NULL, @@ -29,4 +58,5 @@ DT_MACHINE_START(R7S72100_DT, "Generic R7S72100 (Flattened Device Tree)") .init_early = shmobile_init_delay, .init_late = shmobile_init_late, .dt_compat = r7s72100_boards_compat_dt, + .restart = r7s72100_restart, MACHINE_END