Skip to contentSkip to conversation

U-Boot MMC SPL for OMAP4

PATCH New Aneesh V 13 participants 244 messages Feb 28, 2011 – Aug 2, 2011 2 messages not in the archive Page 2 of 2

Subsystems (3)
lore
Share & tools
lore
author
#178 lore raw

v3 cover U-Boot MMC SPL for OMAP4

In reply to Aneesh V

Dear Wolfgang,

Quoted 42 lines · Aneesh V

This series adds mmc SPL support for OMAP4. This is essentially an up-streaming effort for TI's x-loader for OMAP4 using the SPL framework

This work partly draws upon previous work done for x-loader by:
Santosh Shilimkar<[email protected]> Rajendra Nayak<[email protected]>
and many others

This series depends on the following series for the new SPL framework:
http://marc.info/?l=u-boot&m=131056990001719&w=2

Features supported:
* Clock init - DPLL locking, clock domains/modules enabling
* SDRAM/DMM initialization
* Mux initialization
* MMC raw read support
* MMC FAT read support

Improvments over x-loader:
* Code completely revamped
* DPLL programming that works for all SYS_CLK frequencies
* Automatic SDRAM identification and initialization
* Board dependent parts(especially mux) deferred to u-boot. So, same SPL will work for Panda and SDP and most likely on any other board that comes along
* Flexible about the payload. Any image with a mkimage header can be loaded.
* The core SPL logic is generic and available for OMAP3/4. So, OMAP3 platforms can easily extend this work to add SPL support for the respective boards.

V2:
* Some fixes in SDRAM init, clock init
* Use of pre-calculated M& N values for DPLL locking instead run-time calculation
* Change in make files to allow reuse of common rules between boards
* Console initialization moved further earlier in the boot allowing traces from even clock initialization code
* Reuse utility macros from a previous series

Quoted 8 lines

V3:
* Moved to the new SPL framework
* struct based register access for clock init
* Squashed together related patches as per Wolfgang's suggestions
* Re-organization of code in sdram init for better readability
* SPL loading the payload using mkimage header
* Avoided using custom bit-field accessor macros
* Several other minor changes(documented in respective patches)

I think I have addressed all the comments you and others had on the previous series and adapted it to the new SPL framework.

There are just two comments for this series so far. I have to omit the 'SYS' from CONFIG_SYS_SPL_TEXT_BASE and a minor comment by Simon.

If I fix these two, is it ready to go. Do you have any other comments. If not, shall I re-spin the next revision?

br,
Aneesh

#179 lore raw

v3 cover U-Boot MMC SPL for OMAP4

Dear Aneesh V,

Quoted 3 lines · In message <[email protected]> you wrote:

I think I have addressed all the comments you and others had on the previous series and adapted it to the new SPL framework.

Yes, I agree.

Quoted 2 lines

There are just two comments for this series so far. I have to omit the 'SYS' from CONFIG_SYS_SPL_TEXT_BASE and a minor comment by Simon.

That's my understanding, too.

Quoted 2 lines

If I fix these two, is it ready to go. Do you have any other comments. If not, shall I re-spin the next revision?

Please feel free to send the next version, without the RFC part in the subject now. If no complaints come in, I want to pull this in soon.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
######## This message was made from 100% recycled electrons. ########
author
#180 lore raw

v3 cover U-Boot MMC SPL for OMAP4

Dear Wolfgang,

Quoted 7 lines · Wolfgang Denk

Dear Aneesh V,

Quoted 3 lines · In message<[email protected]> you wrote:

I think I have addressed all the comments you and others had on the previous series and adapted it to the new SPL framework.

Quoted 6 lines

Yes, I agree.

Quoted 2 lines

There are just two comments for this series so far. I have to omit the 'SYS' from CONFIG_SYS_SPL_TEXT_BASE and a minor comment by Simon.

That's my understanding, too.

One minor question. For the OMAP spl I have some cofig flags like

CONFIG_SYS_SPL_STACK, CONFIG_SYS_SPL_BSS_START_ADDR etc.

Is it ok to omit the 'SYS' part of these too?

Quoted 6 lines
Quoted 3 lines

If I fix these two, is it ready to go. Do you have any other comments. If not, shall I re-spin the next revision?

Please feel free to send the next version, without the RFC part in the subject now. If no complaints come in, I want to pull this in soon.

Thanks. Will send in the next revision soon.

best regards,
Aneesh

#181 lore raw

v3 cover U-Boot MMC SPL for OMAP4

Dear Aneesh V,

Quoted 6 lines · In message <[email protected]> you wrote:

One minor question. For the OMAP spl I have some cofig flags like

CONFIG_SYS_SPL_STACK, CONFIG_SYS_SPL_BSS_START_ADDR etc.

Is it ok to omit the 'SYS' part of these too?

Yes, please. I think we should make this consistently.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When a program is being  tested,  it  is  too  late  to  make  design
changes.                  -- Geoffrey James, "The Tao of Programming"
author
#182 lore raw

PATCH v3 1/12 omap4: utility function to identify the context of hw init

In reply to Aneesh V

The basic hardware init of OMAP4(s_init()) can happen in 4 different contexts:
1. SPL running from SRAM
2. U-Boot running from FLASH
3. Non-XIP U-Boot loaded to SDRAM by SPL
4. Non-XIP U-Boot loaded to SDRAM by ROM code using the Configuration Header feature

What level of hw initialization gets done depends on this context. Add a utility function to find this context.

---
V3:
* Changed the context names to more meaningful names as suggested by WD

---
 arch/arm/include/asm/arch-omap4/sys_proto.h |   49 ++++++++++++++++++++++++++-
 arch/arm/include/asm/omap_common.h          |   34 ++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_common.h
arch/arm/include/asm/arch-omap4/sys_proto.h +48 -1
index 4fa4f4b..6b596b4 100644
@@ -23,10 +23,12 @@
 
 #include <asm/arch/omap4.h>
 #include <asm/io.h>
+#include <asm/omap_common.h>
 
 struct omap_sysinfo {
 	char *board_string;
 };
+extern const struct omap_sysinfo sysinfo;
 
 void gpmc_init(void);
 void watchdog_init(void);
@@ -37,6 +39,51 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 
-extern const struct omap_sysinfo sysinfo;
+static inline u32 running_from_sdram(void)
+{
+	u32 pc;
+	asm volatile ("mov %0, pc" : "=r" (pc));
+	return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
+	    (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
+}
+
+static inline u8 uboot_loaded_by_spl(void)
+{
+	/*
+	 * Configuration Header is not supported yet, so u-boot init running
+	 * from SDRAM implies that it was loaded by SPL. When this situation
+	 * changes one of these approaches could be taken:
+	 * i.  Pass a magic from SPL to U-Boot and U-Boot save it at a known
+	 *     location.
+	 * ii. Check the OPP. CH can support only 50% OPP while SPL initializes
+	 *     the DPLLs@100% OPP.
+	 */
+	return running_from_sdram();
+}
+/*
+ * The basic hardware init of OMAP(s_init()) can happen in 4
+ * different contexts:
+ *  1. SPL running from SRAM
+ *  2. U-Boot running from FLASH
+ *  3. Non-XIP U-Boot loaded to SDRAM by SPL
+ *  4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
+ *     Configuration Header feature
+ *
+ * This function finds this context.
+ * Defining as inline may help in compiling out unused functions in SPL
+ */
+static inline u32 omap4_hw_init_context(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	return OMAP_INIT_CONTEXT_SPL;
+#else
+	if (uboot_loaded_by_spl())
+		return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
+	else if (running_from_sdram())
+		return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
+	else
+		return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
+#endif
+}
 
 #endif
arch/arm/include/asm/omap_common.h new file +34 -0
new file mode 100644
index 0000000..d80f665
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *
+ * Aneesh V <[email protected]>
+ *
+ * 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	_OMAP_COMMON_H_
+#define	_OMAP_COMMON_H_
+
+/* HW Init Context */
+#define OMAP_INIT_CONTEXT_SPL			0
+#define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR	1
+#define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
+#define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
+
+#endif /* _OMAP_COMMON_H_ */
Signature · 1 line
1.7.0.4
author
#183 lore raw

PATCH v3 2/12 omap4: cleanup pin mux data

In reply to Aneesh V

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

---
This patch add 33 warnings for lines over 80 characters. However, this for the mux table and improves readability.

V3:
* Squashed two mux related patches into one

---
 arch/arm/cpu/armv7/omap4/board.c                   |   53 ++++++++-
 arch/arm/cpu/armv7/omap4/omap4_mux_data.h          |   76 ++++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h        |    4 +-
 board/ti/panda/panda.c                             |   25 +---
 board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} |   76 +++---------
 board/ti/sdp4430/sdp.c                             |   25 +---
 .../{panda/panda.h => sdp4430/sdp4430_mux_data.h}  |  128 +++++++------------
 7 files changed, 209 insertions(+), 178 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/omap4_mux_data.h
 rename board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} (76%)
 rename board/ti/{panda/panda.h => sdp4430/sdp4430_mux_data.h} (67%)
arch/arm/cpu/armv7/omap4/board.c +50 -3
index de4cc2a..3fd6f84 100644
@@ -31,17 +31,65 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
+#include "omap4_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+{
+	int i;
+	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
+
+	for (i = 0; i < size; i++, pad++)
+		writew(pad->val, base + pad->offset);
+}
+
+static void set_muxconf_regs_essential(void)
+{
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_essential,
+		   sizeof(core_padconf_array_essential) /
+		   sizeof(struct pad_conf_entry));
+
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_essential,
+		   sizeof(wkup_padconf_array_essential) /
+		   sizeof(struct pad_conf_entry));
+}
+
+static void set_mux_conf_regs(void)
+{
+	switch (omap4_hw_init_context()) {
+	case OMAP_INIT_CONTEXT_SPL:
+		set_muxconf_regs_essential();
+		break;
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL:
+		set_muxconf_regs_non_essential();
+		break;
+	case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
+		set_muxconf_regs_essential();
+		set_muxconf_regs_non_essential();
+		break;
+	}
+}
+
 /*
  * Routine: s_init
- * Description: Does early system init of muxing and clocks.
- *              - Called path is with SRAM stack.
+ * Description: Does early system init of watchdog, muxing,  andclocks
+ * Watchdog disable is done always. For the rest what gets done
+ * depends on the boot mode in which this function is executed
+ *   1. s_init of SPL running from SRAM
+ *   2. s_init of U-Boot running from FLASH
+ *   3. s_init of U-Boot loaded to SDRAM by SPL
+ *   4. s_init of U-Boot loaded to SDRAM by ROM code using the
+ *	Configuration Header feature
+ * Please have a look at the respective functions to see what gets
+ * done in each of these cases
+ * This function is called with SRAM stack.
  */
 void s_init(void)
 {
 	watchdog_init();
+	set_mux_conf_regs();
 }
 
 /*
@@ -124,7 +172,6 @@ int checkboard(void)
 */
 int arch_cpu_init(void)
 {
-	set_muxconf_regs();
 	return 0;
 }
 
arch/arm/cpu/armv7/omap4/omap4_mux_data.h new file +76 -0

76 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/sys_proto.h +3 -1
index 6b596b4..3624378 100644
@@ -24,6 +24,7 @@
 #include <asm/arch/omap4.h>
 #include <asm/io.h>
 #include <asm/omap_common.h>
+#include <asm/arch/mux_omap4.h>
 
 struct omap_sysinfo {
 	char *board_string;
@@ -33,7 +34,8 @@ extern const struct omap_sysinfo sysinfo;
 void gpmc_init(void);
 void watchdog_init(void);
 u32 get_device_type(void);
-void set_muxconf_regs(void);
+void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
+void set_muxconf_regs_non_essential(void);
 void sr32(void *, u32, u32, u32);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
board/ti/panda/panda.c +6 -19
index 78e1910..9afed80 100644
@@ -25,7 +25,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
-#include "panda.h"
+#include "panda_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -65,27 +65,14 @@ int misc_init_r(void)
 	return 0;
 }
 
