All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 07/11] arm-dt: parse devtree pointer on boot
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Add code to parse the device tree pointer from the atags, and an (empty)
routine to create an mdesc from the discovered device tree.

Split the parsing code in setup_arch to handle both device-tree and tags
based machine discovery.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/include/asm/devtree.h |   22 +++++++++
 arch/arm/kernel/Makefile       |    1 
 arch/arm/kernel/devtree.c      |   14 +++++
 arch/arm/kernel/setup.c        |   80 +++++++++++++++++++++------------
 4 files changed, 90 insertions(+), 27 deletions(-)

diff --git a/arch/arm/include/asm/devtree.h b/arch/arm/include/asm/devtree.h
new file mode 100644
index 0000000..0914ac2
--- /dev/null
+++ b/arch/arm/include/asm/devtree.h
@@ -0,0 +1,22 @@
+/*
+ *  linux/arch/arm/include/asm/devtree.h
+ *
+ *  Copyright (C) 2009 Canonical Ltd. <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
+ *
+ * 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.
+ */
+
+#ifdef CONFIG_ARM_DEVTREE
+
+extern struct machine_desc *parse_devicetree(void *devtree);
+
+#else
+
+static inline struct machine_desc *parse_devicetree(void *devtree)
+{
+	return NULL;
+}
+
+#endif
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 79087dd..45d2d82 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -36,6 +36,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_ARM_DEVTREE)	+= devtree.o
 
 obj-$(CONFIG_CRUNCH)		+= crunch.o crunch-bits.o
 AFLAGS_crunch-bits.o		:= -Wa,-mcpu=ep9312
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
new file mode 100644
index 0000000..864eab5
--- /dev/null
+++ b/arch/arm/kernel/devtree.c
@@ -0,0 +1,14 @@
+/*
+ *  linux/arch/arm/kernel/devtree.c
+ *
+ *  Copyright (C) 2009 Canonical Ltd. <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
+ *
+ * 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.
+ */
+
+struct machine_desc * __init parse_devicetree(void *devtree)
+{
+	return NULL;
+}
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e662d17..8abb4be 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -42,6 +42,7 @@
 #include <asm/mach/time.h>
 #include <asm/traps.h>
 #include <asm/unwind.h>
+#include <asm/devtree.h>
 
 #include "compat.h"
 #include "atags.h"
@@ -636,6 +637,17 @@ static void __init parse_tags(const struct tag *t)
 				t->hdr.tag);
 }
 
+static void * __init find_devtree(const struct tag *tags)
+{
+	const struct tag *t;
+
+	for_each_tag(t, tags)
+		if (t->hdr.tag == ATAG_DEVTREE)
+			return __va(t->u.devtree.devtree);
+
+	return NULL;
+}
+
 /*
  * This holds our defaults.
  */
@@ -692,48 +704,62 @@ void __init setup_arch(char **cmdline_p)
 	struct tag *tags = (struct tag *)&init_tags;
 	struct machine_desc *mdesc;
 	char *from = default_command_line;
+	void *devtree;
 
 	unwind_init();
 
 	setup_processor();
-	mdesc = setup_machine(machine_arch_type);
-	machine_name = mdesc->name;
-
-	if (mdesc->soft_reboot)
-		reboot_setup("s");
 
 	if (__atags_pointer)
 		tags = phys_to_virt(__atags_pointer);
-	else if (mdesc->boot_params)
-		tags = phys_to_virt(mdesc->boot_params);
 
