Re: [U-Boot] [PATCH v3 1/3] ARM1176: Coexist with other ARM1176 platforms

2010-04-11 Thread Tom
Cyril Chemparathy wrote:
 The current ARM1176 CPU specific code is too specific to the SMDK6400
 architecture.  The following changes were necessary prerequisites for the
 addition of other SoCs based on ARM1176.
 
 Existing board's (SMDK6400) configuration has been modified to keep behavior
 unchanged despite these changes.
 
 1. Peripheral port remap configurability
 The earlier code had hardcoded remap values specific to s3c64xx in start.S.
 This change makes the peripheral port remap addresses and sizes configurable.
 
 2. Skip low level initialization
 Ability to skip low level initialization if necessary.  Many other platforms
 have a similar capability, and this is quite useful during debug/bring-up.
 
 3. U-Boot code relocation support
 Most architectures allow u-boot code to run initially at a different
 address (possibly in NOR) and then get relocated to its final resting place
 in RAM.  Added support for this capability in ARM1176 architecture.
 
 4. Disable TCM if necessary
 If a ROM based bootloader happened to have initialized TCM, we disable it here
 to keep things sane.
 
 5. Remove unnecessary SoC specific includes
 ARM1176 code does not really need this SoC specific include.  The presence
 of this include prevents builds on other ARM1176 archs.
 
 6. ARM926 style MMU disable when !CONFIG_ENABLE_MMU
 The original MMU disable code masks out too many bits from the load address
 when it tries to figure out the physical address of the jump target label.
 Consequently, it ends up branching to the wrong address after disabling the
 MMU.
 
 Signed-off-by: Cyril Chemparathy cy...@ti.com

Please rebase this patch.
I had an error when applying it.

Applying: ARM1176: Coexist with other ARM1176 platforms
error: patch failed: cpu/arm1176/cpu.c:33
error: cpu/arm1176/cpu.c: patch does not apply
error: patch failed: cpu/arm1176/start.S:35
error: cpu/arm1176/start.S: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging cpu/arm1176/cpu.c
CONFLICT (content): Merge conflict in cpu/arm1176/cpu.c
Auto-merging cpu/arm1176/start.S
CONFLICT (content): Merge conflict in cpu/arm1176/start.S
Failed to merge in the changes.
Patch failed at 0001 ARM1176: Coexist with other ARM1176 platforms


 ---
 v3: unchanged from v2
 v2: unchanged from v1
 
  cpu/arm1176/cpu.c  |1 -
  cpu/arm1176/start.S|   60 
 ++--
  include/configs/smdk6400.h |6 
  3 files changed, 58 insertions(+), 9 deletions(-)
 
 diff --git a/cpu/arm1176/cpu.c b/cpu/arm1176/cpu.c
 index 2c0014f..c0fd114 100644
 --- a/cpu/arm1176/cpu.c
 +++ b/cpu/arm1176/cpu.c
 @@ -33,7 +33,6 @@
  
  #include common.h
  #include command.h
 -#include asm/arch/s3c6400.h
  #include asm/system.h
  
  static void cache_flush (void);
 diff --git a/cpu/arm1176/start.S b/cpu/arm1176/start.S
 index 68a356d..beec574 100644
 --- a/cpu/arm1176/start.S
 +++ b/cpu/arm1176/start.S
 @@ -1,5 +1,5 @@
  /*
 - *  armboot - Startup Code for S3C6400/ARM1176 CPU-core
 + *  armboot - Startup Code for ARM1176 CPU-core
   *
   * Copyright (c) 2007Samsung Electronics
   *
 @@ -35,7 +35,6 @@
  #ifdef CONFIG_ENABLE_MMU
  #include asm/proc/domain.h
  #endif
 -#include asm/arch/s3c6400.h
  
  #if !defined(CONFIG_ENABLE_MMU)  !defined(CONFIG_SYS_PHY_UBOOT_BASE)
  #define CONFIG_SYS_PHY_UBOOT_BASECONFIG_SYS_UBOOT_BASE
 @@ -145,6 +144,7 @@ reset:
   *
   *
   */
 +#ifndef CONFIG_SKIP_LOWLEVEL_INIT

CONFIG_SKIP_LOWLEVEL_INIT is not used in the other patches.
Why is this needed ?
board/samsung/samsung/smdk6400 has a lowlevel_init.o function.
It is confusing why this function is being if-def and not the real
lowlevel_init..

   /*
* we do sys-critical inits only at reboot,
* not when booting from ram!
 @@ -170,6 +170,8 @@ cpu_init_crit:
   bic r0, r0, #0x0087 @ clear bits 7, 2:0 (B--- -CAM)
   orr r0, r0, #0x0002 @ set bit 2 (A) Align
   orr r0, r0, #0x1000 @ set bit 12 (I) I-Cache
 +
 +#ifdef CONFIG_ENABLE_MMU

This logic is may not be quite correct

 From include/configs/smdk6400.h
#if !defined(CONFIG_NAND_SPL)  (TEXT_BASE = 0xc000)
#define CONFIG_ENABLE_MMU
#endif


   /* Prepare to disable the MMU */
   adr r1, mmu_disable_phys
   /* We presume we're within the first 1024 bytes */
 @@ -187,20 +189,60 @@ mmu_disable:
   nop
   nop
   mov pc, r2
 +mmu_disable_phys:
 +#else
 + mcr p15, 0, r0, c1, c0, 0

Are the noop's used in the mmu enable code after 'mcr pcr ..'
also needed here ?

  #endif
  
 -mmu_disable_phys:
 +#ifdef CONFIG_DISABLE_TCM
 + /*
 +  * Disable the TCMs
 +  */
 + mrc p15, 0, r0, c0, c0, 2   /* Return TCM details */
 + cmp r0, #0
 + beq skip_tcmdisable
 + mov r1, #0
 + mov r2, #1
 + tst r0, r2
 +

