From patchwork Sat Nov 8 22:14:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 408485 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 DEF3D140082 for ; Sun, 9 Nov 2014 09:15:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A036D4B858; Sat, 8 Nov 2014 23:15:43 +0100 (CET) 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 70ITTVPZH16t; Sat, 8 Nov 2014 23:15:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EDDB74B859; Sat, 8 Nov 2014 23:15:42 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8536C4B85E for ; Sat, 8 Nov 2014 23:15:38 +0100 (CET) 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 pb4PQxcdPpN9 for ; Sat, 8 Nov 2014 23:15:38 +0100 (CET) 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 560034B858 for ; Sat, 8 Nov 2014 23:15:36 +0100 (CET) Received: by gagarine.paulk.fr (Postfix, from userid 65534) id 098FA47D05; Sat, 8 Nov 2014 23:15:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on gagarine.paulk.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=RDNS_NONE, TO_NO_BRKTS_NORDNS autolearn=no version=3.3.2 Received: from armstrong.paulk.fr (armstrong.paulk.fr [82.233.88.171]) by gagarine.paulk.fr (Postfix) with ESMTPS id BC1F847D03; Sat, 8 Nov 2014 23:15:10 +0100 (CET) Received: from aldrin.trisquel.info (unknown [192.168.0.1]) by armstrong.paulk.fr (Postfix) with ESMTP id 729D937647; Sat, 8 Nov 2014 23:15:09 +0100 (CET) From: Paul Kocialkowski To: u-boot@lists.denx.de Date: Sat, 8 Nov 2014 23:14:56 +0100 Message-Id: <1415484896-28928-3-git-send-email-contact@paulk.fr> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415484896-28928-1-git-send-email-contact@paulk.fr> References: <1415484896-28928-1-git-send-email-contact@paulk.fr> Cc: Tom Rini Subject: [U-Boot] [PATCH 2/2] spl: MMC U-Boot image load from raw partition X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Raw images of U-Boot can be stored inside MMC partitions, so it makes sense to read the partition table, looking for a partition number instead of using a fixed sector address. Signed-off-by: Paul Kocialkowski Reviewed-by: Tom Rini --- README | 4 ++++ common/spl/spl_mmc.c | 26 +++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README b/README index 0b5fad9..5444b2e 100644 --- a/README +++ b/README @@ -3550,6 +3550,10 @@ FIT uImage format: Address and partition on the MMC to load U-Boot from when the MMC is being used in raw mode. + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION + Partition on the MMC to load U-Boot from when the MMC is being + used in raw mode + CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR Sector to load kernel uImage from when MMC is being used in raw mode (for Falcon mode) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index f9c3851..31ddcdc 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -15,7 +15,7 @@ DECLARE_GLOBAL_DATA_PTR; -static int mmc_load_image_raw(struct mmc *mmc, unsigned long sector) +static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector) { unsigned long err; u32 image_size_sectors; @@ -51,6 +51,20 @@ end: return (err == 0); } +static int mmc_load_image_raw_partition(struct mmc *mmc, int partition) +{ + disk_partition_t info; + + if (get_partition_info(&mmc->block_dev, partition, &info)) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + printf("spl: partition error\n"); +#endif + return -1; + } + + return mmc_load_image_raw_sector(mmc, info.start); +} + #ifdef CONFIG_SPL_OS_BOOT static int mmc_load_image_raw_os(struct mmc *mmc) { @@ -64,7 +78,8 @@ static int mmc_load_image_raw_os(struct mmc *mmc) return -1; } - return mmc_load_image_raw(mmc, CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR); + return mmc_load_image_raw_sector(mmc, + CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR); } #endif @@ -98,8 +113,13 @@ void spl_mmc_load_image(void) #ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || mmc_load_image_raw_os(mmc)) #endif - err = mmc_load_image_raw(mmc, +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION + err = mmc_load_image_raw_partition(mmc, + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION); +#else + err = mmc_load_image_raw_sector(mmc, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); +#endif #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) } else if (boot_mode == MMCSD_MODE_FS) { debug("boot mode - FS\n");