diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-19 21:08:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-19 21:08:06 -0400 |
commit | 08b5d06ec6cff1d952f13cfcffcbf41ff0ce2c86 (patch) | |
tree | 0d087f009b80bdf54f22fdb78437af790c1afc27 /arch/x86/platform | |
parent | 13588209aa90d9c8e502750fc86160314555612f (diff) | |
parent | 5d94e81f69d4b1d1102d3ab557ce0a817c11fbbb (diff) |
Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86: Introduce pci_map_biosrom()
x86, olpc: Use device tree for platform identification
Diffstat (limited to 'arch/x86/platform')
-rw-r--r-- | arch/x86/platform/olpc/Makefile | 4 | ||||
-rw-r--r-- | arch/x86/platform/olpc/olpc.c | 51 | ||||
-rw-r--r-- | arch/x86/platform/olpc/olpc_dt.c | 19 |
3 files changed, 47 insertions, 27 deletions
diff --git a/arch/x86/platform/olpc/Makefile b/arch/x86/platform/olpc/Makefile index c2a8cab65e5d..81c5e2165c24 100644 --- a/arch/x86/platform/olpc/Makefile +++ b/arch/x86/platform/olpc/Makefile | |||
@@ -1,4 +1,2 @@ | |||
1 | obj-$(CONFIG_OLPC) += olpc.o | 1 | obj-$(CONFIG_OLPC) += olpc.o olpc_ofw.o olpc_dt.o |
2 | obj-$(CONFIG_OLPC_XO1) += olpc-xo1.o | 2 | obj-$(CONFIG_OLPC_XO1) += olpc-xo1.o |
3 | obj-$(CONFIG_OLPC) += olpc_ofw.o | ||
4 | obj-$(CONFIG_OF_PROMTREE) += olpc_dt.o | ||
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index edaf3fe8dc5e..0060fd59ea00 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/of.h> | ||
21 | 22 | ||
22 | #include <asm/geode.h> | 23 | #include <asm/geode.h> |
23 | #include <asm/setup.h> | 24 | #include <asm/setup.h> |
@@ -187,41 +188,43 @@ err: | |||
187 | } | 188 | } |
188 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); | 189 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); |
189 | 190 | ||
190 | static bool __init check_ofw_architecture(void) | 191 | static bool __init check_ofw_architecture(struct device_node *root) |
191 | { | 192 | { |
192 | size_t propsize; | 193 | const char *olpc_arch; |
193 | char olpc_arch[5]; | 194 | int propsize; |
194 | const void *args[] = { NULL, "architecture", olpc_arch, (void *)5 }; | ||
195 | void *res[] = { &propsize }; | ||
196 | 195 | ||
197 | if (olpc_ofw("getprop", args, res)) { | 196 | olpc_arch = of_get_property(root, "architecture", &propsize); |
198 | printk(KERN_ERR "ofw: getprop call failed!\n"); | ||
199 | return false; | ||
200 | } | ||
201 | return propsize == 5 && strncmp("OLPC", olpc_arch, 5) == 0; | 197 | return propsize == 5 && strncmp("OLPC", olpc_arch, 5) == 0; |
202 | } | 198 | } |
203 | 199 | ||
204 | static u32 __init get_board_revision(void) | 200 | static u32 __init get_board_revision(struct device_node *root) |
205 | { | 201 | { |
206 | size_t propsize; | 202 | int propsize; |
207 | __be32 rev; | 203 | const __be32 *rev; |
208 | const void *args[] = { NULL, "board-revision-int", &rev, (void *)4 }; | 204 | |
209 | void *res[] = { &propsize }; | 205 | rev = of_get_property(root, "board-revision-int", &propsize); |
210 | 206 | if (propsize != 4) | |
211 | if (olpc_ofw("getprop", args, res) || propsize != 4) { | 207 | return 0; |
212 | printk(KERN_ERR "ofw: getprop call failed!\n"); | 208 | |
213 | return cpu_to_be32(0); | 209 | return be32_to_cpu(*rev); |
214 | } | ||
215 | return be32_to_cpu(rev); | ||
216 | } | 210 | } |
217 | 211 | ||
218 | static bool __init platform_detect(void) | 212 | static bool __init platform_detect(void) |
219 | { | 213 | { |
220 | if (!check_ofw_architecture()) | 214 | struct device_node *root = of_find_node_by_path("/"); |
215 | bool success; | ||
216 | |||
217 | if (!root) | ||
221 | return false; | 218 | return false; |
222 | olpc_platform_info.flags |= OLPC_F_PRESENT; | 219 | |
223 | olpc_platform_info.boardrev = get_board_revision(); | 220 | success = check_ofw_architecture(root); |
224 | return true; | 221 | if (success) { |
222 | olpc_platform_info.boardrev = get_board_revision(root); | ||
223 | olpc_platform_info.flags |= OLPC_F_PRESENT; | ||
224 | } | ||
225 | |||
226 | of_node_put(root); | ||
227 | return success; | ||
225 | } | 228 | } |
226 | 229 | ||
227 | static int __init add_xo1_platform_devices(void) | 230 | static int __init add_xo1_platform_devices(void) |
diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c index 044bda5b3174..d39f63d017d2 100644 --- a/arch/x86/platform/olpc/olpc_dt.c +++ b/arch/x86/platform/olpc/olpc_dt.c | |||
@@ -19,7 +19,9 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/bootmem.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/of_platform.h> | ||
22 | #include <linux/of_pdt.h> | 23 | #include <linux/of_pdt.h> |
24 | #include <asm/olpc.h> | ||
23 | #include <asm/olpc_ofw.h> | 25 | #include <asm/olpc_ofw.h> |
24 | 26 | ||
25 | static phandle __init olpc_dt_getsibling(phandle node) | 27 | static phandle __init olpc_dt_getsibling(phandle node) |
@@ -180,3 +182,20 @@ void __init olpc_dt_build_devicetree(void) | |||
180 | pr_info("PROM DT: Built device tree with %u bytes of memory.\n", | 182 | pr_info("PROM DT: Built device tree with %u bytes of memory.\n", |
181 | prom_early_allocated); | 183 | prom_early_allocated); |
182 | } | 184 | } |
185 | |||
186 | /* A list of DT node/bus matches that we want to expose as platform devices */ | ||
187 | static struct of_device_id __initdata of_ids[] = { | ||
188 | { .compatible = "olpc,xo1-battery" }, | ||
189 | { .compatible = "olpc,xo1-dcon" }, | ||
190 | { .compatible = "olpc,xo1-rtc" }, | ||
191 | {}, | ||
192 | }; | ||
193 | |||
194 | static int __init olpc_create_platform_devices(void) | ||
195 | { | ||
196 | if (machine_is_olpc()) | ||
197 | return of_platform_bus_probe(NULL, of_ids, NULL); | ||
198 | else | ||
199 | return 0; | ||
200 | } | ||
201 | device_initcall(olpc_create_platform_devices); | ||