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