aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-07-03 13:49:45 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-07-03 13:49:45 -0400
commit026477c1141b67e98e3bd8bdedb7d4b88a3ecd09 (patch)
tree2624a44924c625c367f3cebf937853b9da2de282 /arch/sparc
parent9f2fa466383ce100b90fe52cb4489d7a26bf72a9 (diff)
parent29454dde27d8e340bb1987bad9aa504af7081eba (diff)
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/kernel/asm-offsets.c1
-rw-r--r--arch/sparc/kernel/auxio.c1
-rw-r--r--arch/sparc/kernel/cpu.c1
-rw-r--r--arch/sparc/kernel/devices.c1
-rw-r--r--arch/sparc/kernel/ebus.c1
-rw-r--r--arch/sparc/kernel/entry.S1
-rw-r--r--arch/sparc/kernel/head.S1
-rw-r--r--arch/sparc/kernel/idprom.c1
-rw-r--r--arch/sparc/kernel/ioport.c25
-rw-r--r--arch/sparc/kernel/irq.c15
-rw-r--r--arch/sparc/kernel/of_device.c477
-rw-r--r--arch/sparc/kernel/pcic.c5
-rw-r--r--arch/sparc/kernel/process.c1
-rw-r--r--arch/sparc/kernel/prom.c30
-rw-r--r--arch/sparc/kernel/setup.c3
-rw-r--r--arch/sparc/kernel/signal.c1
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c1
-rw-r--r--arch/sparc/kernel/sun4c_irq.c3
-rw-r--r--arch/sparc/kernel/sun4d_irq.c13
-rw-r--r--arch/sparc/kernel/sun4m_irq.c3
-rw-r--r--arch/sparc/kernel/sys_solaris.c1
-rw-r--r--arch/sparc/kernel/sys_sunos.c2
-rw-r--r--arch/sparc/kernel/systbls.S1
-rw-r--r--arch/sparc/kernel/tick14.c2
-rw-r--r--arch/sparc/kernel/time.c110
-rw-r--r--arch/sparc/kernel/traps.c1
-rw-r--r--arch/sparc/lib/atomic.S1
-rw-r--r--arch/sparc/lib/bitops.S1
-rw-r--r--arch/sparc/lib/rwsem.S1
-rw-r--r--arch/sparc/mm/btfixup.c1
-rw-r--r--arch/sparc/mm/extable.c1
-rw-r--r--arch/sparc/mm/hypersparc.S1
-rw-r--r--arch/sparc/mm/init.c1
-rw-r--r--arch/sparc/mm/io-unit.c1
-rw-r--r--arch/sparc/mm/iommu.c1
-rw-r--r--arch/sparc/mm/srmmu.c1
-rw-r--r--arch/sparc/mm/sun4c.c1
-rw-r--r--arch/sparc/mm/swift.S1
-rw-r--r--arch/sparc/mm/tsunami.S1
-rw-r--r--arch/sparc/mm/viking.S1
-rw-r--r--arch/sparc/prom/init.c1
-rw-r--r--arch/sparc/prom/memory.c1
-rw-r--r--arch/sparc/prom/misc.c1
43 files changed, 587 insertions, 132 deletions
diff --git a/arch/sparc/kernel/asm-offsets.c b/arch/sparc/kernel/asm-offsets.c
index 1f55231f07de..29d7cfd1c970 100644
--- a/arch/sparc/kernel/asm-offsets.c
+++ b/arch/sparc/kernel/asm-offsets.c
@@ -10,7 +10,6 @@
10 * On sparc, thread_info data is static and TI_XXX offsets are computed by hand. 10 * On sparc, thread_info data is static and TI_XXX offsets are computed by hand.
11 */ 11 */
12 12
13#include <linux/config.h>
14#include <linux/sched.h> 13#include <linux/sched.h>
15// #include <linux/mm.h> 14// #include <linux/mm.h>
16 15
diff --git a/arch/sparc/kernel/auxio.c b/arch/sparc/kernel/auxio.c
index d3b3648362c0..118f3eca373e 100644
--- a/arch/sparc/kernel/auxio.c
+++ b/arch/sparc/kernel/auxio.c
@@ -5,7 +5,6 @@
5 5
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/config.h>
9#include <linux/spinlock.h> 8#include <linux/spinlock.h>
10#include <asm/oplib.h> 9#include <asm/oplib.h>
11#include <asm/io.h> 10#include <asm/io.h>
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
index d7bfc61d2879..259a559d4cea 100644
--- a/arch/sparc/kernel/cpu.c
+++ b/arch/sparc/kernel/cpu.c
@@ -4,7 +4,6 @@
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */ 5 */
6 6
7#include <linux/config.h>
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/init.h> 8#include <linux/init.h>
10#include <linux/smp.h> 9#include <linux/smp.h>
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index fcb0c049c3fe..adba9dfee35e 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -7,7 +7,6 @@
7 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 7 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
8 */ 8 */
9 9
10#include <linux/config.h>
11#include <linux/kernel.h> 10#include <linux/kernel.h>
12#include <linux/threads.h> 11#include <linux/threads.h>
13#include <linux/string.h> 12#include <linux/string.h>
diff --git a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
index a7a4892956c8..81c0cbd96ff0 100644
--- a/arch/sparc/kernel/ebus.c
+++ b/arch/sparc/kernel/ebus.c
@@ -7,7 +7,6 @@
7 * Fixes for different platforms by Pete Zaitcev. 7 * Fixes for different platforms by Pete Zaitcev.
8 */ 8 */
9 9
10#include <linux/config.h>
11#include <linux/kernel.h> 10#include <linux/kernel.h>
12#include <linux/types.h> 11#include <linux/types.h>
13#include <linux/init.h> 12#include <linux/init.h>
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 887f6a160c58..a4edff4c3be3 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -8,7 +8,6 @@
8 * Copyright (C) 1997 Anton Blanchard (anton@progsoc.uts.edu.au) 8 * Copyright (C) 1997 Anton Blanchard (anton@progsoc.uts.edu.au)
9 */ 9 */
10 10
11#include <linux/config.h>
12#include <linux/errno.h> 11#include <linux/errno.h>
13 12
14#include <asm/head.h> 13#include <asm/head.h>
diff --git a/arch/sparc/kernel/head.S b/arch/sparc/kernel/head.S
index 42d3de59d19b..9a219e8b5ddb 100644
--- a/arch/sparc/kernel/head.S
+++ b/arch/sparc/kernel/head.S
@@ -11,7 +11,6 @@
11 */ 11 */
12 12
13#include <linux/version.h> 13#include <linux/version.h>
14#include <linux/config.h>
15#include <linux/init.h> 14#include <linux/init.h>
16 15
17#include <asm/head.h> 16#include <asm/head.h>
diff --git a/arch/sparc/kernel/idprom.c b/arch/sparc/kernel/idprom.c
index 2e1b0f6e99d4..3a5bad525394 100644
--- a/arch/sparc/kernel/idprom.c
+++ b/arch/sparc/kernel/idprom.c
@@ -5,7 +5,6 @@
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */ 6 */
7 7
8#include <linux/config.h>
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/types.h> 9#include <linux/types.h>
11#include <linux/init.h> 10#include <linux/init.h>
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index ae4c667c906f..8654b446ac9e 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/config.h> 28#include <linux/config.h>
29#include <linux/module.h>
29#include <linux/sched.h> 30#include <linux/sched.h>
30#include <linux/kernel.h> 31#include <linux/kernel.h>
31#include <linux/errno.h> 32#include <linux/errno.h>
@@ -40,6 +41,7 @@
40#include <asm/vaddrs.h> 41#include <asm/vaddrs.h>
41#include <asm/oplib.h> 42#include <asm/oplib.h>
42#include <asm/prom.h> 43#include <asm/prom.h>
44#include <asm/of_device.h>
43#include <asm/sbus.h> 45#include <asm/sbus.h>
44#include <asm/page.h> 46#include <asm/page.h>
45#include <asm/pgalloc.h> 47#include <asm/pgalloc.h>
@@ -143,6 +145,21 @@ void __iomem *sbus_ioremap(struct resource *phyres, unsigned long offset,
143 phyres->start + offset, size, name); 145 phyres->start + offset, size, name);
144} 146}
145 147
148void __iomem *of_ioremap(struct resource *res, unsigned long offset,
149 unsigned long size, char *name)
150{
151 return _sparc_alloc_io(res->flags & 0xF,
152 res->start + offset,
153 size, name);
154}
155EXPORT_SYMBOL(of_ioremap);
156
157void of_iounmap(void __iomem *base, unsigned long size)
158{
159 iounmap(base);
160}
161EXPORT_SYMBOL(of_iounmap);
162
146/* 163/*
147 */ 164 */
148void sbus_iounmap(volatile void __iomem *addr, unsigned long size) 165void sbus_iounmap(volatile void __iomem *addr, unsigned long size)
@@ -208,7 +225,7 @@ _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz)
208 pa &= PAGE_MASK; 225 pa &= PAGE_MASK;
209 sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1); 226 sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1);
210 227
211 return (void __iomem *) (res->start + offset); 228 return (void __iomem *)(unsigned long)(res->start + offset);
212} 229}
213 230
214/* 231/*
@@ -325,7 +342,7 @@ void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp)
325 res->name = sdev->prom_name; 342 res->name = sdev->prom_name;
326 } 343 }
327 344
328 return (void *)res->start; 345 return (void *)(unsigned long)res->start;
329 346
330err_noiommu: 347err_noiommu:
331 release_resource(res); 348 release_resource(res);
@@ -819,7 +836,9 @@ _sparc_io_get_info(char *buf, char **start, off_t fpos, int length, int *eof,
819 if (p + 32 >= e) /* Better than nothing */ 836 if (p + 32 >= e) /* Better than nothing */
820 break; 837 break;
821 if ((nm = r->name) == 0) nm = "???"; 838 if ((nm = r->name) == 0) nm = "???";
822 p += sprintf(p, "%08lx-%08lx: %s\n", r->start, r->end, nm); 839 p += sprintf(p, "%016llx-%016llx: %s\n",
840 (unsigned long long)r->start,
841 (unsigned long long)r->end, nm);
823 } 842 }
824 843
825 return p-buf; 844 return p-buf;
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index aac8af5aae51..cde73327ca96 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -11,7 +11,6 @@
11 * Copyright (C) 1998-2000 Anton Blanchard (anton@samba.org) 11 * Copyright (C) 1998-2000 Anton Blanchard (anton@samba.org)
12 */ 12 */
13 13
14#include <linux/config.h>
15#include <linux/module.h> 14#include <linux/module.h>
16#include <linux/sched.h> 15#include <linux/sched.h>
17#include <linux/ptrace.h> 16#include <linux/ptrace.h>
@@ -192,11 +191,11 @@ int show_interrupts(struct seq_file *p, void *v)
192 } 191 }
193#endif 192#endif
194 seq_printf(p, " %c %s", 193 seq_printf(p, " %c %s",
195 (action->flags & SA_INTERRUPT) ? '+' : ' ', 194 (action->flags & IRQF_DISABLED) ? '+' : ' ',
196 action->name); 195 action->name);
197 for (action=action->next; action; action = action->next) { 196 for (action=action->next; action; action = action->next) {
198 seq_printf(p, ",%s %s", 197 seq_printf(p, ",%s %s",
199 (action->flags & SA_INTERRUPT) ? " +" : "", 198 (action->flags & IRQF_DISABLED) ? " +" : "",
200 action->name); 199 action->name);
201 } 200 }
202 seq_putc(p, '\n'); 201 seq_putc(p, '\n');
@@ -244,7 +243,7 @@ void free_irq(unsigned int irq, void *dev_id)
244 printk("Trying to free free shared IRQ%d\n",irq); 243 printk("Trying to free free shared IRQ%d\n",irq);
245 goto out_unlock; 244 goto out_unlock;
246 } 245 }
247 } else if (action->flags & SA_SHIRQ) { 246 } else if (action->flags & IRQF_SHARED) {
248 printk("Trying to free shared IRQ%d with NULL device ID\n", irq); 247 printk("Trying to free shared IRQ%d with NULL device ID\n", irq);
249 goto out_unlock; 248 goto out_unlock;
250 } 249 }
@@ -396,9 +395,9 @@ int request_fast_irq(unsigned int irq,
396 395
397 action = sparc_irq[cpu_irq].action; 396 action = sparc_irq[cpu_irq].action;
398 if(action) { 397 if(action) {
399 if(action->flags & SA_SHIRQ) 398 if(action->flags & IRQF_SHARED)
400 panic("Trying to register fast irq when already shared.\n"); 399 panic("Trying to register fast irq when already shared.\n");
401 if(irqflags & SA_SHIRQ) 400 if(irqflags & IRQF_SHARED)
402 panic("Trying to register fast irq as shared.\n"); 401 panic("Trying to register fast irq as shared.\n");
403 402
404 /* Anyway, someone already owns it so cannot be made fast. */ 403 /* Anyway, someone already owns it so cannot be made fast. */
@@ -498,11 +497,11 @@ int request_irq(unsigned int irq,
498 actionp = &sparc_irq[cpu_irq].action; 497 actionp = &sparc_irq[cpu_irq].action;
499 action = *actionp; 498 action = *actionp;
500 if (action) { 499 if (action) {
501 if (!(action->flags & SA_SHIRQ) || !(irqflags & SA_SHIRQ)) { 500 if (!(action->flags & IRQF_SHARED) || !(irqflags & IRQF_SHARED)) {
502 ret = -EBUSY; 501 ret = -EBUSY;
503 goto out_unlock; 502 goto out_unlock;
504 } 503 }
505 if ((action->flags & SA_INTERRUPT) != (irqflags & SA_INTERRUPT)) { 504 if ((action->flags & IRQF_DISABLED) != (irqflags & IRQF_DISABLED)) {
506 printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq); 505 printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
507 ret = -EBUSY; 506 ret = -EBUSY;
508 goto out_unlock; 507 goto out_unlock;
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index 80a809478781..bc956c530376 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -129,6 +129,26 @@ static int of_device_resume(struct device * dev)
129 return error; 129 return error;
130} 130}
131 131
132static int node_match(struct device *dev, void *data)
133{
134 struct of_device *op = to_of_device(dev);
135 struct device_node *dp = data;
136
137 return (op->node == dp);
138}
139
140struct of_device *of_find_device_by_node(struct device_node *dp)
141{
142 struct device *dev = bus_find_device(&of_bus_type, NULL,
143 dp, node_match);
144
145 if (dev)
146 return to_of_device(dev);
147
148 return NULL;
149}
150EXPORT_SYMBOL(of_find_device_by_node);
151
132#ifdef CONFIG_PCI 152#ifdef CONFIG_PCI
133struct bus_type ebus_bus_type = { 153struct bus_type ebus_bus_type = {
134 .name = "ebus", 154 .name = "ebus",
@@ -153,10 +173,459 @@ struct bus_type sbus_bus_type = {
153EXPORT_SYMBOL(sbus_bus_type); 173EXPORT_SYMBOL(sbus_bus_type);
154#endif 174#endif
155 175
176struct bus_type of_bus_type = {
177 .name = "of",
178 .match = of_platform_bus_match,
179 .probe = of_device_probe,
180 .remove = of_device_remove,
181 .suspend = of_device_suspend,
182 .resume = of_device_resume,
183};
184EXPORT_SYMBOL(of_bus_type);
185
186static inline u64 of_read_addr(u32 *cell, int size)
187{
188 u64 r = 0;
189 while (size--)
190 r = (r << 32) | *(cell++);
191 return r;
192}
193
194static void __init get_cells(struct device_node *dp,
195 int *addrc, int *sizec)
196{
197 if (addrc)
198 *addrc = of_n_addr_cells(dp);
199 if (sizec)
200 *sizec = of_n_size_cells(dp);
201}
202
203/* Max address size we deal with */
204#define OF_MAX_ADDR_CELLS 4
205
206struct of_bus {
207 const char *name;
208 const char *addr_prop_name;
209 int (*match)(struct device_node *parent);
210 void (*count_cells)(struct device_node *child,
211 int *addrc, int *sizec);
212 u64 (*map)(u32 *addr, u32 *range, int na, int ns, int pna);
213 int (*translate)(u32 *addr, u64 offset, int na);
214 unsigned int (*get_flags)(u32 *addr);
215};
216
217/*
218 * Default translator (generic bus)
219 */
220
221static void of_bus_default_count_cells(struct device_node *dev,
222 int *addrc, int *sizec)
223{
224 get_cells(dev, addrc, sizec);
225}
226
227static u64 of_bus_default_map(u32 *addr, u32 *range, int na, int ns, int pna)
228{
229 u64 cp, s, da;
230
231 cp = of_read_addr(range, na);
232 s = of_read_addr(range + na + pna, ns);
233 da = of_read_addr(addr, na);
234
235 if (da < cp || da >= (cp + s))
236 return OF_BAD_ADDR;
237 return da - cp;
238}
239
240static int of_bus_default_translate(u32 *addr, u64 offset, int na)
241{
242 u64 a = of_read_addr(addr, na);
243 memset(addr, 0, na * 4);
244 a += offset;
245 if (na > 1)
246 addr[na - 2] = a >> 32;
247 addr[na - 1] = a & 0xffffffffu;
248
249 return 0;
250}
251
252static unsigned int of_bus_default_get_flags(u32 *addr)
253{
254 return IORESOURCE_MEM;
255}
256
257
258/*
259 * PCI bus specific translator
260 */
261
262static int of_bus_pci_match(struct device_node *np)
263{
264 return !strcmp(np->type, "pci") || !strcmp(np->type, "pciex");
265}
266
267static void of_bus_pci_count_cells(struct device_node *np,
268 int *addrc, int *sizec)
269{
270 if (addrc)
271 *addrc = 3;
272 if (sizec)
273 *sizec = 2;
274}
275
276static u64 of_bus_pci_map(u32 *addr, u32 *range, int na, int ns, int pna)
277{
278 u64 cp, s, da;
279
280 /* Check address type match */
281 if ((addr[0] ^ range[0]) & 0x03000000)
282 return OF_BAD_ADDR;
283
284 /* Read address values, skipping high cell */
285 cp = of_read_addr(range + 1, na - 1);
286 s = of_read_addr(range + na + pna, ns);
287 da = of_read_addr(addr + 1, na - 1);
288
289 if (da < cp || da >= (cp + s))
290 return OF_BAD_ADDR;
291 return da - cp;
292}
293
294static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
295{
296 return of_bus_default_translate(addr + 1, offset, na - 1);
297}
298
299static unsigned int of_bus_pci_get_flags(u32 *addr)
300{
301 unsigned int flags = 0;
302 u32 w = addr[0];
303
304 switch((w >> 24) & 0x03) {
305 case 0x01:
306 flags |= IORESOURCE_IO;
307 case 0x02: /* 32 bits */
308 case 0x03: /* 64 bits */
309 flags |= IORESOURCE_MEM;
310 }
311 if (w & 0x40000000)
312 flags |= IORESOURCE_PREFETCH;
313 return flags;
314}
315
316/*
317 * SBUS bus specific translator
318 */
319
320static int of_bus_sbus_match(struct device_node *np)
321{
322 return !strcmp(np->name, "sbus") ||
323 !strcmp(np->name, "sbi");
324}
325
326static void of_bus_sbus_count_cells(struct device_node *child,
327 int *addrc, int *sizec)
328{
329 if (addrc)
330 *addrc = 2;
331 if (sizec)
332 *sizec = 1;
333}
334
335static u64 of_bus_sbus_map(u32 *addr, u32 *range, int na, int ns, int pna)
336{
337 return of_bus_default_map(addr, range, na, ns, pna);
338}
339
340static int of_bus_sbus_translate(u32 *addr, u64 offset, int na)
341{
342 return of_bus_default_translate(addr, offset, na);
343}
344
345static unsigned int of_bus_sbus_get_flags(u32 *addr)
346{
347 return IORESOURCE_MEM;
348}
349
350
351/*
352 * Array of bus specific translators
353 */
354
355static struct of_bus of_busses[] = {
356 /* PCI */
357 {
358 .name = "pci",
359 .addr_prop_name = "assigned-addresses",
360 .match = of_bus_pci_match,
361 .count_cells = of_bus_pci_count_cells,
362 .map = of_bus_pci_map,
363 .translate = of_bus_pci_translate,
364 .get_flags = of_bus_pci_get_flags,
365 },
366 /* SBUS */
367 {
368 .name = "sbus",
369 .addr_prop_name = "reg",
370 .match = of_bus_sbus_match,
371 .count_cells = of_bus_sbus_count_cells,
372 .map = of_bus_sbus_map,
373 .translate = of_bus_sbus_translate,
374 .get_flags = of_bus_sbus_get_flags,
375 },
376 /* Default */
377 {
378 .name = "default",
379 .addr_prop_name = "reg",
380 .match = NULL,
381 .count_cells = of_bus_default_count_cells,
382 .map = of_bus_default_map,
383 .translate = of_bus_default_translate,
384 .get_flags = of_bus_default_get_flags,
385 },
386};
387
388static struct of_bus *of_match_bus(struct device_node *np)
389{
390 int i;
391
392 for (i = 0; i < ARRAY_SIZE(of_busses); i ++)
393 if (!of_busses[i].match || of_busses[i].match(np))
394 return &of_busses[i];
395 BUG();
396 return NULL;
397}
398
399static int __init build_one_resource(struct device_node *parent,
400 struct of_bus *bus,
401 struct of_bus *pbus,
402 u32 *addr,
403 int na, int ns, int pna)
404{
405 u32 *ranges;
406 unsigned int rlen;
407 int rone;
408 u64 offset = OF_BAD_ADDR;
409
410 ranges = of_get_property(parent, "ranges", &rlen);
411 if (ranges == NULL || rlen == 0) {
412 offset = of_read_addr(addr, na);
413 memset(addr, 0, pna * 4);
414 goto finish;
415 }
416
417 /* Now walk through the ranges */
418 rlen /= 4;
419 rone = na + pna + ns;
420 for (; rlen >= rone; rlen -= rone, ranges += rone) {
421 offset = bus->map(addr, ranges, na, ns, pna);
422 if (offset != OF_BAD_ADDR)
423 break;
424 }
425 if (offset == OF_BAD_ADDR)
426 return 1;
427
428 memcpy(addr, ranges + na, 4 * pna);
429
430finish:
431 /* Translate it into parent bus space */
432 return pbus->translate(addr, offset, pna);
433}
434
435static void __init build_device_resources(struct of_device *op,
436 struct device *parent)
437{
438 struct of_device *p_op;
439 struct of_bus *bus;
440 int na, ns;
441 int index, num_reg;
442 void *preg;
443
444 if (!parent)
445 return;
446
447 p_op = to_of_device(parent);
448 bus = of_match_bus(p_op->node);
449 bus->count_cells(op->node, &na, &ns);
450
451 preg = of_get_property(op->node, bus->addr_prop_name, &num_reg);
452 if (!preg || num_reg == 0)
453 return;
454
455 /* Convert to num-cells. */
456 num_reg /= 4;
457
458 /* Conver to num-entries. */
459 num_reg /= na + ns;
460
461 for (index = 0; index < num_reg; index++) {
462 struct resource *r = &op->resource[index];
463 u32 addr[OF_MAX_ADDR_CELLS];
464 u32 *reg = (preg + (index * ((na + ns) * 4)));
465 struct device_node *dp = op->node;
466 struct device_node *pp = p_op->node;
467 struct of_bus *pbus;
468 u64 size, result = OF_BAD_ADDR;
469 unsigned long flags;
470 int dna, dns;
471 int pna, pns;
472
473 size = of_read_addr(reg + na, ns);
474 flags = bus->get_flags(reg);
475
476 memcpy(addr, reg, na * 4);
477
478 /* If the immediate parent has no ranges property to apply,
479 * just use a 1<->1 mapping.
480 */
481 if (of_find_property(pp, "ranges", NULL) == NULL) {
482 result = of_read_addr(addr, na);
483 goto build_res;
484 }
485
486 dna = na;
487 dns = ns;
488
489 while (1) {
490 dp = pp;
491 pp = dp->parent;
492 if (!pp) {
493 result = of_read_addr(addr, dna);
494 break;
495 }
496
497 pbus = of_match_bus(pp);
498 pbus->count_cells(dp, &pna, &pns);
499
500 if (build_one_resource(dp, bus, pbus, addr, dna, dns, pna))
501 break;
502
503 dna = pna;
504 dns = pns;
505 bus = pbus;
506 }
507
508 build_res:
509 memset(r, 0, sizeof(*r));
510 if (result != OF_BAD_ADDR) {
511 r->start = result & 0xffffffff;
512 r->end = result + size - 1;
513 r->flags = flags | ((result >> 32ULL) & 0xffUL);
514 } else {
515 r->start = ~0UL;
516 r->end = ~0UL;
517 }
518 r->name = op->node->name;
519 }
520}
521
522static struct of_device * __init scan_one_device(struct device_node *dp,
523 struct device *parent)
524{
525 struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL);
526 struct linux_prom_irqs *intr;
527 int len, i;
528
529 if (!op)
530 return NULL;
531
532 op->node = dp;
533
534 op->clock_freq = of_getintprop_default(dp, "clock-frequency",
535 (25*1000*1000));
536 op->portid = of_getintprop_default(dp, "upa-portid", -1);
537 if (op->portid == -1)
538 op->portid = of_getintprop_default(dp, "portid", -1);
539
540 intr = of_get_property(dp, "intr", &len);
541 if (intr) {
542 op->num_irqs = len / sizeof(struct linux_prom_irqs);
543 for (i = 0; i < op->num_irqs; i++)
544 op->irqs[i] = intr[i].pri;
545 } else {
546 unsigned int *irq = of_get_property(dp, "interrupts", &len);
547
548 if (irq) {
549 op->num_irqs = len / sizeof(unsigned int);
550 for (i = 0; i < op->num_irqs; i++)
551 op->irqs[i] = irq[i];
552 } else {
553 op->num_irqs = 0;
554 }
555 }
556 if (sparc_cpu_model == sun4d) {
557 static int pil_to_sbus[] = {
558 0, 0, 1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 0,
559 };
560 struct device_node *busp = dp->parent;
561 struct linux_prom_registers *regs;
562 int board = of_getintprop_default(busp, "board#", 0);
563 int slot;
564
565 regs = of_get_property(dp, "reg", NULL);
566 slot = regs->which_io;
567
568 for (i = 0; i < op->num_irqs; i++) {
569 int this_irq = op->irqs[i];
570 int sbusl = pil_to_sbus[this_irq];
571
572 if (sbusl)
573 this_irq = (((board + 1) << 5) +
574 (sbusl << 2) +
575 slot);
576
577 op->irqs[i] = this_irq;
578 }
579 }
580
581 build_device_resources(op, parent);
582
583 op->dev.parent = parent;
584 op->dev.bus = &of_bus_type;
585 if (!parent)
586 strcpy(op->dev.bus_id, "root");
587 else
588 strcpy(op->dev.bus_id, dp->path_component_name);
589
590 if (of_device_register(op)) {
591 printk("%s: Could not register of device.\n",
592 dp->full_name);
593 kfree(op);
594 op = NULL;
595 }
596
597 return op;
598}
599
600static void __init scan_tree(struct device_node *dp, struct device *parent)
601{
602 while (dp) {
603 struct of_device *op = scan_one_device(dp, parent);
604
605 if (op)
606 scan_tree(dp->child, &op->dev);
607
608 dp = dp->sibling;
609 }
610}
611
612static void __init scan_of_devices(void)
613{
614 struct device_node *root = of_find_node_by_path("/");
615 struct of_device *parent;
616
617 parent = scan_one_device(root, NULL);
618 if (!parent)
619 return;
620
621 scan_tree(root->child, &parent->dev);
622}
623
156static int __init of_bus_driver_init(void) 624static int __init of_bus_driver_init(void)
157{ 625{
158 int err = 0; 626 int err;
159 627
628 err = bus_register(&of_bus_type);
160#ifdef CONFIG_PCI 629#ifdef CONFIG_PCI
161 if (!err) 630 if (!err)
162 err = bus_register(&ebus_bus_type); 631 err = bus_register(&ebus_bus_type);
@@ -165,7 +634,11 @@ static int __init of_bus_driver_init(void)
165 if (!err) 634 if (!err)
166 err = bus_register(&sbus_bus_type); 635 err = bus_register(&sbus_bus_type);
167#endif 636#endif
168 return 0; 637
638 if (!err)
639 scan_of_devices();
640
641 return err;
169} 642}
170 643
171postcore_initcall(of_bus_driver_init); 644postcore_initcall(of_bus_driver_init);
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index bcfdddd0418a..bfd31aac2df3 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -10,7 +10,6 @@
10 * CP-1200 by Eric Brower. 10 * CP-1200 by Eric Brower.
11 */ 11 */
12 12
13#include <linux/config.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/init.h> 15#include <linux/init.h>
@@ -746,7 +745,7 @@ void __init pci_time_init(void)
746 writel (PCI_COUNTER_IRQ_SET(timer_irq, 0), 745 writel (PCI_COUNTER_IRQ_SET(timer_irq, 0),
747 pcic->pcic_regs+PCI_COUNTER_IRQ); 746 pcic->pcic_regs+PCI_COUNTER_IRQ);
748 irq = request_irq(timer_irq, pcic_timer_handler, 747 irq = request_irq(timer_irq, pcic_timer_handler,
749 (SA_INTERRUPT | SA_STATIC_ALLOC), "timer", NULL); 748 (IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);
750 if (irq) { 749 if (irq) {
751 prom_printf("time_init: unable to attach IRQ%d\n", timer_irq); 750 prom_printf("time_init: unable to attach IRQ%d\n", timer_irq);
752 prom_halt(); 751 prom_halt();
@@ -860,7 +859,7 @@ char * __init pcibios_setup(char *str)
860} 859}
861 860
862void pcibios_align_resource(void *data, struct resource *res, 861void pcibios_align_resource(void *data, struct resource *res,
863 unsigned long size, unsigned long align) 862 resource_size_t size, resource_size_t align)
864{ 863{
865} 864}
866 865
diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
index 118cac84a0f5..89a28cc018c9 100644
--- a/arch/sparc/kernel/process.c
+++ b/arch/sparc/kernel/process.c
@@ -22,7 +22,6 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/user.h> 23#include <linux/user.h>
24#include <linux/a.out.h> 24#include <linux/a.out.h>
25#include <linux/config.h>
26#include <linux/smp.h> 25#include <linux/smp.h>
27#include <linux/smp_lock.h> 26#include <linux/smp_lock.h>
28#include <linux/reboot.h> 27#include <linux/reboot.h>
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index 946ce6d15819..4b06dcb00ebd 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -190,6 +190,36 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
190} 190}
191EXPORT_SYMBOL(of_getintprop_default); 191EXPORT_SYMBOL(of_getintprop_default);
192 192
193int of_n_addr_cells(struct device_node *np)
194{
195 int* ip;
196 do {
197 if (np->parent)
198 np = np->parent;
199 ip = of_get_property(np, "#address-cells", NULL);
200 if (ip != NULL)
201 return *ip;
202 } while (np->parent);
203 /* No #address-cells property for the root node, default to 2 */
204 return 2;
205}
206EXPORT_SYMBOL(of_n_addr_cells);
207
208int of_n_size_cells(struct device_node *np)
209{
210 int* ip;
211 do {
212 if (np->parent)
213 np = np->parent;
214 ip = of_get_property(np, "#size-cells", NULL);
215 if (ip != NULL)
216 return *ip;
217 } while (np->parent);
218 /* No #size-cells property for the root node, default to 1 */
219 return 1;
220}
221EXPORT_SYMBOL(of_n_size_cells);
222
193int of_set_property(struct device_node *dp, const char *name, void *val, int len) 223int of_set_property(struct device_node *dp, const char *name, void *val, int len)
194{ 224{
195 struct property **prevp; 225 struct property **prevp;
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index a893a9cc9534..8606ef4e52e9 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -19,7 +19,6 @@
19#include <linux/a.out.h> 19#include <linux/a.out.h>
20#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/config.h>
23#include <linux/fs.h> 22#include <linux/fs.h>
24#include <linux/seq_file.h> 23#include <linux/seq_file.h>
25#include <linux/syscalls.h> 24#include <linux/syscalls.h>
@@ -496,7 +495,7 @@ static int __init topology_init(void)
496 if (!p) 495 if (!p)
497 err = -ENOMEM; 496 err = -ENOMEM;
498 else 497 else
499 register_cpu(p, i, NULL); 498 register_cpu(p, i);
500 } 499 }
501 500
502 return err; 501 return err;
diff --git a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
index 0748d8147bbf..c9301b9143ca 100644
--- a/arch/sparc/kernel/signal.c
+++ b/arch/sparc/kernel/signal.c
@@ -7,7 +7,6 @@
7 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) 7 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
8 */ 8 */
9 9
10#include <linux/config.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/signal.h> 12#include <linux/signal.h>
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index fd7deabf9982..5fb987fc3d63 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -9,7 +9,6 @@
9#define EXPORT_SYMTAB_STROPS 9#define EXPORT_SYMTAB_STROPS
10#define PROMLIB_INTERNAL 10#define PROMLIB_INTERNAL
11 11
12#include <linux/config.h>
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/init.h> 13#include <linux/init.h>
15#include <linux/smp.h> 14#include <linux/smp.h>
diff --git a/arch/sparc/kernel/sun4c_irq.c b/arch/sparc/kernel/sun4c_irq.c
index 0f2d8d9cbdba..4be2c86ea540 100644
--- a/arch/sparc/kernel/sun4c_irq.c
+++ b/arch/sparc/kernel/sun4c_irq.c
@@ -9,7 +9,6 @@
9 * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk) 9 * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk)
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/errno.h> 12#include <linux/errno.h>
14#include <linux/linkage.h> 13#include <linux/linkage.h>
15#include <linux/kernel_stat.h> 14#include <linux/kernel_stat.h>
@@ -180,7 +179,7 @@ static void __init sun4c_init_timers(irqreturn_t (*counter_fn)(int, void *, stru
180 179
181 irq = request_irq(TIMER_IRQ, 180 irq = request_irq(TIMER_IRQ,
182 counter_fn, 181 counter_fn,
183 (SA_INTERRUPT | SA_STATIC_ALLOC), 182 (IRQF_DISABLED | SA_STATIC_ALLOC),
184 "timer", NULL); 183 "timer", NULL);
185 if (irq) { 184 if (irq) {
186 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ); 185 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index 9c30e35c88f7..74eed9775ac0 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -6,7 +6,6 @@
6 * Heavily based on arch/sparc/kernel/irq.c. 6 * Heavily based on arch/sparc/kernel/irq.c.
7 */ 7 */
8 8
9#include <linux/config.h>
10#include <linux/errno.h> 9#include <linux/errno.h>
11#include <linux/linkage.h> 10#include <linux/linkage.h>
12#include <linux/kernel_stat.h> 11#include <linux/kernel_stat.h>
@@ -108,13 +107,13 @@ found_it: seq_printf(p, "%3d: ", i);
108 kstat_cpu(cpu_logical_map(x)).irqs[i]); 107 kstat_cpu(cpu_logical_map(x)).irqs[i]);
109#endif 108#endif
110 seq_printf(p, "%c %s", 109 seq_printf(p, "%c %s",
111 (action->flags & SA_INTERRUPT) ? '+' : ' ', 110 (action->flags & IRQF_DISABLED) ? '+' : ' ',
112 action->name); 111 action->name);
113 action = action->next; 112 action = action->next;
114 for (;;) { 113 for (;;) {
115 for (; action; action = action->next) { 114 for (; action; action = action->next) {
116 seq_printf(p, ",%s %s", 115 seq_printf(p, ",%s %s",
117 (action->flags & SA_INTERRUPT) ? " +" : "", 116 (action->flags & IRQF_DISABLED) ? " +" : "",
118 action->name); 117 action->name);
119 } 118 }
120 if (!sbusl) break; 119 if (!sbusl) break;
@@ -161,7 +160,7 @@ void sun4d_free_irq(unsigned int irq, void *dev_id)
161 printk("Trying to free free shared IRQ%d\n",irq); 160 printk("Trying to free free shared IRQ%d\n",irq);
162 goto out_unlock; 161 goto out_unlock;
163 } 162 }
164 } else if (action->flags & SA_SHIRQ) { 163 } else if (action->flags & IRQF_SHARED) {
165 printk("Trying to free shared IRQ%d with NULL device ID\n", irq); 164 printk("Trying to free shared IRQ%d with NULL device ID\n", irq);
166 goto out_unlock; 165 goto out_unlock;
167 } 166 }
@@ -299,13 +298,13 @@ int sun4d_request_irq(unsigned int irq,
299 action = *actionp; 298 action = *actionp;
300 299
301 if (action) { 300 if (action) {
302 if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) { 301 if ((action->flags & IRQF_SHARED) && (irqflags & IRQF_SHARED)) {
303 for (tmp = action; tmp->next; tmp = tmp->next); 302 for (tmp = action; tmp->next; tmp = tmp->next);
304 } else { 303 } else {
305 ret = -EBUSY; 304 ret = -EBUSY;
306 goto out_unlock; 305 goto out_unlock;
307 } 306 }
308 if ((action->flags & SA_INTERRUPT) ^ (irqflags & SA_INTERRUPT)) { 307 if ((action->flags & IRQF_DISABLED) ^ (irqflags & IRQF_DISABLED)) {
309 printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq); 308 printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
310 ret = -EBUSY; 309 ret = -EBUSY;
311 goto out_unlock; 310 goto out_unlock;
@@ -491,7 +490,7 @@ static void __init sun4d_init_timers(irqreturn_t (*counter_fn)(int, void *, stru
491 490
492 irq = request_irq(TIMER_IRQ, 491 irq = request_irq(TIMER_IRQ,
493 counter_fn, 492 counter_fn,
494 (SA_INTERRUPT | SA_STATIC_ALLOC), 493 (IRQF_DISABLED | SA_STATIC_ALLOC),
495 "timer", NULL); 494 "timer", NULL);
496 if (irq) { 495 if (irq) {
497 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ); 496 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
diff --git a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c
index a296c13ac18f..7cefa301efea 100644
--- a/arch/sparc/kernel/sun4m_irq.c
+++ b/arch/sparc/kernel/sun4m_irq.c
@@ -9,7 +9,6 @@
9 * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk) 9 * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk)
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/errno.h> 12#include <linux/errno.h>
14#include <linux/linkage.h> 13#include <linux/linkage.h>
15#include <linux/kernel_stat.h> 14#include <linux/kernel_stat.h>
@@ -279,7 +278,7 @@ static void __init sun4m_init_timers(irqreturn_t (*counter_fn)(int, void *, stru
279 278
280 irq = request_irq(TIMER_IRQ, 279 irq = request_irq(TIMER_IRQ,
281 counter_fn, 280 counter_fn,
282 (SA_INTERRUPT | SA_STATIC_ALLOC), 281 (IRQF_DISABLED | SA_STATIC_ALLOC),
283 "timer", NULL); 282 "timer", NULL);
284 if (irq) { 283 if (irq) {
285 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ); 284 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
diff --git a/arch/sparc/kernel/sys_solaris.c b/arch/sparc/kernel/sys_solaris.c
index fb7578554c78..c09afd96dd9c 100644
--- a/arch/sparc/kernel/sys_solaris.c
+++ b/arch/sparc/kernel/sys_solaris.c
@@ -4,7 +4,6 @@
4 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx) 4 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
5 */ 5 */
6 6
7#include <linux/config.h>
8#include <linux/sched.h> 7#include <linux/sched.h>
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/string.h> 9#include <linux/string.h>
diff --git a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
index 288de276d9ff..aa0fb2efb615 100644
--- a/arch/sparc/kernel/sys_sunos.c
+++ b/arch/sparc/kernel/sys_sunos.c
@@ -196,7 +196,7 @@ asmlinkage int sunos_brk(unsigned long brk)
196 * simple, it hopefully works in most obvious cases.. Easy to 196 * simple, it hopefully works in most obvious cases.. Easy to
197 * fool it, but this should catch most mistakes. 197 * fool it, but this should catch most mistakes.
198 */ 198 */
199 freepages = get_page_cache_size(); 199 freepages = global_page_state(NR_FILE_PAGES);
200 freepages >>= 1; 200 freepages >>= 1;
201 freepages += nr_free_pages(); 201 freepages += nr_free_pages();
202 freepages += nr_swap_pages; 202 freepages += nr_swap_pages;
diff --git a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
index 2856551bddf1..10df38eeae08 100644
--- a/arch/sparc/kernel/systbls.S
+++ b/arch/sparc/kernel/systbls.S
@@ -9,7 +9,6 @@
9 * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu) 9 * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu)
10 */ 10 */
11 11
12#include <linux/config.h>
13 12
14 .data 13 .data
15 .align 4 14 .align 4
diff --git a/arch/sparc/kernel/tick14.c b/arch/sparc/kernel/tick14.c
index 591547af4c65..d3b4daac705f 100644
--- a/arch/sparc/kernel/tick14.c
+++ b/arch/sparc/kernel/tick14.c
@@ -74,7 +74,7 @@ void claim_ticker14(irqreturn_t (*handler)(int, void *, struct pt_regs *),
74 74
75 if (!request_irq(irq_nr, 75 if (!request_irq(irq_nr,
76 handler, 76 handler,
77 (SA_INTERRUPT | SA_STATIC_ALLOC), 77 (IRQF_DISABLED | SA_STATIC_ALLOC),
78 "counter14", 78 "counter14",
79 NULL)) { 79 NULL)) {
80 install_linux_ticker(); 80 install_linux_ticker();
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index 7dadcdb4ca42..04eb1eab6e3e 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -15,7 +15,6 @@
15 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96 15 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
16 * "A Kernel Model for Precision Timekeeping" by Dave Mills 16 * "A Kernel Model for Precision Timekeeping" by Dave Mills
17 */ 17 */
18#include <linux/config.h>
19#include <linux/errno.h> 18#include <linux/errno.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/sched.h> 20#include <linux/sched.h>
@@ -42,6 +41,7 @@
42#include <asm/sun4paddr.h> 41#include <asm/sun4paddr.h>
43#include <asm/page.h> 42#include <asm/page.h>
44#include <asm/pcic.h> 43#include <asm/pcic.h>
44#include <asm/of_device.h>
45 45
46extern unsigned long wall_jiffies; 46extern unsigned long wall_jiffies;
47 47
@@ -273,83 +273,31 @@ static __inline__ void sun4_clock_probe(void)
273#endif 273#endif
274} 274}
275 275
276/* Probe for the mostek real time clock chip. */ 276static int __devinit clock_probe(struct of_device *op, const struct of_device_id *match)
277static __inline__ void clock_probe(void)
278{ 277{
279 struct linux_prom_registers clk_reg[2]; 278 struct device_node *dp = op->node;
280 char model[128]; 279 char *model = of_get_property(dp, "model", NULL);
281 register int node, cpuunit, bootbus;
282 struct resource r;
283
284 cpuunit = bootbus = 0;
285 memset(&r, 0, sizeof(r));
286
287 /* Determine the correct starting PROM node for the probe. */
288 node = prom_getchild(prom_root_node);
289 switch (sparc_cpu_model) {
290 case sun4c:
291 break;
292 case sun4m:
293 node = prom_getchild(prom_searchsiblings(node, "obio"));
294 break;
295 case sun4d:
296 node = prom_getchild(bootbus = prom_searchsiblings(prom_getchild(cpuunit = prom_searchsiblings(node, "cpu-unit")), "bootbus"));
297 break;
298 default:
299 prom_printf("CLOCK: Unsupported architecture!\n");
300 prom_halt();
301 }
302 280
303 /* Find the PROM node describing the real time clock. */ 281 if (!model)
304 sp_clock_typ = MSTK_INVALID; 282 return -ENODEV;
305 node = prom_searchsiblings(node,"eeprom");
306 if (!node) {
307 prom_printf("CLOCK: No clock found!\n");
308 prom_halt();
309 }
310 283
311 /* Get the model name and setup everything up. */ 284 if (!strcmp(model, "mk48t02")) {
312 model[0] = '\0';
313 prom_getstring(node, "model", model, sizeof(model));
314 if (strcmp(model, "mk48t02") == 0) {
315 sp_clock_typ = MSTK48T02; 285 sp_clock_typ = MSTK48T02;
316 if (prom_getproperty(node, "reg", (char *) clk_reg, sizeof(clk_reg)) == -1) { 286
317 prom_printf("clock_probe: FAILED!\n");
318 prom_halt();
319 }
320 if (sparc_cpu_model == sun4d)
321 prom_apply_generic_ranges (bootbus, cpuunit, clk_reg, 1);
322 else
323 prom_apply_obio_ranges(clk_reg, 1);
324 /* Map the clock register io area read-only */ 287 /* Map the clock register io area read-only */
325 r.flags = clk_reg[0].which_io; 288 mstk48t02_regs = of_ioremap(&op->resource[0], 0,
326 r.start = clk_reg[0].phys_addr; 289 sizeof(struct mostek48t02),
327 mstk48t02_regs = sbus_ioremap(&r, 0, 290 "mk48t02");
328 sizeof(struct mostek48t02), "mk48t02");
329 mstk48t08_regs = NULL; /* To catch weirdness */ 291 mstk48t08_regs = NULL; /* To catch weirdness */
330 } else if (strcmp(model, "mk48t08") == 0) { 292 } else if (!strcmp(model, "mk48t08")) {
331 sp_clock_typ = MSTK48T08; 293 sp_clock_typ = MSTK48T08;
332 if(prom_getproperty(node, "reg", (char *) clk_reg, 294 mstk48t08_regs = of_ioremap(&op->resource[0], 0,
333 sizeof(clk_reg)) == -1) { 295 sizeof(struct mostek48t08),
334 prom_printf("clock_probe: FAILED!\n"); 296 "mk48t08");
335 prom_halt();
336 }
337 if (sparc_cpu_model == sun4d)
338 prom_apply_generic_ranges (bootbus, cpuunit, clk_reg, 1);
339 else
340 prom_apply_obio_ranges(clk_reg, 1);
341 /* Map the clock register io area read-only */
342 /* XXX r/o attribute is somewhere in r.flags */
343 r.flags = clk_reg[0].which_io;
344 r.start = clk_reg[0].phys_addr;
345 mstk48t08_regs = sbus_ioremap(&r, 0,
346 sizeof(struct mostek48t08), "mk48t08");
347 297
348 mstk48t02_regs = &mstk48t08_regs->regs; 298 mstk48t02_regs = &mstk48t08_regs->regs;
349 } else { 299 } else
350 prom_printf("CLOCK: Unknown model name '%s'\n",model); 300 return -ENODEV;
351 prom_halt();
352 }
353 301
354 /* Report a low battery voltage condition. */ 302 /* Report a low battery voltage condition. */
355 if (has_low_battery()) 303 if (has_low_battery())
@@ -358,6 +306,28 @@ static __inline__ void clock_probe(void)
358 /* Kick start the clock if it is completely stopped. */ 306 /* Kick start the clock if it is completely stopped. */
359 if (mostek_read(mstk48t02_regs + MOSTEK_SEC) & MSTK_STOP) 307 if (mostek_read(mstk48t02_regs + MOSTEK_SEC) & MSTK_STOP)
360 kick_start_clock(); 308 kick_start_clock();
309
310 return 0;
311}
312
313static struct of_device_id clock_match[] = {
314 {
315 .name = "eeprom",
316 },
317 {},
318};
319
320static struct of_platform_driver clock_driver = {
321 .name = "clock",
322 .match_table = clock_match,
323 .probe = clock_probe,
324};
325
326
327/* Probe for the mostek real time clock chip. */
328static void clock_init(void)
329{
330 of_register_driver(&clock_driver, &of_bus_type);
361} 331}
362 332
363void __init sbus_time_init(void) 333void __init sbus_time_init(void)
@@ -376,7 +346,7 @@ void __init sbus_time_init(void)
376 if (ARCH_SUN4) 346 if (ARCH_SUN4)
377 sun4_clock_probe(); 347 sun4_clock_probe();
378 else 348 else
379 clock_probe(); 349 clock_init();
380 350
381 sparc_init_timers(timer_interrupt); 351 sparc_init_timers(timer_interrupt);
382 352
diff --git a/arch/sparc/kernel/traps.c b/arch/sparc/kernel/traps.c
index 41d45c298fb2..6a70d215fd04 100644
--- a/arch/sparc/kernel/traps.c
+++ b/arch/sparc/kernel/traps.c
@@ -9,7 +9,6 @@
9 * I hate traps on the sparc, grrr... 9 * I hate traps on the sparc, grrr...
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/sched.h> /* for jiffies */ 12#include <linux/sched.h> /* for jiffies */
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/kallsyms.h> 14#include <linux/kallsyms.h>
diff --git a/arch/sparc/lib/atomic.S b/arch/sparc/lib/atomic.S
index f48ad0c4dadb..178cbb8ae1b9 100644
--- a/arch/sparc/lib/atomic.S
+++ b/arch/sparc/lib/atomic.S
@@ -3,7 +3,6 @@
3 * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu) 3 * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
4 */ 4 */
5 5
6#include <linux/config.h>
7#include <asm/ptrace.h> 6#include <asm/ptrace.h>
8#include <asm/psr.h> 7#include <asm/psr.h>
9 8
diff --git a/arch/sparc/lib/bitops.S b/arch/sparc/lib/bitops.S
index 3e9399769075..cb7fb66a40c8 100644
--- a/arch/sparc/lib/bitops.S
+++ b/arch/sparc/lib/bitops.S
@@ -3,7 +3,6 @@
3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
4 */ 4 */
5 5
6#include <linux/config.h>
7#include <asm/ptrace.h> 6#include <asm/ptrace.h>
8#include <asm/psr.h> 7#include <asm/psr.h>
9 8
diff --git a/arch/sparc/lib/rwsem.S b/arch/sparc/lib/rwsem.S
index e7578dc600b8..20657744c864 100644
--- a/arch/sparc/lib/rwsem.S
+++ b/arch/sparc/lib/rwsem.S
@@ -4,7 +4,6 @@
4 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) 4 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
5 */ 5 */
6 6
7#include <linux/config.h>
8#include <asm/ptrace.h> 7#include <asm/ptrace.h>
9#include <asm/psr.h> 8#include <asm/psr.h>
10 9
diff --git a/arch/sparc/mm/btfixup.c b/arch/sparc/mm/btfixup.c
index f147a44c9780..ec4231c2855a 100644
--- a/arch/sparc/mm/btfixup.c
+++ b/arch/sparc/mm/btfixup.c
@@ -6,7 +6,6 @@
6 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 6 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 */ 7 */
8 8
9#include <linux/config.h>
10#include <linux/kernel.h> 9#include <linux/kernel.h>
11#include <linux/init.h> 10#include <linux/init.h>
12#include <asm/btfixup.h> 11#include <asm/btfixup.h>
diff --git a/arch/sparc/mm/extable.c b/arch/sparc/mm/extable.c
index c9845c71f426..16cc28935e39 100644
--- a/arch/sparc/mm/extable.c
+++ b/arch/sparc/mm/extable.c
@@ -2,7 +2,6 @@
2 * linux/arch/sparc/mm/extable.c 2 * linux/arch/sparc/mm/extable.c
3 */ 3 */
4 4
5#include <linux/config.h>
6#include <linux/module.h> 5#include <linux/module.h>
7#include <asm/uaccess.h> 6#include <asm/uaccess.h>
8 7
diff --git a/arch/sparc/mm/hypersparc.S b/arch/sparc/mm/hypersparc.S
index a231cca37216..d29cc24c5bba 100644
--- a/arch/sparc/mm/hypersparc.S
+++ b/arch/sparc/mm/hypersparc.S
@@ -10,7 +10,6 @@
10#include <asm/asi.h> 10#include <asm/asi.h>
11#include <asm/page.h> 11#include <asm/page.h>
12#include <asm/pgtsrmmu.h> 12#include <asm/pgtsrmmu.h>
13#include <linux/config.h>
14#include <linux/init.h> 13#include <linux/init.h>
15 14
16 .text 15 .text
diff --git a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c
index cfa7d3456634..c85ddf312747 100644
--- a/arch/sparc/mm/init.c
+++ b/arch/sparc/mm/init.c
@@ -7,7 +7,6 @@
7 * Copyright (C) 2000 Anton Blanchard (anton@samba.org) 7 * Copyright (C) 2000 Anton Blanchard (anton@samba.org)
8 */ 8 */
9 9
10#include <linux/config.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/signal.h> 11#include <linux/signal.h>
13#include <linux/sched.h> 12#include <linux/sched.h>
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index eefffa1dc5de..42c1c700c0a7 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -4,7 +4,6 @@
4 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 4 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 */ 5 */
6 6
7#include <linux/config.h>
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/init.h> 8#include <linux/init.h>
10#include <linux/slab.h> 9#include <linux/slab.h>
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 7215849db392..be042efd1ba4 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -7,7 +7,6 @@
7 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 7 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 */ 8 */
9 9
10#include <linux/config.h>
11#include <linux/kernel.h> 10#include <linux/kernel.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 58c65cc8d0d3..16e13f663ab0 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -8,7 +8,6 @@
8 * Copyright (C) 1999,2000 Anton Blanchard (anton@samba.org) 8 * Copyright (C) 1999,2000 Anton Blanchard (anton@samba.org)
9 */ 9 */
10 10
11#include <linux/config.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index 49f28c1bdc6d..7fdddf3c7e16 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -10,7 +10,6 @@
10 10
11#define NR_TASK_BUCKETS 512 11#define NR_TASK_BUCKETS 512
12 12
13#include <linux/config.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/mm.h> 14#include <linux/mm.h>
16#include <linux/init.h> 15#include <linux/init.h>
diff --git a/arch/sparc/mm/swift.S b/arch/sparc/mm/swift.S
index cd90f3fdc4e7..9f4cd396a0fa 100644
--- a/arch/sparc/mm/swift.S
+++ b/arch/sparc/mm/swift.S
@@ -4,7 +4,6 @@
4 * Copyright (C) 1999 David S. Miller (davem@redhat.com) 4 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
5 */ 5 */
6 6
7#include <linux/config.h>
8#include <asm/psr.h> 7#include <asm/psr.h>
9#include <asm/asi.h> 8#include <asm/asi.h>
10#include <asm/page.h> 9#include <asm/page.h>
diff --git a/arch/sparc/mm/tsunami.S b/arch/sparc/mm/tsunami.S
index 697af617594a..4988e6a310bb 100644
--- a/arch/sparc/mm/tsunami.S
+++ b/arch/sparc/mm/tsunami.S
@@ -4,7 +4,6 @@
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) 4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 */ 5 */
6 6
7#include <linux/config.h>
8#include <asm/ptrace.h> 7#include <asm/ptrace.h>
9#include <asm/asm-offsets.h> 8#include <asm/asm-offsets.h>
10#include <asm/psr.h> 9#include <asm/psr.h>
diff --git a/arch/sparc/mm/viking.S b/arch/sparc/mm/viking.S
index 3cbd6de18dde..754c622548a5 100644
--- a/arch/sparc/mm/viking.S
+++ b/arch/sparc/mm/viking.S
@@ -6,7 +6,6 @@
6 * Copyright (C) 1999 Pavel Semerad (semerad@ss1000.ms.mff.cuni.cz) 6 * Copyright (C) 1999 Pavel Semerad (semerad@ss1000.ms.mff.cuni.cz)
7 */ 7 */
8 8
9#include <linux/config.h>
10#include <asm/ptrace.h> 9#include <asm/ptrace.h>
11#include <asm/psr.h> 10#include <asm/psr.h>
12#include <asm/asm-offsets.h> 11#include <asm/asm-offsets.h>
diff --git a/arch/sparc/prom/init.c b/arch/sparc/prom/init.c
index b83409c81916..50abfb1b880e 100644
--- a/arch/sparc/prom/init.c
+++ b/arch/sparc/prom/init.c
@@ -6,7 +6,6 @@
6 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 6 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 */ 7 */
8 8
9#include <linux/config.h>
10#include <linux/kernel.h> 9#include <linux/kernel.h>
11#include <linux/init.h> 10#include <linux/init.h>
12 11
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c
index c20e5309f8aa..b0c0f9c4fc14 100644
--- a/arch/sparc/prom/memory.c
+++ b/arch/sparc/prom/memory.c
@@ -6,7 +6,6 @@
6 * Copyright (C) 1997 Michael A. Griffith (grif@acm.org) 6 * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
7 */ 7 */
8 8
9#include <linux/config.h>
10#include <linux/kernel.h> 9#include <linux/kernel.h>
11#include <linux/init.h> 10#include <linux/init.h>
12 11
diff --git a/arch/sparc/prom/misc.c b/arch/sparc/prom/misc.c
index c840c2062342..1942c7c05cb1 100644
--- a/arch/sparc/prom/misc.c
+++ b/arch/sparc/prom/misc.c
@@ -5,7 +5,6 @@
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */ 6 */
7 7
8#include <linux/config.h>
9#include <linux/types.h> 8#include <linux/types.h>
10#include <linux/kernel.h> 9#include <linux/kernel.h>
11#include <linux/sched.h> 10#include <linux/sched.h>