From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Fri, 16 Dec 2011 16:37:11 +0100 Subject: [U-Boot] [PATCH V11 11/13] TI: SPL: make SPL available for other SOCs as TI 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> Message-ID: <1324049833-18143-12-git-send-email-sbabic@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@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 + -- 1.7.5.4