Skip to contentSkip to conversation

Merge common OpenFirmware device tree code

RFC PATCH In review Grant Likely 22 participants 59 messages Oct 7, 2009 – Oct 16, 2009 15 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Merge common OpenFirmware device tree code

Well, I've got to start somewhere...

So here goes. I've begun the work to merge and clean up the OF device tree handling code and this is my first set of patches. Not fully tested yet, but I'm getting them out to the lists so that I can start responding to comments and collecting acks. This first batch isn't anything exciting, just a merge of common code

---

Grant Likely (12):
of: merge of_find_all_nodes() implementations
of: merge other miscellaneous prototypes
of: merge of_*_flat_dt*() functions
of: merge of_node_get(), of_node_put() and of_find_all_nodes()
of: merge of_read_number() an of_read_ulong()
of: merge of_node_*_flag() and set_node_proc_entry()
of: merge struct boot_param_header from Microblaze and PowerPC
of: add common header for flattened device tree representation
of: Move OF_IS_DYNAMIC and OF_MARK_DYNAMIC macros to of.h
of: merge struct device_node
of: merge phandle, ihandle and struct property
of: Rework linux/of.h and asm/prom.h include ordering

 arch/microblaze/include/asm/prom.h |  135 +--------------------------------
 arch/microblaze/kernel/prom.c      |   23 ------
 arch/powerpc/include/asm/prom.h    |  147 ------------------------------------
 arch/powerpc/kernel/prom.c         |   23 ------
 arch/sparc/include/asm/prom.h      |   55 -------------
 drivers/of/base.c                  |   26 ++++++
 include/linux/of.h                 |  103 +++++++++++++++++++++++++
 include/linux/of_fdt.h             |   87 +++++++++++++++++++++
 8 files changed, 221 insertions(+), 378 deletions(-)
 create mode 100644 include/linux/of_fdt.h
Signature · 1 line
Signature
#1 lore raw

RFC PATCH 1/12 of: Rework linux/of.h and asm/prom.h include ordering

In preparation to prune things out of the Sparc, PowerPC and Microblaze asm/prom.h files, change the #include statements to ensure that even if asm/prom.h is included first, linux/of.h gets to determine the order in which files are processed.

This patch adds a #include <linux/of.h> to each of the prom.h files *above* the multi-include protection macros to ensure that linux/of.h can define things before prom.h gets processed.

At the end of the merge the cross dependencies between the files should be gone and a sane #include scheme can be restored.

---

 arch/microblaze/include/asm/prom.h |    8 ++------
 arch/powerpc/include/asm/prom.h    |    7 +------
 arch/sparc/include/asm/prom.h      |    7 +------
 3 files changed, 4 insertions(+), 18 deletions(-)
arch/microblaze/include/asm/prom.h +2 -6
index 37e6f30..6636889 100644
@@ -12,6 +12,8 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/of.h>	/* linux/of.h gets to determine #include ordering */
+
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__
@@ -305,12 +307,6 @@ extern int of_irq_to_resource(struct device_node *dev, int index,
  */
 extern void __iomem *of_iomap(struct device_node *device, int index);
 
-/*
- * NB: This is here while we transition from using asm/prom.h
- * to linux/of.h
- */
-#include <linux/of.h>
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_PROM_H */
arch/powerpc/include/asm/prom.h +1 -6
index 6ff0418..b0a84ea 100644
@@ -1,3 +1,4 @@
+#include <linux/of.h>	/* linux/of.h gets to determine #include ordering */
 #ifndef _POWERPC_PROM_H
 #define _POWERPC_PROM_H
 #ifdef __KERNEL__
@@ -349,11 +350,5 @@ extern int of_irq_to_resource(struct device_node *dev, int index,
  */
 extern void __iomem *of_iomap(struct device_node *device, int index);
 
-/*
- * NB:  This is here while we transition from using asm/prom.h
- * to linux/of.h
- */
-#include <linux/of.h>
-
 #endif /* __KERNEL__ */
 #endif /* _POWERPC_PROM_H */
arch/sparc/include/asm/prom.h +1 -6
index 82a190d..0733170 100644
@@ -1,3 +1,4 @@
+#include <linux/of.h>	/* linux/of.h gets to determine #include ordering */
 #ifndef _SPARC_PROM_H
 #define _SPARC_PROM_H
 #ifdef __KERNEL__
@@ -108,12 +109,6 @@ static inline void irq_dispose_mapping(unsigned int virq)
 {
 }
 
-/*
- * NB:  This is here while we transition from using asm/prom.h
- * to linux/of.h
- */
-#include <linux/of.h>
-
 extern struct device_node *of_console_device;
 extern char *of_console_path;
 extern char *of_console_options;
#2 lore raw

RFC PATCH 2/12 of: merge phandle, ihandle and struct property

In reply to Grant Likely

Merge of common code duplicated between Sparc, PowerPC and Microblaze

---

 arch/microblaze/include/asm/prom.h |   10 ----------
 arch/powerpc/include/asm/prom.h    |   12 ------------
 arch/sparc/include/asm/prom.h      |   12 ------------
 include/linux/of.h                 |   12 ++++++++++++
 4 files changed, 12 insertions(+), 34 deletions(-)
arch/microblaze/include/asm/prom.h +0 -10
index 6636889..11cb484 100644
@@ -73,16 +73,6 @@ struct boot_param_header {
 	u32	dt_struct_size; /* size of the DT structure block */
 };
 
-typedef u32 phandle;
-typedef u32 ihandle;
-
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-};
-
 struct device_node {
 	const char *name;
 	const char *type;
arch/powerpc/include/asm/prom.h +0 -12
index b0a84ea..c236326 100644
@@ -71,18 +71,6 @@ struct boot_param_header
 	u32	dt_struct_size;		/* size of the DT structure block */
 };
 
-
-
-typedef u32 phandle;
-typedef u32 ihandle;
-
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-};
-
 struct device_node {
 	const char *name;
 	const char *type;
arch/sparc/include/asm/prom.h +0 -12
index 0733170..b34f988 100644
@@ -29,18 +29,6 @@
 #define of_prop_cmp(s1, s2)		strcasecmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcmp((s1), (s2))
 
-typedef u32 phandle;
-typedef u32 ihandle;
-
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-	unsigned long _flags;
-	unsigned int unique_id;
-};
-
 struct of_irq_controller;
 struct device_node {
 	const char	*name;
include/linux/of.h +12 -0
index 7be2d10..4668b29 100644
@@ -19,6 +19,18 @@
 #include <linux/bitops.h>
 #include <linux/mod_devicetable.h>
 
+typedef u32 phandle;
+typedef u32 ihandle;
+
+struct property {
+	char	*name;
+	int	length;
+	void	*value;
+	struct property *next;
+	unsigned long _flags;
+	unsigned int unique_id;
+};
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#3 lore raw

RFC PATCH 2/12 of: merge phandle, ihandle and struct property

In reply to Grant Likely

Merge of common code duplicated between Sparc, PowerPC and Microblaze

---

 arch/microblaze/include/asm/prom.h |   10 ----------
 arch/powerpc/include/asm/prom.h    |   12 ------------
 arch/sparc/include/asm/prom.h      |   12 ------------
 include/linux/of.h                 |   12 ++++++++++++
 4 files changed, 12 insertions(+), 34 deletions(-)
arch/microblaze/include/asm/prom.h +0 -10
index 6636889..11cb484 100644
@@ -73,16 +73,6 @@ struct boot_param_header {
 	u32	dt_struct_size; /* size of the DT structure block */
 };
 
-typedef u32 phandle;
-typedef u32 ihandle;
-
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-};
-
 struct device_node {
 	const char *name;
 	const char *type;
arch/powerpc/include/asm/prom.h +0 -12
index b0a84ea..c236326 100644
@@ -71,18 +71,6 @@ struct boot_param_header
 	u32	dt_struct_size;		/* size of the DT structure block */
 };
 
-
-
-typedef u32 phandle;
-typedef u32 ihandle;
-
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-};
-
 struct device_node {
 	const char *name;
 	const char *type;
arch/sparc/include/asm/prom.h +0 -12
index 0733170..b34f988 100644
@@ -29,18 +29,6 @@
 #define of_prop_cmp(s1, s2)		strcasecmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcmp((s1), (s2))
 
-typedef u32 phandle;
-typedef u32 ihandle;
-
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-	unsigned long _flags;
-	unsigned int unique_id;
-};
-
 struct of_irq_controller;
 struct device_node {
 	const char	*name;
include/linux/of.h +12 -0
index 7be2d10..4668b29 100644
@@ -19,6 +19,18 @@
 #include <linux/bitops.h>
 #include <linux/mod_devicetable.h>
 
+typedef u32 phandle;
+typedef u32 ihandle;
+
+struct property {
+	char	*name;
+	int	length;
+	void	*value;
+	struct property *next;
+	unsigned long _flags;
+	unsigned int unique_id;
+};
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#4 lore raw

RFC PATCH 3/12 of: merge struct device_node

In reply to Grant Likely

Merge of common code duplicated between Sparc, PowerPC and Microblaze

---

 arch/microblaze/include/asm/prom.h |   20 --------------------
 arch/powerpc/include/asm/prom.h    |   20 --------------------
 arch/sparc/include/asm/prom.h      |   24 ------------------------
 include/linux/of.h                 |   32 ++++++++++++++++++++++++++++++++
 4 files changed, 32 insertions(+), 64 deletions(-)
arch/microblaze/include/asm/prom.h +0 -20
index 11cb484..64e8b3a 100644
@@ -73,26 +73,6 @@ struct boot_param_header {
 	u32	dt_struct_size; /* size of the DT structure block */
 };
 
-struct device_node {
-	const char *name;
-	const char *type;
-	phandle	node;
-	phandle linux_phandle;
-	char	*full_name;
-
-	struct	property *properties;
-	struct	property *deadprops; /* removed properties */
-	struct	device_node *parent;
-	struct	device_node *child;
-	struct	device_node *sibling;
-	struct	device_node *next; /* next device of same type */
-	struct	device_node *allnext; /* next in list of all nodes */
-	struct	proc_dir_entry *pde; /* this node's proc directory */
-	struct	kref kref;
-	unsigned long _flags;
-	void	*data;
-};
-
 extern struct device_node *of_chosen;
 
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
arch/powerpc/include/asm/prom.h +0 -20
index c236326..c918db5 100644
@@ -71,26 +71,6 @@ struct boot_param_header
 	u32	dt_struct_size;		/* size of the DT structure block */
 };
 
-struct device_node {
-	const char *name;
-	const char *type;
-	phandle	node;
-	phandle linux_phandle;
-	char	*full_name;
-
-	struct	property *properties;
-	struct  property *deadprops; /* removed properties */
-	struct	device_node *parent;
-	struct	device_node *child;
-	struct	device_node *sibling;
-	struct	device_node *next;	/* next device of same type */
-	struct	device_node *allnext;	/* next in list of all nodes */
-	struct  proc_dir_entry *pde;	/* this node's proc directory */
-	struct  kref kref;
-	unsigned long _flags;
-	void	*data;
-};
-
 extern struct device_node *of_chosen;
 
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
arch/sparc/include/asm/prom.h +0 -24
index b34f988..e5f4a1d 100644
@@ -29,30 +29,6 @@
 #define of_prop_cmp(s1, s2)		strcasecmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcmp((s1), (s2))
 
