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