Skip to contentSkip to conversation

da8xx: fixup ARM relocation support

PATCH Superseded Ben Gardiner 3 participants 8 messages Aug 13, 2010 – Aug 24, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 da8xx: fixup ARM relocation support

Split the existing dram_init for da8xx when ARM reloc is enabled, like the changes to arch/arm/cpu/arm926ejs/orion5x/dram.c in 0f234d263b17ccf1b8fd776eb8c15b7cdb27a887 by Heiko Schocher <[email protected]>.

Without these changes gd->ram_size is '0' which leads to incorrect relocation when CONFIG_SYS_ARM_WITHOUT_RELOC is defined and the board does not boot.

We use get_ram_size to dynamically calculate the available RAM because it runs on different board version with different ram, as suggested by Heiko in private communication.

Tested on a da850evm with 128M of DDR2 installed; with both CONFIG_SYS_ARM_WITHOUT_RELOC defined and undefined.

---
 board/davinci/common/misc.c |   17 +++++++++++++++++
 include/configs/da850evm.h  |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
board/davinci/common/misc.c +17 -0
index 25ca326..e8acefe 100644
@@ -33,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
@@ -40,6 +41,22 @@ int dram_init(void)
 
 	return(0);
 }
+#else
+int dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(volatile void *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_MAX_RAM_BANK_SIZE);
+	return(0);
+}
+
+void dram_init_banksize (void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif
 
 #ifdef CONFIG_DRIVER_TI_EMAC
 
include/configs/da850evm.h +1 -0
index 016a21e..c929f6b 100644
@@ -47,6 +47,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128 /* reserved for initial data */
 #define PHYS_SDRAM_1		DAVINCI_DDR_EMIF_DATA_BASE /* DDR Start */
 #define PHYS_SDRAM_1_SIZE	(64 << 20) /* SDRAM size 64MB */
+#define CONFIG_MAX_RAM_BANK_SIZE (512 << 20) /*DDR2 Data region maximum size from SPRS586*/
 
 /* memtest start addr */
 #define CONFIG_SYS_MEMTEST_START	(PHYS_SDRAM_1 + 0x2000000)
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v2 1/1 da8xx: fixup ARM relocation support

Split the existing dram_init for da8xx when ARM reloc is enabled, like the changes to arch/arm/cpu/arm926ejs/orion5x/dram.c in 0f234d263b17ccf1b8fd776eb8c15b7cdb27a887 by Heiko Schocher <[email protected]>.

Without these changes gd->ram_size is '0' which leads to incorrect relocation when CONFIG_SYS_ARM_WITHOUT_RELOC is defined and the board does not boot.

We use get_ram_size to dynamically calculate the available RAM because it runs on different board version with different ram, as suggested by Heiko in private communication.

Tested on a da850evm with 128M of DDR2 installed; with both CONFIG_SYS_ARM_WITHOUT_RELOC defined and undefined.

---
This patch is submitted for the arm-reloc-and-cache-support branch of
git://git.denx.de/u-boot-testing.git

V2:
* added Nori Sehkar to the to: list
* indicated for which branch of testing this patch is submitted.

 board/davinci/common/misc.c |   17 +++++++++++++++++
 include/configs/da850evm.h  |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
board/davinci/common/misc.c +17 -0
index 25ca326..e8acefe 100644
@@ -33,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
@@ -40,6 +41,22 @@ int dram_init(void)
 
 	return(0);
 }
