Skip to contentSkip to conversation

omap2420-h4: Fix u-boot support for board

PATCH New Jon Hunter 2 participants 8 messages Apr 3, 2013 – Apr 10, 2013 Arm (32-bit)

lore
Share & tools
lore

Jon Hunter

author
#0 lore raw

cover omap2420-h4: Fix u-boot support for board

Currently, u-boot support for the omap2420-h4 board is broken and u-boot is not booting when program into flash. Fix u-boot support for this board.

Jon Hunter (4):
omap2420-h4: Fix DRAM initialisation
omap2420-h4: Fix booting from NOR flash
omap2420-h4: Add device tree support
omap2420-h4: Fix get_timer() and CONFIG_SYS_HZ

 arch/arm/cpu/arm1136/omap24xx/timer.c         |    8 ++++++--
 arch/arm/include/asm/arch-omap24xx/omap2420.h |    6 +++---
 board/ti/omap2420h4/config.mk                 |    4 ++--
 board/ti/omap2420h4/mem.c                     |   13 -------------
 board/ti/omap2420h4/omap2420h4.c              |   24 ++++++++++++++++++------
 include/configs/omap2420h4.h                  |    5 +++--
 6 files changed, 32 insertions(+), 28 deletions(-)
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 1/4 omap2420-h4: Fix DRAM initialisation

The size of the DRAM for the omap2420-h4 board is getting setup in the dram_init() function. However, for the current u-boot release this is too late and needs to be done in dram_init_banksize(). Therefore, add a dram_init_banksize() function for the omap2420-h4 board and setup the DRAM size there.

---
 board/ti/omap2420h4/omap2420h4.c |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
board/ti/omap2420h4/omap2420h4.c +18 -6
index 188e4ac..532e989 100644
@@ -190,10 +190,10 @@ void ether_init (void)
  * Routine: dram_init
  * Description: sets uboots idea of sdram size
  **********************************************/
-int dram_init (void)
+int dram_init(void)
 {
 	unsigned int size0=0,size1=0;
-	u32 mtype, btype, rev;
+	u32 mtype, btype;
 	u8 chg_on = 0x5; /* enable charge of back up battery */
 	u8 vmode_on = 0x8C;
 	#define NOT_EARLY 0
@@ -202,7 +202,6 @@ int dram_init (void)
 
 	btype = get_board_type();
 	mtype = get_mem_type();
-	rev = get_cpu_rev();
 
 	display_board_info(btype);
 	if (btype == BOARD_H4_MENELAUS){
@@ -217,15 +216,28 @@ int dram_init (void)
 	size0 = get_sdr_cs_size(SDRC_CS0_OSET);
 	size1 = get_sdr_cs_size(SDRC_CS1_OSET);
 
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = size0;
+	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, size0 + size1);
+
+	return 0;
+}
+
+void dram_init_banksize(void)
+{
+	unsigned int size0, size1;
+	u32 rev;
+
+	rev = get_cpu_rev();
+	size0 = get_sdr_cs_size(SDRC_CS0_OSET);
+	size1 = get_sdr_cs_size(SDRC_CS1_OSET);
+
 	if(rev == CPU_2420_2422_ES1) /* ES1's 128MB remap granularity isn't worth doing */
 		gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
 	else /* ES2 and above can remap at 32MB granularity */
 		gd->bd->bi_dram[1].start = PHYS_SDRAM_1+size0;
 	gd->bd->bi_dram[1].size = size1;
 
-	return 0;
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
 }
 
 /**********************************************************
Signature · 1 line
1.7.10.4
author
#2 lore raw

PATCH 2/4 omap2420-h4: Fix booting from NOR flash

In reply to Jon Hunter

The omap2420-h4 board is using a RAM based address as the linker location for code. This is causing several problems when attempting to run the latest u-boot code base on this board from flash. Update the default linker location for code to be in NOR flash. Please note that OMAP maps the NOR flash to address 0x08000000 by default and so use this as the default address for the NOR flash.

Also remove legacy code that attempts to calculate where in flash the sdata structure, that holds the memory interface configuration data, is located. By changing the default linker location for code to flash this is no longer necessary.

---
 arch/arm/include/asm/arch-omap24xx/omap2420.h |    6 +++---
 board/ti/omap2420h4/config.mk                 |    4 ++--
 board/ti/omap2420h4/mem.c                     |   13 -------------
 include/configs/omap2420h4.h                  |    2 +-
 4 files changed, 6 insertions(+), 19 deletions(-)
arch/arm/include/asm/arch-omap24xx/omap2420.h +3 -3
index d8d5647..5724f5d 100644
@@ -212,9 +212,9 @@
 # define H4_CS1_BASE           0x04000000  /* debug board */
 # define H4_CS2_BASE           0x0A000000  /* wifi board */
 #else