-struct of_irq_controller;
-struct device_node {
-	const char	*name;
-	const char	*type;
-	phandle	node;
-	char	*path_component_name;
-	char	*full_name;
-
-	struct	property *properties;
-	struct  property *deadprops; /* removed properties */
-	struct	device_node *parent;
-	struct	device_node *child;
-	struct	device_node *sibling;
-	struct	device_node *next;	/* next device of same type */
-	struct	device_node *allnext;	/* next in list of all nodes */
-	struct  proc_dir_entry *pde;	/* this node's proc directory */
-	struct  kref kref;
-	unsigned long _flags;
-	void	*data;
-	unsigned int unique_id;
-
-	struct of_irq_controller *irq_trans;
-};
-
 struct of_irq_controller {
 	unsigned int	(*irq_build)(struct device_node *, unsigned int, void *);
 	void		*data;
include/linux/of.h +32 -0
index 4668b29..65a158d 100644
@@ -17,6 +17,7 @@
  */
 #include <linux/types.h>
 #include <linux/bitops.h>
+#include <linux/kref.h>
 #include <linux/mod_devicetable.h>
 
 typedef u32 phandle;
@@ -31,6 +32,37 @@ struct property {
 	unsigned int unique_id;
 };
 
+#if defined(CONFIG_SPARC)
+struct of_irq_controller;
+#endif
+
+struct device_node {
+	const char *name;
+	const char *type;
+	phandle	node;
+#if !defined(CONFIG_SPARC)
+	phandle linux_phandle;
+#endif
+	char	*full_name;
+
+	struct	property *properties;
+	struct	property *deadprops;	/* removed properties */
+	struct	device_node *parent;
+	struct	device_node *child;
+	struct	device_node *sibling;
+	struct	device_node *next;	/* next device of same type */
+	struct	device_node *allnext;	/* next in list of all nodes */
+	struct	proc_dir_entry *pde;	/* this node's proc directory */
+	struct	kref kref;
+	unsigned long _flags;
+	void	*data;
+#if defined(CONFIG_SPARC)
+	char	*path_component_name;
+	unsigned int unique_id;
+	struct of_irq_controller *irq_trans;
+#endif
+};
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#5 lore raw

RFC PATCH 4/12 of: Move OF_IS_DYNAMIC and OF_MARK_DYNAMIC macros to of.h

In reply to Grant Likely

Merge of common code duplicated between Sparc, PowerPC and Microblaze

---

 arch/sparc/include/asm/prom.h |    3 ---
 include/linux/of.h            |    3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/sparc/include/asm/prom.h +0 -3
index e5f4a1d..ddbd870 100644
@@ -34,9 +34,6 @@ struct of_irq_controller {
 	void		*data;
 };
 
-#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
-#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
-
 extern struct device_node *of_find_node_by_cpuid(int cpuid);
 extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
 extern struct mutex of_set_property_mutex;
include/linux/of.h +3 -0
index 65a158d..a66c1eb 100644
@@ -69,6 +69,9 @@ struct device_node {
 #define OF_DYNAMIC	1 /* node and properties were allocated via kmalloc */
 #define OF_DETACHED	2 /* node has been detached from the device tree */
 
+#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
+#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
+
 #define OF_BAD_ADDR	((u64)-1)
 
 extern struct device_node *of_find_node_by_name(struct device_node *from,
#6 lore raw

RFC PATCH 4/12 of: Move OF_IS_DYNAMIC and OF_MARK_DYNAMIC macros to of.h

In reply to Grant Likely

Merge of common code duplicated between Sparc, PowerPC and Microblaze

---

 arch/sparc/include/asm/prom.h |    3 ---
 include/linux/of.h            |    3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/sparc/include/asm/prom.h +0 -3
index e5f4a1d..ddbd870 100644
@@ -34,9 +34,6 @@ struct of_irq_controller {
 	void		*data;
 };
 
-#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
-#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
-
 extern struct device_node *of_find_node_by_cpuid(int cpuid);
 extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
 extern struct mutex of_set_property_mutex;
include/linux/of.h +3 -0
index 65a158d..a66c1eb 100644
@@ -69,6 +69,9 @@ struct device_node {
 #define OF_DYNAMIC	1 /* node and properties were allocated via kmalloc */
 #define OF_DETACHED	2 /* node has been detached from the device tree */
 
+#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
+#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
+
 #define OF_BAD_ADDR	((u64)-1)
 
 extern struct device_node *of_find_node_by_name(struct device_node *from,
#7 lore raw

RFC PATCH 5/12 of: add common header for flattened device tree representation

In reply to Grant Likely

Add a common header file for working with the flattened device tree data structure and merge the shared data tags used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 +-----------
 arch/powerpc/include/asm/prom.h    |   12 +-----------
 include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 22 deletions(-)
 create mode 100644 include/linux/of_fdt.h
arch/microblaze/include/asm/prom.h +1 -11
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed /* marker */
-#define OF_DT_BEGIN_NODE	0x1 /* Start of node, full name */
-#define OF_DT_END_NODE		0x2 /* End node */
-#define OF_DT_PROP		0x3 /* Property: name off, size, content */
-#define OF_DT_NOP		0x4 /* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10
-
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
 #include <asm/irq.h>
arch/powerpc/include/asm/prom.h +1 -11
index c918db5..7181f8a 100644
@@ -17,6 +17,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include <linux/types.h>
+#include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
 #include <asm/irq.h>
@@ -29,17 +30,6 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed	/* marker */
-#define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
-#define OF_DT_END_NODE		0x2		/* End node */
-#define OF_DT_PROP		0x3		/* Property: name off, size,
-						 * content */
-#define OF_DT_NOP		0x4		/* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10
-
 /*
  * This is what gets passed to the kernel by prom_init or kexec
  *
include/linux/of_fdt.h new file +30 -0
new file mode 100644
index 0000000..f81d3f8
@@ -0,0 +1,30 @@
+/*
+ * Definitions for working with the Flattened Device Tree data format
+ *
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
+ * Updates for SPARC by David S. Miller
+ * Merged to common code by Grant Likely
+ *
+ * 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.
+ */
+
+#ifndef _LINUX_OF_FDT_H
+#define _LINUX_OF_FDT_H
+
+/* Definitions used by the flattened device tree */
+#define OF_DT_HEADER		0xd00dfeed	/* marker */
+#define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
+#define OF_DT_END_NODE		0x2		/* End node */
+#define OF_DT_PROP		0x3		/* Property: name off, size,
+						 * content */
+#define OF_DT_NOP		0x4		/* nop */
+#define OF_DT_END		0x9
+
+#define OF_DT_VERSION		0x10
+
+#endif /* _LINUX_OF_FDT_H */
#8 lore raw

Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Hi Grant,

Just first obvious thing:

arch/microblaze/include/asm/prom.h line 22

Quoted 12 lines · On Tue, 06 Oct 2009 22:30:59 -0600 Grant Likely…
arch/microblaze/include/asm/prom.h +0 -3
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed /* marker */

This is used in arch/microblaze/kernel/head.S, but you move its definition inside "#ifndef __ASSEMBLY__" below. You should probably replace the include of asm/prom.h in arch/microblaze/kernel/head.S with linux/of_fdt.h (assuming that the comment in there is correct).

Quoted 15 lines
arch/microblaze/include/asm/prom.h +1 -8
-#define OF_DT_BEGIN_NODE	0x1 /* Start of node, full name */
-#define OF_DT_END_NODE		0x2 /* End node */
-#define OF_DT_PROP		0x3 /* Property: name off, size, content */
-#define OF_DT_NOP		0x4 /* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10
-
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
 #include <asm/irq.h>
Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

maintainer
#9 lore raw

Re: [microblaze-uclinux] Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Quoted 5 lines · Stephen Rothwell

Hi Grant,

Just first obvious thing:

On Tue, 06 Oct 2009 22:30:59 -0600 Grant Likely <[email protected]> wrote:

Quoted 16 lines

arch/microblaze/include/asm/prom.h line 22

Quoted 11 lines
arch/microblaze/include/asm/prom.h +0 -3
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed /* marker */

This is used in arch/microblaze/kernel/head.S, but you move its definition inside "#ifndef __ASSEMBLY__" below. You should probably replace the include of asm/prom.h in arch/microblaze/kernel/head.S with linux/of_fdt.h (assuming that the comment in there is correct).

yes, Stephen is right here. I created one patch (in attachment) which fixed it. I tested your patches on Microblaze (noMMU and MMU) and I have no problem with compilation and simple boot-up works for both versions too.

With that my patch: Acked-by: Michal Simek <[email protected]>

Thanks,
Michal

P.S.: I have my provider - it block my emails - that's why the patch is in attachment.

Quoted 17 lines
Quoted 16 lines
arch/microblaze/include/asm/prom.h +1 -8
-#define OF_DT_BEGIN_NODE	0x1 /* Start of node, full name */
-#define OF_DT_END_NODE		0x2 /* End node */
-#define OF_DT_PROP		0x3 /* Property: name off, size, content */
-#define OF_DT_NOP		0x4 /* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10
-
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
 #include <asm/irq.h>
Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
Quoted 1 line

From 73b16cccc544fe8410ec8e8e893aa3357093e985 Mon Sep 17 00:00:00 2001

From: Michal Simek <[email protected]>
Date: Wed, 7 Oct 2009 14:04:01 +0200
Subject: [PATCH] of: microblaze: of_fdt.h is used in asm code.

Microblaze uses OF_DT_HEADER macro to identify DTB.

---
 arch/microblaze/kernel/head.S |    2 +-
 include/linux/of_fdt.h        |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)
arch/microblaze/kernel/head.S +1 -1
index 697ce30..3091619 100644
@@ -31,7 +31,7 @@
 #include <linux/linkage.h>
 #include <asm/thread_info.h>
 #include <asm/page.h>
-#include <asm/prom.h>		/* for OF_DT_HEADER */
+#include <linux/of_fdt.h>		/* for OF_DT_HEADER */
 
 #ifdef CONFIG_MMU
 #include <asm/setup.h> /* COMMAND_LINE_SIZE */
include/linux/of_fdt.h +3 -0
index b41bd18..44fecfa 100644
@@ -30,6 +30,7 @@
 
 #define OF_DT_VERSION		0x10
 
+#ifndef __ASSEMBLY__
 /*
  * This is what gets passed to the kernel by prom_init or kexec
  *
@@ -84,4 +85,6 @@ extern int prom_remove_property(struct device_node *np, struct property *prop);
 extern int prom_update_property(struct device_node *np,
 				struct property *newprop,
 				struct property *oldprop);
+#endif /* __ASSEMBLY__ */
+
 #endif /* _LINUX_OF_FDT_H */
Signature · 1 line
1.5.5.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

Re: [microblaze-uclinux] Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Quoted 25 lines · Michal Simek
Quoted 5 lines · Stephen Rothwell

Hi Grant,

Just first obvious thing:

On Tue, 06 Oct 2009 22:30:59 -0600 Grant Likely <[email protected]> wrote:

Quoted 16 lines

arch/microblaze/include/asm/prom.h line 22

Quoted 11 lines
arch/microblaze/include/asm/prom.h +0 -3
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
  #ifndef _ASM_MICROBLAZE_PROM_H
  #define _ASM_MICROBLAZE_PROM_H
  #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER                0xd00dfeed /* marker */

This is used in arch/microblaze/kernel/head.S, but you move its definition inside "#ifndef __ASSEMBLY__" below.  You should probably replace the include of asm/prom.h in arch/microblaze/kernel/head.S with linux/of_fdt.h (assuming that the comment in there is correct).

Quoted 5 lines

yes, Stephen is right here. I created one patch (in attachment) which fixed it. I tested your patches on Microblaze (noMMU and MMU) and I have no problem with compilation and simple boot-up works for both versions too.

With that my patch: Acked-by: Michal Simek <[email protected]>

Thanks. I'll merge your change with my patch so that bisect isn't broken.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
maintainer
#12 lore raw

Re: [microblaze-uclinux] Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Quoted 23 lines · Grant Likely
Quoted 22 lines · Michal Simek
Quoted 20 lines · Stephen Rothwell

Hi Grant,

Just first obvious thing:

arch/microblaze/include/asm/prom.h line 22

Quoted 11 lines · On Tue, 06 Oct 2009 22:30:59 -0600 Grant Likely <[email protected]>…
arch/microblaze/include/asm/prom.h +0 -3
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER                0xd00dfeed /* marker */

This is used in arch/microblaze/kernel/head.S, but you move its definition inside "#ifndef __ASSEMBLY__" below. You should probably replace the include of asm/prom.h in arch/microblaze/kernel/head.S with linux/of_fdt.h (assuming that the comment in there is correct).

Quoted 7 lines
Quoted 5 lines

yes, Stephen is right here. I created one patch (in attachment) which fixed it. I tested your patches on Microblaze (noMMU and MMU) and I have no problem with compilation and simple boot-up works for both versions too.

With that my patch: Acked-by: Michal Simek <[email protected]>

Thanks. I'll merge your change with my patch so that bisect isn't broken.

if is possible to do it, please do it.

Thanks,
Michal

Quoted 3 lines

g.

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#13 lore raw

Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

In reply to Grant Likely

include/linux/of_fdt.h line 8

Quoted 11 lines · Grant Likely
include/linux/of_fdt.h new file +8 -0
@@ -0,0 +1,30 @@
+/*
+ * Definitions for working with the Flattened Device Tree data format
+ *
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
+ * Updates for SPARC by David S. Miller
+ * Merged to common code by Grant Likely

I think you should prune the above. Make it (c) myself since I wrote the FDT code initially. You can add back (c) of other people as you add more stuff here I suppose.

No big deal tho.

Ben.

Quoted 21 lines
include/linux/of_fdt.h new file +21 -0
+ * 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.
+ */
+
+#ifndef _LINUX_OF_FDT_H
+#define _LINUX_OF_FDT_H
+
+/* Definitions used by the flattened device tree */
+#define OF_DT_HEADER		0xd00dfeed	/* marker */
+#define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
+#define OF_DT_END_NODE		0x2		/* End node */
+#define OF_DT_PROP		0x3		/* Property: name off, size,
+						 * content */
+#define OF_DT_NOP		0x4		/* nop */
+#define OF_DT_END		0x9
+
+#define OF_DT_VERSION		0x10
+
+#endif /* _LINUX_OF_FDT_H */
#14 lore raw

Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Quoted 18 lines · Benjamin Herrenschmidt

include/linux/of_fdt.h line 8

Quoted 11 lines · Grant Likely
include/linux/of_fdt.h new file +8 -0
@@ -0,0 +1,30 @@
+/*
+ * Definitions for working with the Flattened Device Tree data format
+ *
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
+ * Updates for SPARC by David S. Miller
+ * Merged to common code by Grant Likely

I think you should prune the above. Make it (c) myself since I wrote the FDT code initially. You can add back (c) of other people as you add more stuff here I suppose.

Quoted 1 line

No big deal tho.

No problem. What is the exact copyright text that you'd like to see here? I'm not going to guess on other people's copyright notice. :-)

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#15 lore raw

Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

In reply to Grant Likely
Quoted 21 lines · Grant Likely

Add a common header file for working with the flattened device tree data structure and merge the shared data tags used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 +-----------
 arch/powerpc/include/asm/prom.h    |   12 +-----------
 include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 22 deletions(-)
 create mode 100644 include/linux/of_fdt.h
arch/microblaze/include/asm/prom.h +0 -0
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__

arch/microblaze/include/asm/prom.h line 29

Quoted 10 lines
arch/microblaze/include/asm/prom.h +0 -10
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed /* marker */
-#define OF_DT_BEGIN_NODE	0x1 /* Start of node, full name */
-#define OF_DT_END_NODE		0x2 /* End node */
-#define OF_DT_PROP		0x3 /* Property: name off, size, content */
-#define OF_DT_NOP		0x4 /* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10

So, if you're merging all these, I guess the question is do we also want to merge them with scripts/dtc/libfdt/fdt.h, and by extension with the upstream libfdt header file which defines the same things.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#17 lore raw

Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Quoted 29 lines · David Gibson
Quoted 28 lines · Grant Likely

Add a common header file for working with the flattened device tree data structure and merge the shared data tags used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 +----------- arch/powerpc/include/asm/prom.h    |   12 +----------- include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++

 3 files changed, 32 insertions(+), 22 deletions(-)

 create mode 100644 include/linux/of_fdt.h

arch/microblaze/include/asm/prom.h +0 -7
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
  #ifndef _ASM_MICROBLAZE_PROM_H
  #define _ASM_MICROBLAZE_PROM_H
  #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER         0xd00dfeed /* marker */
-#define OF_DT_BEGIN_NODE     0x1 /* Start of node, full name */
-#define OF_DT_END_NODE               0x2 /* End node */
-#define OF_DT_PROP           0x3 /* Property: name off, size, content */
-#define OF_DT_NOP            0x4 /* nop */
Quoted 8 lines

arch/microblaze/include/asm/prom.h line 29

Quoted 3 lines
arch/microblaze/include/asm/prom.h +0 -3
-#define OF_DT_END            0x9
-
-#define OF_DT_VERSION                0x10

So, if you're merging all these, I guess the question is do we also want to merge them with scripts/dtc/libfdt/fdt.h, and by extension with the upstream libfdt header file which defines the same things.

I see your question and raise you another. Where should the merge file live for it to be included both by dtc and kernel code? Or should it just be cloned in the kernel tree?

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

A message that is not in the archive (sent off-list or not yet received): fa686aa40910090007lef3fddbod0c5843abfe33be5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#19 lore raw

Re: [RFC PATCH 05/12] of: add common header for flattened device tree representation

Quoted 40 lines · Grant Likely
Quoted 29 lines · David Gibson
Quoted 28 lines · Grant Likely

Add a common header file for working with the flattened device tree data structure and merge the shared data tags used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 +----------- arch/powerpc/include/asm/prom.h    |   12 +----------- include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++

 3 files changed, 32 insertions(+), 22 deletions(-)

 create mode 100644 include/linux/of_fdt.h

arch/microblaze/include/asm/prom.h +0 -7
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
  #ifndef _ASM_MICROBLAZE_PROM_H
  #define _ASM_MICROBLAZE_PROM_H
  #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER         0xd00dfeed /* marker */
-#define OF_DT_BEGIN_NODE     0x1 /* Start of node, full name */
-#define OF_DT_END_NODE               0x2 /* End node */
-#define OF_DT_PROP           0x3 /* Property: name off, size, content */
-#define OF_DT_NOP            0x4 /* nop */
Quoted 8 lines

arch/microblaze/include/asm/prom.h line 29

Quoted 3 lines
arch/microblaze/include/asm/prom.h +0 -3
-#define OF_DT_END            0x9
-
-#define OF_DT_VERSION                0x10

So, if you're merging all these, I guess the question is do we also want to merge them with scripts/dtc/libfdt/fdt.h, and by extension with the upstream libfdt header file which defines the same things.

Quoted 3 lines

I see your question and raise you another. Where should the merge file live for it to be included both by dtc and kernel code? Or should it just be cloned in the kernel tree?

Yeah, a good question. As I see it there are two options. Number one is just make sure everything relevant that the kernel needs is in the libfdt version, then just have the kernel code reference it from its location in scripts/dtc. Other option is we clone the file in the kernel tree. Requires keeping in sync, in theory at least, but since that file has been pretty static (since it's only supposed to contain passive structures/constants related to the physical flat tree structure - no code or prototypes).

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#20 lore raw

RFC PATCH 5/12 of: add common header for flattened device tree representation

In reply to Grant Likely

Add a common header file for working with the flattened device tree data structure and merge the shared data tags used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 +-----------
 arch/powerpc/include/asm/prom.h    |   12 +-----------
 include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 22 deletions(-)
 create mode 100644 include/linux/of_fdt.h
arch/microblaze/include/asm/prom.h +1 -11
index 64e8b3a..5f461f0 100644
@@ -17,20 +17,10 @@
 #ifndef _ASM_MICROBLAZE_PROM_H
 #define _ASM_MICROBLAZE_PROM_H
 #ifdef __KERNEL__
-
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed /* marker */
-#define OF_DT_BEGIN_NODE	0x1 /* Start of node, full name */
-#define OF_DT_END_NODE		0x2 /* End node */
-#define OF_DT_PROP		0x3 /* Property: name off, size, content */
-#define OF_DT_NOP		0x4 /* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10
-
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
 #include <asm/irq.h>
arch/powerpc/include/asm/prom.h +1 -11
index c918db5..7181f8a 100644
@@ -17,6 +17,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include <linux/types.h>
+#include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
 #include <asm/irq.h>
@@ -29,17 +30,6 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
-/* Definitions used by the flattened device tree */
-#define OF_DT_HEADER		0xd00dfeed	/* marker */
-#define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
-#define OF_DT_END_NODE		0x2		/* End node */
-#define OF_DT_PROP		0x3		/* Property: name off, size,
-						 * content */
-#define OF_DT_NOP		0x4		/* nop */
-#define OF_DT_END		0x9
-
-#define OF_DT_VERSION		0x10
-
 /*
  * This is what gets passed to the kernel by prom_init or kexec
  *
include/linux/of_fdt.h new file +30 -0
new file mode 100644
index 0000000..f81d3f8
@@ -0,0 +1,30 @@
+/*
+ * Definitions for working with the Flattened Device Tree data format
+ *
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
+ * Updates for SPARC by David S. Miller
+ * Merged to common code by Grant Likely
+ *
+ * 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.
+ */
+
+#ifndef _LINUX_OF_FDT_H
+#define _LINUX_OF_FDT_H
+
+/* Definitions used by the flattened device tree */
+#define OF_DT_HEADER		0xd00dfeed	/* marker */
+#define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
+#define OF_DT_END_NODE		0x2		/* End node */
+#define OF_DT_PROP		0x3		/* Property: name off, size,
+						 * content */
+#define OF_DT_NOP		0x4		/* nop */
+#define OF_DT_END		0x9
+
+#define OF_DT_VERSION		0x10
+
+#endif /* _LINUX_OF_FDT_H */
#21 lore raw

RFC PATCH 6/12 of: merge struct boot_param_header from Microblaze and PowerPC

In reply to Grant Likely

Merge common code for working with Flattened Device Tree data structure

---

 arch/microblaze/include/asm/prom.h |   30 ------------------------------
 arch/powerpc/include/asm/prom.h    |   31 -------------------------------
 include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 61 deletions(-)
arch/microblaze/include/asm/prom.h +0 -30
index 5f461f0..dfc4afc 100644
@@ -33,36 +33,6 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
-/*
- * This is what gets passed to the kernel by prom_init or kexec
- *
- * The dt struct contains the device tree structure, full pathes and
- * property contents. The dt strings contain a separate block with just
- * the strings for the property names, and is fully page aligned and
- * self contained in a page, so that it can be kept around by the kernel,
- * each property name appears only once in this page (cheap compression)
- *
- * the mem_rsvmap contains a map of reserved ranges of physical memory,
- * passing it here instead of in the device-tree itself greatly simplifies
- * the job of everybody. It's just a list of u64 pairs (base/size) that
- * ends when size is 0
- */
-struct boot_param_header {
-	u32	magic; /* magic word OF_DT_HEADER */
-	u32	totalsize; /* total size of DT block */
-	u32	off_dt_struct; /* offset to structure */
-	u32	off_dt_strings; /* offset to strings */
-	u32	off_mem_rsvmap; /* offset to memory reserve map */
-	u32	version; /* format version */
-	u32	last_comp_version; /* last compatible version */
-	/* version 2 fields below */
-	u32	boot_cpuid_phys; /* Physical CPU id we're booting on */
-	/* version 3 fields below */
-	u32	dt_strings_size; /* size of the DT strings block */
-	/* version 17 fields below */
-	u32	dt_struct_size; /* size of the DT structure block */
-};
-
 extern struct device_node *of_chosen;
 
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
arch/powerpc/include/asm/prom.h +0 -31
index 7181f8a..ef20e6c 100644
@@ -30,37 +30,6 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
-/*
- * This is what gets passed to the kernel by prom_init or kexec
- *
- * The dt struct contains the device tree structure, full pathes and
- * property contents. The dt strings contain a separate block with just
- * the strings for the property names, and is fully page aligned and
- * self contained in a page, so that it can be kept around by the kernel,
- * each property name appears only once in this page (cheap compression)
- *
- * the mem_rsvmap contains a map of reserved ranges of physical memory,
- * passing it here instead of in the device-tree itself greatly simplifies
- * the job of everybody. It's just a list of u64 pairs (base/size) that
- * ends when size is 0
- */
-struct boot_param_header
-{
-	u32	magic;			/* magic word OF_DT_HEADER */
-	u32	totalsize;		/* total size of DT block */
-	u32	off_dt_struct;		/* offset to structure */
-	u32	off_dt_strings;		/* offset to strings */
-	u32	off_mem_rsvmap;		/* offset to memory reserve map */
-	u32	version;		/* format version */
-	u32	last_comp_version;	/* last compatible version */
-	/* version 2 fields below */
-	u32	boot_cpuid_phys;	/* Physical CPU id we're booting on */
-	/* version 3 fields below */
-	u32	dt_strings_size;	/* size of the DT strings block */
-	/* version 17 fields below */
-	u32	dt_struct_size;		/* size of the DT structure block */
-};
-
 extern struct device_node *of_chosen;
 
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
include/linux/of_fdt.h +30 -0
index f81d3f8..8b87bcb 100644
@@ -27,4 +27,34 @@
 
 #define OF_DT_VERSION		0x10
 
+/*
+ * This is what gets passed to the kernel by prom_init or kexec
+ *
+ * The dt struct contains the device tree structure, full pathes and
+ * property contents. The dt strings contain a separate block with just
+ * the strings for the property names, and is fully page aligned and
+ * self contained in a page, so that it can be kept around by the kernel,
+ * each property name appears only once in this page (cheap compression)
+ *
+ * the mem_rsvmap contains a map of reserved ranges of physical memory,
+ * passing it here instead of in the device-tree itself greatly simplifies
+ * the job of everybody. It's just a list of u64 pairs (base/size) that
+ * ends when size is 0
+ */
+struct boot_param_header {
+	u32	magic;			/* magic word OF_DT_HEADER */
+	u32	totalsize;		/* total size of DT block */
+	u32	off_dt_struct;		/* offset to structure */
+	u32	off_dt_strings;		/* offset to strings */
+	u32	off_mem_rsvmap;		/* offset to memory reserve map */
+	u32	version;		/* format version */
+	u32	last_comp_version;	/* last compatible version */
+	/* version 2 fields below */
+	u32	boot_cpuid_phys;	/* Physical CPU id we're booting on */
+	/* version 3 fields below */
+	u32	dt_strings_size;	/* size of the DT strings block */
+	/* version 17 fields below */
+	u32	dt_struct_size;		/* size of the DT structure block */
+};
+
 #endif /* _LINUX_OF_FDT_H */
#22 lore raw

RFC PATCH 6/12 of: merge struct boot_param_header from Microblaze and PowerPC

In reply to Grant Likely

Merge common code for working with Flattened Device Tree data structure

---

 arch/microblaze/include/asm/prom.h |   30 ------------------------------
 arch/powerpc/include/asm/prom.h    |   31 -------------------------------
 include/linux/of_fdt.h             |   30 ++++++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 61 deletions(-)
arch/microblaze/include/asm/prom.h +0 -30
index 5f461f0..dfc4afc 100644
@@ -33,36 +33,6 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
-/*
- * This is what gets passed to the kernel by prom_init or kexec
- *
- * The dt struct contains the device tree structure, full pathes and
- * property contents. The dt strings contain a separate block with just
- * the strings for the property names, and is fully page aligned and
- * self contained in a page, so that it can be kept around by the kernel,
- * each property name appears only once in this page (cheap compression)
- *
- * the mem_rsvmap contains a map of reserved ranges of physical memory,
- * passing it here instead of in the device-tree itself greatly simplifies
- * the job of everybody. It's just a list of u64 pairs (base/size) that
- * ends when size is 0
- */
-struct boot_param_header {
-	u32	magic; /* magic word OF_DT_HEADER */
-	u32	totalsize; /* total size of DT block */
-	u32	off_dt_struct; /* offset to structure */
-	u32	off_dt_strings; /* offset to strings */
-	u32	off_mem_rsvmap; /* offset to memory reserve map */
-	u32	version; /* format version */
-	u32	last_comp_version; /* last compatible version */
-	/* version 2 fields below */
-	u32	boot_cpuid_phys; /* Physical CPU id we're booting on */
-	/* version 3 fields below */
-	u32	dt_strings_size; /* size of the DT strings block */
-	/* version 17 fields below */
-	u32	dt_struct_size; /* size of the DT structure block */
-};
-
 extern struct device_node *of_chosen;
 
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
arch/powerpc/include/asm/prom.h +0 -31
index 7181f8a..ef20e6c 100644
@@ -30,37 +30,6 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
-/*
- * This is what gets passed to the kernel by prom_init or kexec
- *
- * The dt struct contains the device tree structure, full pathes and
- * property contents. The dt strings contain a separate block with just
- * the strings for the property names, and is fully page aligned and
- * self contained in a page, so that it can be kept around by the kernel,
- * each property name appears only once in this page (cheap compression)
- *
- * the mem_rsvmap contains a map of reserved ranges of physical memory,
- * passing it here instead of in the device-tree itself greatly simplifies
- * the job of everybody. It's just a list of u64 pairs (base/size) that
- * ends when size is 0
- */
-struct boot_param_header
-{
-	u32	magic;			/* magic word OF_DT_HEADER */
-	u32	totalsize;		/* total size of DT block */
-	u32	off_dt_struct;		/* offset to structure */
-	u32	off_dt_strings;		/* offset to strings */
-	u32	off_mem_rsvmap;		/* offset to memory reserve map */
-	u32	version;		/* format version */
-	u32	last_comp_version;	/* last compatible version */
-	/* version 2 fields below */
-	u32	boot_cpuid_phys;	/* Physical CPU id we're booting on */
-	/* version 3 fields below */
-	u32	dt_strings_size;	/* size of the DT strings block */
-	/* version 17 fields below */
-	u32	dt_struct_size;		/* size of the DT structure block */
-};
-
 extern struct device_node *of_chosen;
 
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
include/linux/of_fdt.h +30 -0
index f81d3f8..8b87bcb 100644
@@ -27,4 +27,34 @@
 
 #define OF_DT_VERSION		0x10
 
+/*
+ * This is what gets passed to the kernel by prom_init or kexec
+ *
+ * The dt struct contains the device tree structure, full pathes and
+ * property contents. The dt strings contain a separate block with just
+ * the strings for the property names, and is fully page aligned and
+ * self contained in a page, so that it can be kept around by the kernel,
+ * each property name appears only once in this page (cheap compression)
+ *
+ * the mem_rsvmap contains a map of reserved ranges of physical memory,
+ * passing it here instead of in the device-tree itself greatly simplifies
+ * the job of everybody. It's just a list of u64 pairs (base/size) that
+ * ends when size is 0
+ */
+struct boot_param_header {
+	u32	magic;			/* magic word OF_DT_HEADER */
+	u32	totalsize;		/* total size of DT block */
+	u32	off_dt_struct;		/* offset to structure */
+	u32	off_dt_strings;		/* offset to strings */
+	u32	off_mem_rsvmap;		/* offset to memory reserve map */
+	u32	version;		/* format version */
+	u32	last_comp_version;	/* last compatible version */
+	/* version 2 fields below */
+	u32	boot_cpuid_phys;	/* Physical CPU id we're booting on */
+	/* version 3 fields below */
+	u32	dt_strings_size;	/* size of the DT strings block */
+	/* version 17 fields below */
+	u32	dt_struct_size;		/* size of the DT structure block */
+};
+
 #endif /* _LINUX_OF_FDT_H */
#23 lore raw

RFC PATCH 7/12 of: merge of_node_*_flag() and set_node_proc_entry()

In reply to Grant Likely

Merge common code between PowerPC and Microblaze

---

 arch/microblaze/include/asm/prom.h |   16 ----------------
 arch/powerpc/include/asm/prom.h    |   17 -----------------
 include/linux/of.h                 |   16 ++++++++++++++++
 3 files changed, 16 insertions(+), 33 deletions(-)
arch/microblaze/include/asm/prom.h +0 -16
index dfc4afc..180d844 100644
@@ -35,24 +35,8 @@
 
 extern struct device_node *of_chosen;
 
-static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
-{
-	return test_bit(flag, &n->_flags);
-}
-
-static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
-{
-	set_bit(flag, &n->_flags);
-}
-
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-static inline void set_node_proc_entry(struct device_node *dn,
-					struct proc_dir_entry *de)
-{
-	dn->pde = de;
-}
-
 extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
arch/powerpc/include/asm/prom.h +0 -17
index ef20e6c..2cfd432 100644
@@ -32,25 +32,8 @@
 
 extern struct device_node *of_chosen;
 
-static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
-{
-	return test_bit(flag, &n->_flags);
-}
-
-static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
-{
-	set_bit(flag, &n->_flags);
-}
-
-
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
-{
-	dn->pde = de;
-}
-
-
 extern struct device_node *of_find_all_nodes(struct device_node *prev);
 extern struct device_node *of_node_get(struct device_node *node);
 extern void of_node_put(struct device_node *node);
include/linux/of.h +16 -0
index a66c1eb..d5f6662 100644
@@ -63,6 +63,22 @@ struct device_node {
 #endif
 };
 
+static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
+{
+	return test_bit(flag, &n->_flags);
+}
+
+static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
+{
+	set_bit(flag, &n->_flags);
+}
+
+static inline void
+set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
+{
+	dn->pde = de;
+}
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#24 lore raw

RFC PATCH 7/12 of: merge of_node_*_flag() and set_node_proc_entry()

In reply to Grant Likely

Merge common code between PowerPC and Microblaze

---

 arch/microblaze/include/asm/prom.h |   16 ----------------
 arch/powerpc/include/asm/prom.h    |   17 -----------------
 include/linux/of.h                 |   16 ++++++++++++++++
 3 files changed, 16 insertions(+), 33 deletions(-)
arch/microblaze/include/asm/prom.h +0 -16
index dfc4afc..180d844 100644
@@ -35,24 +35,8 @@
 
 extern struct device_node *of_chosen;
 
-static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
-{
-	return test_bit(flag, &n->_flags);
-}
-
-static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
-{
-	set_bit(flag, &n->_flags);
-}
-
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-static inline void set_node_proc_entry(struct device_node *dn,
-					struct proc_dir_entry *de)
-{
-	dn->pde = de;
-}
-
 extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
arch/powerpc/include/asm/prom.h +0 -17
index ef20e6c..2cfd432 100644
@@ -32,25 +32,8 @@
 
 extern struct device_node *of_chosen;
 
-static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
-{
-	return test_bit(flag, &n->_flags);
-}
-
-static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
-{
-	set_bit(flag, &n->_flags);
-}
-
-
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
-{
-	dn->pde = de;
-}
-
-
 extern struct device_node *of_find_all_nodes(struct device_node *prev);
 extern struct device_node *of_node_get(struct device_node *node);
 extern void of_node_put(struct device_node *node);
include/linux/of.h +16 -0
index a66c1eb..d5f6662 100644
@@ -63,6 +63,22 @@ struct device_node {
 #endif
 };
 
+static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
+{
+	return test_bit(flag, &n->_flags);
+}
+
+static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
+{
+	set_bit(flag, &n->_flags);
+}
+
+static inline void
+set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
+{
+	dn->pde = de;
+}
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#25 lore raw

RFC PATCH 8/12 of: merge of_read_number() an of_read_ulong()

In reply to Grant Likely

Merge common code between Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 ------------
 arch/powerpc/include/asm/prom.h    |   20 --------------------
 include/linux/of.h                 |   23 +++++++++++++++++++++++
 3 files changed, 23 insertions(+), 32 deletions(-)
arch/microblaze/include/asm/prom.h +0 -12
index 180d844..d4f57ff 100644
@@ -82,18 +82,6 @@ extern int release_OF_resource(struct device_node *node, int index);
  * OF address retreival & translation
  */
 
-/* Helper to read a big number; size is in cells (not bytes) */
-static inline u64 of_read_number(const u32 *cell, int size)
-{
-	u64 r = 0;
-	while (size--)
-		r = (r << 32) | *(cell++);
-	return r;
-}
-
-/* Like of_read_number, but we want an unsigned long result */
-#define of_read_ulong(cell, size)	of_read_number(cell, size)
-
 /* Translate an OF address block into a CPU physical address
  */
 extern u64 of_translate_address(struct device_node *np, const u32 *addr);
arch/powerpc/include/asm/prom.h +0 -20
index 2cfd432..d8c0525 100644
@@ -89,26 +89,6 @@ extern int release_OF_resource(struct device_node* node, int index);
  * OF address retreival & translation
  */
 
-
-/* Helper to read a big number; size is in cells (not bytes) */
-static inline u64 of_read_number(const u32 *cell, int size)
-{
-	u64 r = 0;
-	while (size--)
-		r = (r << 32) | *(cell++);
-	return r;
-}
-
-/* Like of_read_number, but we want an unsigned long result */
-#ifdef CONFIG_PPC32
-static inline unsigned long of_read_ulong(const u32 *cell, int size)
-{
-	return cell[size-1];
-}
-#else
-#define of_read_ulong(cell, size)	of_read_number(cell, size)
-#endif
-
 /* Translate an OF address block into a CPU physical address
  */
 extern u64 of_translate_address(struct device_node *np, const u32 *addr);
include/linux/of.h +23 -0
index d5f6662..18e4379 100644
@@ -79,6 +79,29 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
 	dn->pde = de;
 }
 
+/*
+ * OF address retreival & translation
+ */
+
+/* Helper to read a big number; size is in cells (not bytes) */
+static inline u64 of_read_number(const u32 *cell, int size)
+{
+	u64 r = 0;
+	while (size--)
+		r = (r << 32) | *(cell++);
+	return r;
+}
+
+/* Like of_read_number, but we want an unsigned long result */
+#ifdef CONFIG_PPC32
+static inline unsigned long of_read_ulong(const u32 *cell, int size)
+{
+	return cell[size-1];
+}
+#else
+#define of_read_ulong(cell, size)	of_read_number(cell, size)
+#endif
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#26 lore raw

RFC PATCH 8/12 of: merge of_read_number() an of_read_ulong()

In reply to Grant Likely

Merge common code between Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 ------------
 arch/powerpc/include/asm/prom.h    |   20 --------------------
 include/linux/of.h                 |   23 +++++++++++++++++++++++
 3 files changed, 23 insertions(+), 32 deletions(-)
arch/microblaze/include/asm/prom.h +0 -12
index 180d844..d4f57ff 100644
@@ -82,18 +82,6 @@ extern int release_OF_resource(struct device_node *node, int index);
  * OF address retreival & translation
  */
 
-/* Helper to read a big number; size is in cells (not bytes) */
-static inline u64 of_read_number(const u32 *cell, int size)
-{
-	u64 r = 0;
-	while (size--)
-		r = (r << 32) | *(cell++);
-	return r;
-}
-
-/* Like of_read_number, but we want an unsigned long result */
-#define of_read_ulong(cell, size)	of_read_number(cell, size)
-
 /* Translate an OF address block into a CPU physical address
  */
 extern u64 of_translate_address(struct device_node *np, const u32 *addr);
arch/powerpc/include/asm/prom.h +0 -20
index 2cfd432..d8c0525 100644
@@ -89,26 +89,6 @@ extern int release_OF_resource(struct device_node* node, int index);
  * OF address retreival & translation
  */
 
-
-/* Helper to read a big number; size is in cells (not bytes) */
-static inline u64 of_read_number(const u32 *cell, int size)
-{
-	u64 r = 0;
-	while (size--)
-		r = (r << 32) | *(cell++);
-	return r;
-}
-
-/* Like of_read_number, but we want an unsigned long result */
-#ifdef CONFIG_PPC32
-static inline unsigned long of_read_ulong(const u32 *cell, int size)
-{
-	return cell[size-1];
-}
-#else
-#define of_read_ulong(cell, size)	of_read_number(cell, size)
-#endif
-
 /* Translate an OF address block into a CPU physical address
  */
 extern u64 of_translate_address(struct device_node *np, const u32 *addr);
include/linux/of.h +23 -0
index d5f6662..18e4379 100644
@@ -79,6 +79,29 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
 	dn->pde = de;
 }
 
+/*
+ * OF address retreival & translation
+ */
+
+/* Helper to read a big number; size is in cells (not bytes) */
+static inline u64 of_read_number(const u32 *cell, int size)
+{
+	u64 r = 0;
+	while (size--)
+		r = (r << 32) | *(cell++);
+	return r;
+}
+
+/* Like of_read_number, but we want an unsigned long result */
+#ifdef CONFIG_PPC32
+static inline unsigned long of_read_ulong(const u32 *cell, int size)
+{
+	return cell[size-1];
+}
+#else
+#define of_read_ulong(cell, size)	of_read_number(cell, size)
+#endif
+
 #include <asm/prom.h>
 
 /* flag descriptions */
#27 lore raw

RFC PATCH 9/12 of: merge of_node_get(), of_node_put() and of_find_all_nodes()

In reply to Grant Likely

Merge common code between Sparc, PowerPC and Microblaze.

Sparc differs in the implementation at this point, so this patch uses a #ifdef to handle sparc differently for now. The merging of implementations will occur in a later patch

---

 arch/microblaze/include/asm/prom.h |    4 ----
 arch/powerpc/include/asm/prom.h    |    4 ----
 arch/sparc/include/asm/prom.h      |    9 ---------
 include/linux/of.h                 |   16 ++++++++++++++++
 4 files changed, 16 insertions(+), 17 deletions(-)
arch/microblaze/include/asm/prom.h +0 -4
index d4f57ff..c92b4a9 100644
@@ -40,10 +40,6 @@ extern struct device_node *of_chosen;
 extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
-extern struct device_node *of_find_all_nodes(struct device_node *prev);
-extern struct device_node *of_node_get(struct device_node *node);
-extern void of_node_put(struct device_node *node);
-
 /* For scanning the flat device-tree at boot time */
 extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
 					const char *uname, int depth,
arch/powerpc/include/asm/prom.h +0 -4
index d8c0525..622769c 100644
@@ -34,10 +34,6 @@ extern struct device_node *of_chosen;
 
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-extern struct device_node *of_find_all_nodes(struct device_node *prev);
-extern struct device_node *of_node_get(struct device_node *node);
-extern void of_node_put(struct device_node *node);
-
 /* For scanning the flat device-tree at boot time */
 extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
 					    const char *uname, int depth,
arch/sparc/include/asm/prom.h +0 -9
index ddbd870..f845828 100644
@@ -51,15 +51,6 @@ extern void prom_build_devicetree(void);
 extern void of_populate_present_mask(void);
 extern void of_fill_in_cpu_data(void);
 
-/* Dummy ref counting routines - to be implemented later */
-static inline struct device_node *of_node_get(struct device_node *node)
-{
-	return node;
-}
-static inline void of_node_put(struct device_node *node)
-{
-}
-
 /* These routines are here to provide compatibility with how powerpc
  * handles IRQ mapping for OF device nodes.  We precompute and permanently
  * register them in the of_device objects, whereas powerpc computes them
include/linux/of.h +16 -0
index 18e4379..4636bba 100644
@@ -79,6 +79,22 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
 	dn->pde = de;
 }
 
+#if defined(CONFIG_SPARC)
+/* Dummy ref counting routines - to be implemented later */
+static inline struct device_node *of_node_get(struct device_node *node)
+{
+	return node;
+}
+static inline void of_node_put(struct device_node *node)
+{
+}
+
+#else
+extern struct device_node *of_find_all_nodes(struct device_node *prev);
+extern struct device_node *of_node_get(struct device_node *node);
+extern void of_node_put(struct device_node *node);
+#endif
+
 /*
  * OF address retreival & translation
  */
#28 lore raw

RFC PATCH 9/12 of: merge of_node_get(), of_node_put() and of_find_all_nodes()

In reply to Grant Likely

Merge common code between Sparc, PowerPC and Microblaze.

Sparc differs in the implementation at this point, so this patch uses a #ifdef to handle sparc differently for now. The merging of implementations will occur in a later patch

---

 arch/microblaze/include/asm/prom.h |    4 ----
 arch/powerpc/include/asm/prom.h    |    4 ----
 arch/sparc/include/asm/prom.h      |    9 ---------
 include/linux/of.h                 |   16 ++++++++++++++++
 4 files changed, 16 insertions(+), 17 deletions(-)
arch/microblaze/include/asm/prom.h +0 -4
index d4f57ff..c92b4a9 100644
@@ -40,10 +40,6 @@ extern struct device_node *of_chosen;
 extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
-extern struct device_node *of_find_all_nodes(struct device_node *prev);
-extern struct device_node *of_node_get(struct device_node *node);
-extern void of_node_put(struct device_node *node);
-
 /* For scanning the flat device-tree at boot time */
 extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
 					const char *uname, int depth,
arch/powerpc/include/asm/prom.h +0 -4
index d8c0525..622769c 100644
@@ -34,10 +34,6 @@ extern struct device_node *of_chosen;
 
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-extern struct device_node *of_find_all_nodes(struct device_node *prev);
-extern struct device_node *of_node_get(struct device_node *node);
-extern void of_node_put(struct device_node *node);
-
 /* For scanning the flat device-tree at boot time */
 extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
 					    const char *uname, int depth,
arch/sparc/include/asm/prom.h +0 -9
index ddbd870..f845828 100644
@@ -51,15 +51,6 @@ extern void prom_build_devicetree(void);
 extern void of_populate_present_mask(void);
 extern void of_fill_in_cpu_data(void);
 
-/* Dummy ref counting routines - to be implemented later */
-static inline struct device_node *of_node_get(struct device_node *node)
-{
-	return node;
-}
-static inline void of_node_put(struct device_node *node)
-{
-}
-
 /* These routines are here to provide compatibility with how powerpc
  * handles IRQ mapping for OF device nodes.  We precompute and permanently
  * register them in the of_device objects, whereas powerpc computes them
include/linux/of.h +16 -0
index 18e4379..4636bba 100644
@@ -79,6 +79,22 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
 	dn->pde = de;
 }
 
+#if defined(CONFIG_SPARC)
+/* Dummy ref counting routines - to be implemented later */
+static inline struct device_node *of_node_get(struct device_node *node)
+{
+	return node;
+}
+static inline void of_node_put(struct device_node *node)
+{
+}
+
+#else
+extern struct device_node *of_find_all_nodes(struct device_node *prev);
+extern struct device_node *of_node_get(struct device_node *node);
+extern void of_node_put(struct device_node *node);
+#endif
+
 /*
  * OF address retreival & translation
  */
#29 lore raw

RFC PATCH 10/12 of: merge of_*_flat_dt*() functions

In reply to Grant Likely

Merge common flattened device tree code between Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   11 -----------
 arch/powerpc/include/asm/prom.h    |   10 ----------
 include/linux/of_fdt.h             |   14 ++++++++++++++
 3 files changed, 14 insertions(+), 21 deletions(-)
arch/microblaze/include/asm/prom.h +0 -11
index c92b4a9..be4db2a 100644
@@ -40,17 +40,6 @@ extern struct device_node *of_chosen;
 extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
-/* For scanning the flat device-tree at boot time */
-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
-					const char *uname, int depth,
-					void *data),
-				void *data);
-extern void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
-					unsigned long *size);
-extern int __init
-		of_flat_dt_is_compatible(unsigned long node, const char *name);
-extern unsigned long __init of_get_flat_dt_root(void);
-
 /* For updating the device tree at runtime */
 extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
