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