From patchwork Thu Jun 23 12:37:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jon Medhurst \(Tixy\)" X-Patchwork-Id: 70761 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp489225qgy; Thu, 23 Jun 2016 08:26:10 -0700 (PDT) X-Received: by 10.194.139.162 with SMTP id qz2mr30273571wjb.111.1466695570635; Thu, 23 Jun 2016 08:26:10 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id ur3si783645wjc.176.2016.06.23.08.26.10; Thu, 23 Jun 2016 08:26:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0681EA7514; Thu, 23 Jun 2016 17:26:09 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qFQy-BFbHk0j; Thu, 23 Jun 2016 17:26:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4F3AEA74D2; Thu, 23 Jun 2016 17:26:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0B10EA74D2 for ; Thu, 23 Jun 2016 14:37:39 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QYaczmTWXSmO for ; Thu, 23 Jun 2016 14:37:38 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smarthost01d.mail.zen.net.uk (smarthost01d.mail.zen.net.uk [212.23.1.7]) by theia.denx.de (Postfix) with ESMTP id 7066D4BA7F for ; Thu, 23 Jun 2016 14:37:34 +0200 (CEST) Received: from [82.69.122.217] (helo=linaro2) by smarthost01d.mail.zen.net.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1bG3sz-000CQH-1p; Thu, 23 Jun 2016 12:37:33 +0000 Message-ID: <1466685452.3022.18.camel@linaro.org> From: "Jon Medhurst (Tixy)" To: Andre Przywara Date: Thu, 23 Jun 2016 13:37:32 +0100 In-Reply-To: References: <1466606076.3026.30.camel@linaro.org> X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 X-Originating-smarthost01d-IP: [82.69.122.217] X-Mailman-Approved-At: Thu, 23 Jun 2016 17:26:06 +0200 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RFC PATCH] vexpress: Check TC2 firmware support before defaulting to nonsec booting X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The firmware on TC2 needs to be configured appropriately before booting in nonsec mode will work as expected, so test for this and fall back to sec mode if required. Signed-off-by: Jon Medhurst --- This is an implementation of Andre's suggestion in http://lists.denx.de/pipermail/u-boot/2016-June/258873.html Possibly the change to bootm.c should be in a separate patch? arch/arm/lib/bootm.c | 15 ++++++++++----- board/armltd/vexpress/Makefile | 1 + board/armltd/vexpress/vexpress_tc2.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 board/armltd/vexpress/vexpress_tc2.c -- 2.1.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot Reviewed-by: Ryan Harkin Tested-by: Ryan Harkin diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 0838d89..766a0c8 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -248,15 +248,20 @@ static void boot_prep_linux(bootm_headers_t *images) } } -#ifdef CONFIG_ARMV7_NONSEC -bool armv7_boot_nonsec(void) +__weak bool armv7_boot_nonsec_default(void) { - char *s = getenv("bootm_boot_mode"); #ifdef CONFIG_ARMV7_BOOT_SEC_DEFAULT - bool nonsec = false; + return false; #else - bool nonsec = true; + return true; #endif +} + +#ifdef CONFIG_ARMV7_NONSEC +bool armv7_boot_nonsec(void) +{ + char *s = getenv("bootm_boot_mode"); + bool nonsec = armv7_boot_nonsec_default(); if (s && !strcmp(s, "sec")) nonsec = false; diff --git a/board/armltd/vexpress/Makefile b/board/armltd/vexpress/Makefile index 1dd6780..95f4ec0 100644 --- a/board/armltd/vexpress/Makefile +++ b/board/armltd/vexpress/Makefile @@ -6,3 +6,4 @@ # obj-y := vexpress_common.o +obj-$(CONFIG_TARGET_VEXPRESS_CA15_TC2) += vexpress_tc2.o diff --git a/board/armltd/vexpress/vexpress_tc2.c b/board/armltd/vexpress/vexpress_tc2.c new file mode 100644 index 0000000..f00a83c --- /dev/null +++ b/board/armltd/vexpress/vexpress_tc2.c @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2016 Linaro + * Jon Medhurst + * + * TC2 specific code for Versatile Express. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +#define SCC_BASE 0x7fff0000 + +bool armv7_boot_nonsec_default(void) +{ +#ifdef CONFIG_ARMV7_BOOT_SEC_DEFAULT + return false +#else + /* + * The Serial Configuration Controller (SCC) register at address 0x700 + * contains flags for configuring the behaviour of the Boot Monitor + * (which CPUs execute from reset). Two of these bits are of interest: + * + * bit 12 = Use per-cpu mailboxes for power management + * bit 13 = Power down the non-boot cluster + * + * It is only when both of these are false that U-Boot's current + * implementation of 'nonsec' mode can work as expected because we + * rely on getting all CPUs to execute _nonsec_init, so let's check that. + */ + return (readl((u32 *)(SCC_BASE + 0x700)) & ((1 << 12) | (1 << 13))) == 0; +#endif +}