Re: [U-Boot] [PATCH v2 5/6] ARM: add flat device tree support

2010-10-12 Thread Wolfgang Denk
Dear John Rigby,

In message  you 
wrote:
>
> >> index 4e8dfd7..d85a396 100644
> >> --- a/arch/arm/include/asm/config.h
> >> +++ b/arch/arm/include/asm/config.h
> >> @@ -25,4 +25,6 @@
> >>  /* Relocation to SDRAM works on all ARM boards */
> >>  #define CONFIG_RELOC_FIXUP_WORKS
> >>  #endif
> >> +#define CONFIG_LMB
> >> +#define CONFIG_BOOT_RAMDISK_HIGH
> >>  #endif
> >
> > These should be CONFIG_SYS_ instead.
> These are not new.  Do you want me to submit a patch changing all
> existing instances to CONFIG_SYS_*?

Not new? I must be missing something then. I cannot find any reference
to CONFIG_BOOT_RAMDISK_HIGH anywhere in the current code.

CONFIG_LMB is indeed not new, but a misnomer that should by fixed.
Also, an explanation should be added to the README. [I am aware that
this is not a fault of your patch.]

CONFIG_RELOC_FIXUP_WORKS is also a misnomer now, and undocumented :-(

> > On which systems / architectures has this been tested?


Please make sure to proovide such information, it _is_ important.

Best regards,

Wolfgang Denk

-- 
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: w...@denx.de
Celestial navigation is based on the premise that the  Earth  is  the
center  of  the  universe.  The  premise is wrong, but the navigation
works. An incorrect model can be a useful tool.   - Kelvin Throop III
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 5/6] ARM: add flat device tree support

2010-10-12 Thread John Rigby
On Tue, Oct 12, 2010 at 3:29 PM, Wolfgang Denk  wrote:
> Dear John Rigby,
>
> In message <1285775292-15060-6-git-send-email-john.ri...@linaro.org> you 
> wrote:
>> Based on other architectures already supported.
>>
>> Signed-off-by: John Rigby 
>> ---
>>  arch/arm/include/asm/config.h |    2 +
>>  arch/arm/lib/bootm.c          |  137 
>> -
>>  common/image.c                |    2 +
>>  3 files changed, 125 insertions(+), 16 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/config.h b/arch/arm/include/asm/config.h
>> index 4e8dfd7..d85a396 100644
>> --- a/arch/arm/include/asm/config.h
>> +++ b/arch/arm/include/asm/config.h
>> @@ -25,4 +25,6 @@
>>  /* Relocation to SDRAM works on all ARM boards */
>>  #define CONFIG_RELOC_FIXUP_WORKS
>>  #endif
>> +#define CONFIG_LMB
>> +#define CONFIG_BOOT_RAMDISK_HIGH
>>  #endif
>
> These should be CONFIG_SYS_ instead.
These are not new.  Do you want me to submit a patch changing all
existing instances to CONFIG_SYS_*?
>
>
>> diff --git a/common/image.c b/common/image.c
>> index 0562e3b..7b181cc 100644
>> --- a/common/image.c
>> +++ b/common/image.c
>> @@ -1214,9 +1214,11 @@ int boot_relocate_fdt (struct lmb *lmb, ulong 
>> bootmap_base,
>>       if (fdt_blob < (char *)bootmap_base)
>>               relocate = 1;
>>
>> +#ifdef CONFIG_SYS_BOOTMAPSZ
>>       if ((fdt_blob + *of_size + CONFIG_SYS_FDT_PAD) >=
>>                       ((char *)CONFIG_SYS_BOOTMAPSZ + bootmap_base))
>>               relocate = 1;
>> +#endif
>
> What is the impact of this on other architectures?
This ifdef is not needed I will remove it.  It is an artifact of trying
to make the code work without CONFIG_SYS_BOOTMAPSZ which I subsequently
abandoned.
>
> On which systems / architectures has this been tested?
>
> Best regards,
>
> Wolfgang Denk
>
> --
> 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: w...@denx.de
> I wish I had a bronze torc for every user who didn't read the manual.
>                             - Terry Pratchett, _The Light Fantastic_
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 5/6] ARM: add flat device tree support

2010-10-12 Thread Wolfgang Denk
Dear John Rigby,

In message <1285775292-15060-6-git-send-email-john.ri...@linaro.org> you wrote:
> Based on other architectures already supported.
> 
> Signed-off-by: John Rigby 
> ---
>  arch/arm/include/asm/config.h |2 +
>  arch/arm/lib/bootm.c  |  137 
> -
>  common/image.c|2 +
>  3 files changed, 125 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/include/asm/config.h b/arch/arm/include/asm/config.h
> index 4e8dfd7..d85a396 100644
> --- a/arch/arm/include/asm/config.h
> +++ b/arch/arm/include/asm/config.h
> @@ -25,4 +25,6 @@
>  /* Relocation to SDRAM works on all ARM boards */
>  #define CONFIG_RELOC_FIXUP_WORKS
>  #endif
> +#define CONFIG_LMB
> +#define CONFIG_BOOT_RAMDISK_HIGH
>  #endif

These should be CONFIG_SYS_ instead.


> diff --git a/common/image.c b/common/image.c
> index 0562e3b..7b181cc 100644
> --- a/common/image.c
> +++ b/common/image.c
> @@ -1214,9 +1214,11 @@ int boot_relocate_fdt (struct lmb *lmb, ulong 
> bootmap_base,
>   if (fdt_blob < (char *)bootmap_base)
>   relocate = 1;
>  
> +#ifdef CONFIG_SYS_BOOTMAPSZ
>   if ((fdt_blob + *of_size + CONFIG_SYS_FDT_PAD) >=
>   ((char *)CONFIG_SYS_BOOTMAPSZ + bootmap_base))
>   relocate = 1;
> +#endif

What is the impact of this on other architectures?

On which systems / architectures has this been tested?

Best regards,

Wolfgang Denk

-- 
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: w...@denx.de
I wish I had a bronze torc for every user who didn't read the manual.
 - Terry Pratchett, _The Light Fantastic_
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 5/6] ARM: add flat device tree support

