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

source code of linux/arch/m68k/mac/config.c