From patchwork Fri Jun 1 14:30:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar Lad X-Patchwork-Id: 162580 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 F3E51B6FA5 for ; Mon, 4 Jun 2012 03:45:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E5299280BC; Sun, 3 Jun 2012 19:44:53 +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 vbYT9aoFYa-6; Sun, 3 Jun 2012 19:44:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DEBEA280C7; Sun, 3 Jun 2012 19:44:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 07F7828191 for ; Fri, 1 Jun 2012 16:33:12 +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 w1k42cEHVoyX for ; Fri, 1 Jun 2012 16:33:11 +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 bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by theia.denx.de (Postfix) with ESMTPS id 3006E28199 for ; Fri, 1 Jun 2012 16:33:09 +0200 (CEST) Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q51EX6iZ013093 for ; Fri, 1 Jun 2012 09:33:07 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q51EX5ui004431 for ; Fri, 1 Jun 2012 20:03:06 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Fri, 1 Jun 2012 20:03:05 +0530 Received: from psplinux051 (psplinux051.india.ti.com [172.24.162.244]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id q51EX5HK015359; Fri, 1 Jun 2012 20:03:05 +0530 (IST) Received: from x0144960 by psplinux051 with local (Exim 4.74) (envelope-from ) id 1SaSuX-0006Cv-01; Fri, 01 Jun 2012 20:03:04 +0530 From: Prabhakar Lad To: Date: Fri, 1 Jun 2012 20:00:45 +0530 Message-ID: <1338561049-23627-4-git-send-email-prabhakar.lad@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1338561049-23627-1-git-send-email-prabhakar.lad@ti.com> References: <1338561049-23627-1-git-send-email-prabhakar.lad@ti.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 03 Jun 2012 19:43:52 +0200 Cc: Tom Rini , "Rajashekhara, Sudhakar" Subject: [U-Boot] [PATCH 3/7] da850/omap-l138: Add support to read u-boot image from MMC/SD X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Lad, Prabhakar DA850/OMAP-L138 does not support strict MMC/SD boot mode. SPL will be in SPI flash and U-Boot image will be in MMC/SD card. SPL will do the low level initialization and then loads the u-boot image from MMC/SD card. Define the CONFIG_SPL_MMC_LOAD macro in the DA850/OMAP-L138 configuration file to enable this feature. Signed-off-by: Lad, Prabhakar Signed-off-by: Rajashekhara, Sudhakar Signed-off-by: Hadli, Manjunath --- arch/arm/cpu/arm926ejs/davinci/spl.c | 12 ++++++- drivers/mmc/Makefile | 4 ++ drivers/mmc/spl_mmc_load.c | 62 ++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 8 ++++ include/mmc.h | 2 + 5 files changed, 87 insertions(+), 1 deletions(-) create mode 100644 drivers/mmc/spl_mmc_load.c diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index 74632e5..be397ce 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -28,6 +28,11 @@ #include #include #include +#include +#include +#include +#include +#include #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT @@ -91,6 +96,11 @@ void board_init_r(gd_t *id, ulong dummy) gd->have_console = 1; puts("SPI boot...\n"); +#ifdef CONFIG_SPL_MMC_LOAD + spl_mmc_load(); +#else spi_boot(); -#endif +#endif /* CONFIG_SPL_MMC_LOAD */ + +#endif /* CONFIG_SPL_SPI_LOAD */ } diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index c245352..bf4b7d5 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -25,6 +25,10 @@ include $(TOPDIR)/config.mk LIB := $(obj)libmmc.o +ifdef CONFIG_SPL_MMC_LOAD +COBJS-$(CONFIG_SPL_SPI_LOAD) += spl_mmc_load.o +endif + COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o diff --git a/drivers/mmc/spl_mmc_load.c b/drivers/mmc/spl_mmc_load.c new file mode 100644 index 0000000..347dcfe --- /dev/null +++ b/drivers/mmc/spl_mmc_load.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static void mmc_load_image(struct mmc *mmc) +{ + s32 err; + void (*uboot)(void) __noreturn; + + err = mmc->block_dev.block_read(0, CONFIG_SYS_MMC_U_BOOT_OFFS, + CONFIG_SYS_SPI_U_BOOT_SIZE/512, + (u32 *)CONFIG_SYS_TEXT_BASE); + + if (err <= 0) { + printf("spl: error reading image %s, err - %d\n", + "u-boot.img", err); + hang(); + } + uboot = (void *) CONFIG_SYS_TEXT_BASE; + (*uboot)(); +} + +void spl_mmc_load(void) +{ + struct mmc *mmc; + int err; + void (mmc_load_image)(struct mmc *mmc) __noreturn; + + mmc_initialize(gd->bd); + mmc = find_mmc_device(0); + if (!mmc) { + puts("spl: mmc device not found!!\n"); + hang(); + } else { + puts("spl: mmc device found\n"); + } + err = mmc_init(mmc); + if (err) { + printf("spl: mmc init failed: err - %d\n", err); + hang(); + } + mmc_load_image(mmc); +} diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 9301a3b..4da6d24 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -320,6 +320,14 @@ #define CONFIG_GENERIC_MMC #define CONFIG_DAVINCI_MMC +/* Load U-Boot Image From MMC */ +#ifdef CONFIG_SPL_MMC_LOAD +#define CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SPL_FAT_SUPPORT +#define CONFIG_SPL_LIBDISK_SUPPORT +#define CONFIG_SYS_MMC_U_BOOT_OFFS 0x75 +#endif + #ifdef CONFIG_MMC #define CONFIG_DOS_PARTITION #define CONFIG_CMD_EXT2 diff --git a/include/mmc.h b/include/mmc.h index f52df70..282b54d 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -27,6 +27,7 @@ #define _MMC_H_ #include +#include #define SD_VERSION_SD 0x20000 #define SD_VERSION_2 (SD_VERSION_SD | 0x20) @@ -320,6 +321,7 @@ int get_mmc_num(void); int board_mmc_getcd(struct mmc *mmc); int mmc_switch_part(int dev_num, unsigned int part_num); int mmc_getcd(struct mmc *mmc); +void spl_mmc_load(void) __noreturn; #ifdef CONFIG_GENERIC_MMC #define mmc_host_is_spi(mmc) ((mmc)->host_caps & MMC_MODE_SPI)