-# define H4_CS0_BASE           0x04000000  /* flash (64 Meg aligned) */
-# define H4_CS1_BASE           0x08000000  /* debug board */
-# define H4_CS2_BASE           0x0A000000  /* wifi board */
+# define H4_CS0_BASE           0x08000000  /* flash (64 Meg aligned) */
+# define H4_CS1_BASE           0x04000000  /* debug board */
+# define H4_CS2_BASE           0x0C000000  /* wifi board */
 #endif
 
 /* base address for indirect vectors (internal boot mode) */
board/ti/omap2420h4/config.mk +2 -2
index ca5ebdf..e5dff69 100644
@@ -14,7 +14,7 @@
 # (mem base + reserved)
 
 # For use with external or internal boots.
-CONFIG_SYS_TEXT_BASE = 0x80e80000
+#CONFIG_SYS_TEXT_BASE = 0x80e80000
 
 # Used with full SRAM boot.
 # This is either with a GP system or a signed boot image.
@@ -24,5 +24,5 @@ CONFIG_SYS_TEXT_BASE = 0x80e80000
 
 # Handy to get symbols to debug ROM version.
 #CONFIG_SYS_TEXT_BASE = 0x0
-#CONFIG_SYS_TEXT_BASE = 0x08000000
+CONFIG_SYS_TEXT_BASE = 0x08000000
 #CONFIG_SYS_TEXT_BASE = 0x04000000
board/ti/omap2420h4/mem.c +0 -13
index c8b4186..ba3f12a 100644
@@ -200,19 +200,6 @@ void do_sdrc_init(u32 offset, u32 early)
 
 	__asm__ __volatile__("": : :"memory");  /* limit compiler scope */
 
-	/* u-boot is compiled to run in DDR or SRAM at 8xxxxxxx or 4xxxxxxx.
-	 * If we are running in flash prior to relocation and we use data
-	 * here which is not pc relative we need to get the address correct.
-	 * We need to find the current flash mapping to dress up the initial
-	 * pointer load.  As long as this is const data we should be ok.
-	 */
-	if((early) && running_in_flash()){
-		sdata = (sdrc_data_t *)(((u32)sdata & 0x0003FFFF) | get_gpmc0_base());
-		/* NOR internal boot offset is 0x4000 from xloader signature */
-		if(running_from_internal_boot())
-			sdata = (sdrc_data_t *)((u32)sdata + 0x4000);
-	}
-
 	if (!early && (((mtype = get_mem_type()) == DDR_COMBO)||(mtype == DDR_STACKED))) {
 		if(mtype == DDR_COMBO){
 			pmask = BIT2;/* combo part has a shared CKE signal, can't use feature */
include/configs/omap2420h4.h +1 -1
index 1abf259..cb050ab 100644
@@ -220,7 +220,7 @@
 #define CONFIG_ENV_IS_IN_NAND	1
 #define CONFIG_ENV_OFFSET	0x80000	/* environment starts here  */
 #else
-#define CONFIG_ENV_ADDR             (CONFIG_SYS_FLASH_BASE + SZ_128K)
+#define CONFIG_ENV_ADDR             (CONFIG_SYS_FLASH_BASE + SZ_256K)
 #define	CONFIG_ENV_IS_IN_FLASH      1
 #define CONFIG_ENV_SECT_SIZE	PHYS_FLASH_SECT_SIZE
 #define CONFIG_ENV_OFFSET	( CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN ) /* Environment after Monitor */
Signature · 1 line
1.7.10.4
author
#3 lore raw

PATCH 3/4 omap2420-h4: Add device tree support

In reply to Jon Hunter

Enable device-tree support for the omap2420-h4 board.

---
 include/configs/omap2420h4.h |    1 +
 1 file changed, 1 insertion(+)
include/configs/omap2420h4.h +1 -0
index cb050ab..e144ae9d 100644
@@ -67,6 +67,7 @@
 #define CONFIG_SETUP_MEMORY_TAGS 1
 #define CONFIG_INITRD_TAG        1
 #define CONFIG_REVISION_TAG      1
+#define CONFIG_OF_LIBFDT
 
 /*
  * Size of malloc() pool
Signature · 1 line
1.7.10.4
author
#4 lore raw

PATCH 4/4 omap2420-h4: Fix get_timer() and CONFIG_SYS_HZ

In reply to Jon Hunter

The function get_timer() should return time in ms and CONFIG_SYS_HZ should be set to 1000 by default. Fix both of these items.

---
 arch/arm/cpu/arm1136/omap24xx/timer.c |    8 ++++++--
 include/configs/omap2420h4.h          |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/arm/cpu/arm1136/omap24xx/timer.c +6 -2
index 53015cb..3b6666b 100644
@@ -31,13 +31,16 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 #include <asm/arch/bits.h>
 #include <asm/arch/omap2420.h>
 
+#define TIMER_CLOCK	(CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))
 #define TIMER_LOAD_VAL 0
 
 /* macro to read the 32 bit timer */
-#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR)))
+#define READ_TIMER	readl(CONFIG_SYS_TIMERBASE+TCRR) \
+			/ (TIMER_CLOCK / CONFIG_SYS_HZ)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -99,7 +102,8 @@ ulong get_timer_masked (void)
 		gd->arch.tbl += (now - gd->arch.lastinc);
 	} else {
 		/* we have rollover of incrementer */
-		gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
+		gd->arch.tbl += ((0xFFFFFFFF / (TIMER_CLOCK / CONFIG_SYS_HZ))
+				 - gd->arch.lastinc) + now;
 	}
 	gd->arch.lastinc = now;
 	return gd->arch.tbl;
include/configs/omap2420h4.h +1 -1
index e144ae9d..04e8d3a 100644
@@ -190,7 +190,7 @@
 
 #define CONFIG_SYS_TIMERBASE		OMAP2420_GPT2
 #define CONFIG_SYS_PTV			V_PTV	/* 2^(PTV+1) */
-#define CONFIG_SYS_HZ			((CONFIG_SYS_CLK_FREQ)/(2 << CONFIG_SYS_PTV))
+#define CONFIG_SYS_HZ			1000
 
 /*-----------------------------------------------------------------------
  * Physical Memory Map
Signature · 1 line
1.7.10.4
author
#5 lore raw

PATCH 4/4 omap2420h4: Fix get_timer() and CONFIG_SYS_HZ

In reply to Jon Hunter

The function get_timer() should return time in ms and CONFIG_SYS_HZ should be set to 1000 by default. Fix both of these items.

---
 arch/arm/cpu/arm1136/omap24xx/timer.c |    8 ++++++--
 include/configs/omap2420h4.h          |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/arm/cpu/arm1136/omap24xx/timer.c +6 -2
index 53015cb..3b6666b 100644
@@ -31,13 +31,16 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 #include <asm/arch/bits.h>
 #include <asm/arch/omap2420.h>
 
+#define TIMER_CLOCK	(CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))
 #define TIMER_LOAD_VAL 0
 
 /* macro to read the 32 bit timer */
-#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR)))
+#define READ_TIMER	readl(CONFIG_SYS_TIMERBASE+TCRR) \
+			/ (TIMER_CLOCK / CONFIG_SYS_HZ)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -99,7 +102,8 @@ ulong get_timer_masked (void)
 		gd->arch.tbl += (now - gd->arch.lastinc);
 	} else {
 		/* we have rollover of incrementer */
-		gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
+		gd->arch.tbl += ((0xFFFFFFFF / (TIMER_CLOCK / CONFIG_SYS_HZ))
+				 - gd->arch.lastinc) + now;
 	}
 	gd->arch.lastinc = now;
 	return gd->arch.tbl;
