From patchwork Wed Jul 24 23:35:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 18552 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 18A9A25E75 for ; Wed, 24 Jul 2013 23:35:45 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id x14sf713457ggx.0 for ; Wed, 24 Jul 2013 16:35:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :x-server-uuid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:x-wss-id:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=q/zLQ2TKnkWi61T0HXAARbHVvgjvbcplYSaEN+c0Lho=; b=dCp1Y3U5chDCj4Ow26q9gAblAx087Ic9BvZ9AW/X8R6X/T8tbiRdShdn6/TGmpco7X 0QnfnGFzCBxoeIRRCk0CEL/+R6EozBoJ8MXIuSfkK+w6oCR191XUAky2+Pk3J4/2SQxm 6osRs0DojbIMWmYRRS0B9bLQMU7FHyH61pbBFMJeQvWWOVa3DtKI768RM5+tz10U4LOQ MPJ8GqdxxJQJrjaL3UaOY6lO4zDleLLQuPYcU5nUS7YsyTW5z8DdroQgm56FFW+9w3sk v5/LPBOPRlS5aXVTqryJ6T7WHASPp0m3N5AbJxSuNeWVUAxC67y+4jUZhzH7D7BNsvYU DpFQ== X-Received: by 10.224.54.73 with SMTP id p9mr53157290qag.1.1374708944808; Wed, 24 Jul 2013 16:35:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.15.131 with SMTP id x3ls404474qec.76.gmail; Wed, 24 Jul 2013 16:35:44 -0700 (PDT) X-Received: by 10.58.200.73 with SMTP id jq9mr16244338vec.53.1374708944672; Wed, 24 Jul 2013 16:35:44 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id mu5si11147579vec.65.2013.07.24.16.35.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Jul 2013 16:35:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id db10so159059veb.28 for ; Wed, 24 Jul 2013 16:35:44 -0700 (PDT) X-Received: by 10.52.120.77 with SMTP id la13mr13551565vdb.23.1374708944460; Wed, 24 Jul 2013 16:35:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp51753veb; Wed, 24 Jul 2013 16:35:43 -0700 (PDT) X-Received: by 10.68.131.168 with SMTP id on8mr44698880pbb.97.1374708942835; Wed, 24 Jul 2013 16:35:42 -0700 (PDT) Received: from mms1.broadcom.com (mms1.broadcom.com. [216.31.210.17]) by mx.google.com with ESMTP id l2si28894883pan.170.2013.07.24.16.35.41 for ; Wed, 24 Jul 2013 16:35:42 -0700 (PDT) Received-SPF: neutral (google.com: 216.31.210.17 is neither permitted nor denied by best guess record for domain of markus.mayer@linaro.org) client-ip=216.31.210.17; Received: from [10.9.208.55] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Wed, 24 Jul 2013 16:31:47 -0700 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.1.438.0; Wed, 24 Jul 2013 16:35:35 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.1.438.0; Wed, 24 Jul 2013 16:35:35 -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 432E1F2D73; Wed, 24 Jul 2013 16:35:35 -0700 (PDT) From: "Markus Mayer" To: "ARM Kernel List" , "Device Tree List" cc: "Christian Daudt" , "Linaro Patches" , "Device Tree List" , "Markus Mayer" Subject: [PATCH v2 1/2] ARM: bcm281xx: Board specific reboot code Date: Wed, 24 Jul 2013 16:35:22 -0700 Message-ID: <1374708923-11956-2-git-send-email-markus.mayer@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374708923-11956-1-git-send-email-markus.mayer@linaro.org> References: <1374708923-11956-1-git-send-email-markus.mayer@linaro.org> MIME-Version: 1.0 X-WSS-ID: 7DEEBC6931W55491073-01-01 X-Gm-Message-State: ALoCoQk7mSnq6nXbbNUYjjQVf64TNr+KZFr/nLI/lxGgXQUrg5uwodilb6ijXtdSivDo8ZgCPi2Q X-Original-Sender: markus.mayer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch adds the code needed to trigger a reboot on the bcm281xx family. Signed-off-by: Markus Mayer Reviewed-by: Tim Kryger Reviewed-by: Matt Porter Reviewed-by: Alex Elder Acked-by: Christian Daudt --- arch/arm/mach-bcm/Makefile | 4 +-- arch/arm/mach-bcm/board_bcm.c | 20 +++++++++++-- arch/arm/mach-bcm/kona.c | 65 +++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-bcm/kona.h | 17 +++++++++++ 4 files changed, 101 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 2859932..1e49ec0 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 @@ -21,8 +21,8 @@ #include #include - #include "bcm_kona_smc.h" +#include "kona.h" static int __init kona_l2_cache_init(void) { @@ -40,13 +40,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(); } @@ -55,5 +68,6 @@ static const char * const bcm11351_dt_compat[] = { "bcm,bcm11351", NULL, }; DT_MACHINE_START(BCM11351_DT, "Broadcom Application Processor") .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..6939d90 --- /dev/null +++ b/arch/arm/mach-bcm/kona.c @@ -0,0 +1,65 @@ +/* + * 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; + + /* + * The assumption is that whoever calls bcm_kona_setup_restart() + * also needs a Kona Watchdog Timer entry in Device Tree, i.e. we + * report an error if the DT entry is missing. + */ + np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt"); + if (!np_wdog) { + pr_err("brcm,kona-wdt not found in DT, reboot disabled\n"); + return; + } + watchdog_base = of_iomap(np_wdog, 0); + WARN(!watchdog_base, "failed to map watchdog base"); + of_node_put(np_wdog); +} + +#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(enum reboot_mode mode, const char *cmd) +{ + uint32_t val; + + if (!watchdog_base) + panic("Watchdog not mapped. Reboot failed.\n"); + + /* Enable watchdog2 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..291eca3 --- /dev/null +++ b/arch/arm/mach-bcm/kona.h @@ -0,0 +1,17 @@ +/* + * 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 + +void bcm_kona_setup_restart(void); +void bcm_kona_restart(enum reboot_mode mode, const char *cmd);