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