arch/powerpc/include/asm/prom.h +0 -10
index 622769c..c8b5933 100644
@@ -34,16 +34,6 @@ extern struct device_node *of_chosen;
 
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-/* For scanning the flat device-tree at boot time */
-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
-					    const char *uname, int depth,
-					    void *data),
-				  void *data);
-extern void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
-					unsigned long *size);
-extern int __init of_flat_dt_is_compatible(unsigned long node, const char *name);
-extern unsigned long __init of_get_flat_dt_root(void);
-
 /* For updating the device tree at runtime */
 extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
include/linux/of_fdt.h +14 -0
index 8b87bcb..ac31d4f 100644
@@ -16,6 +16,9 @@
 #ifndef _LINUX_OF_FDT_H
 #define _LINUX_OF_FDT_H
 
+#include <linux/types.h>
+#include <linux/init.h>
+
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER		0xd00dfeed	/* marker */
 #define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
@@ -57,4 +60,15 @@ struct boot_param_header {
 	u32	dt_struct_size;		/* size of the DT structure block */
 };
 
+/* For scanning the flat device-tree at boot time */
+extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
+					    const char *uname, int depth,
+					    void *data),
+				  void *data);
+extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name,
+					unsigned long *size);
+extern int __init of_flat_dt_is_compatible(unsigned long node,
+					   const char *name);
+extern unsigned long __init of_get_flat_dt_root(void);
+
 #endif /* _LINUX_OF_FDT_H */