2010-10-07 Thread John Rigby
On Wed, Sep 29, 2010 at 9:48 AM, John Rigby  wrote:
> Based on other architectures already supported.
>
> Signed-off-by: John Rigby 

>From an response to an earlier version of this patch:
Tested-by: Rob Herring 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 5/6] ARM: add flat device tree support

2010-09-29 Thread John Rigby
Based on other architectures already supported.

Signed-off-by: John Rigby 
---
 arch/arm/include/asm/config.h |2 +
 arch/arm/lib/bootm.c  |  137 -
 common/image.c|2 +
 3 files changed, 125 insertions(+), 16 deletions(-)

diff --git a/arch/arm/include/asm/config.h b/arch/arm/include/asm/config.h
index 4e8dfd7..d85a396 100644
--- a/arch/arm/include/asm/config.h
+++ b/arch/arm/include/asm/config.h
@@ -25,4 +25,6 @@
 /* Relocation to SDRAM works on all ARM boards */
 #define CONFIG_RELOC_FIXUP_WORKS
 #endif
+#define CONFIG_LMB
+#define CONFIG_BOOT_RAMDISK_HIGH
 #endif
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 3101321..2e7b2e1 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -26,6 +26,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -50,12 +53,52 @@ static void setup_end_tag (bd_t *bd);
 static struct tag *params;
 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG 
*/
 
-int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t 
*images)
+static ulong get_sp(void);
+#if defined(CONFIG_OF_LIBFDT)
+static int bootm_linux_fdt(int machid, bootm_headers_t *images);
+#endif
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+   ulong sp;
+
+   /*
+* Booting a (Linux) kernel image
+*
+* Allocate space for command line and board info - the
+* address should be as high as possible within the reach of
+* the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
+* memory, which means far enough below the current stack
+* pointer.
+*/
+   sp = get_sp();
+   debug("## Current stack ends at 0x%08lx ", sp);
+
+   /* adjust sp by 1K to be safe */
+   sp -= 1024;
+   lmb_reserve(lmb, sp,
+   gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp);
+}
+
+static void announce_and_cleanup(void)
+{
+   printf("\nStarting kernel ...\n\n");
+
+#ifdef CONFIG_USB_DEVICE
+   {
+   extern void udc_disconnect(void);
+   udc_disconnect();
+   }
+#endif
+   cleanup_before_linux();
+}
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 {
bd_t*bd = gd->bd;
char*s;
int machid = bd->bi_arch_number;
-   void(*theKernel)(int zero, int arch, uint params);
+   void(*kernel_entry)(int zero, int arch, uint params);
 
 #ifdef CONFIG_CMDLINE_TAG
char *commandline = getenv ("bootargs");
@@ -64,8 +107,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[], 
bootm_headers_t *ima
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
return 1;
 
-   theKernel = (void (*)(int, int, uint))images->ep;
-
s = getenv ("machid");
if (s) {
machid = simple_strtoul (s, NULL, 16);
@@ -74,8 +115,15 @@ int do_bootm_linux(int flag, int argc, char * const argv[], 
bootm_headers_t *ima
 
show_boot_progress (15);
 
+#ifdef CONFIG_OF_LIBFDT
+   if (images->ft_len)
+   return bootm_linux_fdt(machid, images);
+#endif
+
+   kernel_entry = (void (*)(int, int, uint))images->ep;
+
debug ("## Transferring control to Linux (at address %08lx) ...\n",
-  (ulong) theKernel);
+  (ulong) kernel_entry);
 
 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
 defined (CONFIG_CMDLINE_TAG) || \
@@ -99,27 +147,76 @@ int do_bootm_linux(int flag, int argc, char * const 
argv[], bootm_headers_t *ima
if (images->rd_start && images->rd_end)
setup_initrd_tag (bd, images->rd_start, images->rd_end);
 #endif
-   setup_end_tag (bd);
+   setup_end_tag(bd);
 #endif
 
-   /* we assume that the kernel is in place */
-   printf ("\nStarting kernel ...\n\n");
+   announce_and_cleanup();
 
-#ifdef CONFIG_USB_DEVICE
-   {
-   extern void udc_disconnect (void);
-   udc_disconnect ();
+   kernel_entry(0, machid, bd->bi_boot_params);
+   /* does not return */
+
+   return 1;
+}
+
+#if defined(CONFIG_OF_LIBFDT)
+static int fixup_memory_node(void *blob)
+{
+   bd_t*bd = gd->bd;
+   int bank;
+   u64 start[CONFIG_NR_DRAM_BANKS];
+   u64 size[CONFIG_NR_DRAM_BANKS];
+
+   for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+   start[bank] = bd->bi_dram[bank].start;
+   size[bank] = bd->bi_dram[bank].size;
}
-#endif
 
-   cleanup_before_linux ();
+   return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
+}
+
+static int bootm_linux_fdt(int machid, bootm_headers_t *images)
+{
+   ulong rd_len;
+   bd_t *bd = gd->bd;
+   char *s;
+   void (*kernel_entry)(int zero, int dt_machid, void *dtblob);
+   ulong bootmap_base = getenv_bootm_low();
+   ulong of_size = images->ft_len;
+