From patchwork Thu Oct 22 12:01:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 534379 X-Patchwork-Delegate: trini@ti.com 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 3073E14131F for ; Thu, 22 Oct 2015 23:02:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=compulab.co.il header.i=@compulab.co.il header.b=FHIWSJxZ; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 68AB8A747F; Thu, 22 Oct 2015 14:02: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 6FFiTtiskvtg; Thu, 22 Oct 2015 14:02:09 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 83F7CA7486; Thu, 22 Oct 2015 14:01:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 51AAE4B894 for ; Thu, 22 Oct 2015 14:01:31 +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 7Twi05ql5AyV for ; Thu, 22 Oct 2015 14:01:31 +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 compulab.co.il (softlayer.compulab.co.il [50.23.254.55]) by theia.denx.de (Postfix) with ESMTPS id 2D5954B899 for ; Thu, 22 Oct 2015 14:01:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=compulab.co.il; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From; bh=cwcZejj/BX+uQ547Msa6cvMZaTLehWDiel8jeHG91IM=; b=FHIWSJxZrX4aP +ACIyVZpCKscfUZQchrvXyyKH12IlUbo8asDtEsEdjNik8Apx7nKBeZ0teO1cTZODCLbVCNU1c7PS 7hKYEV7DxYlyy5D5fkwm7N2+RWpg8Vomtl7JEGTj8UrwRySJCxfMGfehU8jUJx2xyLSPGe8wIhzJo iwpE=; Received: from [62.90.235.247] (port=45950 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.86) (envelope-from ) id 1ZpEYh-0001jT-0C; Thu, 22 Oct 2015 15:01:27 +0300 Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 8FA8B48D59C; Thu, 22 Oct 2015 15:01:25 +0300 (IDT) Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id FeiXyXdMZ9VE; Thu, 22 Oct 2015 15:01:25 +0300 (IDT) Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 3396D48D529; Thu, 22 Oct 2015 15:01:24 +0300 (IDT) X-Virus-Scanned: amavisd-new at zimbra-mta.compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pXX6KA2PXafG; Thu, 22 Oct 2015 15:01:24 +0300 (IDT) Received: from skynet.compulab.local (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id F374B48D54E; Thu, 22 Oct 2015 15:01:23 +0300 (IDT) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Thu, 22 Oct 2015 15:01:17 +0300 Message-Id: <1445515280-21389-10-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445515280-21389-1-git-send-email-nikita@compulab.co.il> References: <1445515280-21389-1-git-send-email-nikita@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_recent_authed_mail_ips_text_entry: nikita@compulab.co.il|compulab.co.il X-Authenticated-Sender: softlayer.compulab.co.il: nikita@compulab.co.il Cc: Tom Rini Subject: [U-Boot] [PATCH 09/12] common: spl: move image load to its own function 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" Refactor spl image load code out of board_init_r and into its own function. This is a preparation for supporting alternative boot devices. Signed-off-by: Nikita Kiryanov Cc: Igor Grinberg Cc: Tom Rini Cc: Simon Glass --- common/spl/spl.c | 117 ++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 67 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index ff1bad2..56fccca 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -178,122 +178,105 @@ int spl_init(void) return 0; } -void board_init_r(gd_t *dummy1, ulong dummy2) +static int spl_load_image(u32 boot_device) { - u32 boot_device; - - debug(">>spl:board_init_r()\n"); - -#if defined(CONFIG_SYS_SPL_MALLOC_START) - mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, - CONFIG_SYS_SPL_MALLOC_SIZE); - gd->flags |= GD_FLG_FULL_MALLOC_INIT; -#endif - if (!(gd->flags & GD_FLG_SPL_INIT)) { - if (spl_init()) - hang(); - } -#ifndef CONFIG_PPC - /* - * timer_init() does not exist on PPC systems. The timer is initialized - * and enabled (decrementer) in interrupt_init() here. - */ - timer_init(); -#endif - -#ifdef CONFIG_SPL_BOARD_INIT - spl_board_init(); -#endif - - boot_device = spl_boot_device(); - debug("boot device - %d\n", boot_device); switch (boot_device) { #ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM: - if (spl_ram_load_image()) - hang(); - break; + return spl_ram_load_image(); #endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: case BOOT_DEVICE_MMC2_2: - if (spl_mmc_load_image()) - hang(); - break; + return spl_mmc_load_image(); #endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND: - if (spl_nand_load_image()) - hang(); - break; + return spl_nand_load_image(); #endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND: - if (spl_onenand_load_image()) - hang(); - break; + return spl_onenand_load_image(); #endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR: - if (spl_nor_load_image()) - hang(); - break; + return spl_nor_load_image(); #endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART: - if (spl_ymodem_load_image()) - hang(); - break; + return spl_ymodem_load_image(); #endif #ifdef CONFIG_SPL_SPI_SUPPORT case BOOT_DEVICE_SPI: - if (spl_spi_load_image()) - hang(); - break; + return spl_spi_load_image(); #endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC: #ifdef CONFIG_SPL_ETH_DEVICE - if (spl_net_load_image(CONFIG_SPL_ETH_DEVICE)) - hang(); + return spl_net_load_image(CONFIG_SPL_ETH_DEVICE); #else - if (spl_net_load_image(NULL)) - hang(); + return spl_net_load_image(NULL); #endif - break; #endif #ifdef CONFIG_SPL_USBETH_SUPPORT case BOOT_DEVICE_USBETH: - if (spl_net_load_image("usb_ether")) - hang(); - break; + return spl_net_load_image("usb_ether"); #endif #ifdef CONFIG_SPL_USB_SUPPORT case BOOT_DEVICE_USB: - if (spl_usb_load_image()) - hang(); - break; + return spl_usb_load_image(); #endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA: - if (spl_sata_load_image()) - hang(); - break; + return spl_sata_load_image(); #endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD: - if (spl_board_load_image()) - hang(); - break; + return spl_board_load_image(); #endif default: #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT) puts("SPL: Unsupported Boot Device!\n"); #endif - hang(); + return -ENODEV; } + return -EINVAL; +} + +void board_init_r(gd_t *dummy1, ulong dummy2) +{ + u32 boot_device; + + debug(">>spl:board_init_r()\n"); + +#if defined(CONFIG_SYS_SPL_MALLOC_START) + mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, + CONFIG_SYS_SPL_MALLOC_SIZE); + gd->flags |= GD_FLG_FULL_MALLOC_INIT; +#endif + if (!(gd->flags & GD_FLG_SPL_INIT)) { + if (spl_init()) + hang(); + } +#ifndef CONFIG_PPC + /* + * timer_init() does not exist on PPC systems. The timer is initialized + * and enabled (decrementer) in interrupt_init() here. + */ + timer_init(); +#endif + +#ifdef CONFIG_SPL_BOARD_INIT + spl_board_init(); +#endif + + boot_device = spl_boot_device(); + debug("boot device - %d\n", boot_device); + if (spl_load_image(boot_device)) + hang(); + switch (spl_image.os) { case IH_OS_U_BOOT: debug("Jumping to U-Boot\n");