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