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