From patchwork Fri Aug 11 13:04:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9895801 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 00C3D602DA for ; Fri, 11 Aug 2017 13:04:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E266428BE7 for ; Fri, 11 Aug 2017 13:04:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6AFD28C1D; Fri, 11 Aug 2017 13:04:42 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham 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 3888C28BE7 for ; Fri, 11 Aug 2017 13:04:42 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=Ggcci1IkNKe5LR7U901v9yov1265qSln885gqdOj2kE=; b=iHoUuc8KWr6ZDI gEjEv7DKd2J3eNoTH0Sd1wkgDFYcZh23HGB8g4DZGZ/WlxRoUYihuVl+k0S/RnqQGpREJsHO810uc slr0gCgK2Qv/5cItr+F+tR50ux/irTOmoY5XAxWq82WhgqSni8GEl3nnPU7gdisIf4JiPA2Dhx6bZ Libd6+ZJVGuUsJXeHCZ6K/PQDfkJEIwrdaiLK3COJ1c9zxJ9klLeX0KpxgDEYeEnTqdyHRuXHctJd P89pKuxOpzKoZZ8t+19evSfDev5EK7BpbnBtNS5LcRknjsZP109ePiwA63JDffIqBCjGutKn4D7r1 lsmRhKMHyLpSuz+hxePA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dg9cD-0007Ce-Uo; Fri, 11 Aug 2017 13:04:37 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dg9cA-00078P-5m for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2017 13:04:36 +0000 Received: by mail-wm0-x243.google.com with SMTP id y206so6412817wmd.5 for ; Fri, 11 Aug 2017 06:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references:mime-version:content-transfer-encoding; bh=HCZGq2Z0ZQ2Js9om5hTfQzdPo8p17jlp7W48Q4LvEeg=; b=RIFoS0h+euifNJyCYox+mXHFATbLrI2szs0ETgmyz+2W5fEuIAVWLBuLhHPXGfVHxo uKtWcHv/kkQeypsH+duqqVAhy0wTPNr2ZrGSl8Z0fg5vX6E2E6/Jr5bF6uIlnjybBDHY DvM2vcQr5Hj3Wg2unHsGx5A3+PNChkGtvZvWKAkrYNxP6m5uOEnCrgi06jpvSvPhWkju QsQiR4amDS0t3ZxNndK+5jEWgrPxiJEGd0DZDynWasjRewfKZBK+bqxRJXgE6QXG+Mr3 TZAmP8IQDN58h0LDBSr0IcjL/z2srIzxQNVn/1xceGhhKxvdBQJnOx5U+MlqVl83QEVe JQqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:mime-version :content-transfer-encoding; bh=HCZGq2Z0ZQ2Js9om5hTfQzdPo8p17jlp7W48Q4LvEeg=; b=TtX0eFv+Avb3AzAPrLfQKRkkh/BMMWruTsGwVfHZaqDeC20eHz0hpLSgAu/KxLNjHy xLsnFXOqOWgz83OCWkdhYkYFPyIor0BopjVY01qqFn8lYQwljmU04vUlTVhipYdqLUg4 WdHpkhEVqGOK84/islGXaZVOrI+30M9nKyq7unggO/MSVgJFZhQOws5HKpcv2lVnlrgd FrnyxbFSrDE1R8AnctQaXQJSEp0kNrGap1jDuoKq126zyHVqf4PvTqcE3cUE0WANVESv wUwnd1eXaUnwWRVs1mHU+h48sky5lzdaDXuuionSsgX+9V5s6Md/+qSYPXMNfaNMqajU Nfhg== X-Gm-Message-State: AHYfb5ineMs0dA8Eb5YmmwmNPDBzjbgeAr7vHE7bU3Z/HjuGbSFBwip8 leIdPcI8jxt3aWBB X-Received: by 10.28.31.77 with SMTP id f74mr9170009wmf.149.1502456651958; Fri, 11 Aug 2017 06:04:11 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id w19sm1131752wrb.49.2017.08.11.06.04.11 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 11 Aug 2017 06:04:11 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH v2 2/2] ARM: zynq: Add support for Zynq-7000S devices Date: Fri, 11 Aug 2017 15:04:08 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: <7e99803ff35cc540f8ce4fccc0940f1d730e8dc5.1502456643.git.michal.simek@xilinx.com> References: <7e99803ff35cc540f8ce4fccc0940f1d730e8dc5.1502456643.git.michal.simek@xilinx.com> In-Reply-To: <7e99803ff35cc540f8ce4fccc0940f1d730e8dc5.1502456643.git.michal.simek@xilinx.com> References: <7e99803ff35cc540f8ce4fccc0940f1d730e8dc5.1502456643.git.michal.simek@xilinx.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170811_060434_388430_037B0210 X-CRM114-Status: GOOD ( 19.72 ) 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: Mark Rutland , devicetree@vger.kernel.org, Peter Crosthwaite , Josh Cartwright , Russell King , Rob Herring , Rob Herring , linux-arm-kernel@lists.infradead.org, Steffen Trumtrar , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= 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 Patch adds detection of Zynq-7000 base silicon configuration, namely Dual or Single CPU. Device trees attempting to enable DUAL CORE behavior on SINGLE CPU Zynq-7000S devices are prevented from corrupting system behavior. Detection of Dual or Single CPU is done via eFuses. Signed-off-by: Michal Simek Acked-by: Sören Brinkmann --- Changes in v2: - Make zynq_efuse_base static arch/arm/boot/dts/zynq-7000.dtsi | 5 +++ arch/arm/mach-zynq/Makefile | 2 +- arch/arm/mach-zynq/common.c | 1 + arch/arm/mach-zynq/common.h | 3 ++ arch/arm/mach-zynq/efuse.c | 75 ++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-zynq/platsmp.c | 3 ++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-zynq/efuse.c diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi index f3ac9bfe580e..ac37d46b2eab 100644 --- a/arch/arm/boot/dts/zynq-7000.dtsi +++ b/arch/arm/boot/dts/zynq-7000.dtsi @@ -305,6 +305,11 @@ syscon = <&slcr>; }; + efuse: efuse@f800d000 { + compatible = "xlnx,zynq-efuse"; + reg = <0xf800d000 0x20>; + }; + global_timer: timer@f8f00200 { compatible = "arm,cortex-a9-global-timer"; reg = <0xf8f00200 0x20>; diff --git a/arch/arm/mach-zynq/Makefile b/arch/arm/mach-zynq/Makefile index b03a97eb7501..1fc2d4b53a5e 100644 --- a/arch/arm/mach-zynq/Makefile +++ b/arch/arm/mach-zynq/Makefile @@ -3,5 +3,5 @@ # # Common support -obj-y := common.o slcr.o pm.o +obj-y := common.o efuse.o slcr.o pm.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c index 6aba9ebf8041..5f28f7220d48 100644 --- a/arch/arm/mach-zynq/common.c +++ b/arch/arm/mach-zynq/common.c @@ -182,6 +182,7 @@ static void __init zynq_map_io(void) static void __init zynq_irq_init(void) { + zynq_early_efuse_init(); zynq_early_slcr_init(); irqchip_init(); } diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h index e771933db7e8..33742c3308e0 100644 --- a/arch/arm/mach-zynq/common.h +++ b/arch/arm/mach-zynq/common.h @@ -25,6 +25,9 @@ extern void zynq_slcr_cpu_state_write(int cpu, bool die); extern u32 zynq_slcr_get_device_id(void); +extern bool zynq_efuse_cpu_state(int cpu); +extern int zynq_early_efuse_init(void); + #ifdef CONFIG_SMP extern char zynq_secondary_trampoline; extern char zynq_secondary_trampoline_jump; diff --git a/arch/arm/mach-zynq/efuse.c b/arch/arm/mach-zynq/efuse.c new file mode 100644 index 000000000000..d9a14d9c8231 --- /dev/null +++ b/arch/arm/mach-zynq/efuse.c @@ -0,0 +1,75 @@ +/* + * Xilinx EFUSE driver + * + * Copyright (c) 2016 Xilinx Inc. + * + * 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; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include "common.h" + +#define EFUSE_STATUS_OFFSET 0x10 + +/* 0 means cpu1 is working, 1 means cpu1 is broken */ +#define EFUSE_STATUS_CPU_BIT BIT(7) + +static void __iomem *zynq_efuse_base; + +/** + * zynq_efuse_cpu_state - Read/write cpu state + * @cpu: cpu number + * + * Return: true if cpu is running, false if cpu is broken + */ +bool zynq_efuse_cpu_state(int cpu) +{ + u32 state; + + if (!cpu) + return true; + + state = readl(zynq_efuse_base + EFUSE_STATUS_OFFSET); + state &= EFUSE_STATUS_CPU_BIT; + + if (!state) + return true; + + return false; +} + +/** + * zynq_early_efuse_init - Early efuse init function + * + * Return: 0 on success, negative errno otherwise. + * + * Called very early during boot from platform code. + */ +int __init zynq_early_efuse_init(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "xlnx,zynq-efuse"); + if (!np) { + pr_err("%s: no efuse node found\n", __func__); + BUG(); + } + + zynq_efuse_base = of_iomap(np, 0); + if (!zynq_efuse_base) { + pr_err("%s: Unable to map I/O memory\n", __func__); + BUG(); + } + + np->data = (__force void *)zynq_efuse_base; + + pr_info("%s mapped to %p\n", np->name, zynq_efuse_base); + + of_node_put(np); + + return 0; +} diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c index caa6d5fe9078..3d81e0f2972f 100644 --- a/arch/arm/mach-zynq/platsmp.c +++ b/arch/arm/mach-zynq/platsmp.c @@ -89,6 +89,9 @@ int zynq_cpun_start(u32 address, int cpu) static int zynq_boot_secondary(unsigned int cpu, struct task_struct *idle) { + if (!zynq_efuse_cpu_state(cpu)) + return -1; + return zynq_cpun_start(__pa_symbol(secondary_startup), cpu); }