From patchwork Tue Aug 2 15:59:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Schwarz X-Patchwork-Id: 107966 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 7953DB71C0 for ; Wed, 3 Aug 2011 02:00:15 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4DD08282B5; Tue, 2 Aug 2011 18:00:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 w92EilH3BMGn; Tue, 2 Aug 2011 18:00:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F97E282DF; Tue, 2 Aug 2011 17:59:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0F25B282AC for ; Tue, 2 Aug 2011 17:59:44 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 5z1NQpd2MdAo for ; Tue, 2 Aug 2011 17:59:41 +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 mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by theia.denx.de (Postfix) with ESMTPS id 52124282C7 for ; Tue, 2 Aug 2011 17:59:38 +0200 (CEST) Received: by mail-fx0-f44.google.com with SMTP id 6so6147198fxe.3 for ; Tue, 02 Aug 2011 08:59:38 -0700 (PDT) Received: by 10.223.54.20 with SMTP id o20mr8276447fag.27.1312300778101; Tue, 02 Aug 2011 08:59:38 -0700 (PDT) Received: from localhost.localdomain (DSL01.212.114.252.242.ip-pool.NEFkom.net [212.114.252.242]) by mx.google.com with ESMTPS id y15sm3528024fah.11.2011.08.02.08.59.35 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Aug 2011 08:59:36 -0700 (PDT) From: Simon Schwarz To: u-boot@lists.denx.de Date: Tue, 2 Aug 2011 17:59:11 +0200 Message-Id: <1312300757-9039-4-git-send-email-simonschwarzcor@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312300757-9039-1-git-send-email-simonschwarzcor@gmail.com> References: <1311958421-9607-1-git-send-email-simonschwarzcor@gmail.com> <1312300757-9039-1-git-send-email-simonschwarzcor@gmail.com> Organization: Corscience GmbH & Co. KG Cc: scottwood@freescale.com Subject: [U-Boot] [PATCH V8 3/9] omap-common: add nand spl support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Add NAND support for the new SPL structure. Signed-off-by: Simon Schwarz --- This patch didn't exist before V2! V2 changes: ADD Some define-barriers for OMAP3 to only use NAND ADD nand_load_image() - inits the OMAP gpmc, loads the images - parses the header CHG cosmetic ADD do_reset() implementation for omap-common spl ADD nand_copy_image to nand.h ADD CPP barriers for mmc and nand support. The parts depending on library support are only compiled if the respective library is included. V3 changes: ADD Comment why setup_clocks_for_console() isn't called for OMAP3 CHG cosmetic (deleted empty line) CHG rename of NAND_MODE_HW to NAND_MODE_HW_ECC DEL NAND_MODE_SW. Not used. V4 changes: CHG cosmetic - style problems V5 changes: CHG renamed nand_copy_image to nand_spl_load_image CHG offs paramter of nand_spl_load_image is of type loff_t now V6 changes: ADD call to nand_deselect after loading the images ADD nand_deselect to nand.h V7 changes: DEL some CONFIG_SPL_* relying on garbage collection now ADD mmc_load_image and nand_load_image now have __attribute__((unused)) to prevent warnings when the lib is not added to SPL DEL do_reset() isn't used anymore CHG header based loading in SPL V8 changes: DEL nand_spl_read_page is replaced by nand_spl_load_image with size=page size Transition from V1 to V2 also includes that this patch is now based on - the new SPL layout by Aneesh V and Daniel Schwierzeck - the OMAP4 SPL patches by Aneesh V --- arch/arm/cpu/armv7/omap-common/spl.c | 46 +++++++++++++++++++++++++++++++++- arch/arm/include/asm/omap_common.h | 1 + include/nand.h | 3 ++ 3 files changed, 49 insertions(+), 1 deletions(-) diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 1d301f4..53d10bf 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -173,7 +174,7 @@ end: hang(); } } - +static void mmc_load_image(void) __attribute__((unused)); static void mmc_load_image(void) { struct mmc *mmc; @@ -207,12 +208,48 @@ static void mmc_load_image(void) } } +#ifdef CONFIG_SPL_NAND_SUPPORT +static void nand_load_image(void) __attribute__ ((unused)); +static void nand_load_image(void) +{ + struct image_header *header; + + gpmc_init(); + nand_init(); + + /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); + +#ifdef CONFIG_NAND_ENV_DST + nand_spl_load_image(CONFIG_ENV_OFFSET, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + parse_image_header(header); + nand_spl_load_image(CONFIG_ENV_OFFSET, image_size, + (void *)image_load_addr); +#ifdef CONFIG_ENV_OFFSET_REDUND + nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + parse_image_header(header); + nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, image_size, + (void *)image_load_addr); +#endif +#endif + /* Load u-boot */ + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + parse_image_header(header); + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + image_size, (void *)image_load_addr); + nand_deselect(); +} +#endif /* CONFIG_SPL_NAND_SUPPORT */ void jump_to_image_no_args(void) { typedef void (*image_entry_noargs_t)(void)__attribute__ ((noreturn)); image_entry_noargs_t image_entry = (image_entry_noargs_t) image_entry_point; + debug("image entry point: 0x%X\n", image_entry_point); image_entry(); } @@ -228,10 +265,17 @@ void board_init_r(gd_t *id, ulong dummy) boot_device = omap_boot_device(); debug("boot device - %d\n", boot_device); switch (boot_device) { +#ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: mmc_load_image(); break; +#endif +#ifdef CONFIG_SPL_NAND_SUPPORT + case BOOT_DEVICE_NAND: + nand_load_image(); + break; +#endif default: printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); hang(); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index d3cb857..13f6884 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -49,6 +49,7 @@ void preloader_console_init(void); #define MMCSD_MODE_UNDEFINED 0 #define MMCSD_MODE_RAW 1 #define MMCSD_MODE_FAT 2 +#define NAND_MODE_HW_ECC 3 u32 omap_boot_device(void); u32 omap_boot_mode(void); diff --git a/include/nand.h b/include/nand.h index 8d94b5c..3c5ef4e 100644 --- a/include/nand.h +++ b/include/nand.h @@ -132,6 +132,9 @@ int nand_lock( nand_info_t *meminfo, int tight ); int nand_unlock( nand_info_t *meminfo, ulong start, ulong length ); int nand_get_lock_status(nand_info_t *meminfo, loff_t offset); +void nand_spl_load_image(loff_t offs, unsigned int size, uchar *dst); +void nand_deselect(void); + #ifdef CONFIG_SYS_NAND_SELECT_DEVICE void board_nand_select_device(struct nand_chip *nand, int chip); #endif