linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Basic ARM devicetree support
@ 2011-02-23  2:22 Grant Likely
  2011-02-23  2:22 ` [PATCH v4 1/7] arm/dt: Make __vet_atags also accept a dtb image Grant Likely
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

Fourth posting.  v4 rebases on top of Nicolas' patch to merge
lookup_machine_type() into setup_machine().  It also adds
documentation and error output when the kernel cannot find a
machine_desc that matches the top level compatible property.

I'm not asking for these patches to be merged into mainline yet, but
I'm fairly confident that they should be pretty close to their final
form.

Not included in this series is:
- Russell's patch to remove early vetting of the machine type number
- Rob's patch to map the region if atags or the dtb are not within the
  first 1MB of ram.
- Nicolas' patch to eliminate lookup_machine_type()
However, I am carrying those patches in my devicetree/arm and
devicetree/test branches for anyone who wants to try them out.

Please test.

...

This patch series allows CONFIG_OF to be enabled on ARM and allows the
kernel to accept a dtb pointer from boot firmware instead of atags.
If a dtb is passed, then the kernel will use the root 'compatible'
property to find a matching machine_desc, and it will use it to obtain
the memory layout, initrd location and kernel parameters string.

Only limited device tree support is enabled here.  It does not perform
any kind of device registration from device tree data.  That support
will be enabled in a later patch set.  Rather, this series is a stable
base that other engineers can use to start working on device tree
support for their platforms.

Tested on Versatile (qemu) and nVidia Tegra Harmony.  Kernel compiles
and boots with CONFIG_OF both on and off, both with and without passing
a device tree blob.

This series is reflected in the following branch (stable; will not be
rebased):

 git://git.secretlab.ca/git/linux-2.6 devicetree/arm

The 'clean' patches (rebased) can be found here:

 git://git.secretlab.ca/git/linux-2.6 devicetree/test

---

Grant Likely (6):
      arm/dt: Make __vet_atags also accept a dtb image
      arm/dt: consolidate atags setup into setup_machine_atags
      arm/dt: probe for platforms via the device tree
      arm/dt: Basic versatile devicetree support
      arm/dt: Basic tegra devicetree support
      dt: add documentation of ARM dt boot interface

Jeremy Kerr (1):
      arm/dt: Allow CONFIG_OF on ARM


 Documentation/arm/Booting                       |   33 +++++
 Documentation/devicetree/booting-without-of.txt |   40 ++++++
 arch/arm/Kconfig                                |    7 +
 arch/arm/include/asm/mach/arch.h                |    9 +
 arch/arm/include/asm/prom.h                     |   37 ++++++
 arch/arm/include/asm/setup.h                    |    5 +
 arch/arm/kernel/Makefile                        |    1 
 arch/arm/kernel/devtree.c                       |  147 +++++++++++++++++++++++
 arch/arm/kernel/head-common.S                   |   24 +++-
 arch/arm/kernel/head.S                          |    8 +
 arch/arm/kernel/setup.c                         |   86 ++++++++-----
 arch/arm/mach-tegra/board-harmony.c             |    6 +
 arch/arm/mach-versatile/versatile_ab.c          |    6 +
 arch/arm/mach-versatile/versatile_pb.c          |    6 +
 arch/arm/mm/init.c                              |   11 ++
 15 files changed, 379 insertions(+), 47 deletions(-)
 create mode 100644 arch/arm/include/asm/prom.h
 create mode 100644 arch/arm/kernel/devtree.c

-- 
Signature

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4 1/7] arm/dt: Make __vet_atags also accept a dtb image
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-23  2:22 ` [PATCH v4 2/7] arm/dt: Allow CONFIG_OF on ARM Grant Likely
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

The dtb is passed to the kernel via register r2, which is the same
method that is used to pass an atags pointer.  This patch modifies
__vet_atags to not clear r2 when it encounters a dtb image.

v2: fixed bugs pointed out by Nicolas Pitre

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/kernel/head-common.S |   24 ++++++++++++++++++------
 arch/arm/kernel/head.S        |    8 ++++----
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S
index c84b57d..854bd22 100644
--- a/arch/arm/kernel/head-common.S
+++ b/arch/arm/kernel/head-common.S
@@ -15,6 +15,12 @@
 #define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)
 #define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2)
 
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define OF_DT_MAGIC 0xd00dfeed
+#else
+#define OF_DT_MAGIC 0xedfe0dd0 /* 0xd00dfeed in big-endian */
+#endif
+
 /*
  * Exception handling.  Something went wrong and we can't proceed.  We
  * ought to tell the user, but since we don't have any guarantee that
@@ -28,20 +34,26 @@
 
 /* Determine validity of the r2 atags pointer.  The heuristic requires
  * that the pointer be aligned, in the first 16k of physical RAM and
- * that the ATAG_CORE marker is first and present.  Future revisions
+ * that the ATAG_CORE marker is first and present.  If CONFIG_OF_FLATTREE
+ * is selected, then it will also accept a dtb pointer.  Future revisions
  * of this function may be more lenient with the physical address and
  * may also be able to move the ATAGS block if necessary.
  *
  * Returns:
- *  r2 either valid atags pointer, or zero
+ *  r2 either valid atags pointer, valid dtb pointer, or zero
  *  r5, r6 corrupted
  */
 __vet_atags:
 	tst	r2, #0x3			@ aligned?
 	bne	1f
 