-void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+void set_muxconf_regs_non_essential(void)
 {
-	int i;
-	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
-
-	for (i = 0; i < size; i++, pad++)
-		writew(pad->val, base + pad->offset);
-}
-
-/**
- * @brief set_muxconf_regs Setting up the configuration Mux registers
- * specific to the board.
- */
-void set_muxconf_regs(void)
-{
-	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array,
-		   sizeof(core_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_non_essential,
+		   sizeof(core_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 
-	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array,
-		   sizeof(wkup_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_non_essential,
+		   sizeof(wkup_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 }
 
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +21 -55

156 lines not on this page · raw message

board/ti/sdp4430/sdp.c +6 -19
index b13c4c5..a5ea682 100644
@@ -27,7 +27,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
-#include "sdp.h"
+#include "sdp4430_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -70,27 +70,14 @@ int misc_init_r(void)
 	return 0;
 }
 
-void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+void set_muxconf_regs_non_essential(void)
 {
-	int i;
-	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
-
-	for (i = 0; i < size; i++, pad++)
-		writew(pad->val, base + pad->offset);
-}
-
-/**
- * @brief set_muxconf_regs Setting up the configuration Mux registers
- * specific to the board.
- */
-void set_muxconf_regs(void)
-{
-	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array,
-		   sizeof(core_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_non_essential,
+		   sizeof(core_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 
-	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array,
-		   sizeof(wkup_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_non_essential,
+		   sizeof(wkup_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 }
 
board/ti/sdp4430/sdp4430_mux_data.h renamed from board/ti/panda/panda.h +47 -81

211 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#184 lore raw

PATCH v3 3/12 omap4: add OMAP4430 revision check

In reply to Aneesh V

---
V2:
* Added a revision string in addition to the revision number Helps in printing out the OMAP revision at bootup

V3:
* Improved the revision check function by saving the value instead of finding it every time.
* Improved revision string function by generating it from the revision rather than hard-coding the string per revision

---
 arch/arm/cpu/armv7/omap4/board.c            |   64 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h     |   29 +++++++++---
 arch/arm/include/asm/arch-omap4/sys_proto.h |    7 +++
 arch/arm/include/asm/armv7.h                |    5 ++
 4 files changed, 97 insertions(+), 8 deletions(-)
arch/arm/cpu/armv7/omap4/board.c +64 -0
index 3fd6f84..09861a9 100644
@@ -28,6 +28,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
+#include <asm/armv7.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
@@ -35,6 +36,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+u32 *const omap4_revision = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
+
 void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
 {
 	int i;
@@ -72,6 +75,66 @@ static void set_mux_conf_regs(void)
 	}
 }
 
+static u32 cortex_a9_rev(void)
+{
+
+	unsigned int rev;
+
+	/* Read Main ID Register (MIDR) */
+	asm ("mrc p15, 0, %0, c0, c0, 0" : "=r" (rev));
+
+	return rev;
+}
+
+static void init_omap4_revision(void)
+{
+	/*
+	 * For some of the ES2/ES1 boards ID_CODE is not reliable:
+	 * Also, ES1 and ES2 have different ARM revisions
+	 * So use ARM revision for identification
+	 */
+	unsigned int arm_rev = cortex_a9_rev();
+
+	switch (arm_rev) {
+	case MIDR_CORTEX_A9_R0P1:
+		*omap4_revision = OMAP4430_ES1_0;
+		break;
+	case MIDR_CORTEX_A9_R1P2:
+		switch (readl(CONTROL_ID_CODE)) {
+		case OMAP4_CONTROL_ID_CODE_ES2_0:
+			*omap4_revision = OMAP4430_ES2_0;
+			break;
+		case OMAP4_CONTROL_ID_CODE_ES2_1:
+			*omap4_revision = OMAP4430_ES2_1;
+			break;
+		case OMAP4_CONTROL_ID_CODE_ES2_2:
+			*omap4_revision = OMAP4430_ES2_2;
+			break;
+		default:
+			*omap4_revision = OMAP4430_ES2_0;
+			break;
+		}
+		break;
+	case MIDR_CORTEX_A9_R1P3:
+		*omap4_revision = OMAP4430_ES2_3;
+		break;
+	default:
+		*omap4_revision = OMAP4430_SILICON_ID_INVALID;
+		break;
+	}
+}
+
+void omap_rev_string(char *omap4_rev_string)
+{
+	u32 omap4_rev = omap_revision();
+	u32 omap4_variant = (omap4_rev & 0xFFFF0000) >> 16;
+	u32 major_rev = (omap4_rev & 0x00000F00) >> 8;
+	u32 minor_rev = (omap4_rev & 0x000000F0) >> 4;
+
+	sprintf(omap4_rev_string, "OMAP%x ES%x.%x", omap4_variant, major_rev,
+		minor_rev);
+}
+
 /*
  * Routine: s_init
  * Description: Does early system init of watchdog, muxing,  andclocks
@@ -88,6 +151,7 @@ static void set_mux_conf_regs(void)
  */
 void s_init(void)
 {
+	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
 }
arch/arm/include/asm/arch-omap4/omap4.h +21 -8
index a30bb33..76b06c2 100644
@@ -51,6 +51,15 @@
 #define CONTROL_PADCONF_CORE	(OMAP44XX_L4_CORE_BASE + 0x100000)
 #define CONTROL_PADCONF_WKUP	(OMAP44XX_L4_CORE_BASE + 0x31E000)
 
+/* CONTROL_ID_CODE */
+#define CONTROL_ID_CODE		0x4A002204
+
+#define OMAP4_CONTROL_ID_CODE_ES1_0	0x0B85202F
+#define OMAP4_CONTROL_ID_CODE_ES2_0	0x1B85202F
+#define OMAP4_CONTROL_ID_CODE_ES2_1	0x3B95C02F
+#define OMAP4_CONTROL_ID_CODE_ES2_2	0x4B95C02F
+#define OMAP4_CONTROL_ID_CODE_ES2_3	0x6B95C02F
+
 /* UART */
 #define UART1_BASE		(OMAP44XX_L4_PER_BASE + 0x6a000)
 #define UART2_BASE		(OMAP44XX_L4_PER_BASE + 0x6c000)
@@ -119,13 +128,17 @@ struct s32ktimer {
 /* base address for indirect vectors (internal boot mode) */
 #define SRAM_ROM_VECT_BASE	0x4030D000
 /* Temporary SRAM stack used while low level init is done */
-#define LOW_LEVEL_SRAM_STACK	NON_SECURE_SRAM_END
-
-/*
- * OMAP4 real hardware:
- * TODO: Change this to the IDCODE in the hw regsiter
- */
-#define CPU_OMAP4430_ES10	1
-#define CPU_OMAP4430_ES20	2
+#define LOW_LEVEL_SRAM_STACK		NON_SECURE_SRAM_END
+#define SRAM_SCRATCH_SPACE_ADDR		NON_SECURE_SRAM_START
+/* SRAM scratch space entries */
+#define OMAP4_SRAM_SCRATCH_OMAP4_REV	SRAM_SCRATCH_SPACE_ADDR
+
+/* Silicon revisions */
+#define OMAP4430_SILICON_ID_INVALID	0xFFFFFFFF
+#define OMAP4430_ES1_0	0x44300100
+#define OMAP4430_ES2_0	0x44300200
+#define OMAP4430_ES2_1	0x44300210
+#define OMAP4430_ES2_2	0x44300220
+#define OMAP4430_ES2_3	0x44300230
 
 #endif
arch/arm/include/asm/arch-omap4/sys_proto.h +7 -0
index 3624378..c10fa18 100644
@@ -40,6 +40,7 @@ void sr32(void *, u32, u32, u32);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
+void omap_rev_string(char *omap4_rev_string);
 
 static inline u32 running_from_sdram(void)
 {
@@ -88,4 +89,10 @@ static inline u32 omap4_hw_init_context(void)
 #endif
 }
 
+static inline u32 omap_revision(void)
+{
+	extern u32 *const omap4_revision;
+	return *omap4_revision;
+}
+
 #endif
arch/arm/include/asm/armv7.h +5 -0
index 88b9c62..b5784d8 100644
@@ -25,6 +25,11 @@
 #define ARMV7_H
 #include <linux/types.h>
 
+/* Cortex-A9 revisions */
+#define MIDR_CORTEX_A9_R0P1	0x410FC091
+#define MIDR_CORTEX_A9_R1P2	0x411FC092
+#define MIDR_CORTEX_A9_R1P3	0x411FC093
+
 /* CCSIDR */
 #define CCSIDR_LINE_SIZE_OFFSET		0
 #define CCSIDR_LINE_SIZE_MASK		0x7
Signature · 1 line
1.7.0.4
author
#185 lore raw

PATCH v3 4/12 omap4: add clock support

In reply to Aneesh V

Add support for:
1. DPLL locking
2. Initialization of clock domains and clock modules
3. Setting up the right voltage on voltage rails

This work draws upon previous work done for x-loader by:
Santosh Shilimkar <[email protected]> Rajendra Nayak <[email protected]>

---
V2:
* Use pre-calculated M & N values instead of calculated ones
* Changes due to make file changes
* Some corrections
* Do all clock initialization in SPL itself instead of differing some work to u-boot

V3:
* Use struct for register addressing
* Support only Turbo OPP for MPU. OPP's above this need Smart Reflex enabled
* Cleaned up the scale_vcore(). Now takes into account the differing voltage offsets for different revisions of Phoenix.
* Removed references to deprecated utility functions - modify_reg_32() etc.
* Changed all spl_debug() to debug()
* Moved the host-program for calculating DPLL multiplier/divider to tools/omap/ directory. Added more documentation
* Replaced calls to omap4_revision() with omap_revision()
* Some changes to IVA and ABE dpll locking code

---
 arch/arm/cpu/armv7/omap4/Makefile           |    1 +
 arch/arm/cpu/armv7/omap4/board.c            |    1 +
 arch/arm/cpu/armv7/omap4/clocks.c           |  809 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/clocks.h    |  664 ++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h |    8 +
 arch/arm/include/asm/omap_common.h          |    3 +
 tools/omap/clocks_get_m_n.c                 |  197 +++++++
 7 files changed, 1683 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/clocks.c
 create mode 100644 arch/arm/include/asm/arch-omap4/clocks.h
 create mode 100644 tools/omap/clocks_get_m_n.c
arch/arm/cpu/armv7/omap4/Makefile +1 -0
index 987dc9d..ac4b2a6 100644
@@ -28,6 +28,7 @@ LIB	=  $(obj)lib$(SOC).o
 SOBJS	+= lowlevel_init.o
 
 COBJS	+= board.o
+COBJS	+= clocks.o
 COBJS	+= mem.o
 COBJS	+= sys_info.o
 
arch/arm/cpu/armv7/omap4/board.c +1 -0
index 09861a9..1c26a66 100644
@@ -154,6 +154,7 @@ void s_init(void)
 	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
+	prcm_init();
 }
 
 /*
arch/arm/cpu/armv7/omap4/clocks.c new file +809 -0

809 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/clocks.h new file +664 -0

664 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/sys_proto.h +8 -0
index c10fa18..f871921 100644
@@ -22,6 +22,7 @@
 #define _SYS_PROTO_H_
 
 #include <asm/arch/omap4.h>
+#include <asm/arch/clocks.h>
 #include <asm/io.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mux_omap4.h>
@@ -31,6 +32,8 @@ struct omap_sysinfo {
 };
 extern const struct omap_sysinfo sysinfo;
 
+extern struct omap4_prcm_regs *const prcm;
+
 void gpmc_init(void);
 void watchdog_init(void);
 u32 get_device_type(void);
@@ -41,6 +44,11 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 void omap_rev_string(char *omap4_rev_string);
+void prcm_init(void);
+void bypass_dpll(u32 *const base);
+void freq_update_core(void);
+u32 get_sys_clk_freq(void);
+u32 omap4_ddr_clk(void);
 
 static inline u32 running_from_sdram(void)
 {
arch/arm/include/asm/omap_common.h +3 -0
index d80f665..33caa4e 100644
@@ -25,6 +25,9 @@
 #ifndef	_OMAP_COMMON_H_
 #define	_OMAP_COMMON_H_
 
+/* Max value for DPLL multiplier M */
+#define OMAP_DPLL_MAX_N	127
+
 /* HW Init Context */
 #define OMAP_INIT_CONTEXT_SPL			0
 #define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR	1
tools/omap/clocks_get_m_n.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#186 lore raw

PATCH v3 5/12 omap4: add sdram init support

In reply to Aneesh V

Add support for the SDRAM controller (EMIF).

---
V2:
* Minor corrections in do_lpddr2_init()
* Minor corrections to read_idle interval calculation
* Sanity test of memory after doing the initialization
* Fixed warnings reported with with latest GCC compilers V3:
* Removed references to modify_reg_32()
* Updated references to OMAP_INIT_CONTEXT_* flags
* Replaced calls to omap4_revision() with omap_revision()
* Replaced sanity test with get_ram_size()

---
 arch/arm/cpu/armv7/omap4/Makefile           |    2 +
 arch/arm/cpu/armv7/omap4/board.c            |    6 +-
 arch/arm/cpu/armv7/omap4/emif.c             |  328 +++++++++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c     |  131 ++++
 arch/arm/include/asm/arch-omap4/clocks.h    |    8 +-
 arch/arm/include/asm/arch-omap4/emif.h      | 1025 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h     |    5 +
 arch/arm/include/asm/arch-omap4/sys_proto.h |    2 +
 8 files changed, 1500 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/emif.c
 create mode 100644 arch/arm/cpu/armv7/omap4/sdram_elpida.c
 create mode 100644 arch/arm/include/asm/arch-omap4/emif.h
arch/arm/cpu/armv7/omap4/Makefile +2 -0
index ac4b2a6..e1ccd68 100644
@@ -29,7 +29,9 @@ SOBJS	+= lowlevel_init.o
 
 COBJS	+= board.o
 COBJS	+= clocks.o
+COBJS	+= emif.o
 COBJS	+= mem.o
+COBJS	+= sdram_elpida.o
 COBJS	+= sys_info.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/omap4/board.c +3 -3
index 1c26a66..ca107f7 100644
@@ -189,7 +189,7 @@ void watchdog_init(void)
  * This is needed because the size of memory installed may be
  * different on different versions of the board
  */
-u32 sdram_size(void)
+u32 omap4_sdram_size(void)
 {
 	u32 section, i, total_size = 0, size, addr;
 	for (i = 0; i < 4; i++) {
@@ -215,8 +215,8 @@ u32 sdram_size(void)
  */
 int dram_init(void)
 {
-
-	gd->ram_size = sdram_size();
+	sdram_init();
+	gd->ram_size = omap4_sdram_size();
 
 	return 0;
 }
arch/arm/cpu/armv7/omap4/emif.c new file +328 -0

328 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/sdram_elpida.c new file +131 -0

131 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/clocks.h +4 -4
index 71db39c..37bdcee 100644
@@ -33,10 +33,10 @@
  */
 #define LDELAY		1000000
 
-#define CM_CLKMODE_DPLL_CORE		(OMAP44XX_L4_CORE_BASE + 0x4120)
-#define CM_CLKMODE_DPLL_PER		(OMAP44XX_L4_CORE_BASE + 0x8140)
-#define CM_CLKMODE_DPLL_MPU		(OMAP44XX_L4_CORE_BASE + 0x4160)
-#define CM_CLKSEL_CORE			(OMAP44XX_L4_CORE_BASE + 0x4100)
+#define CM_CLKMODE_DPLL_CORE		0x4A004120
+#define CM_CLKMODE_DPLL_PER		0x4A008140
+#define CM_CLKMODE_DPLL_MPU		0x4A004160
+#define CM_CLKSEL_CORE			0x4A004100
 
 struct omap4_prcm_regs {
 	/* cm1.ckgen */
arch/arm/include/asm/arch-omap4/emif.h new file +1025 -0

1,025 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/omap4.h +5 -0
index 76b06c2..c9c86e1 100644
@@ -51,6 +51,11 @@
 #define CONTROL_PADCONF_CORE	(OMAP44XX_L4_CORE_BASE + 0x100000)
 #define CONTROL_PADCONF_WKUP	(OMAP44XX_L4_CORE_BASE + 0x31E000)
 
+/* LPDDR2 IO regs */
+#define LPDDR2_IO_REGS_BASE	0x4A100638
+
+#define CONTROL_EFUSE_2		0x4A100704
+
 /* CONTROL_ID_CODE */
 #define CONTROL_ID_CODE		0x4A002204
 
arch/arm/include/asm/arch-omap4/sys_proto.h +2 -0
index f871921..7183a90 100644
@@ -49,6 +49,8 @@ void bypass_dpll(u32 *const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
 u32 omap4_ddr_clk(void);
+void sdram_init(void);
+u32 omap4_sdram_size(void);
 
 static inline u32 running_from_sdram(void)
 {
Signature · 1 line
1.7.0.4
author
#187 lore raw

PATCH v3 6/12 omap4: calculate EMIF register values

In reply to Aneesh V

Calculate EMIF register values based on AC timing parameters from the SDRAM datasheet and the DDR frequency rather than using the hard-coded values.

For a new board the user doen't have to go through the tedious process of calculating the register values. Instead, just provide the AC timings from the device data sheet as input and the driver will automatically calculate the register values.

---
V3:
* Added SDRAM init related CONFIG flags for Panda too. Earlier Panda support for everything was added in a single patch at the end
* Replaced calls to omap4_revision() with omap_revision()
* Reorganization of code for better readability
* Some code re-organization to reduce #ifdef complexities - cleanly separated out functions for getting device details (geometry) vs timings
* Ensured un-necessary code is compiled out if CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REG is defined

---
 arch/arm/cpu/armv7/omap-common/Makefile     |    1 +
 arch/arm/cpu/armv7/omap-common/utils.c      |   57 ++
 arch/arm/cpu/armv7/omap4/board.c            |    9 +-
 arch/arm/cpu/armv7/omap4/emif.c             |  739 +++++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c     |  151 ++++++
 arch/arm/include/asm/arch-omap4/emif.h      |    9 +
 arch/arm/include/asm/arch-omap4/omap4.h     |   10 +-
 arch/arm/include/asm/arch-omap4/sys_proto.h |    1 +
 include/configs/omap4_panda.h               |    5 +
 include/configs/omap4_sdp4430.h             |    5 +
 10 files changed, 977 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/utils.c
arch/arm/cpu/armv7/omap-common/Makefile +1 -0
index dc01ee5..8f698f8 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)libomap-common.o
 SOBJS	:= reset.o
 
 COBJS	:= timer.o
+COBJS	+= utils.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/arm/cpu/armv7/omap-common/utils.c new file +57 -0

57 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/board.c +5 -4
index ca107f7..786c239 100644
@@ -32,6 +32,7 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
+#include <asm/arch/emif.h>
 #include "omap4_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -193,13 +194,13 @@ u32 omap4_sdram_size(void)
 {
 	u32 section, i, total_size = 0, size, addr;
 	for (i = 0; i < 4; i++) {
-		section	= __raw_readl(DMM_LISA_MAP_BASE + i*4);
-		addr = section & DMM_LISA_MAP_SYS_ADDR_MASK;
+		section	= __raw_readl(OMAP44XX_DMM_LISA_MAP_BASE + i*4);
+		addr = section & OMAP44XX_SYS_ADDR_MASK;
 		/* See if the address is valid */
 		if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
 		    (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
-			size	= ((section & DMM_LISA_MAP_SYS_SIZE_MASK) >>
-				    DMM_LISA_MAP_SYS_SIZE_SHIFT);
+			size	= ((section & OMAP44XX_SYS_SIZE_MASK) >>
+				   OMAP44XX_SYS_SIZE_SHIFT);
 			size	= 1 << size;
 			size	*= SZ_16M;
 			total_size += size;
arch/arm/cpu/armv7/omap4/emif.c +739 -0

764 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/sdram_elpida.c +151 -0

160 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/emif.h +9 -0
index 09e9baa..a167508 100644
@@ -1019,7 +1019,16 @@ struct emif_regs {
 #define emif_assert(c)	({ if (0) hang(); })
 #endif
 
+#ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
+#else
+void emif_get_device_details(u32 emif_nr,
+		struct lpddr2_device_details *cs0_device_details,
+		struct lpddr2_device_details *cs1_device_details);
+void emif_get_device_timings(u32 emif_nr,
+		const struct lpddr2_device_timings **cs0_device_timings,
+		const struct lpddr2_device_timings **cs1_device_timings);
+#endif
 
 #endif
arch/arm/include/asm/arch-omap4/omap4.h +4 -6
index c9c86e1..a8dbedb 100644
@@ -84,12 +84,6 @@
 /* GPMC */
 #define OMAP44XX_GPMC_BASE	0x50000000
 
-/* DMM */
-#define OMAP44XX_DMM_BASE		0x4E000000
-#define DMM_LISA_MAP_BASE		(OMAP44XX_DMM_BASE + 0x40)
-#define DMM_LISA_MAP_SYS_SIZE_MASK	(7 << 20)
-#define DMM_LISA_MAP_SYS_SIZE_SHIFT	20
-#define DMM_LISA_MAP_SYS_ADDR_MASK	(0xFF << 24)
 /*
  * Hardware Register Details
  */
@@ -137,6 +131,10 @@ struct s32ktimer {
 #define SRAM_SCRATCH_SPACE_ADDR		NON_SECURE_SRAM_START
 /* SRAM scratch space entries */
 #define OMAP4_SRAM_SCRATCH_OMAP4_REV	SRAM_SCRATCH_SPACE_ADDR
+#define OMAP4_SRAM_SCRATCH_EMIF_SIZE	(SRAM_SCRATCH_SPACE_ADDR + 0x4)
+#define OMAP4_SRAM_SCRATCH_EMIF_T_NUM	(SRAM_SCRATCH_SPACE_ADDR + 0xC)
+#define OMAP4_SRAM_SCRATCH_EMIF_T_DEN	(SRAM_SCRATCH_SPACE_ADDR + 0x10)
+#define OMAP4_SRAM_SCRATCH_SPACE_END	(SRAM_SCRATCH_SPACE_ADDR + 0x14)
 
 /* Silicon revisions */
 #define OMAP4430_SILICON_ID_INVALID	0xFFFFFFFF
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
index 7183a90..1e62878 100644
@@ -49,6 +49,7 @@ void bypass_dpll(u32 *const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
 u32 omap4_ddr_clk(void);
+void cancel_out(u32 *num, u32 *den, u32 den_limit);
 void sdram_init(void);
 u32 omap4_sdram_size(void);
 
include/configs/omap4_panda.h +5 -0
index 1daffb7..9f82ef4 100644
@@ -237,4 +237,9 @@
 #define CONFIG_SYS_PL310_BASE	0x48242000
 #endif
 
+/* Defines for SDRAM init */
+#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
+#endif
+
 #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +5 -0
index 68ffa87..6df1c3d 100644
@@ -243,4 +243,9 @@
 #define CONFIG_SYS_PL310_BASE	0x48242000
 #endif
 
+/* Defines for SDRAM init */
+#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
+#endif
+
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
author
#188 lore raw

PATCH v3 7/12 omap4: automatic sdram detection

In reply to Aneesh V

Identify SDRAM devices connected to EMIF automatically:
LPDDR2 devices have some Mode Registers that provide details about the device such as the type, density, bus width etc. EMIF has the capability to read these registers. If there are no devices connected to a given chip-select reading mode registers will return junk values. After reading as many such registers as possible and matching with expected ranges of values the driver can identify if there is a device connected to the respective CS. If we identify that a device is connected the values read give us complete details about the device.

This along with the base AC timings specified by JESD209-2 allows us to do a complete automatic initialization of SDRAM that works on all boards.

Please note that the default AC timings specified by JESD209-2 will be safe for all devices but not necessarily optimal. However, for the Elpida devices used on Panda and SDP the default timings are both safe and optimal.

---
V3:
* Code re-organization for better readability
* Ensured that un-necessary code is compiled out when CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION is not defined

---
 arch/arm/cpu/armv7/omap4/emif.c |  238 +++++++++++++++++++++++++++++++++++++++
 include/configs/omap4_panda.h   |    1 +
 include/configs/omap4_sdp4430.h |    1 +
 3 files changed, 240 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/omap4/emif.c +238 -0
index ceead9e..1234a7e 100644
@@ -792,6 +792,244 @@ void emif_get_device_timings(u32 emif_nr,
 }
 #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */
 
+#ifdef CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
+const char *get_lpddr2_type(u8 type_id)
+{
+	switch (type_id) {
+	case LPDDR2_TYPE_S4:
+		return "LPDDR2-S4";
+	case LPDDR2_TYPE_S2:
+		return "LPDDR2-S2";
+	default:
+		return NULL;
+	}
+}
+
+const char *get_lpddr2_io_width(u8 width_id)
+{
+	switch (width_id) {
+	case LPDDR2_IO_WIDTH_8:
+		return "x8";
+	case LPDDR2_IO_WIDTH_16:
+		return "x16";
+	case LPDDR2_IO_WIDTH_32:
+		return "x32";
+	default:
+		return NULL;
+	}
+}
+
+const char *get_lpddr2_manufacturer(u32 manufacturer)
+{
+	switch (manufacturer) {
+	case LPDDR2_MANUFACTURER_SAMSUNG:
+		return "Samsung";
+	case LPDDR2_MANUFACTURER_QIMONDA:
+		return "Qimonda";
+	case LPDDR2_MANUFACTURER_ELPIDA:
+		return "Elpida";
+	case LPDDR2_MANUFACTURER_ETRON:
+		return "Etron";
+	case LPDDR2_MANUFACTURER_NANYA:
+		return "Nanya";
+	case LPDDR2_MANUFACTURER_HYNIX:
+		return "Hynix";
+	case LPDDR2_MANUFACTURER_MOSEL:
+		return "Mosel";
+	case LPDDR2_MANUFACTURER_WINBOND:
+		return "Winbond";
+	case LPDDR2_MANUFACTURER_ESMT:
+		return "ESMT";
+	case LPDDR2_MANUFACTURER_SPANSION:
+		return "Spansion";
+	case LPDDR2_MANUFACTURER_SST:
+		return "SST";
+	case LPDDR2_MANUFACTURER_ZMOS:
+		return "ZMOS";
+	case LPDDR2_MANUFACTURER_INTEL:
+		return "Intel";
+	case LPDDR2_MANUFACTURER_NUMONYX:
+		return "Numonyx";
+	case LPDDR2_MANUFACTURER_MICRON:
+		return "Micron";
+	default:
+		return NULL;
+	}
+}
+
+static void display_sdram_details(u32 emif_nr, u32 cs,
+				  struct lpddr2_device_details *device)
+{
+	const char *mfg_str;
+	const char *type_str;
+	char density_str[10];
+	u32 density;
+
+	debug("EMIF%d CS%d\t", emif_nr, cs);
+
+	if (!device) {
+		debug("None\n");
+		return;
+	}
+
+	mfg_str = get_lpddr2_manufacturer(device->manufacturer);
+	type_str = get_lpddr2_type(device->type);
+
+	density = lpddr2_density_2_size_in_mbytes[device->density];
+	if ((density / 1024 * 1024) == density) {
+		density /= 1024;
+		sprintf(density_str, "%d GB", density);
+	} else
+		sprintf(density_str, "%d MB", density);
+	if (mfg_str && type_str)
+		debug("%s\t\t%s\t%s\n", mfg_str, type_str, density_str);
+}
+
+static u8 is_lpddr2_sdram_present(u32 base, u32 cs,
+				  struct lpddr2_device_details *lpddr2_device)
+{
+	u32 mr = 0, temp;
+
+	mr = get_mr(base, cs, LPDDR2_MR0);
+	if (mr > 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	temp = (mr & LPDDR2_MR0_DI_MASK) >> LPDDR2_MR0_DI_SHIFT;
+	if (temp) {
+		/* Not SDRAM */
+		return 0;
+	}
+	temp = (mr & LPDDR2_MR0_DNVI_MASK) >> LPDDR2_MR0_DNVI_SHIFT;
+
+	if (temp) {
+		/* DNV supported - But DNV is only supported for NVM */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR4);
+	if (mr > 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR5);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	if (!get_lpddr2_manufacturer(mr)) {
+		/* Manufacturer not identified */
+		return 0;
+	}
+	lpddr2_device->manufacturer = mr;
+
+	mr = get_mr(base, cs, LPDDR2_MR6);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR7);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR8);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	temp = (mr & MR8_TYPE_MASK) >> MR8_TYPE_SHIFT;
+	if (!get_lpddr2_type(temp)) {
+		/* Not SDRAM */
+		return 0;
+	}
+	lpddr2_device->type = temp;
+
+	temp = (mr & MR8_DENSITY_MASK) >> MR8_DENSITY_SHIFT;
+	if (temp > LPDDR2_DENSITY_32Gb) {
+		/* Density not supported */
+		return 0;
+	}
+	lpddr2_device->density = temp;
+
+	temp = (mr & MR8_IO_WIDTH_MASK) >> MR8_IO_WIDTH_SHIFT;
+	if (!get_lpddr2_io_width(temp)) {
+		/* IO width unsupported value */
+		return 0;
+	}
+	lpddr2_device->io_width = temp;
+
+	/*
+	 * If all the above tests pass we should
+	 * have a device on this chip-select
+	 */
+	return 1;
+}
+
+static struct lpddr2_device_details *get_lpddr2_details(u32 base, u8 cs,
+			struct lpddr2_device_details *lpddr2_dev_details)
+{
+	u32 phy;
+	struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
+
+	if (!lpddr2_dev_details)
+		return NULL;
+
+	/* Do the minimum init for mode register accesses */
+	if (!running_from_sdram()) {
+		phy = get_ddr_phy_ctrl_1(get_sys_clk_freq() / 2, RL_BOOT);
+		writel(phy, &emif->emif_ddr_phy_ctrl_1);
+	}
+
+	if (!(is_lpddr2_sdram_present(base, cs, lpddr2_dev_details)))
+		return NULL;
+
+	display_sdram_details(emif_num(base), cs, lpddr2_dev_details);
+
+	return lpddr2_dev_details;
+}
+
+void emif_get_device_details(u32 emif_nr,
+		struct lpddr2_device_details *cs0_device_details,
+		struct lpddr2_device_details *cs1_device_details)
+{
+	u32 base = (emif_nr == 1) ? OMAP44XX_EMIF1 : OMAP44XX_EMIF2;
+
+	if (running_from_sdram()) {
+		/*
+		 * We can not do automatic discovery running from SDRAM
+		 * Most likely we came here by mistake. Indicate error
+		 * by returning NULL
+		 */
+		cs0_device_details = NULL;
+		cs1_device_details = NULL;
+	} else {
+		/*
+		 * Automatically find the device details:
+		 *
+		 * Reset the PHY after each call to get_lpddr2_details().
+		 * If there is nothing connected to a given chip select
+		 * (typically CS1) mode register reads will mess up with
+		 * the PHY state and subsequent initialization won't work.
+		 * PHY reset brings back PHY to a good state.
+		 */
+		cs0_device_details =
+		    get_lpddr2_details(base, CS0, cs0_device_details);
+		emif_reset_phy(base);
+
+		cs1_device_details =
+		    get_lpddr2_details(base, CS1, cs1_device_details);
+		emif_reset_phy(base);
+	}
+}
+#endif /* CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION */
+
 static void do_sdram_init(u32 base)
 {
 	const struct emif_regs *regs;
include/configs/omap4_panda.h +1 -0
index 9f82ef4..a8dd861 100644
@@ -239,6 +239,7 @@
 
 /* Defines for SDRAM init */
 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
include/configs/omap4_sdp4430.h +1 -0
index 6df1c3d..534f89a 100644
@@ -245,6 +245,7 @@
 
 /* Defines for SDRAM init */
 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
Signature · 1 line
1.7.0.4
author
#189 lore raw

PATCH v3 8/12 armv7: start.S: fixes and enhancements for SPL

In reply to Aneesh V

- Allow SPL to have .bss disjoint from rest of the image
- Allow for .bss setup in CONFIG_SPL_BUILD case too.
- Take care of the special case where relocation offset = 0.
- Compile out exception handling code and install a simpler vector

---
V3:
* Taken care of the case where .bss is at a lower address comapred to _start

---
 arch/arm/cpu/armv7/start.S    |   50 ++++++++++++++++++++++++++++++----------
 arch/arm/cpu/armv7/u-boot.lds |    2 +
 2 files changed, 39 insertions(+), 13 deletions(-)
arch/arm/cpu/armv7/start.S +37 -13
index d2a6207..5be436f 100644
@@ -42,7 +42,16 @@ _start: b	reset
 	ldr	pc, _not_used
 	ldr	pc, _irq
 	ldr	pc, _fiq
-
+#ifdef CONFIG_SPL_BUILD
+_undefined_instruction: .word _undefined_instruction
+_software_interrupt:	.word _software_interrupt
+_prefetch_abort:	.word _prefetch_abort
+_data_abort:		.word _data_abort
+_not_used:		.word _not_used
+_irq:			.word _irq
+_fiq:			.word _fiq
+_pad:			.word 0x12345678 /* now 16*4=64 */
+#else
 _undefined_instruction: .word undefined_instruction
 _software_interrupt:	.word software_interrupt
 _prefetch_abort:	.word prefetch_abort
@@ -51,6 +60,8 @@ _not_used:		.word not_used
 _irq:			.word irq
 _fiq:			.word fiq
 _pad:			.word 0x12345678 /* now 16*4=64 */
+#endif	/* CONFIG_SPL_BUILD */
+
 .global _end_vect
 _end_vect:
 
@@ -89,6 +100,10 @@ _armboot_start:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -182,12 +197,11 @@ stack_setup:
 	mov	sp, r4
 
 	adr	r0, _start
-#ifndef CONFIG_SPL_BUILD
 	cmp	r0, r6
+	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */
 	beq	clear_bss		/* skip relocation */
-#endif
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
@@ -235,20 +249,34 @@ fixnext:
 	add	r2, r2, #8		/* each rel.dyn entry is 8 bytes */
 	cmp	r2, r3
 	blo	fixloop
+	b	clear_bss
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
+#endif	/* #ifndef CONFIG_SPL_BUILD */
 
 clear_bss:
+#ifdef CONFIG_SPL_BUILD
+	/* No relocation for SPL */
+	ldr	r0, =__bss_start
+	ldr	r1, =__bss_end__
+#else
 	ldr	r0, _bss_start_ofs
 	ldr	r1, _bss_end_ofs
 	mov	r4, r6			/* reloc addr */
 	add	r0, r0, r4
 	add	r1, r1, r4
+#endif
 	mov	r2, #0x00000000		/* clear			    */
 
 clbss_l:str	r2, [r0]		/* clear loop...		    */
 	add	r0, r0, #4
 	cmp	r0, r1
 	bne	clbss_l
-#endif	/* #ifndef CONFIG_SPL_BUILD */
 
 /*
  * We are done. Do not return, instead branch to second part of board
@@ -276,13 +304,6 @@ jump_2_ram:
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*************************************************************************
  *
  * CPU_init_critical registers
@@ -327,6 +348,8 @@ cpu_init_crit:
 	bl	lowlevel_init		@ go setup pll,mux,memory
 	mov	lr, ip			@ restore link
 	mov	pc, lr			@ back to my caller
+
+#ifndef CONFIG_SPL_BUILD
 /*
  *************************************************************************
  *
@@ -514,4 +537,5 @@ fiq:
 	bad_save_user_regs
 	bl	do_fiq
 
-#endif
+#endif /* CONFIG_USE_IRQ */
+#endif /* CONFIG_SPL_BUILD */
arch/arm/cpu/armv7/u-boot.lds +2 -0
index dbae54d..40ecf78 100644
@@ -55,6 +55,8 @@ SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
Signature · 1 line
1.7.0.4
author
#190 lore raw

PATCH v3 9/12 omap: add basic SPL support

In reply to Aneesh V

- Provide alternate implementations of board_init_f() board_init_r() for OMAP spl.
- Provide linker script
- Initialize global data
- Add serial console support
- Update CONFIG_SYS_TEXT_BASE to allow for SPL's bss and move it to board config header from config.mk

---

This patch adds two checkpatch warnings that look like false positives. Reported these to checkpatch maintainer.

V2:
* Removed the label __flash_image_end because _end serves the same purpose after rebasing to latest mainline

V3:
* Moved CONFIG_SYS_TEXT_BASE to board config header and deleted config.mk
* Changes for the struct based register accesses
* Removed usage of modify_reg_32() macro
* omap4_rev_string() reference changed to omap_rev_string()
* Folded the patches for linker script changes and console support into this patch
* Improved commit message

---
 arch/arm/cpu/armv7/Makefile                   |    7 ++-
 arch/arm/cpu/armv7/omap-common/Makefile       |    4 +
 arch/arm/cpu/armv7/omap-common/spl.c          |   82 +++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds |   62 +++++++++++++++++++
 arch/arm/cpu/armv7/omap4/Makefile             |    5 +-
 arch/arm/cpu/armv7/omap4/board.c              |    7 ++
 arch/arm/cpu/armv7/omap4/clocks.c             |   33 ++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h   |    1 +
 arch/arm/include/asm/omap_common.h            |    2 +
 board/ti/panda/Makefile                       |    2 +
 board/ti/panda/config.mk                      |   31 ---------
 board/ti/sdp4430/Makefile                     |    2 +
 board/ti/sdp4430/config.mk                    |   31 ---------
 include/configs/omap4_panda.h                 |   26 ++++++++
 include/configs/omap4_sdp4430.h               |   26 ++++++++
 15 files changed, 257 insertions(+), 64 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl.c
 create mode 100644 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
 delete mode 100644 board/ti/panda/config.mk
 delete mode 100644 board/ti/sdp4430/config.mk
arch/arm/cpu/armv7/Makefile +6 -1
index 299792a..92a5a96 100644
@@ -26,7 +26,12 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).o
 
 START	:= start.o
-COBJS	:= cpu.o cache_v7.o
+
+ifndef CONFIG_SPL_BUILD
+COBJS	+= cache_v7.o
+COBJS	+= cpu.o
+endif
+
 COBJS  += syslib.o
 
 SRCS	:= $(START:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/omap-common/Makefile +4 -0
index 8f698f8..0708796 100644
@@ -30,6 +30,10 @@ SOBJS	:= reset.o
 COBJS	:= timer.o
 COBJS	+= utils.o
 
+ifdef CONFIG_SPL_BUILD
+COBJS	+= spl.o
+endif
+
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
arch/arm/cpu/armv7/omap-common/spl.c new file +82 -0

82 lines not on this page · raw message

arch/arm/cpu/armv7/omap-common/u-boot-spl.lds new file +62 -0

62 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/Makefile +4 -1
index e1ccd68..e7ee0b8 100644
@@ -30,9 +30,12 @@ SOBJS	+= lowlevel_init.o
 COBJS	+= board.o
 COBJS	+= clocks.o
 COBJS	+= emif.o
-COBJS	+= mem.o
 COBJS	+= sdram_elpida.o
+
+ifndef CONFIG_SPL_BUILD
+COBJS	+= mem.o
 COBJS	+= sys_info.o
+endif
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap4/board.c +7 -0
index 786c239..54dd509 100644
@@ -155,7 +155,14 @@ void s_init(void)
 	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
+#ifdef CONFIG_SPL_BUILD
+	preloader_console_init();
+#endif
 	prcm_init();
+#ifdef CONFIG_SPL_BUILD
+	/* For regular u-boot sdram_init() is called from dram_init() */
+	sdram_init();
+#endif
 }
 
 /*
arch/arm/cpu/armv7/omap4/clocks.c +33 -0
index e8d3a52..f1e233a 100644
@@ -791,6 +791,39 @@ void lock_dpll(u32 *const base)
 	wait_for_lock(base);
 }
 
+void setup_clocks_for_console(void)
+{
+	/* Do not add any spl_debug prints in this function */
+	clrsetbits_le32(&prcm->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
+			CD_CLKCTRL_CLKTRCTRL_SW_WKUP <<
+			CD_CLKCTRL_CLKTRCTRL_SHIFT);
+
+	/* Enable all UARTs - console will be on one of them */
+	clrsetbits_le32(&prcm->cm_l4per_uart1_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart2_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart3_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart3_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
+			CD_CLKCTRL_CLKTRCTRL_HW_AUTO <<
+			CD_CLKCTRL_CLKTRCTRL_SHIFT);
+}
+
 void prcm_init(void)
 {
 	switch (omap4_hw_init_context()) {
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
index 1e62878..a81f8e5 100644
@@ -44,6 +44,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 void omap_rev_string(char *omap4_rev_string);
+void setup_clocks_for_console(void);
 void prcm_init(void);
 void bypass_dpll(u32 *const base);
 void freq_update_core(void);
arch/arm/include/asm/omap_common.h +2 -0
index 33caa4e..69d53d2 100644
@@ -34,4 +34,6 @@
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
 
+void preloader_console_init(void);
+
 #endif /* _OMAP_COMMON_H_ */
board/ti/panda/Makefile +2 -0
index 2186403..09f88ee 100644
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef CONFIG_SPL_BUILD
 COBJS	:= panda.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/ti/panda/config.mk deleted +0 -31
deleted file mode 100644
index 33901a7..0000000
@@ -1,31 +0,0 @@
-#
-# (C) Copyright 2006-2009
-# Texas Instruments Incorporated, <www.ti.com>
-#
-# OMAP 4430 SDP
-# see http://www.ti.com/ for more information on Texas Instruments
-#
-# 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
-#
-# SDRAM Address Space:
-# 8000'0000 - 9fff'ffff (512 MB)
-# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
-# (mem base + reserved)
-
-CONFIG_SYS_TEXT_BASE = 0x80e80000
board/ti/sdp4430/Makefile +2 -0
index f1ee544..12f2743 100644
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef CONFIG_SPL_BUILD
 COBJS	:= sdp.o cmd_bat.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/ti/sdp4430/config.mk deleted +0 -31
deleted file mode 100644
index 33901a7..0000000
@@ -1,31 +0,0 @@
-#
-# (C) Copyright 2006-2009
-# Texas Instruments Incorporated, <www.ti.com>
-#
-# OMAP 4430 SDP
-# see http://www.ti.com/ for more information on Texas Instruments
-#
-# 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
-#
-# SDRAM Address Space:
-# 8000'0000 - 9fff'ffff (512 MB)
-# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
-# (mem base + reserved)
-
-CONFIG_SYS_TEXT_BASE = 0x80e80000
include/configs/omap4_panda.h +26 -0
index a8dd861..3244fc1 100644
@@ -243,4 +243,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE	0x40304350
+#define CONFIG_SYS_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SYS_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SYS_SPL_BSS_START_ADDR		0x80000000
+#define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SYS_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
 #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +26 -0
index 534f89a..5c486c3 100644
@@ -249,4 +249,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE	0x40304350
+#define CONFIG_SYS_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SYS_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SYS_SPL_BSS_START_ADDR		0x80000000
+#define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SYS_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
#191 lore raw

PATCH v3 9/12 omap: add basic SPL support

Hi Aneesh,

include/configs/omap4_panda.h line 248

Quoted 11 lines · Aneesh V
include/configs/omap4_panda.h +3 -0
index a8dd861..3244fc1 100644
@@ -243,4 +243,30 @@
  #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE	0x40304350

Does this work? The SPL framework patches currently use

ifneq ($(CONFIG_SPL_TEXT_BASE),)
CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE) endif

But CONFIG_SYS_SPL_TEXT_BASE seems to be the right name for this option. Shall I fix it in the SPL framework patches?

Quoted 59 lines
include/configs/omap4_panda.h +23 -0
+#define CONFIG_SYS_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SYS_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SYS_SPL_BSS_START_ADDR		0x80000000
+#define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SYS_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
  #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +26 -0
index 534f89a..5c486c3 100644
@@ -249,4 +249,30 @@
  #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE	0x40304350
+#define CONFIG_SYS_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SYS_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SYS_SPL_BSS_START_ADDR		0x80000000
+#define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SYS_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
  #endif /* __CONFIG_H */
author
#192 lore raw

PATCH v3 9/12 omap: add basic SPL support

Quoted 13 lines · Daniel Schwierzeck

Hi Aneesh,

Quoted 9 lines · Aneesh V
include/configs/omap4_panda.h +0 -0
index a8dd861..3244fc1 100644
@@ -243,4 +243,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
Quoted 5 lines

include/configs/omap4_panda.h line 248

Quoted 3 lines
include/configs/omap4_panda.h +3 -0
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE 0x40304350

Does this work? The SPL framework patches currently use

Hmm.. Good catch. I think it was still working for me because I had this in my linker script:

MEMORY { .sram : ORIGIN = CONFIG_SYS_SPL_TEXT_BASE,\
		 LENGTH = CONFIG_SYS_SPL_MAX_SIZE }

And then I was using the .sram region for rest of the script.

I think this over-rides the -Ttext on the linker command line.

Quoted 6 lines

ifneq ($(CONFIG_SPL_TEXT_BASE),)
CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE) endif

But CONFIG_SYS_SPL_TEXT_BASE seems to be the right name for this option.

Yes, looks like CONFIG_SYS_SPL_TEXT_BASE is the right name. For u-boot we have CONFIG_SYS_TEXT_BASE

Quoted 1 line

Shall I fix it in the SPL framework patches?

I don't know if Daniel wants to do this himself.
As long as you are working on omap and use my linker script, you may still be able to work without any compilation error.

If the framework is going to retain CONFIG_SPL_TEXT_BASE I shall re-submit my patch.

best regards,
Aneesh

author
#193 lore raw

PATCH v3 9/12 omap: add basic SPL support

Quoted 37 lines · Aneesh V
Quoted 13 lines · Daniel Schwierzeck

Hi Aneesh,

Quoted 9 lines · Aneesh V
include/configs/omap4_panda.h +0 -0
index a8dd861..3244fc1 100644
@@ -243,4 +243,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
Quoted 5 lines

include/configs/omap4_panda.h line 248

Quoted 3 lines
include/configs/omap4_panda.h +3 -0
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE 0x40304350

Does this work? The SPL framework patches currently use

Hmm.. Good catch. I think it was still working for me because I had this in my linker script:

MEMORY { .sram : ORIGIN = CONFIG_SYS_SPL_TEXT_BASE,\
LENGTH = CONFIG_SYS_SPL_MAX_SIZE }

And then I was using the .sram region for rest of the script.

I think this over-rides the -Ttext on the linker command line.

Quoted 6 lines

ifneq ($(CONFIG_SPL_TEXT_BASE),)
CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE) endif

But CONFIG_SYS_SPL_TEXT_BASE seems to be the right name for this option.

Quoted 8 lines

Yes, looks like CONFIG_SYS_SPL_TEXT_BASE is the right name. For u-boot we have CONFIG_SYS_TEXT_BASE

Quoted 1 line

Shall I fix it in the SPL framework patches?

I don't know if Daniel wants to do this himself.
As long as you are working on omap and use my linker script, you may still be able to work without any compilation error.

Oops! Terrible mix-up!! I took your mail to be from Simon and hence the above confusion:-)

Yes, fixing this in the framework series seems to be the right thing. Thanks.

best regards,
Aneesh

#194 lore raw

PATCH v3 9/12 omap: add basic SPL support

In reply to Daniel Schwierzeck

Dear Daniel Schwierzeck,

Quoted 3 lines · In message <[email protected]> you wrote:

But CONFIG_SYS_SPL_TEXT_BASE seems to be the right name for this option. Shall I fix it in the SPL framework patches?

This is getting a very long name - and if we do this, we probably have to rename a few other CONFIG_SPL_* into CONFIG_SYS_SPL_* as well.

If you are not really, really convinced this must be renamed I suggest we stick with the shorter CONFIG_SPL_TEXT_BASE instead...

Thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Nobody trips over mountains. It is the small pebble that  causes  you
to  stumble.  Pass all the pebbles in your path and you will find you
have crossed the mountain.
#195 lore raw

PATCH v3 9/12 omap: add basic SPL support

Dear Wolfgang,

Quoted 4 lines · Wolfgang Denk

Dear Daniel Schwierzeck,

Quoted 1 line · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 2 lines

But CONFIG_SYS_SPL_TEXT_BASE seems to be the right name for this option. Shall I fix it in the SPL framework patches?

This is getting a very long name - and if we do this, we probably have to rename a few other CONFIG_SPL_* into CONFIG_SYS_SPL_* as well.

If you are not really, really convinced this must be renamed I suggest we stick with the shorter CONFIG_SPL_TEXT_BASE instead...

ok I won't change the SPL patches. So CONFIG_SPL_* is the new prefix for all SPL specific config options?

Best regards,
Daniel

author
#196 lore raw

PATCH v3 9/12 omap: add basic SPL support

Quoted 10 lines · Daniel Schwierzeck

Dear Wolfgang,

Quoted 7 lines · Wolfgang Denk

Dear Daniel Schwierzeck,

Quoted 3 lines · In message<[email protected]> you wrote:

But CONFIG_SYS_SPL_TEXT_BASE seems to be the right name for this option. Shall I fix it in the SPL framework patches?

Quoted 8 lines
Quoted 5 lines

This is getting a very long name - and if we do this, we probably have to rename a few other CONFIG_SPL_* into CONFIG_SYS_SPL_* as well.

If you are not really, really convinced this must be renamed I suggest we stick with the shorter CONFIG_SPL_TEXT_BASE instead...

ok I won't change the SPL patches. So CONFIG_SPL_* is the new prefix for all SPL specific config options?

Ok. I will change my patch to use CONFIG_SPL_TEXT_BASE then.

br,
Aneesh

#197 lore raw

PATCH v3 9/12 omap: add basic SPL support

In reply to Daniel Schwierzeck

Dear Daniel Schwierzeck,

Quoted 3 lines · In message <CACUy__WZKkYGB9PWu7hTBqBSFV5FD43+E78nD1JQA9pdqoFbPA@mail.gmail.com>…

ok I won't change the SPL patches. So CONFIG_SPL_* is the new prefix for all SPL specific config options?

I'm fine with that.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Man is the best computer we can put aboard a spacecraft ...  and  the
only one that can be mass produced with unskilled labor.
                                                  - Wernher von Braun
#198 lore raw

PATCH v3 9/12 omap: add basic SPL support

In reply to Aneesh V

Hi Aneesh,

Quoted 3 lines · On Sat, 16 Jul 2011 18:23:19 +0530 Aneesh V <[email protected]> wrote:

* omap4_rev_string() reference changed to omap_rev_string()

arch/arm/cpu/armv7/omap-common/spl.c new file +1 -0
+	char omap4_rev_string[50];

[snip]

arch/arm/cpu/armv7/omap-common/spl.c line 81

Quoted 5 lines
(quoted diff) +1 -0
+	printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev,

U_BOOT_DATE,

arch/arm/cpu/armv7/omap-common/spl.c new file +3 -0
+		U_BOOT_TIME);
+	omap_rev_string(omap4_rev_string);
+	printf("Texas Instruments %s\n", omap4_rev_string);

Shouldn't also the omap4_rev_string be renamed to omap_rev_string?

Regards
Simon

author
#199 lore raw

PATCH v3 9/12 omap: add basic SPL support

Hi Simon,

Quoted 9 lines · Simon Schwarz

Hi Aneesh,

Quoted 3 lines · On Sat, 16 Jul 2011 18:23:19 +0530 Aneesh V<[email protected]> wrote:

* omap4_rev_string() reference changed to omap_rev_string()

arch/arm/cpu/armv7/omap-common/spl.c new file +1 -0
+	char omap4_rev_string[50];

[snip]

Quoted 7 lines

arch/arm/cpu/armv7/omap-common/spl.c line 81

Quoted 5 lines
(quoted diff) +1 -0
+	printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev,

U_BOOT_DATE,

arch/arm/cpu/armv7/omap-common/spl.c new file +3 -0
+		U_BOOT_TIME);
+	omap_rev_string(omap4_rev_string);
+	printf("Texas Instruments %s\n", omap4_rev_string);

Shouldn't also the omap4_rev_string be renamed to omap_rev_string?

Just the name of the local variable. But will fix it anyway in the next revision.

br,
Aneesh

author
#200 lore raw

PATCH v3 10/12 Correct ih_os for u-boot.img

In reply to Aneesh V

Provide appropriate '-O u-boot' while doing mkimage for u-boot.img

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index 0707036..f8ae883 100644
@@ -375,7 +375,7 @@ $(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
 
 $(obj)u-boot.img:	$(obj)u-boot.bin
 		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
-		-a $(CONFIG_SYS_TEXT_BASE) -e 0 \
+		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
Signature · 1 line
1.7.0.4
author
#201 lore raw

PATCH v3 11/12 omap: add MMC and FAT support to SPL

In reply to Aneesh V

- Add MMC raw and FAT mode boot support for OMAP
- Provide a means by which parameters passed by ROM-code can be saved in u-boot.
- Save boot mode related information passed by OMAP4 ROM-code and use it to determine where to load the u-boot from
- Assumes that the image has a mkimage header. Gets the payload size and load address from this header. If the header is not detected assume u-boot.bin as payload

---
V3:
* Squashed the patches that provided MMC support, FAT support, start.S hook for saving parameters, and OMAP4 patch for saving the parameters all into this patch.
* Removed the assumption that payload is u-boot.bin. Payload size and address

---
 arch/arm/cpu/armv7/cpu.c                 |    7 +
 arch/arm/cpu/armv7/omap-common/spl.c     |  194 +++++++++++++++++++++++++++++-
 arch/arm/cpu/armv7/omap4/board.c         |   21 ++++
 arch/arm/cpu/armv7/omap4/lowlevel_init.S |   31 +++++
 arch/arm/cpu/armv7/start.S               |    1 +
 arch/arm/include/asm/arch-omap4/omap4.h  |    8 ++
 arch/arm/include/asm/omap_common.h       |   17 +++
 include/configs/omap4_panda.h            |    5 +
 include/configs/omap4_sdp4430.h          |    5 +
 9 files changed, 287 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/cpu.c +7 -0
index def9ced..091e3e0 100644
@@ -37,6 +37,13 @@
 #include <asm/cache.h>
 #include <asm/armv7.h>
 
+void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
+{
+}
+
+void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
+	__attribute__((weak, alias("save_boot_params_default")));
+
 int cleanup_before_linux(void)
 {
 	/*
arch/arm/cpu/armv7/omap-common/spl.c +192 -2

217 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/board.c +21 -0
index 54dd509..2e5739a 100644
@@ -39,6 +39,27 @@ DECLARE_GLOBAL_DATA_PTR;
 
 u32 *const omap4_revision = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
 
+#ifdef CONFIG_SPL_BUILD
+/*
+ * We use static variables because global data is not ready yet.
+ * Initialized data is available in SPL right from the beginning.
+ * We would not typically need to save these parameters in regular
+ * U-Boot. This is needed only in SPL at the moment.
+ */
+u32 omap4_boot_device = BOOT_DEVICE_MMC1;
+u32 omap4_boot_mode = MMCSD_MODE_FAT;
+
+u32 omap_boot_device(void)
+{
+	return omap4_boot_device;
+}
+
+u32 omap_boot_mode(void)
+{
+	return omap4_boot_mode;
+}
+#endif
+
 void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
 {
 	int i;
arch/arm/cpu/armv7/omap4/lowlevel_init.S +31 -0
index 6abfbba..91525ec 100644
@@ -27,6 +27,37 @@
  */
 
 #include <asm/arch/omap4.h>
+#ifdef CONFIG_SPL_BUILD
+.global save_boot_params
+save_boot_params:
+	/*
+	 * See if the rom code passed pointer is valid:
+	 * It is not valid if it is not in non-secure SRAM
+	 * This may happen if you are booting with the help of
+	 * debugger
+	 */
+	ldr     r2, =NON_SECURE_SRAM_START
+	cmp	r2, r0
+	bgt	1f
+	ldr	r2, =NON_SECURE_SRAM_END
+	cmp	r2, r0
+	blt	1f
+
+	/* Store the boot device in omap4_boot_device */
+	ldr     r2, [r0, #BOOT_DEVICE_OFFSET]	@ r1 <- value of boot device
+	and	r2, #BOOT_DEVICE_MASK
+	ldr	r3, =omap4_boot_device
+	str     r2, [r3]			@ omap4_boot_device <- r1
+
+	/* Store the boot mode (raw/FAT) in omap4_boot_mode */
+	ldr	r2, [r0, #DEV_DESC_PTR_OFFSET]	@ get the device descriptor ptr
+	ldr	r2, [r2, #DEV_DATA_PTR_OFFSET]	@ get the pDeviceData ptr
+	ldr	r2, [r2, #BOOT_MODE_OFFSET]	@ get the boot mode
+	ldr	r3, =omap4_boot_mode
+	str	r2, [r3]
+1:
+	bx	lr
+#endif
 
 .globl lowlevel_init
 lowlevel_init:
arch/arm/cpu/armv7/start.S +1 -0
index 5be436f..89ea01f 100644
@@ -134,6 +134,7 @@ IRQ_STACK_START_IN:
  */
 
 reset:
+	bl	save_boot_params
 	/*
 	 * set the cpu to SVC32 mode
 	 */
arch/arm/include/asm/arch-omap4/omap4.h +8 -0
index a8dbedb..563544f 100644
@@ -144,4 +144,12 @@ struct s32ktimer {
 #define OMAP4430_ES2_2	0x44300220
 #define OMAP4430_ES2_3	0x44300230
 
+/* ROM code defines */
+/* Boot device */
+#define BOOT_DEVICE_MASK	0xFF
+#define BOOT_DEVICE_OFFSET	0x8
+#define DEV_DESC_PTR_OFFSET	0x4
+#define DEV_DATA_PTR_OFFSET	0x18
+#define BOOT_MODE_OFFSET	0x8
+
 #endif
arch/arm/include/asm/omap_common.h +17 -0
index 69d53d2..d3cb857 100644
@@ -36,4 +36,21 @@
 
 void preloader_console_init(void);
 
+/* Boot device */
+#define BOOT_DEVICE_NONE	0
+#define BOOT_DEVICE_XIP		1
+#define BOOT_DEVICE_XIPWAIT	2
+#define BOOT_DEVICE_NAND	3
+#define BOOT_DEVICE_ONE_NAND	4
+#define BOOT_DEVICE_MMC1	5
+#define BOOT_DEVICE_MMC2	6
+
+/* Boot type */
+#define	MMCSD_MODE_UNDEFINED	0
+#define MMCSD_MODE_RAW		1
+#define MMCSD_MODE_FAT		2
+
+u32 omap_boot_device(void);
+u32 omap_boot_mode(void);
+
 #endif /* _OMAP_COMMON_H_ */
include/configs/omap4_panda.h +5 -0
index 3244fc1..310c353 100644
@@ -252,6 +252,11 @@
 #define CONFIG_SYS_SPL_BSS_START_ADDR		0x80000000
 #define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
 
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x300 /* address 0x60000 */
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
include/configs/omap4_sdp4430.h +5 -0
index 5c486c3..57ffb3c 100644
@@ -258,6 +258,11 @@
 #define CONFIG_SYS_SPL_BSS_START_ADDR		0x80000000
 #define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
 
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x300 /* address 0x60000 */
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
Signature · 1 line
1.7.0.4
author
#202 lore raw

PATCH v3 12/12 mkimage: Add OMAP boot image support

In reply to Aneesh V

From: John Rigby <[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2

---
 arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
 common/image.c                     |    9 +-
 include/image.h                    |    1 +
 spl/Makefile                       |    6 +
 tools/Makefile                     |    2 +
 tools/mkimage.c                    |    2 +
 tools/mkimage.h                    |    1 +
 tools/omapimage.c                  |  224 ++++++++++++++++++++++++++++++++++++
 tools/omapimage.h                  |   50 ++++++++
 9 files changed, 321 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/config.mk
 create mode 100644 tools/omapimage.c
 create mode 100644 tools/omapimage.h
arch/arm/cpu/armv7/omap4/config.mk new file +30 -0
new file mode 100644
index 0000000..b34fa64
@@ -0,0 +1,30 @@
+#
+# Copyright 2011 Linaro Limited
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# (C) Copyright 2010
+# Texas Instruments, <www.ti.com>
+#
+# Aneesh V <[email protected]>
+#
+# 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
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y	+= $(OBJTREE)/MLO
+else
+ALL-y	+= $(obj)u-boot.img
+endif
common/image.c +5 -4
index e542a57..a141904 100644
@@ -130,17 +130,18 @@ static const table_entry_t uimage_os[] = {
 };
 
 static const table_entry_t uimage_type[] = {
-	{	IH_TYPE_INVALID,    NULL,	  "Invalid Image",	},
 	{	IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image",	},
 	{	IH_TYPE_FIRMWARE,   "firmware",	  "Firmware",		},
+	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
+	{	IH_TYPE_INVALID,    NULL,	  "Invalid Image",	},
+	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	IH_TYPE_KERNEL,	    "kernel",	  "Kernel Image",	},
+	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
 	{	IH_TYPE_MULTI,	    "multi",	  "Multi-File Image",	},
+	{	IH_TYPE_OMAPIMAGE,  "omapimage",  "TI OMAP SPL With GP CH",},
 	{	IH_TYPE_RAMDISK,    "ramdisk",	  "RAMDisk Image",	},
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
-	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
-	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
-	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
include/image.h +1 -0
index c31e862..c606644 100644
@@ -157,6 +157,7 @@
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
 #define IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
 #define IH_TYPE_IMXIMAGE	10	/* Freescale IMXBoot Image	*/
+#define IH_TYPE_OMAPIMAGE	11	/* TI OMAP Config Header Image	*/
 
 /*
  * Compression Types
spl/Makefile +6 -0
index fda4049..b9f4232 100644
@@ -85,6 +85,12 @@ LDPPFLAGS += \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
+ifdef CONFIG_OMAP
+$(OBJTREE)/MLO:	$(obj)u-boot-spl.bin
+	$(OBJTREE)/tools/mkimage -T omapimage \
+		-a $(CONFIG_SYS_SPL_TEXT_BASE) -d $< $@
+endif
+
 ALL-y	+= $(obj)u-boot-spl.bin
 
 all:	$(ALL-y)
tools/Makefile +2 -0
index 97f83f8..cb7f92d 100644
@@ -88,6 +88,7 @@ OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
 NOPED_OBJ_FILES-y += kwbimage.o
 NOPED_OBJ_FILES-y += imximage.o
+NOPED_OBJ_FILES-y += omapimage.o
 NOPED_OBJ_FILES-y += mkimage.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
@@ -188,6 +189,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)md5.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \
+			$(obj)omapimage.o \
 			$(obj)sha1.o \
 			$(LIBFDT_OBJS)
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
tools/mkimage.c +2 -0
index 60f7263..b6a7cb7 100644
@@ -156,6 +156,8 @@ main (int argc, char **argv)
 	init_imx_image_type ();
 	/* Init FIT image generation/list support */
 	init_fit_image_type ();
+	/* Init TI OMAP Boot image generation/list support */
+	init_omap_image_type();
 	/* Init Default image generation/list support */
 	init_default_image_type ();
 
tools/mkimage.h +1 -0
index 9033a7d..3b49645 100644
@@ -143,5 +143,6 @@ void init_kwb_image_type (void);
 void init_imx_image_type (void);
 void init_default_image_type (void);
 void init_fit_image_type (void);
+void init_omap_image_type(void);
 
 #endif /* _MKIIMAGE_H_ */
tools/omapimage.c new file +224 -0

224 lines not on this page · raw message

tools/omapimage.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#203 lore raw

v4 cover U-Boot MMC SPL for OMAP4

In reply to Aneesh V

This series adds mmc SPL support for OMAP4. This is essentially an up-streaming effort for TI's x-loader for OMAP4 using the SPL framework

This work partly draws upon previous work done for x-loader by:
Santosh Shilimkar <[email protected]> Rajendra Nayak <[email protected]>
and many others

This series depends on the following series for the new SPL framework:
http://marc.info/?l=u-boot&m=131056990001719&w=2

Features supported:
* Clock init - DPLL locking, clock domains/modules enabling
* SDRAM/DMM initialization
* Mux initialization
* MMC raw read support
* MMC FAT read support

Improvments over x-loader:
* Code completely revamped
* DPLL programming that works for all SYS_CLK frequencies
* Automatic SDRAM identification and initialization
* Board dependent parts(especially mux) deferred to u-boot. So, same SPL will work for Panda and SDP and most likely on any other board that comes along
* Flexible about the payload. Any image with a mkimage header can be loaded.
* The core SPL logic is generic and available for OMAP3/4. So, OMAP3 platforms can easily extend this work to add SPL support for the respective boards.

V2:
* Some fixes in SDRAM init, clock init
* Use of pre-calculated M & N values for DPLL locking instead run-time calculation
* Change in make files to allow reuse of common rules between boards
* Console initialization moved further earlier in the boot allowing traces from even clock initialization code
* Reuse utility macros from a previous series

V3:
* Moved to the new SPL framework
* struct based register access for clock init
* Squashed together related patches as per Wolfgang's suggestions
* Re-organization of code in sdram init for better readability
* SPL loading the payload using mkimage header
* Avoided using custom bit-field accessor macros
* Several other minor changes(documented in respective patches)

V4:
* Changed the CONFIG_SYS_SPL_* config flags to CONFIG_SPL_*
* Changed the name omap4_rev_string used in spl.c as this file is common for OMAP3/4

Aneesh V (11):
omap4: utility function to identify the context of hw init
omap4: cleanup pin mux data
omap4: add OMAP4430 revision check
omap4: add clock support
omap4: add sdram init support
omap4: calculate EMIF register values
omap4: automatic sdram detection
armv7: start.S: fixes and enhancements for SPL
omap: add basic SPL support
Correct ih_os for u-boot.img
omap: add MMC and FAT support to SPL

John Rigby (1):
mkimage: Add OMAP boot image support

 Makefile                                           |    2 +-
 arch/arm/cpu/armv7/Makefile                        |    7 +-
 arch/arm/cpu/armv7/cpu.c                           |    7 +
 arch/arm/cpu/armv7/omap-common/Makefile            |    5 +
 arch/arm/cpu/armv7/omap-common/spl.c               |  272 ++++
 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds      |   62 +
 arch/arm/cpu/armv7/omap-common/utils.c             |   57 +
 arch/arm/cpu/armv7/omap4/Makefile                  |    6 +
 arch/arm/cpu/armv7/omap4/board.c                   |  161 +++-
 arch/arm/cpu/armv7/omap4/clocks.c                  |  842 +++++++++++++
 .../panda => arch/arm/cpu/armv7/omap4}/config.mk   |   25 +-
 arch/arm/cpu/armv7/omap4/emif.c                    | 1305 ++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/lowlevel_init.S           |   31 +
 arch/arm/cpu/armv7/omap4/omap4_mux_data.h          |   76 ++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c            |  282 +++++
 arch/arm/cpu/armv7/start.S                         |   51 +-
 arch/arm/cpu/armv7/u-boot.lds                      |    2 +
 arch/arm/include/asm/arch-omap4/clocks.h           |  664 ++++++++++
 arch/arm/include/asm/arch-omap4/emif.h             | 1034 ++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h            |   52 +-
 arch/arm/include/asm/arch-omap4/sys_proto.h        |   72 ++-
 arch/arm/include/asm/armv7.h                       |    5 +
 arch/arm/include/asm/omap_common.h                 |   56 +
 board/ti/panda/Makefile                            |    2 +
 board/ti/panda/panda.c                             |   25 +-
 board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} |   76 +-
 board/ti/sdp4430/Makefile                          |    2 +
 board/ti/sdp4430/config.mk                         |   31 -
 board/ti/sdp4430/sdp.c                             |   25 +-
 .../{panda/panda.h => sdp4430/sdp4430_mux_data.h}  |  128 +--
 common/image.c                                     |    9 +-
 include/configs/omap4_panda.h                      |   37 +
 include/configs/omap4_sdp4430.h                    |   37 +
 include/image.h                                    |    1 +
 spl/Makefile                                       |    6 +
 tools/Makefile                                     |    2 +
 tools/mkimage.c                                    |    2 +
 tools/mkimage.h                                    |    1 +
 tools/omap/clocks_get_m_n.c                        |  197 +++
 tools/omapimage.c                                  |  224 ++++
 tools/omapimage.h                                  |   50 +
 41 files changed, 5668 insertions(+), 263 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl.c
 create mode 100644 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
 create mode 100644 arch/arm/cpu/armv7/omap-common/utils.c
 create mode 100644 arch/arm/cpu/armv7/omap4/clocks.c
 rename {board/ti/panda => arch/arm/cpu/armv7/omap4}/config.mk (64%)
 create mode 100644 arch/arm/cpu/armv7/omap4/emif.c
 create mode 100644 arch/arm/cpu/armv7/omap4/omap4_mux_data.h
 create mode 100644 arch/arm/cpu/armv7/omap4/sdram_elpida.c
 create mode 100644 arch/arm/include/asm/arch-omap4/clocks.h
 create mode 100644 arch/arm/include/asm/arch-omap4/emif.h
 create mode 100644 arch/arm/include/asm/omap_common.h
 rename board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} (76%)
 delete mode 100644 board/ti/sdp4430/config.mk
 rename board/ti/{panda/panda.h => sdp4430/sdp4430_mux_data.h} (67%)
 create mode 100644 tools/omap/clocks_get_m_n.c
 create mode 100644 tools/omapimage.c
 create mode 100644 tools/omapimage.h
#204 lore raw

v4 cover U-Boot MMC SPL for OMAP4

Quoted 13 lines

Aneesh V (11):
omap4: utility function to identify the context of hw init
omap4: cleanup pin mux data
omap4: add OMAP4430 revision check
omap4: add clock support
omap4: add sdram init support
omap4: calculate EMIF register values
omap4: automatic sdram detection
armv7: start.S: fixes and enhancements for SPL
omap: add basic SPL support
Correct ih_os for u-boot.img
omap: add MMC and FAT support to SPL

Quoted 2 lines

John Rigby (1):
mkimage: Add OMAP boot image support

Patch #8 of this seires does not apply on the current u-boot-ti U-boot-ti now has the updated SPL framework

Please rebase with u-boot-ti and send updated patch sets for both your series.

Regards,
Sandeep

#205 lore raw

v4 cover U-Boot MMC SPL for OMAP4

Hi Sandeep,

Quoted 13 lines · Sandeep
Quoted 13 lines

Aneesh V (11):
? omap4: utility function to identify the context of hw init ? omap4: cleanup pin mux data
? omap4: add OMAP4430 revision check
? omap4: add clock support
? omap4: add sdram init support
? omap4: calculate EMIF register values
? omap4: automatic sdram detection
? armv7: start.S: fixes and enhancements for SPL
? omap: add basic SPL support
? Correct ih_os for u-boot.img
? omap: add MMC and FAT support to SPL

Quoted 6 lines
Quoted 2 lines

John Rigby (1):
? mkimage: Add OMAP boot image support

Patch #8 of this seires does not apply on the current u-boot-ti U-boot-ti now has the updated SPL framework

There was v4 for just two of the patches of the framework series: 2/9 and 5/9.

I think you missed them. Can you correct this?

Quoted 2 lines

Please rebase with u-boot-ti and send updated patch sets for both your series.

Sure. I will do that.

Thanks,
Aneesh

#206 lore raw

v4 cover U-Boot MMC SPL for OMAP4

Quoted 6 lines

There was v4 for just two of the patches of the framework series: 2/9 and 5/9.

I think you missed them. Can you correct this?

Corrected and applied the patches to u-boot-ti

Thanks,
Sandeep

#207 lore raw

v4 cover U-Boot MMC SPL for OMAP4

In reply to Paulraj

Hi Sandeep,

Quoted 13 lines · Sandeep
Quoted 13 lines

Aneesh V (11):
? omap4: utility function to identify the context of hw init ? omap4: cleanup pin mux data
? omap4: add OMAP4430 revision check
? omap4: add clock support
? omap4: add sdram init support
? omap4: calculate EMIF register values
? omap4: automatic sdram detection
? armv7: start.S: fixes and enhancements for SPL
? omap: add basic SPL support
? Correct ih_os for u-boot.img
? omap: add MMC and FAT support to SPL

Quoted 8 lines
Quoted 2 lines

John Rigby (1):
? mkimage: Add OMAP boot image support

Patch #8 of this seires does not apply on the current u-boot-ti U-boot-ti now has the updated SPL framework

Please rebase with u-boot-ti and send updated patch sets for both your series.

I have done my re-basing. Will send out my series shortly. However, please note that u-boot-ti/master is not building for me. You will need this fix:

Fix typo from 'mb_alloc' -> 'lmb_alloc
http://patchwork.ozlabs.org/patch/105364/

best regards,
Aneesh

author
#208 lore raw

PATCH v4 1/12 omap4: utility function to identify the context of hw init

In reply to Aneesh V

The basic hardware init of OMAP4(s_init()) can happen in 4 different contexts:
1. SPL running from SRAM
2. U-Boot running from FLASH
3. Non-XIP U-Boot loaded to SDRAM by SPL
4. Non-XIP U-Boot loaded to SDRAM by ROM code using the Configuration Header feature

What level of hw initialization gets done depends on this context. Add a utility function to find this context.

---
V3:
* Changed the context names to more meaningful names as suggested by WD

---
 arch/arm/include/asm/arch-omap4/sys_proto.h |   49 ++++++++++++++++++++++++++-
 arch/arm/include/asm/omap_common.h          |   34 ++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_common.h
arch/arm/include/asm/arch-omap4/sys_proto.h +48 -1
index 4fa4f4b..6b596b4 100644
@@ -23,10 +23,12 @@
 
 #include <asm/arch/omap4.h>
 #include <asm/io.h>
+#include <asm/omap_common.h>
 
 struct omap_sysinfo {
 	char *board_string;
 };
+extern const struct omap_sysinfo sysinfo;
 
 void gpmc_init(void);
 void watchdog_init(void);
@@ -37,6 +39,51 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 
-extern const struct omap_sysinfo sysinfo;
+static inline u32 running_from_sdram(void)
+{
+	u32 pc;
+	asm volatile ("mov %0, pc" : "=r" (pc));
+	return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
+	    (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
+}
+
+static inline u8 uboot_loaded_by_spl(void)
+{
+	/*
+	 * Configuration Header is not supported yet, so u-boot init running
+	 * from SDRAM implies that it was loaded by SPL. When this situation
+	 * changes one of these approaches could be taken:
+	 * i.  Pass a magic from SPL to U-Boot and U-Boot save it at a known
+	 *     location.
+	 * ii. Check the OPP. CH can support only 50% OPP while SPL initializes
+	 *     the DPLLs@100% OPP.
+	 */
+	return running_from_sdram();
+}
+/*
+ * The basic hardware init of OMAP(s_init()) can happen in 4
+ * different contexts:
+ *  1. SPL running from SRAM
+ *  2. U-Boot running from FLASH
+ *  3. Non-XIP U-Boot loaded to SDRAM by SPL
+ *  4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
+ *     Configuration Header feature
+ *
+ * This function finds this context.
+ * Defining as inline may help in compiling out unused functions in SPL
+ */
+static inline u32 omap4_hw_init_context(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	return OMAP_INIT_CONTEXT_SPL;
+#else
+	if (uboot_loaded_by_spl())
+		return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
+	else if (running_from_sdram())
+		return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
+	else
+		return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
+#endif
+}
 
 #endif
arch/arm/include/asm/omap_common.h new file +34 -0
new file mode 100644
index 0000000..d80f665
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *
+ * Aneesh V <[email protected]>
+ *
+ * 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	_OMAP_COMMON_H_
+#define	_OMAP_COMMON_H_
+
+/* HW Init Context */
+#define OMAP_INIT_CONTEXT_SPL			0
+#define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR	1
+#define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
+#define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
+
+#endif /* _OMAP_COMMON_H_ */
Signature · 1 line
1.7.0.4
author
#209 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

In reply to Aneesh V

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

---
This patch add 33 warnings for lines over 80 characters. However, this for the mux table and improves readability.

V3:
* Squashed two mux related patches into one

---
 arch/arm/cpu/armv7/omap4/board.c                   |   53 ++++++++-
 arch/arm/cpu/armv7/omap4/omap4_mux_data.h          |   76 ++++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h        |    4 +-
 board/ti/panda/panda.c                             |   25 +---
 board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} |   76 +++---------
 board/ti/sdp4430/sdp.c                             |   25 +---
 .../{panda/panda.h => sdp4430/sdp4430_mux_data.h}  |  128 +++++++------------
 7 files changed, 209 insertions(+), 178 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/omap4_mux_data.h
 rename board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} (76%)
 rename board/ti/{panda/panda.h => sdp4430/sdp4430_mux_data.h} (67%)
arch/arm/cpu/armv7/omap4/board.c +50 -3
index de4cc2a..3fd6f84 100644
@@ -31,17 +31,65 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
+#include "omap4_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+{
+	int i;
+	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
+
+	for (i = 0; i < size; i++, pad++)
+		writew(pad->val, base + pad->offset);
+}
+
+static void set_muxconf_regs_essential(void)
+{
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_essential,
+		   sizeof(core_padconf_array_essential) /
+		   sizeof(struct pad_conf_entry));
+
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_essential,
+		   sizeof(wkup_padconf_array_essential) /
+		   sizeof(struct pad_conf_entry));
+}
+
+static void set_mux_conf_regs(void)
+{
+	switch (omap4_hw_init_context()) {
+	case OMAP_INIT_CONTEXT_SPL:
+		set_muxconf_regs_essential();
+		break;
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL:
+		set_muxconf_regs_non_essential();
+		break;
+	case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
+		set_muxconf_regs_essential();
+		set_muxconf_regs_non_essential();
+		break;
+	}
+}
+
 /*
  * Routine: s_init
- * Description: Does early system init of muxing and clocks.
- *              - Called path is with SRAM stack.
+ * Description: Does early system init of watchdog, muxing,  andclocks
+ * Watchdog disable is done always. For the rest what gets done
+ * depends on the boot mode in which this function is executed
+ *   1. s_init of SPL running from SRAM
+ *   2. s_init of U-Boot running from FLASH
+ *   3. s_init of U-Boot loaded to SDRAM by SPL
+ *   4. s_init of U-Boot loaded to SDRAM by ROM code using the
+ *	Configuration Header feature
+ * Please have a look at the respective functions to see what gets
+ * done in each of these cases
+ * This function is called with SRAM stack.
  */
 void s_init(void)
 {
 	watchdog_init();
+	set_mux_conf_regs();
 }
 
 /*
@@ -124,7 +172,6 @@ int checkboard(void)
 */
 int arch_cpu_init(void)
 {
-	set_muxconf_regs();
 	return 0;
 }
 
arch/arm/cpu/armv7/omap4/omap4_mux_data.h new file +76 -0

76 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/sys_proto.h +3 -1
index 6b596b4..3624378 100644
@@ -24,6 +24,7 @@
 #include <asm/arch/omap4.h>
 #include <asm/io.h>
 #include <asm/omap_common.h>
+#include <asm/arch/mux_omap4.h>
 
 struct omap_sysinfo {
 	char *board_string;
@@ -33,7 +34,8 @@ extern const struct omap_sysinfo sysinfo;
 void gpmc_init(void);
 void watchdog_init(void);
 u32 get_device_type(void);
-void set_muxconf_regs(void);
+void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
+void set_muxconf_regs_non_essential(void);
 void sr32(void *, u32, u32, u32);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
board/ti/panda/panda.c +6 -19
index 78e1910..9afed80 100644
@@ -25,7 +25,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
-#include "panda.h"
+#include "panda_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -65,27 +65,14 @@ int misc_init_r(void)
 	return 0;
 }
 
-void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+void set_muxconf_regs_non_essential(void)
 {
-	int i;
-	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
-
-	for (i = 0; i < size; i++, pad++)
-		writew(pad->val, base + pad->offset);
-}
-
-/**
- * @brief set_muxconf_regs Setting up the configuration Mux registers
- * specific to the board.
- */
-void set_muxconf_regs(void)
-{
-	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array,
-		   sizeof(core_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_non_essential,
+		   sizeof(core_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 
-	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array,
-		   sizeof(wkup_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_non_essential,
+		   sizeof(wkup_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 }
 
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +21 -55

156 lines not on this page · raw message

board/ti/sdp4430/sdp.c +6 -19
index b13c4c5..a5ea682 100644
@@ -27,7 +27,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
-#include "sdp.h"
+#include "sdp4430_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -70,27 +70,14 @@ int misc_init_r(void)
 	return 0;
 }
 
-void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+void set_muxconf_regs_non_essential(void)
 {
-	int i;
-	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
-
-	for (i = 0; i < size; i++, pad++)
-		writew(pad->val, base + pad->offset);
-}
-
-/**
- * @brief set_muxconf_regs Setting up the configuration Mux registers
- * specific to the board.
- */
-void set_muxconf_regs(void)
-{
-	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array,
-		   sizeof(core_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_non_essential,
+		   sizeof(core_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 
-	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array,
-		   sizeof(wkup_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_non_essential,
+		   sizeof(wkup_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 }
 
board/ti/sdp4430/sdp4430_mux_data.h renamed from board/ti/panda/panda.h +47 -81

211 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#210 lore raw

PATCH v4 3/12 omap4: add OMAP4430 revision check

In reply to Aneesh V

---
V2:
* Added a revision string in addition to the revision number Helps in printing out the OMAP revision at bootup

V3:
* Improved the revision check function by saving the value instead of finding it every time.
* Improved revision string function by generating it from the revision rather than hard-coding the string per revision

---
 arch/arm/cpu/armv7/omap4/board.c            |   64 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h     |   29 +++++++++---
 arch/arm/include/asm/arch-omap4/sys_proto.h |    7 +++
 arch/arm/include/asm/armv7.h                |    5 ++
 4 files changed, 97 insertions(+), 8 deletions(-)
arch/arm/cpu/armv7/omap4/board.c +64 -0
index 3fd6f84..09861a9 100644
@@ -28,6 +28,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
+#include <asm/armv7.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
@@ -35,6 +36,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+u32 *const omap4_revision = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
+
 void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
 {
 	int i;
@@ -72,6 +75,66 @@ static void set_mux_conf_regs(void)
 	}
 }
 
+static u32 cortex_a9_rev(void)
+{
+
+	unsigned int rev;
+
+	/* Read Main ID Register (MIDR) */
+	asm ("mrc p15, 0, %0, c0, c0, 0" : "=r" (rev));
+
+	return rev;
+}
+
+static void init_omap4_revision(void)
+{
+	/*
+	 * For some of the ES2/ES1 boards ID_CODE is not reliable:
+	 * Also, ES1 and ES2 have different ARM revisions
+	 * So use ARM revision for identification
+	 */
+	unsigned int arm_rev = cortex_a9_rev();
+
+	switch (arm_rev) {
+	case MIDR_CORTEX_A9_R0P1:
+		*omap4_revision = OMAP4430_ES1_0;
+		break;
+	case MIDR_CORTEX_A9_R1P2:
+		switch (readl(CONTROL_ID_CODE)) {
+		case OMAP4_CONTROL_ID_CODE_ES2_0:
+			*omap4_revision = OMAP4430_ES2_0;
+			break;
+		case OMAP4_CONTROL_ID_CODE_ES2_1:
+			*omap4_revision = OMAP4430_ES2_1;
+			break;
+		case OMAP4_CONTROL_ID_CODE_ES2_2:
+			*omap4_revision = OMAP4430_ES2_2;
+			break;
+		default:
+			*omap4_revision = OMAP4430_ES2_0;
+			break;
+		}
+		break;
+	case MIDR_CORTEX_A9_R1P3:
+		*omap4_revision = OMAP4430_ES2_3;
+		break;
+	default:
+		*omap4_revision = OMAP4430_SILICON_ID_INVALID;
+		break;
+	}
+}
+
+void omap_rev_string(char *omap4_rev_string)
+{
+	u32 omap4_rev = omap_revision();
+	u32 omap4_variant = (omap4_rev & 0xFFFF0000) >> 16;
+	u32 major_rev = (omap4_rev & 0x00000F00) >> 8;
+	u32 minor_rev = (omap4_rev & 0x000000F0) >> 4;
+
+	sprintf(omap4_rev_string, "OMAP%x ES%x.%x", omap4_variant, major_rev,
+		minor_rev);
+}
+
 /*
  * Routine: s_init
  * Description: Does early system init of watchdog, muxing,  andclocks
@@ -88,6 +151,7 @@ static void set_mux_conf_regs(void)
  */
 void s_init(void)
 {
+	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
 }
arch/arm/include/asm/arch-omap4/omap4.h +21 -8
index a30bb33..76b06c2 100644
@@ -51,6 +51,15 @@
 #define CONTROL_PADCONF_CORE	(OMAP44XX_L4_CORE_BASE + 0x100000)
 #define CONTROL_PADCONF_WKUP	(OMAP44XX_L4_CORE_BASE + 0x31E000)
 
+/* CONTROL_ID_CODE */
+#define CONTROL_ID_CODE		0x4A002204
+
+#define OMAP4_CONTROL_ID_CODE_ES1_0	0x0B85202F
+#define OMAP4_CONTROL_ID_CODE_ES2_0	0x1B85202F
+#define OMAP4_CONTROL_ID_CODE_ES2_1	0x3B95C02F
+#define OMAP4_CONTROL_ID_CODE_ES2_2	0x4B95C02F
+#define OMAP4_CONTROL_ID_CODE_ES2_3	0x6B95C02F
+
 /* UART */
 #define UART1_BASE		(OMAP44XX_L4_PER_BASE + 0x6a000)
 #define UART2_BASE		(OMAP44XX_L4_PER_BASE + 0x6c000)
@@ -119,13 +128,17 @@ struct s32ktimer {
 /* base address for indirect vectors (internal boot mode) */
 #define SRAM_ROM_VECT_BASE	0x4030D000
 /* Temporary SRAM stack used while low level init is done */
-#define LOW_LEVEL_SRAM_STACK	NON_SECURE_SRAM_END
-
-/*
- * OMAP4 real hardware:
- * TODO: Change this to the IDCODE in the hw regsiter
- */
-#define CPU_OMAP4430_ES10	1
-#define CPU_OMAP4430_ES20	2
+#define LOW_LEVEL_SRAM_STACK		NON_SECURE_SRAM_END
+#define SRAM_SCRATCH_SPACE_ADDR		NON_SECURE_SRAM_START
+/* SRAM scratch space entries */
+#define OMAP4_SRAM_SCRATCH_OMAP4_REV	SRAM_SCRATCH_SPACE_ADDR
+
+/* Silicon revisions */
+#define OMAP4430_SILICON_ID_INVALID	0xFFFFFFFF
+#define OMAP4430_ES1_0	0x44300100
+#define OMAP4430_ES2_0	0x44300200
+#define OMAP4430_ES2_1	0x44300210
+#define OMAP4430_ES2_2	0x44300220
+#define OMAP4430_ES2_3	0x44300230
 
 #endif
arch/arm/include/asm/arch-omap4/sys_proto.h +7 -0
index 3624378..c10fa18 100644
@@ -40,6 +40,7 @@ void sr32(void *, u32, u32, u32);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
+void omap_rev_string(char *omap4_rev_string);
 
 static inline u32 running_from_sdram(void)
 {
@@ -88,4 +89,10 @@ static inline u32 omap4_hw_init_context(void)
 #endif
 }
 
+static inline u32 omap_revision(void)
+{
+	extern u32 *const omap4_revision;
+	return *omap4_revision;
+}
+
 #endif
arch/arm/include/asm/armv7.h +5 -0
index 88b9c62..b5784d8 100644
@@ -25,6 +25,11 @@
 #define ARMV7_H
 #include <linux/types.h>
 
+/* Cortex-A9 revisions */
+#define MIDR_CORTEX_A9_R0P1	0x410FC091
+#define MIDR_CORTEX_A9_R1P2	0x411FC092
+#define MIDR_CORTEX_A9_R1P3	0x411FC093
+
 /* CCSIDR */
 #define CCSIDR_LINE_SIZE_OFFSET		0
 #define CCSIDR_LINE_SIZE_MASK		0x7
Signature · 1 line
1.7.0.4
author
#211 lore raw

PATCH v4 4/12 omap4: add clock support

In reply to Aneesh V

Add support for:
1. DPLL locking
2. Initialization of clock domains and clock modules
3. Setting up the right voltage on voltage rails

This work draws upon previous work done for x-loader by:
Santosh Shilimkar <[email protected]> Rajendra Nayak <[email protected]>

---
V2:
* Use pre-calculated M & N values instead of calculated ones
* Changes due to make file changes
* Some corrections
* Do all clock initialization in SPL itself instead of differing some work to u-boot

V3:
* Use struct for register addressing
* Support only Turbo OPP for MPU. OPP's above this need Smart Reflex enabled
* Cleaned up the scale_vcore(). Now takes into account the differing voltage offsets for different revisions of Phoenix.
* Removed references to deprecated utility functions - modify_reg_32() etc.
* Changed all spl_debug() to debug()
* Moved the host-program for calculating DPLL multiplier/divider to tools/omap/ directory. Added more documentation
* Replaced calls to omap4_revision() with omap_revision()
* Some changes to IVA and ABE dpll locking code

---
 arch/arm/cpu/armv7/omap4/Makefile           |    1 +
 arch/arm/cpu/armv7/omap4/board.c            |    1 +
 arch/arm/cpu/armv7/omap4/clocks.c           |  809 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/clocks.h    |  664 ++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h |    8 +
 arch/arm/include/asm/omap_common.h          |    3 +
 tools/omap/clocks_get_m_n.c                 |  197 +++++++
 7 files changed, 1683 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/clocks.c
 create mode 100644 arch/arm/include/asm/arch-omap4/clocks.h
 create mode 100644 tools/omap/clocks_get_m_n.c
arch/arm/cpu/armv7/omap4/Makefile +1 -0
index 987dc9d..ac4b2a6 100644
@@ -28,6 +28,7 @@ LIB	=  $(obj)lib$(SOC).o
 SOBJS	+= lowlevel_init.o
 
 COBJS	+= board.o
+COBJS	+= clocks.o
 COBJS	+= mem.o
 COBJS	+= sys_info.o
 
arch/arm/cpu/armv7/omap4/board.c +1 -0
index 09861a9..1c26a66 100644
@@ -154,6 +154,7 @@ void s_init(void)
 	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
+	prcm_init();
 }
 
 /*
arch/arm/cpu/armv7/omap4/clocks.c new file +809 -0

809 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/clocks.h new file +664 -0

664 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/sys_proto.h +8 -0
index c10fa18..f871921 100644
@@ -22,6 +22,7 @@
 #define _SYS_PROTO_H_
 
 #include <asm/arch/omap4.h>
+#include <asm/arch/clocks.h>
 #include <asm/io.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mux_omap4.h>
@@ -31,6 +32,8 @@ struct omap_sysinfo {
 };
 extern const struct omap_sysinfo sysinfo;
 
+extern struct omap4_prcm_regs *const prcm;
+
 void gpmc_init(void);
 void watchdog_init(void);
 u32 get_device_type(void);
@@ -41,6 +44,11 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 void omap_rev_string(char *omap4_rev_string);
+void prcm_init(void);
+void bypass_dpll(u32 *const base);
+void freq_update_core(void);
+u32 get_sys_clk_freq(void);
+u32 omap4_ddr_clk(void);
 
 static inline u32 running_from_sdram(void)
 {
arch/arm/include/asm/omap_common.h +3 -0
index d80f665..33caa4e 100644
@@ -25,6 +25,9 @@
 #ifndef	_OMAP_COMMON_H_
 #define	_OMAP_COMMON_H_
 
+/* Max value for DPLL multiplier M */
+#define OMAP_DPLL_MAX_N	127
+
 /* HW Init Context */
 #define OMAP_INIT_CONTEXT_SPL			0
 #define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR	1
tools/omap/clocks_get_m_n.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#212 lore raw

PATCH v4 5/12 omap4: add sdram init support

In reply to Aneesh V

Add support for the SDRAM controller (EMIF).

---
V2:
* Minor corrections in do_lpddr2_init()
* Minor corrections to read_idle interval calculation
* Sanity test of memory after doing the initialization
* Fixed warnings reported with with latest GCC compilers V3:
* Removed references to modify_reg_32()
* Updated references to OMAP_INIT_CONTEXT_* flags
* Replaced calls to omap4_revision() with omap_revision()
* Replaced sanity test with get_ram_size()

---
 arch/arm/cpu/armv7/omap4/Makefile           |    2 +
 arch/arm/cpu/armv7/omap4/board.c            |    6 +-
 arch/arm/cpu/armv7/omap4/emif.c             |  328 +++++++++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c     |  131 ++++
 arch/arm/include/asm/arch-omap4/clocks.h    |    8 +-
 arch/arm/include/asm/arch-omap4/emif.h      | 1025 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h     |    5 +
 arch/arm/include/asm/arch-omap4/sys_proto.h |    2 +
 8 files changed, 1500 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/emif.c
 create mode 100644 arch/arm/cpu/armv7/omap4/sdram_elpida.c
 create mode 100644 arch/arm/include/asm/arch-omap4/emif.h
arch/arm/cpu/armv7/omap4/Makefile +2 -0
index ac4b2a6..e1ccd68 100644
@@ -29,7 +29,9 @@ SOBJS	+= lowlevel_init.o
 
 COBJS	+= board.o
 COBJS	+= clocks.o
+COBJS	+= emif.o
 COBJS	+= mem.o
+COBJS	+= sdram_elpida.o
 COBJS	+= sys_info.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/omap4/board.c +3 -3
index 1c26a66..ca107f7 100644
@@ -189,7 +189,7 @@ void watchdog_init(void)
  * This is needed because the size of memory installed may be
  * different on different versions of the board
  */
-u32 sdram_size(void)
+u32 omap4_sdram_size(void)
 {
 	u32 section, i, total_size = 0, size, addr;
 	for (i = 0; i < 4; i++) {
@@ -215,8 +215,8 @@ u32 sdram_size(void)
  */
 int dram_init(void)
 {
-
-	gd->ram_size = sdram_size();
+	sdram_init();
+	gd->ram_size = omap4_sdram_size();
 
 	return 0;
 }
arch/arm/cpu/armv7/omap4/emif.c new file +328 -0

328 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/sdram_elpida.c new file +131 -0

131 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/clocks.h +4 -4
index 71db39c..37bdcee 100644
@@ -33,10 +33,10 @@
  */
 #define LDELAY		1000000
 
-#define CM_CLKMODE_DPLL_CORE		(OMAP44XX_L4_CORE_BASE + 0x4120)
-#define CM_CLKMODE_DPLL_PER		(OMAP44XX_L4_CORE_BASE + 0x8140)
-#define CM_CLKMODE_DPLL_MPU		(OMAP44XX_L4_CORE_BASE + 0x4160)
-#define CM_CLKSEL_CORE			(OMAP44XX_L4_CORE_BASE + 0x4100)
+#define CM_CLKMODE_DPLL_CORE		0x4A004120
+#define CM_CLKMODE_DPLL_PER		0x4A008140
+#define CM_CLKMODE_DPLL_MPU		0x4A004160
+#define CM_CLKSEL_CORE			0x4A004100
 
 struct omap4_prcm_regs {
 	/* cm1.ckgen */
arch/arm/include/asm/arch-omap4/emif.h new file +1025 -0

1,025 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/omap4.h +5 -0
index 76b06c2..c9c86e1 100644
@@ -51,6 +51,11 @@
 #define CONTROL_PADCONF_CORE	(OMAP44XX_L4_CORE_BASE + 0x100000)
 #define CONTROL_PADCONF_WKUP	(OMAP44XX_L4_CORE_BASE + 0x31E000)
 
+/* LPDDR2 IO regs */
+#define LPDDR2_IO_REGS_BASE	0x4A100638
+
+#define CONTROL_EFUSE_2		0x4A100704
+
 /* CONTROL_ID_CODE */
 #define CONTROL_ID_CODE		0x4A002204
 
arch/arm/include/asm/arch-omap4/sys_proto.h +2 -0
index f871921..7183a90 100644
@@ -49,6 +49,8 @@ void bypass_dpll(u32 *const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
 u32 omap4_ddr_clk(void);
+void sdram_init(void);
+u32 omap4_sdram_size(void);
 
 static inline u32 running_from_sdram(void)
 {
Signature · 1 line
1.7.0.4
author
#213 lore raw

PATCH v4 6/12 omap4: calculate EMIF register values

In reply to Aneesh V

Calculate EMIF register values based on AC timing parameters from the SDRAM datasheet and the DDR frequency rather than using the hard-coded values.

For a new board the user doen't have to go through the tedious process of calculating the register values. Instead, just provide the AC timings from the device data sheet as input and the driver will automatically calculate the register values.

---
V3:
* Added SDRAM init related CONFIG flags for Panda too. Earlier Panda support for everything was added in a single patch at the end
* Replaced calls to omap4_revision() with omap_revision()
* Reorganization of code for better readability
* Some code re-organization to reduce #ifdef complexities - cleanly separated out functions for getting device details (geometry) vs timings
* Ensured un-necessary code is compiled out if CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REG is defined

---
 arch/arm/cpu/armv7/omap-common/Makefile     |    1 +
 arch/arm/cpu/armv7/omap-common/utils.c      |   57 ++
 arch/arm/cpu/armv7/omap4/board.c            |    9 +-
 arch/arm/cpu/armv7/omap4/emif.c             |  739 +++++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c     |  151 ++++++
 arch/arm/include/asm/arch-omap4/emif.h      |    9 +
 arch/arm/include/asm/arch-omap4/omap4.h     |   10 +-
 arch/arm/include/asm/arch-omap4/sys_proto.h |    1 +
 include/configs/omap4_panda.h               |    5 +
 include/configs/omap4_sdp4430.h             |    5 +
 10 files changed, 977 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/utils.c
arch/arm/cpu/armv7/omap-common/Makefile +1 -0
index dc01ee5..8f698f8 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)libomap-common.o
 SOBJS	:= reset.o
 
 COBJS	:= timer.o
+COBJS	+= utils.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/arm/cpu/armv7/omap-common/utils.c new file +57 -0

57 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/board.c +5 -4
index ca107f7..786c239 100644
@@ -32,6 +32,7 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
+#include <asm/arch/emif.h>
 #include "omap4_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -193,13 +194,13 @@ u32 omap4_sdram_size(void)
 {
 	u32 section, i, total_size = 0, size, addr;
 	for (i = 0; i < 4; i++) {
-		section	= __raw_readl(DMM_LISA_MAP_BASE + i*4);
-		addr = section & DMM_LISA_MAP_SYS_ADDR_MASK;
+		section	= __raw_readl(OMAP44XX_DMM_LISA_MAP_BASE + i*4);
+		addr = section & OMAP44XX_SYS_ADDR_MASK;
 		/* See if the address is valid */
 		if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
 		    (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
-			size	= ((section & DMM_LISA_MAP_SYS_SIZE_MASK) >>
-				    DMM_LISA_MAP_SYS_SIZE_SHIFT);
+			size	= ((section & OMAP44XX_SYS_SIZE_MASK) >>
+				   OMAP44XX_SYS_SIZE_SHIFT);
 			size	= 1 << size;
 			size	*= SZ_16M;
 			total_size += size;
arch/arm/cpu/armv7/omap4/emif.c +739 -0

764 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/sdram_elpida.c +151 -0

160 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/emif.h +9 -0
index 09e9baa..a167508 100644
@@ -1019,7 +1019,16 @@ struct emif_regs {
 #define emif_assert(c)	({ if (0) hang(); })
 #endif
 
+#ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
+#else
+void emif_get_device_details(u32 emif_nr,
+		struct lpddr2_device_details *cs0_device_details,
+		struct lpddr2_device_details *cs1_device_details);
+void emif_get_device_timings(u32 emif_nr,
+		const struct lpddr2_device_timings **cs0_device_timings,
+		const struct lpddr2_device_timings **cs1_device_timings);
+#endif
 
 #endif
arch/arm/include/asm/arch-omap4/omap4.h +4 -6
index c9c86e1..a8dbedb 100644
@@ -84,12 +84,6 @@
 /* GPMC */
 #define OMAP44XX_GPMC_BASE	0x50000000
 
-/* DMM */
-#define OMAP44XX_DMM_BASE		0x4E000000
-#define DMM_LISA_MAP_BASE		(OMAP44XX_DMM_BASE + 0x40)
-#define DMM_LISA_MAP_SYS_SIZE_MASK	(7 << 20)
-#define DMM_LISA_MAP_SYS_SIZE_SHIFT	20
-#define DMM_LISA_MAP_SYS_ADDR_MASK	(0xFF << 24)
 /*
  * Hardware Register Details
  */
@@ -137,6 +131,10 @@ struct s32ktimer {
 #define SRAM_SCRATCH_SPACE_ADDR		NON_SECURE_SRAM_START
 /* SRAM scratch space entries */
 #define OMAP4_SRAM_SCRATCH_OMAP4_REV	SRAM_SCRATCH_SPACE_ADDR
+#define OMAP4_SRAM_SCRATCH_EMIF_SIZE	(SRAM_SCRATCH_SPACE_ADDR + 0x4)
+#define OMAP4_SRAM_SCRATCH_EMIF_T_NUM	(SRAM_SCRATCH_SPACE_ADDR + 0xC)
+#define OMAP4_SRAM_SCRATCH_EMIF_T_DEN	(SRAM_SCRATCH_SPACE_ADDR + 0x10)
+#define OMAP4_SRAM_SCRATCH_SPACE_END	(SRAM_SCRATCH_SPACE_ADDR + 0x14)
 
 /* Silicon revisions */
 #define OMAP4430_SILICON_ID_INVALID	0xFFFFFFFF
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
index 7183a90..1e62878 100644
@@ -49,6 +49,7 @@ void bypass_dpll(u32 *const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
 u32 omap4_ddr_clk(void);
+void cancel_out(u32 *num, u32 *den, u32 den_limit);
 void sdram_init(void);
 u32 omap4_sdram_size(void);
 
include/configs/omap4_panda.h +5 -0
index 1daffb7..9f82ef4 100644
@@ -237,4 +237,9 @@
 #define CONFIG_SYS_PL310_BASE	0x48242000
 #endif
 
+/* Defines for SDRAM init */
+#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
+#endif
+
 #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +5 -0
index 68ffa87..6df1c3d 100644
@@ -243,4 +243,9 @@
 #define CONFIG_SYS_PL310_BASE	0x48242000
 #endif
 
+/* Defines for SDRAM init */
+#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
+#endif
+
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
author
#214 lore raw

PATCH v4 7/12 omap4: automatic sdram detection

In reply to Aneesh V

Identify SDRAM devices connected to EMIF automatically:
LPDDR2 devices have some Mode Registers that provide details about the device such as the type, density, bus width etc. EMIF has the capability to read these registers. If there are no devices connected to a given chip-select reading mode registers will return junk values. After reading as many such registers as possible and matching with expected ranges of values the driver can identify if there is a device connected to the respective CS. If we identify that a device is connected the values read give us complete details about the device.

This along with the base AC timings specified by JESD209-2 allows us to do a complete automatic initialization of SDRAM that works on all boards.

Please note that the default AC timings specified by JESD209-2 will be safe for all devices but not necessarily optimal. However, for the Elpida devices used on Panda and SDP the default timings are both safe and optimal.

---
V3:
* Code re-organization for better readability
* Ensured that un-necessary code is compiled out when CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION is not defined

---
 arch/arm/cpu/armv7/omap4/emif.c |  238 +++++++++++++++++++++++++++++++++++++++
 include/configs/omap4_panda.h   |    1 +
 include/configs/omap4_sdp4430.h |    1 +
 3 files changed, 240 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/omap4/emif.c +238 -0
index ceead9e..1234a7e 100644
@@ -792,6 +792,244 @@ void emif_get_device_timings(u32 emif_nr,
 }
 #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */
 
+#ifdef CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
+const char *get_lpddr2_type(u8 type_id)
+{
+	switch (type_id) {
+	case LPDDR2_TYPE_S4:
+		return "LPDDR2-S4";
+	case LPDDR2_TYPE_S2:
+		return "LPDDR2-S2";
+	default:
+		return NULL;
+	}
+}
+
+const char *get_lpddr2_io_width(u8 width_id)
+{
+	switch (width_id) {
+	case LPDDR2_IO_WIDTH_8:
+		return "x8";
+	case LPDDR2_IO_WIDTH_16:
+		return "x16";
+	case LPDDR2_IO_WIDTH_32:
+		return "x32";
+	default:
+		return NULL;
+	}
+}
+
+const char *get_lpddr2_manufacturer(u32 manufacturer)
+{
+	switch (manufacturer) {
+	case LPDDR2_MANUFACTURER_SAMSUNG:
+		return "Samsung";
+	case LPDDR2_MANUFACTURER_QIMONDA:
+		return "Qimonda";
+	case LPDDR2_MANUFACTURER_ELPIDA:
+		return "Elpida";
+	case LPDDR2_MANUFACTURER_ETRON:
+		return "Etron";
+	case LPDDR2_MANUFACTURER_NANYA:
+		return "Nanya";
+	case LPDDR2_MANUFACTURER_HYNIX:
+		return "Hynix";
+	case LPDDR2_MANUFACTURER_MOSEL:
+		return "Mosel";
+	case LPDDR2_MANUFACTURER_WINBOND:
+		return "Winbond";
+	case LPDDR2_MANUFACTURER_ESMT:
+		return "ESMT";
+	case LPDDR2_MANUFACTURER_SPANSION:
+		return "Spansion";
+	case LPDDR2_MANUFACTURER_SST:
+		return "SST";
+	case LPDDR2_MANUFACTURER_ZMOS:
+		return "ZMOS";
+	case LPDDR2_MANUFACTURER_INTEL:
+		return "Intel";
+	case LPDDR2_MANUFACTURER_NUMONYX:
+		return "Numonyx";
+	case LPDDR2_MANUFACTURER_MICRON:
+		return "Micron";
+	default:
+		return NULL;
+	}
+}
+
+static void display_sdram_details(u32 emif_nr, u32 cs,
+				  struct lpddr2_device_details *device)
+{
+	const char *mfg_str;
+	const char *type_str;
+	char density_str[10];
+	u32 density;
+
+	debug("EMIF%d CS%d\t", emif_nr, cs);
+
+	if (!device) {
+		debug("None\n");
+		return;
+	}
+
+	mfg_str = get_lpddr2_manufacturer(device->manufacturer);
+	type_str = get_lpddr2_type(device->type);
+
+	density = lpddr2_density_2_size_in_mbytes[device->density];
+	if ((density / 1024 * 1024) == density) {
+		density /= 1024;
+		sprintf(density_str, "%d GB", density);
+	} else
+		sprintf(density_str, "%d MB", density);
+	if (mfg_str && type_str)
+		debug("%s\t\t%s\t%s\n", mfg_str, type_str, density_str);
+}
+
+static u8 is_lpddr2_sdram_present(u32 base, u32 cs,
+				  struct lpddr2_device_details *lpddr2_device)
+{
+	u32 mr = 0, temp;
+
+	mr = get_mr(base, cs, LPDDR2_MR0);
+	if (mr > 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	temp = (mr & LPDDR2_MR0_DI_MASK) >> LPDDR2_MR0_DI_SHIFT;
+	if (temp) {
+		/* Not SDRAM */
+		return 0;
+	}
+	temp = (mr & LPDDR2_MR0_DNVI_MASK) >> LPDDR2_MR0_DNVI_SHIFT;
+
+	if (temp) {
+		/* DNV supported - But DNV is only supported for NVM */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR4);
+	if (mr > 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR5);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	if (!get_lpddr2_manufacturer(mr)) {
+		/* Manufacturer not identified */
+		return 0;
+	}
+	lpddr2_device->manufacturer = mr;
+
+	mr = get_mr(base, cs, LPDDR2_MR6);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR7);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR8);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	temp = (mr & MR8_TYPE_MASK) >> MR8_TYPE_SHIFT;
+	if (!get_lpddr2_type(temp)) {
+		/* Not SDRAM */
+		return 0;
+	}
+	lpddr2_device->type = temp;
+
+	temp = (mr & MR8_DENSITY_MASK) >> MR8_DENSITY_SHIFT;
+	if (temp > LPDDR2_DENSITY_32Gb) {
+		/* Density not supported */
+		return 0;
+	}
+	lpddr2_device->density = temp;
+
+	temp = (mr & MR8_IO_WIDTH_MASK) >> MR8_IO_WIDTH_SHIFT;
+	if (!get_lpddr2_io_width(temp)) {
+		/* IO width unsupported value */
+		return 0;
+	}
+	lpddr2_device->io_width = temp;
+
+	/*
+	 * If all the above tests pass we should
+	 * have a device on this chip-select
+	 */
+	return 1;
+}
+
+static struct lpddr2_device_details *get_lpddr2_details(u32 base, u8 cs,
+			struct lpddr2_device_details *lpddr2_dev_details)
+{
+	u32 phy;
+	struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
+
+	if (!lpddr2_dev_details)
+		return NULL;
+
+	/* Do the minimum init for mode register accesses */
+	if (!running_from_sdram()) {
+		phy = get_ddr_phy_ctrl_1(get_sys_clk_freq() / 2, RL_BOOT);
+		writel(phy, &emif->emif_ddr_phy_ctrl_1);
+	}
+
+	if (!(is_lpddr2_sdram_present(base, cs, lpddr2_dev_details)))
+		return NULL;
+
+	display_sdram_details(emif_num(base), cs, lpddr2_dev_details);
+
+	return lpddr2_dev_details;
+}
+
+void emif_get_device_details(u32 emif_nr,
+		struct lpddr2_device_details *cs0_device_details,
+		struct lpddr2_device_details *cs1_device_details)
+{
+	u32 base = (emif_nr == 1) ? OMAP44XX_EMIF1 : OMAP44XX_EMIF2;
+
+	if (running_from_sdram()) {
+		/*
+		 * We can not do automatic discovery running from SDRAM
+		 * Most likely we came here by mistake. Indicate error
+		 * by returning NULL
+		 */
+		cs0_device_details = NULL;
+		cs1_device_details = NULL;
+	} else {
+		/*
+		 * Automatically find the device details:
+		 *
+		 * Reset the PHY after each call to get_lpddr2_details().
+		 * If there is nothing connected to a given chip select
+		 * (typically CS1) mode register reads will mess up with
+		 * the PHY state and subsequent initialization won't work.
+		 * PHY reset brings back PHY to a good state.
+		 */
+		cs0_device_details =
+		    get_lpddr2_details(base, CS0, cs0_device_details);
+		emif_reset_phy(base);
+
+		cs1_device_details =
+		    get_lpddr2_details(base, CS1, cs1_device_details);
+		emif_reset_phy(base);
+	}
+}
+#endif /* CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION */
+
 static void do_sdram_init(u32 base)
 {
 	const struct emif_regs *regs;
include/configs/omap4_panda.h +1 -0
index 9f82ef4..a8dd861 100644
@@ -239,6 +239,7 @@
 
 /* Defines for SDRAM init */
 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
include/configs/omap4_sdp4430.h +1 -0
index 6df1c3d..534f89a 100644
@@ -245,6 +245,7 @@
 
 /* Defines for SDRAM init */
 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
Signature · 1 line
1.7.0.4
author
#215 lore raw

PATCH v4 8/12 armv7: start.S: fixes and enhancements for SPL

In reply to Aneesh V

- Allow SPL to have .bss disjoint from rest of the image
- Allow for .bss setup in CONFIG_SPL_BUILD case too.
- Take care of the special case where relocation offset = 0.
- Compile out exception handling code and install a simpler vector

---
V3:
* Taken care of the case where .bss is at a lower address comapred to _start

---
 arch/arm/cpu/armv7/start.S    |   50 ++++++++++++++++++++++++++++++----------
 arch/arm/cpu/armv7/u-boot.lds |    2 +
 2 files changed, 39 insertions(+), 13 deletions(-)
arch/arm/cpu/armv7/start.S +37 -13
index d2a6207..5be436f 100644
@@ -42,7 +42,16 @@ _start: b	reset
 	ldr	pc, _not_used
 	ldr	pc, _irq
 	ldr	pc, _fiq
-
+#ifdef CONFIG_SPL_BUILD
+_undefined_instruction: .word _undefined_instruction
+_software_interrupt:	.word _software_interrupt
+_prefetch_abort:	.word _prefetch_abort
+_data_abort:		.word _data_abort
+_not_used:		.word _not_used
+_irq:			.word _irq
+_fiq:			.word _fiq
+_pad:			.word 0x12345678 /* now 16*4=64 */
+#else
 _undefined_instruction: .word undefined_instruction
 _software_interrupt:	.word software_interrupt
 _prefetch_abort:	.word prefetch_abort
@@ -51,6 +60,8 @@ _not_used:		.word not_used
 _irq:			.word irq
 _fiq:			.word fiq
 _pad:			.word 0x12345678 /* now 16*4=64 */
+#endif	/* CONFIG_SPL_BUILD */
+
 .global _end_vect
 _end_vect:
 
@@ -89,6 +100,10 @@ _armboot_start:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -182,12 +197,11 @@ stack_setup:
 	mov	sp, r4
 
 	adr	r0, _start
-#ifndef CONFIG_SPL_BUILD
 	cmp	r0, r6
+	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */
 	beq	clear_bss		/* skip relocation */
-#endif
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
@@ -235,20 +249,34 @@ fixnext:
 	add	r2, r2, #8		/* each rel.dyn entry is 8 bytes */
 	cmp	r2, r3
 	blo	fixloop
+	b	clear_bss
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
+#endif	/* #ifndef CONFIG_SPL_BUILD */
 
 clear_bss:
+#ifdef CONFIG_SPL_BUILD
+	/* No relocation for SPL */
+	ldr	r0, =__bss_start
+	ldr	r1, =__bss_end__
+#else
 	ldr	r0, _bss_start_ofs
 	ldr	r1, _bss_end_ofs
 	mov	r4, r6			/* reloc addr */
 	add	r0, r0, r4
 	add	r1, r1, r4
+#endif
 	mov	r2, #0x00000000		/* clear			    */
 
 clbss_l:str	r2, [r0]		/* clear loop...		    */
 	add	r0, r0, #4
 	cmp	r0, r1
 	bne	clbss_l
-#endif	/* #ifndef CONFIG_SPL_BUILD */
 
 /*
  * We are done. Do not return, instead branch to second part of board
@@ -276,13 +304,6 @@ jump_2_ram:
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*************************************************************************
  *
  * CPU_init_critical registers
@@ -327,6 +348,8 @@ cpu_init_crit:
 	bl	lowlevel_init		@ go setup pll,mux,memory
 	mov	lr, ip			@ restore link
 	mov	pc, lr			@ back to my caller
+
+#ifndef CONFIG_SPL_BUILD
 /*
  *************************************************************************
  *
@@ -514,4 +537,5 @@ fiq:
 	bad_save_user_regs
 	bl	do_fiq
 
-#endif
+#endif /* CONFIG_USE_IRQ */
+#endif /* CONFIG_SPL_BUILD */
arch/arm/cpu/armv7/u-boot.lds +2 -0
index dbae54d..40ecf78 100644
@@ -55,6 +55,8 @@ SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
Signature · 1 line
1.7.0.4
author
#216 lore raw

PATCH v4 9/12 omap: add basic SPL support

In reply to Aneesh V

- Provide alternate implementations of board_init_f() board_init_r() for OMAP spl.
- Provide linker script
- Initialize global data
- Add serial console support
- Update CONFIG_SYS_TEXT_BASE to allow for SPL's bss and move it to board config header from config.mk

---

This patch adds two checkpatch warnings that look like false positives. Reported these to checkpatch maintainer.

V2:
* Removed the label __flash_image_end because _end serves the same purpose after rebasing to latest mainline

V3:
* Moved CONFIG_SYS_TEXT_BASE to board config header and deleted config.mk
* Changes for the struct based register accesses
* Removed usage of modify_reg_32() macro
* omap4_rev_string() reference changed to omap_rev_string()
* Folded the patches for linker script changes and console support into this patch
* Improved commit message

V4:
* Changed the CONFIG_SYS_SPL_* config flags to:
CONFIG_SPL_*
* Changed the name omap4_rev_string used in spl.c as this file is common for OMAP3/4

---
 arch/arm/cpu/armv7/Makefile                   |    7 ++-
 arch/arm/cpu/armv7/omap-common/Makefile       |    4 +
 arch/arm/cpu/armv7/omap-common/spl.c          |   82 +++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds |   62 +++++++++++++++++++
 arch/arm/cpu/armv7/omap4/Makefile             |    5 +-
 arch/arm/cpu/armv7/omap4/board.c              |    7 ++
 arch/arm/cpu/armv7/omap4/clocks.c             |   33 ++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h   |    1 +
 arch/arm/include/asm/omap_common.h            |    2 +
 board/ti/panda/Makefile                       |    2 +
 board/ti/panda/config.mk                      |   31 ---------
 board/ti/sdp4430/Makefile                     |    2 +
 board/ti/sdp4430/config.mk                    |   31 ---------
 include/configs/omap4_panda.h                 |   26 ++++++++
 include/configs/omap4_sdp4430.h               |   26 ++++++++
 15 files changed, 257 insertions(+), 64 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl.c
 create mode 100644 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
 delete mode 100644 board/ti/panda/config.mk
 delete mode 100644 board/ti/sdp4430/config.mk
arch/arm/cpu/armv7/Makefile +6 -1
index 299792a..92a5a96 100644
@@ -26,7 +26,12 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).o
 
 START	:= start.o
-COBJS	:= cpu.o cache_v7.o
+
+ifndef CONFIG_SPL_BUILD
+COBJS	+= cache_v7.o
+COBJS	+= cpu.o
+endif
+
 COBJS  += syslib.o
 
 SRCS	:= $(START:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/omap-common/Makefile +4 -0
index 8f698f8..0708796 100644
@@ -30,6 +30,10 @@ SOBJS	:= reset.o
 COBJS	:= timer.o
 COBJS	+= utils.o
 
+ifdef CONFIG_SPL_BUILD
+COBJS	+= spl.o
+endif
+
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
arch/arm/cpu/armv7/omap-common/spl.c new file +82 -0

82 lines not on this page · raw message

arch/arm/cpu/armv7/omap-common/u-boot-spl.lds new file +62 -0

62 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/Makefile +4 -1
index e1ccd68..e7ee0b8 100644
@@ -30,9 +30,12 @@ SOBJS	+= lowlevel_init.o
 COBJS	+= board.o
 COBJS	+= clocks.o
 COBJS	+= emif.o
-COBJS	+= mem.o
 COBJS	+= sdram_elpida.o
+
+ifndef CONFIG_SPL_BUILD
+COBJS	+= mem.o
 COBJS	+= sys_info.o
+endif
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap4/board.c +7 -0
index 786c239..54dd509 100644
@@ -155,7 +155,14 @@ void s_init(void)
 	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
+#ifdef CONFIG_SPL_BUILD
+	preloader_console_init();
+#endif
 	prcm_init();
+#ifdef CONFIG_SPL_BUILD
+	/* For regular u-boot sdram_init() is called from dram_init() */
+	sdram_init();
+#endif
 }
 
 /*
arch/arm/cpu/armv7/omap4/clocks.c +33 -0
index e8d3a52..f1e233a 100644
@@ -791,6 +791,39 @@ void lock_dpll(u32 *const base)
 	wait_for_lock(base);
 }
 
+void setup_clocks_for_console(void)
+{
+	/* Do not add any spl_debug prints in this function */
+	clrsetbits_le32(&prcm->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
+			CD_CLKCTRL_CLKTRCTRL_SW_WKUP <<
+			CD_CLKCTRL_CLKTRCTRL_SHIFT);
+
+	/* Enable all UARTs - console will be on one of them */
+	clrsetbits_le32(&prcm->cm_l4per_uart1_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart2_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart3_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart3_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
+			CD_CLKCTRL_CLKTRCTRL_HW_AUTO <<
+			CD_CLKCTRL_CLKTRCTRL_SHIFT);
+}
+
 void prcm_init(void)
 {
 	switch (omap4_hw_init_context()) {
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
index 1e62878..a81f8e5 100644
@@ -44,6 +44,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 void omap_rev_string(char *omap4_rev_string);
+void setup_clocks_for_console(void);
 void prcm_init(void);
 void bypass_dpll(u32 *const base);
 void freq_update_core(void);
arch/arm/include/asm/omap_common.h +2 -0
index 33caa4e..69d53d2 100644
@@ -34,4 +34,6 @@
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
 
+void preloader_console_init(void);
+
 #endif /* _OMAP_COMMON_H_ */
board/ti/panda/Makefile +2 -0
index 2186403..09f88ee 100644
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef CONFIG_SPL_BUILD
 COBJS	:= panda.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/ti/panda/config.mk deleted +0 -31
deleted file mode 100644
index 33901a7..0000000
@@ -1,31 +0,0 @@
-#
-# (C) Copyright 2006-2009
-# Texas Instruments Incorporated, <www.ti.com>
-#
-# OMAP 4430 SDP
-# see http://www.ti.com/ for more information on Texas Instruments
-#
-# 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
-#
-# SDRAM Address Space:
-# 8000'0000 - 9fff'ffff (512 MB)
-# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
-# (mem base + reserved)
-
-CONFIG_SYS_TEXT_BASE = 0x80e80000
board/ti/sdp4430/Makefile +2 -0
index f1ee544..12f2743 100644
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef CONFIG_SPL_BUILD
 COBJS	:= sdp.o cmd_bat.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/ti/sdp4430/config.mk deleted +0 -31
deleted file mode 100644
index 33901a7..0000000
@@ -1,31 +0,0 @@
-#
-# (C) Copyright 2006-2009
-# Texas Instruments Incorporated, <www.ti.com>
-#
-# OMAP 4430 SDP
-# see http://www.ti.com/ for more information on Texas Instruments
-#
-# 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
-#
-# SDRAM Address Space:
-# 8000'0000 - 9fff'ffff (512 MB)
-# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
-# (mem base + reserved)
-
-CONFIG_SYS_TEXT_BASE = 0x80e80000
include/configs/omap4_panda.h +26 -0
index a8dd861..1112362 100644
@@ -243,4 +243,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SPL_TEXT_BASE		0x40304350
+#define CONFIG_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SPL_BSS_START_ADDR	0x80000000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
 #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +26 -0
index 534f89a..6a6be9e 100644
@@ -249,4 +249,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SPL_TEXT_BASE		0x40304350
+#define CONFIG_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SPL_BSS_START_ADDR	0x80000000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
author
#217 lore raw

PATCH v4 10/12 Correct ih_os for u-boot.img

In reply to Aneesh V

Provide appropriate '-O u-boot' while doing mkimage for u-boot.img

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index 0707036..f8ae883 100644
@@ -375,7 +375,7 @@ $(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
 
 $(obj)u-boot.img:	$(obj)u-boot.bin
 		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
-		-a $(CONFIG_SYS_TEXT_BASE) -e 0 \
+		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
Signature · 1 line
1.7.0.4
#218 lore raw

PATCH v4 10/12 Correct ih_os for u-boot.img

Dear Aneesh V,

Quoted 7 lines · In message <[email protected]> you wrote:

Provide appropriate '-O u-boot' while doing mkimage for u-boot.img

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What about WRITING it first and rationalizing it afterwords?  :-)
                       - Larry Wall in <[email protected]>
author
#219 lore raw

PATCH v4 11/12 omap: add MMC and FAT support to SPL

In reply to Aneesh V

- Add MMC raw and FAT mode boot support for OMAP
- Provide a means by which parameters passed by ROM-code can be saved in u-boot.
- Save boot mode related information passed by OMAP4 ROM-code and use it to determine where to load the u-boot from
- Assumes that the image has a mkimage header. Gets the payload size and load address from this header. If the header is not detected assume u-boot.bin as payload

---
V3:
* Squashed the patches that provided MMC support, FAT support, start.S hook for saving parameters, and OMAP4 patch for saving the parameters all into this patch.
* Removed the assumption that payload is u-boot.bin. Payload size and address

---
 arch/arm/cpu/armv7/cpu.c                 |    7 +
 arch/arm/cpu/armv7/omap-common/spl.c     |  194 +++++++++++++++++++++++++++++-
 arch/arm/cpu/armv7/omap4/board.c         |   21 ++++
 arch/arm/cpu/armv7/omap4/lowlevel_init.S |   31 +++++
 arch/arm/cpu/armv7/start.S               |    1 +
 arch/arm/include/asm/arch-omap4/omap4.h  |    8 ++
 arch/arm/include/asm/omap_common.h       |   17 +++
 include/configs/omap4_panda.h            |    5 +
 include/configs/omap4_sdp4430.h          |    5 +
 9 files changed, 287 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/cpu.c +7 -0
index def9ced..091e3e0 100644
@@ -37,6 +37,13 @@
 #include <asm/cache.h>
 #include <asm/armv7.h>
 
+void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
+{
+}
+
+void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
+	__attribute__((weak, alias("save_boot_params_default")));
+
 int cleanup_before_linux(void)
 {
 	/*
arch/arm/cpu/armv7/omap-common/spl.c +192 -2

217 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/board.c +21 -0
index 54dd509..2e5739a 100644
@@ -39,6 +39,27 @@ DECLARE_GLOBAL_DATA_PTR;
 
 u32 *const omap4_revision = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
 
+#ifdef CONFIG_SPL_BUILD
+/*
+ * We use static variables because global data is not ready yet.
+ * Initialized data is available in SPL right from the beginning.
+ * We would not typically need to save these parameters in regular
+ * U-Boot. This is needed only in SPL at the moment.
+ */
+u32 omap4_boot_device = BOOT_DEVICE_MMC1;
+u32 omap4_boot_mode = MMCSD_MODE_FAT;
+
+u32 omap_boot_device(void)
+{
+	return omap4_boot_device;
+}
+
+u32 omap_boot_mode(void)
+{
+	return omap4_boot_mode;
+}
+#endif
+
 void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
 {
 	int i;
arch/arm/cpu/armv7/omap4/lowlevel_init.S +31 -0
index 6abfbba..91525ec 100644
@@ -27,6 +27,37 @@
  */
 
 #include <asm/arch/omap4.h>
+#ifdef CONFIG_SPL_BUILD
+.global save_boot_params
+save_boot_params:
+	/*
+	 * See if the rom code passed pointer is valid:
+	 * It is not valid if it is not in non-secure SRAM
+	 * This may happen if you are booting with the help of
+	 * debugger
+	 */
+	ldr     r2, =NON_SECURE_SRAM_START
+	cmp	r2, r0
+	bgt	1f
+	ldr	r2, =NON_SECURE_SRAM_END
+	cmp	r2, r0
+	blt	1f
+
+	/* Store the boot device in omap4_boot_device */
+	ldr     r2, [r0, #BOOT_DEVICE_OFFSET]	@ r1 <- value of boot device
+	and	r2, #BOOT_DEVICE_MASK
+	ldr	r3, =omap4_boot_device
+	str     r2, [r3]			@ omap4_boot_device <- r1
+
+	/* Store the boot mode (raw/FAT) in omap4_boot_mode */
+	ldr	r2, [r0, #DEV_DESC_PTR_OFFSET]	@ get the device descriptor ptr
+	ldr	r2, [r2, #DEV_DATA_PTR_OFFSET]	@ get the pDeviceData ptr
+	ldr	r2, [r2, #BOOT_MODE_OFFSET]	@ get the boot mode
+	ldr	r3, =omap4_boot_mode
+	str	r2, [r3]
+1:
+	bx	lr
+#endif
 
 .globl lowlevel_init
 lowlevel_init:
arch/arm/cpu/armv7/start.S +1 -0
index 5be436f..89ea01f 100644
@@ -134,6 +134,7 @@ IRQ_STACK_START_IN:
  */
 
 reset:
+	bl	save_boot_params
 	/*
 	 * set the cpu to SVC32 mode
 	 */
arch/arm/include/asm/arch-omap4/omap4.h +8 -0
index a8dbedb..563544f 100644
@@ -144,4 +144,12 @@ struct s32ktimer {
 #define OMAP4430_ES2_2	0x44300220
 #define OMAP4430_ES2_3	0x44300230
 
+/* ROM code defines */
+/* Boot device */
+#define BOOT_DEVICE_MASK	0xFF
+#define BOOT_DEVICE_OFFSET	0x8
+#define DEV_DESC_PTR_OFFSET	0x4
+#define DEV_DATA_PTR_OFFSET	0x18
+#define BOOT_MODE_OFFSET	0x8
+
 #endif
arch/arm/include/asm/omap_common.h +17 -0
index 69d53d2..d3cb857 100644
@@ -36,4 +36,21 @@
 
 void preloader_console_init(void);
 
+/* Boot device */
+#define BOOT_DEVICE_NONE	0
+#define BOOT_DEVICE_XIP		1
+#define BOOT_DEVICE_XIPWAIT	2
+#define BOOT_DEVICE_NAND	3
+#define BOOT_DEVICE_ONE_NAND	4
+#define BOOT_DEVICE_MMC1	5
+#define BOOT_DEVICE_MMC2	6
+
+/* Boot type */
+#define	MMCSD_MODE_UNDEFINED	0
+#define MMCSD_MODE_RAW		1
+#define MMCSD_MODE_FAT		2
+
+u32 omap_boot_device(void);
+u32 omap_boot_mode(void);
+
 #endif /* _OMAP_COMMON_H_ */
include/configs/omap4_panda.h +5 -0
index 1112362..f6f283a 100644
@@ -252,6 +252,11 @@
 #define CONFIG_SPL_BSS_START_ADDR	0x80000000
 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
 
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x300 /* address 0x60000 */
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
include/configs/omap4_sdp4430.h +5 -0
index 6a6be9e..346763d 100644
@@ -258,6 +258,11 @@
 #define CONFIG_SPL_BSS_START_ADDR	0x80000000
 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
 
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x300 /* address 0x60000 */
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
Signature · 1 line
1.7.0.4
#220 lore raw

PATCH v4 11/12 omap: add MMC and FAT support to SPL

Hi Aneesh,

I'am not really sure about the save_boot_params() feature you added.

May you point me where I can find this in the OMAP reference docs?

Thanks!
Simon

author
#221 lore raw

PATCH v4 11/12 omap: add MMC and FAT support to SPL

Hi Simon,

Quoted 5 lines · Simon Schwarz

Hi Aneesh,

I'am not really sure about the save_boot_params() feature you added.

May you point me where I can find this in the OMAP reference docs?

What I have done for OMAP4 will not work for OMAP3. For OMAP3 you will get only the boot-device(eMMC, MMC/SD, nand etc) and *not* the bootmode(raw vs FAT).

To get boot device you can don one of the following approaches.

1. What x-loader does

git://git.omapzoom.org/repo/x-loader.git - master branch

cpu/omap3/start.S:

reset:

	ldr	r4, scratchpad		/* r4 <- scratchpad reg address */
	ldr	r5, [r0, #0x4]		/* r5 <- value of boot device */
	str	r5, [r4]		/* store r5 in scratchpad reg */

See the usage in lib/board.c:

Here are the device numbers:

	case 0x03:
		strcpy(boot_dev_name, "ONENAND");
	case 0x02:
		strcpy(boot_dev_name, "NAND");
	case 0x05:
		strcpy(boot_dev_name, "EMMC");
	case 0x06:
		strcpy(boot_dev_name, "MMC/SD1");

This is internal ROM code information and not documented anywhere.

You may assume FAT mode for MMC/SD1 and raw mode for the rest.

2. Read the boot device from a hw register(SYS_BOOT)

See 'chapter 26 Initialization' and look@table 26-3

best regards,
Aneesh

author
#222 lore raw

PATCH v4 12/12 mkimage: Add OMAP boot image support

In reply to Aneesh V

From: John Rigby <[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2
* Adapted for the new SPL framework
V4:
* Replaced CONFIG_SYS_SPL_TEXT_BASE with CONFIG_SPL_TEXT_BASE

---
 arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
 common/image.c                     |    9 +-
 include/image.h                    |    1 +
 spl/Makefile                       |    6 +
 tools/Makefile                     |    2 +
 tools/mkimage.c                    |    2 +
 tools/mkimage.h                    |    1 +
 tools/omapimage.c                  |  224 ++++++++++++++++++++++++++++++++++++
 tools/omapimage.h                  |   50 ++++++++
 9 files changed, 321 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/config.mk
 create mode 100644 tools/omapimage.c
 create mode 100644 tools/omapimage.h
arch/arm/cpu/armv7/omap4/config.mk new file +30 -0
new file mode 100644
index 0000000..b34fa64
@@ -0,0 +1,30 @@
+#
+# Copyright 2011 Linaro Limited
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# (C) Copyright 2010
+# Texas Instruments, <www.ti.com>
+#
+# Aneesh V <[email protected]>
+#
+# 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
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y	+= $(OBJTREE)/MLO
+else
+ALL-y	+= $(obj)u-boot.img
+endif
common/image.c +5 -4
index e542a57..a141904 100644
@@ -130,17 +130,18 @@ static const table_entry_t uimage_os[] = {
 };
 
 static const table_entry_t uimage_type[] = {
-	{	IH_TYPE_INVALID,    NULL,	  "Invalid Image",	},
 	{	IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image",	},
 	{	IH_TYPE_FIRMWARE,   "firmware",	  "Firmware",		},
+	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
+	{	IH_TYPE_INVALID,    NULL,	  "Invalid Image",	},
+	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	IH_TYPE_KERNEL,	    "kernel",	  "Kernel Image",	},
+	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
 	{	IH_TYPE_MULTI,	    "multi",	  "Multi-File Image",	},
+	{	IH_TYPE_OMAPIMAGE,  "omapimage",  "TI OMAP SPL With GP CH",},
 	{	IH_TYPE_RAMDISK,    "ramdisk",	  "RAMDisk Image",	},
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
-	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
-	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
-	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
include/image.h +1 -0
index c31e862..c606644 100644
@@ -157,6 +157,7 @@
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
 #define IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
 #define IH_TYPE_IMXIMAGE	10	/* Freescale IMXBoot Image	*/
+#define IH_TYPE_OMAPIMAGE	11	/* TI OMAP Config Header Image	*/
 
 /*
  * Compression Types
spl/Makefile +6 -0
index 0c0ae2a..5cdd9e9 100644
@@ -85,6 +85,12 @@ LDPPFLAGS += \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
+ifdef CONFIG_OMAP
+$(OBJTREE)/MLO:	$(obj)u-boot-spl.bin
+	$(OBJTREE)/tools/mkimage -T omapimage \
+		-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
+endif
+
 ALL-y	+= $(obj)u-boot-spl.bin
 
 all:	$(ALL-y)
tools/Makefile +2 -0
index 97f83f8..cb7f92d 100644
@@ -88,6 +88,7 @@ OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
 NOPED_OBJ_FILES-y += kwbimage.o
 NOPED_OBJ_FILES-y += imximage.o
+NOPED_OBJ_FILES-y += omapimage.o
 NOPED_OBJ_FILES-y += mkimage.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
@@ -188,6 +189,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)md5.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \
+			$(obj)omapimage.o \
 			$(obj)sha1.o \
 			$(LIBFDT_OBJS)
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
tools/mkimage.c +2 -0
index 60f7263..b6a7cb7 100644
@@ -156,6 +156,8 @@ main (int argc, char **argv)
 	init_imx_image_type ();
 	/* Init FIT image generation/list support */
 	init_fit_image_type ();
+	/* Init TI OMAP Boot image generation/list support */
+	init_omap_image_type();
 	/* Init Default image generation/list support */
 	init_default_image_type ();
 
tools/mkimage.h +1 -0
index 9033a7d..3b49645 100644
@@ -143,5 +143,6 @@ void init_kwb_image_type (void);
 void init_imx_image_type (void);
 void init_default_image_type (void);
 void init_fit_image_type (void);
+void init_omap_image_type(void);
 
 #endif /* _MKIIMAGE_H_ */
tools/omapimage.c new file +224 -0

224 lines not on this page · raw message

tools/omapimage.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#223 lore raw

PATCH v4 12/12 mkimage: Add OMAP boot image support

Dear Sandeep,

please pull this directly with the rest of the OMAP SPL patches.

Quoted 19 lines · In message <[email protected]> you wrote:

From: John Rigby <[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2
* Adapted for the new SPL framework
V4:
* Replaced CONFIG_SYS_SPL_TEXT_BASE with CONFIG_SPL_TEXT_BASE

Quoted 14 lines
---
 arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
 common/image.c                     |    9 +-
 include/image.h                    |    1 +
 spl/Makefile                       |    6 +
 tools/Makefile                     |    2 +
 tools/mkimage.c                    |    2 +
 tools/mkimage.h                    |    1 +
 tools/omapimage.c                  |  224 ++++++++++++++++++++++++++++++++++++
 tools/omapimage.h                  |   50 ++++++++
 9 files changed, 321 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/config.mk
 create mode 100644 tools/omapimage.c
 create mode 100644 tools/omapimage.h

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never call a man a fool.  Borrow from him.
#224 lore raw

PATCH v4 12/12 mkimage: Add OMAP boot image support

Dear Albert,

Quoted 28 lines

Dear Sandeep,

please pull this directly with the rest of the OMAP SPL patches.

Quoted 23 lines · In message <[email protected]> you wrote:

From: John Rigby <[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2
* Adapted for the new SPL framework
V4:
* Replaced CONFIG_SYS_SPL_TEXT_BASE with CONFIG_SPL_TEXT_BASE

---
 arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
 common/image.c                     |    9 +-
 include/image.h                    |    1 +

For some reason the change to include/image.h has NOT made it into u-boot-arm/master, therefore all builds are currently broken!

common/image.c:141:4: error: ?IH_TYPE_OMAPIMAGE? undeclared here (not in a function)

Best Regards,
Reinhard

#225 lore raw

PATCH v4 12/12 mkimage: Add OMAP boot image support

Hi Reinhard,

Le 02/08/2011 11:08, Reinhard Meyer a ?crit :

Quoted 30 lines

Dear Albert,

Quoted 28 lines

Dear Sandeep,

please pull this directly with the rest of the OMAP SPL patches.

Quoted 23 lines · In message<[email protected]> you wrote:

From: John Rigby<[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2
* Adapted for the new SPL framework
V4:
* Replaced CONFIG_SYS_SPL_TEXT_BASE with CONFIG_SPL_TEXT_BASE

---
  arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
  common/image.c                     |    9 +-
  include/image.h                    |    1 +
Quoted 5 lines

For some reason the change to include/image.h has NOT made it into u-boot-arm/master, therefore all builds are currently broken!

common/image.c:141:4: error: ?IH_TYPE_OMAPIMAGE? undeclared here (not in a function)

My fault -- slipped a cam when rebasing. Please re-fetch master (and next and utf8 for anyone who wants them too).

Two notes BTW:

1. due to the merge conflict between UBL and OMAP image additions, I have re-numbered TH_TYPE_OMAPIMAGE value from 11 to 12.

2. after UBL addition, the table_entry_t uimage_type table in common/image.c is no longer sorted by image name. I did not fix this as this could require changes beyond what the merge conflict resolution required.

Quoted 2 lines

Best Regards,
Reinhard

Apologies for the merge issue.

Amicalement,

Signature · 1 line
Albert.
#226 lore raw

PATCH v4 12/12 mkimage: Add OMAP boot image support

Dear Albert,

Quoted 50 lines

Le 02/08/2011 11:08, Reinhard Meyer a ?crit :

Quoted 30 lines

Dear Albert,

Quoted 28 lines

Dear Sandeep,

please pull this directly with the rest of the OMAP SPL patches.

Quoted 23 lines · In message<[email protected]> you wrote:

From: John Rigby<[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2
* Adapted for the new SPL framework
V4:
* Replaced CONFIG_SYS_SPL_TEXT_BASE with CONFIG_SPL_TEXT_BASE

---
  arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
  common/image.c                     |    9 +-
  include/image.h                    |    1 +
Quoted 5 lines

For some reason the change to include/image.h has NOT made it into u-boot-arm/master, therefore all builds are currently broken!

common/image.c:141:4: error: ?IH_TYPE_OMAPIMAGE? undeclared here (not in a function)

My fault -- slipped a cam when rebasing. Please re-fetch master (and next and utf8 for anyone who wants them too).

Two notes BTW:

1. due to the merge conflict between UBL and OMAP image additions, I have re-numbered TH_TYPE_OMAPIMAGE value from 11 to 12.

2. after UBL addition, the table_entry_t uimage_type table in common/image.c is no longer sorted by image name. I did not fix this as this could require changes beyond what the merge conflict resolution required.

Quoted 6 lines
Quoted 2 lines

Best Regards,
Reinhard

Apologies for the merge issue.

Amicalement,

I had locally fixed that define myself, but then got build warnings for some undefined function in the same image-making business (can't recheck that right now, a lengthy MAKEALL is in progress).

For the time being I rather stay based on u-boot/master until such issues are fixed. Anyway a merge of my AT91 stuff with your ARM stuff should not generate any merge conflicts, except maybe boards.cfg.

Best Regards,
Reinhard

author
#227 lore raw

v4 cover U-Boot MMC SPL for OMAP4

In reply to Aneesh V

This series adds mmc SPL support for OMAP4. This is essentially an up-streaming effort for TI's x-loader for OMAP4 using the SPL framework

This work partly draws upon previous work done for x-loader by:
Santosh Shilimkar <[email protected]> Rajendra Nayak <[email protected]>
and many others

This series depends on the following series for the new SPL framework:
http://marc.info/?l=u-boot&m=131056990001719&w=2

Features supported:
* Clock init - DPLL locking, clock domains/modules enabling
* SDRAM/DMM initialization
* Mux initialization
* MMC raw read support
* MMC FAT read support

Improvments over x-loader:
* Code completely revamped
* DPLL programming that works for all SYS_CLK frequencies
* Automatic SDRAM identification and initialization
* Board dependent parts(especially mux) deferred to u-boot. So, same SPL will work for Panda and SDP and most likely on any other board that comes along
* Flexible about the payload. Any image with a mkimage header can be loaded.
* The core SPL logic is generic and available for OMAP3/4. So, OMAP3 platforms can easily extend this work to add SPL support for the respective boards.

V2:
* Some fixes in SDRAM init, clock init
* Use of pre-calculated M & N values for DPLL locking instead run-time calculation
* Change in make files to allow reuse of common rules between boards
* Console initialization moved further earlier in the boot allowing traces from even clock initialization code
* Reuse utility macros from a previous series

V3:
* Moved to the new SPL framework
* struct based register access for clock init
* Squashed together related patches as per Wolfgang's suggestions
* Re-organization of code in sdram init for better readability
* SPL loading the payload using mkimage header
* Avoided using custom bit-field accessor macros
* Several other minor changes(documented in respective patches)

V4:
* Rebased on u-boot-ti/master as on 21 Jul 2011

Aneesh V (11):
omap4: utility function to identify the context of hw init
omap4: cleanup pin mux data
omap4: add OMAP4430 revision check
omap4: add clock support
omap4: add sdram init support
omap4: calculate EMIF register values
omap4: automatic sdram detection
armv7: start.S: fixes and enhancements for SPL
omap: add basic SPL support
Correct ih_os for u-boot.img
omap: add MMC and FAT support to SPL

John Rigby (1):
mkimage: Add OMAP boot image support

 Makefile                                           |    2 +-
 arch/arm/cpu/armv7/Makefile                        |    7 +-
 arch/arm/cpu/armv7/cpu.c                           |    7 +
 arch/arm/cpu/armv7/omap-common/Makefile            |    5 +
 arch/arm/cpu/armv7/omap-common/spl.c               |  272 ++++
 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds      |   62 +
 arch/arm/cpu/armv7/omap-common/utils.c             |   57 +
 arch/arm/cpu/armv7/omap4/Makefile                  |    6 +
 arch/arm/cpu/armv7/omap4/board.c                   |  161 +++-
 arch/arm/cpu/armv7/omap4/clocks.c                  |  842 +++++++++++++
 .../panda => arch/arm/cpu/armv7/omap4}/config.mk   |   25 +-
 arch/arm/cpu/armv7/omap4/emif.c                    | 1305 ++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/lowlevel_init.S           |   31 +
 arch/arm/cpu/armv7/omap4/omap4_mux_data.h          |   76 ++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c            |  282 +++++
 arch/arm/cpu/armv7/start.S                         |   50 +-
 arch/arm/cpu/armv7/u-boot.lds                      |    2 +
 arch/arm/include/asm/arch-omap4/clocks.h           |  664 ++++++++++
 arch/arm/include/asm/arch-omap4/emif.h             | 1034 ++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h            |   52 +-
 arch/arm/include/asm/arch-omap4/sys_proto.h        |   72 ++-
 arch/arm/include/asm/armv7.h                       |    5 +
 arch/arm/include/asm/omap_common.h                 |   56 +
 board/ti/panda/Makefile                            |    2 +
 board/ti/panda/panda.c                             |   25 +-
 board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} |   76 +-
 board/ti/sdp4430/Makefile                          |    2 +
 board/ti/sdp4430/config.mk                         |   31 -
 board/ti/sdp4430/sdp.c                             |   25 +-
 .../{panda/panda.h => sdp4430/sdp4430_mux_data.h}  |  128 +--
 common/image.c                                     |    9 +-
 include/configs/omap4_panda.h                      |   37 +
 include/configs/omap4_sdp4430.h                    |   37 +
 include/image.h                                    |    1 +
 spl/Makefile                                       |    6 +
 tools/Makefile                                     |    2 +
 tools/mkimage.c                                    |    2 +
 tools/mkimage.h                                    |    1 +
 tools/omap/clocks_get_m_n.c                        |  197 +++
 tools/omapimage.c                                  |  224 ++++
 tools/omapimage.h                                  |   50 +
 41 files changed, 5668 insertions(+), 262 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl.c
 create mode 100644 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
 create mode 100644 arch/arm/cpu/armv7/omap-common/utils.c
 create mode 100644 arch/arm/cpu/armv7/omap4/clocks.c
 rename {board/ti/panda => arch/arm/cpu/armv7/omap4}/config.mk (64%)
 create mode 100644 arch/arm/cpu/armv7/omap4/emif.c
 create mode 100644 arch/arm/cpu/armv7/omap4/omap4_mux_data.h
 create mode 100644 arch/arm/cpu/armv7/omap4/sdram_elpida.c
 create mode 100644 arch/arm/include/asm/arch-omap4/clocks.h
 create mode 100644 arch/arm/include/asm/arch-omap4/emif.h
 create mode 100644 arch/arm/include/asm/omap_common.h
 rename board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} (76%)
 delete mode 100644 board/ti/sdp4430/config.mk
 rename board/ti/{panda/panda.h => sdp4430/sdp4430_mux_data.h} (67%)
 create mode 100644 tools/omap/clocks_get_m_n.c
 create mode 100644 tools/omapimage.c
 create mode 100644 tools/omapimage.h
#228 lore raw

v4 cover U-Boot MMC SPL for OMAP4

Quoted 70 lines

This series adds mmc SPL support for OMAP4. This is essentially an up-streaming effort for TI's x-loader for OMAP4 using the SPL framework

This work partly draws upon previous work done for x-loader by:
Santosh Shilimkar <[email protected]> Rajendra Nayak <[email protected]>
and many others

This series depends on the following series for the new SPL framework:
http://marc.info/?l=u-boot&m=131056990001719&w=2

Features supported:
* Clock init - DPLL locking, clock domains/modules enabling
* SDRAM/DMM initialization
* Mux initialization
* MMC raw read support
* MMC FAT read support

Improvments over x-loader:
* Code completely revamped
* DPLL programming that works for all SYS_CLK frequencies
* Automatic SDRAM identification and initialization
* Board dependent parts(especially mux) deferred to u-boot. So, same SPL will work for Panda and SDP and most likely on any other board that comes along
* Flexible about the payload. Any image with a mkimage header can be loaded.
* The core SPL logic is generic and available for OMAP3/4. So, OMAP3 platforms can easily extend this work to add SPL support for the respective boards.

V2:
* Some fixes in SDRAM init, clock init
* Use of pre-calculated M & N values for DPLL locking instead run-time calculation
* Change in make files to allow reuse of common rules between boards
* Console initialization moved further earlier in the boot allowing traces from even clock initialization code
* Reuse utility macros from a previous series

V3:
* Moved to the new SPL framework
* struct based register access for clock init
* Squashed together related patches as per Wolfgang's suggestions
* Re-organization of code in sdram init for better readability
* SPL loading the payload using mkimage header
* Avoided using custom bit-field accessor macros
* Several other minor changes(documented in respective patches)

V4:
* Rebased on u-boot-ti/master as on 21 Jul 2011

Aneesh V (11):
omap4: utility function to identify the context of hw init
omap4: cleanup pin mux data
omap4: add OMAP4430 revision check
omap4: add clock support
omap4: add sdram init support
omap4: calculate EMIF register values
omap4: automatic sdram detection
armv7: start.S: fixes and enhancements for SPL
omap: add basic SPL support
Correct ih_os for u-boot.img
omap: add MMC and FAT support to SPL

Quoted 3 lines

John Rigby (1):
mkimage: Add OMAP boot image support

Pushed the series to u-boot-ti

http://git.denx.de/?p=u-boot/u-boot-ti.git;a=summary

Thanks,
Sandeep

author
#229 lore raw

PATCH v4 1/12 omap4: utility function to identify the context of hw init

In reply to Aneesh V

The basic hardware init of OMAP4(s_init()) can happen in 4 different contexts:
1. SPL running from SRAM
2. U-Boot running from FLASH
3. Non-XIP U-Boot loaded to SDRAM by SPL
4. Non-XIP U-Boot loaded to SDRAM by ROM code using the Configuration Header feature

What level of hw initialization gets done depends on this context. Add a utility function to find this context.

---
V3:
* Changed the context names to more meaningful names as suggested by WD

---
 arch/arm/include/asm/arch-omap4/sys_proto.h |   49 ++++++++++++++++++++++++++-
 arch/arm/include/asm/omap_common.h          |   34 ++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_common.h
arch/arm/include/asm/arch-omap4/sys_proto.h +48 -1
index 4fa4f4b..6b596b4 100644
@@ -23,10 +23,12 @@
 
 #include <asm/arch/omap4.h>
 #include <asm/io.h>
+#include <asm/omap_common.h>
 
 struct omap_sysinfo {
 	char *board_string;
 };
+extern const struct omap_sysinfo sysinfo;
 
 void gpmc_init(void);
 void watchdog_init(void);
@@ -37,6 +39,51 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 
-extern const struct omap_sysinfo sysinfo;
+static inline u32 running_from_sdram(void)
+{
+	u32 pc;
+	asm volatile ("mov %0, pc" : "=r" (pc));
+	return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
+	    (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
+}
+
+static inline u8 uboot_loaded_by_spl(void)
+{
+	/*
+	 * Configuration Header is not supported yet, so u-boot init running
+	 * from SDRAM implies that it was loaded by SPL. When this situation
+	 * changes one of these approaches could be taken:
+	 * i.  Pass a magic from SPL to U-Boot and U-Boot save it at a known
+	 *     location.
+	 * ii. Check the OPP. CH can support only 50% OPP while SPL initializes
+	 *     the DPLLs@100% OPP.
+	 */
+	return running_from_sdram();
+}
+/*
+ * The basic hardware init of OMAP(s_init()) can happen in 4
+ * different contexts:
+ *  1. SPL running from SRAM
+ *  2. U-Boot running from FLASH
+ *  3. Non-XIP U-Boot loaded to SDRAM by SPL
+ *  4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
+ *     Configuration Header feature
+ *
+ * This function finds this context.
+ * Defining as inline may help in compiling out unused functions in SPL
+ */
+static inline u32 omap4_hw_init_context(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	return OMAP_INIT_CONTEXT_SPL;
+#else
+	if (uboot_loaded_by_spl())
+		return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
+	else if (running_from_sdram())
+		return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
+	else
+		return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
+#endif
+}
 
 #endif
arch/arm/include/asm/omap_common.h new file +34 -0
new file mode 100644
index 0000000..d80f665
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *
+ * Aneesh V <[email protected]>
+ *
+ * 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	_OMAP_COMMON_H_
+#define	_OMAP_COMMON_H_
+
+/* HW Init Context */
+#define OMAP_INIT_CONTEXT_SPL			0
+#define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR	1
+#define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
+#define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
+
+#endif /* _OMAP_COMMON_H_ */
Signature · 1 line
1.7.0.4
author
#230 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

In reply to Aneesh V

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

---
This patch add 33 warnings for lines over 80 characters. However, this for the mux table and improves readability.

V3:
* Squashed two mux related patches into one

---
 arch/arm/cpu/armv7/omap4/board.c                   |   53 ++++++++-
 arch/arm/cpu/armv7/omap4/omap4_mux_data.h          |   76 ++++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h        |    4 +-
 board/ti/panda/panda.c                             |   25 +---
 board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} |   76 +++---------
 board/ti/sdp4430/sdp.c                             |   25 +---
 .../{panda/panda.h => sdp4430/sdp4430_mux_data.h}  |  128 +++++++------------
 7 files changed, 209 insertions(+), 178 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/omap4_mux_data.h
 rename board/ti/{sdp4430/sdp.h => panda/panda_mux_data.h} (76%)
 rename board/ti/{panda/panda.h => sdp4430/sdp4430_mux_data.h} (67%)
arch/arm/cpu/armv7/omap4/board.c +50 -3
index de4cc2a..3fd6f84 100644
@@ -31,17 +31,65 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
+#include "omap4_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+{
+	int i;
+	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
+
+	for (i = 0; i < size; i++, pad++)
+		writew(pad->val, base + pad->offset);
+}
+
+static void set_muxconf_regs_essential(void)
+{
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_essential,
+		   sizeof(core_padconf_array_essential) /
+		   sizeof(struct pad_conf_entry));
+
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_essential,
+		   sizeof(wkup_padconf_array_essential) /
+		   sizeof(struct pad_conf_entry));
+}
+
+static void set_mux_conf_regs(void)
+{
+	switch (omap4_hw_init_context()) {
+	case OMAP_INIT_CONTEXT_SPL:
+		set_muxconf_regs_essential();
+		break;
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL:
+		set_muxconf_regs_non_essential();
+		break;
+	case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
+		set_muxconf_regs_essential();
+		set_muxconf_regs_non_essential();
+		break;
+	}
+}
+
 /*
  * Routine: s_init
- * Description: Does early system init of muxing and clocks.
- *              - Called path is with SRAM stack.
+ * Description: Does early system init of watchdog, muxing,  andclocks
+ * Watchdog disable is done always. For the rest what gets done
+ * depends on the boot mode in which this function is executed
+ *   1. s_init of SPL running from SRAM
+ *   2. s_init of U-Boot running from FLASH
+ *   3. s_init of U-Boot loaded to SDRAM by SPL
+ *   4. s_init of U-Boot loaded to SDRAM by ROM code using the
+ *	Configuration Header feature
+ * Please have a look at the respective functions to see what gets
+ * done in each of these cases
+ * This function is called with SRAM stack.
  */
 void s_init(void)
 {
 	watchdog_init();
+	set_mux_conf_regs();
 }
 
 /*
@@ -124,7 +172,6 @@ int checkboard(void)
 */
 int arch_cpu_init(void)
 {
-	set_muxconf_regs();
 	return 0;
 }
 
arch/arm/cpu/armv7/omap4/omap4_mux_data.h new file +76 -0

76 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/sys_proto.h +3 -1
index 6b596b4..3624378 100644
@@ -24,6 +24,7 @@
 #include <asm/arch/omap4.h>
 #include <asm/io.h>
 #include <asm/omap_common.h>
+#include <asm/arch/mux_omap4.h>
 
 struct omap_sysinfo {
 	char *board_string;
@@ -33,7 +34,8 @@ extern const struct omap_sysinfo sysinfo;
 void gpmc_init(void);
 void watchdog_init(void);
 u32 get_device_type(void);
-void set_muxconf_regs(void);
+void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
+void set_muxconf_regs_non_essential(void);
 void sr32(void *, u32, u32, u32);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
board/ti/panda/panda.c +6 -19
index 78e1910..9afed80 100644
@@ -25,7 +25,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
-#include "panda.h"
+#include "panda_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -65,27 +65,14 @@ int misc_init_r(void)
 	return 0;
 }
 
-void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+void set_muxconf_regs_non_essential(void)
 {
-	int i;
-	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
-
-	for (i = 0; i < size; i++, pad++)
-		writew(pad->val, base + pad->offset);
-}
-
-/**
- * @brief set_muxconf_regs Setting up the configuration Mux registers
- * specific to the board.
- */
-void set_muxconf_regs(void)
-{
-	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array,
-		   sizeof(core_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_non_essential,
+		   sizeof(core_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 
-	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array,
-		   sizeof(wkup_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_non_essential,
+		   sizeof(wkup_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 }
 
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +21 -55

156 lines not on this page · raw message

board/ti/sdp4430/sdp.c +6 -19
index b13c4c5..a5ea682 100644
@@ -27,7 +27,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
-#include "sdp.h"
+#include "sdp4430_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -70,27 +70,14 @@ int misc_init_r(void)
 	return 0;
 }
 
-void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
+void set_muxconf_regs_non_essential(void)
 {
-	int i;
-	struct pad_conf_entry *pad = (struct pad_conf_entry *) array;
-
-	for (i = 0; i < size; i++, pad++)
-		writew(pad->val, base + pad->offset);
-}
-
-/**
- * @brief set_muxconf_regs Setting up the configuration Mux registers
- * specific to the board.
- */
-void set_muxconf_regs(void)
-{
-	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array,
-		   sizeof(core_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_CORE, core_padconf_array_non_essential,
+		   sizeof(core_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 
-	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array,
-		   sizeof(wkup_padconf_array) /
+	do_set_mux(CONTROL_PADCONF_WKUP, wkup_padconf_array_non_essential,
+		   sizeof(wkup_padconf_array_non_essential) /
 		   sizeof(struct pad_conf_entry));
 }
 
board/ti/sdp4430/sdp4430_mux_data.h renamed from board/ti/panda/panda.h +47 -81

211 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#231 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

Dear Aneesh V,

Quoted 7 lines · In message <[email protected]> you wrote:

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

...

board/ti/panda/panda_mux_data.h const struct pad_conf_entry core_padconf_array[] = { · line 94

Quoted 8 lines
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +8 -0
+	{USBB1_ULPITLL_CLK, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cawake */
+	{USBB1_ULPITLL_STP, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cadata */
+	{USBB1_ULPITLL_DIR, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caflag */
+	{USBB1_ULPITLL_NXT, (OFF_EN | M1)},				/* hsi1_acready */
+	{USBB1_ULPITLL_DAT0, (OFF_EN | M1)},				/* hsi1_acwake */
+	{USBB1_ULPITLL_DAT1, (OFF_EN | M1)},				/* hsi1_acdata */
+	{USBB1_ULPITLL_DAT2, (OFF_EN | M1)},				/* hsi1_acflag */
+	{USBB1_ULPITLL_DAT3, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caready */

Lines too long, please fix globally.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Quote from the Boss after overriding the decision of a task force  he
created  to  find  a  solution:  "I'm  sorry  if  I ever gave you the
impression your input would have any effect on my  decision  for  the
outcome of this project!"
author
#232 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

Dear Wolfgang,

Quoted 11 lines · Wolfgang Denk

Dear Aneesh V,

Quoted 7 lines · In message<[email protected]> you wrote:

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

...

Quoted 10 lines

board/ti/panda/panda_mux_data.h const struct pad_conf_entry core_padconf_array[] = { · line 94

Quoted 8 lines
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +8 -0
+	{USBB1_ULPITLL_CLK, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cawake */
+	{USBB1_ULPITLL_STP, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cadata */
+	{USBB1_ULPITLL_DIR, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caflag */
+	{USBB1_ULPITLL_NXT, (OFF_EN | M1)},				/* hsi1_acready */
+	{USBB1_ULPITLL_DAT0, (OFF_EN | M1)},				/* hsi1_acwake */
+	{USBB1_ULPITLL_DAT1, (OFF_EN | M1)},				/* hsi1_acdata */
+	{USBB1_ULPITLL_DAT2, (OFF_EN | M1)},				/* hsi1_acflag */
+	{USBB1_ULPITLL_DAT3, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caready */

Lines too long, please fix globally.

This table looks better and readable if each row is a single line. I had mentioned this in the commit log. Does it make sense to make an exception for this?

best regards,
Aneesh

#233 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

Dear Aneesh V,

Quoted 25 lines · In message <[email protected]> you wrote:

Dear Wolfgang,

Quoted 11 lines · Wolfgang Denk

Dear Aneesh V,

Quoted 7 lines · In message<[email protected]> you wrote:

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

...

Quoted 10 lines

board/ti/panda/panda_mux_data.h const struct pad_conf_entry core_padconf_array[] = { · line 94

Quoted 8 lines
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +8 -0
+	{USBB1_ULPITLL_CLK, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cawake */
+	{USBB1_ULPITLL_STP, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cadata */
+	{USBB1_ULPITLL_DIR, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caflag */
+	{USBB1_ULPITLL_NXT, (OFF_EN | M1)},				/* hsi1_acready */
+	{USBB1_ULPITLL_DAT0, (OFF_EN | M1)},				/* hsi1_acwake */
+	{USBB1_ULPITLL_DAT1, (OFF_EN | M1)},				/* hsi1_acdata */
+	{USBB1_ULPITLL_DAT2, (OFF_EN | M1)},				/* hsi1_acflag */
+	{USBB1_ULPITLL_DAT3, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caready */

Lines too long, please fix globally.

Quoted 3 lines

This table looks better and readable if each row is a single line. I had mentioned this in the commit log. Does it make sense to make an exception for this?

I agree that it does not make sense to split the lines.

But it seems there is potential to reduce the line length: in may cases, you can just reduce the indentation of the comments.

In many other places the commets are just useless and should be omitted. See for example the (old, existing) lines:

{CAM_SHUTTER, (OFF_EN | OFF_PD | OFF_OUT_PTD | M0)}, /* cam_shutter */
{CAM_STROBE, (OFF_EN | OFF_PD | OFF_OUT_PTD | M0)}, /* cam_strobe */
...

        {USBB1_ULPITLL_DAT4, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},    /* usbb1_ulpiphy_dat4 */
        {USBB1_ULPITLL_DAT5, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},    /* usbb1_ulpiphy_dat5 */
        {USBB1_ULPITLL_DAT6, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},    /* usbb1_ulpiphy_dat6 */

...
etc.

A comment that just repeats the content of the first argument without any additional information carries zero information and should just be removed.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If you use modules, you pay the price. Sane embedded solutions
running in "tight" environments don't use modules :-)
    -- Benjamin Herrenschmidt in <1258234866.2140.451.camel@pasglop>
author
#234 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

Dear Wolfgang,

Quoted 28 lines · Wolfgang Denk

Dear Aneesh V,

Quoted 25 lines · In message<[email protected]> you wrote:

Dear Wolfgang,

Quoted 21 lines · Wolfgang Denk

Dear Aneesh V,

Quoted 7 lines · In message<[email protected]> you wrote:

- separate mux settings into essential and non essential parts
- essential part is board independent as of now(so move it to SoC directory). Will help in having single SPL for all boards.
- Non-essential part(the pins not essential for u-boot to function) need to be phased out eventually.
- Correct mux data by aligning to the latest settings in x-loader

...

board/ti/panda/panda_mux_data.h const struct pad_conf_entry core_padconf_array[] = { · line 94

Quoted 8 lines
board/ti/panda/panda_mux_data.h renamed from board/ti/sdp4430/sdp.h +8 -0
+	{USBB1_ULPITLL_CLK, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cawake */
+	{USBB1_ULPITLL_STP, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cadata */
+	{USBB1_ULPITLL_DIR, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caflag */
+	{USBB1_ULPITLL_NXT, (OFF_EN | M1)},				/* hsi1_acready */
+	{USBB1_ULPITLL_DAT0, (OFF_EN | M1)},				/* hsi1_acwake */
+	{USBB1_ULPITLL_DAT1, (OFF_EN | M1)},				/* hsi1_acdata */
+	{USBB1_ULPITLL_DAT2, (OFF_EN | M1)},				/* hsi1_acflag */
+	{USBB1_ULPITLL_DAT3, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caready */

Lines too long, please fix globally.

Quoted 8 lines
Quoted 3 lines

This table looks better and readable if each row is a single line. I had mentioned this in the commit log. Does it make sense to make an exception for this?

I agree that it does not make sense to split the lines.

But it seems there is potential to reduce the line length: in may cases, you can just reduce the indentation of the comments.

Yes, for some lines there is potential to reduce the length. But I just aligned the comments vertically for the entire table since more than half of the rows were anyway overflowing.

Quoted 6 lines

In many other places the commets are just useless and should be omitted. See for example the (old, existing) lines:

{CAM_SHUTTER, (OFF_EN | OFF_PD | OFF_OUT_PTD | M0)}, /* cam_shutter */
{CAM_STROBE, (OFF_EN | OFF_PD | OFF_OUT_PTD | M0)}, /* cam_strobe */

The two are actually not same. The first column indicates the register name. The documented name specifies the function selected which depends on the last column, the mode(M0, M4 etc). The name of the register happens to be the function selected by M0. So, in those cases, what you said is correct. But IMHO, it's better to document the function selected even in those cases, because when somebody changes the mode here or for a new board, he/she is not likely to update the comment if it is already absent.

Quoted 6 lines

...

         {USBB1_ULPITLL_DAT4, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},    /* usbb1_ulpiphy_dat4 */
         {USBB1_ULPITLL_DAT5, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},    /* usbb1_ulpiphy_dat5 */
         {USBB1_ULPITLL_DAT6, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},    /* usbb1_ulpiphy_dat6 */

...
etc.

For the above please note that first column and comments are indeed different. Please note the difference between ULPI'TLL'_DATA4 and ulpi'phy'_data4.

My patch is already in u-boot-arm. If I have to rework this patch should I create a new patch to fix the problem or should I re-work the original patch?

best regards,
Aneesh

#235 lore raw

PATCH v4 2/12 omap4: cleanup pin mux data

Dear Aneesh V,

Quoted 4 lines · In message <[email protected]> you wrote:

My patch is already in u-boot-arm. If I have to rework this patch should I create a new patch to fix the problem or should I re-work the original patch?

It's not worth fighting about this. Please feel free to leave as is.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"There is nothing new under the sun, but there are lots of old things
we don't know yet."                                  - Ambrose Bierce
author
#236 lore raw

PATCH v4 3/12 omap4: add OMAP4430 revision check

In reply to Aneesh V

---
V2:
* Added a revision string in addition to the revision number Helps in printing out the OMAP revision at bootup

V3:
* Improved the revision check function by saving the value instead of finding it every time.
* Improved revision string function by generating it from the revision rather than hard-coding the string per revision

---
 arch/arm/cpu/armv7/omap4/board.c            |   64 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h     |   29 +++++++++---
 arch/arm/include/asm/arch-omap4/sys_proto.h |    7 +++
 arch/arm/include/asm/armv7.h                |    5 ++
 4 files changed, 97 insertions(+), 8 deletions(-)
arch/arm/cpu/armv7/omap4/board.c +64 -0
index 3fd6f84..09861a9 100644
@@ -28,6 +28,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
+#include <asm/armv7.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
@@ -35,6 +36,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+u32 *const omap4_revision = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
+
 void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
 {
 	int i;
@@ -72,6 +75,66 @@ static void set_mux_conf_regs(void)
 	}
 }
 
+static u32 cortex_a9_rev(void)
+{
+
+	unsigned int rev;
+
+	/* Read Main ID Register (MIDR) */
+	asm ("mrc p15, 0, %0, c0, c0, 0" : "=r" (rev));
+
+	return rev;
+}
+
+static void init_omap4_revision(void)
+{
+	/*
+	 * For some of the ES2/ES1 boards ID_CODE is not reliable:
+	 * Also, ES1 and ES2 have different ARM revisions
+	 * So use ARM revision for identification
+	 */
+	unsigned int arm_rev = cortex_a9_rev();
+
+	switch (arm_rev) {
+	case MIDR_CORTEX_A9_R0P1:
+		*omap4_revision = OMAP4430_ES1_0;
+		break;
+	case MIDR_CORTEX_A9_R1P2:
+		switch (readl(CONTROL_ID_CODE)) {
+		case OMAP4_CONTROL_ID_CODE_ES2_0:
+			*omap4_revision = OMAP4430_ES2_0;
+			break;
+		case OMAP4_CONTROL_ID_CODE_ES2_1:
+			*omap4_revision = OMAP4430_ES2_1;
+			break;
+		case OMAP4_CONTROL_ID_CODE_ES2_2:
+			*omap4_revision = OMAP4430_ES2_2;
+			break;
+		default:
+			*omap4_revision = OMAP4430_ES2_0;
+			break;
+		}
+		break;
+	case MIDR_CORTEX_A9_R1P3:
+		*omap4_revision = OMAP4430_ES2_3;
+		break;
+	default:
+		*omap4_revision = OMAP4430_SILICON_ID_INVALID;
+		break;
+	}
+}
+
+void omap_rev_string(char *omap4_rev_string)
+{
+	u32 omap4_rev = omap_revision();
+	u32 omap4_variant = (omap4_rev & 0xFFFF0000) >> 16;
+	u32 major_rev = (omap4_rev & 0x00000F00) >> 8;
+	u32 minor_rev = (omap4_rev & 0x000000F0) >> 4;
+
+	sprintf(omap4_rev_string, "OMAP%x ES%x.%x", omap4_variant, major_rev,
+		minor_rev);
+}
+
 /*
  * Routine: s_init
  * Description: Does early system init of watchdog, muxing,  andclocks
@@ -88,6 +151,7 @@ static void set_mux_conf_regs(void)
  */
 void s_init(void)
 {
+	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
 }
arch/arm/include/asm/arch-omap4/omap4.h +21 -8
index a30bb33..76b06c2 100644
@@ -51,6 +51,15 @@
 #define CONTROL_PADCONF_CORE	(OMAP44XX_L4_CORE_BASE + 0x100000)
 #define CONTROL_PADCONF_WKUP	(OMAP44XX_L4_CORE_BASE + 0x31E000)
 
+/* CONTROL_ID_CODE */
+#define CONTROL_ID_CODE		0x4A002204
+
+#define OMAP4_CONTROL_ID_CODE_ES1_0	0x0B85202F
+#define OMAP4_CONTROL_ID_CODE_ES2_0	0x1B85202F
+#define OMAP4_CONTROL_ID_CODE_ES2_1	0x3B95C02F
+#define OMAP4_CONTROL_ID_CODE_ES2_2	0x4B95C02F
+#define OMAP4_CONTROL_ID_CODE_ES2_3	0x6B95C02F
+
 /* UART */
 #define UART1_BASE		(OMAP44XX_L4_PER_BASE + 0x6a000)
 #define UART2_BASE		(OMAP44XX_L4_PER_BASE + 0x6c000)
@@ -119,13 +128,17 @@ struct s32ktimer {
 /* base address for indirect vectors (internal boot mode) */
 #define SRAM_ROM_VECT_BASE	0x4030D000
 /* Temporary SRAM stack used while low level init is done */
-#define LOW_LEVEL_SRAM_STACK	NON_SECURE_SRAM_END
-
-/*
- * OMAP4 real hardware:
- * TODO: Change this to the IDCODE in the hw regsiter
- */
-#define CPU_OMAP4430_ES10	1
-#define CPU_OMAP4430_ES20	2
+#define LOW_LEVEL_SRAM_STACK		NON_SECURE_SRAM_END
+#define SRAM_SCRATCH_SPACE_ADDR		NON_SECURE_SRAM_START
+/* SRAM scratch space entries */
+#define OMAP4_SRAM_SCRATCH_OMAP4_REV	SRAM_SCRATCH_SPACE_ADDR
+
+/* Silicon revisions */
+#define OMAP4430_SILICON_ID_INVALID	0xFFFFFFFF
+#define OMAP4430_ES1_0	0x44300100
+#define OMAP4430_ES2_0	0x44300200
+#define OMAP4430_ES2_1	0x44300210
+#define OMAP4430_ES2_2	0x44300220
+#define OMAP4430_ES2_3	0x44300230
 
 #endif
arch/arm/include/asm/arch-omap4/sys_proto.h +7 -0
index 3624378..c10fa18 100644
@@ -40,6 +40,7 @@ void sr32(void *, u32, u32, u32);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
+void omap_rev_string(char *omap4_rev_string);
 
 static inline u32 running_from_sdram(void)
 {
@@ -88,4 +89,10 @@ static inline u32 omap4_hw_init_context(void)
 #endif
 }
 
+static inline u32 omap_revision(void)
+{
+	extern u32 *const omap4_revision;
+	return *omap4_revision;
+}
+
 #endif
arch/arm/include/asm/armv7.h +5 -0
index 88b9c62..b5784d8 100644
@@ -25,6 +25,11 @@
 #define ARMV7_H
 #include <linux/types.h>
 
+/* Cortex-A9 revisions */
+#define MIDR_CORTEX_A9_R0P1	0x410FC091
+#define MIDR_CORTEX_A9_R1P2	0x411FC092
+#define MIDR_CORTEX_A9_R1P3	0x411FC093
+
 /* CCSIDR */
 #define CCSIDR_LINE_SIZE_OFFSET		0
 #define CCSIDR_LINE_SIZE_MASK		0x7
Signature · 1 line
1.7.0.4
author
#237 lore raw

PATCH v4 4/12 omap4: add clock support

In reply to Aneesh V

Add support for:
1. DPLL locking
2. Initialization of clock domains and clock modules
3. Setting up the right voltage on voltage rails

This work draws upon previous work done for x-loader by:
Santosh Shilimkar <[email protected]> Rajendra Nayak <[email protected]>

---
V2:
* Use pre-calculated M & N values instead of calculated ones
* Changes due to make file changes
* Some corrections
* Do all clock initialization in SPL itself instead of differing some work to u-boot

V3:
* Use struct for register addressing
* Support only Turbo OPP for MPU. OPP's above this need Smart Reflex enabled
* Cleaned up the scale_vcore(). Now takes into account the differing voltage offsets for different revisions of Phoenix.
* Removed references to deprecated utility functions - modify_reg_32() etc.
* Changed all spl_debug() to debug()
* Moved the host-program for calculating DPLL multiplier/divider to tools/omap/ directory. Added more documentation
* Replaced calls to omap4_revision() with omap_revision()
* Some changes to IVA and ABE dpll locking code

---
 arch/arm/cpu/armv7/omap4/Makefile           |    1 +
 arch/arm/cpu/armv7/omap4/board.c            |    1 +
 arch/arm/cpu/armv7/omap4/clocks.c           |  809 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/clocks.h    |  664 ++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h |    8 +
 arch/arm/include/asm/omap_common.h          |    3 +
 tools/omap/clocks_get_m_n.c                 |  197 +++++++
 7 files changed, 1683 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/clocks.c
 create mode 100644 arch/arm/include/asm/arch-omap4/clocks.h
 create mode 100644 tools/omap/clocks_get_m_n.c
arch/arm/cpu/armv7/omap4/Makefile +1 -0
index 987dc9d..ac4b2a6 100644
@@ -28,6 +28,7 @@ LIB	=  $(obj)lib$(SOC).o
 SOBJS	+= lowlevel_init.o
 
 COBJS	+= board.o
+COBJS	+= clocks.o
 COBJS	+= mem.o
 COBJS	+= sys_info.o
 
arch/arm/cpu/armv7/omap4/board.c +1 -0
index 09861a9..1c26a66 100644
@@ -154,6 +154,7 @@ void s_init(void)
 	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
+	prcm_init();
 }
 
 /*
arch/arm/cpu/armv7/omap4/clocks.c new file +809 -0

809 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/clocks.h new file +664 -0

664 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/sys_proto.h +8 -0
index c10fa18..f871921 100644
@@ -22,6 +22,7 @@
 #define _SYS_PROTO_H_
 
 #include <asm/arch/omap4.h>
+#include <asm/arch/clocks.h>
 #include <asm/io.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mux_omap4.h>
@@ -31,6 +32,8 @@ struct omap_sysinfo {
 };
 extern const struct omap_sysinfo sysinfo;
 
+extern struct omap4_prcm_regs *const prcm;
+
 void gpmc_init(void);
 void watchdog_init(void);
 u32 get_device_type(void);
@@ -41,6 +44,11 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 void omap_rev_string(char *omap4_rev_string);
+void prcm_init(void);
+void bypass_dpll(u32 *const base);
+void freq_update_core(void);
+u32 get_sys_clk_freq(void);
+u32 omap4_ddr_clk(void);
 
 static inline u32 running_from_sdram(void)
 {
arch/arm/include/asm/omap_common.h +3 -0
index d80f665..33caa4e 100644
@@ -25,6 +25,9 @@
 #ifndef	_OMAP_COMMON_H_
 #define	_OMAP_COMMON_H_
 
+/* Max value for DPLL multiplier M */
+#define OMAP_DPLL_MAX_N	127
+
 /* HW Init Context */
 #define OMAP_INIT_CONTEXT_SPL			0
 #define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR	1
tools/omap/clocks_get_m_n.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#238 lore raw

PATCH v4 5/12 omap4: add sdram init support

In reply to Aneesh V

Add support for the SDRAM controller (EMIF).

---
V2:
* Minor corrections in do_lpddr2_init()
* Minor corrections to read_idle interval calculation
* Sanity test of memory after doing the initialization
* Fixed warnings reported with with latest GCC compilers V3:
* Removed references to modify_reg_32()
* Updated references to OMAP_INIT_CONTEXT_* flags
* Replaced calls to omap4_revision() with omap_revision()
* Replaced sanity test with get_ram_size()

---
 arch/arm/cpu/armv7/omap4/Makefile           |    2 +
 arch/arm/cpu/armv7/omap4/board.c            |    6 +-
 arch/arm/cpu/armv7/omap4/emif.c             |  328 +++++++++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c     |  131 ++++
 arch/arm/include/asm/arch-omap4/clocks.h    |    8 +-
 arch/arm/include/asm/arch-omap4/emif.h      | 1025 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap4.h     |    5 +
 arch/arm/include/asm/arch-omap4/sys_proto.h |    2 +
 8 files changed, 1500 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/emif.c
 create mode 100644 arch/arm/cpu/armv7/omap4/sdram_elpida.c
 create mode 100644 arch/arm/include/asm/arch-omap4/emif.h
arch/arm/cpu/armv7/omap4/Makefile +2 -0
index ac4b2a6..e1ccd68 100644
@@ -29,7 +29,9 @@ SOBJS	+= lowlevel_init.o
 
 COBJS	+= board.o
 COBJS	+= clocks.o
+COBJS	+= emif.o
 COBJS	+= mem.o
+COBJS	+= sdram_elpida.o
 COBJS	+= sys_info.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/omap4/board.c +3 -3
index 1c26a66..ca107f7 100644
@@ -189,7 +189,7 @@ void watchdog_init(void)
  * This is needed because the size of memory installed may be
  * different on different versions of the board
  */
-u32 sdram_size(void)
+u32 omap4_sdram_size(void)
 {
 	u32 section, i, total_size = 0, size, addr;
 	for (i = 0; i < 4; i++) {
@@ -215,8 +215,8 @@ u32 sdram_size(void)
  */
 int dram_init(void)
 {
-
-	gd->ram_size = sdram_size();
+	sdram_init();
+	gd->ram_size = omap4_sdram_size();
 
 	return 0;
 }
arch/arm/cpu/armv7/omap4/emif.c new file +328 -0

328 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/sdram_elpida.c new file +131 -0

131 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/clocks.h +4 -4
index 71db39c..37bdcee 100644
@@ -33,10 +33,10 @@
  */
 #define LDELAY		1000000
 
-#define CM_CLKMODE_DPLL_CORE		(OMAP44XX_L4_CORE_BASE + 0x4120)
-#define CM_CLKMODE_DPLL_PER		(OMAP44XX_L4_CORE_BASE + 0x8140)
-#define CM_CLKMODE_DPLL_MPU		(OMAP44XX_L4_CORE_BASE + 0x4160)
-#define CM_CLKSEL_CORE			(OMAP44XX_L4_CORE_BASE + 0x4100)
+#define CM_CLKMODE_DPLL_CORE		0x4A004120
+#define CM_CLKMODE_DPLL_PER		0x4A008140
+#define CM_CLKMODE_DPLL_MPU		0x4A004160
+#define CM_CLKSEL_CORE			0x4A004100
 
 struct omap4_prcm_regs {
 	/* cm1.ckgen */
arch/arm/include/asm/arch-omap4/emif.h new file +1025 -0

1,025 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/omap4.h +5 -0
index 76b06c2..c9c86e1 100644
@@ -51,6 +51,11 @@
 #define CONTROL_PADCONF_CORE	(OMAP44XX_L4_CORE_BASE + 0x100000)
 #define CONTROL_PADCONF_WKUP	(OMAP44XX_L4_CORE_BASE + 0x31E000)
 
+/* LPDDR2 IO regs */
+#define LPDDR2_IO_REGS_BASE	0x4A100638
+
+#define CONTROL_EFUSE_2		0x4A100704
+
 /* CONTROL_ID_CODE */
 #define CONTROL_ID_CODE		0x4A002204
 
arch/arm/include/asm/arch-omap4/sys_proto.h +2 -0
index f871921..7183a90 100644
@@ -49,6 +49,8 @@ void bypass_dpll(u32 *const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
 u32 omap4_ddr_clk(void);
+void sdram_init(void);
+u32 omap4_sdram_size(void);
 
 static inline u32 running_from_sdram(void)
 {
Signature · 1 line
1.7.0.4
author
#239 lore raw

PATCH v4 6/12 omap4: calculate EMIF register values

In reply to Aneesh V

Calculate EMIF register values based on AC timing parameters from the SDRAM datasheet and the DDR frequency rather than using the hard-coded values.

For a new board the user doen't have to go through the tedious process of calculating the register values. Instead, just provide the AC timings from the device data sheet as input and the driver will automatically calculate the register values.

---
V3:
* Added SDRAM init related CONFIG flags for Panda too. Earlier Panda support for everything was added in a single patch at the end
* Replaced calls to omap4_revision() with omap_revision()
* Reorganization of code for better readability
* Some code re-organization to reduce #ifdef complexities - cleanly separated out functions for getting device details (geometry) vs timings
* Ensured un-necessary code is compiled out if CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REG is defined

---
 arch/arm/cpu/armv7/omap-common/Makefile     |    1 +
 arch/arm/cpu/armv7/omap-common/utils.c      |   57 ++
 arch/arm/cpu/armv7/omap4/board.c            |    9 +-
 arch/arm/cpu/armv7/omap4/emif.c             |  739 +++++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/sdram_elpida.c     |  151 ++++++
 arch/arm/include/asm/arch-omap4/emif.h      |    9 +
 arch/arm/include/asm/arch-omap4/omap4.h     |   10 +-
 arch/arm/include/asm/arch-omap4/sys_proto.h |    1 +
 include/configs/omap4_panda.h               |    5 +
 include/configs/omap4_sdp4430.h             |    5 +
 10 files changed, 977 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/utils.c
arch/arm/cpu/armv7/omap-common/Makefile +1 -0
index dc01ee5..8f698f8 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)libomap-common.o
 SOBJS	:= reset.o
 
 COBJS	:= timer.o
+COBJS	+= utils.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/arm/cpu/armv7/omap-common/utils.c new file +57 -0

57 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/board.c +5 -4
index ca107f7..786c239 100644
@@ -32,6 +32,7 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
+#include <asm/arch/emif.h>
 #include "omap4_mux_data.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -193,13 +194,13 @@ u32 omap4_sdram_size(void)
 {
 	u32 section, i, total_size = 0, size, addr;
 	for (i = 0; i < 4; i++) {
-		section	= __raw_readl(DMM_LISA_MAP_BASE + i*4);
-		addr = section & DMM_LISA_MAP_SYS_ADDR_MASK;
+		section	= __raw_readl(OMAP44XX_DMM_LISA_MAP_BASE + i*4);
+		addr = section & OMAP44XX_SYS_ADDR_MASK;
 		/* See if the address is valid */
 		if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
 		    (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
-			size	= ((section & DMM_LISA_MAP_SYS_SIZE_MASK) >>
-				    DMM_LISA_MAP_SYS_SIZE_SHIFT);
+			size	= ((section & OMAP44XX_SYS_SIZE_MASK) >>
+				   OMAP44XX_SYS_SIZE_SHIFT);
 			size	= 1 << size;
 			size	*= SZ_16M;
 			total_size += size;
arch/arm/cpu/armv7/omap4/emif.c +739 -0

764 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/sdram_elpida.c +151 -0

160 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/emif.h +9 -0
index 09e9baa..a167508 100644
@@ -1019,7 +1019,16 @@ struct emif_regs {
 #define emif_assert(c)	({ if (0) hang(); })
 #endif
 
+#ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
+#else
+void emif_get_device_details(u32 emif_nr,
+		struct lpddr2_device_details *cs0_device_details,
+		struct lpddr2_device_details *cs1_device_details);
+void emif_get_device_timings(u32 emif_nr,
+		const struct lpddr2_device_timings **cs0_device_timings,
+		const struct lpddr2_device_timings **cs1_device_timings);
+#endif
 
 #endif
arch/arm/include/asm/arch-omap4/omap4.h +4 -6
index c9c86e1..a8dbedb 100644
@@ -84,12 +84,6 @@
 /* GPMC */
 #define OMAP44XX_GPMC_BASE	0x50000000
 
-/* DMM */
-#define OMAP44XX_DMM_BASE		0x4E000000
-#define DMM_LISA_MAP_BASE		(OMAP44XX_DMM_BASE + 0x40)
-#define DMM_LISA_MAP_SYS_SIZE_MASK	(7 << 20)
-#define DMM_LISA_MAP_SYS_SIZE_SHIFT	20
-#define DMM_LISA_MAP_SYS_ADDR_MASK	(0xFF << 24)
 /*
  * Hardware Register Details
  */
@@ -137,6 +131,10 @@ struct s32ktimer {
 #define SRAM_SCRATCH_SPACE_ADDR		NON_SECURE_SRAM_START
 /* SRAM scratch space entries */
 #define OMAP4_SRAM_SCRATCH_OMAP4_REV	SRAM_SCRATCH_SPACE_ADDR
+#define OMAP4_SRAM_SCRATCH_EMIF_SIZE	(SRAM_SCRATCH_SPACE_ADDR + 0x4)
+#define OMAP4_SRAM_SCRATCH_EMIF_T_NUM	(SRAM_SCRATCH_SPACE_ADDR + 0xC)
+#define OMAP4_SRAM_SCRATCH_EMIF_T_DEN	(SRAM_SCRATCH_SPACE_ADDR + 0x10)
+#define OMAP4_SRAM_SCRATCH_SPACE_END	(SRAM_SCRATCH_SPACE_ADDR + 0x14)
 
 /* Silicon revisions */
 #define OMAP4430_SILICON_ID_INVALID	0xFFFFFFFF
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
index 7183a90..1e62878 100644
@@ -49,6 +49,7 @@ void bypass_dpll(u32 *const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
 u32 omap4_ddr_clk(void);
+void cancel_out(u32 *num, u32 *den, u32 den_limit);
 void sdram_init(void);
 u32 omap4_sdram_size(void);
 
include/configs/omap4_panda.h +5 -0
index 1daffb7..9f82ef4 100644
@@ -237,4 +237,9 @@
 #define CONFIG_SYS_PL310_BASE	0x48242000
 #endif
 
+/* Defines for SDRAM init */
+#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
+#endif
+
 #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +5 -0
index 68ffa87..6df1c3d 100644
@@ -243,4 +243,9 @@
 #define CONFIG_SYS_PL310_BASE	0x48242000
 #endif
 
+/* Defines for SDRAM init */
+#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
+#endif
+
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
author
#240 lore raw

PATCH v4 7/12 omap4: automatic sdram detection

In reply to Aneesh V

Identify SDRAM devices connected to EMIF automatically:
LPDDR2 devices have some Mode Registers that provide details about the device such as the type, density, bus width etc. EMIF has the capability to read these registers. If there are no devices connected to a given chip-select reading mode registers will return junk values. After reading as many such registers as possible and matching with expected ranges of values the driver can identify if there is a device connected to the respective CS. If we identify that a device is connected the values read give us complete details about the device.

This along with the base AC timings specified by JESD209-2 allows us to do a complete automatic initialization of SDRAM that works on all boards.

Please note that the default AC timings specified by JESD209-2 will be safe for all devices but not necessarily optimal. However, for the Elpida devices used on Panda and SDP the default timings are both safe and optimal.

---
V3:
* Code re-organization for better readability
* Ensured that un-necessary code is compiled out when CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION is not defined

---
 arch/arm/cpu/armv7/omap4/emif.c |  238 +++++++++++++++++++++++++++++++++++++++
 include/configs/omap4_panda.h   |    1 +
 include/configs/omap4_sdp4430.h |    1 +
 3 files changed, 240 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/omap4/emif.c +238 -0
index ceead9e..1234a7e 100644
@@ -792,6 +792,244 @@ void emif_get_device_timings(u32 emif_nr,
 }
 #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */
 
+#ifdef CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
+const char *get_lpddr2_type(u8 type_id)
+{
+	switch (type_id) {
+	case LPDDR2_TYPE_S4:
+		return "LPDDR2-S4";
+	case LPDDR2_TYPE_S2:
+		return "LPDDR2-S2";
+	default:
+		return NULL;
+	}
+}
+
+const char *get_lpddr2_io_width(u8 width_id)
+{
+	switch (width_id) {
+	case LPDDR2_IO_WIDTH_8:
+		return "x8";
+	case LPDDR2_IO_WIDTH_16:
+		return "x16";
+	case LPDDR2_IO_WIDTH_32:
+		return "x32";
+	default:
+		return NULL;
+	}
+}
+
+const char *get_lpddr2_manufacturer(u32 manufacturer)
+{
+	switch (manufacturer) {
+	case LPDDR2_MANUFACTURER_SAMSUNG:
+		return "Samsung";
+	case LPDDR2_MANUFACTURER_QIMONDA:
+		return "Qimonda";
+	case LPDDR2_MANUFACTURER_ELPIDA:
+		return "Elpida";
+	case LPDDR2_MANUFACTURER_ETRON:
+		return "Etron";
+	case LPDDR2_MANUFACTURER_NANYA:
+		return "Nanya";
+	case LPDDR2_MANUFACTURER_HYNIX:
+		return "Hynix";
+	case LPDDR2_MANUFACTURER_MOSEL:
+		return "Mosel";
+	case LPDDR2_MANUFACTURER_WINBOND:
+		return "Winbond";
+	case LPDDR2_MANUFACTURER_ESMT:
+		return "ESMT";
+	case LPDDR2_MANUFACTURER_SPANSION:
+		return "Spansion";
+	case LPDDR2_MANUFACTURER_SST:
+		return "SST";
+	case LPDDR2_MANUFACTURER_ZMOS:
+		return "ZMOS";
+	case LPDDR2_MANUFACTURER_INTEL:
+		return "Intel";
+	case LPDDR2_MANUFACTURER_NUMONYX:
+		return "Numonyx";
+	case LPDDR2_MANUFACTURER_MICRON:
+		return "Micron";
+	default:
+		return NULL;
+	}
+}
+
+static void display_sdram_details(u32 emif_nr, u32 cs,
+				  struct lpddr2_device_details *device)
+{
+	const char *mfg_str;
+	const char *type_str;
+	char density_str[10];
+	u32 density;
+
+	debug("EMIF%d CS%d\t", emif_nr, cs);
+
+	if (!device) {
+		debug("None\n");
+		return;
+	}
+
+	mfg_str = get_lpddr2_manufacturer(device->manufacturer);
+	type_str = get_lpddr2_type(device->type);
+
+	density = lpddr2_density_2_size_in_mbytes[device->density];
+	if ((density / 1024 * 1024) == density) {
+		density /= 1024;
+		sprintf(density_str, "%d GB", density);
+	} else
+		sprintf(density_str, "%d MB", density);
+	if (mfg_str && type_str)
+		debug("%s\t\t%s\t%s\n", mfg_str, type_str, density_str);
+}
+
+static u8 is_lpddr2_sdram_present(u32 base, u32 cs,
+				  struct lpddr2_device_details *lpddr2_device)
+{
+	u32 mr = 0, temp;
+
+	mr = get_mr(base, cs, LPDDR2_MR0);
+	if (mr > 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	temp = (mr & LPDDR2_MR0_DI_MASK) >> LPDDR2_MR0_DI_SHIFT;
+	if (temp) {
+		/* Not SDRAM */
+		return 0;
+	}
+	temp = (mr & LPDDR2_MR0_DNVI_MASK) >> LPDDR2_MR0_DNVI_SHIFT;
+
+	if (temp) {
+		/* DNV supported - But DNV is only supported for NVM */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR4);
+	if (mr > 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR5);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	if (!get_lpddr2_manufacturer(mr)) {
+		/* Manufacturer not identified */
+		return 0;
+	}
+	lpddr2_device->manufacturer = mr;
+
+	mr = get_mr(base, cs, LPDDR2_MR6);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR7);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	mr = get_mr(base, cs, LPDDR2_MR8);
+	if (mr >= 0xFF) {
+		/* Mode register value bigger than 8 bit */
+		return 0;
+	}
+
+	temp = (mr & MR8_TYPE_MASK) >> MR8_TYPE_SHIFT;
+	if (!get_lpddr2_type(temp)) {
+		/* Not SDRAM */
+		return 0;
+	}
+	lpddr2_device->type = temp;
+
+	temp = (mr & MR8_DENSITY_MASK) >> MR8_DENSITY_SHIFT;
+	if (temp > LPDDR2_DENSITY_32Gb) {
+		/* Density not supported */
+		return 0;
+	}
+	lpddr2_device->density = temp;
+
+	temp = (mr & MR8_IO_WIDTH_MASK) >> MR8_IO_WIDTH_SHIFT;
+	if (!get_lpddr2_io_width(temp)) {
+		/* IO width unsupported value */
+		return 0;
+	}
+	lpddr2_device->io_width = temp;
+
+	/*
+	 * If all the above tests pass we should
+	 * have a device on this chip-select
+	 */
+	return 1;
+}
+
+static struct lpddr2_device_details *get_lpddr2_details(u32 base, u8 cs,
+			struct lpddr2_device_details *lpddr2_dev_details)
+{
+	u32 phy;
+	struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
+
+	if (!lpddr2_dev_details)
+		return NULL;
+
+	/* Do the minimum init for mode register accesses */
+	if (!running_from_sdram()) {
+		phy = get_ddr_phy_ctrl_1(get_sys_clk_freq() / 2, RL_BOOT);
+		writel(phy, &emif->emif_ddr_phy_ctrl_1);
+	}
+
+	if (!(is_lpddr2_sdram_present(base, cs, lpddr2_dev_details)))
+		return NULL;
+
+	display_sdram_details(emif_num(base), cs, lpddr2_dev_details);
+
+	return lpddr2_dev_details;
+}
+
+void emif_get_device_details(u32 emif_nr,
+		struct lpddr2_device_details *cs0_device_details,
+		struct lpddr2_device_details *cs1_device_details)
+{
+	u32 base = (emif_nr == 1) ? OMAP44XX_EMIF1 : OMAP44XX_EMIF2;
+
+	if (running_from_sdram()) {
+		/*
+		 * We can not do automatic discovery running from SDRAM
+		 * Most likely we came here by mistake. Indicate error
+		 * by returning NULL
+		 */
+		cs0_device_details = NULL;
+		cs1_device_details = NULL;
+	} else {
+		/*
+		 * Automatically find the device details:
+		 *
+		 * Reset the PHY after each call to get_lpddr2_details().
+		 * If there is nothing connected to a given chip select
+		 * (typically CS1) mode register reads will mess up with
+		 * the PHY state and subsequent initialization won't work.
+		 * PHY reset brings back PHY to a good state.
+		 */
+		cs0_device_details =
+		    get_lpddr2_details(base, CS0, cs0_device_details);
+		emif_reset_phy(base);
+
+		cs1_device_details =
+		    get_lpddr2_details(base, CS1, cs1_device_details);
+		emif_reset_phy(base);
+	}
+}
+#endif /* CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION */
+
 static void do_sdram_init(u32 base)
 {
 	const struct emif_regs *regs;
include/configs/omap4_panda.h +1 -0
index 9f82ef4..a8dd861 100644
@@ -239,6 +239,7 @@
 
 /* Defines for SDRAM init */
 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
include/configs/omap4_sdp4430.h +1 -0
index 6df1c3d..534f89a 100644
@@ -245,6 +245,7 @@
 
 /* Defines for SDRAM init */
 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
Signature · 1 line
1.7.0.4
author
#241 lore raw

PATCH v4 8/12 armv7: start.S: fixes and enhancements for SPL

In reply to Aneesh V

- Allow SPL to have .bss disjoint from rest of the image
- Allow for .bss setup in CONFIG_SPL_BUILD case too.
- Take care of the special case where relocation offset = 0.
- Compile out exception handling code and install a simpler vector

---
V3:
* Taken care of the case where .bss is at a lower address comapred to _start

V4:
* Rebased to the latest u-boot-ti/master

---
 arch/arm/cpu/armv7/start.S    |   49 +++++++++++++++++++++++++++++++----------
 arch/arm/cpu/armv7/u-boot.lds |    2 +
 2 files changed, 39 insertions(+), 12 deletions(-)
arch/arm/cpu/armv7/start.S +37 -12
index 5c87e9c..02a2535 100644
@@ -42,7 +42,16 @@ _start: b	reset
 	ldr	pc, _not_used
 	ldr	pc, _irq
 	ldr	pc, _fiq
-
+#ifdef CONFIG_SPL_BUILD
+_undefined_instruction: .word _undefined_instruction
+_software_interrupt:	.word _software_interrupt
+_prefetch_abort:	.word _prefetch_abort
+_data_abort:		.word _data_abort
+_not_used:		.word _not_used
+_irq:			.word _irq
+_fiq:			.word _fiq
+_pad:			.word 0x12345678 /* now 16*4=64 */
+#else
 _undefined_instruction: .word undefined_instruction
 _software_interrupt:	.word software_interrupt
 _prefetch_abort:	.word prefetch_abort
@@ -51,6 +60,8 @@ _not_used:		.word not_used
 _irq:			.word irq
 _fiq:			.word fiq
 _pad:			.word 0x12345678 /* now 16*4=64 */
+#endif	/* CONFIG_SPL_BUILD */
+
 .global _end_vect
 _end_vect:
 
@@ -89,6 +100,10 @@ _armboot_start:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -182,12 +197,11 @@ stack_setup:
 	mov	sp, r4
 
 	adr	r0, _start
-#ifndef CONFIG_SPL_BUILD
 	cmp	r0, r6
+	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */
 	beq	clear_bss		/* skip relocation */
-#endif
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
@@ -235,20 +249,34 @@ fixnext:
 	add	r2, r2, #8		/* each rel.dyn entry is 8 bytes */
 	cmp	r2, r3
 	blo	fixloop
+	b	clear_bss
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
+#endif	/* #ifndef CONFIG_SPL_BUILD */
 
 clear_bss:
+#ifdef CONFIG_SPL_BUILD
+	/* No relocation for SPL */
+	ldr	r0, =__bss_start
+	ldr	r1, =__bss_end__
+#else
 	ldr	r0, _bss_start_ofs
 	ldr	r1, _bss_end_ofs
 	mov	r4, r6			/* reloc addr */
 	add	r0, r0, r4
 	add	r1, r1, r4
+#endif
 	mov	r2, #0x00000000		/* clear			    */
 
 clbss_l:str	r2, [r0]		/* clear loop...		    */
 	add	r0, r0, #4
 	cmp	r0, r1
 	bne	clbss_l
-#endif	/* #ifndef CONFIG_SPL_BUILD */
 
 /*
  * We are done. Do not return, instead branch to second part of board
@@ -276,12 +304,6 @@ jump_2_ram:
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 /*************************************************************************
@@ -329,6 +351,8 @@ cpu_init_crit:
 	mov	lr, ip			@ restore link
 	mov	pc, lr			@ back to my caller
 #endif
+
+#ifndef CONFIG_SPL_BUILD
 /*
  *************************************************************************
  *
@@ -516,4 +540,5 @@ fiq:
 	bad_save_user_regs
 	bl	do_fiq
 
-#endif
+#endif /* CONFIG_USE_IRQ */
+#endif /* CONFIG_SPL_BUILD */
arch/arm/cpu/armv7/u-boot.lds +2 -0
index dbae54d..40ecf78 100644
@@ -55,6 +55,8 @@ SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
Signature · 1 line
1.7.0.4
author
#242 lore raw

PATCH v4 9/12 omap: add basic SPL support

In reply to Aneesh V

- Provide alternate implementations of board_init_f() board_init_r() for OMAP spl.
- Provide linker script
- Initialize global data
- Add serial console support
- Update CONFIG_SYS_TEXT_BASE to allow for SPL's bss and move it to board config header from config.mk

---

This patch adds two checkpatch warnings that look like false positives. Reported these to checkpatch maintainer.

V2:
* Removed the label __flash_image_end because _end serves the same purpose after rebasing to latest mainline

V3:
* Moved CONFIG_SYS_TEXT_BASE to board config header and deleted config.mk
* Changes for the struct based register accesses
* Removed usage of modify_reg_32() macro
* omap4_rev_string() reference changed to omap_rev_string()
* Folded the patches for linker script changes and console support into this patch
* Improved commit message

V4:
* Changed the CONFIG_SYS_SPL_* config flags to:
CONFIG_SPL_*
* Changed the name omap4_rev_string used in spl.c as this file is common for OMAP3/4

---
 arch/arm/cpu/armv7/Makefile                   |    7 ++-
 arch/arm/cpu/armv7/omap-common/Makefile       |    4 +
 arch/arm/cpu/armv7/omap-common/spl.c          |   82 +++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds |   62 +++++++++++++++++++
 arch/arm/cpu/armv7/omap4/Makefile             |    5 +-
 arch/arm/cpu/armv7/omap4/board.c              |    7 ++
 arch/arm/cpu/armv7/omap4/clocks.c             |   33 ++++++++++
 arch/arm/include/asm/arch-omap4/sys_proto.h   |    1 +
 arch/arm/include/asm/omap_common.h            |    2 +
 board/ti/panda/Makefile                       |    2 +
 board/ti/panda/config.mk                      |   31 ---------
 board/ti/sdp4430/Makefile                     |    2 +
 board/ti/sdp4430/config.mk                    |   31 ---------
 include/configs/omap4_panda.h                 |   26 ++++++++
 include/configs/omap4_sdp4430.h               |   26 ++++++++
 15 files changed, 257 insertions(+), 64 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl.c
 create mode 100644 arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
 delete mode 100644 board/ti/panda/config.mk
 delete mode 100644 board/ti/sdp4430/config.mk
arch/arm/cpu/armv7/Makefile +6 -1
index 299792a..92a5a96 100644
@@ -26,7 +26,12 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).o
 
 START	:= start.o
-COBJS	:= cpu.o cache_v7.o
+
+ifndef CONFIG_SPL_BUILD
+COBJS	+= cache_v7.o
+COBJS	+= cpu.o
+endif
+
 COBJS  += syslib.o
 
 SRCS	:= $(START:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/omap-common/Makefile +4 -0
index 8f698f8..0708796 100644
@@ -30,6 +30,10 @@ SOBJS	:= reset.o
 COBJS	:= timer.o
 COBJS	+= utils.o
 
+ifdef CONFIG_SPL_BUILD
+COBJS	+= spl.o
+endif
+
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
arch/arm/cpu/armv7/omap-common/spl.c new file +82 -0

82 lines not on this page · raw message

arch/arm/cpu/armv7/omap-common/u-boot-spl.lds new file +62 -0

62 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/Makefile +4 -1
index e1ccd68..e7ee0b8 100644
@@ -30,9 +30,12 @@ SOBJS	+= lowlevel_init.o
 COBJS	+= board.o
 COBJS	+= clocks.o
 COBJS	+= emif.o
-COBJS	+= mem.o
 COBJS	+= sdram_elpida.o
+
+ifndef CONFIG_SPL_BUILD
+COBJS	+= mem.o
 COBJS	+= sys_info.o
+endif
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap4/board.c +7 -0
index 786c239..54dd509 100644
@@ -155,7 +155,14 @@ void s_init(void)
 	init_omap4_revision();
 	watchdog_init();
 	set_mux_conf_regs();
+#ifdef CONFIG_SPL_BUILD
+	preloader_console_init();
+#endif
 	prcm_init();
+#ifdef CONFIG_SPL_BUILD
+	/* For regular u-boot sdram_init() is called from dram_init() */
+	sdram_init();
+#endif
 }
 
 /*
arch/arm/cpu/armv7/omap4/clocks.c +33 -0
index e8d3a52..f1e233a 100644
@@ -791,6 +791,39 @@ void lock_dpll(u32 *const base)
 	wait_for_lock(base);
 }
 
+void setup_clocks_for_console(void)
+{
+	/* Do not add any spl_debug prints in this function */
+	clrsetbits_le32(&prcm->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
+			CD_CLKCTRL_CLKTRCTRL_SW_WKUP <<
+			CD_CLKCTRL_CLKTRCTRL_SHIFT);
+
+	/* Enable all UARTs - console will be on one of them */
+	clrsetbits_le32(&prcm->cm_l4per_uart1_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart2_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart3_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_uart3_clkctrl,
+			MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	clrsetbits_le32(&prcm->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
+			CD_CLKCTRL_CLKTRCTRL_HW_AUTO <<
+			CD_CLKCTRL_CLKTRCTRL_SHIFT);
+}
+
 void prcm_init(void)
 {
 	switch (omap4_hw_init_context()) {
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
index 1e62878..a81f8e5 100644
@@ -44,6 +44,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void set_pl310_ctrl_reg(u32 val);
 void omap_rev_string(char *omap4_rev_string);
+void setup_clocks_for_console(void);
 void prcm_init(void);
 void bypass_dpll(u32 *const base);
 void freq_update_core(void);
arch/arm/include/asm/omap_common.h +2 -0
index 33caa4e..69d53d2 100644
@@ -34,4 +34,6 @@
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
 
+void preloader_console_init(void);
+
 #endif /* _OMAP_COMMON_H_ */
board/ti/panda/Makefile +2 -0
index 2186403..09f88ee 100644
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef CONFIG_SPL_BUILD
 COBJS	:= panda.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/ti/panda/config.mk deleted +0 -31
deleted file mode 100644
index 33901a7..0000000
@@ -1,31 +0,0 @@
-#
-# (C) Copyright 2006-2009
-# Texas Instruments Incorporated, <www.ti.com>
-#
-# OMAP 4430 SDP
-# see http://www.ti.com/ for more information on Texas Instruments
-#
-# 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
-#
-# SDRAM Address Space:
-# 8000'0000 - 9fff'ffff (512 MB)
-# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
-# (mem base + reserved)
-
-CONFIG_SYS_TEXT_BASE = 0x80e80000
board/ti/sdp4430/Makefile +2 -0
index f1ee544..12f2743 100644
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef CONFIG_SPL_BUILD
 COBJS	:= sdp.o cmd_bat.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/ti/sdp4430/config.mk deleted +0 -31
deleted file mode 100644
index 33901a7..0000000
@@ -1,31 +0,0 @@
-#
-# (C) Copyright 2006-2009
-# Texas Instruments Incorporated, <www.ti.com>
-#
-# OMAP 4430 SDP
-# see http://www.ti.com/ for more information on Texas Instruments
-#
-# 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
-#
-# SDRAM Address Space:
-# 8000'0000 - 9fff'ffff (512 MB)
-# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
-# (mem base + reserved)
-
-CONFIG_SYS_TEXT_BASE = 0x80e80000
include/configs/omap4_panda.h +26 -0
index a8dd861..1112362 100644
@@ -243,4 +243,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SPL_TEXT_BASE		0x40304350
+#define CONFIG_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SPL_BSS_START_ADDR	0x80000000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
 #endif /* __CONFIG_H */
include/configs/omap4_sdp4430.h +26 -0
index 534f89a..6a6be9e 100644
@@ -249,4 +249,30 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 #endif
 
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SPL_TEXT_BASE		0x40304350
+#define CONFIG_SPL_MAX_SIZE		0x8000	/* 32 K */
+#define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SPL_BSS_START_ADDR	0x80000000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
+
+/*
+ * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+ * 64 bytes before this address should be set aside for u-boot.img's
+ * header. That is 0x800FFFC0--0x80100000 should not be used for any
+ * other needs.
+ */
+#define CONFIG_SYS_TEXT_BASE		0x80100000
+
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
author
#243 lore raw

PATCH v4 10/12 Correct ih_os for u-boot.img

In reply to Aneesh V

Provide appropriate '-O u-boot' while doing mkimage for u-boot.img

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index 0707036..f8ae883 100644
@@ -375,7 +375,7 @@ $(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
 
 $(obj)u-boot.img:	$(obj)u-boot.bin
 		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
-		-a $(CONFIG_SYS_TEXT_BASE) -e 0 \
+		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
Signature · 1 line
1.7.0.4
author
#244 lore raw

PATCH v4 11/12 omap: add MMC and FAT support to SPL

In reply to Aneesh V

- Add MMC raw and FAT mode boot support for OMAP
- Provide a means by which parameters passed by ROM-code can be saved in u-boot.
- Save boot mode related information passed by OMAP4 ROM-code and use it to determine where to load the u-boot from
- Assumes that the image has a mkimage header. Gets the payload size and load address from this header. If the header is not detected assume u-boot.bin as payload

---
V3:
* Squashed the patches that provided MMC support, FAT support, start.S hook for saving parameters, and OMAP4 patch for saving the parameters all into this patch.
* Removed the assumption that payload is u-boot.bin. Payload size and address

---
 arch/arm/cpu/armv7/cpu.c                 |    7 +
 arch/arm/cpu/armv7/omap-common/spl.c     |  194 +++++++++++++++++++++++++++++-
 arch/arm/cpu/armv7/omap4/board.c         |   21 ++++
 arch/arm/cpu/armv7/omap4/lowlevel_init.S |   31 +++++
 arch/arm/cpu/armv7/start.S               |    1 +
 arch/arm/include/asm/arch-omap4/omap4.h  |    8 ++
 arch/arm/include/asm/omap_common.h       |   17 +++
 include/configs/omap4_panda.h            |    5 +
 include/configs/omap4_sdp4430.h          |    5 +
 9 files changed, 287 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/cpu.c +7 -0
index def9ced..091e3e0 100644
@@ -37,6 +37,13 @@
 #include <asm/cache.h>
 #include <asm/armv7.h>
 
+void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
+{
+}
+
+void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
+	__attribute__((weak, alias("save_boot_params_default")));
+
 int cleanup_before_linux(void)
 {
 	/*
arch/arm/cpu/armv7/omap-common/spl.c +192 -2

217 lines not on this page · raw message

arch/arm/cpu/armv7/omap4/board.c +21 -0
index 54dd509..2e5739a 100644
@@ -39,6 +39,27 @@ DECLARE_GLOBAL_DATA_PTR;
 
 u32 *const omap4_revision = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
 
+#ifdef CONFIG_SPL_BUILD
+/*
+ * We use static variables because global data is not ready yet.
+ * Initialized data is available in SPL right from the beginning.
+ * We would not typically need to save these parameters in regular
+ * U-Boot. This is needed only in SPL at the moment.
+ */
+u32 omap4_boot_device = BOOT_DEVICE_MMC1;
+u32 omap4_boot_mode = MMCSD_MODE_FAT;
+
+u32 omap_boot_device(void)
+{
+	return omap4_boot_device;
+}
+
+u32 omap_boot_mode(void)
+{
+	return omap4_boot_mode;
+}
+#endif
+
 void do_set_mux(u32 base, struct pad_conf_entry const *array, int size)
 {
 	int i;
arch/arm/cpu/armv7/omap4/lowlevel_init.S +31 -0
index 6abfbba..91525ec 100644
@@ -27,6 +27,37 @@
  */
 
 #include <asm/arch/omap4.h>
+#ifdef CONFIG_SPL_BUILD
+.global save_boot_params
+save_boot_params:
+	/*
+	 * See if the rom code passed pointer is valid:
+	 * It is not valid if it is not in non-secure SRAM
+	 * This may happen if you are booting with the help of
+	 * debugger
+	 */
+	ldr     r2, =NON_SECURE_SRAM_START
+	cmp	r2, r0
+	bgt	1f
+	ldr	r2, =NON_SECURE_SRAM_END
+	cmp	r2, r0
+	blt	1f
+
+	/* Store the boot device in omap4_boot_device */
+	ldr     r2, [r0, #BOOT_DEVICE_OFFSET]	@ r1 <- value of boot device
+	and	r2, #BOOT_DEVICE_MASK
+	ldr	r3, =omap4_boot_device
+	str     r2, [r3]			@ omap4_boot_device <- r1
+
+	/* Store the boot mode (raw/FAT) in omap4_boot_mode */
+	ldr	r2, [r0, #DEV_DESC_PTR_OFFSET]	@ get the device descriptor ptr
+	ldr	r2, [r2, #DEV_DATA_PTR_OFFSET]	@ get the pDeviceData ptr
+	ldr	r2, [r2, #BOOT_MODE_OFFSET]	@ get the boot mode
+	ldr	r3, =omap4_boot_mode
+	str	r2, [r3]
+1:
+	bx	lr
+#endif
 
 .globl lowlevel_init
 lowlevel_init:
arch/arm/cpu/armv7/start.S +1 -0
index 02a2535..db8e9d2 100644
@@ -134,6 +134,7 @@ IRQ_STACK_START_IN:
  */
 
 reset:
+	bl	save_boot_params
 	/*
 	 * set the cpu to SVC32 mode
 	 */
arch/arm/include/asm/arch-omap4/omap4.h +8 -0
index a8dbedb..563544f 100644
@@ -144,4 +144,12 @@ struct s32ktimer {
 #define OMAP4430_ES2_2	0x44300220
 #define OMAP4430_ES2_3	0x44300230
 
+/* ROM code defines */
+/* Boot device */
+#define BOOT_DEVICE_MASK	0xFF
+#define BOOT_DEVICE_OFFSET	0x8
+#define DEV_DESC_PTR_OFFSET	0x4
+#define DEV_DATA_PTR_OFFSET	0x18
+#define BOOT_MODE_OFFSET	0x8
+
 #endif
arch/arm/include/asm/omap_common.h +17 -0
index 69d53d2..d3cb857 100644
@@ -36,4 +36,21 @@
 
 void preloader_console_init(void);
 
+/* Boot device */
+#define BOOT_DEVICE_NONE	0
+#define BOOT_DEVICE_XIP		1
+#define BOOT_DEVICE_XIPWAIT	2
+#define BOOT_DEVICE_NAND	3
+#define BOOT_DEVICE_ONE_NAND	4
+#define BOOT_DEVICE_MMC1	5
+#define BOOT_DEVICE_MMC2	6
+
+/* Boot type */
+#define	MMCSD_MODE_UNDEFINED	0
+#define MMCSD_MODE_RAW		1
+#define MMCSD_MODE_FAT		2
+
+u32 omap_boot_device(void);
+u32 omap_boot_mode(void);
+
 #endif /* _OMAP_COMMON_H_ */
include/configs/omap4_panda.h +5 -0
index 1112362..f6f283a 100644
@@ -252,6 +252,11 @@
 #define CONFIG_SPL_BSS_START_ADDR	0x80000000
 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
 
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x300 /* address 0x60000 */
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
include/configs/omap4_sdp4430.h +5 -0
index 6a6be9e..346763d 100644
@@ -258,6 +258,11 @@
 #define CONFIG_SPL_BSS_START_ADDR	0x80000000
 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
 
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x300 /* address 0x60000 */
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
Signature · 1 line
1.7.0.4
author
#245 lore raw

PATCH v4 12/12 mkimage: Add OMAP boot image support

In reply to Aneesh V

From: John Rigby <[email protected]>

- Add mkimage support for OMAP boot image
- Add support for OMAP boot image(MLO) generation in the new SPL framework

---
V3:
* Fixed minor issue with casting away 'const'ness of pointers
* Ensure lists are sorted alphabetically
* Added an error message
* Removed 'packed' attribute from structs
* Fixed some other minor comments on V2
* Adapted for the new SPL framework
V4:
* Replaced CONFIG_SYS_SPL_TEXT_BASE with CONFIG_SPL_TEXT_BASE

---
 arch/arm/cpu/armv7/omap4/config.mk |   30 +++++
 common/image.c                     |    9 +-
 include/image.h                    |    1 +
 spl/Makefile                       |    6 +
 tools/Makefile                     |    2 +
 tools/mkimage.c                    |    2 +
 tools/mkimage.h                    |    1 +
 tools/omapimage.c                  |  224 ++++++++++++++++++++++++++++++++++++
 tools/omapimage.h                  |   50 ++++++++
 9 files changed, 321 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap4/config.mk
 create mode 100644 tools/omapimage.c
 create mode 100644 tools/omapimage.h
arch/arm/cpu/armv7/omap4/config.mk new file +30 -0
new file mode 100644
index 0000000..b34fa64
@@ -0,0 +1,30 @@
+#
+# Copyright 2011 Linaro Limited
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# (C) Copyright 2010
+# Texas Instruments, <www.ti.com>
+#
+# Aneesh V <[email protected]>
+#
+# 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
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y	+= $(OBJTREE)/MLO
+else
+ALL-y	+= $(obj)u-boot.img
+endif
common/image.c +5 -4
index 5c7d4f4..5f71c99 100644
@@ -130,17 +130,18 @@ static const table_entry_t uimage_os[] = {
 };
 
 static const table_entry_t uimage_type[] = {
-	{	IH_TYPE_INVALID,    NULL,	  "Invalid Image",	},
 	{	IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image",	},
 	{	IH_TYPE_FIRMWARE,   "firmware",	  "Firmware",		},
+	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
+	{	IH_TYPE_INVALID,    NULL,	  "Invalid Image",	},
+	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	IH_TYPE_KERNEL,	    "kernel",	  "Kernel Image",	},
+	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
 	{	IH_TYPE_MULTI,	    "multi",	  "Multi-File Image",	},
+	{	IH_TYPE_OMAPIMAGE,  "omapimage",  "TI OMAP SPL With GP CH",},
 	{	IH_TYPE_RAMDISK,    "ramdisk",	  "RAMDisk Image",	},
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
-	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
-	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
-	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
include/image.h +1 -0
index c31e862..c606644 100644
@@ -157,6 +157,7 @@
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
 #define IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
 #define IH_TYPE_IMXIMAGE	10	/* Freescale IMXBoot Image	*/
+#define IH_TYPE_OMAPIMAGE	11	/* TI OMAP Config Header Image	*/
 
 /*
  * Compression Types
spl/Makefile +6 -0
index 638aab7..2a1fd11 100644
@@ -85,6 +85,12 @@ LDPPFLAGS += \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
+ifdef CONFIG_OMAP
+$(OBJTREE)/MLO:	$(obj)u-boot-spl.bin
+	$(OBJTREE)/tools/mkimage -T omapimage \
+		-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
+endif
+
 ALL-y	+= $(obj)u-boot-spl.bin
 
 all:	$(ALL-y)
tools/Makefile +2 -0
index 97f83f8..cb7f92d 100644
@@ -88,6 +88,7 @@ OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
 NOPED_OBJ_FILES-y += kwbimage.o
 NOPED_OBJ_FILES-y += imximage.o
+NOPED_OBJ_FILES-y += omapimage.o
 NOPED_OBJ_FILES-y += mkimage.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
@@ -188,6 +189,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)md5.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \
+			$(obj)omapimage.o \
 			$(obj)sha1.o \
 			$(LIBFDT_OBJS)
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
tools/mkimage.c +2 -0
index 60f7263..b6a7cb7 100644
@@ -156,6 +156,8 @@ main (int argc, char **argv)
 	init_imx_image_type ();
 	/* Init FIT image generation/list support */
 	init_fit_image_type ();
+	/* Init TI OMAP Boot image generation/list support */
+	init_omap_image_type();
 	/* Init Default image generation/list support */
 	init_default_image_type ();
 
tools/mkimage.h +1 -0
index 9033a7d..3b49645 100644
@@ -143,5 +143,6 @@ void init_kwb_image_type (void);
 void init_imx_image_type (void);
 void init_default_image_type (void);
 void init_fit_image_type (void);
+void init_omap_image_type(void);
 
 #endif /* _MKIIMAGE_H_ */
tools/omapimage.c new file +224 -0

224 lines not on this page · raw message

tools/omapimage.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.0.4