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)
8 #include <linux/kernel.h>
9 #include <linux/malloc.h>
12 #include <asm/oplib.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
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)
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
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) |
54 linux_cpus
[i
].mid
= mid
;
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
;
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
);
88 prom_printf("starfire_hookup: No memory, this is insane.\n");
91 treg_base
= 0x100fc000000UL
;
92 hwmid
= ((upaid
& 0x3c) << 1) |
93 ((upaid
& 0x40) >> 4) |
96 treg_base
+= (hwmid
<< 33UL);
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;
112 unsigned int starfire_translate(unsigned long imap
,
115 struct starfire_irqinfo
*p
;
116 unsigned int bus_hwmid
;
119 bus_hwmid
= (((unsigned long)imap
) >> 33) & 0x7f;
120 for(p
= sflist
; p
!= NULL
; p
= p
->next
)
121 if(p
->hwmid
== bus_hwmid
)
124 prom_printf("XFIRE: Cannot find irqinfo for imap %016lx\n",
125 ((unsigned long)imap
));
128 for(i
= 0; i
< 32; i
++) {
129 if(p
->imap_slots
[i
] == imap
||
130 p
->imap_slots
[i
] == 0UL)
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) |
144 upa_writel(upaid
, p
->tregs
[i
]);