1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <linux/types.h>
28#include <linux/mm.h>
29#include <linux/seq_file.h>
30#include <linux/console.h>
31#include <linux/init.h>
32#include <linux/delay.h>
33#include <linux/ioport.h>
34#include <linux/vt_kern.h>
35#include <linux/module.h>
36
37#include <asm/bootinfo.h>
38#include <asm/setup.h>
39#include <asm/atarihw.h>
40#include <asm/atariints.h>
41#include <asm/atari_stram.h>
42#include <asm/system.h>
43#include <asm/machdep.h>
44#include <asm/hwtest.h>
45#include <asm/io.h>
46
47u_long atari_mch_cookie;
48EXPORT_SYMBOL(atari_mch_cookie);
49
50u_long atari_mch_type;
51EXPORT_SYMBOL(atari_mch_type);
52
53struct atari_hw_present atari_hw_present;
54EXPORT_SYMBOL(atari_hw_present);
55
56u_long atari_switches;
57EXPORT_SYMBOL(atari_switches);
58
59int atari_dont_touch_floppy_select;
60EXPORT_SYMBOL(atari_dont_touch_floppy_select);
61
62int atari_rtc_year_offset;
63
64
65static void atari_reset(void);
66static void atari_get_model(char *model);
67static void atari_get_hardware_list(struct seq_file *m);
68
69
70extern void atari_init_IRQ (void);
71extern void atari_mksound(unsigned int count, unsigned int ticks);
72#ifdef CONFIG_HEARTBEAT
73static void atari_heartbeat(int on);
74#endif
75
76
77extern void atari_sched_init(irq_handler_t);
78extern unsigned long atari_gettimeoffset (void);
79extern int atari_mste_hwclk (int, struct rtc_time *);
80extern int atari_tt_hwclk (int, struct rtc_time *);
81extern int atari_mste_set_clock_mmss (unsigned long);
82extern int atari_tt_set_clock_mmss (unsigned long);
83
84
85
86
87
88
89
90
91
92
93static int __init scc_test(volatile char *ctla)
94{
95 if (!hwreg_present(ctla))
96 return 0;
97 MFPDELAY();
98
99 *ctla = 2;
100 MFPDELAY();
101 *ctla = 0x40;
102 MFPDELAY();
103
104 *ctla = 2;
105 MFPDELAY();
106 if (*ctla != 0x40)
107 return 0;
108 MFPDELAY();
109
110 *ctla = 2;
111 MFPDELAY();
112 *ctla = 0x60;
113 MFPDELAY();
114
115 *ctla = 2;
116 MFPDELAY();
117 if (*ctla != 0x60)
118 return 0;
119
120 return 1;
121}
122
123
124
125
126
127
128int __init atari_parse_bootinfo(const struct bi_record *record)
129{
130 int unknown = 0;
131 const u_long *data = record->data;
132
133 switch (record->tag) {
134 case BI_ATARI_MCH_COOKIE:
135 atari_mch_cookie = *data;
136 break;
137 case BI_ATARI_MCH_TYPE:
138 atari_mch_type = *data;
139 break;
140 default:
141 unknown = 1;
142 break;
143 }
144 return unknown;
145}
146
147
148
149static int __init atari_switches_setup(char *str)
150{
151 char switches[strlen(str) + 1];
152 char *p;
153 int ovsc_shift;
154 char *args = switches;
155
156 if (!MACH_IS_ATARI)
157 return 0;
158
159
160 strcpy(switches, str);
161 atari_switches = 0;
162
163
164 while ((p = strsep(&args, ",")) != NULL) {
165 if (!*p)
166 continue;
167 ovsc_shift = 0;
168 if (strncmp(p, "ov_", 3) == 0) {
169 p += 3;
170 ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
171 }
172
173 if (strcmp(p, "ikbd") == 0) {
174
175 atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
176 } else if (strcmp(p, "midi") == 0) {
177
178 atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
179 } else if (strcmp(p, "snd6") == 0) {
180 atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
181 } else if (strcmp(p, "snd7") == 0) {
182 atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
183 }
184 }
185 return 0;
186}
187
188early_param("switches", atari_switches_setup);
189
190
191
192
193
194
195void __init config_atari(void)
196{
197 unsigned short tos_version;
198
199 memset(&atari_hw_present, 0, sizeof(atari_hw_present));
200
201
202 ioport_resource.end = 0xFFFFFFFF;
203
204 mach_sched_init = atari_sched_init;
205 mach_init_IRQ = atari_init_IRQ;
206 mach_get_model = atari_get_model;
207 mach_get_hardware_list = atari_get_hardware_list;
208 mach_gettimeoffset = atari_gettimeoffset;
209 mach_reset = atari_reset;
210 mach_max_dma_address = 0xffffff;
211#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
212 mach_beep = atari_mksound;
213#endif
214#ifdef CONFIG_HEARTBEAT
215 mach_heartbeat = atari_heartbeat;
216#endif
217
218
219 if (atari_switches & ATARI_SWITCH_IKBD)
220 acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
221 if (atari_switches & ATARI_SWITCH_MIDI)
222 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
223 if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
224 sound_ym.rd_data_reg_sel = 14;
225 sound_ym.wd_data = sound_ym.rd_data_reg_sel |
226 ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
227 ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
228 }
229
230
231
232
233
234 printk("Atari hardware found: ");
235 if (MACH_IS_MEDUSA) {
236
237
238 } else if (hwreg_present(f030_xreg)) {
239 ATARIHW_SET(VIDEL_SHIFTER);
240 printk("VIDEL ");
241
242
243
244
245
246 ATARIHW_SET(ST_SCSI);
247 printk("STDMA-SCSI ");
248 } else if (hwreg_present(tt_palette)) {
249 ATARIHW_SET(TT_SHIFTER);
250 printk("TT_SHIFTER ");
251 } else if (hwreg_present(&shifter.bas_hi)) {
252 if (hwreg_present(&shifter.bas_lo) &&
253 (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) {
254 ATARIHW_SET(EXTD_SHIFTER);
255 printk("EXTD_SHIFTER ");
256 } else {
257 ATARIHW_SET(STND_SHIFTER);
258 printk("STND_SHIFTER ");
259 }
260 }
261 if (hwreg_present(&st_mfp.par_dt_reg)) {
262 ATARIHW_SET(ST_MFP);
263 printk("ST_MFP ");
264 }
265 if (hwreg_present(&tt_mfp.par_dt_reg)) {
266 ATARIHW_SET(TT_MFP);
267 printk("TT_MFP ");
268 }
269 if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) {
270 ATARIHW_SET(SCSI_DMA);
271 printk("TT_SCSI_DMA ");
272 }
273
274
275
276
277 if (MACH_IS_MEDUSA ||
278 (hwreg_present(&st_dma.dma_vhi) &&
279 (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
280 st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
281 (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
282 st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
283 ATARIHW_SET(EXTD_DMA);
284 printk("EXTD_DMA ");
285 }
286 if (hwreg_present(&tt_scsi.scsi_data)) {
287 ATARIHW_SET(TT_SCSI);
288 printk("TT_SCSI ");
289 }
290 if (hwreg_present(&sound_ym.rd_data_reg_sel)) {
291 ATARIHW_SET(YM_2149);
292 printk("YM2149 ");
293 }
294 if (!MACH_IS_MEDUSA && hwreg_present(&tt_dmasnd.ctrl)) {
295 ATARIHW_SET(PCM_8BIT);
296 printk("PCM ");
297 }
298 if (hwreg_present(&falcon_codec.unused5)) {
299 ATARIHW_SET(CODEC);
300 printk("CODEC ");
301 }
302 if (hwreg_present(&dsp56k_host_interface.icr)) {
303 ATARIHW_SET(DSP56K);
304 printk("DSP56K ");
305 }
306 if (hwreg_present(&tt_scc_dma.dma_ctrl) &&
307#if 0
308
309 (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
310 (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
311#else
312 !MACH_IS_MEDUSA
313#endif
314 ) {
315 ATARIHW_SET(SCC_DMA);
316 printk("SCC_DMA ");
317 }
318 if (scc_test(&scc.cha_a_ctrl)) {
319 ATARIHW_SET(SCC);
320 printk("SCC ");
321 }
322 if (scc_test(&st_escc.cha_b_ctrl)) {
323 ATARIHW_SET(ST_ESCC);
324 printk("ST_ESCC ");
325 }
326 if (hwreg_present(&tt_scu.sys_mask)) {
327 ATARIHW_SET(SCU);
328
329 ATARIHW_SET(VME);
330 printk("VME SCU ");
331 }
332 if (hwreg_present((void *)(0xffff9210))) {
333 ATARIHW_SET(ANALOG_JOY);
334 printk("ANALOG_JOY ");
335 }
336 if (hwreg_present(blitter.halftone)) {
337 ATARIHW_SET(BLITTER);
338 printk("BLITTER ");
339 }
340 if (hwreg_present((void *)0xfff00039)) {
341 ATARIHW_SET(IDE);
342 printk("IDE ");
343 }
344#if 1
345 if (!MACH_IS_MEDUSA && hwreg_present(&tt_microwire.data) &&
346 hwreg_present(&tt_microwire.mask) &&
347 (tt_microwire.mask = 0x7ff,
348 udelay(1),
349 tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
350 udelay(1),
351 tt_microwire.data != 0)) {
352 ATARIHW_SET(MICROWIRE);
353 while (tt_microwire.mask != 0x7ff)
354 ;
355 printk("MICROWIRE ");
356 }
357#endif
358 if (hwreg_present(&tt_rtc.regsel)) {
359 ATARIHW_SET(TT_CLK);
360 printk("TT_CLK ");
361 mach_hwclk = atari_tt_hwclk;
362 mach_set_clock_mmss = atari_tt_set_clock_mmss;
363 }
364 if (hwreg_present(&mste_rtc.sec_ones)) {
365 ATARIHW_SET(MSTE_CLK);
366 printk("MSTE_CLK ");
367 mach_hwclk = atari_mste_hwclk;
368 mach_set_clock_mmss = atari_mste_set_clock_mmss;
369 }
370 if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
371 hwreg_write(&dma_wd.fdc_speed, 0)) {
372 ATARIHW_SET(FDCSPEED);
373 printk("FDC_SPEED ");
374 }
375 if (!ATARIHW_PRESENT(ST_SCSI)) {
376 ATARIHW_SET(ACSI);
377 printk("ACSI ");
378 }
379 printk("\n");
380
381 if (CPU_IS_040_OR_060)
382
383
384
385
386 asm volatile ("\n"
387 " moveq #0,%%d0\n"
388 " .chip 68040\n"
389 " movec %%d0,%%itt0\n"
390 " movec %%d0,%%dtt0\n"
391 " .chip 68k"
392 :
393 :
394 : "d0");
395
396
397 atari_stram_init();
398
399
400
401
402
403
404
405
406
407
408
409
410 if (CPU_IS_020_OR_030) {
411 unsigned long tt1_val;
412 tt1_val = 0xfe008543;
413
414
415 asm volatile ("\n"
416 " .chip 68030\n"
417 " pmove %0@,%/tt1\n"
418 " .chip 68k"
419 : : "a" (&tt1_val));
420 } else {
421 asm volatile ("\n"
422 " .chip 68040\n"
423 " movec %0,%%itt1\n"
424 " movec %0,%%dtt1\n"
425 " .chip 68k"
426 :
427 : "d" (0xfe00a040));
428
429
430
431 }
432
433
434
435
436
437
438
439
440
441
442
443 tos_version = (MACH_IS_MEDUSA) ?
444 0xfff : *(unsigned short *)0xff000002;
445 atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
446}
447
448#ifdef CONFIG_HEARTBEAT
449static void atari_heartbeat(int on)
450{
451 unsigned char tmp;
452 unsigned long flags;
453
454 if (atari_dont_touch_floppy_select)
455 return;
456
457 local_irq_save(flags);
458 sound_ym.rd_data_reg_sel = 14;
459 tmp = sound_ym.rd_data_reg_sel;
460 sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
461 local_irq_restore(flags);
462}
463#endif
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496static void atari_reset(void)
497{
498 long tc_val = 0;
499 long reset_addr;
500
501
502
503
504
505 reset_addr = MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
506 *(unsigned long *) 0xff000004;
507
508
509 if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
510 acia.key_ctrl = ACIA_RESET;
511 if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
512 acia.mid_ctrl = ACIA_RESET;
513
514
515
516
517
518 local_irq_disable();
519 asm volatile ("movec %0,%%vbr"
520 : : "d" (0));
521
522 if (CPU_IS_040_OR_060) {
523 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
524 if (CPU_IS_060) {
525
526 asm volatile ("\n"
527 " .chip 68060\n"
528 " movec %0,%%pcr\n"
529 " .chip 68k"
530 : : "d" (0));
531 }
532
533 asm volatile ("\n"
534 " move.l %0,%%d0\n"
535 " and.l #0xff000000,%%d0\n"
536 " or.w #0xe020,%%d0\n"
537 " .chip 68040\n"
538 " movec %%d0,%%itt0\n"
539 " movec %%d0,%%dtt0\n"
540 " .chip 68k\n"
541 " jmp %0@"
542 : : "a" (jmp_addr040)
543 : "d0");
544 jmp_addr_label040:
545 asm volatile ("\n"
546 " moveq #0,%%d0\n"
547 " nop\n"
548 " .chip 68040\n"
549 " cinva %%bc\n"
550 " nop\n"
551 " pflusha\n"
552 " nop\n"
553 " movec %%d0,%%tc\n"
554 " nop\n"
555
556
557
558
559 " move.l #0xffc000,%%d0\n"
560 " movec %%d0,%%itt0\n"
561 " movec %%d0,%%itt1\n"
562 " or.w #0x40,%/d0\n"
563 " movec %%d0,%%dtt0\n"
564 " movec %%d0,%%dtt1\n"
565 " .chip 68k\n"
566 " jmp %0@"
567 :
568 : "a" (reset_addr)
569 : "d0");
570 } else
571 asm volatile ("\n"
572 " pmove %0@,%%tc\n"
573 " jmp %1@"
574 :
575 : "a" (&tc_val), "a" (reset_addr));
576}
577
578
579static void atari_get_model(char *model)
580{
581 strcpy(model, "Atari ");
582 switch (atari_mch_cookie >> 16) {
583 case ATARI_MCH_ST:
584 if (ATARIHW_PRESENT(MSTE_CLK))
585 strcat(model, "Mega ST");
586 else
587 strcat(model, "ST");
588 break;
589 case ATARI_MCH_STE:
590 if (MACH_IS_MSTE)
591 strcat(model, "Mega STE");
592 else
593 strcat(model, "STE");
594 break;
595 case ATARI_MCH_TT:
596 if (MACH_IS_MEDUSA)
597
598 strcat(model, "Medusa");
599 else
600 strcat(model, "TT");
601 break;
602 case ATARI_MCH_FALCON:
603 strcat(model, "Falcon");
604 if (MACH_IS_AB40)
605 strcat(model, " (with Afterburner040)");
606 break;
607 default:
608 sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
609 atari_mch_cookie);
610 break;
611 }
612}
613
614
615static void atari_get_hardware_list(struct seq_file *m)
616{
617 int i;
618
619 for (i = 0; i < m68k_num_memory; i++)
620 seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n",
621 m68k_memory[i].size >> 20, m68k_memory[i].addr,
622 (m68k_memory[i].addr & 0xff000000 ?
623 "alternate RAM" : "ST-RAM"));
624
625#define ATARIHW_ANNOUNCE(name, str) \
626 if (ATARIHW_PRESENT(name)) \
627 seq_printf(m, "\t%s\n", str)
628
629 seq_printf(m, "Detected hardware:\n");
630 ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
631 ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
632 ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
633 ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
634 ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
635 ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
636 ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
637 ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
638 ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
639 ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
640 ATARIHW_ANNOUNCE(IDE, "IDE Interface");
641 ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
642 ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
643 ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
644 ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
645 ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
646 ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
647 ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
648 ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
649 ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
650 ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
651 ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
652 ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
653 ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
654 ATARIHW_ANNOUNCE(SCU, "System Control Unit");
655 ATARIHW_ANNOUNCE(BLITTER, "Blitter");
656 ATARIHW_ANNOUNCE(VME, "VME Bus");
657 ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
658}
659