-	/*
-	 * If we have the old style parameters, convert them to
-	 * a tag list.
-	 */
-	if (tags->hdr.tag != ATAG_CORE)
-		convert_to_tag_list(tags);
-	if (tags->hdr.tag != ATAG_CORE)
-		tags = (struct tag *)&init_tags;
-
-	if (mdesc->fixup)
-		mdesc->fixup(mdesc, tags, &from, &meminfo);
-
-	if (tags->hdr.tag == ATAG_CORE) {
-		if (meminfo.nr_banks != 0)
-			squash_mem_tags(tags);
-		save_atags(tags);
-		parse_tags(tags);
+	devtree = find_devtree(tags);
+	if (devtree) {
+		mdesc = parse_devicetree(devtree);
+
+		/*
+		 * todo: fallback to arch-number-based mdesc discovery
+		 * if device tree doesn't match
+		 */
+	} else {
+		mdesc = setup_machine(machine_arch_type);
+
+		if (!__atags_pointer && mdesc->boot_params)
+			tags = phys_to_virt(mdesc->boot_params);
+
+		/*
+		 * If we have the old style parameters, convert them to
+		 * a tag list.
+		 */
+		if (tags->hdr.tag != ATAG_CORE)
+			convert_to_tag_list(tags);
+		if (tags->hdr.tag != ATAG_CORE)
+			tags = (struct tag *)&init_tags;
+
+		if (mdesc->fixup)
+			mdesc->fixup(mdesc, tags, &from, &meminfo);
+
+		if (tags->hdr.tag == ATAG_CORE) {
+			if (meminfo.nr_banks != 0)
+				squash_mem_tags(tags);
+			save_atags(tags);
+			parse_tags(tags);
+		}
+
+		/* Copy discovered command line to boot_command_line */
+		strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
+
 	}
 
+	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;
 
-	/* 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);
 	*cmdline_p = cmd_line;

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

* [PATCH 02/11] arm: use generic infrastructure for early params
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

The ARM setup code includes its own parser for early params, there's
also one in the generic init code.

This patch removes __early_init (and related code) from
arch/arm/kernel/setup.c, and changes users to the generic early_init
macro instead.

The generic macro takes a char * argument, rather than char **, so we
need to update the parser functions a little.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/include/asm/setup.h      |   12 -----
 arch/arm/kernel/setup.c           |   62 +++++++-----------------------
 arch/arm/kernel/vmlinux.lds.S     |    3 -
 arch/arm/mach-footbridge/common.c |    7 +--
 arch/arm/mm/init.c                |   12 +++--
 arch/arm/mm/mmu.c                 |   41 ++++++++++---------
 6 files changed, 48 insertions(+), 89 deletions(-)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 1e2ab1b..3b6f461 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -221,18 +221,6 @@ extern struct meminfo meminfo;
 #define bank_phys_end(bank)	((bank)->start + (bank)->size)
 #define bank_phys_size(bank)	(bank)->size
 
-/*
- * Early command line parameters.
- */
-struct early_params {
-	const char *arg;
-	void (*fn)(char **p);
-};
-
-#define __early_param(name,fn)					\
-static struct early_params __early_##fn __used			\
-__attribute__((__section__(".early_param.init"))) = { name, fn }
-
 #define COMMAND_LINE_SIZE 1024
 
 extern char cmd_line[COMMAND_LINE_SIZE];
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 015803a..4206286 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -417,10 +417,11 @@ static int __init arm_add_memory(unsigned long start, unsigned long size)
  * Pick out the memory size.  We look for mem=size@start,
  * where start and size are "size[KkMm]"
  */
-static void __init early_mem(char **p)
+static int __init early_mem(char *p)
 {
 	static int usermem __initdata = 0;
 	unsigned long size, start;
+	char *endp;
 
 	/*
 	 * If the user specifies memory size, we
@@ -433,52 +434,15 @@ static void __init early_mem(char **p)
 	}
 
 	start = PHYS_OFFSET;
-	size  = memparse(*p, p);
-	if (**p == '@')
-		start = memparse(*p + 1, p);
+	size  = memparse(p, &endp);
+	if (*endp == '@')
+		start = memparse(endp + 1, NULL);
 
 	arm_add_memory(start, size);
-}
-__early_param("mem=", early_mem);
 
-/*
- * Initial parsing of the command line.
- */
-static void __init parse_cmdline(char **cmdline_p, char *from)
-{
-	char c = ' ', *to = cmd_line;
-	int len = 0;
-
-	for (;;) {
-		if (c == ' ') {
-			extern struct early_params __early_begin, __early_end;
-			struct early_params *p;
-
-			for (p = &__early_begin; p < &__early_end; p++) {
-				int arglen = strlen(p->arg);
-
-				if (memcmp(from, p->arg, arglen) == 0) {
-					if (to != cmd_line)
-						to -= 1;
-					from += arglen;
-					p->fn(&from);
-
-					while (*from != ' ' && *from != '\0')
-						from++;
-					break;
-				}
-			}
-		}
-		c = *from++;
-		if (!c)
-			break;
-		if (COMMAND_LINE_SIZE <= ++len)
-			break;
-		*to++ = c;
-	}
-	*to = '\0';
-	*cmdline_p = cmd_line;
+	return 0;
 }
+early_param("mem", early_mem);
 
 static void __init
 setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
@@ -739,9 +703,15 @@ void __init setup_arch(char **cmdline_p)
 	init_mm.end_data   = (unsigned long) _edata;
 	init_mm.brk	   = (unsigned long) _end;
 
-	memcpy(boot_command_line, from, COMMAND_LINE_SIZE);
-	boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
-	parse_cmdline(cmdline_p, from);
+	/* 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);
+	*cmdline_p = cmd_line;
+
+	parse_early_param();
+
 	paging_init(mdesc);
 	request_standard_resources(&meminfo, mdesc);
 
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index aecf87d..1975c76 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -46,9 +46,6 @@ SECTIONS
 		__setup_start = .;
 			*(.init.setup)
 		__setup_end = .;
-		__early_begin = .;
-			*(.early_param.init)
-		__early_end = .;
 		__initcall_start = .;
 			INITCALLS
 		__initcall_end = .;
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index b97f529..8a4a8d8 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -32,12 +32,13 @@ unsigned int mem_fclk_21285 = 50000000;
 
 EXPORT_SYMBOL(mem_fclk_21285);
 
-static void __init early_fclk(char **arg)
+static int __init early_fclk(char *arg)
 {
-	mem_fclk_21285 = simple_strtoul(*arg, arg, 0);
+	mem_fclk_21285 = simple_strtoul(arg, NULL, 0);
+	return 0;
 }
 
-__early_param("mem_fclk_21285=", early_fclk);
+early_param("mem_fclk_21285", early_fclk);
 
 static int __init parse_tag_memclk(const struct tag *tag)
 {
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 52c40d1..4d3c90f 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -32,19 +32,21 @@
 static unsigned long phys_initrd_start __initdata = 0;
 static unsigned long phys_initrd_size __initdata = 0;
 
-static void __init early_initrd(char **p)
+static int __init early_initrd(char *p)
 {
 	unsigned long start, size;
+	char *endp;
 
-	start = memparse(*p, p);
-	if (**p == ',') {
-		size = memparse((*p) + 1, p);
+	start = memparse(p, &endp);
+	if (*endp == ',') {
+		size = memparse(endp + 1, NULL);
 
 		phys_initrd_start = start;
 		phys_initrd_size = size;
 	}
+	return 0;
 }
-__early_param("initrd=", early_initrd);
+early_param("initrd", early_initrd);
 
 static int __init parse_tag_initrd(const struct tag *tag)
 {
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index ea67be0..7c07a16 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -100,18 +100,17 @@ static struct cachepolicy cache_policies[] __initdata = {
  * writebuffer to be turned off.  (Note: the write
  * buffer should not be on and the cache off).
  */
-static void __init early_cachepolicy(char **p)
+static int __init early_cachepolicy(char *p)
 {
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(cache_policies); i++) {
 		int len = strlen(cache_policies[i].policy);
 
-		if (memcmp(*p, cache_policies[i].policy, len) == 0) {
+		if (memcmp(p, cache_policies[i].policy, len) == 0) {
 			cachepolicy = i;
 			cr_alignment &= ~cache_policies[i].cr_mask;
 			cr_no_alignment &= ~cache_policies[i].cr_mask;
-			*p += len;
 			break;
 		}
 	}
@@ -130,36 +129,37 @@ static void __init early_cachepolicy(char **p)
 	}
 	flush_cache_all();
 	set_cr(cr_alignment);
+	return 0;
 }
-__early_param("cachepolicy=", early_cachepolicy);
+early_param("cachepolicy", early_cachepolicy);
 
-static void __init early_nocache(char **__unused)
+static int __init early_nocache(char *__unused)
 {
 	char *p = "buffered";
 	printk(KERN_WARNING "nocache is deprecated; use cachepolicy=%s\n", p);
-	early_cachepolicy(&p);
+	early_cachepolicy(p);
+	return 0;
 }
-__early_param("nocache", early_nocache);
+early_param("nocache", early_nocache);
 
-static void __init early_nowrite(char **__unused)
+static int __init early_nowrite(char *__unused)
 {
 	char *p = "uncached";
 	printk(KERN_WARNING "nowb is deprecated; use cachepolicy=%s\n", p);
-	early_cachepolicy(&p);
+	early_cachepolicy(p);
+	return 0;
 }
-__early_param("nowb", early_nowrite);
+early_param("nowb", early_nowrite);
 
-static void __init early_ecc(char **p)
+static int __init early_ecc(char *p)
 {
-	if (memcmp(*p, "on", 2) == 0) {
+	if (memcmp(p, "on", 2) == 0)
 		ecc_mask = PMD_PROTECTION;
-		*p += 2;
-	} else if (memcmp(*p, "off", 3) == 0) {
+	else if (memcmp(p, "off", 3) == 0)
 		ecc_mask = 0;
-		*p += 3;
-	}
+	return 0;
 }
-__early_param("ecc=", early_ecc);
+early_param("ecc", early_ecc);
 
 static int __init noalign_setup(char *__unused)
 {
@@ -671,9 +671,9 @@ static unsigned long __initdata vmalloc_reserve = SZ_128M;
  * bytes. This can be used to increase (or decrease) the vmalloc
  * area - the default is 128m.
  */
-static void __init early_vmalloc(char **arg)
+static int __init early_vmalloc(char *arg)
 {
-	vmalloc_reserve = memparse(*arg, arg);
+	vmalloc_reserve = memparse(arg, NULL);
 
 	if (vmalloc_reserve < SZ_16M) {
 		vmalloc_reserve = SZ_16M;
@@ -688,8 +688,9 @@ static void __init early_vmalloc(char **arg)
 			"vmalloc area is too big, limiting to %luMB\n",
 			vmalloc_reserve >> 20);
 	}
+	return 0;
 }
-__early_param("vmalloc=", early_vmalloc);
+early_param("vmalloc", early_vmalloc);
 
 #define VMALLOC_MIN	(void *)(VMALLOC_END - vmalloc_reserve)

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

* [PATCH 11/11] arm/versatile: probe via device tree
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

For testing the dt work, define a dt-enabled versatile platform,
separate from the existing versatile platform support.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/mach-versatile/Kconfig        |    7 +
 arch/arm/mach-versatile/Makefile       |    1 
 arch/arm/mach-versatile/versatile_dt.c |  129 +++++++++++++++++++++++++
 3 files changed, 137 insertions(+)

diff --git a/arch/arm/mach-versatile/Kconfig b/arch/arm/mach-versatile/Kconfig
index c781f30..9e8f4a9 100644
--- a/arch/arm/mach-versatile/Kconfig
+++ b/arch/arm/mach-versatile/Kconfig
@@ -14,4 +14,11 @@ config MACH_VERSATILE_AB
 	help
 	  Include support for the ARM(R) Versatile/AP platform.
 
+config MACH_VERSATILE_DT
+	bool "Support Versatile platform from device tree"
+	depends on ARM_DEVTREE
+	help
+	  Include support for the ARM(R) Versatile/PB platform,
+	  using the device tree for discovery
+
 endmenu
diff --git a/arch/arm/mach-versatile/Makefile b/arch/arm/mach-versatile/Makefile
index ba81e70..07d0701 100644
--- a/arch/arm/mach-versatile/Makefile
+++ b/arch/arm/mach-versatile/Makefile
@@ -5,4 +5,5 @@
 obj-y					:= core.o clock.o
 obj-$(CONFIG_ARCH_VERSATILE_PB)		+= versatile_pb.o
 obj-$(CONFIG_MACH_VERSATILE_AB)		+= versatile_ab.o
+obj-$(CONFIG_MACH_VERSATILE_DT)		+= versatile_dt.o
 obj-$(CONFIG_PCI)			+= pci.o
diff --git a/arch/arm/mach-versatile/versatile_dt.c b/arch/arm/mach-versatile/versatile_dt.c
new file mode 100644
index 0000000..45c95a2
--- /dev/null
+++ b/arch/arm/mach-versatile/versatile_dt.c
@@ -0,0 +1,129 @@
+/*
+ *  linux/arch/arm/mach-versatile/versatile_dt.c
+ *
+ *  Copyright (C) 2009 Canonical Ltd.
+ *  Copyright (C) 2004 ARM Limited
+ *  Copyright (C) 2000 Deep Blue Solutions Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/sysdev.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/pl061.h>
+#include <linux/amba/mmci.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+#include <mach/hardware.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+
+#include <asm/mach/arch.h>
+
+#include "core.h"
+
+#if 1
+#define IRQ_MMCI1A	IRQ_VICSOURCE23
+#else
+#define IRQ_MMCI1A	IRQ_SIC_MMCI1A
+#endif
+
+static struct mmci_platform_data mmc1_plat_data = {
+	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
+	.status		= mmc_status,
+	.gpio_wp	= -1,
+	.gpio_cd	= -1,
+};
+
+static struct pl061_platform_data gpio2_plat_data = {
+	.gpio_base	= 16,
+	.irq_base	= IRQ_GPIO2_START,
+};
+
+static struct pl061_platform_data gpio3_plat_data = {
+	.gpio_base	= 24,
+	.irq_base	= IRQ_GPIO3_START,
+};
+
+#define UART3_IRQ	{ IRQ_SIC_UART3, NO_IRQ }
+#define UART3_DMA	{ 0x86, 0x87 }
+#define SCI1_IRQ	{ IRQ_SIC_SCI3, NO_IRQ }
+#define SCI1_DMA	{ 0x88, 0x89 }
+#define MMCI1_IRQ	{ IRQ_MMCI1A, IRQ_SIC_MMCI1B }
+#define MMCI1_DMA	{ 0x85, 0 }
+
+/*
+ * These devices are connected via the core APB bridge
+ */
+#define GPIO2_IRQ	{ IRQ_GPIOINT2, NO_IRQ }
+#define GPIO2_DMA	{ 0, 0 }
+#define GPIO3_IRQ	{ IRQ_GPIOINT3, NO_IRQ }
+#define GPIO3_DMA	{ 0, 0 }
+
+/*
+ * These devices are connected via the DMA APB bridge
+ */
+
+/* FPGA Primecells */
+AMBA_DEVICE(uart3, "fpga:09", UART3,    NULL);
+AMBA_DEVICE(sci1,  "fpga:0a", SCI1,     NULL);
+AMBA_DEVICE(mmc1,  "fpga:0b", MMCI1,    &mmc1_plat_data);
+
+/* DevChip Primecells */
+AMBA_DEVICE(gpio2, "dev:e6",  GPIO2,    &gpio2_plat_data);
+AMBA_DEVICE(gpio3, "dev:e7",  GPIO3,    &gpio3_plat_data);
+
+static struct amba_device *amba_devs[] __initdata = {
+	&uart3_device,
+	&gpio2_device,
+	&gpio3_device,
+	&sci1_device,
+	&mmc1_device,
+};
+
+static void __init versatile_dt_init(void)
+{
+	int i;
+
+	versatile_init();
+
+	for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
+		struct amba_device *d = amba_devs[i];
+		amba_device_register(d, &iomem_resource);
+	}
+}
+static int __init versatile_dt_probe(unsigned long dt)
+{
+	if (!of_flat_dt_is_compatible(dt, "arm,versatile"))
+		return 0;
+
+	return 1;
+}
+
+DT_MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
+	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
+	.phys_io	= 0x101f1000,
+	.io_pg_offst	= ((0xf11f1000) >> 18) & 0xfffc,
+	.boot_params	= 0x00000100,
+	.map_io		= versatile_map_io,
+	.init_irq	= versatile_init_irq,
+	.timer		= &versatile_timer,
+	.init_machine	= versatile_dt_init,
+	.probe_dt	= versatile_dt_probe,
+MACHINE_END

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