#30 lore raw

Re: [RFC PATCH 10/12] of: merge of_*_flat_dt*() functions

Quoted 1 line · Grant Likely

Merge common flattened device tree code between Microblaze and PowerPC

And I guess another question is do we want to replace these with a libfdt based implementation.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#32 lore raw

Re: [RFC PATCH 10/12] of: merge of_*_flat_dt*() functions

Quoted 5 lines · David Gibson
Quoted 1 line · Grant Likely

Merge common flattened device tree code between Microblaze and PowerPC

And I guess another question is do we want to replace these with a libfdt based implementation.

Perhaps. Let me get things unified and sane first though.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#33 lore raw

RFC PATCH 10/12 of: merge of_*_flat_dt*() functions

In reply to Grant Likely

Merge common flattened device tree code between Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   11 -----------
 arch/powerpc/include/asm/prom.h    |   10 ----------
 include/linux/of_fdt.h             |   14 ++++++++++++++
 3 files changed, 14 insertions(+), 21 deletions(-)
arch/microblaze/include/asm/prom.h +0 -11
index c92b4a9..be4db2a 100644
@@ -40,17 +40,6 @@ extern struct device_node *of_chosen;
 extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
-/* For scanning the flat device-tree at boot time */
-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
-					const char *uname, int depth,
-					void *data),
-				void *data);
-extern void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
-					unsigned long *size);
-extern int __init
-		of_flat_dt_is_compatible(unsigned long node, const char *name);
-extern unsigned long __init of_get_flat_dt_root(void);
-
 /* For updating the device tree at runtime */
 extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
