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