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