[U-Boot] [PATCH v3 1/3] ARM1176: Coexist with other ARM1176 platforms

2010-04-06 Thread Cyril Chemparathy
The current ARM1176 CPU specific code is too specific to the SMDK6400
architecture.  The following changes were necessary prerequisites for the
addition of other SoCs based on ARM1176.

Existing board's (SMDK6400) configuration has been modified to keep behavior
unchanged despite these changes.

1. Peripheral port remap configurability
The earlier code had hardcoded remap values specific to s3c64xx in start.S.
This change makes the peripheral port remap addresses and sizes configurable.

2. Skip low level initialization
Ability to skip low level initialization if necessary.  Many other platforms
have a similar capability, and this is quite useful during debug/bring-up.

3. U-Boot code relocation support
Most architectures allow u-boot code to run initially at a different
address (possibly in NOR) and then get relocated to its final resting place
in RAM.  Added support for this capability in ARM1176 architecture.

4. Disable TCM if necessary
If a ROM based bootloader happened to have initialized TCM, we disable it here
to keep things sane.

5. Remove unnecessary SoC specific includes
ARM1176 code does not really need this SoC specific include.  The presence
of this include prevents builds on other ARM1176 archs.

6. ARM926 style MMU disable when !CONFIG_ENABLE_MMU
The original MMU disable code masks out too many bits from the load address
when it tries to figure out the physical address of the jump target label.
Consequently, it ends up branching to the wrong address after disabling the
MMU.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
v3: unchanged from v2
v2: unchanged from v1

 cpu/arm1176/cpu.c  |1 -
 cpu/arm1176/start.S|   60 ++--
 include/configs/smdk6400.h |6 
 3 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/cpu/arm1176/cpu.c b/cpu/arm1176/cpu.c
index 2c0014f..c0fd114 100644
--- a/cpu/arm1176/cpu.c
+++ b/cpu/arm1176/cpu.c
@@ -33,7 +33,6 @@
 
 #include common.h
 #include command.h
-#include asm/arch/s3c6400.h
 #include asm/system.h
 
 static void cache_flush (void);
diff --git a/cpu/arm1176/start.S b/cpu/arm1176/start.S
index 68a356d..beec574 100644
--- a/cpu/arm1176/start.S
+++ b/cpu/arm1176/start.S
@@ -1,5 +1,5 @@
 /*
- *  armboot - Startup Code for S3C6400/ARM1176 CPU-core
+ *  armboot - Startup Code for ARM1176 CPU-core
  *
  * Copyright (c) 2007  Samsung Electronics
  *
@@ -35,7 +35,6 @@
 #ifdef CONFIG_ENABLE_MMU
 #include asm/proc/domain.h
 #endif
-#include asm/arch/s3c6400.h
 
 #if !defined(CONFIG_ENABLE_MMU)  !defined(CONFIG_SYS_PHY_UBOOT_BASE)
 #define CONFIG_SYS_PHY_UBOOT_BASE  CONFIG_SYS_UBOOT_BASE
@@ -145,6 +144,7 @@ reset:
  *
  *
  */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
/*
 * we do sys-critical inits only at reboot,
 * not when booting from ram!
@@ -170,6 +170,8 @@ cpu_init_crit:
bic r0, r0, #0x0087 @ clear bits 7, 2:0 (B--- -CAM)
orr r0, r0, #0x0002 @ set bit 2 (A) Align
orr r0, r0, #0x1000 @ set bit 12 (I) I-Cache
+
+#ifdef CONFIG_ENABLE_MMU
/* Prepare to disable the MMU */
adr r1, mmu_disable_phys
/* We presume we're within the first 1024 bytes */
@@ -187,20 +189,60 @@ mmu_disable:
nop
nop
mov pc, r2
+mmu_disable_phys:
+#else
+   mcr p15, 0, r0, c1, c0, 0
 #endif
 
-mmu_disable_phys:
+#ifdef CONFIG_DISABLE_TCM
+   /*
+* Disable the TCMs
+*/
+   mrc p15, 0, r0, c0, c0, 2   /* Return TCM details */
+   cmp r0, #0
+   beq skip_tcmdisable
+   mov r1, #0
+   mov r2, #1
+   tst r0, r2
+   mcrne   p15, 0, r1, c9, c1, 1   /* Disable Instruction TCM if present*/
+   tst r0, r2, LSL #16
+   mcrne   p15, 0, r1, c9, c1, 0   /* Disable Data TCM if present*/
+skip_tcmdisable:
+#endif
+#endif
+
+#ifdef CONFIG_PERIPORT_REMAP
/* Peri port setup */
-   ldr r0, =0x7000
-   orr r0, r0, #0x13
+   ldr r0, =CONFIG_PERIPORT_BASE
+   orr r0, r0, #CONFIG_PERIPORT_SIZE
mcr p15,0,r0,c15,c2,4   @ 256M (0x7000 - 0x7fff)
+#endif
 
/*
 * Go setup Memory and board specific bits prior to relocation.
 */
bl  lowlevel_init   /* go setup pll,mux,memory */
+#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+relocate:  /* relocate U-Boot to RAM   */
+   adr r0, _start  /* r0 - current position of code   */
+   ldr r1, _TEXT_BASE  /* test if we run from flash or RAM */
+   cmp r0, r1  /* don't reloc during debug */
+   beq stack_setup
+
+   ldr r2, _armboot_start
+   ldr r3, _bss_start
+   sub r2, r3, r2  /* r2 - size of armboot*/
+