From patchwork Fri Dec 16 15:37:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 131857 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 BB2D61007D7 for ; Sat, 17 Dec 2011 02:40:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C448280B7; Fri, 16 Dec 2011 16:39:50 +0100 (CET) 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 egBqCIizEp54; Fri, 16 Dec 2011 16:39:50 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3A3662855C; Fri, 16 Dec 2011 16:39:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5B8D828437 for ; Fri, 16 Dec 2011 16:39:18 +0100 (CET) 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 1kw9C5NXKDGJ for ; Fri, 16 Dec 2011 16:39:17 +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 smtpi3.ngi.it (smtpi3.ngi.it [88.149.128.33]) by theia.denx.de (Postfix) with ESMTP id 8D2CD28488 for ; Fri, 16 Dec 2011 16:38:46 +0100 (CET) Received: from paperina.lan (unknown [88.149.182.160]) by smtpi3.ngi.it (Postfix) with ESMTP id 82D23319471; Fri, 16 Dec 2011 16:38:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by paperina.lan (Postfix) with ESMTP id EE451140A017; Fri, 16 Dec 2011 16:38:17 +0100 (CET) Received: from paperina.lan ([127.0.0.1]) by localhost (paperina.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UDtlGCS8rHzr; Fri, 16 Dec 2011 16:38:06 +0100 (CET) Received: from papero.lan (papero.lan [192.168.2.247]) by paperina.lan (Postfix) with ESMTP id 84736140A12F; Fri, 16 Dec 2011 16:37:17 +0100 (CET) From: Stefano Babic To: u-boot@lists.denx.de Date: Fri, 16 Dec 2011 16:37:11 +0100 Message-Id: <1324049833-18143-12-git-send-email-sbabic@denx.de> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1324049833-18143-1-git-send-email-sbabic@denx.de> References: <1313073896-12952-1-git-send-email-simonschwarzcor@gmail.com> <1324049833-18143-1-git-send-email-sbabic@denx.de> Subject: [U-Boot] [PATCH V11 11/13] TI: SPL: make SPL available for other SOCs as TI 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The SPL is developped first for TI-OMAPx. The patch move OMAP specific function into OMAP directory. Signed-off-by: Stefano Babic CC: Tom Rini CC: Wolfgang Denk CC: Simon Schwarz --- arch/arm/cpu/armv7/omap-common/Makefile | 2 + arch/arm/cpu/armv7/omap-common/spl_omap.c | 71 +++++++++++++++++++++++++++++ arch/arm/cpu/armv7/omap3/board.c | 4 ++ arch/arm/include/asm/omap_common.h | 34 -------------- common/spl.c | 1 + common/spl_mmc.c | 21 ++------- common/spl_nand.c | 14 +----- include/spl.h | 68 +++++++++++++++++++++++++++ 8 files changed, 153 insertions(+), 62 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_omap.c create mode 100644 include/spl.h diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index e65e992..6fb544c 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -44,6 +44,8 @@ ifndef CONFIG_SPL_BUILD ifneq ($(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) COBJS += mem-common.o endif +else +COBJS += spl_omap.o endif SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/arch/arm/cpu/armv7/omap-common/spl_omap.c b/arch/arm/cpu/armv7/omap-common/spl_omap.c new file mode 100644 index 0000000..692d8c2 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_omap.c @@ -0,0 +1,71 @@ +/* + * (C) Copyright 2010 + * Texas Instruments, + * + * Aneesh V + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_GENERIC_MMC +int board_mmc_init(bd_t *bis) +{ + switch (omap_boot_device()) { + case BOOT_DEVICE_MMC1: + omap_mmc_init(0); + break; + case BOOT_DEVICE_MMC2: + omap_mmc_init(1); + break; + } + return 0; +} +#endif + +#ifdef CONFIG_SPL_NAND_SUPPORT +void spl_arch_nand_init(void) +{ + switch (omap_boot_mode()) { + case NAND_MODE_HW_ECC: + debug("spl: nand - using hw ecc\n"); + gpmc_init(); + nand_init(); + break; + default: + puts("spl: ERROR: This bootmode is not implemented - hanging"); + hang(); + } +} +#endif + +u32 spl_boot_mode(void) +{ + return omap_boot_mode(); +} diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 889d650..f06d614 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -42,6 +42,10 @@ #include #include +#ifdef CONFIG_SPL_BUILD +#include +#endif + /* Declarations */ extern omap3_sysinfo sysinfo; static void omap3_setup_aux_cr(void); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 8a7d1e5..e46e612 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -64,43 +64,9 @@ void preloader_console_init(void); #define BOOT_DEVICE_XIPWAIT 7 #endif -/* Boot type */ -#define MMCSD_MODE_UNDEFINED 0 -#define MMCSD_MODE_RAW 1 -#define MMCSD_MODE_FAT 2 -#define NAND_MODE_HW_ECC 3 - -struct spl_image_info { - const char *name; - u8 os; - u32 load_addr; - u32 entry_point; - u32 size; -}; - -extern struct spl_image_info spl_image; - -extern u32* boot_params_ptr; u32 omap_boot_device(void); u32 omap_boot_mode(void); -/* SPL common function s*/ -void spl_parse_image_header(const struct image_header *header); -void omap_rev_string(char *omap_rev_string); -int spl_uboot_key(void); -void spl_board_prepare_for_linux(void); -int spl_start_uboot(void); - -/* NAND SPL functions */ -void spl_nand_load_image(void); - -/* MMC SPL functions */ -void spl_mmc_load_image(void); - -#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void); -#endif - /* * silicon revisions. * Moving this to common, so that most of code can be moved to common, diff --git a/common/spl.c b/common/spl.c index 1671a03..5fdf3fb 100644 --- a/common/spl.c +++ b/common/spl.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/common/spl_mmc.c b/common/spl_mmc.c index 6f5b43e..9c0086c 100644 --- a/common/spl_mmc.c +++ b/common/spl_mmc.c @@ -29,25 +29,12 @@ #include #include #include -#include -#include +#include DECLARE_GLOBAL_DATA_PTR; -#ifdef CONFIG_GENERIC_MMC -int board_mmc_init(bd_t *bis) -{ - switch (omap_boot_device()) { - case BOOT_DEVICE_MMC1: - omap_mmc_init(0); - break; - case BOOT_DEVICE_MMC2: - omap_mmc_init(1); - break; - } - return 0; -} -#endif +/* Define the sector size, this is usually 512 bytes */ +#define MMCSD_SECTOR_SIZE 512 static void mmc_load_image_raw(struct mmc *mmc) { @@ -135,7 +122,7 @@ void spl_mmc_load_image(void) printf("spl: mmc init failed: err - %d\n", err); hang(); } - boot_mode = omap_boot_mode(); + boot_mode = spl_boot_mode(); if (boot_mode == MMCSD_MODE_RAW) { debug("boot mode - RAW\n"); mmc_load_image_raw(mmc); diff --git a/common/spl_nand.c b/common/spl_nand.c index 1295e88..1adaf03 100644 --- a/common/spl_nand.c +++ b/common/spl_nand.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include void spl_nand_load_image(void) { @@ -35,16 +35,8 @@ void spl_nand_load_image(void) int *src __attribute__((unused)); int *dst __attribute__((unused)); - switch (omap_boot_mode()) { - case NAND_MODE_HW_ECC: - debug("spl: nand - using hw ecc\n"); - gpmc_init(); - nand_init(); - break; - default: - puts("spl: ERROR: This bootmode is not implemented - hanging"); - hang(); - } + /* Call the architecture NAND init function */ + spl_arch_nand_init(); /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); diff --git a/include/spl.h b/include/spl.h new file mode 100644 index 0000000..af16163 --- /dev/null +++ b/include/spl.h @@ -0,0 +1,68 @@ +/* + * (C) Copyright 2011, Stefano Babic + * + * (C) Copyright 2010 + * Texas Instruments, + * + * Aneesh V + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _SPL_COMMON_H_ +#define _SPL_COMMON_H_ + +/* Boot type */ +#define MMCSD_MODE_UNDEFINED 0 +#define MMCSD_MODE_RAW 1 +#define MMCSD_MODE_FAT 2 +#define NAND_MODE_HW_ECC 3 + +struct spl_image_info { + const char *name; + u8 os; + u32 load_addr; + u32 entry_point; + u32 size; +}; + +extern struct spl_image_info spl_image; + +extern u32 *boot_params_ptr; + +/* SPL common function s*/ +void spl_parse_image_header(const struct image_header *header); +void omap_rev_string(char *omap_rev_string); +int spl_uboot_key(void); +void spl_board_prepare_for_linux(void); +int spl_start_uboot(void); +u32 spl_boot_mode(void); + +/* NAND SPL functions */ +void spl_nand_load_image(void); +void spl_arch_nand_init(void); + +/* MMC SPL functions */ +void spl_mmc_load_image(void); + +#ifdef CONFIG_SPL_BOARD_INIT +void spl_board_init(void); +#endif + +#endif +