- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / arch / sparc64 / kernel / starfire.c
blob6899e7c4a12eb370fc93214168aa81e5cb257491
1 /* $Id: starfire.c,v 1.8 2000/10/27 18:36:47 anton Exp $
2 * starfire.c: Starfire/E10000 support.
4 * Copyright (C) 1998 David S. Miller (davem@redhat.com)
5 * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
6 */
8 #include <linux/kernel.h>
9 #include <linux/malloc.h>
11 #include <asm/page.h>
12 #include <asm/oplib.h>
13 #include <asm/smp.h>
14 #include <asm/upa.h>
15 #include <asm/starfire.h>
18 * A few places around the kernel check this to see if
19 * they need to call us to do things in a Starfire specific
20 * way.
22 int this_is_starfire = 0;
24 void check_if_starfire(void)
26 int ssnode = prom_finddevice("/ssp-serial");
27 if(ssnode != 0 && ssnode != -1)
28 this_is_starfire = 1;
31 void starfire_cpu_setup(void)
33 if (this_is_starfire) {
35 * We do this in starfire_translate and xcall_deliver. When we fix our cpu
36 * arrays to support > 64 processors we can use the real upaid instead
37 * of the logical cpuid in __cpu_number_map etc, then we can get rid of
38 * the translations everywhere. - Anton
40 #if 0
41 int i;
44 * Now must fixup cpu MIDs. OBP gave us a logical
45 * linear cpuid number, not the real upaid.
47 for(i = 0; i < linux_num_cpus; i++) {
48 unsigned int mid = linux_cpus[i].mid;
50 mid = (((mid & 0x3c) << 1) |
51 ((mid & 0x40) >> 4) |
52 (mid & 0x3));
54 linux_cpus[i].mid = mid;
56 #endif
60 int starfire_hard_smp_processor_id(void)
62 return upa_readl(0x1fff40000d0UL);
66 * Each Starfire board has 32 registers which perform translation
67 * and delivery of traditional interrupt packets into the extended
68 * Starfire hardware format. Essentially UPAID's now have 2 more
69 * bits than in all previous Sun5 systems.
71 struct starfire_irqinfo {
72 unsigned long imap_slots[32];
73 unsigned long tregs[32];
74 struct starfire_irqinfo *next;
75 int upaid, hwmid;
78 static struct starfire_irqinfo *sflist = NULL;
80 /* Beam me up Scott(McNeil)y... */
81 void *starfire_hookup(int upaid)
83 struct starfire_irqinfo *p;
84 unsigned long treg_base, hwmid, i;
86 p = kmalloc(sizeof(*p), GFP_KERNEL);
87 if(!p) {
88 prom_printf("starfire_hookup: No memory, this is insane.\n");
89 prom_halt();
91 treg_base = 0x100fc000000UL;
92 hwmid = ((upaid & 0x3c) << 1) |
93 ((upaid & 0x40) >> 4) |
94 (upaid & 0x3);
95 p->hwmid = hwmid;
96 treg_base += (hwmid << 33UL);
97 treg_base += 0x200UL;
98 for(i = 0; i < 32; i++) {
99 p->imap_slots[i] = 0UL;
100 p->tregs[i] = treg_base + (i * 0x10UL);
101 /* Lets play it safe and not overwrite existing mappings */
102 if (upa_readl(p->tregs[i]) != 0)
103 p->imap_slots[i] = 0xdeadbeaf;
105 p->upaid = upaid;
106 p->next = sflist;
107 sflist = p;
109 return (void *) p;
112 unsigned int starfire_translate(unsigned long imap,
113 unsigned int upaid)
115 struct starfire_irqinfo *p;
116 unsigned int bus_hwmid;
117 unsigned int i;
119 bus_hwmid = (((unsigned long)imap) >> 33) & 0x7f;
120 for(p = sflist; p != NULL; p = p->next)
121 if(p->hwmid == bus_hwmid)
122 break;
123 if(p == NULL) {
124 prom_printf("XFIRE: Cannot find irqinfo for imap %016lx\n",
125 ((unsigned long)imap));
126 prom_halt();
128 for(i = 0; i < 32; i++) {
129 if(p->imap_slots[i] == imap ||
130 p->imap_slots[i] == 0UL)
131 break;
133 if(i == 32) {
134 printk("starfire_translate: Are you kidding me?\n");
135 panic("Lucy in the sky....");
137 p->imap_slots[i] = imap;
139 /* map to real upaid */
140 upaid = (((upaid & 0x3c) << 1) |
141 ((upaid & 0x40) >> 4) |
142 (upaid & 0x3));
144 upa_writel(upaid, p->tregs[i]);
146 return i;