Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | /* * $Id: prep_pci.c,v 1.20 1998/06/19 16:48:45 cort Exp $ * PReP pci functions. * Originally by Gary Thomas * rewritten and updated by Cort Dougan (cort@cs.nmt.edu) * * The motherboard routes/maps will disappear shortly. -- Cort */ #include <linux/types.h> #include <linux/pci.h> #include <linux/kernel.h> #include <linux/init.h> #include <asm/byteorder.h> #include <asm/io.h> #include <asm/ptrace.h> #include <asm/processor.h> #define MAX_DEVNR 22 /* Which PCI interrupt line does a given device [slot] use? */ /* Note: This really should be two dimensional based in slot/pin used */ unsigned char *Motherboard_map; unsigned char *Motherboard_map_name; /* How is the 82378 PIRQ mapping setup? */ unsigned char *Motherboard_routes; /* Tables for known hardware */ /* Motorola PowerStackII - Utah */ static char Utah_pci_IRQ_map[23] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 4, /* Slot 2 - SCSI - NCR825A */ 0, /* Slot 3 - unused */ 1, /* Slot 4 - Ethernet - DEC2114x */ 0, /* Slot 5 - unused */ 2, /* Slot 6 - PCI Card slot #1 */ 3, /* Slot 7 - PCI Card slot #2 */ 4, /* Slot 8 - PCI Card slot #3 */ 4, /* Slot 9 - PCI Bridge */ /* added here in case we ever support PCI bridges */ /* Secondary PCI bus cards are at slot-9,6 & slot-9,7 */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 4, /* Slot 12 - SCSI - NCR825A */ 0, /* Slot 13 - unused */ 2, /* Slot 14 - enet */ 0, /* Slot 15 - unused */ 0, 0, 0, 0, 0, 0, 0, }; static char Utah_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 9, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15, /* Line 4 */ }; /* Motorola PowerStackII - Omaha */ /* no integrated SCSI or ethernet */ static char Omaha_pci_IRQ_map[23] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 3, /* Slot 2 - Winbond EIDE */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 1, /* Slot 6 - PCI slot 1 */ 2, /* Slot 7 - PCI slot 2 */ 3, /* Slot 8 - PCI slot 3 */ 4, /* Slot 9 - PCI slot 4 */ /* needs indirect access */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 0, /* Slot 12 - unused */ 0, /* Slot 13 - unused */ 0, /* Slot 14 - unused */ 0, /* Slot 15 - unused */ 1, /* Slot 16 - PCI slot 1 */ 2, /* Slot 17 - PCI slot 2 */ 3, /* Slot 18 - PCI slot 3 */ 4, /* Slot 19 - PCI slot 4 */ /* needs indirect access */ 0, 0, 0, }; static char Omaha_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 9, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */ }; /* Motorola PowerStack */ static char Blackhawk_pci_IRQ_map[16] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ }; static char Blackhawk_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 9, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */ }; /* Motorola MVME16xx */ static char Genesis_pci_IRQ_map[16] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ }; static char Genesis_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 10, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */ }; /* Motorola Series-E */ static char Comet_pci_IRQ_map[16] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ }; static char Comet_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 10, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */ }; /* * ibm 830 (and 850?). * This is actually based on the Carolina motherboard * -- Cort */ static char ibm8xx_pci_IRQ_map[23] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - FireCoral */ 4, /* Slot 12 - Ethernet PCIINTD# */ 2, /* Slot 13 - PCI Slot #2 */ 2, /* Slot 14 - S3 Video PCIINTD# */ 0, /* Slot 15 - onboard SCSI (INDI) [1] */ 3, /* Slot 16 - NCR58C810 RS6000 Only PCIINTC# */ 0, /* Slot 17 - unused */ 2, /* Slot 18 - PCI Slot 2 PCIINTx# (See below) */ 0, /* Slot 19 - unused */ 0, /* Slot 20 - unused */ 0, /* Slot 21 - unused */ 2, /* Slot 22 - PCI slot 1 PCIINTx# (See below) */ }; static char ibm8xx_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - unused */ 13, /* Line 1 */ 10, /* Line 2 */ 15, /* Line 3 */ 15, /* Line 4 */ }; /* IBM Nobis and 850 */ static char Nobis_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 0, /* Slot 14 - unused */ 0, /* Slot 15 - unused */ }; static char Nobis_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 13, /* Line 1 */ 13, /* Line 2 */ 13, /* Line 3 */ 13 /* Line 4 */ }; /* We have to turn on LEVEL mode for changed IRQ's */ /* All PCI IRQ's need to be level mode, so this should be something * other than hard-coded as well... IRQ's are individually mappable * to either edge or level. */ #define CAROLINA_IRQ_EDGE_MASK_LO 0x00 /* IRQ's 0-7 */ #define CAROLINA_IRQ_EDGE_MASK_HI 0xA4 /* IRQ's 8-15 [10,13,15] */ __prep int prep_pcibios_read_config_dword (unsigned char bus, unsigned char dev, unsigned char offset, unsigned int *val) { unsigned long _val; unsigned long *ptr; dev >>= 3; if ((bus != 0) || (dev > MAX_DEVNR)) { *val = 0xFFFFFFFF; return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned long *)(0x80800000 | (1<<dev) | offset); _val = le32_to_cpu(*ptr); } *val = _val; return PCIBIOS_SUCCESSFUL; } __prep int prep_pcibios_read_config_word (unsigned char bus, unsigned char dev, unsigned char offset, unsigned short *val) { unsigned short _val; unsigned short *ptr; dev >>= 3; if ((bus != 0) || (dev > MAX_DEVNR)) { *val = (unsigned short)0xFFFFFFFF; return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned short *)(0x80800000 | (1<<dev) | offset); _val = le16_to_cpu(*ptr); } *val = _val; return PCIBIOS_SUCCESSFUL; } __prep int prep_pcibios_read_config_byte (unsigned char bus, unsigned char dev, unsigned char offset, unsigned char *val) { unsigned char _val; volatile unsigned char *ptr; dev >>= 3; if ((bus != 0) || (dev > MAX_DEVNR)) { *(unsigned long *)val = (unsigned long) 0xFFFFFFFF; return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned char *)(0x80800000 | (1<<dev) | (offset ^ 1)); _val = *ptr; } *val = _val; return PCIBIOS_SUCCESSFUL; } __prep int prep_pcibios_write_config_dword (unsigned char bus, unsigned char dev, unsigned char offset, unsigned int val) { unsigned long _val; unsigned long *ptr; dev >>= 3; _val = le32_to_cpu(val); if ((bus != 0) || (dev > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned long *)(0x80800000 | (1<<dev) | offset); *ptr = _val; } return PCIBIOS_SUCCESSFUL; } __prep int prep_pcibios_write_config_word (unsigned char bus, unsigned char dev, unsigned char offset, unsigned short val) { unsigned short _val; unsigned short *ptr; dev >>= 3; _val = le16_to_cpu(val); if ((bus != 0) || (dev > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned short *)(0x80800000 | (1<<dev) | offset); *ptr = _val; } return PCIBIOS_SUCCESSFUL; } __prep int prep_pcibios_write_config_byte (unsigned char bus, unsigned char dev, unsigned char offset, unsigned char val) { unsigned char _val; unsigned char *ptr; dev >>= 3; _val = val; if ((bus != 0) || (dev > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned char *)(0x80800000 | (1<<dev) | (offset^1)); *ptr = _val; } return PCIBIOS_SUCCESSFUL; } __initfunc(unsigned long route_pci_interrupts(void)) { unsigned char *ibc_pirq = (unsigned char *)0x80800860; unsigned char *ibc_pcicon = (unsigned char *)0x80800840; int i; if ( _prep_type == _PREP_Motorola) { switch (inb(0x800) & 0xF0) { case 0x10: /* MVME16xx */ Motherboard_map_name = "Genesis"; Motherboard_map = Genesis_pci_IRQ_map; Motherboard_routes = Genesis_pci_IRQ_routes; break; case 0x20: /* Series E */ Motherboard_map_name = "Powerstack (Series E)"; Motherboard_map = Comet_pci_IRQ_map; Motherboard_routes = Comet_pci_IRQ_routes; break; case 0x50: /* PowerStackII Pro3000 */ Motherboard_map_name = "Omaha (PowerStack II Pro3000)"; Motherboard_map = Omaha_pci_IRQ_map; Motherboard_routes = Omaha_pci_IRQ_routes; break; case 0x60: /* PowerStackII Pro4000 */ Motherboard_map_name = "Utah (Powerstack II Pro4000)"; Motherboard_map = Utah_pci_IRQ_map; Motherboard_routes = Utah_pci_IRQ_routes; break; case 0x40: /* PowerStack */ default: /* Can't hurt, can it? */ Motherboard_map_name = "Blackhawk (Powerstack)"; Motherboard_map = Blackhawk_pci_IRQ_map; Motherboard_routes = Blackhawk_pci_IRQ_routes; break; } } else if ( _prep_type == _PREP_IBM ) { unsigned char pl_id; if (inb(0x0852) == 0xFF) { Motherboard_map_name = "IBM 850/860 Portable\n"; Motherboard_map = Nobis_pci_IRQ_map; Motherboard_routes = Nobis_pci_IRQ_routes; } else { Motherboard_map_name = "IBM 8xx (Carolina)"; Motherboard_map = ibm8xx_pci_IRQ_map; Motherboard_routes = ibm8xx_pci_IRQ_routes; } /*printk("Changing IRQ mode\n");*/ pl_id=inb(0x04d0); /*printk("Low mask is %#0x\n", pl_id);*/ outb(pl_id|CAROLINA_IRQ_EDGE_MASK_LO, 0x04d0); pl_id=inb(0x04d1); /*printk("Hi mask is %#0x\n", pl_id);*/ outb(pl_id|CAROLINA_IRQ_EDGE_MASK_HI, 0x04d1); pl_id=inb(0x04d1); /*printk("Hi mask now %#0x\n", pl_id);*/ } else { printk("No known machine pci routing!\n"); return -1; } /* Set up mapping from slots */ for (i = 1; i <= 4; i++) { ibc_pirq[i-1] = Motherboard_routes[i]; } /* Enable PCI interrupts */ *ibc_pcicon |= 0x20; return 0; } |