Skip to contentSkip to conversation

x86: OLPC: add OLPC device-tree support (v4)

PATCH In review Andres Salomon 1 participant 3 messages Nov 12, 2010 – Dec 16, 2010

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

PATCH 2/3 x86: OLPC: add OLPC device-tree support (v4)

Make use of PROC_DEVICETREE to export the tree, and sparc's PROMTREE code to call into OLPC's Open Firmware to build the tree.

v4: address some minor style issues pointed out by Grant, and explicitly cast
negative phandle checks to s32.

v3: rename olpc_prom to olpc_dt
- rework Kconfig entries
- drop devtree build hook from proc, instead adding a call to x86's paging_init (similarly to how sparc64 does it)
- switch allocation from using slab to alloc_bootmem. this allows the DT to be built earlier during boot (during setup_arch); the downside is that there are some 1200 bootmem reservations that are done during boot. Not ideal..
- add a helper olpc_ofw_is_installed function to test for the existence and successful detection of OLPC's OFW.

---
 arch/x86/Kconfig                  |    6 ++
 arch/x86/include/asm/olpc_ofw.h   |    9 ++
 arch/x86/include/asm/prom.h       |    1 +
 arch/x86/mm/init_32.c             |    2 +
 arch/x86/platform/olpc/Makefile   |    1 +
 arch/x86/platform/olpc/olpc_dt.c  |  165 +++++++++++++++++++++++++++++++++++++
 arch/x86/platform/olpc/olpc_ofw.c |    5 +
 7 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/prom.h
 create mode 100644 arch/x86/platform/olpc/olpc_dt.c
arch/x86/Kconfig +6 -0
index e832768..d8d6c76 100644
@@ -2049,11 +2049,17 @@ config OLPC_OPENFIRMWARE
 	bool "Support for OLPC's Open Firmware"
 	depends on !X86_64 && !X86_PAE
 	default n
+	select OF
 	help
 	  This option adds support for the implementation of Open Firmware
 	  that is used on the OLPC XO-1 Children's Machine.
 	  If unsure, say N here.
 
+config OLPC_OPENFIRMWARE_DT
+	bool
+	default y if OLPC_OPENFIRMWARE && PROC_DEVICETREE
+	select OF_PROMTREE
+
 endif # X86_32
 
 config AMD_NB
arch/x86/include/asm/olpc_ofw.h +9 -0
index 2a84781..641988e 100644
@@ -8,6 +8,8 @@
 
 #ifdef CONFIG_OLPC_OPENFIRMWARE
 
+extern bool olpc_ofw_is_installed(void);
+
 /* run an OFW command by calling into the firmware */
 #define olpc_ofw(name, args, res) \
 	__olpc_ofw((name), ARRAY_SIZE(args), args, ARRAY_SIZE(res), res)
@@ -26,10 +28,17 @@ extern bool olpc_ofw_present(void);
 
 #else /* !CONFIG_OLPC_OPENFIRMWARE */
 
+static inline bool olpc_ofw_is_installed(void) { return false; }
 static inline void olpc_ofw_detect(void) { }
 static inline void setup_olpc_ofw_pgd(void) { }
 static inline bool olpc_ofw_present(void) { return false; }
 
 #endif /* !CONFIG_OLPC_OPENFIRMWARE */
 
+#ifdef CONFIG_OLPC_OPENFIRMWARE_DT
+extern void olpc_dt_build_devicetree(void);
+#else
+static inline void olpc_dt_build_devicetree(void) { }
+#endif /* CONFIG_OLPC_OPENFIRMWARE_DT */
+
 #endif /* _ASM_X86_OLPC_OFW_H */
arch/x86/include/asm/prom.h new file +1 -0
new file mode 100644
index 0000000..b4ec95f
@@ -0,0 +1 @@
+/* dummy prom.h; here to make linux/of.h's #includes happy */
arch/x86/mm/init_32.c +2 -0
index 0e969f9..8c852e4 100644
@@ -45,6 +45,7 @@
 #include <asm/bugs.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