include/configs/omap2420h4.h +1 -1
index e144ae9d..04e8d3a 100644
@@ -190,7 +190,7 @@
 
 #define CONFIG_SYS_TIMERBASE		OMAP2420_GPT2
 #define CONFIG_SYS_PTV			V_PTV	/* 2^(PTV+1) */
-#define CONFIG_SYS_HZ			((CONFIG_SYS_CLK_FREQ)/(2 << CONFIG_SYS_PTV))
+#define CONFIG_SYS_HZ			1000
 
 /*-----------------------------------------------------------------------
  * Physical Memory Map
Signature · 1 line
1.7.10.4
author
#6 lore raw

PATCH 4/4 omap2420h4: Fix get_timer() and CONFIG_SYS_HZ

Quoted 2 lines · Jon Hunter

The function get_timer() should return time in ms and CONFIG_SYS_HZ should be set to 1000 by default. Fix both of these items.

Ignore this patch it is a duplicate!

Jon

#7 lore raw

cover omap2420-h4: Fix u-boot support for board

In reply to Jon Hunter
Quoted 10 lines · Jon Hunter

Currently, u-boot support for the omap2420-h4 board is broken and u-boot is not booting when program into flash. Fix u-boot support for this board.

Jon Hunter (4):
omap2420-h4: Fix DRAM initialisation
omap2420-h4: Fix booting from NOR flash
omap2420-h4: Add device tree support
omap2420-h4: Fix get_timer() and CONFIG_SYS_HZ

Quoted 7 lines
 arch/arm/cpu/arm1136/omap24xx/timer.c         |    8 ++++++--
 arch/arm/include/asm/arch-omap24xx/omap2420.h |    6 +++---
 board/ti/omap2420h4/config.mk                 |    4 ++--
 board/ti/omap2420h4/mem.c                     |   13 -------------
 board/ti/omap2420h4/omap2420h4.c              |   24 ++++++++++++++++++------
 include/configs/omap2420h4.h                  |    5 +++--
 6 files changed, 32 insertions(+), 28 deletions(-)

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130410/cc63e8bb/attachment.pgp>