-	ldr	r5, [r2, #0]			@ is first tag ATAG_CORE?
-	cmp	r5, #ATAG_CORE_SIZE
+	ldr	r5, [r2, #0]
+#ifdef CONFIG_OF_FLATTREE
+	ldr	r6, =OF_DT_MAGIC		@ is it a DTB?
+	cmp	r5, r6
+	beq	2f
+#endif
+	cmp	r5, #ATAG_CORE_SIZE		@ is first tag ATAG_CORE?
 	cmpne	r5, #ATAG_CORE_SIZE_EMPTY
 	bne	1f
 	ldr	r5, [r2, #4]
@@ -49,7 +61,7 @@ __vet_atags:
 	cmp	r5, r6
 	bne	1f
 
-	mov	pc, lr				@ atag pointer is ok
+2:	mov	pc, lr				@ atag/dtb pointer is ok
 
 1:	mov	r2, #0
 	mov	pc, lr
@@ -61,7 +73,7 @@ ENDPROC(__vet_atags)
  *
  *  r0  = cp#15 control register
  *  r1  = machine ID
- *  r2  = atags pointer
+ *  r2  = atags/dtb pointer
  *  r9  = processor ID
  */
 	__INIT
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 64af186..5bad500 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -66,7 +66,7 @@
  *
  * This is normally called from the decompressor code.  The requirements
  * are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
- * r1 = machine nr, r2 = atags pointer.
+ * r1 = machine nr, r2 = atags or dtb pointer.
  *
  * This code is mostly position independent, so if you link the kernel at
  * 0xc0008000, you call this at __pa(0xc0008000).
@@ -89,7 +89,7 @@ ENTRY(stext)
 	beq	__error_p			@ yes, error 'p'
 
 	/*
-	 * r1 = machine no, r2 = atags,
+	 * r1 = machine no, r2 = atags or dtb,
 	 * r9 = cpuid, r10 = procinfo
 	 */
 	bl	__vet_atags
@@ -347,7 +347,7 @@ __secondary_data:
  *
  *  r0  = cp#15 control register
  *  r1  = machine ID
- *  r2  = atags pointer
+ *  r2  = atags or dtb pointer
  *  r4  = page table pointer
  *  r9  = processor ID
  *  r13 = *virtual* address to jump to upon completion
@@ -384,7 +384,7 @@ ENDPROC(__enable_mmu)
  *
  *  r0  = cp#15 control register
  *  r1  = machine ID
- *  r2  = atags pointer
+ *  r2  = atags or dtb pointer
  *  r9  = processor ID
  *  r13 = *virtual* address to jump to upon completion
  *


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 2/7] arm/dt: Allow CONFIG_OF on ARM
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
  2011-02-23  2:22 ` [PATCH v4 1/7] arm/dt: Make __vet_atags also accept a dtb image Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-23  2:22 ` [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags Grant Likely
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

From: Jeremy Kerr <jeremy.kerr@canonical.com>

Add some basic empty infrastructure for DT support on ARM.

v3: - moved cmd_line export and initrd setup to this patch to make the
      series bisectable.
    - switched to alloc_bootmem_align() for allocation when
      unflattening the device tree.  memblock_alloc() was not the
      right interface.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/Kconfig             |    7 ++++++
 arch/arm/include/asm/prom.h  |   25 ++++++++++++++++++++++
 arch/arm/include/asm/setup.h |    3 +++
 arch/arm/kernel/Makefile     |    1 +
 arch/arm/kernel/devtree.c    |   47 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/setup.c      |    4 ++--
 arch/arm/mm/init.c           |    9 ++++++++
 7 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/include/asm/prom.h
 create mode 100644 arch/arm/kernel/devtree.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 166efa2..92bae09 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1611,6 +1611,13 @@ endmenu
 
 menu "Boot options"
 
+config USE_OF
+	bool "Flattened Device Tree support"
+	select OF
+	select OF_EARLY_FLATTREE
+	help
+	  Include support for flattened device tree machine descriptions.
+
 # Compressed boot loader in ROM.  Yes, we really want to ask about
 # TEXT and BSS so we preserve their values in the config files.
 config ZBOOT_ROM_TEXT
diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h
new file mode 100644
index 0000000..8f1037f
--- /dev/null
+++ b/arch/arm/include/asm/prom.h
@@ -0,0 +1,25 @@
+/*
+ *  arch/arm/include/asm/prom.h
+ *
+ *  Copyright (C) 2009 Canonical Ltd. <jeremy.kerr@canonical.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __ASMARM_PROM_H
+#define __ASMARM_PROM_H
+
+#ifdef CONFIG_OF
+
+#include <asm/setup.h>
+#include <asm/irq.h>
+
+static inline void irq_dispose_mapping(unsigned int virq)
+{
+	return;
+}
+
+#endif /* CONFIG_OF */
+#endif /* ASMARM_PROM_H */
diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index f1e5a9b..1cec82a 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -221,6 +221,9 @@ extern struct meminfo meminfo;
 #define bank_phys_end(bank)	((bank)->start + (bank)->size)
 #define bank_phys_size(bank)	(bank)->size
 
+extern int arm_add_memory(unsigned long start, unsigned long size);
+extern char cmd_line[COMMAND_LINE_SIZE];
+
 #endif  /*  __KERNEL__  */
 
 #endif
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 185ee82..8df05fd 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_ARM_THUMBEE)	+= thumbee.o
 obj-$(CONFIG_KGDB)		+= kgdb.o
 obj-$(CONFIG_ARM_UNWIND)	+= unwind.o
 obj-$(CONFIG_HAVE_TCM)		+= tcm.o
+obj-$(CONFIG_OF)		+= devtree.o
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
 obj-$(CONFIG_SWP_EMULATE)	+= swp_emulate.o
 CFLAGS_swp_emulate.o		:= -Wa,-march=armv7-a
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
new file mode 100644
index 0000000..75e3df8
--- /dev/null
+++ b/arch/arm/kernel/devtree.c
@@ -0,0 +1,47 @@
+/*
+ *  linux/arch/arm/kernel/devtree.c
+ *
+ *  Copyright (C) 2009 Canonical Ltd. <jeremy.kerr@canonical.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/bootmem.h>
+#include <linux/memblock.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+
+#include <asm/setup.h>
+#include <asm/page.h>
+
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+	arm_add_memory(base, size);
+}
+
+void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+	return alloc_bootmem_align(size, align);
+}
+
+/**
+ * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
+ *
+ * Currently the mapping mechanism is trivial; simple flat hwirq numbers are
+ * mapped 1:1 onto Linux irq numbers.  Cascaded irq controllers are not
+ * supported.
+ */
+unsigned int irq_create_of_mapping(struct device_node *controller,
+				   const u32 *intspec, unsigned int intsize)
+{
+	return intspec[0];
+}
+EXPORT_SYMBOL_GPL(irq_create_of_mapping);
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index a40216e..8e046f1 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -125,7 +125,7 @@ EXPORT_SYMBOL(elf_platform);
 
 static const char *cpu_name;
 static const char *machine_name;
-static char __initdata cmd_line[COMMAND_LINE_SIZE];
+char cmd_line[COMMAND_LINE_SIZE];
 struct machine_desc *machine_desc __initdata;
 
 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
@@ -466,7 +466,7 @@ static struct machine_desc * __init setup_machine(unsigned int nr)
 		/* can't use cpu_relax() here as it may require MMU setup */;
 }
 
-static int __init arm_add_memory(unsigned long start, unsigned long size)
+int __init arm_add_memory(unsigned long start, unsigned long size)
 {
 	struct membank *bank = &meminfo.bank[meminfo.nr_banks];
 
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index cddd684..a2ba1d1 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -15,6 +15,7 @@
 #include <linux/mman.h>
 #include <linux/nodemask.h>
 #include <linux/initrd.h>
+#include <linux/of_fdt.h>
 #include <linux/highmem.h>
 #include <linux/gfp.h>
 #include <linux/memblock.h>
@@ -71,6 +72,14 @@ static int __init parse_tag_initrd2(const struct tag *tag)
 
 __tagtable(ATAG_INITRD2, parse_tag_initrd2);
 
+#ifdef CONFIG_OF_FLATTREE
+void __init early_init_dt_setup_initrd_arch(unsigned long start, unsigned long end)
+{
+	phys_initrd_start = start;
+	phys_initrd_size = end - start + 1;
+}
+#endif /* CONFIG_OF_FLATTREE */
+
 /*
  * This keeps memory configuration data used by a couple memory
  * initialization functions, as well as show_mem() for the skipping


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
  2011-02-23  2:22 ` [PATCH v4 1/7] arm/dt: Make __vet_atags also accept a dtb image Grant Likely
  2011-02-23  2:22 ` [PATCH v4 2/7] arm/dt: Allow CONFIG_OF on ARM Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-26 15:27   ` Shawn Guo
  2011-02-23  2:22 ` [PATCH v4 4/7] arm/dt: probe for platforms via the device tree Grant Likely
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

In preparation for adding device tree support, this patch consolidates
all of the atag-specific setup into a single function.

v4: - adapt to the removal of lookup_machine_type()
    - break out dump of machine_desc table into dump_machine_table()
      because the device tree probe code will use it.
    - Add for_each_machine_desc() macro

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/include/asm/mach/arch.h |    7 ++++
 arch/arm/kernel/setup.c          |   74 +++++++++++++++++++++++---------------
 2 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index 3a0893a..ed9a10c 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -52,6 +52,13 @@ struct machine_desc {
 extern struct machine_desc *machine_desc;
 
 /*
+ * Machine type table - also only accessible during boot
+ */
+extern struct machine_desc __arch_info_begin[], __arch_info_end[];
+#define for_each_machine_desc(p)			\
+	for (p = __arch_info_begin; p < __arch_info_end; p++)
+
+/*
  * Set of macros to define architecture features.  This is built into
  * a table by the linker.
  */
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 8e046f1..e420565 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -439,25 +439,12 @@ void cpu_init(void)
 	    : "r14");
 }
 
