From patchwork Wed May 4 12:04:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 618405 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 3r0H0P6Qkyz9sBl for ; Wed, 4 May 2016 22:09:41 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C08F3A7841; Wed, 4 May 2016 14:09:28 +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 n1AcXRT4YHp9; Wed, 4 May 2016 14:09:28 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 807A4A783B; Wed, 4 May 2016 14:09:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC7A2A77FC for ; Wed, 4 May 2016 14:09:22 +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 lQ1k6kfNc5rg for ; Wed, 4 May 2016 14:09:22 +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 arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id C84A0A77F8 for ; Wed, 4 May 2016 14:09:13 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u44C9BW6022665; Wed, 4 May 2016 07:09:11 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u44C9BQH007557; Wed, 4 May 2016 07:09:11 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Wed, 4 May 2016 07:09:10 -0500 Received: from a0131933.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u44C8kjr029649; Wed, 4 May 2016 07:09:06 -0500 From: Lokesh Vutla To: , , Date: Wed, 4 May 2016 17:34:37 +0530 Message-ID: <1462363477-20445-4-git-send-email-lokeshvutla@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462363477-20445-1-git-send-email-lokeshvutla@ti.com> References: <1462363477-20445-1-git-send-email-lokeshvutla@ti.com> MIME-Version: 1.0 Cc: Tero Kristo , Sekhar Nori , michal.simek@xilinx.com Subject: [U-Boot] [PATCH v5 3/3] spl: Support loading a FIT from FAT FS 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" Detect a FIT when loading from a FAT File system and handle it using the new FIT SPL support. Signed-off-by: Lokesh Vutla Tested-by: Michal Simek Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- common/spl/spl_fat.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index d761b26..cdb9811 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -15,6 +15,7 @@ #include #include #include +#include static int fat_registered; @@ -39,6 +40,20 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition) return err; } +static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset, + ulong size, void *buf) +{ + loff_t actread; + int ret; + char *filename = (char *)load->priv; + + ret = fat_read_file(filename, buf, file_offset, size, &actread); + if (ret) + return ret; + + return actread; +} + int spl_load_image_fat(struct blk_desc *block_dev, int partition, const char *filename) @@ -57,9 +72,21 @@ int spl_load_image_fat(struct blk_desc *block_dev, if (err <= 0) goto end; - spl_parse_image_header(header); + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && + image_get_magic(header) == FDT_MAGIC) { + struct spl_load_info load; + + debug("Found FIT\n"); + load.read = spl_fit_read; + load.bl_len = 1; + load.priv = (void *)filename; - err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0); + return spl_load_simple_fit(&load, 0, header); + } else { + spl_parse_image_header(header); + + err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0); + } end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT