1/*
2 *  linux/arch/m68k/atari/config.c
3 *
4 *  Copyright (C) 1994 Bjoern Brauel
5 *
6 *  5/2/94 Roman Hodek:
7 *    Added setting of time_adj to get a better clock.
8 *
9 *  5/14/94 Roman Hodek:
10 *    gettod() for TT
11 *
12 *  5/15/94 Roman Hodek:
13 *    hard_reset_now() for Atari (and others?)
14 *
15 *  94/12/30 Andreas Schwab:
16 *    atari_sched_init fixed to get precise clock.
17 *
18 * This file is subject to the terms and conditions of the GNU General Public
19 * License.  See the file COPYING in the main directory of this archive
20 * for more details.
21 */
22
23/*
24 * Miscellaneous atari stuff
25 */
26
27#include <linux/config.h>
28#include <linux/types.h>
29#include <linux/mm.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
36#include <asm/bootinfo.h>
37#include <asm/setup.h>
38#include <asm/atarihw.h>
39#include <asm/atariints.h>
40#include <asm/atari_stram.h>
41#include <asm/system.h>
42#include <asm/keyboard.h>
43#include <asm/machdep.h>
44#include <asm/hwtest.h>
45#include <asm/io.h>
46
47u_long atari_mch_cookie;
48u_long atari_mch_type = 0;
49struct atari_hw_present atari_hw_present;
50u_long atari_switches = 0;
51int atari_dont_touch_floppy_select = 0;
52int atari_rtc_year_offset;
53
54/* local function prototypes */
55static void atari_reset( void );
56#ifdef CONFIG_ATARI_FLOPPY
57extern void atari_floppy_setup(char *, int *);
58#endif
59static void atari_get_model(char *model);
60static int atari_get_hardware_list(char *buffer);
61
62/* atari specific keyboard functions */
63extern int atari_keyb_init(void);
64extern int atari_kbdrate (struct kbd_repeat *);
65extern int atari_kbd_translate(unsigned char keycode, unsigned char *keycodep,
66			       char raw_mode);
67extern void atari_kbd_leds (unsigned int);
68/* atari specific irq functions */
69extern void atari_init_IRQ (void);
70extern int atari_request_irq (unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
71                              unsigned long flags, const char *devname, void *dev_id);
72extern void atari_free_irq (unsigned int irq, void *dev_id);
73extern void atari_enable_irq (unsigned int);
74extern void atari_disable_irq (unsigned int);
75extern int atari_get_irq_list (char *buf);
76extern void atari_mksound( unsigned int count, unsigned int ticks );
77#ifdef CONFIG_HEARTBEAT
78static void atari_heartbeat( int on );
79#endif
80
81/* atari specific timer functions (in time.c) */
82extern void atari_sched_init(void (*)(int, void *, struct pt_regs *));
83extern unsigned long atari_gettimeoffset (void);
84extern void atari_mste_gettod (int *, int *, int *, int *, int *, int *);
85extern void atari_tt_gettod (int *, int *, int *, int *, int *, int *);
86extern int atari_mste_hwclk (int, struct rtc_time *);
87extern int atari_tt_hwclk (int, struct rtc_time *);
88extern int atari_mste_set_clock_mmss (unsigned long);
89extern int atari_tt_set_clock_mmss (unsigned long);
90
91/* atari specific debug functions (in debug.c) */
92extern void atari_debug_init(void);
93
94#ifdef CONFIG_MAGIC_SYSRQ
95static char atari_sysrq_xlate[128] =
96	"\000\0331234567890-=\177\t"					/* 0x00 - 0x0f */
97	"qwertyuiop[]\r\000as"							/* 0x10 - 0x1f */
98	"dfghjkl;'`\000\\zxcv"							/* 0x20 - 0x2f */
99	"bnm,./\000\000\000 \000\201\202\203\204\205"	/* 0x30 - 0x3f */
100	"\206\207\210\211\212\000\000\000\000\000-\000\000\000+\000"/* 0x40 - 0x4f */
101	"\000\000\000\177\000\000\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
102	"\000\000\000()/*789456123"						/* 0x60 - 0x6f */
103	"0.\r\000\000\000\000\000\000\000\000\000\000\000\000\000";	/* 0x70 - 0x7f */
104#endif
105
106
107/* I've moved hwreg_present() and hwreg_present_bywrite() out into
108 * mm/hwtest.c, to avoid having multiple copies of the same routine
109 * in the kernel [I wanted them in hp300 and they were already used
110 * in the nubus code. NB: I don't have an Atari so this might (just
111 * conceivably) break something.
112 * I've preserved the #if 0 version of hwreg_present_bywrite() here
113 * for posterity.
114 *   -- Peter Maydell <pmaydell@chiark.greenend.org.uk>, 05/1998
115 */
116
117
118
119/* ++roman: This is a more elaborate test for an SCC chip, since the plain
120 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
121 * board in the Medusa is possible. Also, the addresses where the ST_ESCC
122 * resides generate DTACK without the chip, too.
123 * The method is to write values into the interrupt vector register, that
124 * should be readable without trouble (from channel A!).
125 */
126
127static int __init scc_test( volatile char *ctla )
128{
129	if (!hwreg_present( ctla ))
130		return( 0 );
131	MFPDELAY();
132
133	*ctla = 2; MFPDELAY();
134	*ctla = 0x40; MFPDELAY();
135
136	*ctla = 2; MFPDELAY();
137	if (*ctla != 0x40) return( 0 );
138	MFPDELAY();
139
140	*ctla = 2; MFPDELAY();
141	*ctla = 0x60; MFPDELAY();
142
143	*ctla = 2; MFPDELAY();
144	if (*ctla != 0x60) return( 0 );
145
146	return( 1 );
147}
148
149
150    /*
151     *  Parse an Atari-specific record in the bootinfo
152     */
153
154int __init atari_parse_bootinfo(const struct bi_record *record)
155{
156    int unknown = 0;
157    const u_long *data = record->data;
158
159    switch (record->tag) {
160	case BI_ATARI_MCH_COOKIE:
161	    atari_mch_cookie = *data;
162	    break;
163	case BI_ATARI_MCH_TYPE:
164	    atari_mch_type = *data;
165	    break;
166	default:
167	    unknown = 1;
168    }
169    return(unknown);
170}
171
172
173/* Parse the Atari-specific switches= option. */
174void __init atari_switches_setup( const char *str, unsigned len )
175{
176    char switches[len+1];
177    char *p;
178    int ovsc_shift;
179
180    /* copy string to local array, strtok works destructively... */
181    strncpy( switches, str, len );
182    switches[len] = 0;
183    atari_switches = 0;
184
185    /* parse the options */
186    for( p = strtok( switches, "," ); p; p = strtok( NULL, "," ) ) {
187	ovsc_shift = 0;
188	if (strncmp( p, "ov_", 3 ) == 0) {
189	    p += 3;
190	    ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
191	}
192
193	if (strcmp( p, "ikbd" ) == 0) {
194	    /* RTS line of IKBD ACIA */
195	    atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
196	}
197	else if (strcmp( p, "midi" ) == 0) {
198	    /* RTS line of MIDI ACIA */
199	    atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
200	}
201	else if (strcmp( p, "snd6" ) == 0) {
202	    atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
203	}
204	else if (strcmp( p, "snd7" ) == 0) {
205	    atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
206	}
207    }
208}
209
210
211    /*
212     *  Setup the Atari configuration info
213     */
214
215void __init config_atari(void)
216{
217    unsigned short tos_version;
218
219    memset(&atari_hw_present, 0, sizeof(atari_hw_present));
220
221    atari_debug_init();
222
223    ioport_resource.end  = 0xFFFFFFFF;  /* Change size of I/O space from 64KB
224                                           to 4GB. */
225
226    mach_sched_init      = atari_sched_init;
227#ifdef CONFIG_VT
228    mach_keyb_init       = atari_keyb_init;
229    mach_kbdrate         = atari_kbdrate;
230    mach_kbd_translate   = atari_kbd_translate;
231    mach_kbd_leds        = atari_kbd_leds;
232    kd_mksound		 = atari_mksound;
233#endif
234    mach_init_IRQ        = atari_init_IRQ;
235    mach_request_irq     = atari_request_irq;
236    mach_free_irq        = atari_free_irq;
237    enable_irq           = atari_enable_irq;
238    disable_irq          = atari_disable_irq;
239    mach_get_model	 = atari_get_model;
240    mach_get_hardware_list = atari_get_hardware_list;
241    mach_get_irq_list	 = atari_get_irq_list;
242    mach_gettimeoffset   = atari_gettimeoffset;
243    mach_reset           = atari_reset;
244#ifdef CONFIG_ATARI_FLOPPY
245    mach_floppy_setup	 = atari_floppy_setup;
246#endif
247#ifdef CONFIG_DUMMY_CONSOLE
248    conswitchp	         = &dummy_con;
249#endif
250    mach_max_dma_address = 0xffffff;
251#ifdef CONFIG_MAGIC_SYSRQ
252    SYSRQ_KEY            = 0xff;
253    mach_sysrq_key = 98;          /* HELP */
254    mach_sysrq_shift_state = 8;   /* Alt */
255    mach_sysrq_shift_mask = 0xff; /* all modifiers except CapsLock */
256    mach_sysrq_xlate = atari_sysrq_xlate;
257#endif
258#ifdef CONFIG_HEARTBEAT
259    mach_heartbeat = atari_heartbeat;
260#endif
261
262    /* Set switches as requested by the user */
263    if (atari_switches & ATARI_SWITCH_IKBD)
264	acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
265    if (atari_switches & ATARI_SWITCH_MIDI)
266	acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
267    if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
268	sound_ym.rd_data_reg_sel = 14;
269	sound_ym.wd_data = sound_ym.rd_data_reg_sel |
270			   ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
271			   ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
272    }
273
274    /* ++bjoern:
275     * Determine hardware present
276     */
277
278    printk( "Atari hardware found: " );
279    if (MACH_IS_MEDUSA || MACH_IS_HADES) {
280        /* There's no Atari video hardware on the Medusa, but all the
281         * addresses below generate a DTACK so no bus error occurs! */
282    }
283    else if (hwreg_present( f030_xreg )) {
284	ATARIHW_SET(VIDEL_SHIFTER);
285        printk( "VIDEL " );
286        /* This is a temporary hack: If there is Falcon video
287         * hardware, we assume that the ST-DMA serves SCSI instead of
288         * ACSI. In the future, there should be a better method for
289         * this...
290         */
291	ATARIHW_SET(ST_SCSI);
292        printk( "STDMA-SCSI " );
293    }
294    else if (hwreg_present( tt_palette )) {
295	ATARIHW_SET(TT_SHIFTER);
296        printk( "TT_SHIFTER " );
297    }
298    else if (hwreg_present( &shifter.bas_hi )) {
299        if (hwreg_present( &shifter.bas_lo ) &&
300	    (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) {
301	    ATARIHW_SET(EXTD_SHIFTER);
302            printk( "EXTD_SHIFTER " );
303        }
304        else {
305	    ATARIHW_SET(STND_SHIFTER);
306            printk( "STND_SHIFTER " );
307        }
308    }
309    if (hwreg_present( &mfp.par_dt_reg )) {
310	ATARIHW_SET(ST_MFP);
311        printk( "ST_MFP " );
312    }
313    if (hwreg_present( &tt_mfp.par_dt_reg )) {
314	ATARIHW_SET(TT_MFP);
315        printk( "TT_MFP " );
316    }
317    if (hwreg_present( &tt_scsi_dma.dma_addr_hi )) {
318	ATARIHW_SET(SCSI_DMA);
319        printk( "TT_SCSI_DMA " );
320    }
321    if (!MACH_IS_HADES && hwreg_present( &st_dma.dma_hi )) {
322	ATARIHW_SET(STND_DMA);
323        printk( "STND_DMA " );
324    }
325    if (MACH_IS_MEDUSA || /* The ST-DMA address registers aren't readable
326			   * on all Medusas, so the test below may fail */
327        (hwreg_present( &st_dma.dma_vhi ) &&
328         (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
329         st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
330         (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
331         st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
332	ATARIHW_SET(EXTD_DMA);
333        printk( "EXTD_DMA " );
334    }
335    if (hwreg_present( &tt_scsi.scsi_data )) {
336	ATARIHW_SET(TT_SCSI);
337        printk( "TT_SCSI " );
338    }
339    if (hwreg_present( &sound_ym.rd_data_reg_sel )) {
340	ATARIHW_SET(YM_2149);
341        printk( "YM2149 " );
342    }
343    if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
344	hwreg_present( &tt_dmasnd.ctrl )) {
345	ATARIHW_SET(PCM_8BIT);
346        printk( "PCM " );
347    }
348    if (!MACH_IS_HADES && hwreg_present( &codec.unused5 )) {
349	ATARIHW_SET(CODEC);
350        printk( "CODEC " );
351    }
352    if (hwreg_present( &dsp56k_host_interface.icr )) {
353	ATARIHW_SET(DSP56K);
354        printk( "DSP56K " );
355    }
356    if (hwreg_present( &tt_scc_dma.dma_ctrl ) &&
357	!MACH_IS_MEDUSA && !MACH_IS_HADES
358	) {
359	ATARIHW_SET(SCC_DMA);
360        printk( "SCC_DMA " );
361    }
362    if (scc_test( &scc.cha_a_ctrl )) {
363	ATARIHW_SET(SCC);
364        printk( "SCC " );
365    }
366    if (scc_test( &st_escc.cha_b_ctrl )) {
367	ATARIHW_SET( ST_ESCC );
368	printk( "ST_ESCC " );
369    }
370    if (MACH_IS_HADES)
371    {
372        ATARIHW_SET( VME );
373        printk( "VME " );
374    }
375    else if (hwreg_present( &tt_scu.sys_mask )) {
376	ATARIHW_SET(SCU);
377	/* Assume a VME bus if there's a SCU */
378	ATARIHW_SET( VME );
379        printk( "VME SCU " );
380    }
381    if (hwreg_present( (void *)(0xffff9210) )) {
382	ATARIHW_SET(ANALOG_JOY);
383        printk( "ANALOG_JOY " );
384    }
385    if (!MACH_IS_HADES && hwreg_present( blitter.halftone )) {
386	ATARIHW_SET(BLITTER);
387        printk( "BLITTER " );
388    }
389    if (hwreg_present((void *)0xfff00039)) {
390	ATARIHW_SET(IDE);
391        printk( "IDE " );
392    }
393    if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
394	hwreg_present( &tt_microwire.data ) &&
395	hwreg_present( &tt_microwire.mask ) &&
396	(tt_microwire.mask = 0x7ff,
397	 udelay(1),
398	 tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
399	 udelay(1),
400	 tt_microwire.data != 0)) {
401	ATARIHW_SET(MICROWIRE);
402	while (tt_microwire.mask != 0x7ff) ;
403        printk( "MICROWIRE " );
404    }
405    if (hwreg_present( &tt_rtc.regsel )) {
406	ATARIHW_SET(TT_CLK);
407        printk( "TT_CLK " );
408        mach_gettod = atari_tt_gettod;
409        mach_hwclk = atari_tt_hwclk;
410        mach_set_clock_mmss = atari_tt_set_clock_mmss;
411    }
412    if (!MACH_IS_HADES && hwreg_present( &mste_rtc.sec_ones)) {
413	ATARIHW_SET(MSTE_CLK);
414        printk( "MSTE_CLK ");
415        mach_gettod = atari_mste_gettod;
416        mach_hwclk = atari_mste_hwclk;
417        mach_set_clock_mmss = atari_mste_set_clock_mmss;
418    }
419    if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
420	hwreg_present( &dma_wd.fdc_speed ) &&
421	hwreg_write( &dma_wd.fdc_speed, 0 )) {
422	    ATARIHW_SET(FDCSPEED);
423	    printk( "FDC_SPEED ");
424    }
425    if (!MACH_IS_HADES && !ATARIHW_PRESENT(ST_SCSI)) {
426	ATARIHW_SET(ACSI);
427        printk( "ACSI " );
428    }
429    printk("\n");
430
431    if (CPU_IS_040_OR_060)
432        /* Now it seems to be safe to turn of the tt0 transparent
433         * translation (the one that must not be turned off in
434         * head.S...)
435         */
436        __asm__ volatile ("moveq #0,%/d0\n\t"
437                          ".chip 68040\n\t"
438			  "movec %%d0,%%itt0\n\t"
439			  "movec %%d0,%%dtt0\n\t"
440			  ".chip 68k"
441						  : /* no outputs */
442						  : /* no inputs */
443						  : "d0");
444
445    /* allocator for memory that must reside in st-ram */
446    atari_stram_init ();
447
448    /* Set up a mapping for the VMEbus address region:
449     *
450     * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff
451     * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at
452     * 0xfe000000 virt., because this can be done with a single
453     * transparent translation. On the 68040, lots of often unused
454     * page tables would be needed otherwise. On a MegaSTE or similar,
455     * the highest byte is stripped off by hardware due to the 24 bit
456     * design of the bus.
457     */
458
459    if (CPU_IS_020_OR_030) {
460        unsigned long	tt1_val;
461        tt1_val = 0xfe008543;	/* Translate 0xfexxxxxx, enable, cache
462                                 * inhibit, read and write, FDC mask = 3,
463                                 * FDC val = 4 -> Supervisor only */
464        __asm__ __volatile__ ( ".chip 68030\n\t"
465				"pmove	%0@,%/tt1\n\t"
466				".chip 68k"
467				: : "a" (&tt1_val) );
468    }
469    else {
470        __asm__ __volatile__
471            ( "movel %0,%/d0\n\t"
472	      ".chip 68040\n\t"
473	      "movec %%d0,%%itt1\n\t"
474	      "movec %%d0,%%dtt1\n\t"
475	      ".chip 68k"
476              :
477              : "g" (0xfe00a040)	/* Translate 0xfexxxxxx, enable,
478                                         * supervisor only, non-cacheable/
479                                         * serialized, writable */
480              : "d0" );
481
482    }
483
484    /* Fetch tos version at Physical 2 */
485    /* We my not be able to access this address if the kernel is
486       loaded to st ram, since the first page is unmapped.  On the
487       Medusa this is always the case and there is nothing we can do
488       about this, so we just assume the smaller offset.  For the TT
489       we use the fact that in head.S we have set up a mapping
490       0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
491       in the last 16MB of the address space. */
492    tos_version = (MACH_IS_MEDUSA || MACH_IS_HADES) ?
493		  0xfff : *(unsigned short *)0xff000002;
494    atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
495}
496
497#ifdef CONFIG_HEARTBEAT
498static void atari_heartbeat( int on )
499{
500    unsigned char tmp;
501    unsigned long flags;
502
503    if (atari_dont_touch_floppy_select)
504	return;
505
506    save_flags(flags);
507    cli();
508    sound_ym.rd_data_reg_sel = 14; /* Select PSG Port A */
509    tmp = sound_ym.rd_data_reg_sel;
510    sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
511    restore_flags(flags);
512}
513#endif
514
515/* ++roman:
516 *
517 * This function does a reset on machines that lack the ability to
518 * assert the processor's _RESET signal somehow via hardware. It is
519 * based on the fact that you can find the initial SP and PC values
520 * after a reset at physical addresses 0 and 4. This works pretty well
521 * for Atari machines, since the lowest 8 bytes of physical memory are
522 * really ROM (mapped by hardware). For other 680x0 machines: don't
523 * know if it works...
524 *
525 * To get the values at addresses 0 and 4, the MMU better is turned
526 * off first. After that, we have to jump into physical address space
527 * (the PC before the pmove statement points to the virtual address of
528 * the code). Getting that physical address is not hard, but the code
529 * becomes a bit complex since I've tried to ensure that the jump
530 * statement after the pmove is in the cache already (otherwise the
531 * processor can't fetch it!). For that, the code first jumps to the
532 * jump statement with the (virtual) address of the pmove section in
533 * an address register . The jump statement is surely in the cache
534 * now. After that, that physical address of the reset code is loaded
535 * into the same address register, pmove is done and the same jump
536 * statements goes to the reset code. Since there are not many
537 * statements between the two jumps, I hope it stays in the cache.
538 *
539 * The C code makes heavy use of the GCC features that you can get the
540 * address of a C label. No hope to compile this with another compiler
541 * than GCC!
542 */
543
544/* ++andreas: no need for complicated code, just depend on prefetch */
545
546static void atari_reset (void)
547{
548    long tc_val = 0;
549    long reset_addr;
550
551    /* On the Medusa, phys. 0x4 may contain garbage because it's no
552       ROM.  See above for explanation why we cannot use PTOV(4). */
553    reset_addr = MACH_IS_HADES ? 0x7fe00030 :
554                 MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
555		 *(unsigned long *) 0xff000004;
556
557    /* reset ACIA for switch off OverScan, if it's active */
558    if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
559	acia.key_ctrl = ACIA_RESET;
560    if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
561	acia.mid_ctrl = ACIA_RESET;
562
563    /* processor independent: turn off interrupts and reset the VBR;
564     * the caches must be left enabled, else prefetching the final jump
565     * instruction doesn't work. */
566    cli();
567    __asm__ __volatile__
568	("moveq	#0,%/d0\n\t"
569	 "movec	%/d0,%/vbr"
570	 : : : "d0" );
571
572    if (CPU_IS_040_OR_060) {
573        unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
574	if (CPU_IS_060) {
575	    /* 68060: clear PCR to turn off superscalar operation */
576	    __asm__ __volatile__
577		("moveq	#0,%/d0\n\t"
578		 ".chip 68060\n\t"
579		 "movec %%d0,%%pcr\n\t"
580		 ".chip 68k"
581		 : : : "d0" );
582	}
583
584        __asm__ __volatile__
585            ("movel    %0,%/d0\n\t"
586             "andl     #0xff000000,%/d0\n\t"
587             "orw      #0xe020,%/d0\n\t"   /* map 16 MB, enable, cacheable */
588             ".chip 68040\n\t"
589	     "movec    %%d0,%%itt0\n\t"
590             "movec    %%d0,%%dtt0\n\t"
591	     ".chip 68k\n\t"
592             "jmp   %0@\n\t"
593             : /* no outputs */
594             : "a" (jmp_addr040)
595             : "d0" );
596      jmp_addr_label040:
597        __asm__ __volatile__
598          ("moveq #0,%/d0\n\t"
599	   "nop\n\t"
600	   ".chip 68040\n\t"
601	   "cinva %%bc\n\t"
602	   "nop\n\t"
603	   "pflusha\n\t"
604	   "nop\n\t"
605	   "movec %%d0,%%tc\n\t"
606	   "nop\n\t"
607	   /* the following setup of transparent translations is needed on the
608	    * Afterburner040 to successfully reboot. Other machines shouldn't
609	    * care about a different tt regs setup, they also didn't care in
610	    * the past that the regs weren't turned off. */
611	   "movel #0xffc000,%%d0\n\t" /* whole insn space cacheable */
612	   "movec %%d0,%%itt0\n\t"
613	   "movec %%d0,%%itt1\n\t"
614	   "orw   #0x40,%/d0\n\t" /* whole data space non-cacheable/ser. */
615	   "movec %%d0,%%dtt0\n\t"
616	   "movec %%d0,%%dtt1\n\t"
617	   ".chip 68k\n\t"
618           "jmp %0@"
619           : /* no outputs */
620           : "a" (reset_addr)
621           : "d0");
622    }
623    else
624        __asm__ __volatile__
625            ("pmove %0@,%/tc\n\t"
626             "jmp %1@"
627             : /* no outputs */
628             : "a" (&tc_val), "a" (reset_addr));
629}
630
631
632static void atari_get_model(char *model)
633{
634    strcpy(model, "Atari ");
635    switch (atari_mch_cookie >> 16) {
636	case ATARI_MCH_ST:
637	    if (ATARIHW_PRESENT(MSTE_CLK))
638		strcat (model, "Mega ST");
639	    else
640		strcat (model, "ST");
641	    break;
642	case ATARI_MCH_STE:
643	    if (MACH_IS_MSTE)
644		strcat (model, "Mega STE");
645	    else
646		strcat (model, "STE");
647	    break;
648	case ATARI_MCH_TT:
649	    if (MACH_IS_MEDUSA)
650		/* Medusa has TT _MCH cookie */
651		strcat (model, "Medusa");
652	    else if (MACH_IS_HADES)
653		strcat(model, "Hades");
654	    else
655		strcat (model, "TT");
656	    break;
657	case ATARI_MCH_FALCON:
658	    strcat (model, "Falcon");
659	    if (MACH_IS_AB40)
660		strcat (model, " (with Afterburner040)");
661	    break;
662	default:
663	    sprintf (model + strlen (model), "(unknown mach cookie 0x%lx)",
664		     atari_mch_cookie);
665	    break;
666    }
667}
668
669
670static int atari_get_hardware_list(char *buffer)
671{
672    int len = 0, i;
673
674    for (i = 0; i < m68k_num_memory; i++)
675	len += sprintf (buffer+len, "\t%3ld MB at 0x%08lx (%s)\n",
676			m68k_memory[i].size >> 20, m68k_memory[i].addr,
677			(m68k_memory[i].addr & 0xff000000 ?
678			 "alternate RAM" : "ST-RAM"));
679
680#define ATARIHW_ANNOUNCE(name,str)				\
681    if (ATARIHW_PRESENT(name))			\
682	len += sprintf (buffer + len, "\t%s\n", str)
683
684    len += sprintf (buffer + len, "Detected hardware:\n");
685    ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
686    ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
687    ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
688    ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
689    ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
690    ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
691    ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
692    ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
693    ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
694    ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
695    ATARIHW_ANNOUNCE(IDE, "IDE Interface");
696    ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
697    ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
698    ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
699    ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
700    ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
701    ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
702    ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
703    ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
704    ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
705    ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
706    ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
707    ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
708    ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
709    ATARIHW_ANNOUNCE(SCU, "System Control Unit");
710    ATARIHW_ANNOUNCE(BLITTER, "Blitter");
711    ATARIHW_ANNOUNCE(VME, "VME Bus");
712    ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
713
714    return(len);
715}
716
717/*
718 * Local variables:
719 *  c-indent-level: 4
720 *  tab-width: 8
721 * End:
722 */
723