From patchwork Fri Jun 28 20:56:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 2802371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 68782BF4A1 for ; Fri, 28 Jun 2013 20:59:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BFD45202F7 for ; Fri, 28 Jun 2013 20:59:52 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFFB7202F6 for ; Fri, 28 Jun 2013 20:59:50 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Usfl5-0008Vj-IJ; Fri, 28 Jun 2013 20:59:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Usfks-0007Xy-9j; Fri, 28 Jun 2013 20:58:54 +0000 Received: from mms3.broadcom.com ([216.31.210.19]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Usfkb-0007WN-V2 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2013 20:58:40 +0000 Received: from [10.9.208.53] by mms3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Fri, 28 Jun 2013 13:48:47 -0700 X-Server-Uuid: B86B6450-0931-4310-942E-F00ED04CA7AF Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.1.438.0; Fri, 28 Jun 2013 13:58:05 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.1.438.0; Fri, 28 Jun 2013 13:58:05 -0700 Received: from mail.broadcom.com (lbrmn-lnxub70.ric.broadcom.com [10.136.8.215]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 1329CF2D73; Fri, 28 Jun 2013 13:58:05 -0700 (PDT) From: "Markus Mayer" To: "ARM Kernel List" Subject: [PATCH 1/2] ARM: bcm281xx: Board specific reboot code Date: Fri, 28 Jun 2013 13:56:57 -0700 Message-ID: <1372453018-5830-2-git-send-email-markus.mayer@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1372453018-5830-1-git-send-email-markus.mayer@linaro.org> References: <1372453018-5830-1-git-send-email-markus.mayer@linaro.org> MIME-Version: 1.0 X-WSS-ID: 7DD329252L839505051-01-01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130628_165838_252907_06346A4C X-CRM114-Status: GOOD ( 19.00 ) X-Spam-Score: -4.2 (----) Cc: Markus Mayer , Device Tree List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the code needed to trigger a reboot on the bcm281xx family. Signed-off-by: Markus Mayer Reviewed-by: Tim Kryger Acked-by: Christian Daudt --- arch/arm/mach-bcm/Makefile | 4 +-- arch/arm/mach-bcm/board_bcm.c | 20 ++++++++++++--- arch/arm/mach-bcm/kona.c | 54 +++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-bcm/kona.h | 15 ++++++++++++ 4 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 arch/arm/mach-bcm/kona.c create mode 100644 arch/arm/mach-bcm/kona.h diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile index 6adb6aec..7e5ca0a 100644 --- a/arch/arm/mach-bcm/Makefile +++ b/arch/arm/mach-bcm/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2012 Broadcom Corporation +# Copyright (C) 2012-2013 Broadcom Corporation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -10,6 +10,6 @@ # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -obj-$(CONFIG_ARCH_BCM) := board_bcm.o bcm_kona_smc.o bcm_kona_smc_asm.o +obj-$(CONFIG_ARCH_BCM) := board_bcm.o bcm_kona_smc.o bcm_kona_smc_asm.o kona.o plus_sec := $(call as-instr,.arch_extension sec,+sec) AFLAGS_bcm_kona_smc_asm.o :=-Wa,-march=armv7-a$(plus_sec) diff --git a/arch/arm/mach-bcm/board_bcm.c b/arch/arm/mach-bcm/board_bcm.c index 22e8421..2dc9f95 100644 --- a/arch/arm/mach-bcm/board_bcm.c +++ b/arch/arm/mach-bcm/board_bcm.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Broadcom Corporation + * Copyright (C) 2012-2013 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -22,8 +22,8 @@ #include #include - #include "bcm_kona_smc.h" +#include "kona.h" static int __init kona_l2_cache_init(void) { @@ -41,13 +41,26 @@ static int __init kona_l2_cache_init(void) return 0; } +static void bcm_board_setup_restart(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "bcm,bcm11351"); + if (np) { + if (of_device_is_available(np)) + bcm_kona_setup_restart(); + of_node_put(np); + } + /* Restart setup for other boards goes here */ +} + static void __init board_init(void) { of_platform_populate(NULL, of_default_bus_match_table, NULL, &platform_bus); bcm_kona_smc_init(); - + bcm_board_setup_restart(); kona_l2_cache_init(); } @@ -57,5 +70,6 @@ DT_MACHINE_START(BCM11351_DT, "Broadcom Application Processor") .init_irq = irqchip_init, .init_time = clocksource_of_init, .init_machine = board_init, + .restart = bcm_kona_restart, .dt_compat = bcm11351_dt_compat, MACHINE_END diff --git a/arch/arm/mach-bcm/kona.c b/arch/arm/mach-bcm/kona.c new file mode 100644 index 0000000..4492b9f --- /dev/null +++ b/arch/arm/mach-bcm/kona.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 Broadcom Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#include "kona.h" + +static void __iomem *watchdog_base; + +void bcm_kona_setup_restart(void) +{ + struct device_node *np_wdog; + + np_wdog = of_find_compatible_node(NULL, NULL, "bcm,kona-wdt"); + watchdog_base = of_iomap(np_wdog, 0); + WARN(!watchdog_base, "failed to map watchdog base"); + of_node_put(np_wdog); +} + +#define GICDIST_ENABLE_OFFSET 0x00000000 +#define SECWDOG_OFFSET 0x00000000 +#define SECWDOG_RESERVED_MASK 0xE2000000 +#define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000 +#define SECWDOG_EN_MASK 0x08000000 +#define SECWDOG_SRSTEN_MASK 0x04000000 +#define SECWDOG_CLKS_SHIFT 20 +#define SECWDOG_LOCK_SHIFT 0 + +void bcm_kona_restart(char mode, const char *cmd) +{ + uint32_t val; + + /* Enable watchdog 2 with very short timeout. */ + val = readl(watchdog_base + SECWDOG_OFFSET); + val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK; + val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK | + (0x8 << SECWDOG_CLKS_SHIFT) | + (0x8 << SECWDOG_LOCK_SHIFT); + writel(val, watchdog_base + SECWDOG_OFFSET); + + while (1) + ; +} diff --git a/arch/arm/mach-bcm/kona.h b/arch/arm/mach-bcm/kona.h new file mode 100644 index 0000000..ecb417e --- /dev/null +++ b/arch/arm/mach-bcm/kona.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2013 Broadcom Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +void bcm_kona_setup_restart(void); +void bcm_kona_restart(char mode, const char *cmd);