+#include <asm/olpc_ofw.h>
 #include <asm/pgalloc.h>
 #include <asm/sections.h>
 #include <asm/paravirt.h>
@@ -715,6 +716,7 @@ void __init paging_init(void)
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
 	 */
+	olpc_dt_build_devicetree();
 	sparse_init();
 	zone_sizes_init();
 }
arch/x86/platform/olpc/Makefile +1 -0
index c31b8fc..e797428 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_OLPC)		+= olpc.o
 obj-$(CONFIG_OLPC_XO1)		+= olpc-xo1.o
 obj-$(CONFIG_OLPC_OPENFIRMWARE)	+= olpc_ofw.o
+obj-$(CONFIG_OLPC_OPENFIRMWARE_DT)	+= olpc_dt.o
arch/x86/platform/olpc/olpc_dt.c new file +165 -0

165 lines not on this page · raw message

arch/x86/platform/olpc/olpc_ofw.c +5 -0
index 7873204..e7604f6 100644
@@ -110,3 +110,8 @@ void __init olpc_ofw_detect(void)
 			(unsigned long)olpc_ofw_cif, (-start) >> 20);
 	reserve_top_address(-start);
 }
+
+bool __init olpc_ofw_is_installed(void)
+{
+	return olpc_ofw_cif != NULL;
+}
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 2/3 x86: OLPC: add OLPC device-tree support (v5)

Make use of PROC_DEVICETREE to export the tree, and sparc's PROMTREE code to call into OLPC's Open Firmware to build the tree.

v5: fix buglet with root node check (introduced in v4)

v4: address some minor style issues pointed out by Grant, and explicitly cast
negative phandle checks to s32.

v3: rename olpc_prom to olpc_dt
- rework Kconfig entries
- drop devtree build hook from proc, instead adding a call to x86's paging_init (similarly to how sparc64 does it)
- switch allocation from using slab to alloc_bootmem. this allows the DT to be built earlier during boot (during setup_arch); the downside is that there are some 1200 bootmem reservations that are done during boot. Not ideal..
- add a helper olpc_ofw_is_installed function to test for the existence and successful detection of OLPC's OFW.

---
 arch/x86/Kconfig                  |    6 ++
 arch/x86/include/asm/olpc_ofw.h   |    9 ++
 arch/x86/include/asm/prom.h       |    1 +
 arch/x86/mm/init_32.c             |    2 +
 arch/x86/platform/olpc/Makefile   |    1 +
 arch/x86/platform/olpc/olpc_dt.c  |  165 +++++++++++++++++++++++++++++++++++++
 arch/x86/platform/olpc/olpc_ofw.c |    5 +
 7 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/prom.h
 create mode 100644 arch/x86/platform/olpc/olpc_dt.c
arch/x86/Kconfig +6 -0
index e832768..d8d6c76 100644
@@ -2049,11 +2049,17 @@ config OLPC_OPENFIRMWARE
 	bool "Support for OLPC's Open Firmware"
 	depends on !X86_64 && !X86_PAE
 	default n
+	select OF
 	help
 	  This option adds support for the implementation of Open Firmware
 	  that is used on the OLPC XO-1 Children's Machine.
 	  If unsure, say N here.
 
+config OLPC_OPENFIRMWARE_DT
+	bool
+	default y if OLPC_OPENFIRMWARE && PROC_DEVICETREE
+	select OF_PROMTREE
+
 endif # X86_32
 
 config AMD_NB
arch/x86/include/asm/olpc_ofw.h +9 -0
index 2a84781..641988e 100644
@@ -8,6 +8,8 @@
 
 #ifdef CONFIG_OLPC_OPENFIRMWARE
 
+extern bool olpc_ofw_is_installed(void);
+
 /* run an OFW command by calling into the firmware */
 #define olpc_ofw(name, args, res) \
 	__olpc_ofw((name), ARRAY_SIZE(args), args, ARRAY_SIZE(res), res)
@@ -26,10 +28,17 @@ extern bool olpc_ofw_present(void);
 
 #else /* !CONFIG_OLPC_OPENFIRMWARE */
 