+#else
+int dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(volatile void *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_MAX_RAM_BANK_SIZE);
+	return(0);
+}
+
+void dram_init_banksize (void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif
 
 #ifdef CONFIG_DRIVER_TI_EMAC
 
include/configs/da850evm.h +1 -0
index 016a21e..c929f6b 100644
@@ -47,6 +47,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128 /* reserved for initial data */
 #define PHYS_SDRAM_1		DAVINCI_DDR_EMIF_DATA_BASE /* DDR Start */
 #define PHYS_SDRAM_1_SIZE	(64 << 20) /* SDRAM size 64MB */
+#define CONFIG_MAX_RAM_BANK_SIZE (512 << 20) /*DDR2 Data region maximum size from SPRS586*/
 
 /* memtest start addr */
 #define CONFIG_SYS_MEMTEST_START	(PHYS_SDRAM_1 + 0x2000000)
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v2 1/1 da8xx: fixup ARM relocation support

Ben Gardiner <bengardiner <at> nanometrics.ca> writes:

[...] snip

board/davinci/common/misc.c int dram_init(void) · line 59

Quoted 8 lines
board/davinci/common/misc.c +7 -0
+
+void dram_init_banksize (void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif

dram_init() gets called from arch/arm/lib/board.c and initializes gd->ram_size but who is calling dram_init_banksize to initialize gd->bd->bi_dram[0].start and gd->bd->bi_dram[0].size?

Regards,
Sudhakar

#3 lore raw

PATCH v2 1/1 da8xx: fixup ARM relocation support

Hi Sudhakar,

Thank you for reviewing this patch.

Quoted 4 lines · Sudhakar Rajashekhara

Ben Gardiner <bengardiner <at> nanometrics.ca> writes:

[...] snip

Quoted 12 lines

board/davinci/common/misc.c int dram_init(void) · line 59

Quoted 8 lines
board/davinci/common/misc.c +7 -0
+
+void dram_init_banksize (void)
+{
+ ? ? gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+ ? ? gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif

dram_init() gets called from arch/arm/lib/board.c and initializes gd->ram_size but who is calling dram_init_banksize to initialize gd->bd->bi_dram[0].start and gd->bd->bi_dram[0].size?

As of commit a716b323f10d4f2bce6b4ae01f6d1544e5781ed8 on the arm-reloc-and-cache-support branch of
git://git.denx.de/u-boot-testing.git , dram_init_banksize() is called from board_init_f which is executed just before relocation.

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
+1 (613) 592-6776 x239
http://www.nanometrics.ca

#4 lore raw

PATCH v2 1/1 da8xx: fixup ARM relocation support

Hi Ben,

Quoted 23 lines · Ben Gardiner

Hi Sudhakar,

Thank you for reviewing this patch.

Quoted 4 lines · Sudhakar Rajashekhara

Ben Gardiner <bengardiner <at> nanometrics.ca> writes:

[...] snip

Quoted 12 lines

board/davinci/common/misc.c int dram_init(void) · line 59

Quoted 8 lines
board/davinci/common/misc.c +7 -0
+
+void dram_init_banksize (void)
+{
+ ? ? gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+ ? ? gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif

dram_init() gets called from arch/arm/lib/board.c and initializes gd->ram_size but who is calling dram_init_banksize to initialize gd->bd->bi_dram[0].start and gd->bd->bi_dram[0].size?

Quoted 5 lines

As of commit a716b323f10d4f2bce6b4ae01f6d1544e5781ed8 on the arm-reloc-and-cache-support branch of
git://git.denx.de/u-boot-testing.git , dram_init_banksize() is called from board_init_f which is executed just before relocation.

Though you have mentioned in your changelog, I just want to make sure that gd->ramsize will be ZERO only when CONFIG_SYS_ARM_WITHOUT_RELOC is defined. Is it right? Otherwise get_ram_size() needs to be called in both cases.

I was also about to comment about the line length in your patch but Heiko has given the same comment. Please fix that and re-submit the patch. I can post Acked-by/Reviewed-by on that version.

Regards,
Sudhakar

#5 lore raw

PATCH v2 1/1 da8xx: fixup ARM relocation support

In reply to Ben Gardiner

Hello Ben,

Quoted 67 lines · Ben Gardiner

Split the existing dram_init for da8xx when ARM reloc is enabled, like the changes to arch/arm/cpu/arm926ejs/orion5x/dram.c in 0f234d263b17ccf1b8fd776eb8c15b7cdb27a887 by Heiko Schocher <[email protected]>.

Without these changes gd->ram_size is '0' which leads to incorrect relocation when CONFIG_SYS_ARM_WITHOUT_RELOC is defined and the board does not boot.

We use get_ram_size to dynamically calculate the available RAM because it runs on different board version with different ram, as suggested by Heiko in private communication.

Tested on a da850evm with 128M of DDR2 installed; with both CONFIG_SYS_ARM_WITHOUT_RELOC defined and undefined.

---
This patch is submitted for the arm-reloc-and-cache-support branch of
git://git.denx.de/u-boot-testing.git

V2:
* added Nori Sehkar to the to: list
* indicated for which branch of testing this patch is submitted.

 board/davinci/common/misc.c |   17 +++++++++++++++++
 include/configs/da850evm.h  |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
board/davinci/common/misc.c +17 -0
index 25ca326..e8acefe 100644
@@ -33,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
@@ -40,6 +41,22 @@ int dram_init(void)
 
 	return(0);
 }
+#else
+int dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(volatile void *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_MAX_RAM_BANK_SIZE);
+	return(0);
+}
+
+void dram_init_banksize (void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif
 
 #ifdef CONFIG_DRIVER_TI_EMAC
 
include/configs/da850evm.h +0 -0
index 016a21e..c929f6b 100644

include/configs/da850evm.h line 50

Quoted 4 lines
include/configs/da850evm.h +1 -0
@@ -47,6 +47,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128 /* reserved for initial data */
 #define PHYS_SDRAM_1		DAVINCI_DDR_EMIF_DATA_BASE /* DDR Start */
 #define PHYS_SDRAM_1_SIZE	(64 << 20) /* SDRAM size 64MB */
+#define CONFIG_MAX_RAM_BANK_SIZE (512 << 20) /*DDR2 Data region maximum size from SPRS586*/

Line to long, please fix.

include/configs/da850evm.h line 53

Quoted 2 lines
include/configs/da850evm.h +0 -0
 /* memtest start addr */
 #define CONFIG_SYS_MEMTEST_START	(PHYS_SDRAM_1 + 0x2000000)

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#6 lore raw

PATCH v3 1/1 da8xx: fixup ARM relocation support

Split the existing dram_init for da8xx when ARM reloc is enabled, like the changes to arch/arm/cpu/arm926ejs/orion5x/dram.c in 0f234d263b17ccf1b8fd776eb8c15b7cdb27a887 by Heiko Schocher <[email protected]>.

Without these changes gd->ram_size is '0' which leads to incorrect relocation when CONFIG_SYS_ARM_WITHOUT_RELOC is defined and the board does not boot.

We use get_ram_size to dynamically calculate the available RAM because it runs on different board version with different ram, as suggested by Heiko in private communication.

Tested on a da850evm with 128M of DDR2 installed; with both CONFIG_SYS_ARM_WITHOUT_RELOC defined and undefined.

CC Sudhakar Rajashekhara <[email protected]>
CC Heiko Schocher <[email protected]>

---
This patch is submitted for the arm-reloc-and-cache-support branch of
git://git.denx.de/u-boot-testing.git

V2:
* added Nori Sehkar to the to: list
* indicated for which branch of testing this patch is submitted.

V3:
* fix checkpatch errors
* directed to Sudhakar Rajashekhara instead of Nori Sehkar

---
 board/davinci/common/misc.c |   17 +++++++++++++++++
 include/configs/da850evm.h  |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
board/davinci/common/misc.c +17 -0
index 25ca326..86a875e 100644
@@ -33,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
@@ -40,6 +41,22 @@ int dram_init(void)
 
 	return(0);
 }
+#else
+int dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(volatile void *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_MAX_RAM_BANK_SIZE);
+	return 0;
+}
+
+void dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif
 
 #ifdef CONFIG_DRIVER_TI_EMAC
 
include/configs/da850evm.h +1 -0
index 016a21e..d02b196 100644
@@ -47,6 +47,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128 /* reserved for initial data */
 #define PHYS_SDRAM_1		DAVINCI_DDR_EMIF_DATA_BASE /* DDR Start */
 #define PHYS_SDRAM_1_SIZE	(64 << 20) /* SDRAM size 64MB */
+#define CONFIG_MAX_RAM_BANK_SIZE (512 << 20) /* max size from SPRS586*/
 
 /* memtest start addr */
 #define CONFIG_SYS_MEMTEST_START	(PHYS_SDRAM_1 + 0x2000000)
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH v3 1/1 da8xx: fixup ARM relocation support

Hi,

Quoted 73 lines · Ben Gardiner

Split the existing dram_init for da8xx when ARM reloc is enabled, like the changes to arch/arm/cpu/arm926ejs/orion5x/dram.c in 0f234d263b17ccf1b8fd776eb8c15b7cdb27a887 by Heiko Schocher <[email protected]>.

Without these changes gd->ram_size is '0' which leads to incorrect relocation when CONFIG_SYS_ARM_WITHOUT_RELOC is defined and the board does not boot.

We use get_ram_size to dynamically calculate the available RAM because it runs on different board version with different ram, as suggested by Heiko in private communication.

Tested on a da850evm with 128M of DDR2 installed; with both CONFIG_SYS_ARM_WITHOUT_RELOC defined and undefined.

CC Sudhakar Rajashekhara <[email protected]>
CC Heiko Schocher <[email protected]>

---
This patch is submitted for the arm-reloc-and-cache-support branch of
git://git.denx.de/u-boot-testing.git

V2:
* added Nori Sehkar to the to: list
* indicated for which branch of testing this patch is submitted.

V3:
* fix checkpatch errors
* directed to Sudhakar Rajashekhara instead of Nori Sehkar

---
 board/davinci/common/misc.c |   17 +++++++++++++++++
 include/configs/da850evm.h  |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
board/davinci/common/misc.c +17 -0
index 25ca326..86a875e 100644
@@ -33,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
@@ -40,6 +41,22 @@ int dram_init(void)
 
 	return(0);
 }
+#else
+int dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(volatile void *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_MAX_RAM_BANK_SIZE);
+	return 0;
+}
+
+void dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+}
+#endif
 
 #ifdef CONFIG_DRIVER_TI_EMAC
 
include/configs/da850evm.h +0 -0
index 016a21e..d02b196 100644

include/configs/da850evm.h line 53

Quoted 7 lines
include/configs/da850evm.h +1 -0
@@ -47,6 +47,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128 /* reserved for initial data */
 #define PHYS_SDRAM_1		DAVINCI_DDR_EMIF_DATA_BASE /* DDR Start */
 #define PHYS_SDRAM_1_SIZE	(64 << 20) /* SDRAM size 64MB */
+#define CONFIG_MAX_RAM_BANK_SIZE (512 << 20) /* max size from SPRS586*/
 
 /* memtest start addr */
 #define CONFIG_SYS_MEMTEST_START	(PHYS_SDRAM_1 + 0x2000000)

Thanks,
Sudhakar