-static struct machine_desc * __init setup_machine(unsigned int nr)
+static void __init dump_machine_table(void)
 {
-	extern struct machine_desc __arch_info_begin[], __arch_info_end[];
 	struct machine_desc *p;
 
-	/*
-	 * locate machine in the list of supported machines.
-	 */
-	for (p = __arch_info_begin; p < __arch_info_end; p++)
-		if (nr == p->nr) {
-			printk("Machine: %s\n", p->name);
-			return p;
-		}
-
-	early_print("\n"
-		"Error: unrecognized/unsupported machine ID (r1 = 0x%08x).\n\n"
-		"Available machine support:\n\nID (hex)\tNAME\n", nr);
-
-	for (p = __arch_info_begin; p < __arch_info_end; p++)
+	early_print("Available machine support:\n\nID (hex)\tNAME\n");
+	for_each_machine_desc(p)
 		early_print("%08x\t%s\n", p->nr, p->name);
 
 	early_print("\nPlease check your kernel config and/or bootloader.\n");
@@ -819,21 +806,29 @@ static void __init squash_mem_tags(struct tag *tag)
 			tag->hdr.tag = ATAG_NONE;
 }
 
-void __init setup_arch(char **cmdline_p)
+static struct machine_desc * __init setup_machine_tags(unsigned int nr)
 {
 	struct tag *tags = (struct tag *)&init_tags;
-	struct machine_desc *mdesc;
+	struct machine_desc *mdesc = NULL, *p;
 	char *from = default_command_line;
 
-	unwind_init();
+	/*
+	 * locate machine in the list of supported machines.
+	 */
+	for_each_machine_desc(p)
+		if (nr == p->nr) {
+			printk("Machine: %s\n", p->name);
+			mdesc = p;
+			break;
+		}
 
-	setup_processor();
-	mdesc = setup_machine(machine_arch_type);
-	machine_desc = mdesc;
-	machine_name = mdesc->name;
+	if (!mdesc) {
+		early_print("\nError: unrecognized/unsupported machine ID"
+			" (r1 = 0x%08x).\n\n", nr);
+		dump_machine_table(); /* does not return */
+	}
 
-	if (mdesc->soft_reboot)
-		reboot_setup("s");
+	printk("Machine: %s\n", mdesc->name);
 
 	if (__atags_pointer)
 		tags = phys_to_virt(__atags_pointer);
@@ -861,16 +856,35 @@ void __init setup_arch(char **cmdline_p)
 		parse_tags(tags);
 	}
 
-	init_mm.start_code = (unsigned long) _text;
-	init_mm.end_code   = (unsigned long) _etext;
-	init_mm.end_data   = (unsigned long) _edata;
-	init_mm.brk	   = (unsigned long) _end;
-
 	/* parse_early_param needs a boot_command_line */
 	strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
 
 	/* populate cmd_line too for later use, preserving boot_command_line */
 	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
+
+	return mdesc;
+}
+
+
+void __init setup_arch(char **cmdline_p)
+{
+	struct machine_desc *mdesc;
+
+	unwind_init();
+
+	setup_processor();
+	mdesc = setup_machine_tags(machine_arch_type);
+	machine_desc = mdesc;
+	machine_name = mdesc->name;
+
+	if (mdesc->soft_reboot)
+		reboot_setup("s");
+
+	init_mm.start_code = (unsigned long) _text;
+	init_mm.end_code   = (unsigned long) _etext;
+	init_mm.end_data   = (unsigned long) _edata;
+	init_mm.brk	   = (unsigned long) _end;
+
 	*cmdline_p = cmd_line;
 
 	parse_early_param();


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 4/7] arm/dt: probe for platforms via the device tree
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
                   ` (2 preceding siblings ...)
  2011-02-23  2:22 ` [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-23  2:22 ` [PATCH v4 5/7] arm/dt: Basic versatile devicetree support Grant Likely
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

If a dtb is passed to the kernel then the kernel needs to iterate
through compiled-in mdescs looking for one that matches and move the
dtb data to a safe location before it gets accidentally overwritten by
the kernel.

This patch creates a new function, setup_machine_fdt() which is
analogous to the setup_machine_atags() created in the previous patch.
It does all the early setup needed to use a device tree machine
description.

v4: - Dump some output when a matching machine_desc cannot be found
v3: - Added processing of reserved list.
    - Backed out the v2 change that copied instead of reserved the
      dtb.  dtb is reserved again and the real problem was fixed by
      using alloc_bootmem_align() for early allocation of RAM for
      unflattening the tree.
    - Moved cmd_line and initrd changes to earlier patch to make series
      bisectable.
v2: Changed to save the dtb by copying into an allocated buffer.
    - Since the dtb will very likely be passed in the first 16k of ram
      where the interrupt vectors live, memblock_reserve() is
      insufficient to protect the dtb data.
[based on work originally written by Jeremy Kerr <jeremy.kerr@canonical.com>]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/include/asm/mach/arch.h |    2 +
 arch/arm/include/asm/prom.h      |   12 +++++
 arch/arm/include/asm/setup.h     |    2 +
 arch/arm/kernel/devtree.c        |  100 ++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/setup.c          |   12 +++--
 arch/arm/mm/init.c               |    2 +
 6 files changed, 127 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index ed9a10c..d7b12ad 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -22,6 +22,8 @@ struct machine_desc {
 	unsigned int		nr;		/* architecture number	*/
 	const char		*name;		/* architecture name	*/
 	unsigned long		boot_params;	/* tagged list		*/
+	const char		**dt_compat;	/* array of device tree
+						 * 'compatible' strings	*/
 
 	unsigned int		nr_irqs;	/* number of IRQs */
 
diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h
index 8f1037f..11b8708 100644
--- a/arch/arm/include/asm/prom.h
+++ b/arch/arm/include/asm/prom.h
@@ -21,5 +21,17 @@ static inline void irq_dispose_mapping(unsigned int virq)
 	return;
 }
 
+extern struct machine_desc *setup_machine_fdt(unsigned int dt_phys);
+extern void arm_dt_memblock_reserve(void);
+
+#else /* CONFIG_OF */
+
+static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)
+{
+	return NULL;
+}
+
+static inline void arm_dt_memblock_reserve(void) { }
+
 #endif /* CONFIG_OF */
 #endif /* ASMARM_PROM_H */
diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 1cec82a..207f911 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -223,6 +223,8 @@ extern struct meminfo meminfo;
 
 extern int arm_add_memory(unsigned long start, unsigned long size);
 extern char cmd_line[COMMAND_LINE_SIZE];
+extern void early_print(const char *str, ...);
+extern void dump_machine_table(void);
 
 #endif  /*  __KERNEL__  */
 
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 75e3df8..4dd725a 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -21,6 +21,8 @@
 
 #include <asm/setup.h>
 #include <asm/page.h>
+#include <asm/mach/arch.h>
+#include <asm/mach-types.h>
 
 void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 {
@@ -32,6 +34,33 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
 	return alloc_bootmem_align(size, align);
 }
 
+void __init arm_dt_memblock_reserve(void)
+{
+	u64 *reserve_map, base, size;
+
+	if (!initial_boot_params)
+		return;
+
+	/* Reserve the dtb region */
+	memblock_reserve(virt_to_phys(initial_boot_params),
+			 be32_to_cpu(initial_boot_params->totalsize));
+
+	/*
+	 * Process the reserve map.  This will probably overlap the initrd
+	 * and dtb locations which are already reserved, but overlaping
+	 * doesn't hurt anything
+	 */
+	reserve_map = ((void*)initial_boot_params) +
+			be32_to_cpu(initial_boot_params->off_mem_rsvmap);
+	while (1) {
+		base = be64_to_cpup(reserve_map++);
+		size = be64_to_cpup(reserve_map++);
+		if (!size)
+			break;
+		memblock_reserve(base, size);
+	}
+}
+
 /**
  * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
  *
@@ -45,3 +74,74 @@ unsigned int irq_create_of_mapping(struct device_node *controller,
 	return intspec[0];
 }
 EXPORT_SYMBOL_GPL(irq_create_of_mapping);
+
+/**
+ * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
+ * @dt_phys: physical address of dt blob
+ *
+ * If a dtb was passed to the kernel in r2, then use it to choose the
+ * correct machine_desc and to setup the system.
+ */
+struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
+{
+	struct boot_param_header *devtree;
+	struct machine_desc *mdesc, *mdesc_best = NULL;
+	unsigned int score, mdesc_score = ~1;
+	unsigned long dt_root;
+	const char *model;
+
+	devtree = phys_to_virt(dt_phys);
+
+	/* check device tree validity */
+	if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
+		return NULL;
+
+	/* Search the mdescs for the 'best' compatible value match */
+	initial_boot_params = devtree;
+	dt_root = of_get_flat_dt_root();
+	for_each_machine_desc(mdesc) {
+		score = of_flat_dt_match(dt_root, mdesc->dt_compat);
+		if (score > 0 && score < mdesc_score) {
+			mdesc_best = mdesc;
+			mdesc_score = score;
+		}
+	}
+	if (!mdesc_best) {
+		const char *prop;
+		long size;
+
+		early_print("\nError: unrecognized/unsupported "
+			    "device tree compatible list:\n[ ");
+
+		prop = of_get_flat_dt_prop(dt_root, "compatible", &size);
+		while (size > 0) {
+			early_print("'%s' ", prop);
+			size -= strlen(prop) + 1;
+			prop += strlen(prop) + 1;
+		}
+		early_print("]\n\n");
+
+		dump_machine_table(); /* does not return */
+	}
+
+	model = of_get_flat_dt_prop(dt_root, "model", NULL);
+	if (!model)
+		model = of_get_flat_dt_prop(dt_root, "compatible", NULL);
+	if (!model)
+		model = "<unknown>";
+	pr_info("Machine: %s, model: %s\n", mdesc_best->name, model);
+
+	/* Retrieve various information from the /chosen node */
+	of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
+	/* Initialize {size,address}-cells info */
+	of_scan_flat_dt(early_init_dt_scan_root, NULL);
+	/* Setup memory, calling early_init_dt_add_memory_arch */
+	of_scan_flat_dt(early_init_dt_scan_memory, NULL);
+	/* Save command line for /proc/cmdline  */
+	strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
+
+	/* Change machine number to match the mdesc we're using */
+	__machine_arch_type = mdesc->nr;
+
+	return mdesc_best;
+}
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e420565..8734716 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -20,6 +20,7 @@
 #include <linux/screen_info.h>
 #include <linux/init.h>
 #include <linux/kexec.h>
+#include <linux/of_fdt.h>
 #include <linux/crash_dump.h>
 #include <linux/root_dev.h>
 #include <linux/cpu.h>
@@ -42,6 +43,7 @@
 #include <asm/cachetype.h>
 #include <asm/tlbflush.h>
 
+#include <asm/prom.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
@@ -309,7 +311,7 @@ static void __init cacheid_init(void)
  */
 extern struct proc_info_list *lookup_processor_type(unsigned int);
 
-static void __init early_print(const char *str, ...)
+void __init early_print(const char *str, ...)
 {
 	extern void printascii(const char *);
 	char buf[256];
@@ -439,7 +441,7 @@ void cpu_init(void)
 	    : "r14");
 }
 
-static void __init dump_machine_table(void)
+void __init dump_machine_table(void)
 {
 	struct machine_desc *p;
 
@@ -873,7 +875,9 @@ void __init setup_arch(char **cmdline_p)
 	unwind_init();
 
 	setup_processor();
-	mdesc = setup_machine_tags(machine_arch_type);
+	mdesc = setup_machine_fdt(__atags_pointer);
+	if (!mdesc)
+		mdesc = setup_machine_tags(machine_arch_type);
 	machine_desc = mdesc;
 	machine_name = mdesc->name;
 
@@ -894,6 +898,8 @@ void __init setup_arch(char **cmdline_p)
 	paging_init(mdesc);
 	request_standard_resources(mdesc);
 
+	unflatten_device_tree();
+
 #ifdef CONFIG_SMP
 	if (is_smp())
 		smp_init_cpus();
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index a2ba1d1..8e3387c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -22,6 +22,7 @@
 #include <linux/sort.h>
 
 #include <asm/mach-types.h>
+#include <asm/prom.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
 #include <asm/sizes.h>
@@ -322,6 +323,7 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 #endif
 
 	arm_mm_memblock_reserve();
+	arm_dt_memblock_reserve();
 
 	/* reserve any platform specific memblock areas */
 	if (mdesc->reserve)


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 5/7] arm/dt: Basic versatile devicetree support
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
                   ` (3 preceding siblings ...)
  2011-02-23  2:22 ` [PATCH v4 4/7] arm/dt: probe for platforms via the device tree Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-23  2:22 ` [PATCH v4 6/7] arm/dt: Basic tegra " Grant Likely
  2011-02-23  2:22 ` [PATCH v4 7/7] dt: add documentation of ARM dt boot interface Grant Likely
  6 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

This patch adds adds very basic support for booting versatile with a
device tree.  It simply allows the existing machine_descs to match
against the versatile ab & pb compatible values so that the kernel can
boot.  Kernel parameters and the initrd pointer is read out of the
tree instead of atags.

This is not complete device tree support.  This change will be
reverted when a new machine_desc is added that can populate the
versatile device registrations directly from data in the tree instead
of using hard coded data.  That change will be made in a future patch.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/mach-versatile/versatile_ab.c |    6 ++++++
 arch/arm/mach-versatile/versatile_pb.c |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c
index aa9730f..62053df 100644
--- a/arch/arm/mach-versatile/versatile_ab.c
+++ b/arch/arm/mach-versatile/versatile_ab.c
@@ -33,6 +33,11 @@
 
 #include "core.h"
 
+static const char *versatile_ab_match[] __initdata = {
+	"arm,versatile-ab",
+	NULL,
+};
+
 MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
 	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
 	.boot_params	= 0x00000100,
@@ -40,4 +45,5 @@ MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
 	.init_irq	= versatile_init_irq,
 	.timer		= &versatile_timer,
 	.init_machine	= versatile_init,
+	.dt_compat	= versatile_ab_match,
 MACHINE_END
diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
index bf46964..eba12fa 100644
--- a/arch/arm/mach-versatile/versatile_pb.c
+++ b/arch/arm/mach-versatile/versatile_pb.c
@@ -106,6 +106,11 @@ static void __init versatile_pb_init(void)
 	}
 }
 
+static const char *versatile_pb_match[] __initdata = {
+	"arm,versatile-pb",
+	NULL,
+};
+
 MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
 	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
 	.boot_params	= 0x00000100,
@@ -113,4 +118,5 @@ MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
 	.init_irq	= versatile_init_irq,
 	.timer		= &versatile_timer,
 	.init_machine	= versatile_pb_init,
+	.dt_compat	= versatile_pb_match,
 MACHINE_END


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 6/7] arm/dt: Basic tegra devicetree support
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
                   ` (4 preceding siblings ...)
  2011-02-23  2:22 ` [PATCH v4 5/7] arm/dt: Basic versatile devicetree support Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-23 21:13   ` Sergei Shtylyov
  2011-02-23  2:22 ` [PATCH v4 7/7] dt: add documentation of ARM dt boot interface Grant Likely
  6 siblings, 1 reply; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

This patch adds adds very basic support for booting tegra with a
device tree.  It simply allows the existing machine_descs to match
against the tegra compatible values so that the kernel can boot.
Kernel parameters and the initrd pointer is read out of the tree
instead of atags.

This is not complete device tree support.  This change will be
reverted when a new machine_desc is added that can populate the
device registrations directly from data in the tree instead of using
hard coded data.  That change will be made in a future patch.

v2: Fixed cut-and-paste error in commit text

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/mach-tegra/board-harmony.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-tegra/board-harmony.c b/arch/arm/mach-tegra/board-harmony.c
index b9dbdb1..99884e9 100644
--- a/arch/arm/mach-tegra/board-harmony.c
+++ b/arch/arm/mach-tegra/board-harmony.c
@@ -113,6 +113,11 @@ static void __init tegra_harmony_init(void)
 	platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
 }
 
+static const char * tegra_harmony_board_compat[] = {
+	"nvidia,harmony",
+	NULL
+};
+
 MACHINE_START(HARMONY, "harmony")
 	.boot_params  = 0x00000100,
 	.fixup		= tegra_harmony_fixup,
@@ -120,4 +125,5 @@ MACHINE_START(HARMONY, "harmony")
 	.init_machine   = tegra_harmony_init,
 	.map_io         = tegra_map_common_io,
 	.timer          = &tegra_timer,
+	.dt_compat      = tegra_harmony_board_compat,
 MACHINE_END


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 7/7] dt: add documentation of ARM dt boot interface
  2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
                   ` (5 preceding siblings ...)
  2011-02-23  2:22 ` [PATCH v4 6/7] arm/dt: Basic tegra " Grant Likely
@ 2011-02-23  2:22 ` Grant Likely
  2011-02-23  2:55   ` Nicolas Pitre
  6 siblings, 1 reply; 16+ messages in thread
From: Grant Likely @ 2011-02-23  2:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Nicolas Pitre, Russell King

v3: added details to Documentation/arm/Booting

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 Documentation/arm/Booting                       |   33 +++++++++++++++++--
 Documentation/devicetree/booting-without-of.txt |   40 +++++++++++++++++++++++
 2 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/Documentation/arm/Booting b/Documentation/arm/Booting
index 7685029..4e686a2 100644
--- a/Documentation/arm/Booting
+++ b/Documentation/arm/Booting
@@ -65,13 +65,19 @@ looks at the connected hardware is beyond the scope of this document.
 The boot loader must ultimately be able to provide a MACH_TYPE_xxx
 value to the kernel. (see linux/arch/arm/tools/mach-types).
 
-
-4. Setup the kernel tagged list
--------------------------------
+4. Setup boot data
+------------------
 
 Existing boot loaders:		OPTIONAL, HIGHLY RECOMMENDED
 New boot loaders:		MANDATORY
 
+The boot loader must provide either a tagged list or a dtb image for
+passing configuration data to the kernel.  The physical address of the
+boot data is passed to the kernel in register r2.
+
+4a. Setup the kernel tagged list
+--------------------------------
+
 The boot loader must create and initialise the kernel tagged list.
 A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
 The ATAG_CORE tag may or may not be empty.  An empty ATAG_CORE tag
@@ -101,6 +107,24 @@ The tagged list must be placed in a region of memory where neither
 the kernel decompressor nor initrd 'bootp' program will overwrite
 it.  The recommended placement is in the first 16KiB of RAM.
 
+4b. Setup the device tree
+-------------------------
+
+The boot loader must load a device tree image (dtb) into system ram
+at a 64bit aligned address and initialize it with the boot data.  The
+dtb format is documented in Documentation/devicetree/booting-without-of.txt.
+The kernel will look for the dtb magic value of 0xd00dfeed at the dtb
+physical address to determine if a dtb has been passed instead of a
+tagged list.
+
+The boot loader must pass at a minimum the size and location of the
+system memory, and the root filesystem location.  The dtb must be
+placed in a region of memory where the kernel decompressor will not
+overwrite it.  The recommended placement is in the first 16KiB of RAM
+with the caveat that it may not be located at physical address 0 since
+the kernel interprets a value of 0 in r2 to mean neither a tagged list
+nor a dtb were passed.
+
 5. Calling the kernel image
 ---------------------------
 
@@ -125,7 +149,8 @@ In either case, the following conditions must be met:
 - CPU register settings
   r0 = 0,
   r1 = machine type number discovered in (3) above.
-  r2 = physical address of tagged list in system RAM.
+  r2 = physical address of tagged list in system RAM, or
+       physical address of device tree block (dtb) in system RAM
 
 - CPU mode
   All forms of interrupts must be disabled (IRQs and FIQs)
diff --git a/Documentation/devicetree/booting-without-of.txt b/Documentation/devicetree/booting-without-of.txt
index 28b1c9d..9381a14 100644
--- a/Documentation/devicetree/booting-without-of.txt
+++ b/Documentation/devicetree/booting-without-of.txt
@@ -13,6 +13,7 @@ Table of Contents
 
   I - Introduction
     1) Entry point for arch/powerpc
+    2) Entry point for arch/arm
 
   II - The DT block format
     1) Header
@@ -225,6 +226,45 @@ it with special cases.
   cannot support both configurations with Book E and configurations
   with classic Powerpc architectures.
 
+2) Entry point for arch/arm
+---------------------------
+
+   There is one single entry point to the kernel, at the start
+   of the kernel image. That entry point supports two calling
+   conventions.  A summary of the interface is described here.  A full
+   description of the boot requirements is documented in
+   Documentation/arm/Booting
+
+        a) ATAGS interface.  Minimal information is passed from firmware
+        to the kernel with a tagged list of predefined parameters.
+
+                r0 : 0
+
+                r1 : Machine type number
+
+                r2 : Physical address of tagged list in system RAM
+
+        b) Entry with a flattened device-tree block.  Firmware loads the
+        physical address of the flattened device tree block (dtb) into r2,
+        r1 is not used, but it is considered good practise to use a valid
+        machine number as described in Documentation/arm/Booting.
+
+                r0 : 0
+
+                r1 : Valid machine type number.  When using a device tree,
+                a single machine type number will often be assigned to
+                represent a class or family of SoCs.
+
+                r2 : physical pointer to the device-tree block
+                (defined in chapter II) in RAM.  Device tree can be located
+                anywhere in system RAM, but it should be aligned on a 32 bit
+                boundary.
+
+   The kernel will differentiate between ATAGS and device tree booting by
+   reading the memory pointed to by r1 and looking for either the flattened
+   device tree block magic value (0xd00dfeed) or the ATAG_CORE value at
+   offset 0x4 from r2 (0x54410001).
+
 
 II - The DT block format
 ========================


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 7/7] dt: add documentation of ARM dt boot interface
  2011-02-23  2:22 ` [PATCH v4 7/7] dt: add documentation of ARM dt boot interface Grant Likely
@ 2011-02-23  2:55   ` Nicolas Pitre
  2011-02-23  4:35     ` Grant Likely
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Pitre @ 2011-02-23  2:55 UTC (permalink / raw)
  To: Grant Likely; +Cc: lkml, linux-arm-kernel, Russell King

On Tue, 22 Feb 2011, Grant Likely wrote:

> +The boot loader must load a device tree image (dtb) into system ram
> +at a 64bit aligned address and initialize it with the boot data.
[...]
> +                r2 : physical pointer to the device-tree block
> +                (defined in chapter II) in RAM.  Device tree can be located
> +                anywhere in system RAM, but it should be aligned on a 32 bit
> +                boundary.

So... which one is true?


Nicolas

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 7/7] dt: add documentation of ARM dt boot interface
  2011-02-23  2:55   ` Nicolas Pitre
@ 2011-02-23  4:35     ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-23  4:35 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: lkml, linux-arm-kernel, Russell King

On Tue, Feb 22, 2011 at 7:55 PM, Nicolas Pitre <nicolas.pitre@linaro.org> wrote:
> On Tue, 22 Feb 2011, Grant Likely wrote:
>
>> +The boot loader must load a device tree image (dtb) into system ram
>> +at a 64bit aligned address and initialize it with the boot data.
> [...]
>> +                r2 : physical pointer to the device-tree block
>> +                (defined in chapter II) in RAM.  Device tree can be located
>> +                anywhere in system RAM, but it should be aligned on a 32 bit
>> +                boundary.
>
> So... which one is true?

Oops, I thought I fixed that.  It should be 64 bit boundary (actually,
32 bit is probably just fine, but there are some header fields which
are u64 physical address values so it probably makes sense to keep it
aligned for 64 bits).

g.

>
>
> Nicolas
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 6/7] arm/dt: Basic tegra devicetree support
  2011-02-23  2:22 ` [PATCH v4 6/7] arm/dt: Basic tegra " Grant Likely
@ 2011-02-23 21:13   ` Sergei Shtylyov
  2011-02-23 21:36     ` Grant Likely
  0 siblings, 1 reply; 16+ messages in thread
From: Sergei Shtylyov @ 2011-02-23 21:13 UTC (permalink / raw)
  To: Grant Likely; +Cc: linux-kernel, linux-arm-kernel, Nicolas Pitre, Russell King

Hello.

On 23-02-2011 5:22, Grant Likely wrote:

> This patch adds adds very basic support for booting tegra with a
> device tree.  It simply allows the existing machine_descs to match
> against the tegra compatible values so that the kernel can boot.
> Kernel parameters and the initrd pointer is read out of the tree
> instead of atags.

> This is not complete device tree support.  This change will be
> reverted when a new machine_desc is added that can populate the
> device registrations directly from data in the tree instead of using
> hard coded data.  That change will be made in a future patch.

> v2: Fixed cut-and-paste error in commit text

    Shouldn't this sentence follow the --- tearline?

> Signed-off-by: Grant Likely<grant.likely@secretlab.ca>

WBR, Sergei

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 6/7] arm/dt: Basic tegra devicetree support
  2011-02-23 21:13   ` Sergei Shtylyov
@ 2011-02-23 21:36     ` Grant Likely
  2011-02-25 13:30       ` Sergei Shtylyov
  0 siblings, 1 reply; 16+ messages in thread
From: Grant Likely @ 2011-02-23 21:36 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-kernel, linux-arm-kernel, Nicolas Pitre, Russell King

On Thu, Feb 24, 2011 at 12:13:36AM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 23-02-2011 5:22, Grant Likely wrote:
> 
> >This patch adds adds very basic support for booting tegra with a
> >device tree.  It simply allows the existing machine_descs to match
> >against the tegra compatible values so that the kernel can boot.
> >Kernel parameters and the initrd pointer is read out of the tree
> >instead of atags.
> 
> >This is not complete device tree support.  This change will be
> >reverted when a new machine_desc is added that can populate the
> >device registrations directly from data in the tree instead of using
> >hard coded data.  That change will be made in a future patch.
> 
> >v2: Fixed cut-and-paste error in commit text
> 
>    Shouldn't this sentence follow the --- tearline?

Nope!  It is actually quite useful for the version information to show
up in the commit text.  That way you know *exactly* which version got
merged.  dwmw2 pointed that out to me a few months back.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 6/7] arm/dt: Basic tegra devicetree support
  2011-02-23 21:36     ` Grant Likely
@ 2011-02-25 13:30       ` Sergei Shtylyov
  2011-02-25 15:54         ` Grant Likely
  0 siblings, 1 reply; 16+ messages in thread
From: Sergei Shtylyov @ 2011-02-25 13:30 UTC (permalink / raw)
  To: Grant Likely
  Cc: Sergei Shtylyov, linux-kernel, linux-arm-kernel, Nicolas Pitre,
	Russell King

Hello.

On 24-02-2011 0:36, Grant Likely wrote:

>>> This patch adds adds very basic support for booting tegra with a
>>> device tree.  It simply allows the existing machine_descs to match
>>> against the tegra compatible values so that the kernel can boot.
>>> Kernel parameters and the initrd pointer is read out of the tree
>>> instead of atags.

>>> This is not complete device tree support.  This change will be
>>> reverted when a new machine_desc is added that can populate the
>>> device registrations directly from data in the tree instead of using
>>> hard coded data.  That change will be made in a future patch.

>>> v2: Fixed cut-and-paste error in commit text

>>     Shouldn't this sentence follow the --- tearline?

> Nope!  It is actually quite useful for the version information to show
> up in the commit text.  That way you know *exactly* which version got
> merged.  dwmw2 pointed that out to me a few months back.

    Well, I think that depends on the patch. If you have say 9 revisions with 
significant changes (that's what I actually had) and the revision history far 
exceeds the original patch description, then this will just become too ugly I 
think...

WBR, Sergei

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 6/7] arm/dt: Basic tegra devicetree support
  2011-02-25 13:30       ` Sergei Shtylyov
@ 2011-02-25 15:54         ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-02-25 15:54 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-kernel, linux-arm-kernel, Nicolas Pitre, Russell King

On Fri, Feb 25, 2011 at 6:30 AM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
> On 24-02-2011 0:36, Grant Likely wrote:
>>>> v2: Fixed cut-and-paste error in commit text
>
>>>    Shouldn't this sentence follow the --- tearline?
>
>> Nope!  It is actually quite useful for the version information to show
>> up in the commit text.  That way you know *exactly* which version got
>> merged.  dwmw2 pointed that out to me a few months back.
>
>   Well, I think that depends on the patch. If you have say 9 revisions with
> significant changes (that's what I actually had) and the revision history
> far exceeds the original patch description, then this will just become too
> ugly I think...

Meh.  commit text is cheap and useful.

g.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags
  2011-02-23  2:22 ` [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags Grant Likely
@ 2011-02-26 15:27   ` Shawn Guo
  2011-03-26  6:44     ` Grant Likely
  0 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2011-02-26 15:27 UTC (permalink / raw)
  To: Grant Likely; +Cc: linux-kernel, linux-arm-kernel, Nicolas Pitre, Russell King

Hi Grant,

One minor nitpicking below ...

On Tue, Feb 22, 2011 at 07:22:19PM -0700, Grant Likely wrote:
> In preparation for adding device tree support, this patch consolidates
> all of the atag-specific setup into a single function.
> 
> v4: - adapt to the removal of lookup_machine_type()
>     - break out dump of machine_desc table into dump_machine_table()
>       because the device tree probe code will use it.
>     - Add for_each_machine_desc() macro
> 
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>  arch/arm/include/asm/mach/arch.h |    7 ++++
>  arch/arm/kernel/setup.c          |   74 +++++++++++++++++++++++---------------
>  2 files changed, 51 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
> index 3a0893a..ed9a10c 100644
> --- a/arch/arm/include/asm/mach/arch.h
> +++ b/arch/arm/include/asm/mach/arch.h
> @@ -52,6 +52,13 @@ struct machine_desc {
>  extern struct machine_desc *machine_desc;
>  
>  /*
> + * Machine type table - also only accessible during boot
> + */
> +extern struct machine_desc __arch_info_begin[], __arch_info_end[];
> +#define for_each_machine_desc(p)			\
> +	for (p = __arch_info_begin; p < __arch_info_end; p++)
> +
> +/*
>   * Set of macros to define architecture features.  This is built into
>   * a table by the linker.
>   */
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> index 8e046f1..e420565 100644
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -439,25 +439,12 @@ void cpu_init(void)
>  	    : "r14");
>  }
>  
> -static struct machine_desc * __init setup_machine(unsigned int nr)
> +static void __init dump_machine_table(void)
>  {
> -	extern struct machine_desc __arch_info_begin[], __arch_info_end[];
>  	struct machine_desc *p;
>  
> -	/*
> -	 * locate machine in the list of supported machines.
> -	 */
> -	for (p = __arch_info_begin; p < __arch_info_end; p++)
> -		if (nr == p->nr) {
> -			printk("Machine: %s\n", p->name);
> -			return p;
> -		}
> -
> -	early_print("\n"
> -		"Error: unrecognized/unsupported machine ID (r1 = 0x%08x).\n\n"
> -		"Available machine support:\n\nID (hex)\tNAME\n", nr);
> -
> -	for (p = __arch_info_begin; p < __arch_info_end; p++)
> +	early_print("Available machine support:\n\nID (hex)\tNAME\n");
> +	for_each_machine_desc(p)
>  		early_print("%08x\t%s\n", p->nr, p->name);
>  
>  	early_print("\nPlease check your kernel config and/or bootloader.\n");
> @@ -819,21 +806,29 @@ static void __init squash_mem_tags(struct tag *tag)
>  			tag->hdr.tag = ATAG_NONE;
>  }
>  
> -void __init setup_arch(char **cmdline_p)
> +static struct machine_desc * __init setup_machine_tags(unsigned int nr)
>  {
>  	struct tag *tags = (struct tag *)&init_tags;
> -	struct machine_desc *mdesc;
> +	struct machine_desc *mdesc = NULL, *p;
>  	char *from = default_command_line;
>  
> -	unwind_init();
> +	/*
> +	 * locate machine in the list of supported machines.
> +	 */
> +	for_each_machine_desc(p)
> +		if (nr == p->nr) {
> +			printk("Machine: %s\n", p->name);

Print once ...

> +			mdesc = p;
> +			break;
> +		}
>  
> -	setup_processor();
> -	mdesc = setup_machine(machine_arch_type);
> -	machine_desc = mdesc;
> -	machine_name = mdesc->name;
> +	if (!mdesc) {
> +		early_print("\nError: unrecognized/unsupported machine ID"
> +			" (r1 = 0x%08x).\n\n", nr);
> +		dump_machine_table(); /* does not return */
> +	}
>  
> -	if (mdesc->soft_reboot)
> -		reboot_setup("s");
> +	printk("Machine: %s\n", mdesc->name);
>  
twice, which give something like:

Uncompressing Linux... done, booting the kernel.
[...]
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Freescale MX51 Babbage Board
Machine: Freescale MX51 Babbage Board
Memory policy: ECC disabled, Data cache writeback

>  	if (__atags_pointer)
>  		tags = phys_to_virt(__atags_pointer);
> @@ -861,16 +856,35 @@ void __init setup_arch(char **cmdline_p)
>  		parse_tags(tags);
>  	}
>  
> -	init_mm.start_code = (unsigned long) _text;
> -	init_mm.end_code   = (unsigned long) _etext;
> -	init_mm.end_data   = (unsigned long) _edata;
> -	init_mm.brk	   = (unsigned long) _end;
> -
>  	/* parse_early_param needs a boot_command_line */
>  	strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
>  
>  	/* populate cmd_line too for later use, preserving boot_command_line */
>  	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
> +
> +	return mdesc;
> +}
> +
> +
> +void __init setup_arch(char **cmdline_p)
> +{
> +	struct machine_desc *mdesc;
> +
> +	unwind_init();
> +
> +	setup_processor();
> +	mdesc = setup_machine_tags(machine_arch_type);
> +	machine_desc = mdesc;
> +	machine_name = mdesc->name;
> +
> +	if (mdesc->soft_reboot)
> +		reboot_setup("s");
> +
> +	init_mm.start_code = (unsigned long) _text;
> +	init_mm.end_code   = (unsigned long) _etext;
> +	init_mm.end_data   = (unsigned long) _edata;
> +	init_mm.brk	   = (unsigned long) _end;
> +
>  	*cmdline_p = cmd_line;
>  
>  	parse_early_param();
> 

-- 
Regards,
Shawn


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags
  2011-02-26 15:27   ` Shawn Guo
@ 2011-03-26  6:44     ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-03-26  6:44 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-kernel, linux-arm-kernel, Nicolas Pitre, Russell King

On Sat, Feb 26, 2011 at 8:27 AM, Shawn Guo <shawn.guo@freescale.com> wrote:
> Hi Grant,
>
> One minor nitpicking below ...
>
> On Tue, Feb 22, 2011 at 07:22:19PM -0700, Grant Likely wrote:
>> In preparation for adding device tree support, this patch consolidates
>> all of the atag-specific setup into a single function.
>>
>> v4: - adapt to the removal of lookup_machine_type()
>>     - break out dump of machine_desc table into dump_machine_table()
>>       because the device tree probe code will use it.
>>     - Add for_each_machine_desc() macro
>>
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> ---
>>  arch/arm/include/asm/mach/arch.h |    7 ++++
>>  arch/arm/kernel/setup.c          |   74 +++++++++++++++++++++++---------------
>>  2 files changed, 51 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
>> index 3a0893a..ed9a10c 100644
>> --- a/arch/arm/include/asm/mach/arch.h
>> +++ b/arch/arm/include/asm/mach/arch.h
>> @@ -52,6 +52,13 @@ struct machine_desc {
>>  extern struct machine_desc *machine_desc;
>>
>>  /*
>> + * Machine type table - also only accessible during boot
>> + */
>> +extern struct machine_desc __arch_info_begin[], __arch_info_end[];
>> +#define for_each_machine_desc(p)                     \
>> +     for (p = __arch_info_begin; p < __arch_info_end; p++)
>> +
>> +/*
>>   * Set of macros to define architecture features.  This is built into
>>   * a table by the linker.
>>   */
>> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
>> index 8e046f1..e420565 100644
>> --- a/arch/arm/kernel/setup.c
>> +++ b/arch/arm/kernel/setup.c
>> @@ -439,25 +439,12 @@ void cpu_init(void)
>>           : "r14");
>>  }
>>
>> -static struct machine_desc * __init setup_machine(unsigned int nr)
>> +static void __init dump_machine_table(void)
>>  {
>> -     extern struct machine_desc __arch_info_begin[], __arch_info_end[];
>>       struct machine_desc *p;
>>
>> -     /*
>> -      * locate machine in the list of supported machines.
>> -      */
>> -     for (p = __arch_info_begin; p < __arch_info_end; p++)
>> -             if (nr == p->nr) {
>> -                     printk("Machine: %s\n", p->name);
>> -                     return p;
>> -             }
>> -
>> -     early_print("\n"
>> -             "Error: unrecognized/unsupported machine ID (r1 = 0x%08x).\n\n"
>> -             "Available machine support:\n\nID (hex)\tNAME\n", nr);
>> -
>> -     for (p = __arch_info_begin; p < __arch_info_end; p++)
>> +     early_print("Available machine support:\n\nID (hex)\tNAME\n");
>> +     for_each_machine_desc(p)
>>               early_print("%08x\t%s\n", p->nr, p->name);
>>
>>       early_print("\nPlease check your kernel config and/or bootloader.\n");
>> @@ -819,21 +806,29 @@ static void __init squash_mem_tags(struct tag *tag)
>>                       tag->hdr.tag = ATAG_NONE;
>>  }
>>
>> -void __init setup_arch(char **cmdline_p)
>> +static struct machine_desc * __init setup_machine_tags(unsigned int nr)
>>  {
>>       struct tag *tags = (struct tag *)&init_tags;
>> -     struct machine_desc *mdesc;
>> +     struct machine_desc *mdesc = NULL, *p;
>>       char *from = default_command_line;
>>
>> -     unwind_init();
>> +     /*
>> +      * locate machine in the list of supported machines.
>> +      */
>> +     for_each_machine_desc(p)
>> +             if (nr == p->nr) {
>> +                     printk("Machine: %s\n", p->name);
>
> Print once ...
>
>> +                     mdesc = p;
>> +                     break;
>> +             }
>>
>> -     setup_processor();
>> -     mdesc = setup_machine(machine_arch_type);
>> -     machine_desc = mdesc;
>> -     machine_name = mdesc->name;
>> +     if (!mdesc) {
>> +             early_print("\nError: unrecognized/unsupported machine ID"
>> +                     " (r1 = 0x%08x).\n\n", nr);
>> +             dump_machine_table(); /* does not return */
>> +     }
>>
>> -     if (mdesc->soft_reboot)
>> -             reboot_setup("s");
>> +     printk("Machine: %s\n", mdesc->name);
>>
> twice, which give something like:
>
> Uncompressing Linux... done, booting the kernel.
> [...]
> CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
> Machine: Freescale MX51 Babbage Board
> Machine: Freescale MX51 Babbage Board
> Memory policy: ECC disabled, Data cache writeback

Fixed, thanks.

g.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-03-26  6:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23  2:22 [PATCH v4 0/7] Basic ARM devicetree support Grant Likely
2011-02-23  2:22 ` [PATCH v4 1/7] arm/dt: Make __vet_atags also accept a dtb image Grant Likely
2011-02-23  2:22 ` [PATCH v4 2/7] arm/dt: Allow CONFIG_OF on ARM Grant Likely
2011-02-23  2:22 ` [PATCH v4 3/7] arm/dt: consolidate atags setup into setup_machine_atags Grant Likely
2011-02-26 15:27   ` Shawn Guo
2011-03-26  6:44     ` Grant Likely
2011-02-23  2:22 ` [PATCH v4 4/7] arm/dt: probe for platforms via the device tree Grant Likely
2011-02-23  2:22 ` [PATCH v4 5/7] arm/dt: Basic versatile devicetree support Grant Likely
2011-02-23  2:22 ` [PATCH v4 6/7] arm/dt: Basic tegra " Grant Likely
2011-02-23 21:13   ` Sergei Shtylyov
2011-02-23 21:36     ` Grant Likely
2011-02-25 13:30       ` Sergei Shtylyov
2011-02-25 15:54         ` Grant Likely
2011-02-23  2:22 ` [PATCH v4 7/7] dt: add documentation of ARM dt boot interface Grant Likely
2011-02-23  2:55   ` Nicolas Pitre
2011-02-23  4:35     ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).