+static inline bool olpc_ofw_is_installed(void) { return false; }
 static inline void olpc_ofw_detect(void) { }
 static inline void setup_olpc_ofw_pgd(void) { }
 static inline bool olpc_ofw_present(void) { return false; }
 
 #endif /* !CONFIG_OLPC_OPENFIRMWARE */
 
+#ifdef CONFIG_OLPC_OPENFIRMWARE_DT
+extern void olpc_dt_build_devicetree(void);
+#else
+static inline void olpc_dt_build_devicetree(void) { }
+#endif /* CONFIG_OLPC_OPENFIRMWARE_DT */
+
 #endif /* _ASM_X86_OLPC_OFW_H */
arch/x86/include/asm/prom.h new file +1 -0
new file mode 100644
index 0000000..b4ec95f
@@ -0,0 +1 @@
+/* dummy prom.h; here to make linux/of.h's #includes happy */
arch/x86/mm/init_32.c +2 -0
index 0e969f9..8c852e4 100644
@@ -45,6 +45,7 @@
 #include <asm/bugs.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
+#include <asm/olpc_ofw.h>
 #include <asm/pgalloc.h>
 #include <asm/sections.h>
 #include <asm/paravirt.h>
@@ -715,6 +716,7 @@ void __init paging_init(void)
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
 	 */
+	olpc_dt_build_devicetree();
 	sparse_init();
 	zone_sizes_init();
 }
arch/x86/platform/olpc/Makefile +1 -0
index c31b8fc..e797428 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_OLPC)		+= olpc.o
 obj-$(CONFIG_OLPC_XO1)		+= olpc-xo1.o
 obj-$(CONFIG_OLPC_OPENFIRMWARE)	+= olpc_ofw.o
+obj-$(CONFIG_OLPC_OPENFIRMWARE_DT)	+= olpc_dt.o
arch/x86/platform/olpc/olpc_dt.c new file +165 -0

165 lines not on this page · raw message

arch/x86/platform/olpc/olpc_ofw.c +5 -0
index 7873204..e7604f6 100644
@@ -110,3 +110,8 @@ void __init olpc_ofw_detect(void)
 			(unsigned long)olpc_ofw_cif, (-start) >> 20);
 	reserve_top_address(-start);
 }
+
+bool __init olpc_ofw_is_installed(void)
+{
+	return olpc_ofw_cif != NULL;
+}
Signature · 1 line
1.7.2.3
#2 lore raw

[tip:x86/olpc] x86, olpc: Add OLPC device-tree support

Commit-ID:  c10d1e260f7cb6766dc76b4e36ed8f4be53f195a
Gitweb:     http://git.kernel.org/tip/c10d1e260f7cb6766dc76b4e36ed8f4be53f195a
Author:     Andres Salomon <[email protected]>
AuthorDate: Wed, 17 Nov 2010 06:09:52 +0000
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Wed, 15 Dec 2010 17:11:30 -0800

x86, olpc: Add OLPC device-tree support

Make use of PROC_DEVICETREE to export the tree, and sparc's PROMTREE code to call into OLPC's Open Firmware to build the tree.

v5: fix buglet with root node check (introduced in v4)

v4: address some minor style issues pointed out by Grant, and explicitly cast
negative phandle checks to s32.

v3: rename olpc_prom to olpc_dt
- rework Kconfig entries
- drop devtree build hook from proc, instead adding a call to x86's paging_init (similarly to how sparc64 does it)
- switch allocation from using slab to alloc_bootmem. this allows the DT to be built earlier during boot (during setup_arch); the downside is that there are some 1200 bootmem reservations that are done during boot. Not ideal..
- add a helper olpc_ofw_is_installed function to test for the existence and successful detection of OLPC's OFW.

LKML-Reference: <[email protected]>

