Commit 08b5d06ec6cff1d952f13cfcffcbf41ff0ce2c86
Exists in
master
and in
7 other branches
Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kern…
…el/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
Showing 12 changed files Side-by-side Diff
- arch/x86/Kconfig
- arch/x86/include/asm/olpc_ofw.h
- arch/x86/include/asm/probe_roms.h
- arch/x86/include/asm/setup.h
- arch/x86/kernel/Makefile
- arch/x86/kernel/head32.c
- arch/x86/kernel/probe_roms.c
- arch/x86/kernel/probe_roms_32.c
- arch/x86/kernel/x86_init.c
- arch/x86/platform/olpc/Makefile
- arch/x86/platform/olpc/olpc.c
- arch/x86/platform/olpc/olpc_dt.c
arch/x86/Kconfig
arch/x86/include/asm/olpc_ofw.h
... | ... | @@ -26,16 +26,13 @@ |
26 | 26 | /* check if OFW was detected during boot */ |
27 | 27 | extern bool olpc_ofw_present(void); |
28 | 28 | |
29 | +extern void olpc_dt_build_devicetree(void); | |
30 | + | |
29 | 31 | #else /* !CONFIG_OLPC */ |
30 | 32 | static inline void olpc_ofw_detect(void) { } |
31 | 33 | static inline void setup_olpc_ofw_pgd(void) { } |
32 | -#endif /* !CONFIG_OLPC */ | |
33 | - | |
34 | -#ifdef CONFIG_OF_PROMTREE | |
35 | -extern void olpc_dt_build_devicetree(void); | |
36 | -#else | |
37 | 34 | static inline void olpc_dt_build_devicetree(void) { } |
38 | -#endif | |
35 | +#endif /* !CONFIG_OLPC */ | |
39 | 36 | |
40 | 37 | #endif /* _ASM_X86_OLPC_OFW_H */ |
arch/x86/include/asm/probe_roms.h
arch/x86/include/asm/setup.h
... | ... | @@ -104,10 +104,10 @@ |
104 | 104 | type *name; \ |
105 | 105 | RESERVE_BRK(name, sizeof(type) * entries) |
106 | 106 | |
107 | +extern void probe_roms(void); | |
107 | 108 | #ifdef __i386__ |
108 | 109 | |
109 | 110 | void __init i386_start_kernel(void); |
110 | -extern void probe_roms(void); | |
111 | 111 | |
112 | 112 | #else |
113 | 113 | void __init x86_64_start_kernel(char *real_mode); |
arch/x86/kernel/Makefile
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | obj-y += time.o ioport.o ldt.o dumpstack.o |
37 | 37 | obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o |
38 | 38 | obj-$(CONFIG_IRQ_WORK) += irq_work.o |
39 | -obj-$(CONFIG_X86_32) += probe_roms_32.o | |
39 | +obj-y += probe_roms.o | |
40 | 40 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o |
41 | 41 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o |
42 | 42 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o |
arch/x86/kernel/head32.c
... | ... | @@ -23,7 +23,6 @@ |
23 | 23 | static void __init i386_default_early_setup(void) |
24 | 24 | { |
25 | 25 | /* Initialize 32bit specific setup functions */ |
26 | - x86_init.resources.probe_roms = probe_roms; | |
27 | 26 | x86_init.resources.reserve_resources = i386_reserve_resources; |
28 | 27 | x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; |
29 | 28 |
arch/x86/kernel/probe_roms.c
1 | +#include <linux/sched.h> | |
2 | +#include <linux/mm.h> | |
3 | +#include <linux/uaccess.h> | |
4 | +#include <linux/mmzone.h> | |
5 | +#include <linux/ioport.h> | |
6 | +#include <linux/seq_file.h> | |
7 | +#include <linux/console.h> | |
8 | +#include <linux/init.h> | |
9 | +#include <linux/edd.h> | |
10 | +#include <linux/dmi.h> | |
11 | +#include <linux/pfn.h> | |
12 | +#include <linux/pci.h> | |
13 | +#include <asm/pci-direct.h> | |
14 | + | |
15 | + | |
16 | +#include <asm/e820.h> | |
17 | +#include <asm/mmzone.h> | |
18 | +#include <asm/setup.h> | |
19 | +#include <asm/sections.h> | |
20 | +#include <asm/io.h> | |
21 | +#include <asm/setup_arch.h> | |
22 | + | |
23 | +static struct resource system_rom_resource = { | |
24 | + .name = "System ROM", | |
25 | + .start = 0xf0000, | |
26 | + .end = 0xfffff, | |
27 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
28 | +}; | |
29 | + | |
30 | +static struct resource extension_rom_resource = { | |
31 | + .name = "Extension ROM", | |
32 | + .start = 0xe0000, | |
33 | + .end = 0xeffff, | |
34 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
35 | +}; | |
36 | + | |
37 | +static struct resource adapter_rom_resources[] = { { | |
38 | + .name = "Adapter ROM", | |
39 | + .start = 0xc8000, | |
40 | + .end = 0, | |
41 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
42 | +}, { | |
43 | + .name = "Adapter ROM", | |
44 | + .start = 0, | |
45 | + .end = 0, | |
46 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
47 | +}, { | |
48 | + .name = "Adapter ROM", | |
49 | + .start = 0, | |
50 | + .end = 0, | |
51 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
52 | +}, { | |
53 | + .name = "Adapter ROM", | |
54 | + .start = 0, | |
55 | + .end = 0, | |
56 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
57 | +}, { | |
58 | + .name = "Adapter ROM", | |
59 | + .start = 0, | |
60 | + .end = 0, | |
61 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
62 | +}, { | |
63 | + .name = "Adapter ROM", | |
64 | + .start = 0, | |
65 | + .end = 0, | |
66 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
67 | +} }; | |
68 | + | |
69 | +static struct resource video_rom_resource = { | |
70 | + .name = "Video ROM", | |
71 | + .start = 0xc0000, | |
72 | + .end = 0xc7fff, | |
73 | + .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
74 | +}; | |
75 | + | |
76 | +/* does this oprom support the given pci device, or any of the devices | |
77 | + * that the driver supports? | |
78 | + */ | |
79 | +static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device) | |
80 | +{ | |
81 | + struct pci_driver *drv = pdev->driver; | |
82 | + const struct pci_device_id *id; | |
83 | + | |
84 | + if (pdev->vendor == vendor && pdev->device == device) | |
85 | + return true; | |
86 | + | |
87 | + for (id = drv ? drv->id_table : NULL; id && id->vendor; id++) | |
88 | + if (id->vendor == vendor && id->device == device) | |
89 | + break; | |
90 | + | |
91 | + return id && id->vendor; | |
92 | +} | |
93 | + | |
94 | +static bool probe_list(struct pci_dev *pdev, unsigned short vendor, | |
95 | + const unsigned char *rom_list) | |
96 | +{ | |
97 | + unsigned short device; | |
98 | + | |
99 | + do { | |
100 | + if (probe_kernel_address(rom_list, device) != 0) | |
101 | + device = 0; | |
102 | + | |
103 | + if (device && match_id(pdev, vendor, device)) | |
104 | + break; | |
105 | + | |
106 | + rom_list += 2; | |
107 | + } while (device); | |
108 | + | |
109 | + return !!device; | |
110 | +} | |
111 | + | |
112 | +static struct resource *find_oprom(struct pci_dev *pdev) | |
113 | +{ | |
114 | + struct resource *oprom = NULL; | |
115 | + int i; | |
116 | + | |
117 | + for (i = 0; i < ARRAY_SIZE(adapter_rom_resources); i++) { | |
118 | + struct resource *res = &adapter_rom_resources[i]; | |
119 | + unsigned short offset, vendor, device, list, rev; | |
120 | + const unsigned char *rom; | |
121 | + | |
122 | + if (res->end == 0) | |
123 | + break; | |
124 | + | |
125 | + rom = isa_bus_to_virt(res->start); | |
126 | + if (probe_kernel_address(rom + 0x18, offset) != 0) | |
127 | + continue; | |
128 | + | |
129 | + if (probe_kernel_address(rom + offset + 0x4, vendor) != 0) | |
130 | + continue; | |
131 | + | |
132 | + if (probe_kernel_address(rom + offset + 0x6, device) != 0) | |
133 | + continue; | |
134 | + | |
135 | + if (match_id(pdev, vendor, device)) { | |
136 | + oprom = res; | |
137 | + break; | |
138 | + } | |
139 | + | |
140 | + if (probe_kernel_address(rom + offset + 0x8, list) == 0 && | |
141 | + probe_kernel_address(rom + offset + 0xc, rev) == 0 && | |
142 | + rev >= 3 && list && | |
143 | + probe_list(pdev, vendor, rom + offset + list)) { | |
144 | + oprom = res; | |
145 | + break; | |
146 | + } | |
147 | + } | |
148 | + | |
149 | + return oprom; | |
150 | +} | |
151 | + | |
152 | +void *pci_map_biosrom(struct pci_dev *pdev) | |
153 | +{ | |
154 | + struct resource *oprom = find_oprom(pdev); | |
155 | + | |
156 | + if (!oprom) | |
157 | + return NULL; | |
158 | + | |
159 | + return ioremap(oprom->start, resource_size(oprom)); | |
160 | +} | |
161 | +EXPORT_SYMBOL(pci_map_biosrom); | |
162 | + | |
163 | +void pci_unmap_biosrom(void __iomem *image) | |
164 | +{ | |
165 | + iounmap(image); | |
166 | +} | |
167 | +EXPORT_SYMBOL(pci_unmap_biosrom); | |
168 | + | |
169 | +size_t pci_biosrom_size(struct pci_dev *pdev) | |
170 | +{ | |
171 | + struct resource *oprom = find_oprom(pdev); | |
172 | + | |
173 | + return oprom ? resource_size(oprom) : 0; | |
174 | +} | |
175 | +EXPORT_SYMBOL(pci_biosrom_size); | |
176 | + | |
177 | +#define ROMSIGNATURE 0xaa55 | |
178 | + | |
179 | +static int __init romsignature(const unsigned char *rom) | |
180 | +{ | |
181 | + const unsigned short * const ptr = (const unsigned short *)rom; | |
182 | + unsigned short sig; | |
183 | + | |
184 | + return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; | |
185 | +} | |
186 | + | |
187 | +static int __init romchecksum(const unsigned char *rom, unsigned long length) | |
188 | +{ | |
189 | + unsigned char sum, c; | |
190 | + | |
191 | + for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) | |
192 | + sum += c; | |
193 | + return !length && !sum; | |
194 | +} | |
195 | + | |
196 | +void __init probe_roms(void) | |
197 | +{ | |
198 | + const unsigned char *rom; | |
199 | + unsigned long start, length, upper; | |
200 | + unsigned char c; | |
201 | + int i; | |
202 | + | |
203 | + /* video rom */ | |
204 | + upper = adapter_rom_resources[0].start; | |
205 | + for (start = video_rom_resource.start; start < upper; start += 2048) { | |
206 | + rom = isa_bus_to_virt(start); | |
207 | + if (!romsignature(rom)) | |
208 | + continue; | |
209 | + | |
210 | + video_rom_resource.start = start; | |
211 | + | |
212 | + if (probe_kernel_address(rom + 2, c) != 0) | |
213 | + continue; | |
214 | + | |
215 | + /* 0 < length <= 0x7f * 512, historically */ | |
216 | + length = c * 512; | |
217 | + | |
218 | + /* if checksum okay, trust length byte */ | |
219 | + if (length && romchecksum(rom, length)) | |
220 | + video_rom_resource.end = start + length - 1; | |
221 | + | |
222 | + request_resource(&iomem_resource, &video_rom_resource); | |
223 | + break; | |
224 | + } | |
225 | + | |
226 | + start = (video_rom_resource.end + 1 + 2047) & ~2047UL; | |
227 | + if (start < upper) | |
228 | + start = upper; | |
229 | + | |
230 | + /* system rom */ | |
231 | + request_resource(&iomem_resource, &system_rom_resource); | |
232 | + upper = system_rom_resource.start; | |
233 | + | |
234 | + /* check for extension rom (ignore length byte!) */ | |
235 | + rom = isa_bus_to_virt(extension_rom_resource.start); | |
236 | + if (romsignature(rom)) { | |
237 | + length = extension_rom_resource.end - extension_rom_resource.start + 1; | |
238 | + if (romchecksum(rom, length)) { | |
239 | + request_resource(&iomem_resource, &extension_rom_resource); | |
240 | + upper = extension_rom_resource.start; | |
241 | + } | |
242 | + } | |
243 | + | |
244 | + /* check for adapter roms on 2k boundaries */ | |
245 | + for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) { | |
246 | + rom = isa_bus_to_virt(start); | |
247 | + if (!romsignature(rom)) | |
248 | + continue; | |
249 | + | |
250 | + if (probe_kernel_address(rom + 2, c) != 0) | |
251 | + continue; | |
252 | + | |
253 | + /* 0 < length <= 0x7f * 512, historically */ | |
254 | + length = c * 512; | |
255 | + | |
256 | + /* but accept any length that fits if checksum okay */ | |
257 | + if (!length || start + length > upper || !romchecksum(rom, length)) | |
258 | + continue; | |
259 | + | |
260 | + adapter_rom_resources[i].start = start; | |
261 | + adapter_rom_resources[i].end = start + length - 1; | |
262 | + request_resource(&iomem_resource, &adapter_rom_resources[i]); | |
263 | + | |
264 | + start = adapter_rom_resources[i++].end & ~2047UL; | |
265 | + } | |
266 | +} |
arch/x86/kernel/probe_roms_32.c
1 | -#include <linux/sched.h> | |
2 | -#include <linux/mm.h> | |
3 | -#include <linux/uaccess.h> | |
4 | -#include <linux/mmzone.h> | |
5 | -#include <linux/ioport.h> | |
6 | -#include <linux/seq_file.h> | |
7 | -#include <linux/console.h> | |
8 | -#include <linux/init.h> | |
9 | -#include <linux/edd.h> | |
10 | -#include <linux/dmi.h> | |
11 | -#include <linux/pfn.h> | |
12 | -#include <linux/pci.h> | |
13 | -#include <asm/pci-direct.h> | |
14 | - | |
15 | - | |
16 | -#include <asm/e820.h> | |
17 | -#include <asm/mmzone.h> | |
18 | -#include <asm/setup.h> | |
19 | -#include <asm/sections.h> | |
20 | -#include <asm/io.h> | |
21 | -#include <asm/setup_arch.h> | |
22 | - | |
23 | -static struct resource system_rom_resource = { | |
24 | - .name = "System ROM", | |
25 | - .start = 0xf0000, | |
26 | - .end = 0xfffff, | |
27 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
28 | -}; | |
29 | - | |
30 | -static struct resource extension_rom_resource = { | |
31 | - .name = "Extension ROM", | |
32 | - .start = 0xe0000, | |
33 | - .end = 0xeffff, | |
34 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
35 | -}; | |
36 | - | |
37 | -static struct resource adapter_rom_resources[] = { { | |
38 | - .name = "Adapter ROM", | |
39 | - .start = 0xc8000, | |
40 | - .end = 0, | |
41 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
42 | -}, { | |
43 | - .name = "Adapter ROM", | |
44 | - .start = 0, | |
45 | - .end = 0, | |
46 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
47 | -}, { | |
48 | - .name = "Adapter ROM", | |
49 | - .start = 0, | |
50 | - .end = 0, | |
51 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
52 | -}, { | |
53 | - .name = "Adapter ROM", | |
54 | - .start = 0, | |
55 | - .end = 0, | |
56 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
57 | -}, { | |
58 | - .name = "Adapter ROM", | |
59 | - .start = 0, | |
60 | - .end = 0, | |
61 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
62 | -}, { | |
63 | - .name = "Adapter ROM", | |
64 | - .start = 0, | |
65 | - .end = 0, | |
66 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
67 | -} }; | |
68 | - | |
69 | -static struct resource video_rom_resource = { | |
70 | - .name = "Video ROM", | |
71 | - .start = 0xc0000, | |
72 | - .end = 0xc7fff, | |
73 | - .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
74 | -}; | |
75 | - | |
76 | -#define ROMSIGNATURE 0xaa55 | |
77 | - | |
78 | -static int __init romsignature(const unsigned char *rom) | |
79 | -{ | |
80 | - const unsigned short * const ptr = (const unsigned short *)rom; | |
81 | - unsigned short sig; | |
82 | - | |
83 | - return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; | |
84 | -} | |
85 | - | |
86 | -static int __init romchecksum(const unsigned char *rom, unsigned long length) | |
87 | -{ | |
88 | - unsigned char sum, c; | |
89 | - | |
90 | - for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) | |
91 | - sum += c; | |
92 | - return !length && !sum; | |
93 | -} | |
94 | - | |
95 | -void __init probe_roms(void) | |
96 | -{ | |
97 | - const unsigned char *rom; | |
98 | - unsigned long start, length, upper; | |
99 | - unsigned char c; | |
100 | - int i; | |
101 | - | |
102 | - /* video rom */ | |
103 | - upper = adapter_rom_resources[0].start; | |
104 | - for (start = video_rom_resource.start; start < upper; start += 2048) { | |
105 | - rom = isa_bus_to_virt(start); | |
106 | - if (!romsignature(rom)) | |
107 | - continue; | |
108 | - | |
109 | - video_rom_resource.start = start; | |
110 | - | |
111 | - if (probe_kernel_address(rom + 2, c) != 0) | |
112 | - continue; | |
113 | - | |
114 | - /* 0 < length <= 0x7f * 512, historically */ | |
115 | - length = c * 512; | |
116 | - | |
117 | - /* if checksum okay, trust length byte */ | |
118 | - if (length && romchecksum(rom, length)) | |
119 | - video_rom_resource.end = start + length - 1; | |
120 | - | |
121 | - request_resource(&iomem_resource, &video_rom_resource); | |
122 | - break; | |
123 | - } | |
124 | - | |
125 | - start = (video_rom_resource.end + 1 + 2047) & ~2047UL; | |
126 | - if (start < upper) | |
127 | - start = upper; | |
128 | - | |
129 | - /* system rom */ | |
130 | - request_resource(&iomem_resource, &system_rom_resource); | |
131 | - upper = system_rom_resource.start; | |
132 | - | |
133 | - /* check for extension rom (ignore length byte!) */ | |
134 | - rom = isa_bus_to_virt(extension_rom_resource.start); | |
135 | - if (romsignature(rom)) { | |
136 | - length = extension_rom_resource.end - extension_rom_resource.start + 1; | |
137 | - if (romchecksum(rom, length)) { | |
138 | - request_resource(&iomem_resource, &extension_rom_resource); | |
139 | - upper = extension_rom_resource.start; | |
140 | - } | |
141 | - } | |
142 | - | |
143 | - /* check for adapter roms on 2k boundaries */ | |
144 | - for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) { | |
145 | - rom = isa_bus_to_virt(start); | |
146 | - if (!romsignature(rom)) | |
147 | - continue; | |
148 | - | |
149 | - if (probe_kernel_address(rom + 2, c) != 0) | |
150 | - continue; | |
151 | - | |
152 | - /* 0 < length <= 0x7f * 512, historically */ | |
153 | - length = c * 512; | |
154 | - | |
155 | - /* but accept any length that fits if checksum okay */ | |
156 | - if (!length || start + length > upper || !romchecksum(rom, length)) | |
157 | - continue; | |
158 | - | |
159 | - adapter_rom_resources[i].start = start; | |
160 | - adapter_rom_resources[i].end = start + length - 1; | |
161 | - request_resource(&iomem_resource, &adapter_rom_resources[i]); | |
162 | - | |
163 | - start = adapter_rom_resources[i++].end & ~2047UL; | |
164 | - } | |
165 | -} |
arch/x86/kernel/x86_init.c
arch/x86/platform/olpc/Makefile
arch/x86/platform/olpc/olpc.c
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | #include <linux/io.h> |
19 | 19 | #include <linux/string.h> |
20 | 20 | #include <linux/platform_device.h> |
21 | +#include <linux/of.h> | |
21 | 22 | |
22 | 23 | #include <asm/geode.h> |
23 | 24 | #include <asm/setup.h> |
24 | 25 | |
25 | 26 | |
26 | 27 | |
27 | 28 | |
28 | 29 | |
29 | 30 | |
30 | 31 | |
... | ... | @@ -187,41 +188,43 @@ |
187 | 188 | } |
188 | 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 | - char olpc_arch[5]; | |
194 | - const void *args[] = { NULL, "architecture", olpc_arch, (void *)5 }; | |
195 | - void *res[] = { &propsize }; | |
193 | + const char *olpc_arch; | |
194 | + int propsize; | |
196 | 195 | |
197 | - if (olpc_ofw("getprop", args, res)) { | |
198 | - printk(KERN_ERR "ofw: getprop call failed!\n"); | |
199 | - return false; | |
200 | - } | |
196 | + olpc_arch = of_get_property(root, "architecture", &propsize); | |
201 | 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; | |
207 | - __be32 rev; | |
208 | - const void *args[] = { NULL, "board-revision-int", &rev, (void *)4 }; | |
209 | - void *res[] = { &propsize }; | |
202 | + int propsize; | |
203 | + const __be32 *rev; | |
210 | 204 | |
211 | - if (olpc_ofw("getprop", args, res) || propsize != 4) { | |
212 | - printk(KERN_ERR "ofw: getprop call failed!\n"); | |
213 | - return cpu_to_be32(0); | |
214 | - } | |
215 | - return be32_to_cpu(rev); | |
205 | + rev = of_get_property(root, "board-revision-int", &propsize); | |
206 | + if (propsize != 4) | |
207 | + return 0; | |
208 | + | |
209 | + return be32_to_cpu(*rev); | |
216 | 210 | } |
217 | 211 | |
218 | 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 | 218 | return false; |
222 | - olpc_platform_info.flags |= OLPC_F_PRESENT; | |
223 | - olpc_platform_info.boardrev = get_board_revision(); | |
224 | - return true; | |
219 | + | |
220 | + success = check_ofw_architecture(root); | |
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 | 230 | static int __init add_xo1_platform_devices(void) |
arch/x86/platform/olpc/olpc_dt.c
... | ... | @@ -19,7 +19,9 @@ |
19 | 19 | #include <linux/kernel.h> |
20 | 20 | #include <linux/bootmem.h> |
21 | 21 | #include <linux/of.h> |
22 | +#include <linux/of_platform.h> | |
22 | 23 | #include <linux/of_pdt.h> |
24 | +#include <asm/olpc.h> | |
23 | 25 | #include <asm/olpc_ofw.h> |
24 | 26 | |
25 | 27 | static phandle __init olpc_dt_getsibling(phandle node) |
... | ... | @@ -180,4 +182,21 @@ |
180 | 182 | pr_info("PROM DT: Built device tree with %u bytes of memory.\n", |
181 | 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); |