arch/powerpc/include/asm/prom.h +0 -10
index 622769c..c8b5933 100644
@@ -34,16 +34,6 @@ extern struct device_node *of_chosen;
 
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-/* For scanning the flat device-tree at boot time */
-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
-					    const char *uname, int depth,
-					    void *data),
-				  void *data);
-extern void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
-					unsigned long *size);
-extern int __init of_flat_dt_is_compatible(unsigned long node, const char *name);
-extern unsigned long __init of_get_flat_dt_root(void);
-
 /* For updating the device tree at runtime */
 extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
include/linux/of_fdt.h +14 -0
index 8b87bcb..ac31d4f 100644
@@ -16,6 +16,9 @@
 #ifndef _LINUX_OF_FDT_H
 #define _LINUX_OF_FDT_H
 
+#include <linux/types.h>
+#include <linux/init.h>
+
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER		0xd00dfeed	/* marker */
 #define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
@@ -57,4 +60,15 @@ struct boot_param_header {
 	u32	dt_struct_size;		/* size of the DT structure block */
 };
 
+/* For scanning the flat device-tree at boot time */
+extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
+					    const char *uname, int depth,
+					    void *data),
+				  void *data);
+extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name,
+					unsigned long *size);
+extern int __init of_flat_dt_is_compatible(unsigned long node,
+					   const char *name);
+extern unsigned long __init of_get_flat_dt_root(void);
+
 #endif /* _LINUX_OF_FDT_H */
#34 lore raw

RFC PATCH 11/12 of: merge other miscellaneous prototypes

In reply to Grant Likely

Merge common prototypes used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 ------------
 arch/powerpc/include/asm/prom.h    |   14 --------------
 include/linux/of_fdt.h             |   13 +++++++++++++
 3 files changed, 13 insertions(+), 26 deletions(-)
arch/microblaze/include/asm/prom.h +0 -12
index be4db2a..ef3ec1d 100644
@@ -45,19 +45,7 @@ extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
 
 /* Other Prototypes */
-extern void finish_device_tree(void);
-extern void unflatten_device_tree(void);
 extern int early_uartlite_console(void);
-extern void early_init_devtree(void *);
-extern int machine_is_compatible(const char *compat);
-extern void print_properties(struct device_node *node);
-extern int prom_n_intr_cells(struct device_node *np);
-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
-extern int prom_add_property(struct device_node *np, struct property *prop);
-extern int prom_remove_property(struct device_node *np, struct property *prop);
-extern int prom_update_property(struct device_node *np,
-				struct property *newprop,
-				struct property *oldprop);
 
 extern struct resource *request_OF_resource(struct device_node *node,
 				int index, const char *name_postfix);
arch/powerpc/include/asm/prom.h +0 -14
index c8b5933..2ab9cbd 100644
@@ -38,20 +38,6 @@ extern struct device_node *of_chosen;
 extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
 
-/* Other Prototypes */
-extern void finish_device_tree(void);
-extern void unflatten_device_tree(void);
-extern void early_init_devtree(void *);
-extern int machine_is_compatible(const char *compat);
-extern void print_properties(struct device_node *node);
-extern int prom_n_intr_cells(struct device_node* np);
-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
-extern int prom_add_property(struct device_node* np, struct property* prop);
-extern int prom_remove_property(struct device_node *np, struct property *prop);
-extern int prom_update_property(struct device_node *np,
-				struct property *newprop,
-				struct property *oldprop);
-
 #ifdef CONFIG_PPC32
 /*
  * PCI <-> OF matching functions
include/linux/of_fdt.h +13 -0
index ac31d4f..b41bd18 100644
@@ -71,4 +71,17 @@ extern int __init of_flat_dt_is_compatible(unsigned long node,
 					   const char *name);
 extern unsigned long __init of_get_flat_dt_root(void);
 
+/* Other Prototypes */
+extern void finish_device_tree(void);
+extern void unflatten_device_tree(void);
+extern void early_init_devtree(void *);
+extern int machine_is_compatible(const char *compat);
+extern void print_properties(struct device_node *node);
+extern int prom_n_intr_cells(struct device_node* np);
+extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
+extern int prom_add_property(struct device_node* np, struct property* prop);
+extern int prom_remove_property(struct device_node *np, struct property *prop);
+extern int prom_update_property(struct device_node *np,
+				struct property *newprop,
+				struct property *oldprop);
 #endif /* _LINUX_OF_FDT_H */
#35 lore raw

RFC PATCH 11/12 of: merge other miscellaneous prototypes

In reply to Grant Likely

Merge common prototypes used by Microblaze and PowerPC

---

 arch/microblaze/include/asm/prom.h |   12 ------------
 arch/powerpc/include/asm/prom.h    |   14 --------------
 include/linux/of_fdt.h             |   13 +++++++++++++
 3 files changed, 13 insertions(+), 26 deletions(-)
arch/microblaze/include/asm/prom.h +0 -12
index be4db2a..ef3ec1d 100644
@@ -45,19 +45,7 @@ extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
 
 /* Other Prototypes */
-extern void finish_device_tree(void);
-extern void unflatten_device_tree(void);
 extern int early_uartlite_console(void);
-extern void early_init_devtree(void *);
-extern int machine_is_compatible(const char *compat);
-extern void print_properties(struct device_node *node);
-extern int prom_n_intr_cells(struct device_node *np);
-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
-extern int prom_add_property(struct device_node *np, struct property *prop);
-extern int prom_remove_property(struct device_node *np, struct property *prop);
-extern int prom_update_property(struct device_node *np,
-				struct property *newprop,
-				struct property *oldprop);
 
 extern struct resource *request_OF_resource(struct device_node *node,
 				int index, const char *name_postfix);
arch/powerpc/include/asm/prom.h +0 -14
index c8b5933..2ab9cbd 100644
@@ -38,20 +38,6 @@ extern struct device_node *of_chosen;
 extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
 
-/* Other Prototypes */
-extern void finish_device_tree(void);
-extern void unflatten_device_tree(void);
-extern void early_init_devtree(void *);
-extern int machine_is_compatible(const char *compat);
-extern void print_properties(struct device_node *node);
-extern int prom_n_intr_cells(struct device_node* np);
-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
-extern int prom_add_property(struct device_node* np, struct property* prop);
-extern int prom_remove_property(struct device_node *np, struct property *prop);
-extern int prom_update_property(struct device_node *np,
-				struct property *newprop,
-				struct property *oldprop);
-
 #ifdef CONFIG_PPC32
 /*
  * PCI <-> OF matching functions
include/linux/of_fdt.h +13 -0
index ac31d4f..b41bd18 100644
@@ -71,4 +71,17 @@ extern int __init of_flat_dt_is_compatible(unsigned long node,
 					   const char *name);
 extern unsigned long __init of_get_flat_dt_root(void);
 
+/* Other Prototypes */
+extern void finish_device_tree(void);
+extern void unflatten_device_tree(void);
+extern void early_init_devtree(void *);
+extern int machine_is_compatible(const char *compat);
+extern void print_properties(struct device_node *node);
+extern int prom_n_intr_cells(struct device_node* np);
+extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
+extern int prom_add_property(struct device_node* np, struct property* prop);
+extern int prom_remove_property(struct device_node *np, struct property *prop);
+extern int prom_update_property(struct device_node *np,
+				struct property *newprop,
+				struct property *oldprop);
 #endif /* _LINUX_OF_FDT_H */
#36 lore raw

RFC PATCH 12/12 of: merge of_find_all_nodes() implementations

In reply to Grant Likely

Merge common code between Microblaze and PowerPC, and make it available to Sparc

---

 arch/microblaze/kernel/prom.c |   23 -----------------------
 arch/powerpc/kernel/prom.c    |   23 -----------------------
 drivers/of/base.c             |   26 +++++++++++++++++++++++++-
 include/linux/of.h            |    3 ++-
 4 files changed, 27 insertions(+), 48 deletions(-)
arch/microblaze/kernel/prom.c +0 -23
index c005cc6..b817df1 100644
@@ -860,29 +860,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
 /**
- *	of_find_all_nodes - Get next node in global list
- *	@prev:	Previous node or NULL to start iteration
- *		of_node_put() will be called on it
- *
- *	Returns a node pointer with refcount incremented, use
- *	of_node_put() on it when done.
- */
-struct device_node *of_find_all_nodes(struct device_node *prev)
-{
-	struct device_node *np;
-
-	read_lock(&devtree_lock);
-	np = prev ? prev->allnext : allnodes;
-	for (; np != NULL; np = np->allnext)
-		if (of_node_get(np))
-			break;
-	of_node_put(prev);
-	read_unlock(&devtree_lock);
-	return np;
-}
-EXPORT_SYMBOL(of_find_all_nodes);
-
-/**
  *	of_node_get - Increment refcount of a node
  *	@node:	Node to inc refcount, NULL is supported to
  *		simplify writing of callers
arch/powerpc/kernel/prom.c +0 -23
index d4405b9..4ec3008 100644
@@ -1317,29 +1317,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
 }
 
 /**
- *	of_find_all_nodes - Get next node in global list
- *	@prev:	Previous node or NULL to start iteration
- *		of_node_put() will be called on it
- *
- *	Returns a node pointer with refcount incremented, use
- *	of_node_put() on it when done.
- */
-struct device_node *of_find_all_nodes(struct device_node *prev)
-{
-	struct device_node *np;
-
-	read_lock(&devtree_lock);
-	np = prev ? prev->allnext : allnodes;
-	for (; np != 0; np = np->allnext)
-		if (of_node_get(np))
-			break;
-	of_node_put(prev);
-	read_unlock(&devtree_lock);
-	return np;
-}
-EXPORT_SYMBOL(of_find_all_nodes);
-
-/**
  *	of_node_get - Increment refcount of a node
  *	@node:	Node to inc refcount, NULL is supported to
  *		simplify writing of callers
drivers/of/base.c +25 -1
index ddf224d..e6627b2 100644
@@ -9,7 +9,8 @@
  *
  *  Adapted for sparc and sparc64 by David S. Miller davem-fT/PcQaiUtIeIZ0/[email protected]
  *
- *  Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell.
+ *  Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and
+ *  Grant Likely.
  *
  *      This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -82,6 +83,29 @@ struct property *of_find_property(const struct device_node *np,
 }
 EXPORT_SYMBOL(of_find_property);
 
+/**
+ * of_find_all_nodes - Get next node in global list
+ * @prev:	Previous node or NULL to start iteration
+ *		of_node_put() will be called on it
+ *
+ * Returns a node pointer with refcount incremented, use
+ * of_node_put() on it when done.
+ */
+struct device_node *of_find_all_nodes(struct device_node *prev)
+{
+	struct device_node *np;
+
+	read_lock(&devtree_lock);
+	np = prev ? prev->allnext : allnodes;
+	for (; np != NULL; np = np->allnext)
+		if (of_node_get(np))
+			break;
+	of_node_put(prev);
+	read_unlock(&devtree_lock);
+	return np;
+}
+EXPORT_SYMBOL(of_find_all_nodes);
+
 /*
  * Find a property with a given name for a given node
  * and return the value.
include/linux/of.h +2 -1
index 4636bba..e7facd8 100644
@@ -79,6 +79,8 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
 	dn->pde = de;
 }
 
+extern struct device_node *of_find_all_nodes(struct device_node *prev);
+
 #if defined(CONFIG_SPARC)
 /* Dummy ref counting routines - to be implemented later */
 static inline struct device_node *of_node_get(struct device_node *node)
