1 | /* motorola.h |
---|
2 | * |
---|
3 | * This include file describe the data structure and the functions implemented |
---|
4 | * by rtems to identify motorola boards. |
---|
5 | * |
---|
6 | * CopyRight (C) 1999 valette@crf.canon.fr |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in found in the file LICENSE in this distribution or at |
---|
10 | * http://www.OARcorp.com/rtems/license.html. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | |
---|
16 | #include <bsp/motorola.h> |
---|
17 | #include <rtems/bspIo.h> |
---|
18 | #include <libcpu/io.h> |
---|
19 | #include <string.h> |
---|
20 | |
---|
21 | |
---|
22 | /* |
---|
23 | ** Board-specific table that maps interrupt names to onboard pci |
---|
24 | ** peripherals as well as local pci busses. This table is used at |
---|
25 | ** bspstart() to configure the interrupt name & pin for all devices that |
---|
26 | ** do not have it already specified. If the device is already |
---|
27 | ** configured, we leave it alone but sanity check & print a warning if |
---|
28 | ** we don't know about the pin/line the card gives us. |
---|
29 | ** |
---|
30 | ** bus = the bus number of the slot/device in question |
---|
31 | ** |
---|
32 | ** slot : |
---|
33 | ** |
---|
34 | ** If slot != -1, it indicates a device on the given bus in that slot |
---|
35 | ** is to use one of the listed interrupt names given an interrupt pin. |
---|
36 | ** |
---|
37 | ** If slot == -1, it means devices on this bus can occupy any slot- |
---|
38 | ** and for pci, this means the particular interrupt pin that the |
---|
39 | ** device signals is therefore dependent on the particular slot. To |
---|
40 | ** work from the slot to the interrupt pin, the swizzle table is used. |
---|
41 | ** Once the bus and interrupt pin is known, the correct interrupt name |
---|
42 | ** can be pulled from the table. The swizzle table relates the |
---|
43 | ** interrupt pin from the device to the particular interrupt |
---|
44 | ** controller interrupt pin- so it is quite reasonable for a device on |
---|
45 | ** bus 1 signalling interrupt pin 1 to show up at the interrupt |
---|
46 | ** controller as pin 4- this is why the int pin field varies for |
---|
47 | ** bridged pci busses. |
---|
48 | ** |
---|
49 | ** |
---|
50 | ** opts = bitmap of options that control the configuration of this |
---|
51 | ** slot/bus. |
---|
52 | ** |
---|
53 | ** pin_routes[] = array of pin & vectors that may serve this slot; |
---|
54 | ** |
---|
55 | ** pin = the pin # which delivers an interrupt on this route, A=1, |
---|
56 | ** B=2, C=3, D=4 |
---|
57 | ** |
---|
58 | ** int_name[4] = an array of up to 4 bsp-specific interrupt name |
---|
59 | ** that can be used by this route. Unused entries should be -1. |
---|
60 | ** The array is of primary use for slots that can be vectored thru |
---|
61 | ** multiple interrupt lines over the interrupt pin supplied by the |
---|
62 | ** record. If more than one entry is present, the most preferable |
---|
63 | ** should supplied first. |
---|
64 | ** |
---|
65 | */ |
---|
66 | |
---|
67 | #define NULL_PINMAP {-1,{-1,-1,-1,-1}} |
---|
68 | #define NULL_INTMAP {-1,-1,-1,{}} |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | static struct _int_map mcp750_intmap[] = { |
---|
73 | |
---|
74 | { 0, 16, 0, {{1, {5, 19,-1,-1}}, /* pmc slot */ |
---|
75 | NULL_PINMAP}}, |
---|
76 | |
---|
77 | { 0, 14, 0, {{1, {10,18,-1,-1}}, /* onboard ethernet */ |
---|
78 | NULL_PINMAP}}, |
---|
79 | |
---|
80 | { 1, -1, 0, {{1, {24,-1,-1,-1}}, |
---|
81 | {2, {25,-1,-1,-1}}, |
---|
82 | {3, {26,-1,-1,-1}}, |
---|
83 | {4, {27,-1,-1,-1}}, |
---|
84 | NULL_PINMAP}}, |
---|
85 | |
---|
86 | NULL_INTMAP }; |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | static struct _int_map mtx603_intmap[] = { |
---|
92 | |
---|
93 | {0, 14, 0, {{1, {10,16,-1,-1}}, /* onboard ethernet */ |
---|
94 | NULL_PINMAP}}, |
---|
95 | |
---|
96 | {0, 12, 0, {{1, {14,18,-1,-1}}, /* onboard scsi */ |
---|
97 | NULL_PINMAP}}, |
---|
98 | |
---|
99 | {0, 16, 0, {{1, {25,-1,-1,-1}}, /* pci/pmc slot 1 */ |
---|
100 | {2, {26,-1,-1,-1}}, |
---|
101 | {3, {27,-1,-1,-1}}, |
---|
102 | {4, {28,-1,-1,-1}}, |
---|
103 | NULL_PINMAP}}, |
---|
104 | |
---|
105 | {0, 17, 0, {{1, {26,-1,-1,-1}}, /* pci/pmc slot 2 */ |
---|
106 | {2, {27,-1,-1,-1}}, |
---|
107 | {3, {28,-1,-1,-1}}, |
---|
108 | {4, {25,-1,-1,-1}}, |
---|
109 | NULL_PINMAP}}, |
---|
110 | |
---|
111 | {0, 18, 0, {{1, {27,-1,-1,-1}}, /* pci slot 3 */ |
---|
112 | {2, {28,-1,-1,-1}}, |
---|
113 | {3, {25,-1,-1,-1}}, |
---|
114 | {4, {26,-1,-1,-1}}, |
---|
115 | NULL_PINMAP}}, |
---|
116 | |
---|
117 | NULL_INTMAP }; |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | /* |
---|
127 | * This table represents the standard PCI swizzle defined in the |
---|
128 | * PCI bus specification. Table taken from Linux 2.4.18, prep_pci.c, |
---|
129 | * the values in this table are interrupt_pin values (1 based). |
---|
130 | */ |
---|
131 | static unsigned char prep_pci_intpins[4][4] = |
---|
132 | { |
---|
133 | { 1, 2, 3, 4 }, /* Buses 0, 4, 8, ... */ |
---|
134 | { 2, 3, 4, 1 }, /* Buses 1, 5, 9, ... */ |
---|
135 | { 3, 4, 1, 2 }, /* Buses 2, 6, 10 ... */ |
---|
136 | { 4, 1, 2, 3 }, /* Buses 3, 7, 11 ... */ |
---|
137 | }; |
---|
138 | |
---|
139 | static int prep_pci_swizzle(int slot, int pin) |
---|
140 | { |
---|
141 | return prep_pci_intpins[ slot % 4 ][ pin-1 ]; |
---|
142 | } |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | typedef struct { |
---|
153 | /* |
---|
154 | * 0x100 mask assumes for Raven and Hawk boards |
---|
155 | * that the level/edge are set. |
---|
156 | * 0x200 if this board has a Hawk chip. |
---|
157 | */ |
---|
158 | int cpu_type; |
---|
159 | int base_type; |
---|
160 | const char *name; |
---|
161 | |
---|
162 | struct _int_map *intmap; |
---|
163 | int (*swizzler)(int, int); |
---|
164 | } mot_info_t; |
---|
165 | |
---|
166 | |
---|
167 | static const mot_info_t mot_boards[] = { |
---|
168 | {0x300, 0x00, "MVME 2400", NULL, NULL}, |
---|
169 | {0x010, 0x00, "Genesis", NULL, NULL}, |
---|
170 | {0x020, 0x00, "Powerstack (Series E)", NULL, NULL}, |
---|
171 | {0x040, 0x00, "Blackhawk (Powerstack)", NULL, NULL}, |
---|
172 | {0x050, 0x00, "Omaha (PowerStack II Pro3000)", NULL, NULL}, |
---|
173 | {0x060, 0x00, "Utah (Powerstack II Pro4000)", NULL, NULL}, |
---|
174 | {0x0A0, 0x00, "Powerstack (Series EX)", NULL, NULL}, |
---|
175 | {0x1E0, 0xE0, "Mesquite cPCI (MCP750)", mcp750_intmap, prep_pci_swizzle}, |
---|
176 | {0x1E0, 0xE1, "Sitka cPCI (MCPN750)", mcp750_intmap, prep_pci_swizzle}, |
---|
177 | {0x1E0, 0xE2, "Mesquite cPCI (MCP750) w/ HAC", mcp750_intmap, prep_pci_swizzle}, |
---|
178 | {0x1E0, 0xF6, "MTX Plus", NULL, NULL}, |
---|
179 | {0x1E0, 0xF7, "MTX w/o Parallel Port", mtx603_intmap, prep_pci_swizzle}, |
---|
180 | {0x1E0, 0xF8, "MTX w/ Parallel Port", mtx603_intmap, prep_pci_swizzle}, |
---|
181 | {0x1E0, 0xF9, "MVME 2300", NULL, NULL}, |
---|
182 | {0x1E0, 0xFA, "MVME 2300SC/2600", NULL, NULL}, |
---|
183 | {0x1E0, 0xFB, "MVME 2600 with MVME712M", NULL, NULL}, |
---|
184 | {0x1E0, 0xFC, "MVME 2600/2700 with MVME761", NULL, NULL}, |
---|
185 | {0x1E0, 0xFD, "MVME 3600 with MVME712M", NULL, NULL}, |
---|
186 | {0x1E0, 0xFE, "MVME 3600 with MVME761", NULL, NULL}, |
---|
187 | {0x1E0, 0xFF, "MVME 1600-001 or 1600-011", NULL, NULL}, |
---|
188 | {0x000, 0x00, ""} |
---|
189 | }; |
---|
190 | |
---|
191 | |
---|
192 | |
---|
193 | prep_t currentPrepType; |
---|
194 | motorolaBoard currentBoard; |
---|
195 | prep_t checkPrepBoardType(RESIDUAL *res) |
---|
196 | { |
---|
197 | prep_t PREP_type; |
---|
198 | /* figure out what kind of prep workstation we are */ |
---|
199 | if ( res->ResidualLength != 0 ) { |
---|
200 | if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) ) |
---|
201 | PREP_type = PREP_IBM; |
---|
202 | else if (!strncmp(res->VitalProductData.PrintableModel, |
---|
203 | "Radstone",8)){ |
---|
204 | PREP_type = PREP_Radstone; |
---|
205 | } |
---|
206 | else |
---|
207 | PREP_type = PREP_Motorola; |
---|
208 | } |
---|
209 | else /* assume motorola if no residual (netboot?) */ { |
---|
210 | PREP_type = PREP_Motorola; |
---|
211 | } |
---|
212 | currentPrepType = PREP_type; |
---|
213 | return PREP_type; |
---|
214 | } |
---|
215 | |
---|
216 | motorolaBoard getMotorolaBoard() |
---|
217 | { |
---|
218 | unsigned char cpu_type; |
---|
219 | unsigned char base_mod; |
---|
220 | int entry; |
---|
221 | int mot_entry = -1; |
---|
222 | |
---|
223 | cpu_type = inb(MOTOROLA_CPUTYPE_REG) & 0xF0; |
---|
224 | base_mod = inb(MOTOROLA_BASETYPE_REG); |
---|
225 | |
---|
226 | for (entry = 0; mot_boards[entry].cpu_type != 0; entry++) { |
---|
227 | if ((mot_boards[entry].cpu_type & 0xff) != cpu_type) |
---|
228 | continue; |
---|
229 | |
---|
230 | if (mot_boards[entry].base_type == 0) { |
---|
231 | mot_entry = entry; |
---|
232 | break; |
---|
233 | } |
---|
234 | |
---|
235 | if (mot_boards[entry].base_type != base_mod) |
---|
236 | continue; |
---|
237 | else{ |
---|
238 | mot_entry = entry; |
---|
239 | break; |
---|
240 | } |
---|
241 | } |
---|
242 | if (mot_entry == -1) { |
---|
243 | printk("Unknown motorola board Please update libbsp/powerpc/shared/motorola/motorola.c\n"); |
---|
244 | printk("cpu_type = %x\n", (unsigned) cpu_type); |
---|
245 | printk("base_mod = %x\n", (unsigned) base_mod); |
---|
246 | currentBoard = MOTOROLA_UNKNOWN; |
---|
247 | return currentBoard; |
---|
248 | } |
---|
249 | currentBoard = (motorolaBoard) mot_entry; |
---|
250 | return currentBoard; |
---|
251 | } |
---|
252 | |
---|
253 | |
---|
254 | const char* motorolaBoardToString(motorolaBoard board) |
---|
255 | { |
---|
256 | if (board == MOTOROLA_UNKNOWN) return "Unknown motorola board"; |
---|
257 | return (mot_boards[board].name); |
---|
258 | } |
---|
259 | |
---|
260 | |
---|
261 | const struct _int_map *motorolaIntMap(motorolaBoard board) |
---|
262 | { |
---|
263 | if (board == MOTOROLA_UNKNOWN) return NULL; |
---|
264 | return mot_boards[board].intmap; |
---|
265 | } |
---|
266 | |
---|
267 | |
---|
268 | const void *motorolaIntSwizzle(motorolaBoard board) |
---|
269 | { |
---|
270 | if (board == MOTOROLA_UNKNOWN) return NULL; |
---|
271 | return (void *)mot_boards[board].swizzler; |
---|
272 | } |
---|
273 | |
---|