diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/Kconfig | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/olpc_ofw.h | 9 | ||||
-rw-r--r-- | arch/x86/include/asm/probe_roms.h | 8 | ||||
-rw-r--r-- | arch/x86/include/asm/setup.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/kernel/head32.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/probe_roms.c (renamed from arch/x86/kernel/probe_roms_32.c) | 101 | ||||
-rw-r--r-- | arch/x86/kernel/x86_init.c | 2 | ||||
-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 |
11 files changed, 163 insertions, 38 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 0a1fe60037f2..4168e5d8632a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -2069,7 +2069,7 @@ config OLPC | |||
2069 | depends on !X86_PAE | 2069 | depends on !X86_PAE |
2070 | select GPIOLIB | 2070 | select GPIOLIB |
2071 | select OF | 2071 | select OF |
2072 | select OF_PROMTREE if PROC_DEVICETREE | 2072 | select OF_PROMTREE |
2073 | ---help--- | 2073 | ---help--- |
2074 | Add support for detecting the unique features of the OLPC | 2074 | Add support for detecting the unique features of the OLPC |
2075 | XO hardware. | 2075 | XO hardware. |
diff --git a/arch/x86/include/asm/olpc_ofw.h b/arch/x86/include/asm/olpc_ofw.h index c5d3a5abbb9f..24487712e0b1 100644 --- a/arch/x86/include/asm/olpc_ofw.h +++ b/arch/x86/include/asm/olpc_ofw.h | |||
@@ -26,15 +26,12 @@ extern void setup_olpc_ofw_pgd(void); | |||
26 | /* check if OFW was detected during boot */ | 26 | /* check if OFW was detected during boot */ |
27 | extern bool olpc_ofw_present(void); | 27 | extern bool olpc_ofw_present(void); |
28 | 28 | ||
29 | extern void olpc_dt_build_devicetree(void); | ||
30 | |||
29 | #else /* !CONFIG_OLPC */ | 31 | #else /* !CONFIG_OLPC */ |
30 | static inline void olpc_ofw_detect(void) { } | 32 | static inline void olpc_ofw_detect(void) { } |
31 | static inline void setup_olpc_ofw_pgd(void) { } | 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 | static inline void olpc_dt_build_devicetree(void) { } | 34 | static inline void olpc_dt_build_devicetree(void) { } |
38 | #endif | 35 | #endif /* !CONFIG_OLPC */ |
39 | 36 | ||
40 | #endif /* _ASM_X86_OLPC_OFW_H */ | 37 | #endif /* _ASM_X86_OLPC_OFW_H */ |
diff --git a/arch/x86/include/asm/probe_roms.h b/arch/x86/include/asm/probe_roms.h new file mode 100644 index 000000000000..4950a0b1d09c --- /dev/null +++ b/arch/x86/include/asm/probe_roms.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _PROBE_ROMS_H_ | ||
2 | #define _PROBE_ROMS_H_ | ||
3 | struct pci_dev; | ||
4 | |||
5 | extern void __iomem *pci_map_biosrom(struct pci_dev *pdev); | ||
6 | extern void pci_unmap_biosrom(void __iomem *rom); | ||
7 | extern size_t pci_biosrom_size(struct pci_dev *pdev); | ||
8 | #endif | ||
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index 647d8a06ce4f..9756551ec760 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h | |||
@@ -104,10 +104,10 @@ void *extend_brk(size_t size, size_t align); | |||
104 | type *name; \ | 104 | type *name; \ |
105 | RESERVE_BRK(name, sizeof(type) * entries) | 105 | RESERVE_BRK(name, sizeof(type) * entries) |
106 | 106 | ||
107 | extern void probe_roms(void); | ||
107 | #ifdef __i386__ | 108 | #ifdef __i386__ |
108 | 109 | ||
109 | void __init i386_start_kernel(void); | 110 | void __init i386_start_kernel(void); |
110 | extern void probe_roms(void); | ||
111 | 111 | ||
112 | #else | 112 | #else |
113 | void __init x86_64_start_kernel(char *real_mode); | 113 | void __init x86_64_start_kernel(char *real_mode); |
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 97ebf82e0b7f..250806472a7e 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -36,7 +36,7 @@ obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o | |||
36 | obj-y += time.o ioport.o ldt.o dumpstack.o | 36 | obj-y += time.o ioport.o ldt.o dumpstack.o |
37 | obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o | 37 | obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o |
38 | obj-$(CONFIG_IRQ_WORK) += irq_work.o | 38 | obj-$(CONFIG_IRQ_WORK) += irq_work.o |
39 | obj-$(CONFIG_X86_32) += probe_roms_32.o | 39 | obj-y += probe_roms.o |
40 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o | 40 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o |
41 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o | 41 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o |
42 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o | 42 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o |
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c index d6d6bb361931..3bb08509a7a1 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c | |||
@@ -23,7 +23,6 @@ | |||
23 | static void __init i386_default_early_setup(void) | 23 | static void __init i386_default_early_setup(void) |
24 | { | 24 | { |
25 | /* Initialize 32bit specific setup functions */ | 25 | /* Initialize 32bit specific setup functions */ |
26 | x86_init.resources.probe_roms = probe_roms; | ||
27 | x86_init.resources.reserve_resources = i386_reserve_resources; | 26 | x86_init.resources.reserve_resources = i386_reserve_resources; |
28 | x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; | 27 | x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; |
29 | 28 | ||
diff --git a/arch/x86/kernel/probe_roms_32.c b/arch/x86/kernel/probe_roms.c index 071e7fea42e5..ba0a4cce53be 100644 --- a/arch/x86/kernel/probe_roms_32.c +++ b/arch/x86/kernel/probe_roms.c | |||
@@ -73,6 +73,107 @@ static struct resource video_rom_resource = { | |||
73 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | 73 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM |
74 | }; | 74 | }; |
75 | 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 | |||
76 | #define ROMSIGNATURE 0xaa55 | 177 | #define ROMSIGNATURE 0xaa55 |
77 | 178 | ||
78 | static int __init romsignature(const unsigned char *rom) | 179 | static int __init romsignature(const unsigned char *rom) |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 75ef4b18e9b7..6f164bd5e14d 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
@@ -35,7 +35,7 @@ void iommu_shutdown_noop(void) { } | |||
35 | struct x86_init_ops x86_init __initdata = { | 35 | struct x86_init_ops x86_init __initdata = { |
36 | 36 | ||
37 | .resources = { | 37 | .resources = { |
38 | .probe_roms = x86_init_noop, | 38 | .probe_roms = probe_roms, |
39 | .reserve_resources = reserve_standard_io_resources, | 39 | .reserve_resources = reserve_standard_io_resources, |
40 | .memory_setup = default_machine_specific_memory_setup, | 40 | .memory_setup = default_machine_specific_memory_setup, |
41 | }, | 41 | }, |
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); | ||