@@ -90,7 +92,6 @@ static inline void of_node_put(struct device_node *node)
 }
 
 #else
-extern struct device_node *of_find_all_nodes(struct device_node *prev);
 extern struct device_node *of_node_get(struct device_node *node);
 extern void of_node_put(struct device_node *node);
 #endif
#37 lore raw

RFC PATCH 12/12 of: merge of_find_all_nodes() implementations

In reply to Grant Likely

Merge common code between Microblaze and PowerPC, and make it available to Sparc

---

 arch/microblaze/kernel/prom.c |   23 -----------------------
 arch/powerpc/kernel/prom.c    |   23 -----------------------
 drivers/of/base.c             |   26 +++++++++++++++++++++++++-
 include/linux/of.h            |    3 ++-
 4 files changed, 27 insertions(+), 48 deletions(-)
arch/microblaze/kernel/prom.c +0 -23
index c005cc6..b817df1 100644
@@ -860,29 +860,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
 /**
- *	of_find_all_nodes - Get next node in global list
- *	@prev:	Previous node or NULL to start iteration
- *		of_node_put() will be called on it
- *
- *	Returns a node pointer with refcount incremented, use
- *	of_node_put() on it when done.
- */
-struct device_node *of_find_all_nodes(struct device_node *prev)
-{
-	struct device_node *np;
-
-	read_lock(&devtree_lock);
-	np = prev ? prev->allnext : allnodes;
-	for (; np != NULL; np = np->allnext)
-		if (of_node_get(np))
-			break;
-	of_node_put(prev);
-	read_unlock(&devtree_lock);
-	return np;
-}
-EXPORT_SYMBOL(of_find_all_nodes);
-
-/**
  *	of_node_get - Increment refcount of a node
  *	@node:	Node to inc refcount, NULL is supported to
  *		simplify writing of callers
arch/powerpc/kernel/prom.c +0 -23
index d4405b9..4ec3008 100644
@@ -1317,29 +1317,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
 }
 
 /**
- *	of_find_all_nodes - Get next node in global list
- *	@prev:	Previous node or NULL to start iteration
- *		of_node_put() will be called on it
- *
- *	Returns a node pointer with refcount incremented, use
- *	of_node_put() on it when done.
- */
-struct device_node *of_find_all_nodes(struct device_node *prev)
-{
-	struct device_node *np;
-
-	read_lock(&devtree_lock);
-	np = prev ? prev->allnext : allnodes;
-	for (; np != 0; np = np->allnext)
-		if (of_node_get(np))
-			break;
-	of_node_put(prev);
-	read_unlock(&devtree_lock);
-	return np;
-}
-EXPORT_SYMBOL(of_find_all_nodes);
-
-/**
  *	of_node_get - Increment refcount of a node
  *	@node:	Node to inc refcount, NULL is supported to
  *		simplify writing of callers
drivers/of/base.c +25 -1
index ddf224d..e6627b2 100644
@@ -9,7 +9,8 @@
  *
  *  Adapted for sparc and sparc64 by David S. Miller [email protected]
  *
- *  Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell.
+ *  Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and
+ *  Grant Likely.
  *
  *      This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -82,6 +83,29 @@ struct property *of_find_property(const struct device_node *np,
 }
 EXPORT_SYMBOL(of_find_property);
 
+/**
+ * of_find_all_nodes - Get next node in global list
+ * @prev:	Previous node or NULL to start iteration
+ *		of_node_put() will be called on it
+ *
+ * Returns a node pointer with refcount incremented, use
+ * of_node_put() on it when done.
+ */
+struct device_node *of_find_all_nodes(struct device_node *prev)
+{
+	struct device_node *np;
+
+	read_lock(&devtree_lock);
+	np = prev ? prev->allnext : allnodes;
+	for (; np != NULL; np = np->allnext)
+		if (of_node_get(np))
+			break;
+	of_node_put(prev);
+	read_unlock(&devtree_lock);
+	return np;
+}
+EXPORT_SYMBOL(of_find_all_nodes);
+
 /*
  * Find a property with a given name for a given node
  * and return the value.
include/linux/of.h +2 -1
index 4636bba..e7facd8 100644
@@ -79,6 +79,8 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
 	dn->pde = de;
 }
 
+extern struct device_node *of_find_all_nodes(struct device_node *prev);
+
 #if defined(CONFIG_SPARC)
 /* Dummy ref counting routines - to be implemented later */
 static inline struct device_node *of_node_get(struct device_node *node)
@@ -90,7 +92,6 @@ static inline void of_node_put(struct device_node *node)
 }
 
 #else
-extern struct device_node *of_find_all_nodes(struct device_node *prev);
 extern struct device_node *of_node_get(struct device_node *node);
 extern void of_node_put(struct device_node *node);
 #endif
#38 lore raw
In reply to Grant Likely
Quoted 7 lines · Grant Likely

Well, I've got to start somewhere...

So here goes.  I've begun the work to merge and clean up the OF device tree handling code and this is my first set of patches.  Not fully tested yet, but I'm getting them out to the lists so that I can start responding to comments and collecting acks.  This first batch isn't anything exciting, just a merge of common code

Shoot.... most of what I wrote got trimmed accidentally. Here's the rest of the text:

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow. Once I've got all the common code merged between Microblaze, PowerPC and Sparc I'll be fix the endian problems and making it easily usable by other architectures like ARM and MIPS. Lots of work to be done.

As for merging this stuff, because the patches cross architecture boundaries, I've been thinking of publishing a new git tree for collecting device tree related changes and getting it added to the linux-next tree list. I'll commit changes to that tree once I get acks from each of the affected arch maintainers. Then, either Linus can pull my tree directly, or I could ask a more senior maintainer to pull into their tree before sending a pull request to Linus. Ben, David and Michal, how does that sound to you? Stephen, would you be willing to add my tree to the linux-next list?

Also, I'd like to take on responsibility for maintaining the cross- architecture device tree code. If there are no objections, I'll write a patch to add a device tree section to MAINTAINERS.

Cheers,
g.

Quoted 27 lines

---

Grant Likely (12):
     of: merge of_find_all_nodes() implementations
     of: merge other miscellaneous prototypes
     of: merge of_*_flat_dt*() functions
     of: merge of_node_get(), of_node_put() and of_find_all_nodes()
     of: merge of_read_number() an of_read_ulong()
     of: merge of_node_*_flag() and set_node_proc_entry()
     of: merge struct boot_param_header from Microblaze and PowerPC
     of: add common header for flattened device tree representation
     of: Move OF_IS_DYNAMIC and OF_MARK_DYNAMIC macros to of.h
     of: merge struct device_node
     of: merge phandle, ihandle and struct property
     of: Rework linux/of.h and asm/prom.h include ordering

 arch/microblaze/include/asm/prom.h |  135 +-------------------------------- arch/microblaze/kernel/prom.c      |   23 ------ arch/powerpc/include/asm/prom.h    |  147 ------------------------------------ arch/powerpc/kernel/prom.c         |   23 ------ arch/sparc/include/asm/prom.h      |   55 ------------- drivers/of/base.c                  |   26 ++++++ include/linux/of.h                 |  103 +++++++++++++++++++++++++ include/linux/of_fdt.h             |   87 +++++++++++++++++++++

 8 files changed, 221 insertions(+), 378 deletions(-)

 create mode 100644 include/linux/of_fdt.h

#39 lore raw
Quoted 7 lines · Grant Likely
Quoted 6 lines · Grant Likely

So here goes.  I've begun the work to merge and clean up the OF device tree handling code and this is my first set of patches.  Not fully tested yet, but I'm getting them out to the lists so that I can start responding to comments and collecting acks.  This first batch isn't anything exciting, just a merge of common code

Good work, for what it's worth, this all looks good to me.

Quoted 5 lines

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow.  Once I've got all the common code merged between Microblaze, PowerPC and Sparc I'll be fix the endian problems and making it easily usable by other architectures like ARM and MIPS.  Lots of work to be done.

On the subject of merging code, I know that the SUN3 code in m68k uses a similar prom interface to the sparc32 code. (and I've also considered unifying that and ... well ... see above) Does anyone know if it has an OpenFirmware interface for it's devices? Is OF on SUN3 even remotely useful? Does Linux on SUN3 even work with modern kernels?

Another issue is that there is at least one driver in the kernel that depends on both PPC and OF to work around the differences in the implementations of OpenFirmware on Sparc and PowerPC. (I submitted a patch for it, but can't remember the driver's name) Whilst the driver's author assures me that the hardware will never go anywhere near Sparc, it can't hurt to drop the dependency on PPC for additional compile testing coverage - and because it's the Right Thing. (and the reduction of cheap hacks like this can't be bad either.)

Other than that, good work, and keep going.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/

A message that is not in the archive (sent off-list or not yet received): 646765f40910062218s19d540f9q14c9086bedd1d9da-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#41 lore raw
Quoted 17 lines · Julian Calaby
Quoted 7 lines · Grant Likely
Quoted 6 lines · Grant Likely

So here goes.  I've begun the work to merge and clean up the OF device tree handling code and this is my first set of patches.  Not fully tested yet, but I'm getting them out to the lists so that I can start responding to comments and collecting acks.  This first batch isn't anything exciting, just a merge of common code

Good work, for what it's worth, this all looks good to me.

Quoted 5 lines

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow.  Once I've got all the common code merged between Microblaze, PowerPC and Sparc I'll be fix the endian problems and making it easily usable by other architectures like ARM and MIPS.  Lots of work to be done.

Quoted 6 lines