* [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

When we're using CONFIG_ARM_DEVTREE, we need to postpone machine detection
until later in setup_arch. Because ARM_DEVTREE depends on !DEBUG_LL,
we don't need the mdesc this early anyway.

We'll add support for ARM_DEVTREE && DEBUG_LL later.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/kernel/head.S |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 38ccbe1..66bb56f 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -82,9 +82,18 @@ ENTRY(stext)
 	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
 	movs	r10, r5				@ invalid processor (r5=0)?
 	beq	__error_p			@ yes, error 'p'
+
+	/* If we're using the device tree for machine detection, we don't
+	 * look for a machinfo here, as we'll dynamically create one in
+	 * setup_arch(). ARM_DEVTREE depends on !DEBUG_LL, so we won't need
+	 * any machinfo fields 'til later.
+	 */
+#ifndef CONFIG_ARM_DEVTREE
 	bl	__lookup_machine_type		@ r5=machinfo
 	movs	r8, r5				@ invalid machine (r5=0)?
 	beq	__error_a			@ yes, error 'a'
+#endif
+
 	bl	__vet_atags
 	bl	__create_page_tables

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

* [PATCH 10/11] arm-dt: parse initrd from device tree
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Move early_init_dt_setup_initrd_arch to arch/arm/mm/init.c, and populate
it to set the properties of the parsed initrd area.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/kernel/devtree.c |    3 ---
 arch/arm/mm/init.c        |   15 +++++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 2ff4bd0..9fd1f24 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -23,9 +23,6 @@ struct device_node *of_chosen;
 
 void __init early_init_dt_scan_chosen_arch(unsigned long node) { }
 
-void __init early_init_dt_setup_initrd_arch(unsigned long start,
-					    unsigned long end) { }
-
 void __init early_init_devtree_arch(void) { }
 
 int __init early_init_dt_scan_memory_arch(unsigned long node,
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 4d3c90f..77f09d6 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -18,6 +18,11 @@
 #include <linux/sort.h>
 #include <linux/highmem.h>
 
+#ifdef CONFIG_ARM_DEVTREEE
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#endif /* CONFIG_ARM_DEVTREEE */
+
 #include <asm/mach-types.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
@@ -68,6 +73,16 @@ static int __init parse_tag_initrd2(const struct tag *tag)
 
 __tagtable(ATAG_INITRD2, parse_tag_initrd2);
 
+#if defined(CONFIG_BLK_DEV_INITRD) && defined(CONFIG_ARM_DEVTREE)
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end)
+{
+	phys_initrd_start = start;
+	phys_initrd_size = end - start;
+}
+#endif /* CONFIG_BLK_DEV_INITRD && CONFIG_ARM_DEVTREE */
+
+
 /*
  * 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] 33+ messages in thread

* [PATCH 08/11] arm-dt: parse memory info from DT
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Move the early_init_dt hooks into a new file, and populate the
_alloc_memory and _add_memory functions.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/kernel/devtree.c |   42 ++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/setup.c   |   23 --------------------
 2 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 864eab5..a8496f6 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -8,6 +8,48 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/bootmem.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+#include <asm/setup.h>
+#include <asm/page.h>
+
+struct device_node *of_chosen;
+
+void __init early_init_dt_scan_chosen_arch(unsigned long node) { }
+
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end) { }
+
+void __init early_init_devtree_arch(void) { }
+
+int __init early_init_dt_scan_memory_arch(unsigned long node,
+					    const char *uname,
+					    int depth, void *data)
+{
+	return -EINVAL;
+}
+
+void __init early_init_dt_add_memory(u64 base, u64 size)
+{
+	arm_add_memory(base, size);
+}
+
+u64 __init early_init_dt_alloc_memory(u64 size, u64 align)
+{
+	return __pa(__alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)));
+}
+
+int __init early_init_dt_scan_cpus(unsigned long node, const char *uname,
+			    int depth, void *data)
+{
+	return 0;
+}
+
 struct machine_desc * __init parse_devicetree(void *devtree)
 {
 	return NULL;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 8abb4be..88d4def 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -676,29 +676,6 @@ static int __init customize_machine(void)
 }
 arch_initcall(customize_machine);
 
-/* arch-specific device tree handling */
-#ifdef CONFIG_ARM_DEVTREE
-void early_init_dt_scan_chosen_arch(unsigned long node) { }
-
-void early_init_dt_setup_initrd_arch(unsigned long start, unsigned long_end) { }
-
-void early_init_devtree_arch(void) { }
-
-int early_init_dt_scan_memory(unsigned long node, const char *uname,
-			      int depth, void *data)
-{
-	return 0;
-}
-
-int early_init_dt_scan_cpus(unsigned long node, const char *uname,
-			    int depth, void *data)
-{
-	return 0;
-}
-
-struct device_node *of_chosen;
-#endif /* CONFIG_ARM_DEVTREE */
-
 void __init setup_arch(char **cmdline_p)
 {
 	struct tag *tags = (struct tag *)&init_tags;

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

* [PATCH 00/11] Device-tree support for ARM
@ 2009-12-22 10:54 ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Hi all,

The following series of patches is an early prototype to add device tree
support to the ARM architecture.

If you're not familiar with device trees: a device tree is a data
structure describing the hardware that the kernel is booted on. On boot,
the bootloader can pass a 'device tree blob' to the kernel; the kernel
then parses the blob and extracts data used to initialise the machine.
Think ATAGS with a free-form structure and arbitrary property names and
values.

For cases where we don't want to rely on the bootloader's device tree
blob[1] (maybe we have an updated one with fixes), we can supply our own
device tree, attached to the kernel and passed through a boot wrapper.

Device trees are currently used in the boot process for the powerpc,
sparc and microblaze architectures.

This work is aimed at reducing the effort required to port to a new
board. Some hardware changes to may not require a new kernel at all;
these may be described by a corresponding change to the device
tree.

We'd also hope to see an overall decrease in code required as drivers
can be made generic enough to support a set of compatible devices, with
the differences being represented in the device tree.

At this stage, I've just added a mechanism to probe a platform
(Versatile PB) using a device tree; this is just a proof of concept for
machine probe, the interesting stuff happens when we can add DT support
to drivers that the DT-enabled platforms use. Also todo is the boot
wrapper to enable us to embed an updated DT in a bootable image.

These patches are based on Grant Likely's test-devicetree repo[2], which
is an effort to merge the common device tree code between the powerpc,
sparc and microblaze architectures. I have a git tree[3] of these
patches up too, based on his tree.

The approach I've chosen for a boot interface is to add an ATAG that
points to a device tree blob. If this ATAG is found, we use the
device-tree based discovery. There are a couple of other options, but I
think this is the least-intrusive method of passing the DT to the
kernel, and will continue to work with non-DT bootloaders.

If you'd like to try the code out, I have a page[4] up that has
details of the kernel, a link to DT-enabled qemu sources and a sample
device tree for the versatile machine.

This is only an initial prototype, but I'd appreciate any comments,
feedback or review.

Cheers,


Jeremy

1: http://lkml.org/lkml/2009/5/27/446
2: http://git.secretlab.ca/?p=linux-2.6.git;a=shortlog;h=refs/heads/test-devicetree
3: http://kernel.ubuntu.com/git?p=jk/dt/linux-2.6.git;a=summary
4: https://wiki.ubuntu.com/KernelTeam/ARMDeviceTrees

---
Jeremy Kerr (11):
      arm: change command_line to cmd_line, and export it
      arm: use generic infrastructure for early params
      arm: export arm_add_memory
      arm-dt: Add ATAG_DEVTREE tag
      arm-dt: Add CONFIG_ARM_DEVTREE
      arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
      arm-dt: parse devtree pointer on boot
      arm-dt: parse memory info from DT
      arm-dt: probe for device-tree enabled platforms
      arm-dt: parse initrd from device tree
      arm/versatile: probe via device tree

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

* [PATCH 09/11] arm-dt: probe for device-tree enabled platforms
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Add a probe_dt pointer to struct machine_desc, which can be populated by
platforms that support discovery via device trees.

At setup_arch time, each compiled-in machine_desc with a dt_probe member
will be probed. If the probe function returns 1, we have a match.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/include/asm/mach/arch.h |   10 ++++++++++
 arch/arm/kernel/devtree.c        |   19 ++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index c59842d..b83af35 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -41,6 +41,7 @@ struct machine_desc {
 	void			(*init_irq)(void);
 	struct sys_timer	*timer;		/* system tick timer	*/
 	void			(*init_machine)(void);
+	int			(*probe_dt)(unsigned long root);
 };
 
 /*
@@ -57,4 +58,13 @@ static const struct machine_desc __mach_desc_##_type	\
 #define MACHINE_END				\
 };
 
+#define MACH_TYPE_DT	0xffffffff
+
+#define DT_MACHINE_START(_name, _namestr)		\
+static const struct machine_desc __mach_desc_##_name	\
+ __used							\
+ __attribute__((__section__(".arch.info.init"))) = {	\
+	.nr		= MACH_TYPE_DT,			\
+	.name		= _namestr,
+
 #endif
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index a8496f6..2ff4bd0 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -17,6 +17,7 @@
 
 #include <asm/setup.h>
 #include <asm/page.h>
+#include <asm/mach/arch.h>
 
 struct device_node *of_chosen;
 
@@ -52,5 +53,21 @@ int __init early_init_dt_scan_cpus(unsigned long node, const char *uname,
 
 struct machine_desc * __init parse_devicetree(void *devtree)
 {
-	return NULL;
+	extern struct machine_desc __arch_info_begin, __arch_info_end;
+	struct machine_desc *mdesc;
+	unsigned long dt_root;
+
+	early_init_devtree(devtree);
+
+	dt_root = of_get_flat_dt_root();
+
+	for (mdesc = &__arch_info_begin; mdesc < &__arch_info_end; mdesc++) {
+		if (mdesc->probe_dt && mdesc->probe_dt(dt_root))
+			break;
+	}
+
+	if (mdesc >= &__arch_info_end)
+		return NULL;
+
+	return mdesc;
 }

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

* [PATCH 05/11] arm-dt: Add CONFIG_ARM_DEVTREE
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Add some basic empty infrastructure for DT support on ARM.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/Kconfig            |   13 +++++++++++++
 arch/arm/include/asm/prom.h |   28 ++++++++++++++++++++++++++++
 arch/arm/kernel/setup.c     |   28 ++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1c4119c..2e53d33 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1225,6 +1225,19 @@ endmenu
 
 menu "Boot options"
 
+config OF
+	bool
+	default n
+
+config ARM_DEVTREE
+	bool "Device tree support"
+	default y
+	depends on !DEBUG_LL
+	select OF
+	select OF_FLATTREE
+	help
+	  Support for OpenFirmware-style device trees
+
 # 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..5260d22
--- /dev/null
+++ b/arch/arm/include/asm/prom.h
@@ -0,0 +1,28 @@
+/*
+ *  arch/arm/include/asm/prom.h
+ *
+ *  Copyright (C) 2009 Canonical Ltd. <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
+ *
+ * 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
+
+#include <asm/setup.h>
+
+#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	1
+#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
+
+#define of_compat_cmp(s1, s2, l)	strncasecmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
+#define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
+
+/* _ALIGN expects upwards alignment */
+#define _ALIGN(addr, size)		(((addr)+((size)-1))&(~((size)-1)))
+
+extern struct device_node *of_chosen;
+
+#endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 84fd876..e662d17 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -47,6 +47,11 @@
 #include "atags.h"
 #include "tcm.h"
 
+#ifdef CONFIG_ARM_DEVTREE
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#endif
+
 #ifndef MEM_SIZE
 #define MEM_SIZE	(16*1024*1024)
 #endif
@@ -659,6 +664,29 @@ static int __init customize_machine(void)
 }
 arch_initcall(customize_machine);
 
+/* arch-specific device tree handling */
+#ifdef CONFIG_ARM_DEVTREE
+void early_init_dt_scan_chosen_arch(unsigned long node) { }
+
+void early_init_dt_setup_initrd_arch(unsigned long start, unsigned long_end) { }
+
+void early_init_devtree_arch(void) { }
+
+int early_init_dt_scan_memory(unsigned long node, const char *uname,
+			      int depth, void *data)
+{
+	return 0;
+}
+
+int early_init_dt_scan_cpus(unsigned long node, const char *uname,
+			    int depth, void *data)
+{
+	return 0;
+}
+
+struct device_node *of_chosen;
+#endif /* CONFIG_ARM_DEVTREE */
+
 void __init setup_arch(char **cmdline_p)
 {
 	struct tag *tags = (struct tag *)&init_tags;

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

* [PATCH 04/11] arm-dt: Add ATAG_DEVTREE tag
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

We'd like to provide a pointer to the device tree blob through the atags
mechanism, so add a tag type containing a physical dtb pointer.

We won't need a parser for this, as we'll need to do the devtree parsing
a little earlier than other tags.

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/include/asm/setup.h |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 3fa2555..99ba6db 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -141,6 +141,13 @@ struct tag_memclk {
 	__u32 fmemclk;
 };
 
+/* OF device tree blob pointer */
+#define ATAG_DEVTREE	0x5441000a
+
+struct tag_devtree {
+	__u32 devtree;		/* physical address */
+};
+
 struct tag {
 	struct tag_header hdr;
 	union {
@@ -153,6 +160,7 @@ struct tag {
 		struct tag_revision	revision;
 		struct tag_videolfb	videolfb;
 		struct tag_cmdline	cmdline;
+		struct tag_devtree	devtree;
 
 		/*
 		 * Acorn specific

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

* [PATCH 01/11] arm: change command_line to cmd_line, and export it
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

drivers/of/fdt expects a cmd_line symbol, while arm uses command_line.
Change to the former and make accessible from setup.h, so that we can
share with the fdt code.

This means a change in section from .init.data to .data

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/include/asm/setup.h |    6 ++++--
 arch/arm/kernel/setup.c      |    8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 5ccce0a..1e2ab1b 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -16,8 +16,6 @@
 
 #include <linux/types.h>
 
-#define COMMAND_LINE_SIZE 1024
-
 /* The list ends with an ATAG_NONE node. */
 #define ATAG_NONE	0x00000000
 
@@ -235,6 +233,10 @@ struct early_params {
 static struct early_params __early_##fn __used			\
 __attribute__((__section__(".early_param.init"))) = { name, fn }
 
+#define COMMAND_LINE_SIZE 1024
+
+extern char cmd_line[COMMAND_LINE_SIZE];
+
 #endif  /*  __KERNEL__  */
 
 #endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index c6c57b6..015803a 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -117,7 +117,7 @@ EXPORT_SYMBOL(elf_platform);
 
 static const char *cpu_name;
 static const char *machine_name;
-static char __initdata command_line[COMMAND_LINE_SIZE];
+char cmd_line[COMMAND_LINE_SIZE];
 
 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
@@ -446,7 +446,7 @@ __early_param("mem=", early_mem);
  */
 static void __init parse_cmdline(char **cmdline_p, char *from)
 {
-	char c = ' ', *to = command_line;
+	char c = ' ', *to = cmd_line;
 	int len = 0;
 
 	for (;;) {
@@ -458,7 +458,7 @@ static void __init parse_cmdline(char **cmdline_p, char *from)
 				int arglen = strlen(p->arg);
 
 				if (memcmp(from, p->arg, arglen) == 0) {
-					if (to != command_line)
+					if (to != cmd_line)
 						to -= 1;
 					from += arglen;
 					p->fn(&from);
@@ -477,7 +477,7 @@ static void __init parse_cmdline(char **cmdline_p, char *from)
 		*to++ = c;
 	}
 	*to = '\0';
-	*cmdline_p = command_line;
+	*cmdline_p = cmd_line;
 }
 
 static void __init

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

* [PATCH 03/11] arm: export arm_add_memory
  2009-12-22 10:54 ` Jeremy Kerr
@ 2009-12-22 10:54   ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

We'd like to add memory from the device tree, so make arm_add_memory
non-static and add a prototype in setup.h

Signed-off-by: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

---
 arch/arm/include/asm/setup.h |    2 ++
 arch/arm/kernel/setup.c      |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 3b6f461..3fa2555 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -225,6 +225,8 @@ extern struct meminfo meminfo;
 
 extern char cmd_line[COMMAND_LINE_SIZE];
 
+extern int arm_add_memory(unsigned long start, unsigned long size);
+
 #endif  /*  __KERNEL__  */
 
 #endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 4206286..84fd876 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -383,7 +383,7 @@ static struct machine_desc * __init setup_machine(unsigned int nr)
 	return list;
 }
 
-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];

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

* [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

When we're using CONFIG_ARM_DEVTREE, we need to postpone machine detection
until later in setup_arch. Because ARM_DEVTREE depends on !DEBUG_LL,
we don't need the mdesc this early anyway.

We'll add support for ARM_DEVTREE && DEBUG_LL later.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/kernel/head.S |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 38ccbe1..66bb56f 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -82,9 +82,18 @@ ENTRY(stext)
 	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
 	movs	r10, r5				@ invalid processor (r5=0)?
 	beq	__error_p			@ yes, error 'p'
+
+	/* If we're using the device tree for machine detection, we don't
+	 * look for a machinfo here, as we'll dynamically create one in
+	 * setup_arch(). ARM_DEVTREE depends on !DEBUG_LL, so we won't need
+	 * any machinfo fields 'til later.
+	 */
+#ifndef CONFIG_ARM_DEVTREE
 	bl	__lookup_machine_type		@ r5=machinfo
 	movs	r8, r5				@ invalid machine (r5=0)?
 	beq	__error_a			@ yes, error 'a'
+#endif
+
 	bl	__vet_atags
 	bl	__create_page_tables
 

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

* [PATCH 07/11] arm-dt: parse devtree pointer on boot
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Add code to parse the device tree pointer from the atags, and an (empty)
routine to create an mdesc from the discovered device tree.

Split the parsing code in setup_arch to handle both device-tree and tags
based machine discovery.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/include/asm/devtree.h |   22 +++++++++
 arch/arm/kernel/Makefile       |    1 
 arch/arm/kernel/devtree.c      |   14 +++++
 arch/arm/kernel/setup.c        |   80 +++++++++++++++++++++------------
 4 files changed, 90 insertions(+), 27 deletions(-)

diff --git a/arch/arm/include/asm/devtree.h b/arch/arm/include/asm/devtree.h
new file mode 100644
index 0000000..0914ac2
--- /dev/null
+++ b/arch/arm/include/asm/devtree.h
@@ -0,0 +1,22 @@
+/*
+ *  linux/arch/arm/include/asm/devtree.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.
+ */
+
+#ifdef CONFIG_ARM_DEVTREE
+
+extern struct machine_desc *parse_devicetree(void *devtree);
+
+#else
+
+static inline struct machine_desc *parse_devicetree(void *devtree)
+{
+	return NULL;
+}
+
+#endif
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 79087dd..45d2d82 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -36,6 +36,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_ARM_DEVTREE)	+= devtree.o
 
 obj-$(CONFIG_CRUNCH)		+= crunch.o crunch-bits.o
 AFLAGS_crunch-bits.o		:= -Wa,-mcpu=ep9312
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
new file mode 100644
index 0000000..864eab5
--- /dev/null
+++ b/arch/arm/kernel/devtree.c
@@ -0,0 +1,14 @@
+/*
+ *  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.
+ */
+
+struct machine_desc * __init parse_devicetree(void *devtree)
+{
+	return NULL;
+}
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e662d17..8abb4be 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -42,6 +42,7 @@
 #include <asm/mach/time.h>
 #include <asm/traps.h>
 #include <asm/unwind.h>
+#include <asm/devtree.h>
 
 #include "compat.h"
 #include "atags.h"
@@ -636,6 +637,17 @@ static void __init parse_tags(const struct tag *t)
 				t->hdr.tag);
 }
 
+static void * __init find_devtree(const struct tag *tags)
+{
+	const struct tag *t;
+
+	for_each_tag(t, tags)
+		if (t->hdr.tag == ATAG_DEVTREE)
+			return __va(t->u.devtree.devtree);
+
+	return NULL;
+}
+
 /*
  * This holds our defaults.
  */
@@ -692,48 +704,62 @@ void __init setup_arch(char **cmdline_p)
 	struct tag *tags = (struct tag *)&init_tags;
 	struct machine_desc *mdesc;
 	char *from = default_command_line;
+	void *devtree;
 
 	unwind_init();
 
 	setup_processor();
-	mdesc = setup_machine(machine_arch_type);
-	machine_name = mdesc->name;
-
-	if (mdesc->soft_reboot)
-		reboot_setup("s");
 
 	if (__atags_pointer)
 		tags = phys_to_virt(__atags_pointer);
-	else if (mdesc->boot_params)
-		tags = phys_to_virt(mdesc->boot_params);
 
-	/*
-	 * If we have the old style parameters, convert them to
-	 * a tag list.
-	 */
-	if (tags->hdr.tag != ATAG_CORE)
-		convert_to_tag_list(tags);
-	if (tags->hdr.tag != ATAG_CORE)
-		tags = (struct tag *)&init_tags;
-
-	if (mdesc->fixup)
-		mdesc->fixup(mdesc, tags, &from, &meminfo);
-
-	if (tags->hdr.tag == ATAG_CORE) {
-		if (meminfo.nr_banks != 0)
-			squash_mem_tags(tags);
-		save_atags(tags);
-		parse_tags(tags);
+	devtree = find_devtree(tags);
+	if (devtree) {
+		mdesc = parse_devicetree(devtree);
+
+		/*
+		 * todo: fallback to arch-number-based mdesc discovery
+		 * if device tree doesn't match
+		 */
+	} else {
+		mdesc = setup_machine(machine_arch_type);
+
+		if (!__atags_pointer && mdesc->boot_params)
+			tags = phys_to_virt(mdesc->boot_params);
+
+		/*
+		 * If we have the old style parameters, convert them to
+		 * a tag list.
+		 */
+		if (tags->hdr.tag != ATAG_CORE)
+			convert_to_tag_list(tags);
+		if (tags->hdr.tag != ATAG_CORE)
+			tags = (struct tag *)&init_tags;
+
+		if (mdesc->fixup)
+			mdesc->fixup(mdesc, tags, &from, &meminfo);
+
+		if (tags->hdr.tag == ATAG_CORE) {
+			if (meminfo.nr_banks != 0)
+				squash_mem_tags(tags);
+			save_atags(tags);
+			parse_tags(tags);
+		}
+
+		/* Copy discovered command line to boot_command_line */
+		strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
+
 	}
 
+	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;
 
-	/* 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);
 	*cmdline_p = cmd_line;

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

* [PATCH 08/11] arm-dt: parse memory info from DT
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Move the early_init_dt hooks into a new file, and populate the
_alloc_memory and _add_memory functions.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/kernel/devtree.c |   42 ++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/setup.c   |   23 --------------------
 2 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 864eab5..a8496f6 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -8,6 +8,48 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/bootmem.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+#include <asm/setup.h>
+#include <asm/page.h>
+
+struct device_node *of_chosen;
+
+void __init early_init_dt_scan_chosen_arch(unsigned long node) { }
+
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end) { }
+
+void __init early_init_devtree_arch(void) { }
+
+int __init early_init_dt_scan_memory_arch(unsigned long node,
+					    const char *uname,
+					    int depth, void *data)
+{
+	return -EINVAL;
+}
+
+void __init early_init_dt_add_memory(u64 base, u64 size)
+{
+	arm_add_memory(base, size);
+}
+
+u64 __init early_init_dt_alloc_memory(u64 size, u64 align)
+{
+	return __pa(__alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)));
+}
+
+int __init early_init_dt_scan_cpus(unsigned long node, const char *uname,
+			    int depth, void *data)
+{
+	return 0;
+}
+
 struct machine_desc * __init parse_devicetree(void *devtree)
 {
 	return NULL;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 8abb4be..88d4def 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -676,29 +676,6 @@ static int __init customize_machine(void)
 }
 arch_initcall(customize_machine);
 
-/* arch-specific device tree handling */
-#ifdef CONFIG_ARM_DEVTREE
-void early_init_dt_scan_chosen_arch(unsigned long node) { }
-
-void early_init_dt_setup_initrd_arch(unsigned long start, unsigned long_end) { }
-
-void early_init_devtree_arch(void) { }
-
-int early_init_dt_scan_memory(unsigned long node, const char *uname,
-			      int depth, void *data)
-{
-	return 0;
-}
-
-int early_init_dt_scan_cpus(unsigned long node, const char *uname,
-			    int depth, void *data)
-{
-	return 0;
-}
-
-struct device_node *of_chosen;
-#endif /* CONFIG_ARM_DEVTREE */
-
 void __init setup_arch(char **cmdline_p)
 {
 	struct tag *tags = (struct tag *)&init_tags;

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

* [PATCH 10/11] arm-dt: parse initrd from device tree
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Move early_init_dt_setup_initrd_arch to arch/arm/mm/init.c, and populate
it to set the properties of the parsed initrd area.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/kernel/devtree.c |    3 ---
 arch/arm/mm/init.c        |   15 +++++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 2ff4bd0..9fd1f24 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -23,9 +23,6 @@ struct device_node *of_chosen;
 
 void __init early_init_dt_scan_chosen_arch(unsigned long node) { }
 
-void __init early_init_dt_setup_initrd_arch(unsigned long start,
-					    unsigned long end) { }
-
 void __init early_init_devtree_arch(void) { }
 
 int __init early_init_dt_scan_memory_arch(unsigned long node,
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 4d3c90f..77f09d6 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -18,6 +18,11 @@
 #include <linux/sort.h>
 #include <linux/highmem.h>
 
+#ifdef CONFIG_ARM_DEVTREEE
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#endif /* CONFIG_ARM_DEVTREEE */
+
 #include <asm/mach-types.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
@@ -68,6 +73,16 @@ static int __init parse_tag_initrd2(const struct tag *tag)
 
 __tagtable(ATAG_INITRD2, parse_tag_initrd2);
 
+#if defined(CONFIG_BLK_DEV_INITRD) && defined(CONFIG_ARM_DEVTREE)
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end)
+{
+	phys_initrd_start = start;
+	phys_initrd_size = end - start;
+}
+#endif /* CONFIG_BLK_DEV_INITRD && CONFIG_ARM_DEVTREE */
+
+
 /*
  * 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] 33+ messages in thread

* [PATCH 11/11] arm/versatile: probe via device tree
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

For testing the dt work, define a dt-enabled versatile platform,
separate from the existing versatile platform support.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/mach-versatile/Kconfig        |    7 +
 arch/arm/mach-versatile/Makefile       |    1 
 arch/arm/mach-versatile/versatile_dt.c |  129 +++++++++++++++++++++++++
 3 files changed, 137 insertions(+)

diff --git a/arch/arm/mach-versatile/Kconfig b/arch/arm/mach-versatile/Kconfig
index c781f30..9e8f4a9 100644
--- a/arch/arm/mach-versatile/Kconfig
+++ b/arch/arm/mach-versatile/Kconfig
@@ -14,4 +14,11 @@ config MACH_VERSATILE_AB
 	help
 	  Include support for the ARM(R) Versatile/AP platform.
 
+config MACH_VERSATILE_DT
+	bool "Support Versatile platform from device tree"
+	depends on ARM_DEVTREE
+	help
+	  Include support for the ARM(R) Versatile/PB platform,
+	  using the device tree for discovery
+
 endmenu
diff --git a/arch/arm/mach-versatile/Makefile b/arch/arm/mach-versatile/Makefile
index ba81e70..07d0701 100644
--- a/arch/arm/mach-versatile/Makefile
+++ b/arch/arm/mach-versatile/Makefile
@@ -5,4 +5,5 @@
 obj-y					:= core.o clock.o
 obj-$(CONFIG_ARCH_VERSATILE_PB)		+= versatile_pb.o
 obj-$(CONFIG_MACH_VERSATILE_AB)		+= versatile_ab.o
+obj-$(CONFIG_MACH_VERSATILE_DT)		+= versatile_dt.o
 obj-$(CONFIG_PCI)			+= pci.o
diff --git a/arch/arm/mach-versatile/versatile_dt.c b/arch/arm/mach-versatile/versatile_dt.c
new file mode 100644
index 0000000..45c95a2
--- /dev/null
+++ b/arch/arm/mach-versatile/versatile_dt.c
@@ -0,0 +1,129 @@
+/*
+ *  linux/arch/arm/mach-versatile/versatile_dt.c
+ *
+ *  Copyright (C) 2009 Canonical Ltd.
+ *  Copyright (C) 2004 ARM Limited
+ *  Copyright (C) 2000 Deep Blue Solutions Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/sysdev.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/pl061.h>
+#include <linux/amba/mmci.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+#include <mach/hardware.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+
+#include <asm/mach/arch.h>
+
+#include "core.h"
+
+#if 1
+#define IRQ_MMCI1A	IRQ_VICSOURCE23
+#else
+#define IRQ_MMCI1A	IRQ_SIC_MMCI1A
+#endif
+
+static struct mmci_platform_data mmc1_plat_data = {
+	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
+	.status		= mmc_status,
+	.gpio_wp	= -1,
+	.gpio_cd	= -1,
+};
+
+static struct pl061_platform_data gpio2_plat_data = {
+	.gpio_base	= 16,
+	.irq_base	= IRQ_GPIO2_START,
+};
+
+static struct pl061_platform_data gpio3_plat_data = {
+	.gpio_base	= 24,
+	.irq_base	= IRQ_GPIO3_START,
+};
+
+#define UART3_IRQ	{ IRQ_SIC_UART3, NO_IRQ }
+#define UART3_DMA	{ 0x86, 0x87 }
+#define SCI1_IRQ	{ IRQ_SIC_SCI3, NO_IRQ }
+#define SCI1_DMA	{ 0x88, 0x89 }
+#define MMCI1_IRQ	{ IRQ_MMCI1A, IRQ_SIC_MMCI1B }
+#define MMCI1_DMA	{ 0x85, 0 }
+
+/*
+ * These devices are connected via the core APB bridge
+ */
+#define GPIO2_IRQ	{ IRQ_GPIOINT2, NO_IRQ }
+#define GPIO2_DMA	{ 0, 0 }
+#define GPIO3_IRQ	{ IRQ_GPIOINT3, NO_IRQ }
+#define GPIO3_DMA	{ 0, 0 }
+
+/*
+ * These devices are connected via the DMA APB bridge
+ */
+
+/* FPGA Primecells */
+AMBA_DEVICE(uart3, "fpga:09", UART3,    NULL);
+AMBA_DEVICE(sci1,  "fpga:0a", SCI1,     NULL);
+AMBA_DEVICE(mmc1,  "fpga:0b", MMCI1,    &mmc1_plat_data);
+
+/* DevChip Primecells */
+AMBA_DEVICE(gpio2, "dev:e6",  GPIO2,    &gpio2_plat_data);
+AMBA_DEVICE(gpio3, "dev:e7",  GPIO3,    &gpio3_plat_data);
+
+static struct amba_device *amba_devs[] __initdata = {
+	&uart3_device,
+	&gpio2_device,
+	&gpio3_device,
+	&sci1_device,
+	&mmc1_device,
+};
+
+static void __init versatile_dt_init(void)
+{
+	int i;
+
+	versatile_init();
+
+	for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
+		struct amba_device *d = amba_devs[i];
+		amba_device_register(d, &iomem_resource);
+	}
+}
+static int __init versatile_dt_probe(unsigned long dt)
+{
+	if (!of_flat_dt_is_compatible(dt, "arm,versatile"))
+		return 0;
+
+	return 1;
+}
+
+DT_MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
+	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
+	.phys_io	= 0x101f1000,
+	.io_pg_offst	= ((0xf11f1000) >> 18) & 0xfffc,
+	.boot_params	= 0x00000100,
+	.map_io		= versatile_map_io,
+	.init_irq	= versatile_init_irq,
+	.timer		= &versatile_timer,
+	.init_machine	= versatile_dt_init,
+	.probe_dt	= versatile_dt_probe,
+MACHINE_END

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

* [PATCH 02/11] arm: use generic infrastructure for early params
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

The ARM setup code includes its own parser for early params, there's
also one in the generic init code.

This patch removes __early_init (and related code) from
arch/arm/kernel/setup.c, and changes users to the generic early_init
macro instead.

The generic macro takes a char * argument, rather than char **, so we
need to update the parser functions a little.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/include/asm/setup.h      |   12 -----
 arch/arm/kernel/setup.c           |   62 +++++++-----------------------
 arch/arm/kernel/vmlinux.lds.S     |    3 -
 arch/arm/mach-footbridge/common.c |    7 +--
 arch/arm/mm/init.c                |   12 +++--
 arch/arm/mm/mmu.c                 |   41 ++++++++++---------
 6 files changed, 48 insertions(+), 89 deletions(-)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 1e2ab1b..3b6f461 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -221,18 +221,6 @@ extern struct meminfo meminfo;
 #define bank_phys_end(bank)	((bank)->start + (bank)->size)
 #define bank_phys_size(bank)	(bank)->size
 
-/*
- * Early command line parameters.
- */
-struct early_params {
-	const char *arg;
-	void (*fn)(char **p);
-};
-
-#define __early_param(name,fn)					\
-static struct early_params __early_##fn __used			\
-__attribute__((__section__(".early_param.init"))) = { name, fn }
-
 #define COMMAND_LINE_SIZE 1024
 
 extern char cmd_line[COMMAND_LINE_SIZE];
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 015803a..4206286 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -417,10 +417,11 @@ static int __init arm_add_memory(unsigned long start, unsigned long size)
  * Pick out the memory size.  We look for mem=size at start,
  * where start and size are "size[KkMm]"
  */
-static void __init early_mem(char **p)
+static int __init early_mem(char *p)
 {
 	static int usermem __initdata = 0;
 	unsigned long size, start;
+	char *endp;
 
 	/*
 	 * If the user specifies memory size, we
@@ -433,52 +434,15 @@ static void __init early_mem(char **p)
 	}
 
 	start = PHYS_OFFSET;
-	size  = memparse(*p, p);
-	if (**p == '@')
-		start = memparse(*p + 1, p);
+	size  = memparse(p, &endp);
+	if (*endp == '@')
+		start = memparse(endp + 1, NULL);
 
 	arm_add_memory(start, size);
-}
-__early_param("mem=", early_mem);
 
-/*
- * Initial parsing of the command line.
- */
-static void __init parse_cmdline(char **cmdline_p, char *from)
-{
-	char c = ' ', *to = cmd_line;
-	int len = 0;
-
-	for (;;) {
-		if (c == ' ') {
-			extern struct early_params __early_begin, __early_end;
-			struct early_params *p;
-
-			for (p = &__early_begin; p < &__early_end; p++) {
-				int arglen = strlen(p->arg);
-
-				if (memcmp(from, p->arg, arglen) == 0) {
-					if (to != cmd_line)
-						to -= 1;
-					from += arglen;
-					p->fn(&from);
-
-					while (*from != ' ' && *from != '\0')
-						from++;
-					break;
-				}
-			}
-		}
-		c = *from++;
-		if (!c)
-			break;
-		if (COMMAND_LINE_SIZE <= ++len)
-			break;
-		*to++ = c;
-	}
-	*to = '\0';
-	*cmdline_p = cmd_line;
+	return 0;
 }
+early_param("mem", early_mem);
 
 static void __init
 setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
@@ -739,9 +703,15 @@ void __init setup_arch(char **cmdline_p)
 	init_mm.end_data   = (unsigned long) _edata;
 	init_mm.brk	   = (unsigned long) _end;
 
-	memcpy(boot_command_line, from, COMMAND_LINE_SIZE);
-	boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
-	parse_cmdline(cmdline_p, from);
+	/* 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);
+	*cmdline_p = cmd_line;
+
+	parse_early_param();
+
 	paging_init(mdesc);
 	request_standard_resources(&meminfo, mdesc);
 
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index aecf87d..1975c76 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -46,9 +46,6 @@ SECTIONS
 		__setup_start = .;
 			*(.init.setup)
 		__setup_end = .;
-		__early_begin = .;
-			*(.early_param.init)
-		__early_end = .;
 		__initcall_start = .;
 			INITCALLS
 		__initcall_end = .;
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index b97f529..8a4a8d8 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -32,12 +32,13 @@ unsigned int mem_fclk_21285 = 50000000;
 
 EXPORT_SYMBOL(mem_fclk_21285);
 
-static void __init early_fclk(char **arg)
+static int __init early_fclk(char *arg)
 {
-	mem_fclk_21285 = simple_strtoul(*arg, arg, 0);
+	mem_fclk_21285 = simple_strtoul(arg, NULL, 0);
+	return 0;
 }
 
-__early_param("mem_fclk_21285=", early_fclk);
+early_param("mem_fclk_21285", early_fclk);
 
 static int __init parse_tag_memclk(const struct tag *tag)
 {
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 52c40d1..4d3c90f 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -32,19 +32,21 @@
 static unsigned long phys_initrd_start __initdata = 0;
 static unsigned long phys_initrd_size __initdata = 0;
 
-static void __init early_initrd(char **p)
+static int __init early_initrd(char *p)
 {
 	unsigned long start, size;
+	char *endp;
 
-	start = memparse(*p, p);
-	if (**p == ',') {
-		size = memparse((*p) + 1, p);
+	start = memparse(p, &endp);
+	if (*endp == ',') {
+		size = memparse(endp + 1, NULL);
 
 		phys_initrd_start = start;
 		phys_initrd_size = size;
 	}
+	return 0;
 }
-__early_param("initrd=", early_initrd);
+early_param("initrd", early_initrd);
 
 static int __init parse_tag_initrd(const struct tag *tag)
 {
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index ea67be0..7c07a16 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -100,18 +100,17 @@ static struct cachepolicy cache_policies[] __initdata = {
  * writebuffer to be turned off.  (Note: the write
  * buffer should not be on and the cache off).
  */
-static void __init early_cachepolicy(char **p)
+static int __init early_cachepolicy(char *p)
 {
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(cache_policies); i++) {
 		int len = strlen(cache_policies[i].policy);
 
-		if (memcmp(*p, cache_policies[i].policy, len) == 0) {
+		if (memcmp(p, cache_policies[i].policy, len) == 0) {
 			cachepolicy = i;
 			cr_alignment &= ~cache_policies[i].cr_mask;
 			cr_no_alignment &= ~cache_policies[i].cr_mask;
-			*p += len;
 			break;
 		}
 	}
@@ -130,36 +129,37 @@ static void __init early_cachepolicy(char **p)
 	}
 	flush_cache_all();
 	set_cr(cr_alignment);
+	return 0;
 }
-__early_param("cachepolicy=", early_cachepolicy);
+early_param("cachepolicy", early_cachepolicy);
 
-static void __init early_nocache(char **__unused)
+static int __init early_nocache(char *__unused)
 {
 	char *p = "buffered";
 	printk(KERN_WARNING "nocache is deprecated; use cachepolicy=%s\n", p);
-	early_cachepolicy(&p);
+	early_cachepolicy(p);
+	return 0;
 }
-__early_param("nocache", early_nocache);
+early_param("nocache", early_nocache);
 
-static void __init early_nowrite(char **__unused)
+static int __init early_nowrite(char *__unused)
 {
 	char *p = "uncached";
 	printk(KERN_WARNING "nowb is deprecated; use cachepolicy=%s\n", p);
-	early_cachepolicy(&p);
+	early_cachepolicy(p);
+	return 0;
 }
-__early_param("nowb", early_nowrite);
+early_param("nowb", early_nowrite);
 
-static void __init early_ecc(char **p)
+static int __init early_ecc(char *p)
 {
-	if (memcmp(*p, "on", 2) == 0) {
+	if (memcmp(p, "on", 2) == 0)
 		ecc_mask = PMD_PROTECTION;
-		*p += 2;
-	} else if (memcmp(*p, "off", 3) == 0) {
+	else if (memcmp(p, "off", 3) == 0)
 		ecc_mask = 0;
-		*p += 3;
-	}
+	return 0;
 }
-__early_param("ecc=", early_ecc);
+early_param("ecc", early_ecc);
 
 static int __init noalign_setup(char *__unused)
 {
@@ -671,9 +671,9 @@ static unsigned long __initdata vmalloc_reserve = SZ_128M;
  * bytes. This can be used to increase (or decrease) the vmalloc
  * area - the default is 128m.
  */
-static void __init early_vmalloc(char **arg)
+static int __init early_vmalloc(char *arg)
 {
-	vmalloc_reserve = memparse(*arg, arg);
+	vmalloc_reserve = memparse(arg, NULL);
 
 	if (vmalloc_reserve < SZ_16M) {
 		vmalloc_reserve = SZ_16M;
@@ -688,8 +688,9 @@ static void __init early_vmalloc(char **arg)
 			"vmalloc area is too big, limiting to %luMB\n",
 			vmalloc_reserve >> 20);
 	}
+	return 0;
 }
-__early_param("vmalloc=", early_vmalloc);
+early_param("vmalloc", early_vmalloc);
 
 #define VMALLOC_MIN	(void *)(VMALLOC_END - vmalloc_reserve)
 

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

* [PATCH 00/11] Device-tree support for ARM
@ 2009-12-22 10:54 ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all,

The following series of patches is an early prototype to add device tree
support to the ARM architecture.

If you're not familiar with device trees: a device tree is a data
structure describing the hardware that the kernel is booted on. On boot,
the bootloader can pass a 'device tree blob' to the kernel; the kernel
then parses the blob and extracts data used to initialise the machine.
Think ATAGS with a free-form structure and arbitrary property names and
values.

For cases where we don't want to rely on the bootloader's device tree
blob[1] (maybe we have an updated one with fixes), we can supply our own
device tree, attached to the kernel and passed through a boot wrapper.

Device trees are currently used in the boot process for the powerpc,
sparc and microblaze architectures.

This work is aimed at reducing the effort required to port to a new
board. Some hardware changes to may not require a new kernel at all;
these may be described by a corresponding change to the device
tree.

We'd also hope to see an overall decrease in code required as drivers
can be made generic enough to support a set of compatible devices, with
the differences being represented in the device tree.

At this stage, I've just added a mechanism to probe a platform
(Versatile PB) using a device tree; this is just a proof of concept for
machine probe, the interesting stuff happens when we can add DT support
to drivers that the DT-enabled platforms use. Also todo is the boot
wrapper to enable us to embed an updated DT in a bootable image.

These patches are based on Grant Likely's test-devicetree repo[2], which
is an effort to merge the common device tree code between the powerpc,
sparc and microblaze architectures. I have a git tree[3] of these
patches up too, based on his tree.

The approach I've chosen for a boot interface is to add an ATAG that
points to a device tree blob. If this ATAG is found, we use the
device-tree based discovery. There are a couple of other options, but I
think this is the least-intrusive method of passing the DT to the
kernel, and will continue to work with non-DT bootloaders.

If you'd like to try the code out, I have a page[4] up that has
details of the kernel, a link to DT-enabled qemu sources and a sample
device tree for the versatile machine.

This is only an initial prototype, but I'd appreciate any comments,
feedback or review.

Cheers,


Jeremy

1: http://lkml.org/lkml/2009/5/27/446
2: http://git.secretlab.ca/?p=linux-2.6.git;a=shortlog;h=refs/heads/test-devicetree
3: http://kernel.ubuntu.com/git?p=jk/dt/linux-2.6.git;a=summary
4: https://wiki.ubuntu.com/KernelTeam/ARMDeviceTrees

---
Jeremy Kerr (11):
      arm: change command_line to cmd_line, and export it
      arm: use generic infrastructure for early params
      arm: export arm_add_memory
      arm-dt: Add ATAG_DEVTREE tag
      arm-dt: Add CONFIG_ARM_DEVTREE
      arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
      arm-dt: parse devtree pointer on boot
      arm-dt: parse memory info from DT
      arm-dt: probe for device-tree enabled platforms
      arm-dt: parse initrd from device tree
      arm/versatile: probe via device tree

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

* [PATCH 09/11] arm-dt: probe for device-tree enabled platforms
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Add a probe_dt pointer to struct machine_desc, which can be populated by
platforms that support discovery via device trees.

At setup_arch time, each compiled-in machine_desc with a dt_probe member
will be probed. If the probe function returns 1, we have a match.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/include/asm/mach/arch.h |   10 ++++++++++
 arch/arm/kernel/devtree.c        |   19 ++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index c59842d..b83af35 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -41,6 +41,7 @@ struct machine_desc {
 	void			(*init_irq)(void);
 	struct sys_timer	*timer;		/* system tick timer	*/
 	void			(*init_machine)(void);
+	int			(*probe_dt)(unsigned long root);
 };
 
 /*
@@ -57,4 +58,13 @@ static const struct machine_desc __mach_desc_##_type	\
 #define MACHINE_END				\
 };
 
+#define MACH_TYPE_DT	0xffffffff
+
+#define DT_MACHINE_START(_name, _namestr)		\
+static const struct machine_desc __mach_desc_##_name	\
+ __used							\
+ __attribute__((__section__(".arch.info.init"))) = {	\
+	.nr		= MACH_TYPE_DT,			\
+	.name		= _namestr,
+
 #endif
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index a8496f6..2ff4bd0 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -17,6 +17,7 @@
 
 #include <asm/setup.h>
 #include <asm/page.h>
+#include <asm/mach/arch.h>
 
 struct device_node *of_chosen;
 
@@ -52,5 +53,21 @@ int __init early_init_dt_scan_cpus(unsigned long node, const char *uname,
 
 struct machine_desc * __init parse_devicetree(void *devtree)
 {
-	return NULL;
+	extern struct machine_desc __arch_info_begin, __arch_info_end;
+	struct machine_desc *mdesc;
+	unsigned long dt_root;
+
+	early_init_devtree(devtree);
+
+	dt_root = of_get_flat_dt_root();
+
+	for (mdesc = &__arch_info_begin; mdesc < &__arch_info_end; mdesc++) {
+		if (mdesc->probe_dt && mdesc->probe_dt(dt_root))
+			break;
+	}
+
+	if (mdesc >= &__arch_info_end)
+		return NULL;
+
+	return mdesc;
 }

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

* [PATCH 05/11] arm-dt: Add CONFIG_ARM_DEVTREE
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Add some basic empty infrastructure for DT support on ARM.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/Kconfig            |   13 +++++++++++++
 arch/arm/include/asm/prom.h |   28 ++++++++++++++++++++++++++++
 arch/arm/kernel/setup.c     |   28 ++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1c4119c..2e53d33 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1225,6 +1225,19 @@ endmenu
 
 menu "Boot options"
 
+config OF
+	bool
+	default n
+
+config ARM_DEVTREE
+	bool "Device tree support"
+	default y
+	depends on !DEBUG_LL
+	select OF
+	select OF_FLATTREE
+	help
+	  Support for OpenFirmware-style device trees
+
 # 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..5260d22
--- /dev/null
+++ b/arch/arm/include/asm/prom.h
@@ -0,0 +1,28 @@
+/*
+ *  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
+
+#include <asm/setup.h>
+
+#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	1
+#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
+
+#define of_compat_cmp(s1, s2, l)	strncasecmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
+#define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
+
+/* _ALIGN expects upwards alignment */
+#define _ALIGN(addr, size)		(((addr)+((size)-1))&(~((size)-1)))
+
+extern struct device_node *of_chosen;
+
+#endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 84fd876..e662d17 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -47,6 +47,11 @@
 #include "atags.h"
 #include "tcm.h"
 
+#ifdef CONFIG_ARM_DEVTREE
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#endif
+
 #ifndef MEM_SIZE
 #define MEM_SIZE	(16*1024*1024)
 #endif
@@ -659,6 +664,29 @@ static int __init customize_machine(void)
 }
 arch_initcall(customize_machine);
 
+/* arch-specific device tree handling */
+#ifdef CONFIG_ARM_DEVTREE
+void early_init_dt_scan_chosen_arch(unsigned long node) { }
+
+void early_init_dt_setup_initrd_arch(unsigned long start, unsigned long_end) { }
+
+void early_init_devtree_arch(void) { }
+
+int early_init_dt_scan_memory(unsigned long node, const char *uname,
+			      int depth, void *data)
+{
+	return 0;
+}
+
+int early_init_dt_scan_cpus(unsigned long node, const char *uname,
+			    int depth, void *data)
+{
+	return 0;
+}
+
+struct device_node *of_chosen;
+#endif /* CONFIG_ARM_DEVTREE */
+
 void __init setup_arch(char **cmdline_p)
 {
 	struct tag *tags = (struct tag *)&init_tags;

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

* [PATCH 01/11] arm: change command_line to cmd_line, and export it
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

drivers/of/fdt expects a cmd_line symbol, while arm uses command_line.
Change to the former and make accessible from setup.h, so that we can
share with the fdt code.

This means a change in section from .init.data to .data

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/include/asm/setup.h |    6 ++++--
 arch/arm/kernel/setup.c      |    8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 5ccce0a..1e2ab1b 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -16,8 +16,6 @@
 
 #include <linux/types.h>
 
-#define COMMAND_LINE_SIZE 1024
-
 /* The list ends with an ATAG_NONE node. */
 #define ATAG_NONE	0x00000000
 
@@ -235,6 +233,10 @@ struct early_params {
 static struct early_params __early_##fn __used			\
 __attribute__((__section__(".early_param.init"))) = { name, fn }
 
+#define COMMAND_LINE_SIZE 1024
+
+extern char cmd_line[COMMAND_LINE_SIZE];
+
 #endif  /*  __KERNEL__  */
 
 #endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index c6c57b6..015803a 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -117,7 +117,7 @@ EXPORT_SYMBOL(elf_platform);
 
 static const char *cpu_name;
 static const char *machine_name;
-static char __initdata command_line[COMMAND_LINE_SIZE];
+char cmd_line[COMMAND_LINE_SIZE];
 
 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
@@ -446,7 +446,7 @@ __early_param("mem=", early_mem);
  */
 static void __init parse_cmdline(char **cmdline_p, char *from)
 {
-	char c = ' ', *to = command_line;
+	char c = ' ', *to = cmd_line;
 	int len = 0;
 
 	for (;;) {
@@ -458,7 +458,7 @@ static void __init parse_cmdline(char **cmdline_p, char *from)
 				int arglen = strlen(p->arg);
 
 				if (memcmp(from, p->arg, arglen) == 0) {
-					if (to != command_line)
+					if (to != cmd_line)
 						to -= 1;
 					from += arglen;
 					p->fn(&from);
@@ -477,7 +477,7 @@ static void __init parse_cmdline(char **cmdline_p, char *from)
 		*to++ = c;
 	}
 	*to = '\0';
-	*cmdline_p = command_line;
+	*cmdline_p = cmd_line;
 }
 
 static void __init

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

* [PATCH 03/11] arm: export arm_add_memory
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

We'd like to add memory from the device tree, so make arm_add_memory
non-static and add a prototype in setup.h

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/include/asm/setup.h |    2 ++
 arch/arm/kernel/setup.c      |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 3b6f461..3fa2555 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -225,6 +225,8 @@ extern struct meminfo meminfo;
 
 extern char cmd_line[COMMAND_LINE_SIZE];
 
+extern int arm_add_memory(unsigned long start, unsigned long size);
+
 #endif  /*  __KERNEL__  */
 
 #endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 4206286..84fd876 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -383,7 +383,7 @@ static struct machine_desc * __init setup_machine(unsigned int nr)
 	return list;
 }
 
-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];
 

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

* [PATCH 04/11] arm-dt: Add ATAG_DEVTREE tag
@ 2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

We'd like to provide a pointer to the device tree blob through the atags
mechanism, so add a tag type containing a physical dtb pointer.

We won't need a parser for this, as we'll need to do the devtree parsing
a little earlier than other tags.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/arm/include/asm/setup.h |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 3fa2555..99ba6db 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -141,6 +141,13 @@ struct tag_memclk {
 	__u32 fmemclk;
 };
 
+/* OF device tree blob pointer */
+#define ATAG_DEVTREE	0x5441000a
+
+struct tag_devtree {
+	__u32 devtree;		/* physical address */
+};
+
 struct tag {
 	struct tag_header hdr;
 	union {
@@ -153,6 +160,7 @@ struct tag {
 		struct tag_revision	revision;
 		struct tag_videolfb	videolfb;
 		struct tag_cmdline	cmdline;
+		struct tag_devtree	devtree;
 
 		/*
 		 * Acorn specific

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

* Re: [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
  2009-12-22 10:54   ` Jeremy Kerr
@ 2010-01-04 16:36     ` Ben Dooks
  -1 siblings, 0 replies; 33+ messages in thread
From: Ben Dooks @ 2010-01-04 16:36 UTC (permalink / raw)
  To: Jeremy Kerr; +Cc: devicetree-discuss, linux-arm-kernel

Jeremy Kerr wrote:
> When we're using CONFIG_ARM_DEVTREE, we need to postpone machine detection
> until later in setup_arch. Because ARM_DEVTREE depends on !DEBUG_LL,
> we don't need the mdesc this early anyway.
> 
> We'll add support for ARM_DEVTREE && DEBUG_LL later.

Why not add a specific machine type for 'this is device tree' and
then these routines don't even need to #ifdef. It would especially
be good as it allows dt and non-dt machines to coexist in the same
kernel together.

> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> 
> ---
>  arch/arm/kernel/head.S |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index 38ccbe1..66bb56f 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -82,9 +82,18 @@ ENTRY(stext)
>  	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
>  	movs	r10, r5				@ invalid processor (r5=0)?
>  	beq	__error_p			@ yes, error 'p'
> +
> +	/* If we're using the device tree for machine detection, we don't
> +	 * look for a machinfo here, as we'll dynamically create one in
> +	 * setup_arch(). ARM_DEVTREE depends on !DEBUG_LL, so we won't need
> +	 * any machinfo fields 'til later.
> +	 */
> +#ifndef CONFIG_ARM_DEVTREE
>  	bl	__lookup_machine_type		@ r5=machinfo
>  	movs	r8, r5				@ invalid machine (r5=0)?
>  	beq	__error_a			@ yes, error 'a'
> +#endif
> +
>  	bl	__vet_atags
>  	bl	__create_page_tables
>  
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
@ 2010-01-04 16:36     ` Ben Dooks
  0 siblings, 0 replies; 33+ messages in thread
From: Ben Dooks @ 2010-01-04 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

Jeremy Kerr wrote:
> When we're using CONFIG_ARM_DEVTREE, we need to postpone machine detection
> until later in setup_arch. Because ARM_DEVTREE depends on !DEBUG_LL,
> we don't need the mdesc this early anyway.
> 
> We'll add support for ARM_DEVTREE && DEBUG_LL later.

Why not add a specific machine type for 'this is device tree' and
then these routines don't even need to #ifdef. It would especially
be good as it allows dt and non-dt machines to coexist in the same
kernel together.

> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> 
> ---
>  arch/arm/kernel/head.S |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index 38ccbe1..66bb56f 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -82,9 +82,18 @@ ENTRY(stext)
>  	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
>  	movs	r10, r5				@ invalid processor (r5=0)?
>  	beq	__error_p			@ yes, error 'p'
> +
> +	/* If we're using the device tree for machine detection, we don't
> +	 * look for a machinfo here, as we'll dynamically create one in
> +	 * setup_arch(). ARM_DEVTREE depends on !DEBUG_LL, so we won't need
> +	 * any machinfo fields 'til later.
> +	 */
> +#ifndef CONFIG_ARM_DEVTREE
>  	bl	__lookup_machine_type		@ r5=machinfo
>  	movs	r8, r5				@ invalid machine (r5=0)?
>  	beq	__error_a			@ yes, error 'a'
> +#endif
> +
>  	bl	__vet_atags
>  	bl	__create_page_tables
>  
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
  2010-01-04 16:36     ` Ben Dooks
@ 2010-01-04 22:26         ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2010-01-04 22:26 UTC (permalink / raw)
  To: Ben Dooks
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hi Ben,

> > When we're using CONFIG_ARM_DEVTREE, we need to postpone machine
> > detection until later in setup_arch. Because ARM_DEVTREE depends on
> > !DEBUG_LL, we don't need the mdesc this early anyway.
> >
> > We'll add support for ARM_DEVTREE && DEBUG_LL later.
> 
> Why not add a specific machine type for 'this is device tree' and
> then these routines don't even need to #ifdef. It would especially
> be good as it allows dt and non-dt machines to coexist in the same
> kernel together.

Mainly because this doesn't gain us much; the machine_desc that is discovered 
from this new machine type would not have the correct data (phys_io & 
io_pg_offset) required for early setup (used for DEBUG_LL).

We could conditionally skip the detection if we see a DT machine type, but 
then we'd need to add similar checks for all the paths where the machine_desc 
is used.

However, my goal is indeed to allow DT and non-DT machines to coexist as much 
as possible, this patch is more a temporary workaround while I figure out how 
to handle the DEBUG_LL stuff nicely for DT cases.

Cheers,


Jeremy

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

* [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE
@ 2010-01-04 22:26         ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2010-01-04 22:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ben,

> > When we're using CONFIG_ARM_DEVTREE, we need to postpone machine
> > detection until later in setup_arch. Because ARM_DEVTREE depends on
> > !DEBUG_LL, we don't need the mdesc this early anyway.
> >
> > We'll add support for ARM_DEVTREE && DEBUG_LL later.
> 
> Why not add a specific machine type for 'this is device tree' and
> then these routines don't even need to #ifdef. It would especially
> be good as it allows dt and non-dt machines to coexist in the same
> kernel together.

Mainly because this doesn't gain us much; the machine_desc that is discovered 
from this new machine type would not have the correct data (phys_io & 
io_pg_offset) required for early setup (used for DEBUG_LL).

We could conditionally skip the detection if we see a DT machine type, but 
then we'd need to add similar checks for all the paths where the machine_desc 
is used.

However, my goal is indeed to allow DT and non-DT machines to coexist as much 
as possible, this patch is more a temporary workaround while I figure out how 
to handle the DEBUG_LL stuff nicely for DT cases.

Cheers,


Jeremy

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

* Re: [PATCH 02/11] arm: use generic infrastructure for early params
  2009-12-22 10:54   ` Jeremy Kerr
@ 2010-01-06 16:27     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 33+ messages in thread
From: Russell King - ARM Linux @ 2010-01-06 16:27 UTC (permalink / raw)
  To: Jeremy Kerr; +Cc: devicetree-discuss, linux-arm-kernel

On Tue, Dec 22, 2009 at 06:54:56PM +0800, Jeremy Kerr wrote:
> The ARM setup code includes its own parser for early params, there's
> also one in the generic init code.

This is something which should be separate from the rest of the DT
patch - could we have this as a patch which can be applied to the
current kernel tree please?

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

* [PATCH 02/11] arm: use generic infrastructure for early params
@ 2010-01-06 16:27     ` Russell King - ARM Linux
  0 siblings, 0 replies; 33+ messages in thread
From: Russell King - ARM Linux @ 2010-01-06 16:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 22, 2009 at 06:54:56PM +0800, Jeremy Kerr wrote:
> The ARM setup code includes its own parser for early params, there's
> also one in the generic init code.

This is something which should be separate from the rest of the DT
patch - could we have this as a patch which can be applied to the
current kernel tree please?

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

* Re: [PATCH 02/11] arm: use generic infrastructure for early params
  2010-01-06 16:27     ` Russell King - ARM Linux
@ 2010-01-06 22:31         ` Jeremy Kerr
  -1 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2010-01-06 22:31 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Russell,

> This is something which should be separate from the rest of the DT
> patch - could we have this as a patch which can be applied to the
> current kernel tree please?

Sure, patch coming.

The first three patches of this series (prefixed with arm:, rather than arm-
dt:) are all generic arm patches that don't specifically add device tree 
support, would you like the other two as well?

I'm in the process of rebasing my work onto a merge or your and Grant Likely's 
test-devicetree branch, so future patches should be easier to work with.

Cheers,


Jeremy

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

* [PATCH 02/11] arm: use generic infrastructure for early params
@ 2010-01-06 22:31         ` Jeremy Kerr
  0 siblings, 0 replies; 33+ messages in thread
From: Jeremy Kerr @ 2010-01-06 22:31 UTC (permalink / raw)
  To: linux-arm-kernel

Russell,

> This is something which should be separate from the rest of the DT
> patch - could we have this as a patch which can be applied to the
> current kernel tree please?

Sure, patch coming.

The first three patches of this series (prefixed with arm:, rather than arm-
dt:) are all generic arm patches that don't specifically add device tree 
support, would you like the other two as well?

I'm in the process of rebasing my work onto a merge or your and Grant Likely's 
test-devicetree branch, so future patches should be easier to work with.

Cheers,


Jeremy

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

* Re: [PATCH 02/11] arm: use generic infrastructure for early params
       [not found]           ` <201003060733.57636.rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
@ 2010-03-06 16:01             ` Grant Likely
  0 siblings, 0 replies; 33+ messages in thread
From: Grant Likely @ 2010-03-06 16:01 UTC (permalink / raw)
  To: Rob Landley; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jeremy Kerr

On Sat, Mar 6, 2010 at 6:33 AM, Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org> wrote:
> On Wednesday 06 January 2010 16:31:00 Jeremy Kerr wrote:
>> Russell,
>>
>> > This is something which should be separate from the rest of the DT
>> > patch - could we have this as a patch which can be applied to the
>> > current kernel tree please?
>>
>> Sure, patch coming.
>>
>> The first three patches of this series (prefixed with arm:, rather than
>> arm- dt:) are all generic arm patches that don't specifically add device
>> tree support, would you like the other two as well?
>>
>> I'm in the process of rebasing my work onto a merge or your and Grant
>> Likely's test-devicetree branch, so future patches should be easier to work
>> with.
>>
>> Cheers,
>
> What's the current status on the device tree for arm stuff?
>
> I'm going through some of my todo bookmarks and stumbled across
> http://lwn.net/Articles/367752/ and I'd like to poke at it under qemu.
>
> I've been patching the kernel kconfig stuff to let me plug various different arm
> processors into a versatile board (because it's convinced that you can't
> possibly have an armv6l versatilepb and qemu's -cpu option makes that easy).
> Feeding in a device tree (or better yet teaching qemu to generate one) sounds
> like a better long-term approach...

https://wiki.ubuntu.com/KernelTeam/ARMDeviceTrees

g.

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

end of thread, other threads:[~2010-03-06 16:01 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22 10:54 [PATCH 00/11] Device-tree support for ARM Jeremy Kerr
2009-12-22 10:54 ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 05/11] arm-dt: Add CONFIG_ARM_DEVTREE Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 06/11] arm-dt: postpone machine detection until setup_arch with CONFIG_ARM_DEVTREE Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2010-01-04 16:36   ` Ben Dooks
2010-01-04 16:36     ` Ben Dooks
     [not found]     ` <4B421903.4050200-Y5A6D6n0/KfQXOPxS62xeg@public.gmane.org>
2010-01-04 22:26       ` Jeremy Kerr
2010-01-04 22:26         ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 01/11] arm: change command_line to cmd_line, and export it Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 03/11] arm: export arm_add_memory Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 08/11] arm-dt: parse memory info from DT Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 09/11] arm-dt: probe for device-tree enabled platforms Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 02/11] arm: use generic infrastructure for early params Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2010-01-06 16:27   ` Russell King - ARM Linux
2010-01-06 16:27     ` Russell King - ARM Linux
     [not found]     ` <20100106162731.GB1728-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2010-01-06 22:31       ` Jeremy Kerr
2010-01-06 22:31         ` Jeremy Kerr
     [not found]         ` <201003060733.57636.rob@landley.net>
     [not found]           ` <201003060733.57636.rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2010-03-06 16:01             ` Grant Likely
2009-12-22 10:54 ` [PATCH 04/11] arm-dt: Add ATAG_DEVTREE tag Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 07/11] arm-dt: parse devtree pointer on boot Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 10/11] arm-dt: parse initrd from device tree Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 10:54 ` [PATCH 11/11] arm/versatile: probe via " Jeremy Kerr
2009-12-22 10:54   ` Jeremy Kerr

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.