---
 arch/x86/Kconfig                  |    6 ++
 arch/x86/include/asm/olpc_ofw.h   |    9 ++
 arch/x86/include/asm/prom.h       |    1 +
 arch/x86/mm/init_32.c             |    2 +
 arch/x86/platform/olpc/Makefile   |    1 +
 arch/x86/platform/olpc/olpc_dt.c  |  165 +++++++++++++++++++++++++++++++++++++
 arch/x86/platform/olpc/olpc_ofw.c |    5 +
 7 files changed, 189 insertions(+), 0 deletions(-)
arch/x86/Kconfig +6 -0
index e330da2..ef34031 100644
@@ -2049,11 +2049,17 @@ config OLPC_OPENFIRMWARE
 	bool "Support for OLPC's Open Firmware"
 	depends on !X86_64 && !X86_PAE
 	default n
+	select OF
 	help
 	  This option adds support for the implementation of Open Firmware
 	  that is used on the OLPC XO-1 Children's Machine.
 	  If unsure, say N here.
 
+config OLPC_OPENFIRMWARE_DT
+	bool
+	default y if OLPC_OPENFIRMWARE && PROC_DEVICETREE
+	select OF_PROMTREE
+
 endif # X86_32
 
 config AMD_NB
arch/x86/include/asm/olpc_ofw.h +9 -0
index 2a84781..641988e 100644
@@ -8,6 +8,8 @@
 
 #ifdef CONFIG_OLPC_OPENFIRMWARE
 
+extern bool olpc_ofw_is_installed(void);
+
 /* run an OFW command by calling into the firmware */
 #define olpc_ofw(name, args, res) \
 	__olpc_ofw((name), ARRAY_SIZE(args), args, ARRAY_SIZE(res), res)
@@ -26,10 +28,17 @@ extern bool olpc_ofw_present(void);
 
 #else /* !CONFIG_OLPC_OPENFIRMWARE */
 
+static inline bool olpc_ofw_is_installed(void) { return false; }
 static inline void olpc_ofw_detect(void) { }
 static inline void setup_olpc_ofw_pgd(void) { }
 static inline bool olpc_ofw_present(void) { return false; }
 
 #endif /* !CONFIG_OLPC_OPENFIRMWARE */
 
+#ifdef CONFIG_OLPC_OPENFIRMWARE_DT
+extern void olpc_dt_build_devicetree(void);
+#else
+static inline void olpc_dt_build_devicetree(void) { }
+#endif /* CONFIG_OLPC_OPENFIRMWARE_DT */
+
 #endif /* _ASM_X86_OLPC_OFW_H */
arch/x86/include/asm/prom.h new file +1 -0
new file mode 100644
index 0000000..b4ec95f
@@ -0,0 +1 @@
+/* dummy prom.h; here to make linux/of.h's #includes happy */
arch/x86/mm/init_32.c +2 -0
index 0e969f9..8c852e4 100644
@@ -45,6 +45,7 @@
 #include <asm/bugs.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
+#include <asm/olpc_ofw.h>
 #include <asm/pgalloc.h>
 #include <asm/sections.h>
 #include <asm/paravirt.h>
@@ -715,6 +716,7 @@ void __init paging_init(void)
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
 	 */
+	olpc_dt_build_devicetree();
 	sparse_init();
 	zone_sizes_init();
 }
arch/x86/platform/olpc/Makefile +1 -0
index c31b8fc..e797428 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_OLPC)		+= olpc.o
 obj-$(CONFIG_OLPC_XO1)		+= olpc-xo1.o
 obj-$(CONFIG_OLPC_OPENFIRMWARE)	+= olpc_ofw.o
+obj-$(CONFIG_OLPC_OPENFIRMWARE_DT)	+= olpc_dt.o
arch/x86/platform/olpc/olpc_dt.c new file +165 -0

165 lines not on this page · raw message

arch/x86/platform/olpc/olpc_ofw.c +5 -0
index 7873204..e7604f6 100644
@@ -110,3 +110,8 @@ void __init olpc_ofw_detect(void)
 			(unsigned long)olpc_ofw_cif, (-start) >> 20);
 	reserve_top_address(-start);
 }
+
+bool __init olpc_ofw_is_installed(void)
+{
+	return olpc_ofw_cif != NULL;
+}