1 /* 2 * linux/arch/m68k/mac/config.c 3 * 4 * This file is subject to the terms and conditions of the GNU General Public 5 * License. See the file COPYING in the main directory of this archive 6 * for more details. 7 */ 8 9 /* 10 * Miscellaneous linux stuff 11 */ 12 13 #include <linux/errno.h> 14 #include <linux/module.h> 15 #include <linux/types.h> 16 #include <linux/mm.h> 17 #include <linux/tty.h> 18 #include <linux/console.h> 19 #include <linux/interrupt.h> 20 /* keyb */ 21 #include <linux/random.h> 22 #include <linux/delay.h> 23 /* keyb */ 24 #include <linux/init.h> 25 #include <linux/vt_kern.h> 26 #include <linux/platform_device.h> 27 #include <linux/adb.h> 28 #include <linux/cuda.h> 29 #include <linux/rtc.h> 30 31 #include <asm/setup.h> 32 #include <asm/bootinfo.h> 33 #include <asm/bootinfo-mac.h> 34 #include <asm/byteorder.h> 35 36 #include <asm/io.h> 37 #include <asm/irq.h> 38 #include <asm/pgtable.h> 39 #include <asm/machdep.h> 40 41 #include <asm/macintosh.h> 42 #include <asm/macints.h> 43 #include <asm/machw.h> 44 45 #include <asm/mac_iop.h> 46 #include <asm/mac_via.h> 47 #include <asm/mac_oss.h> 48 #include <asm/mac_psc.h> 49 50 /* Mac bootinfo struct */ 51 struct mac_booter_data mac_bi_data; 52 53 /* The phys. video addr. - might be bogus on some machines */ 54 static unsigned long mac_orig_videoaddr; 55 56 /* Mac specific timer functions */ 57 extern u32 mac_gettimeoffset(void); 58 extern int mac_hwclk(int, struct rtc_time *); 59 extern int mac_set_clock_mmss(unsigned long); 60 extern void iop_preinit(void); 61 extern void iop_init(void); 62 extern void via_init(void); 63 extern void via_init_clock(irq_handler_t func); 64 extern void via_flush_cache(void); 65 extern void oss_init(void); 66 extern void psc_init(void); 67 extern void baboon_init(void); 68 69 extern void mac_mksound(unsigned int, unsigned int); 70 71 static void mac_get_model(char *str); 72 static void mac_identify(void); 73 static void mac_report_hardware(void); 74 75 static void __init mac_sched_init(irq_handler_t vector) 76 { 77 via_init_clock(vector); 78 } 79 80 /* 81 * Parse a Macintosh-specific record in the bootinfo 82 */ 83 84 int __init mac_parse_bootinfo(const struct bi_record *record) 85 { 86 int unknown = 0; 87 const void *data = record->data; 88 89 switch (be16_to_cpu(record->tag)) { 90 case BI_MAC_MODEL: 91 mac_bi_data.id = be32_to_cpup(data); 92 break; 93 case BI_MAC_VADDR: 94 mac_bi_data.videoaddr = be32_to_cpup(data); 95 break; 96 case BI_MAC_VDEPTH: 97 mac_bi_data.videodepth = be32_to_cpup(data); 98 break; 99 case BI_MAC_VROW: 100 mac_bi_data.videorow = be32_to_cpup(data); 101 break; 102 case BI_MAC_VDIM: 103 mac_bi_data.dimensions = be32_to_cpup(data); 104 break; 105 case BI_MAC_VLOGICAL: 106 mac_orig_videoaddr = be32_to_cpup(data); 107 mac_bi_data.videological = 108 VIDEOMEMBASE + (mac_orig_videoaddr & ~VIDEOMEMMASK); 109 break; 110 case BI_MAC_SCCBASE: 111 mac_bi_data.sccbase = be32_to_cpup(data); 112 break; 113 case BI_MAC_BTIME: 114 mac_bi_data.boottime = be32_to_cpup(data); 115 break; 116 case BI_MAC_GMTBIAS: 117 mac_bi_data.gmtbias = be32_to_cpup(data); 118 break; 119 case BI_MAC_MEMSIZE: 120 mac_bi_data.memsize = be32_to_cpup(data); 121 break; 122 case BI_MAC_CPUID: 123 mac_bi_data.cpuid = be32_to_cpup(data); 124 break; 125 case BI_MAC_ROMBASE: 126 mac_bi_data.rombase = be32_to_cpup(data); 127 break; 128 default: 129 unknown = 1; 130 break; 131 } 132 return unknown; 133 } 134 135 /* 136 * Flip into 24bit mode for an instant - flushes the L2 cache card. We 137 * have to disable interrupts for this. Our IRQ handlers will crap 138 * themselves if they take an IRQ in 24bit mode! 139 */ 140 141 static void mac_cache_card_flush(int writeback) 142 { 143 unsigned long flags; 144 145 local_irq_save(flags); 146 via_flush_cache(); 147 local_irq_restore(flags); 148 } 149 150 void __init config_mac(void) 151 { 152 if (!MACH_IS_MAC) 153 printk(KERN_ERR "ERROR: no Mac, but config_mac() called!!\n"); 154 155 mach_sched_init = mac_sched_init; 156 mach_init_IRQ = mac_init_IRQ; 157 mach_get_model = mac_get_model; 158 arch_gettimeoffset = mac_gettimeoffset; 159 mach_hwclk = mac_hwclk; 160 mach_set_clock_mmss = mac_set_clock_mmss; 161 mach_reset = mac_reset; 162 mach_halt = mac_poweroff; 163 mach_power_off = mac_poweroff; 164 mach_max_dma_address = 0xffffffff; 165 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 166 mach_beep = mac_mksound; 167 #endif 168 169 /* 170 * Determine hardware present 171 */ 172 173 mac_identify(); 174 mac_report_hardware(); 175 176 /* 177 * AFAIK only the IIci takes a cache card. The IIfx has onboard 178 * cache ... someone needs to figure out how to tell if it's on or 179 * not. 180 */ 181 182 if (macintosh_config->ident == MAC_MODEL_IICI 183 || macintosh_config->ident == MAC_MODEL_IIFX) 184 mach_l2_flush = mac_cache_card_flush; 185 } 186 187 188 /* 189 * Macintosh Table: hardcoded model configuration data. 190 * 191 * Much of this was defined by Alan, based on who knows what docs. 192 * I've added a lot more, and some of that was pure guesswork based 193 * on hardware pages present on the Mac web site. Possibly wildly 194 * inaccurate, so look here if a new Mac model won't run. Example: if 195 * a Mac crashes immediately after the VIA1 registers have been dumped 196 * to the screen, it probably died attempting to read DirB on a RBV. 197 * Meaning it should have MAC_VIA_IICI here :-) 198 */ 199 200 struct mac_model *macintosh_config; 201 EXPORT_SYMBOL(macintosh_config); 202 203 static struct mac_model mac_data_table[] = { 204 /* 205 * We'll pretend to be a Macintosh II, that's pretty safe. 206 */ 207 208 { 209 .ident = MAC_MODEL_II, 210 .name = "Unknown", 211 .adb_type = MAC_ADB_II, 212 .via_type = MAC_VIA_II, 213 .scsi_type = MAC_SCSI_OLD, 214 .scc_type = MAC_SCC_II, 215 .nubus_type = MAC_NUBUS, 216 .floppy_type = MAC_FLOPPY_IWM, 217 }, 218 219 /* 220 * Original Mac II hardware 221 */ 222 223 { 224 .ident = MAC_MODEL_II, 225 .name = "II", 226 .adb_type = MAC_ADB_II, 227 .via_type = MAC_VIA_II, 228 .scsi_type = MAC_SCSI_OLD, 229 .scc_type = MAC_SCC_II, 230 .nubus_type = MAC_NUBUS, 231 .floppy_type = MAC_FLOPPY_IWM, 232 }, { 233 .ident = MAC_MODEL_IIX, 234 .name = "IIx", 235 .adb_type = MAC_ADB_II, 236 .via_type = MAC_VIA_II, 237 .scsi_type = MAC_SCSI_OLD, 238 .scc_type = MAC_SCC_II, 239 .nubus_type = MAC_NUBUS, 240 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 241 }, { 242 .ident = MAC_MODEL_IICX, 243 .name = "IIcx", 244 .adb_type = MAC_ADB_II, 245 .via_type = MAC_VIA_II, 246 .scsi_type = MAC_SCSI_OLD, 247 .scc_type = MAC_SCC_II, 248 .nubus_type = MAC_NUBUS, 249 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 250 }, { 251 .ident = MAC_MODEL_SE30, 252 .name = "SE/30", 253 .adb_type = MAC_ADB_II, 254 .via_type = MAC_VIA_II, 255 .scsi_type = MAC_SCSI_OLD, 256 .scc_type = MAC_SCC_II, 257 .nubus_type = MAC_NUBUS, 258 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 259 }, 260 261 /* 262 * Weirdified Mac II hardware - all subtly different. Gee thanks 263 * Apple. All these boxes seem to have VIA2 in a different place to 264 * the Mac II (+1A000 rather than +4000) 265 * CSA: see http://developer.apple.com/technotes/hw/hw_09.html 266 */ 267 268 { 269 .ident = MAC_MODEL_IICI, 270 .name = "IIci", 271 .adb_type = MAC_ADB_II, 272 .via_type = MAC_VIA_IICI, 273 .scsi_type = MAC_SCSI_OLD, 274 .scc_type = MAC_SCC_II, 275 .nubus_type = MAC_NUBUS, 276 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 277 }, { 278 .ident = MAC_MODEL_IIFX, 279 .name = "IIfx", 280 .adb_type = MAC_ADB_IOP, 281 .via_type = MAC_VIA_IICI, 282 .scsi_type = MAC_SCSI_IIFX, 283 .scc_type = MAC_SCC_IOP, 284 .nubus_type = MAC_NUBUS, 285 .floppy_type = MAC_FLOPPY_SWIM_IOP, 286 }, { 287 .ident = MAC_MODEL_IISI, 288 .name = "IIsi", 289 .adb_type = MAC_ADB_IISI, 290 .via_type = MAC_VIA_IICI, 291 .scsi_type = MAC_SCSI_OLD, 292 .scc_type = MAC_SCC_II, 293 .nubus_type = MAC_NUBUS, 294 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 295 }, { 296 .ident = MAC_MODEL_IIVI, 297 .name = "IIvi", 298 .adb_type = MAC_ADB_IISI, 299 .via_type = MAC_VIA_IICI, 300 .scsi_type = MAC_SCSI_LC, 301 .scc_type = MAC_SCC_II, 302 .nubus_type = MAC_NUBUS, 303 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 304 }, { 305 .ident = MAC_MODEL_IIVX, 306 .name = "IIvx", 307 .adb_type = MAC_ADB_IISI, 308 .via_type = MAC_VIA_IICI, 309 .scsi_type = MAC_SCSI_LC, 310 .scc_type = MAC_SCC_II, 311 .nubus_type = MAC_NUBUS, 312 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 313 }, 314 315 /* 316 * Classic models (guessing: similar to SE/30? Nope, similar to LC...) 317 */ 318 319 { 320 .ident = MAC_MODEL_CLII, 321 .name = "Classic II", 322 .adb_type = MAC_ADB_IISI, 323 .via_type = MAC_VIA_IICI, 324 .scsi_type = MAC_SCSI_LC, 325 .scc_type = MAC_SCC_II, 326 .nubus_type = MAC_NUBUS, 327 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 328 }, { 329 .ident = MAC_MODEL_CCL, 330 .name = "Color Classic", 331 .adb_type = MAC_ADB_CUDA, 332 .via_type = MAC_VIA_IICI, 333 .scsi_type = MAC_SCSI_LC, 334 .scc_type = MAC_SCC_II, 335 .nubus_type = MAC_NUBUS, 336 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 337 }, { 338 .ident = MAC_MODEL_CCLII, 339 .name = "Color Classic II", 340 .adb_type = MAC_ADB_CUDA, 341 .via_type = MAC_VIA_IICI, 342 .scsi_type = MAC_SCSI_LC, 343 .scc_type = MAC_SCC_II, 344 .nubus_type = MAC_NUBUS, 345 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 346 }, 347 348 /* 349 * Some Mac LC machines. Basically the same as the IIci, ADB like IIsi 350 */ 351 352 { 353 .ident = MAC_MODEL_LC, 354 .name = "LC", 355 .adb_type = MAC_ADB_IISI, 356 .via_type = MAC_VIA_IICI, 357 .scsi_type = MAC_SCSI_LC, 358 .scc_type = MAC_SCC_II, 359 .nubus_type = MAC_NUBUS, 360 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 361 }, { 362 .ident = MAC_MODEL_LCII, 363 .name = "LC II", 364 .adb_type = MAC_ADB_IISI, 365 .via_type = MAC_VIA_IICI, 366 .scsi_type = MAC_SCSI_LC, 367 .scc_type = MAC_SCC_II, 368 .nubus_type = MAC_NUBUS, 369 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 370 }, { 371 .ident = MAC_MODEL_LCIII, 372 .name = "LC III", 373 .adb_type = MAC_ADB_IISI, 374 .via_type = MAC_VIA_IICI, 375 .scsi_type = MAC_SCSI_LC, 376 .scc_type = MAC_SCC_II, 377 .nubus_type = MAC_NUBUS, 378 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 379 }, 380 381 /* 382 * Quadra. Video is at 0xF9000000, via is like a MacII. We label it 383 * differently as some of the stuff connected to VIA2 seems different. 384 * Better SCSI chip and onboard ethernet using a NatSemi SONIC except 385 * the 660AV and 840AV which use an AMD 79C940 (MACE). 386 * The 700, 900 and 950 have some I/O chips in the wrong place to 387 * confuse us. The 840AV has a SCSI location of its own (same as 388 * the 660AV). 389 */ 390 391 { 392 .ident = MAC_MODEL_Q605, 393 .name = "Quadra 605", 394 .adb_type = MAC_ADB_CUDA, 395 .via_type = MAC_VIA_QUADRA, 396 .scsi_type = MAC_SCSI_QUADRA, 397 .scc_type = MAC_SCC_QUADRA, 398 .nubus_type = MAC_NUBUS, 399 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 400 }, { 401 .ident = MAC_MODEL_Q605_ACC, 402 .name = "Quadra 605", 403 .adb_type = MAC_ADB_CUDA, 404 .via_type = MAC_VIA_QUADRA, 405 .scsi_type = MAC_SCSI_QUADRA, 406 .scc_type = MAC_SCC_QUADRA, 407 .nubus_type = MAC_NUBUS, 408 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 409 }, { 410 .ident = MAC_MODEL_Q610, 411 .name = "Quadra 610", 412 .adb_type = MAC_ADB_II, 413 .via_type = MAC_VIA_QUADRA, 414 .scsi_type = MAC_SCSI_QUADRA, 415 .scc_type = MAC_SCC_QUADRA, 416 .ether_type = MAC_ETHER_SONIC, 417 .nubus_type = MAC_NUBUS, 418 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 419 }, { 420 .ident = MAC_MODEL_Q630, 421 .name = "Quadra 630", 422 .adb_type = MAC_ADB_CUDA, 423 .via_type = MAC_VIA_QUADRA, 424 .scsi_type = MAC_SCSI_QUADRA, 425 .ide_type = MAC_IDE_QUADRA, 426 .scc_type = MAC_SCC_QUADRA, 427 .ether_type = MAC_ETHER_SONIC, 428 .nubus_type = MAC_NUBUS, 429 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 430 }, { 431 .ident = MAC_MODEL_Q650, 432 .name = "Quadra 650", 433 .adb_type = MAC_ADB_II, 434 .via_type = MAC_VIA_QUADRA, 435 .scsi_type = MAC_SCSI_QUADRA, 436 .scc_type = MAC_SCC_QUADRA, 437 .ether_type = MAC_ETHER_SONIC, 438 .nubus_type = MAC_NUBUS, 439 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 440 }, 441 /* The Q700 does have a NS Sonic */ 442 { 443 .ident = MAC_MODEL_Q700, 444 .name = "Quadra 700", 445 .adb_type = MAC_ADB_II, 446 .via_type = MAC_VIA_QUADRA, 447 .scsi_type = MAC_SCSI_QUADRA2, 448 .scc_type = MAC_SCC_QUADRA, 449 .ether_type = MAC_ETHER_SONIC, 450 .nubus_type = MAC_NUBUS, 451 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 452 }, { 453 .ident = MAC_MODEL_Q800, 454 .name = "Quadra 800", 455 .adb_type = MAC_ADB_II, 456 .via_type = MAC_VIA_QUADRA, 457 .scsi_type = MAC_SCSI_QUADRA, 458 .scc_type = MAC_SCC_QUADRA, 459 .ether_type = MAC_ETHER_SONIC, 460 .nubus_type = MAC_NUBUS, 461 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 462 }, { 463 .ident = MAC_MODEL_Q840, 464 .name = "Quadra 840AV", 465 .adb_type = MAC_ADB_CUDA, 466 .via_type = MAC_VIA_QUADRA, 467 .scsi_type = MAC_SCSI_QUADRA3, 468 .scc_type = MAC_SCC_PSC, 469 .ether_type = MAC_ETHER_MACE, 470 .nubus_type = MAC_NUBUS, 471 .floppy_type = MAC_FLOPPY_AV, 472 }, { 473 .ident = MAC_MODEL_Q900, 474 .name = "Quadra 900", 475 .adb_type = MAC_ADB_IOP, 476 .via_type = MAC_VIA_QUADRA, 477 .scsi_type = MAC_SCSI_QUADRA2, 478 .scc_type = MAC_SCC_IOP, 479 .ether_type = MAC_ETHER_SONIC, 480 .nubus_type = MAC_NUBUS, 481 .floppy_type = MAC_FLOPPY_SWIM_IOP, 482 }, { 483 .ident = MAC_MODEL_Q950, 484 .name = "Quadra 950", 485 .adb_type = MAC_ADB_IOP, 486 .via_type = MAC_VIA_QUADRA, 487 .scsi_type = MAC_SCSI_QUADRA2, 488 .scc_type = MAC_SCC_IOP, 489 .ether_type = MAC_ETHER_SONIC, 490 .nubus_type = MAC_NUBUS, 491 .floppy_type = MAC_FLOPPY_SWIM_IOP, 492 }, 493 494 /* 495 * Performa - more LC type machines 496 */ 497 498 { 499 .ident = MAC_MODEL_P460, 500 .name = "Performa 460", 501 .adb_type = MAC_ADB_IISI, 502 .via_type = MAC_VIA_IICI, 503 .scsi_type = MAC_SCSI_LC, 504 .scc_type = MAC_SCC_II, 505 .nubus_type = MAC_NUBUS, 506 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 507 }, { 508 .ident = MAC_MODEL_P475, 509 .name = "Performa 475", 510 .adb_type = MAC_ADB_CUDA, 511 .via_type = MAC_VIA_QUADRA, 512 .scsi_type = MAC_SCSI_QUADRA, 513 .scc_type = MAC_SCC_II, 514 .nubus_type = MAC_NUBUS, 515 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 516 }, { 517 .ident = MAC_MODEL_P475F, 518 .name = "Performa 475", 519 .adb_type = MAC_ADB_CUDA, 520 .via_type = MAC_VIA_QUADRA, 521 .scsi_type = MAC_SCSI_QUADRA, 522 .scc_type = MAC_SCC_II, 523 .nubus_type = MAC_NUBUS, 524 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 525 }, { 526 .ident = MAC_MODEL_P520, 527 .name = "Performa 520", 528 .adb_type = MAC_ADB_CUDA, 529 .via_type = MAC_VIA_IICI, 530 .scsi_type = MAC_SCSI_LC, 531 .scc_type = MAC_SCC_II, 532 .nubus_type = MAC_NUBUS, 533 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 534 }, { 535 .ident = MAC_MODEL_P550, 536 .name = "Performa 550", 537 .adb_type = MAC_ADB_CUDA, 538 .via_type = MAC_VIA_IICI, 539 .scsi_type = MAC_SCSI_LC, 540 .scc_type = MAC_SCC_II, 541 .nubus_type = MAC_NUBUS, 542 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 543 }, 544 /* These have the comm slot, and therefore possibly SONIC ethernet */ 545 { 546 .ident = MAC_MODEL_P575, 547 .name = "Performa 575", 548 .adb_type = MAC_ADB_CUDA, 549 .via_type = MAC_VIA_QUADRA, 550 .scsi_type = MAC_SCSI_QUADRA, 551 .scc_type = MAC_SCC_II, 552 .ether_type = MAC_ETHER_SONIC, 553 .nubus_type = MAC_NUBUS, 554 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 555 }, { 556 .ident = MAC_MODEL_P588, 557 .name = "Performa 588", 558 .adb_type = MAC_ADB_CUDA, 559 .via_type = MAC_VIA_QUADRA, 560 .scsi_type = MAC_SCSI_QUADRA, 561 .ide_type = MAC_IDE_QUADRA, 562 .scc_type = MAC_SCC_II, 563 .ether_type = MAC_ETHER_SONIC, 564 .nubus_type = MAC_NUBUS, 565 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 566 }, { 567 .ident = MAC_MODEL_TV, 568 .name = "TV", 569 .adb_type = MAC_ADB_CUDA, 570 .via_type = MAC_VIA_IICI, 571 .scsi_type = MAC_SCSI_LC, 572 .scc_type = MAC_SCC_II, 573 .nubus_type = MAC_NUBUS, 574 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 575 }, { 576 .ident = MAC_MODEL_P600, 577 .name = "Performa 600", 578 .adb_type = MAC_ADB_IISI, 579 .via_type = MAC_VIA_IICI, 580 .scsi_type = MAC_SCSI_LC, 581 .scc_type = MAC_SCC_II, 582 .nubus_type = MAC_NUBUS, 583 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 584 }, 585 586 /* 587 * Centris - just guessing again; maybe like Quadra. 588 * The C610 may or may not have SONIC. We probe to make sure. 589 */ 590 591 { 592 .ident = MAC_MODEL_C610, 593 .name = "Centris 610", 594 .adb_type = MAC_ADB_II, 595 .via_type = MAC_VIA_QUADRA, 596 .scsi_type = MAC_SCSI_QUADRA, 597 .scc_type = MAC_SCC_QUADRA, 598 .ether_type = MAC_ETHER_SONIC, 599 .nubus_type = MAC_NUBUS, 600 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 601 }, { 602 .ident = MAC_MODEL_C650, 603 .name = "Centris 650", 604 .adb_type = MAC_ADB_II, 605 .via_type = MAC_VIA_QUADRA, 606 .scsi_type = MAC_SCSI_QUADRA, 607 .scc_type = MAC_SCC_QUADRA, 608 .ether_type = MAC_ETHER_SONIC, 609 .nubus_type = MAC_NUBUS, 610 .floppy_type = MAC_FLOPPY_SWIM_ADDR1, 611 }, { 612 .ident = MAC_MODEL_C660, 613 .name = "Centris 660AV", 614 .adb_type = MAC_ADB_CUDA, 615 .via_type = MAC_VIA_QUADRA, 616 .scsi_type = MAC_SCSI_QUADRA3, 617 .scc_type = MAC_SCC_PSC, 618 .ether_type = MAC_ETHER_MACE, 619 .nubus_type = MAC_NUBUS, 620 .floppy_type = MAC_FLOPPY_AV, 621 }, 622 623 /* 624 * The PowerBooks all the same "Combo" custom IC for SCSI and SCC 625 * and a PMU (in two variations?) for ADB. Most of them use the 626 * Quadra-style VIAs. A few models also have IDE from hell. 627 */ 628 629 { 630 .ident = MAC_MODEL_PB140, 631 .name = "PowerBook 140", 632 .adb_type = MAC_ADB_PB1, 633 .via_type = MAC_VIA_QUADRA, 634 .scsi_type = MAC_SCSI_OLD, 635 .scc_type = MAC_SCC_QUADRA, 636 .nubus_type = MAC_NUBUS, 637 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 638 }, { 639 .ident = MAC_MODEL_PB145, 640 .name = "PowerBook 145", 641 .adb_type = MAC_ADB_PB1, 642 .via_type = MAC_VIA_QUADRA, 643 .scsi_type = MAC_SCSI_OLD, 644 .scc_type = MAC_SCC_QUADRA, 645 .nubus_type = MAC_NUBUS, 646 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 647 }, { 648 .ident = MAC_MODEL_PB150, 649 .name = "PowerBook 150", 650 .adb_type = MAC_ADB_PB2, 651 .via_type = MAC_VIA_IICI, 652 .scsi_type = MAC_SCSI_OLD, 653 .ide_type = MAC_IDE_PB, 654 .scc_type = MAC_SCC_QUADRA, 655 .nubus_type = MAC_NUBUS, 656 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 657 }, { 658 .ident = MAC_MODEL_PB160, 659 .name = "PowerBook 160", 660 .adb_type = MAC_ADB_PB1, 661 .via_type = MAC_VIA_QUADRA, 662 .scsi_type = MAC_SCSI_OLD, 663 .scc_type = MAC_SCC_QUADRA, 664 .nubus_type = MAC_NUBUS, 665 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 666 }, { 667 .ident = MAC_MODEL_PB165, 668 .name = "PowerBook 165", 669 .adb_type = MAC_ADB_PB1, 670 .via_type = MAC_VIA_QUADRA, 671 .scsi_type = MAC_SCSI_OLD, 672 .scc_type = MAC_SCC_QUADRA, 673 .nubus_type = MAC_NUBUS, 674 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 675 }, { 676 .ident = MAC_MODEL_PB165C, 677 .name = "PowerBook 165c", 678 .adb_type = MAC_ADB_PB1, 679 .via_type = MAC_VIA_QUADRA, 680 .scsi_type = MAC_SCSI_OLD, 681 .scc_type = MAC_SCC_QUADRA, 682 .nubus_type = MAC_NUBUS, 683 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 684 }, { 685 .ident = MAC_MODEL_PB170, 686 .name = "PowerBook 170", 687 .adb_type = MAC_ADB_PB1, 688 .via_type = MAC_VIA_QUADRA, 689 .scsi_type = MAC_SCSI_OLD, 690 .scc_type = MAC_SCC_QUADRA, 691 .nubus_type = MAC_NUBUS, 692 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 693 }, { 694 .ident = MAC_MODEL_PB180, 695 .name = "PowerBook 180", 696 .adb_type = MAC_ADB_PB1, 697 .via_type = MAC_VIA_QUADRA, 698 .scsi_type = MAC_SCSI_OLD, 699 .scc_type = MAC_SCC_QUADRA, 700 .nubus_type = MAC_NUBUS, 701 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 702 }, { 703 .ident = MAC_MODEL_PB180C, 704 .name = "PowerBook 180c", 705 .adb_type = MAC_ADB_PB1, 706 .via_type = MAC_VIA_QUADRA, 707 .scsi_type = MAC_SCSI_OLD, 708 .scc_type = MAC_SCC_QUADRA, 709 .nubus_type = MAC_NUBUS, 710 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 711 }, { 712 .ident = MAC_MODEL_PB190, 713 .name = "PowerBook 190", 714 .adb_type = MAC_ADB_PB2, 715 .via_type = MAC_VIA_QUADRA, 716 .scsi_type = MAC_SCSI_LATE, 717 .ide_type = MAC_IDE_BABOON, 718 .scc_type = MAC_SCC_QUADRA, 719 .nubus_type = MAC_NUBUS, 720 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 721 }, { 722 .ident = MAC_MODEL_PB520, 723 .name = "PowerBook 520", 724 .adb_type = MAC_ADB_PB2, 725 .via_type = MAC_VIA_QUADRA, 726 .scsi_type = MAC_SCSI_LATE, 727 .scc_type = MAC_SCC_QUADRA, 728 .ether_type = MAC_ETHER_SONIC, 729 .nubus_type = MAC_NUBUS, 730 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 731 }, 732 733 /* 734 * PowerBook Duos are pretty much like normal PowerBooks 735 * All of these probably have onboard SONIC in the Dock which 736 * means we'll have to probe for it eventually. 737 */ 738 739 { 740 .ident = MAC_MODEL_PB210, 741 .name = "PowerBook Duo 210", 742 .adb_type = MAC_ADB_PB2, 743 .via_type = MAC_VIA_IICI, 744 .scsi_type = MAC_SCSI_DUO, 745 .scc_type = MAC_SCC_QUADRA, 746 .nubus_type = MAC_NUBUS, 747 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 748 }, { 749 .ident = MAC_MODEL_PB230, 750 .name = "PowerBook Duo 230", 751 .adb_type = MAC_ADB_PB2, 752 .via_type = MAC_VIA_IICI, 753 .scsi_type = MAC_SCSI_DUO, 754 .scc_type = MAC_SCC_QUADRA, 755 .nubus_type = MAC_NUBUS, 756 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 757 }, { 758 .ident = MAC_MODEL_PB250, 759 .name = "PowerBook Duo 250", 760 .adb_type = MAC_ADB_PB2, 761 .via_type = MAC_VIA_IICI, 762 .scsi_type = MAC_SCSI_DUO, 763 .scc_type = MAC_SCC_QUADRA, 764 .nubus_type = MAC_NUBUS, 765 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 766 }, { 767 .ident = MAC_MODEL_PB270C, 768 .name = "PowerBook Duo 270c", 769 .adb_type = MAC_ADB_PB2, 770 .via_type = MAC_VIA_IICI, 771 .scsi_type = MAC_SCSI_DUO, 772 .scc_type = MAC_SCC_QUADRA, 773 .nubus_type = MAC_NUBUS, 774 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 775 }, { 776 .ident = MAC_MODEL_PB280, 777 .name = "PowerBook Duo 280", 778 .adb_type = MAC_ADB_PB2, 779 .via_type = MAC_VIA_IICI, 780 .scsi_type = MAC_SCSI_DUO, 781 .scc_type = MAC_SCC_QUADRA, 782 .nubus_type = MAC_NUBUS, 783 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 784 }, { 785 .ident = MAC_MODEL_PB280C, 786 .name = "PowerBook Duo 280c", 787 .adb_type = MAC_ADB_PB2, 788 .via_type = MAC_VIA_IICI, 789 .scsi_type = MAC_SCSI_DUO, 790 .scc_type = MAC_SCC_QUADRA, 791 .nubus_type = MAC_NUBUS, 792 .floppy_type = MAC_FLOPPY_SWIM_ADDR2, 793 }, 794 795 /* 796 * Other stuff? 797 */ 798 799 { 800 .ident = -1 801 } 802 }; 803 804 static struct resource scc_a_rsrcs[] = { 805 { .flags = IORESOURCE_MEM }, 806 { .flags = IORESOURCE_IRQ }, 807 }; 808 809 static struct resource scc_b_rsrcs[] = { 810 { .flags = IORESOURCE_MEM }, 811 { .flags = IORESOURCE_IRQ }, 812 }; 813 814 struct platform_device scc_a_pdev = { 815 .name = "scc", 816 .id = 0, 817 .num_resources = ARRAY_SIZE(scc_a_rsrcs), 818 .resource = scc_a_rsrcs, 819 }; 820 EXPORT_SYMBOL(scc_a_pdev); 821 822 struct platform_device scc_b_pdev = { 823 .name = "scc", 824 .id = 1, 825 .num_resources = ARRAY_SIZE(scc_b_rsrcs), 826 .resource = scc_b_rsrcs, 827 }; 828 EXPORT_SYMBOL(scc_b_pdev); 829 830 static void __init mac_identify(void) 831 { 832 struct mac_model *m; 833 834 /* Penguin data useful? */ 835 int model = mac_bi_data.id; 836 if (!model) { 837 /* no bootinfo model id -> NetBSD booter was used! */ 838 /* XXX FIXME: breaks for model > 31 */ 839 model = (mac_bi_data.cpuid >> 2) & 63; 840 printk(KERN_WARNING "No bootinfo model ID, using cpuid instead " 841 "(obsolete bootloader?)\n"); 842 } 843 844 macintosh_config = mac_data_table; 845 for (m = macintosh_config; m->ident != -1; m++) { 846 if (m->ident == model) { 847 macintosh_config = m; 848 break; 849 } 850 } 851 852 /* Set up serial port resources for the console initcall. */ 853 854 scc_a_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase + 2; 855 scc_a_rsrcs[0].end = scc_a_rsrcs[0].start; 856 scc_b_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase; 857 scc_b_rsrcs[0].end = scc_b_rsrcs[0].start; 858 859 switch (macintosh_config->scc_type) { 860 case MAC_SCC_PSC: 861 scc_a_rsrcs[1].start = scc_a_rsrcs[1].end = IRQ_MAC_SCC_A; 862 scc_b_rsrcs[1].start = scc_b_rsrcs[1].end = IRQ_MAC_SCC_B; 863 break; 864 default: 865 /* On non-PSC machines, the serial ports share an IRQ. */ 866 if (macintosh_config->ident == MAC_MODEL_IIFX) { 867 scc_a_rsrcs[1].start = scc_a_rsrcs[1].end = IRQ_MAC_SCC; 868 scc_b_rsrcs[1].start = scc_b_rsrcs[1].end = IRQ_MAC_SCC; 869 } else { 870 scc_a_rsrcs[1].start = scc_a_rsrcs[1].end = IRQ_AUTO_4; 871 scc_b_rsrcs[1].start = scc_b_rsrcs[1].end = IRQ_AUTO_4; 872 } 873 break; 874 } 875 876 /* 877 * We need to pre-init the IOPs, if any. Otherwise 878 * the serial console won't work if the user had 879 * the serial ports set to "Faster" mode in MacOS. 880 */ 881 iop_preinit(); 882 883 printk(KERN_INFO "Detected Macintosh model: %d\n", model); 884 885 /* 886 * Report booter data: 887 */ 888 printk(KERN_DEBUG " Penguin bootinfo data:\n"); 889 printk(KERN_DEBUG " Video: addr 0x%lx " 890 "row 0x%lx depth %lx dimensions %ld x %ld\n", 891 mac_bi_data.videoaddr, mac_bi_data.videorow, 892 mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF, 893 mac_bi_data.dimensions >> 16); 894 printk(KERN_DEBUG " Videological 0x%lx phys. 0x%lx, SCC at 0x%lx\n", 895 mac_bi_data.videological, mac_orig_videoaddr, 896 mac_bi_data.sccbase); 897 printk(KERN_DEBUG " Boottime: 0x%lx GMTBias: 0x%lx\n", 898 mac_bi_data.boottime, mac_bi_data.gmtbias); 899 printk(KERN_DEBUG " Machine ID: %ld CPUid: 0x%lx memory size: 0x%lx\n", 900 mac_bi_data.id, mac_bi_data.cpuid, mac_bi_data.memsize); 901 902 iop_init(); 903 via_init(); 904 oss_init(); 905 psc_init(); 906 baboon_init(); 907 908 #ifdef CONFIG_ADB_CUDA 909 find_via_cuda(); 910 #endif 911 } 912 913 static void __init mac_report_hardware(void) 914 { 915 printk(KERN_INFO "Apple Macintosh %s\n", macintosh_config->name); 916 } 917 918 static void mac_get_model(char *str) 919 { 920 strcpy(str, "Macintosh "); 921 strcat(str, macintosh_config->name); 922 } 923 924 static struct resource swim_rsrc = { .flags = IORESOURCE_MEM }; 925 926 static struct platform_device swim_pdev = { 927 .name = "swim", 928 .id = -1, 929 .num_resources = 1, 930 .resource = &swim_rsrc, 931 }; 932 933 static const struct resource mac_scsi_iifx_rsrc[] __initconst = { 934 { 935 .flags = IORESOURCE_IRQ, 936 .start = IRQ_MAC_SCSI, 937 .end = IRQ_MAC_SCSI, 938 }, { 939 .flags = IORESOURCE_MEM, 940 .start = 0x50008000, 941 .end = 0x50009FFF, 942 }, 943 }; 944 945 static const struct resource mac_scsi_duo_rsrc[] __initconst = { 946 { 947 .flags = IORESOURCE_MEM, 948 .start = 0xFEE02000, 949 .end = 0xFEE03FFF, 950 }, 951 }; 952 953 static const struct resource mac_scsi_old_rsrc[] __initconst = { 954 { 955 .flags = IORESOURCE_IRQ, 956 .start = IRQ_MAC_SCSI, 957 .end = IRQ_MAC_SCSI, 958 }, { 959 .flags = IORESOURCE_MEM, 960 .start = 0x50010000, 961 .end = 0x50011FFF, 962 }, { 963 .flags = IORESOURCE_MEM, 964 .start = 0x50006000, 965 .end = 0x50007FFF, 966 }, 967 }; 968 969 static const struct resource mac_scsi_late_rsrc[] __initconst = { 970 { 971 .flags = IORESOURCE_IRQ, 972 .start = IRQ_MAC_SCSI, 973 .end = IRQ_MAC_SCSI, 974 }, { 975 .flags = IORESOURCE_MEM, 976 .start = 0x50010000, 977 .end = 0x50011FFF, 978 }, 979 }; 980 981 static const struct resource mac_scsi_ccl_rsrc[] __initconst = { 982 { 983 .flags = IORESOURCE_IRQ, 984 .start = IRQ_MAC_SCSI, 985 .end = IRQ_MAC_SCSI, 986 }, { 987 .flags = IORESOURCE_MEM, 988 .start = 0x50F10000, 989 .end = 0x50F11FFF, 990 }, { 991 .flags = IORESOURCE_MEM, 992 .start = 0x50F06000, 993 .end = 0x50F07FFF, 994 }, 995 }; 996 997 static struct platform_device esp_0_pdev = { 998 .name = "mac_esp", 999 .id = 0, 1000 }; 1001 1002 static struct platform_device esp_1_pdev = { 1003 .name = "mac_esp", 1004 .id = 1, 1005 }; 1006 1007 static struct platform_device sonic_pdev = { 1008 .name = "macsonic", 1009 .id = -1, 1010 }; 1011 1012 static struct platform_device mace_pdev = { 1013 .name = "macmace", 1014 .id = -1, 1015 }; 1016 1017 int __init mac_platform_init(void) 1018 { 1019 u8 *swim_base; 1020 1021 if (!MACH_IS_MAC) 1022 return -ENODEV; 1023 1024 /* 1025 * Serial devices 1026 */ 1027 1028 platform_device_register(&scc_a_pdev); 1029 platform_device_register(&scc_b_pdev); 1030 1031 /* 1032 * Floppy device 1033 */ 1034 1035 switch (macintosh_config->floppy_type) { 1036 case MAC_FLOPPY_SWIM_ADDR1: 1037 swim_base = (u8 *)(VIA1_BASE + 0x1E000); 1038 break; 1039 case MAC_FLOPPY_SWIM_ADDR2: 1040 swim_base = (u8 *)(VIA1_BASE + 0x16000); 1041 break; 1042 default: 1043 swim_base = NULL; 1044 break; 1045 } 1046 1047 if (swim_base) { 1048 swim_rsrc.start = (resource_size_t) swim_base, 1049 swim_rsrc.end = (resource_size_t) swim_base + 0x2000, 1050 platform_device_register(&swim_pdev); 1051 } 1052 1053 /* 1054 * SCSI device(s) 1055 */ 1056 1057 switch (macintosh_config->scsi_type) { 1058 case MAC_SCSI_QUADRA: 1059 case MAC_SCSI_QUADRA3: 1060 platform_device_register(&esp_0_pdev); 1061 break; 1062 case MAC_SCSI_QUADRA2: 1063 platform_device_register(&esp_0_pdev); 1064 if ((macintosh_config->ident == MAC_MODEL_Q900) || 1065 (macintosh_config->ident == MAC_MODEL_Q950)) 1066 platform_device_register(&esp_1_pdev); 1067 break; 1068 case MAC_SCSI_IIFX: 1069 /* Addresses from The Guide to Mac Family Hardware. 1070 * $5000 8000 - $5000 9FFF: SCSI DMA 1071 * $5000 C000 - $5000 DFFF: Alternate SCSI (DMA) 1072 * $5000 E000 - $5000 FFFF: Alternate SCSI (Hsk) 1073 * The SCSI DMA custom IC embeds the 53C80 core. mac_scsi does 1074 * not make use of its DMA or hardware handshaking logic. 1075 */ 1076 platform_device_register_simple("mac_scsi", 0, 1077 mac_scsi_iifx_rsrc, ARRAY_SIZE(mac_scsi_iifx_rsrc)); 1078 break; 1079 case MAC_SCSI_DUO: 1080 /* Addresses from the Duo Dock II Developer Note. 1081 * $FEE0 2000 - $FEE0 3FFF: normal mode 1082 * $FEE0 4000 - $FEE0 5FFF: pseudo DMA without /DRQ 1083 * $FEE0 6000 - $FEE0 7FFF: pseudo DMA with /DRQ 1084 * The NetBSD code indicates that both 5380 chips share 1085 * an IRQ (?) which would need careful handling (see mac_esp). 1086 */ 1087 platform_device_register_simple("mac_scsi", 1, 1088 mac_scsi_duo_rsrc, ARRAY_SIZE(mac_scsi_duo_rsrc)); 1089 /* fall through */ 1090 case MAC_SCSI_OLD: 1091 /* Addresses from Developer Notes for Duo System, 1092 * PowerBook 180 & 160, 140 & 170, Macintosh IIsi 1093 * and also from The Guide to Mac Family Hardware for 1094 * SE/30, II, IIx, IIcx, IIci. 1095 * $5000 6000 - $5000 7FFF: pseudo-DMA with /DRQ 1096 * $5001 0000 - $5001 1FFF: normal mode 1097 * $5001 2000 - $5001 3FFF: pseudo-DMA without /DRQ 1098 * GMFH says that $5000 0000 - $50FF FFFF "wraps 1099 * $5000 0000 - $5001 FFFF eight times" (!) 1100 * mess.org says IIci and Color Classic do not alias 1101 * I/O address space. 1102 */ 1103 platform_device_register_simple("mac_scsi", 0, 1104 mac_scsi_old_rsrc, ARRAY_SIZE(mac_scsi_old_rsrc)); 1105 break; 1106 case MAC_SCSI_LATE: 1107 /* PDMA logic in 68040 PowerBooks is somehow different to 1108 * '030 models. It's probably more like Quadras (see mac_esp). 1109 */ 1110 platform_device_register_simple("mac_scsi", 0, 1111 mac_scsi_late_rsrc, ARRAY_SIZE(mac_scsi_late_rsrc)); 1112 break; 1113 case MAC_SCSI_LC: 1114 /* Addresses from Mac LC data in Designing Cards & Drivers 3ed. 1115 * Also from the Developer Notes for Classic II, LC III, 1116 * Color Classic and IIvx. 1117 * $50F0 6000 - $50F0 7FFF: SCSI handshake 1118 * $50F1 0000 - $50F1 1FFF: SCSI 1119 * $50F1 2000 - $50F1 3FFF: SCSI DMA 1120 */ 1121 platform_device_register_simple("mac_scsi", 0, 1122 mac_scsi_ccl_rsrc, ARRAY_SIZE(mac_scsi_ccl_rsrc)); 1123 break; 1124 } 1125 1126 /* 1127 * Ethernet device 1128 */ 1129 1130 switch (macintosh_config->ether_type) { 1131 case MAC_ETHER_SONIC: 1132 platform_device_register(&sonic_pdev); 1133 break; 1134 case MAC_ETHER_MACE: 1135 platform_device_register(&mace_pdev); 1136 break; 1137 } 1138 1139 return 0; 1140 } 1141 1142 arch_initcall(mac_platform_init); 1143