[U-Boot] [PATCH] [TESTING] 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 hs@denx.de.
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.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca --- board/davinci/common/misc.c | 17 +++++++++++++++++ include/configs/da850evm.h | 1 + 2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c index 25ca326..e8acefe 100644 --- a/board/davinci/common/misc.c +++ b/board/davinci/common/misc.c @@ -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
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 016a21e..c929f6b 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -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)

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 hs@denx.de.
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.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca --- 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(-)
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c index 25ca326..e8acefe 100644 --- a/board/davinci/common/misc.c +++ b/board/davinci/common/misc.c @@ -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
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 016a21e..c929f6b 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -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)

Ben Gardiner <bengardiner <at> nanometrics.ca> writes:
[...] snip
+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

Hi Sudhakar,
Thank you for reviewing this patch.
On Thu, Aug 19, 2010 at 2:25 AM, Sudhakar Rajashekhara sudhakar.raj@ti.com wrote:
Ben Gardiner <bengardiner <at> nanometrics.ca> writes:
[...] snip
+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

Hi Ben,
On Thu, Aug 19, 2010 at 18:32:48, Ben Gardiner wrote:
Hi Sudhakar,
Thank you for reviewing this patch.
On Thu, Aug 19, 2010 at 2:25 AM, Sudhakar Rajashekhara sudhakar.raj@ti.com wrote:
Ben Gardiner <bengardiner <at> nanometrics.ca> writes:
[...] snip
+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.
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

Hello Ben,
Ben Gardiner wrote:
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 hs@denx.de.
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.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca
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(-)
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c index 25ca326..e8acefe 100644 --- a/board/davinci/common/misc.c +++ b/board/davinci/common/misc.c @@ -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
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 016a21e..c929f6b 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -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.
/* memtest start addr */ #define CONFIG_SYS_MEMTEST_START (PHYS_SDRAM_1 + 0x2000000)
bye, Heiko

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 hs@denx.de.
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.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca CC: Sudhakar Rajashekhara sudhakar.raj@ti.com CC: Heiko Schocher hs@denx.de --- 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(-)
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c index 25ca326..86a875e 100644 --- a/board/davinci/common/misc.c +++ b/board/davinci/common/misc.c @@ -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
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 016a21e..d02b196 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -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)

Hi,
On Mon, Aug 23, 2010 at 18:38:15, Ben Gardiner wrote:
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 hs@denx.de.
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.
Signed-off-by: Ben Gardiner bengardiner@nanometrics.ca CC: Sudhakar Rajashekhara sudhakar.raj@ti.com CC: Heiko Schocher hs@denx.de
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(-)
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c index 25ca326..86a875e 100644 --- a/board/davinci/common/misc.c +++ b/board/davinci/common/misc.c @@ -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
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 016a21e..d02b196 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -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)
Reviewed-by: Sudhakar Rajashekhara sudhakar.raj@ti.com
Thanks, Sudhakar
participants (3)
-
Ben Gardiner
-
Heiko Schocher
-
Sudhakar Rajashekhara