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