From patchwork Thu Jan 25 18:02:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 10184429 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 0B59260388 for ; Thu, 25 Jan 2018 18:04:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EECBA28A10 for ; Thu, 25 Jan 2018 18:04:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2D1C28A23; Thu, 25 Jan 2018 18:04:01 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7203728A2C for ; Thu, 25 Jan 2018 18:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n6ttws7nEIzyAcDj4UtH81x16M41W5FRLiqfcc8+do4=; b=Y2UP8e64FD/yvEf4aodiR2r9T+ Adrw5tLPSr/ACF9SD4BMW6YBdMTMe/QvSIWgXVUU4B//KtwK6a4gPwlzGs4HpsP04NJBmYxkEwad6 jyQ6kXuxUj2O2lIpeBmGtG4byBXefpEjw6fOUdhVaiHUJ3PBQ97By9wwmOyxsKPCehuFKYMvCPOml RTPnp/lzQxdJTHxcniUxaGA4zUC6n2J/WjCjZzR1WEMuBqsaLqyQRR5h3fJOzSMUTGi3Jj+byIytF EEYt+55qsGPEGteDLk/K1BRrqPs0ega0nSC8jTzWpxxuxeEjqNqD0a5JGrQ32rG3m5z/mbAfmP2PS TLeRhr6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eelsU-0000jL-2a; Thu, 25 Jan 2018 18:03:58 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie1.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eelsB-0000Rg-LH for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2018 18:03:41 +0000 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 26 Jan 2018 03:03:31 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 4783B4BB92; Fri, 26 Jan 2018 03:03:31 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.46,412,1511794800"; d="scan'208";a="270636832" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.37.88]) by relmlii2.idc.renesas.com with ESMTP; 26 Jan 2018 03:03:25 +0900 From: Fabrizio Castro To: Philipp Zabel , Rob Herring , Mark Rutland , Wim Van Sebroeck , Russell King , Catalin Marinas , Will Deacon , Michael Turquette , Stephen Boyd , Simon Horman , Magnus Damm , Geert Uytterhoeven Subject: [RFC 01/37] ARM: shmobile: Add watchdog support Date: Thu, 25 Jan 2018 18:02:35 +0000 Message-Id: <1516903391-30467-2-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516903391-30467-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1516903391-30467-1-git-send-email-fabrizio.castro@bp.renesas.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabrizio Castro , devicetree@vger.kernel.org, Chris Paterson , linux-watchdog@vger.kernel.org, Biju Das , linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ramesh Shanmugasundaram , linux-clk@vger.kernel.org, Guenter Roeck MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On R-Car Gen2 and RZ/G1 platforms, we use the SBAR registers to make non boot CPUs run a routine designed to bring up SMP and deal with hot plug. The value contained in the SBAR registers is not initialized by a WDT triggered reset, which means that after a WDT triggered reset we jump to the SMP bring up routine, preventing the system from executing the bootrom code. The purpose of this patch is to jump to the bootrom code in case of a WDT triggered reset, and keep the SMP functionality untouched. In order to tell if the code had been called due to the WDT overflowing we need to inspect flag WOVF from register RWTCSRA, however for this to work smoothly we need to make sure that RWDT clock is ON. Since it's not wise to interfere with the clock configuration from within this routine, a flag has been put in place (shmobile_wdt_clock_status) so that the watchdog driver can tell shmobile_boot_vector when the clock is ON, and therefore there is no need for shmobile_boot_vector to mess up with the clock registers. Bit WOVF survives a watchdog triggered reset, and it is usually cleared by the bootloader. Checking the MMU enable bit from register SCTLR allows us to make the code a little bit more robust (just in case the bit wasn't cleared up), as right after a reset the MMU is disabled, and when Linux is running the MMU is enabled. Also, accessing RWTCSRA physical address is safe when the MMU is down. SMP bringup, CPU hot plug, and suspend to RAM work as normal. Since shmobile_boot_vector has become bigger, "reg" property of nodes compatible with "renesas,smp-sram" now need to be set to "<0 0x64>". Signed-off-by: Fabrizio Castro Signed-off-by: Ramesh Shanmugasundaram --- arch/arm/mach-shmobile/headsmp.S | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/arch/arm/mach-shmobile/headsmp.S b/arch/arm/mach-shmobile/headsmp.S index 32e0bf6..835bddc 100644 --- a/arch/arm/mach-shmobile/headsmp.S +++ b/arch/arm/mach-shmobile/headsmp.S @@ -16,6 +16,13 @@ #include #include +#define RWDT_CLOCK_ON 0xdeadbeef +#define RWDT_CLOCK_OFF 0x00000000 +#define SCTLR_MMU 0x01 +#define BOOTROM_ADDRESS 0xE6340000 +#define RWTCSRA_ADDRESS 0xE6020004 +#define RWTCSRA_WOVF 0x10 + /* * Reset vector for secondary CPUs. * This will be mapped at address 0 by SBAR register. @@ -24,11 +31,57 @@ .arm .align 12 ENTRY(shmobile_boot_vector) +/* + if (SCTLR_MMU == 1) + goto shmobile_smp_continue; +*/ + mrc p15, 0, r1, c1, c0, 0 @ r1 = SCTLR + and r0, r1, #SCTLR_MMU + cmp r0, #SCTLR_MMU + beq shmobile_smp_continue +/* + if (shmobile_wdt_clock_status != RWDT_CLOCK_ON) + goto shmobile_smp_continue; +*/ + ldr r0, #shmobile_wdt_clock_status + ldr r1, #clock_on + cmp r0, r1 + bne shmobile_smp_continue + +/* + if (RWTCSRA_WOVF == 0) + goto shmobile_smp_continue; +*/ + ldr r0, rwtcsra + mov r1, #0 + ldrb r1, [r0] + and r0, r1, #RWTCSRA_WOVF + cmp r0, #RWTCSRA_WOVF + bne shmobile_smp_continue + +/* + goto bootrom; +*/ + ldr r0, bootrom + bx r0 + +shmobile_smp_continue: ldr r1, 1f bx r1 ENDPROC(shmobile_boot_vector) + .align 4 +rwtcsra: + .word RWTCSRA_ADDRESS +bootrom: + .word BOOTROM_ADDRESS +clock_on: + .word RWDT_CLOCK_ON + .globl shmobile_wdt_clock_status +shmobile_wdt_clock_status: + .word RWDT_CLOCK_OFF + .align 2 .globl shmobile_boot_fn shmobile_boot_fn: