[U-Boot] [PATCH V12 11/14] TI: SPL: make SPL available for other SOCs as TI

Stefano Babic sbabic at denx.de
Wed Jan 4 09:25:15 CET 2012


The SPL is developped first for TI-OMAPx. The patch
move OMAP specific function into OMAP directory.

Signed-off-by: Stefano Babic <sbabic at denx.de>
CC: Tom Rini <tom.rini at gmail.com>
CC: Wolfgang Denk <wd at denx.de>
CC: Simon Schwarz <simonschwarzcor at gmail.com>
---

V12: replace tab with space defining MMCSD_MODE_UNDEFINED

 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, <www.ti.com>
+ *
+ * Aneesh V <aneesh at ti.com>
+ *
+ * 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 <common.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <asm/arch/sys_proto.h>
+#include <mmc.h>
+#include <nand.h>
+#include <fat.h>
+#include <spl.h>
+#include <version.h>
+#include <asm/omap_common.h>
+#include <asm/arch/mmc_host_def.h>
+
+#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 1f6a3e9..11a6caa 100644
--- a/arch/arm/cpu/armv7/omap3/board.c
+++ b/arch/arm/cpu/armv7/omap3/board.c
@@ -42,6 +42,10 @@
 #include <asm/omap_common.h>
 #include <i2c.h>
 
+#ifdef CONFIG_SPL_BUILD
+#include <spl.h>
+#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 <mmc.h>
 #include <fat.h>
 #include <version.h>
+#include <spl.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
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 <mmc.h>
 #include <fat.h>
 #include <version.h>
-#include <asm/omap_common.h>
-#include <asm/arch/mmc_host_def.h>
+#include <spl.h>
 
 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 <asm/io.h>
 #include <nand.h>
 #include <version.h>
-#include <asm/omap_common.h>
+#include <spl.h>
 
 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..6ea3823
--- /dev/null
+++ b/include/spl.h
@@ -0,0 +1,68 @@
+/*
+ * (C) Copyright 2011, Stefano Babic <sbabic at denx.de>
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *
+ * Aneesh V <aneesh at ti.com>
+ *
+ * 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



More information about the U-Boot mailing list