On the subject of merging code, I know that the SUN3 code in m68k uses a similar prom interface to the sparc32 code. (and I've also considered unifying that and ... well ... see above) Does anyone know if it has an OpenFirmware interface for it's devices? Is OF on SUN3 even remotely useful? Does Linux on SUN3 even work with modern kernels?

Sun3 doesn't have OF, though I've got some dormant patches to add an OF emulation layer to make it easier to reuse Sparc drivers on
Sun3... Never finished enough to submit, so it probably shouldn't
affect anything you're doing here.

As for recent kernels, I think 2.6.19 was the last sun3 I distributed patches for, so modern might be pushing it...

-- Sam

#42 lore raw
Quoted 2 lines

Sun3 doesn't have OF

When I was first developing Open Boot for the SPARCstation-1, I was also simultaneously trying to do it for a Sun-3 system that was being built at the same time.

It proved to be too much to do both jobs at the same time, especially in light of all the hardware debugging that is part of a new system bringup. So I gave up on Sun 3 and just focused on SS-1.

That particular Sun-3 machine never sold very well, while the SS-1 was very popular. That was Sun's last 680x0 machine.

Personally, I think that continuing to support Sun-3 in Linux is not useful in a practical sense. To the extent that supporting long-obsolete platforms and devices makes the job harder for current systems, it is actually harmful. Portability and generality is good in some theoretical "rightness" sense, but there are practical limits. Code can become so heavily layered that approaching it requires a huge commitment of effort to learn all the artificial layers. Sometimes you have to prune the dead branches so the living ones can get light and air.

Taking this one step further, I don't see any real good reason to continue supporting Sun4 going forward. I got rid of my Sun4 systems long ago because it was just too hard to keep them working - after having used them long after most people had moved on. Dropping Sun3 and Sun4 eliminates all vestiges of the sunmon interface and also allows dropping support for OBP version 1, which only shipped on SS1-class machines - the first machines in the Sun4c subclass.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#44 lore raw
Quoted 1 line · Mitch Bradley

Taking this one step further, I don't see any real good reason to continue supporting Sun4 going forward. I got rid of my Sun4 systems long ago because it was just too hard to keep them working - after having used them long after most people had moved on. Dropping Sun3 and Sun4 eliminates all vestiges of the sunmon interface and also allows dropping support for OBP version 1, which only shipped on SS1-class machines - the first machines in the Sun4c subclass.

Sun4c has also been broken for a long time and sun4d has never worked properly. Is it time to also prune these ?.
That would leave only Sun4m in the 32bit kernel, which still works and has plenty of ongoing user interest.

A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.60.0910072148040.11795-pb599fR3TxWvwYtD5Hs6llaTQe2KTcn/@public.gmane.org

#46 lore raw

From: Chris Newport <[email protected]>
Date: Wed, 7 Oct 2009 21:54:34 +0100 (BST)

Quoted 4 lines

Sun4c has also been broken for a long time and sun4d has never worked properly. Is it time to also prune these ?.
That would leave only Sun4m in the 32bit kernel, which still works and has plenty of ongoing user interest.

Chris don't over-exaggerate the state.

The truth is that the whole sparc32 port is in a state of mild disrepair, and many of the issues apply to all the port rather than just one family of systems. I think someone suitably motivated could get most of the bugs sorted out.

There is no reason to drop support for SS1 machines, we already fully build the software device tree and use all of the generic OF infrastructure in the Linux kernel on those systems. It is not a road block at all for the OF genericization work, if that's what you read into wmb's email.

#47 lore raw
Quoted 12 lines · David Miller
Quoted 4 lines

Sun4c has also been broken for a long time and sun4d has never worked properly. Is it time to also prune these ?.
That would leave only Sun4m in the 32bit kernel, which still works and has plenty of ongoing user interest.

Chris don't over-exaggerate the state.

The truth is that the whole sparc32 port is in a state of mild disrepair, and many of the issues apply to all the port rather than just one family of systems. I think someone suitably motivated could get most of the bugs sorted out.

Quoted 5 lines

There is no reason to drop support for SS1 machines, we already fully build the software device tree and use all of the generic OF infrastructure in the Linux kernel on those systems. It is not a road block at all for the OF genericization work, if that's what you read into wmb's email.

Your call, as you say there is little to be gained other than tidyness.

FWIW my opinions (and ICBW) are based on :-
Sun4c machines have a max of 48 or 64Mb and very few are still working Sun4d has never had SMP support and this is apparantly problematic
due to Cray interlectual property causing a lack of bus documentation. Running these heavy and power hungry lumps UP is a bit silly.

A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.60.0910080155210.12519-pb599fR3TxWvwYtD5Hs6llaTQe2KTcn/@public.gmane.org

#49 lore raw

From: Chris Newport <[email protected]>
Date: Thu, 8 Oct 2009 02:29:25 +0100 (BST)

Quoted 1 line

Sun4d has never had SMP support and

Wrong.

Quoted 2 lines

this is apparantly problematic due to Cray interlectual property
causing a lack of bus documentation.

XBUS documentation is not available, but we fully know how to program the SBUS interrupt controller and whatnot. It's all there in the sun4d interrupt and SMP support and it did work just fine at one point.

Amusingly the SBUS interrupt stuff on sun4d is a very close sibling to the IMAP/ICLR scheme used on sun4u.

A message that is not in the archive (sent off-list or not yet received): 20091007.213915.37481688.davem-fT/PcQaiUtIeIZ0/[email protected]

#51 lore raw
Quoted 10 lines · David Miller

From: Chris Newport <[email protected]>
Date: Thu, 8 Oct 2009 02:29:25 +0100 (BST)

Quoted 1 line

Sun4d has never had SMP support and

Wrong.

Quoted 2 lines

this is apparantly problematic due to Cray interlectual property
causing a lack of bus documentation.

Quoted 8 lines

XBUS documentation is not available, but we fully know how to program the SBUS interrupt controller and whatnot. It's all there in the sun4d interrupt and SMP support and it did work just fine at one point.

Amusingly the SBUS interrupt stuff on sun4d is a very close sibling to the IMAP/ICLR scheme used on sun4u.

The Sun4d SMP support exists, but is broken in 2.6. And the UP support is buggy. At least on my test-setup, the kernel is unable to load userland from scsi-drives.

Dropping the sun4 32-bit SPARC is a bit counterproductive when considering the resent effort to unify sparc64 and sparc arch-branches ?

#52 lore raw
In reply to Sam Creasey
Quoted 8 lines · Sam Creasey
Quoted 6 lines · Julian Calaby

On the subject of merging code, I know that the SUN3 code in m68k uses a similar prom interface to the sparc32 code. (and I've also considered unifying that and ... well ... see above) Does anyone know if it has an OpenFirmware interface for it's devices? Is OF on SUN3 even remotely useful? Does Linux on SUN3 even work with modern kernels?

Quoted 4 lines

Sun3 doesn't have OF, though I've got some dormant patches to add an OF emulation layer to make it easier to reuse Sparc drivers on
Sun3... Never finished enough to submit, so it probably shouldn't
affect anything you're doing here.

I was also looking at using the OF code on m68k, but for a different reason. My goal was to get macio_bus working so we can merge a few of the m68k Mac drivers into the ppc Mac drivers. The simplest way to do that seemed to be supporting OF since macio_dev is a wrapper for of_device. It was also a nice way to build up a table of all the onboard devices in memory. Hopefully it would enable better user-space device detection as well.

I got the framework built against an older kernel, but it wasn't enough to be useful at that point. This set of patches could help quite a bit.

Brad Boyer
[email protected]

A message that is not in the archive (sent off-list or not yet received): fa686aa40910062149p5d7141e4x3ff849fd4d191f38-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#54 lore raw
Quoted 6 lines · On Tuesday 06 October 2009 23:49:04 Grant Likely wrote:

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow. Once I've got all the common code merged between Microblaze, PowerPC and Sparc I'll be fix the endian problems and making it easily usable by other architectures like ARM and MIPS. Lots of work to be done.

Is there any news on getting QEMU to parse a device tree to figure out what hardware to emulate? (I.E. using the device tree code to let qemu provide configurable board emulations instead of hardwiring them in C code?)

Also, what would be involved in getting x86 to (at least have the option to) use the device tree stuff?

Rob

Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
#55 lore raw
Quoted 11 lines · Rob Landley
Quoted 6 lines · On Tuesday 06 October 2009 23:49:04 Grant Likely wrote:

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow.  Once I've got all the common code merged between Microblaze, PowerPC and Sparc I'll be fix the endian problems and making it easily usable by other architectures like ARM and MIPS.  Lots of work to be done.

Is there any news on getting QEMU to parse a device tree to figure out what hardware to emulate?  (I.E. using the device tree code to let qemu provide configurable board emulations instead of hardwiring them in C code?)

Not that I have, but I expect that I will be hacking on QEMU as part of this work.

Quoted 2 lines

Also, what would be involved in getting x86 to (at least have the option to) use the device tree stuff?

It would be very easy once the endian issues are worked out since the device tree is just a data format to be parsed.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

A message that is not in the archive (sent off-list or not yet received): fa686aa40910070702j470785d2ka2621122a8e2f1fd-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#57 lore raw
Quoted 7 lines · Grant Likely
Quoted 6 lines · Rob Landley
Quoted 5 lines · On Tuesday 06 October 2009 23:49:04 Grant Likely wrote:

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow. Once I've got all the common code merged between Microblaze, PowerPC and Sparc I'll be fix the endian problems and making it easily usable by other architectures like ARM and MIPS. Lots of work to be done.

Quoted 6 lines
Quoted 3 lines

Is there any news on getting QEMU to parse a device tree to figure out what hardware to emulate? (I.E. using the device tree code to let qemu provide configurable board emulations instead of hardwiring them in C code?)

Not that I have, but I expect that I will be hacking on QEMU as part of this work.

ok great. Just let us know - we will test it.

Thanks,
Michal

Quoted 9 lines
Quoted 3 lines

Also, what would be involved in getting x86 to (at least have the option to) use the device tree stuff?

It would be very easy once the endian issues are worked out since the device tree is just a data format to be parsed.

g.

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
Acked-by
#58 lore raw
In reply to a message not in the archive

From: Grant Likely <grant.likely-s3s/[email protected]>
Date: Tue, 6 Oct 2009 22:49:04 -0600

Quoted 3 lines

Also, I'd like to take on responsibility for maintaining the cross- architecture device tree code. If there are no objections, I'll write a patch to add a device tree section to MAINTAINERS.

Feel free. And also feel free to add my:

to your patches.

Thanks!

A message that is not in the archive (sent off-list or not yet received): 20091007.002722.168292120.davem-fT/PcQaiUtIeIZ0/[email protected]

#60 lore raw
Quoted 3 lines

-----Original Message-----
From:

devicetree-discuss-bounces+stephen.neuendorffer=xilinx.com-uLR06cmDAlaKREJ1Ck/[email protected] org [mailto:devicetree-

Quoted 1 line

discuss-bounces+stephen.neuendorffer=xilinx.com-uLR06cmDAlY/[email protected]] On

Behalf Of David Miller

Quoted 3 lines

Sent: Wednesday, October 07, 2009 12:27 AM
To: grant.likely-s3s/[email protected]
Cc: [email protected]; devicetree-discuss-uLR06cmDAlY/[email protected];

microblaze-uclinux-rVRm/[email protected];

Quoted 2 lines

[email protected]; linuxppc-dev-uLR06cmDAlY/[email protected]
Subject: Re: [RFC PATCH 00/12] Merge common OpenFirmware device tree

code

Quoted 8 lines

From: Grant Likely <grant.likely-s3s/[email protected]>
Date: Tue, 6 Oct 2009 22:49:04 -0600

Quoted 3 lines

Also, I'd like to take on responsibility for maintaining the cross- architecture device tree code. If there are no objections, I'll write a patch to add a device tree section to MAINTAINERS.

Quoted 6 lines

Feel free. And also feel free to add my:

to your patches.

Thanks for doing this, Grant.... It's definitely needed.

Steve

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

Acked-by
#61 lore raw
In reply to a message not in the archive
Quoted 3 lines

However, I've completely devoted to this work for at least the next two months, so there are plenty more patches to follow. Once I've

\o/ Thanks, Grant! A seperate tree would be great. Patches look good to me:

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#62 lore raw
In reply to Grant Likely
Quoted 5 lines · Mitch Bradley

Taking this one step further, I don't see any real good reason to continue supporting Sun4 going forward. I got rid of my Sun4 systems long ago because it was just too hard to keep them working - after having used them long after most people had moved on.

I've got a few sun4u machines that are going strong. I'd hate to see support "go away" going forward.

I do wish I knew more about the archetecture and kernel development, but alas, my life conspires against me when I try to learn more.

I do know that this release seems to be the latest version that I can cleanly boot without much issue:

Linux wormhole 2.6.25-gentoo-r2 #2 SMP PREEMPT Tue May 6 20:59:30 AKDT 2008 sparc64 sun4u TI UltraSparc II (BlackBird) GNU/Linux

I do try to send bug reports/comments to the various lists, and watch the development. Unfortunately, none of my systems are available for "lab" work, as they're all remotely deployed, so testing of new kernels can really only happen when I have somebody available onsite to remotely powercycle, as the crashes tend to be severe enough that I can't break-to-OBP

But thanks for all the hard work.

Leif

maintainer
#63 lore raw
In reply to Grant Likely

From: Leif Sawyer <[email protected]>
Date: Wed, 7 Oct 2009 14:20:10 -0800

Quoted 9 lines
Quoted 5 lines · Mitch Bradley

Taking this one step further, I don't see any real good reason to continue supporting Sun4 going forward. I got rid of my Sun4 systems long ago because it was just too hard to keep them working - after having used them long after most people had moved on.

I've got a few sun4u machines that are going strong. I'd hate to see support "go away" going forward.

He's talking about 32-bit sparc machines made 15 to 20 years ago, not sun4u boxes like your's.

#64 lore raw
In reply to Grant Likely

The Sun4 generations were (from memory):

sun4 - first generation SPARC, implemented as an FPGA. IIRC, speeds topped out at about 20 MHz. PCI bus.
sun4c - 2nd generation, implemented in CMOS. SS1 and SS2 families. Desktop machines only. Expansion via SBus. 40 to 80 MHz
sun4m - "SuperSPARC" - multiprocessor support. TLB MMU
sun4d - "Sun Dragon". Big iron, intended for high reliability. Based on a bus architecture from Xerox PARC.
sun4u - UltraSPARC - 64-bit

There was also an ECL SPARC that never made it out of the lab.

#65 lore raw
In reply to Grant Likely

Hi Grant,

Quoted 8 lines · On Tue, 06 Oct 2009 22:29:57 -0600 Grant Likely…

Well, I've got to start somewhere...

So here goes. I've begun the work to merge and clean up the OF device tree handling code and this is my first set of patches. Not fully tested yet, but I'm getting them out to the lists so that I can start responding to comments and collecting acks. This first batch isn't anything exciting, just a merge of common code

This all looks OK to me. One thing: I started in this as well some time ago and in my attempt I was hoping to avoid the ARCH ifdefs in linux/of.h by creating asm/of.h and moving the differing bits in there ...

I'll send out the two patches I did just to show what I mean (these are from before microblaze was using the OF stuff).

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

A message that is not in the archive (sent off-list or not yet received): 20091015120007.3780c59b.sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org

#67 lore raw

PATCH 1/2 of: create asm/of.h

This creates asm/of.h for powerpc and sparc and includes it from linux/of.h, it also moves the first trivial stuff there from asm/prom.h

---
 arch/powerpc/include/asm/of.h   |   23 +++++++++++++++++++++++
 arch/powerpc/include/asm/prom.h |    7 -------
 arch/sparc/include/asm/of.h     |   24 ++++++++++++++++++++++++
 arch/sparc/include/asm/prom.h   |    7 -------
 include/linux/of.h              |    1 +
 5 files changed, 48 insertions(+), 14 deletions(-)
 create mode 100644 arch/powerpc/include/asm/of.h
 create mode 100644 arch/sparc/include/asm/of.h
arch/powerpc/include/asm/of.h new file +23 -0
new file mode 100644
index 0000000..1c1089a
@@ -0,0 +1,23 @@
+#ifndef _POWERPC_OF_H
+#define _POWERPC_OF_H
+/*
+ * Definitions for accessing the in memory device tree.
+ *
+ * Extracted from prom.h
+ *	Copyright (C) 1996-2005 Paul Mackerras.
+ *	Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
+ *
+ * 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.
+ */
+
+#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	1
+#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
+
+#define of_compat_cmp(s1, s2, l)	strcasecmp((s1), (s2))
+#define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
+#define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
+
+#endif /* _POWERPC_OF_H */
arch/powerpc/include/asm/prom.h +0 -7
index 6ff0418..07aef9f 100644
@@ -21,13 +21,6 @@
 #include <asm/irq.h>
 #include <asm/atomic.h>
 
-#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	1
-#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
-
-#define of_compat_cmp(s1, s2, l)	strcasecmp((s1), (s2))
-#define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
-#define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
-
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER		0xd00dfeed	/* marker */
 #define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
arch/sparc/include/asm/of.h new file +24 -0
new file mode 100644
index 0000000..57ab8f9
@@ -0,0 +1,24 @@
+#ifndef _SPARC_OF_H
+#define _SPARC_OF_H
+/*
+ * Definitions for accessing the in memory device tree.
+ *
+ * Extracted from prom.h
+ *	Copyright (C) 1996-2005 Paul Mackerras.
+ *	Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
+ *	Updates for SPARC by David S. Miller
+ *
+ * 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.
+ */
+
+#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	2
+#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
+
+#define of_compat_cmp(s1, s2, l)	strncmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2)		strcasecmp((s1), (s2))
+#define of_node_cmp(s1, s2)		strcmp((s1), (s2))
+
+#endif /* _SPARC_OF_H */
arch/sparc/include/asm/prom.h +0 -7
index 82a190d..4b6ec43 100644
@@ -21,13 +21,6 @@
 #include <linux/mutex.h>
 #include <asm/atomic.h>
 
-#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	2
-#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
-
-#define of_compat_cmp(s1, s2, l)	strncmp((s1), (s2), (l))
-#define of_prop_cmp(s1, s2)		strcasecmp((s1), (s2))
-#define of_node_cmp(s1, s2)		strcmp((s1), (s2))
-
 typedef u32 phandle;
 typedef u32 ihandle;
 
include/linux/of.h +1 -0
index 7be2d10..3bfdaec 100644
@@ -19,6 +19,7 @@
 #include <linux/bitops.h>
 #include <linux/mod_devicetable.h>
 
+#include <asm/of.h>
 #include <asm/prom.h>
 
 /* flag descriptions */
Signature · 6 lines
1.6.4.3

-- 
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#68 lore raw

PATCH 2/2 of: move struct property to asm/of.h

Also find all users of struct property and make sure that they include linux/of.h.

---
 arch/powerpc/include/asm/of.h                |    7 +++++++
 arch/powerpc/include/asm/prom.h              |    7 +------
 arch/powerpc/kernel/machine_kexec_64.c       |    1 +
 arch/powerpc/kernel/prom.c                   |    1 +
 arch/powerpc/kernel/prom_parse.c             |    2 ++
 arch/powerpc/platforms/maple/pci.c           |    1 +
 arch/powerpc/platforms/powermac/pci.c        |    1 +
 arch/powerpc/platforms/powermac/pfunc_core.c |    1 +
 arch/powerpc/platforms/pseries/reconfig.c    |    1 +
 arch/powerpc/sysdev/qe_lib/qe.c              |    2 ++
 arch/sparc/include/asm/of.h                  |    9 +++++++++
 arch/sparc/include/asm/prom.h                |    9 +--------
 arch/sparc/kernel/pci_psycho.c               |    1 +
 arch/sparc/kernel/pci_schizo.c               |    1 +
 arch/sparc/kernel/pci_sun4v.c                |    1 +
 arch/sparc/kernel/prom_32.c                  |    1 +
 arch/sparc/kernel/prom_64.c                  |    1 +
 drivers/macintosh/smu.c                      |    1 +
 drivers/sbus/char/openprom.c                 |    2 ++
 fs/openpromfs/inode.c                        |    1 +
 fs/proc/proc_devtree.c                       |    2 ++
 21 files changed, 39 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/of.h +7 -0
index 1c1089a..383f48d 100644
@@ -20,4 +20,11 @@
 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
 
+struct property {
+	char		*name;
+	int		length;
+	void		*value;
+	struct property *next;
+};
+
 #endif /* _POWERPC_OF_H */
arch/powerpc/include/asm/prom.h +1 -6
index 07aef9f..97b24c9 100644
@@ -68,12 +68,7 @@ struct boot_param_header
 typedef u32 phandle;
 typedef u32 ihandle;
 
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-};
+struct property;
 
 struct device_node {
 	const char *name;
arch/powerpc/kernel/machine_kexec_64.c +1 -0
index 040bd1d..8ff5e00 100644
@@ -15,6 +15,7 @@
 #include <linux/thread_info.h>
 #include <linux/init_task.h>
 #include <linux/errno.h>
+#include <linux/of.h>
 
 #include <asm/page.h>
 #include <asm/current.h>
arch/powerpc/kernel/prom.c +1 -0
index d4405b9..c7c2655 100644
@@ -32,6 +32,7 @@
 #include <linux/debugfs.h>
 #include <linux/irq.h>
 #include <linux/lmb.h>
+#include <linux/of.h>
 
 #include <asm/prom.h>
 #include <asm/rtas.h>
arch/powerpc/kernel/prom_parse.c +2 -0
index 8362620..07698d4 100644
@@ -6,6 +6,8 @@
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/etherdevice.h>
+#include <linux/of.h>
+
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 
arch/powerpc/platforms/maple/pci.c +1 -0
index 04296ff..599c192 100644
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/irq.h>
+#include <linux/of.h>
 
 #include <asm/sections.h>
 #include <asm/io.h>
arch/powerpc/platforms/powermac/pci.c +1 -0
index e81403b..ac0ab8d 100644
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/irq.h>
+#include <linux/of.h>
 
 #include <asm/sections.h>
 #include <asm/io.h>
arch/powerpc/platforms/powermac/pfunc_core.c +1 -0
index 96d5ce5..2eb9cde 100644
@@ -11,6 +11,7 @@
 #include <linux/spinlock.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/of.h>
 
 #include <asm/prom.h>
 #include <asm/pmac_pfunc.h>
arch/powerpc/platforms/pseries/reconfig.c +1 -0
index 2e2bbe1..5d089d7 100644
@@ -15,6 +15,7 @@
 #include <linux/kref.h>
 #include <linux/notifier.h>
 #include <linux/proc_fs.h>
+#include <linux/of.h>
 
 #include <asm/prom.h>
 #include <asm/machdep.h>
arch/powerpc/sysdev/qe_lib/qe.c +2 -0
index 464271b..8e690ca 100644
@@ -27,6 +27,8 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/crc32.h>
+#include <linux/of.h>
+
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
arch/sparc/include/asm/of.h +9 -0
index 57ab8f9..7aeb0c2 100644
@@ -21,4 +21,13 @@
 #define of_prop_cmp(s1, s2)		strcasecmp((s1), (s2))
 #define of_node_cmp(s1, s2)		strcmp((s1), (s2))
 
+struct property {
+	char		*name;
+	int		length;
+	void		*value;
+	struct property *next;
+	unsigned long	 _flags;
+	unsigned int	 unique_id;
+};
+
 #endif /* _SPARC_OF_H */
arch/sparc/include/asm/prom.h +1 -8
index 4b6ec43..03266c2 100644
@@ -24,14 +24,7 @@
 typedef u32 phandle;
 typedef u32 ihandle;
 
-struct property {
-	char	*name;
-	int	length;
-	void	*value;
-	struct property *next;
-	unsigned long _flags;
-	unsigned int unique_id;
-};
+struct property;
 
 struct of_irq_controller;
 struct device_node {
arch/sparc/kernel/pci_psycho.c +1 -0
index 142b9d6..d9c8cde 100644
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 
 #include <asm/iommu.h>
arch/sparc/kernel/pci_schizo.c +1 -0
index 2b5cdde..c923817 100644
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 
 #include <asm/iommu.h>
arch/sparc/kernel/pci_sun4v.c +1 -0
index 23c33ff..322dfe0 100644
@@ -13,6 +13,7 @@
 #include <linux/irq.h>
 #include <linux/msi.h>
 #include <linux/log2.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 
 #include <asm/iommu.h>
arch/sparc/kernel/prom_32.c +1 -0
index 0a37e8c..61eafe0 100644
@@ -21,6 +21,7 @@
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/module.h>
+#include <linux/of.h>
 
 #include <asm/prom.h>
 #include <asm/oplib.h>
arch/sparc/kernel/prom_64.c +1 -0
index fb06ac2..f05ebdc 100644
@@ -21,6 +21,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/lmb.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 
 #include <asm/prom.h>
drivers/macintosh/smu.c +1 -0
index 96faa79..743e44a 100644
@@ -36,6 +36,7 @@
 #include <linux/sysdev.h>
 #include <linux/poll.h>
 #include <linux/mutex.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 
drivers/sbus/char/openprom.c +2 -0
index 75ac19b..c67a9ab 100644
@@ -38,6 +38,8 @@
 #include <linux/miscdevice.h>
 #include <linux/init.h>
 #include <linux/fs.h>
+#include <linux/of.h>
+
 #include <asm/oplib.h>
 #include <asm/prom.h>
 #include <asm/system.h>
fs/openpromfs/inode.c +1 -0
index ffcd04f..b308cdf 100644
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/magic.h>
+#include <linux/of.h>
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
fs/proc/proc_devtree.c +2 -0
index 7ba79a5..42121fc 100644
@@ -9,6 +9,8 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/string.h>
+#include <linux/of.h>
+
 #include <asm/prom.h>
 #include <asm/uaccess.h>
 #include "internal.h"
Signature · 6 lines
1.6.4.3

-- 
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#69 lore raw
In reply to Stephen Rothwell
Quoted 12 lines · Stephen Rothwell

Hi Grant,

Quoted 8 lines · On Tue, 06 Oct 2009 22:29:57 -0600 Grant Likely <[email protected]>…

Well, I've got to start somewhere...

So here goes.  I've begun the work to merge and clean up the OF device tree handling code and this is my first set of patches.  Not fully tested yet, but I'm getting them out to the lists so that I can start responding to comments and collecting acks.  This first batch isn't anything exciting, just a merge of common code

Quoted 3 lines

This all looks OK to me.  One thing:  I started in this as well some time ago and in my attempt I was hoping to avoid the ARCH ifdefs in linux/of.h by creating asm/of.h and moving the differing bits in there ...

Thanks Stephen.

At the moment I'm purposefully experimenting with doing arch #ifdefs in the hope that it will lead to obvious places where the code can be generalized even further. I'll see how it looks before I commit down that path though.

In the mean time, I've pushed out the current series with acked-bys added to my git server. I think I'm ready for things to start going into linux-next. Since this is the first time I've asked for a tree to be added to linux-next, please let me know if you see anything troublesome or problematic. Here's the tree:

The following changes since commit 4bdf0bb7d64cf672199519b3d808e2a82f5b59e9:
Grant Likely (1):
powerpc/5200: Update defconfigs

are available in the git repository at:

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

Grant Likely (12):
of: Rework linux/of.h and asm/prom.h include ordering
of: merge phandle, ihandle and struct property
of: merge struct device_node
of: Move OF_IS_DYNAMIC and OF_MARK_DYNAMIC macros to of.h
of: add common header for flattened device tree representation
of: merge struct boot_param_header from Microblaze and PowerPC
of: merge of_node_*_flag() and set_node_proc_entry()
of: merge of_read_number() an of_read_ulong()
of: merge of_node_get(), of_node_put() and of_find_all_nodes()
of: merge of_*_flat_dt*() functions
of: merge other miscellaneous prototypes
of: merge of_find_all_nodes() implementations

 arch/microblaze/include/asm/prom.h |  135 +--------------------------------
 arch/microblaze/kernel/head.S      |    2 +-
 arch/microblaze/kernel/prom.c      |   23 ------
 arch/powerpc/include/asm/prom.h    |  147 +-----------------------------------
 arch/powerpc/kernel/prom.c         |   23 ------
 arch/sparc/include/asm/prom.h      |   55 +-------------
 drivers/of/base.c                  |   26 ++++++-
 include/linux/of.h                 |  103 +++++++++++++++++++++++++
 include/linux/of_fdt.h             |   86 +++++++++++++++++++++
 9 files changed, 221 insertions(+), 379 deletions(-)
 create mode 100644 include/linux/of_fdt.h
Quoted 2 lines

I'll send out the two patches I did just to show what I mean (these are from before microblaze was using the OF stuff).

Got them, thanks.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

A message that is not in the archive (sent off-list or not yet received): fa686aa40910151006k43b07c30q1e43c3b1ae4af561-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#71 lore raw

Hi Grant,

Quoted 10 lines · On Thu, 15 Oct 2009 11:06:15 -0600 Grant Likely…

In the mean time, I've pushed out the current series with acked-bys added to my git server. I think I'm ready for things to start going into linux-next. Since this is the first time I've asked for a tree to be added to linux-next, please let me know if you see anything troublesome or problematic. Here's the tree:

The following changes since commit 4bdf0bb7d64cf672199519b3d808e2a82f5b59e9:
Grant Likely (1):
powerpc/5200: Update defconfigs

Um, that commit is in no tree but yours ...

Quoted 3 lines

are available in the git repository at:

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

I have added this for today, but note that it contains stuff that is not devicetree related. Trees in linux-next should be based on other trees in linux-next (almost always Linus' tree, but any other nonrebasing tree is fine).

Thanks for adding your subsystem tree as a participant of linux-next. As you may know, this is not a judgment of your code. The purpose of linux-next is for integration testing and to lower the impact of conflicts between subsystems in the next merge window.

You will need to ensure that the patches/commits in your tree/series have been:
* submitted under GPL v2 (or later) and include the Contributor's Signed-off-by,
* posted to the relevant mailing list,
* reviewed by you (or another maintainer of your subsystem tree),
* successfully unit tested, and
* destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him to fetch). It is allowed to be rebased if you deem it necessary.

Signature · 15 lines
Cheers,
Stephen Rothwell 
[email protected]

Legal Stuff:
By participating in linux-next, your subsystem tree contributions are
public and will be included in the linux-next trees.  You may be sent
e-mail messages indicating errors or other issues when the
patches/commits from your subsystem tree are merged and tested in
linux-next.  These messages may also be cross-posted to the linux-next
mailing list, the linux-kernel mailing list, etc.  The linux-next tree
project and IBM (my employer) make no warranties regarding the linux-next
project, the testing procedures, the results, the e-mails, etc.  If you
don't agree to these ground rules, let me know and I'll remove your tree
from participation in linux-next.

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

A message that is not in the archive (sent off-list or not yet received): 20091016103829.323c89d7.sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org

#73 lore raw
Quoted 10 lines · Stephen Rothwell

Hi Grant,

Quoted 7 lines · On Thu, 15 Oct 2009 11:06:15 -0600 Grant Likely <[email protected]>…

In the mean time, I've pushed out the current series with acked-bys added to my git server.  I think I'm ready for things to start going into linux-next.  Since this is the first time I've asked for a tree to be added to linux-next, please let me know if you see anything troublesome or problematic.  Here's the tree:

Quoted 5 lines
Quoted 3 lines

The following changes since commit 4bdf0bb7d64cf672199519b3d808e2a82f5b59e9:
  Grant Likely (1):
        powerpc/5200: Update defconfigs

Um, that commit is in no tree but yours ...

It should be in Ben's merge tree shortly, and Linus' shortly after that, but yeah that was lazy. It was the tree that I tested my commits on, and I should have either rebased or waited until it actually hit mainline. I just wanted to get the ball rolling before heading out the door for Japan.

Quoted 8 lines
Quoted 3 lines

are available in the git repository at:

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

I have added this for today, but note that it contains stuff that is not devicetree related.  Trees in linux-next should be based on other trees in linux-next (almost always Linus' tree, but any other nonrebasing tree is fine).

Thanks.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.