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