From patchwork Mon Jun 8 21:24:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 482013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5AE18140213 for ; Tue, 9 Jun 2015 07:25:49 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DB75D4B6F3; Mon, 8 Jun 2015 23:25:36 +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 RWa9-tY46Arm; Mon, 8 Jun 2015 23:25:36 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 088F64B70B; Mon, 8 Jun 2015 23:25:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 643BE4B6A2 for ; Mon, 8 Jun 2015 23:25:30 +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 hlzkK_FAaXQk for ; Mon, 8 Jun 2015 23:25:30 +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 gagarine.paulk.fr (gagarine.paulk.fr [109.190.93.129]) by theia.denx.de (Postfix) with ESMTPS id 12D914B67B for ; Mon, 8 Jun 2015 23:25:28 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 65534) id 86B211FE4F; Mon, 8 Jun 2015 23:25:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on gagarine.paulk.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=RDNS_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from armstrong.paulk.fr (armstrong.paulk.fr [82.233.88.171]) by gagarine.paulk.fr (Postfix) with ESMTPS id 2103B1FE5F; Mon, 8 Jun 2015 23:24:40 +0200 (CEST) Received: from localhost.localdomain (unknown [192.168.0.2]) by armstrong.paulk.fr (Postfix) with ESMTP id 3B66037862; Mon, 8 Jun 2015 23:24:38 +0200 (CEST) From: Paul Kocialkowski To: u-boot@lists.denx.de Date: Mon, 8 Jun 2015 23:24:23 +0200 Message-Id: <1433798667-9171-6-git-send-email-contact@paulk.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433798667-9171-1-git-send-email-contact@paulk.fr> References: <1433351007-1704-2-git-send-email-contact@paulk.fr> <1433798667-9171-1-git-send-email-contact@paulk.fr> Cc: Marek Vasut , Tom Rini , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [U-Boot] [PATCH v2 5/8] omap-common: SYS_BOOT-based fallback boot device selection for peripheral boot 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" OMAP devices might boot from peripheral devices, such as UART or USB. When that happens, the U-Boot SPL tries to boot the next stage (complete U-Boot) from that peripheral device, but in most cases, this is not a valid boot device. This introduces a fallback option that reads the SYS_BOOT pins, that are used by the bootrom to determine which device to boot from. It is intended for the SYS_BOOT value to be interpreted in the memory-preferred scheme, so that the U-Boot SPL can load the next stage from a valid location. Practically, this options allows loading the U-Boot SPL through USB and have it load the next stage according to the memory device selected by SYS_BOOT instead of stalling. Signed-off-by: Paul Kocialkowski --- arch/arm/cpu/armv7/omap-common/boot-common.c | 51 ++++++++++++++++++++++++---- arch/arm/include/asm/omap_common.h | 4 +++ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 944b6e4..8a7df89 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -21,6 +21,11 @@ DECLARE_GLOBAL_DATA_PTR; +__weak u32 omap_sys_boot_device(void) +{ + return BOOT_DEVICE_NONE; +} + void save_omap_boot_params(void) { u32 boot_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS); @@ -34,9 +39,10 @@ void save_omap_boot_params(void) omap_boot_params = (struct omap_boot_parameters *)boot_params; - /* Boot device */ - boot_device = omap_boot_params->boot_device; + boot_mode = MMCSD_MODE_UNDEFINED; + + /* Boot device */ #ifdef BOOT_DEVICE_NAND_I2C /* @@ -58,16 +64,38 @@ void save_omap_boot_params(void) if (boot_device == BOOT_DEVICE_QSPI_4) boot_device = BOOT_DEVICE_SPI; #endif +#if (defined(BOOT_DEVICE_UART) && !defined(CONFIG_SPL_YMODEM_SUPPORT)) || \ + (defined(BOOT_DEVICE_USB) && !defined(CONFIG_SPL_USB_SUPPORT)) + /* + * When booting from peripheral booting, the boot device is not usable + * as-is (unless there is support for it), so the boot device is instead + * figured out using the SYS_BOOT pins. + */ + switch (boot_device) { +#ifdef BOOT_DEVICE_UART + case BOOT_DEVICE_UART: +#endif +#ifdef BOOT_DEVICE_USB + case BOOT_DEVICE_USB: +#endif + boot_device = omap_sys_boot_device(); + + /* MMC raw mode will fallback to FS mode. */ + if ((boot_device >= MMC_BOOT_DEVICES_START) && + (boot_device <= MMC_BOOT_DEVICES_END)) + boot_mode = MMCSD_MODE_RAW; + + break; + } +#endif gd->arch.omap_boot_device = boot_device; /* Boot mode */ - boot_mode = MMCSD_MODE_UNDEFINED; - +#ifdef CONFIG_OMAP34XX if ((boot_device >= MMC_BOOT_DEVICES_START) && (boot_device <= MMC_BOOT_DEVICES_END)) { -#ifdef CONFIG_OMAP34XX switch (boot_device) { case BOOT_DEVICE_MMC1: boot_mode = MMCSD_MODE_FS; @@ -76,7 +104,16 @@ void save_omap_boot_params(void) boot_mode = MMCSD_MODE_RAW; break; } + } #else + /* + * If the boot device was dynamically changed and doesn't match what + * the bootrom initially booted, we cannot use the boot device + * descriptor to figure out te boot mode. + */ + if ((boot_device == omap_boot_params->boot_device) && + (boot_device >= MMC_BOOT_DEVICES_START) && + (boot_device <= MMC_BOOT_DEVICES_END)) { boot_params = omap_boot_params->boot_device_descriptor; if ((boot_params < NON_SECURE_SRAM_START) || (boot_params > NON_SECURE_SRAM_END)) @@ -92,12 +129,12 @@ void save_omap_boot_params(void) if (boot_mode != MMCSD_MODE_FS && boot_mode != MMCSD_MODE_RAW) #ifdef CONFIG_SUPPORT_EMMC_BOOT - boot_mode = MMCSD_MODE_EMMCBOOT + boot_mode = MMCSD_MODE_EMMCBOOT; #else boot_mode = MMCSD_MODE_UNDEFINED; #endif -#endif } +#endif gd->arch.omap_boot_mode = boot_mode; diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index e8c502c..7733311 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -682,4 +682,8 @@ static inline u8 is_dra7xx(void) #define CH_FLAGS_CHFLASH (1 << 2) #define CH_FLAGS_CHMMCSD (1 << 3) +#ifndef __ASSEMBLY__ +u32 omap_sys_boot_device(void); +#endif + #endif /* _OMAP_COMMON_H_ */