Linux Audio

Check our new training course

Loading...
v3.15
  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/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/platform_device.h>
 35#include <linux/usb/isp116x.h>
 36#include <linux/vt_kern.h>
 37#include <linux/module.h>
 38
 39#include <asm/bootinfo.h>
 40#include <asm/bootinfo-atari.h>
 41#include <asm/byteorder.h>
 42#include <asm/setup.h>
 43#include <asm/atarihw.h>
 44#include <asm/atariints.h>
 45#include <asm/atari_stram.h>
 46#include <asm/machdep.h>
 47#include <asm/hwtest.h>
 48#include <asm/io.h>
 
 
 
 49
 50u_long atari_mch_cookie;
 51EXPORT_SYMBOL(atari_mch_cookie);
 52
 53u_long atari_mch_type;
 54EXPORT_SYMBOL(atari_mch_type);
 55
 56struct atari_hw_present atari_hw_present;
 57EXPORT_SYMBOL(atari_hw_present);
 58
 59u_long atari_switches;
 60EXPORT_SYMBOL(atari_switches);
 61
 62int atari_dont_touch_floppy_select;
 63EXPORT_SYMBOL(atari_dont_touch_floppy_select);
 64
 65int atari_rtc_year_offset;
 66
 67/* local function prototypes */
 68static void atari_reset(void);
 69static void atari_get_model(char *model);
 70static void atari_get_hardware_list(struct seq_file *m);
 71
 72/* atari specific irq functions */
 73extern void atari_init_IRQ (void);
 74extern void atari_mksound(unsigned int count, unsigned int ticks);
 75#ifdef CONFIG_HEARTBEAT
 76static void atari_heartbeat(int on);
 77#endif
 78
 79/* atari specific timer functions (in time.c) */
 80extern void atari_sched_init(irq_handler_t);
 81extern u32 atari_gettimeoffset(void);
 82extern int atari_mste_hwclk (int, struct rtc_time *);
 83extern int atari_tt_hwclk (int, struct rtc_time *);
 84extern int atari_mste_set_clock_mmss (unsigned long);
 85extern int atari_tt_set_clock_mmss (unsigned long);
 86
 87
 88/* ++roman: This is a more elaborate test for an SCC chip, since the plain
 89 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
 90 * board in the Medusa is possible. Also, the addresses where the ST_ESCC
 91 * resides generate DTACK without the chip, too.
 92 * The method is to write values into the interrupt vector register, that
 93 * should be readable without trouble (from channel A!).
 94 */
 95
 96static int __init scc_test(volatile char *ctla)
 97{
 98	if (!hwreg_present(ctla))
 99		return 0;
100	MFPDELAY();
101
102	*ctla = 2;
103	MFPDELAY();
104	*ctla = 0x40;
105	MFPDELAY();
106
107	*ctla = 2;
108	MFPDELAY();
109	if (*ctla != 0x40)
110		return 0;
111	MFPDELAY();
112
113	*ctla = 2;
114	MFPDELAY();
115	*ctla = 0x60;
116	MFPDELAY();
117
118	*ctla = 2;
119	MFPDELAY();
120	if (*ctla != 0x60)
121		return 0;
122
123	return 1;
124}
125
126
127    /*
128     *  Parse an Atari-specific record in the bootinfo
129     */
130
131int __init atari_parse_bootinfo(const struct bi_record *record)
132{
133	int unknown = 0;
134	const void *data = record->data;
135
136	switch (be16_to_cpu(record->tag)) {
137	case BI_ATARI_MCH_COOKIE:
138		atari_mch_cookie = be32_to_cpup(data);
139		break;
140	case BI_ATARI_MCH_TYPE:
141		atari_mch_type = be32_to_cpup(data);
142		break;
143	default:
144		unknown = 1;
145		break;
146	}
147	return unknown;
148}
149
150
151/* Parse the Atari-specific switches= option. */
152static int __init atari_switches_setup(char *str)
153{
154	char switches[strlen(str) + 1];
155	char *p;
156	int ovsc_shift;
157	char *args = switches;
158
159	if (!MACH_IS_ATARI)
160		return 0;
161
162	/* copy string to local array, strsep works destructively... */
163	strcpy(switches, str);
164	atari_switches = 0;
165
166	/* parse the options */
167	while ((p = strsep(&args, ",")) != NULL) {
168		if (!*p)
169			continue;
170		ovsc_shift = 0;
171		if (strncmp(p, "ov_", 3) == 0) {
172			p += 3;
173			ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
174		}
175
176		if (strcmp(p, "ikbd") == 0) {
177			/* RTS line of IKBD ACIA */
178			atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
179		} else if (strcmp(p, "midi") == 0) {
180			/* RTS line of MIDI ACIA */
181			atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
182		} else if (strcmp(p, "snd6") == 0) {
183			atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
184		} else if (strcmp(p, "snd7") == 0) {
185			atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
186		}
187	}
188	return 0;
189}
190
191early_param("switches", atari_switches_setup);
192
193
194    /*
195     *  Setup the Atari configuration info
196     */
197
198void __init config_atari(void)
199{
200	unsigned short tos_version;
201
202	memset(&atari_hw_present, 0, sizeof(atari_hw_present));
203
204	/* Change size of I/O space from 64KB to 4GB. */
205	ioport_resource.end  = 0xFFFFFFFF;
206
207	mach_sched_init      = atari_sched_init;
208	mach_init_IRQ        = atari_init_IRQ;
209	mach_get_model	 = atari_get_model;
210	mach_get_hardware_list = atari_get_hardware_list;
211	arch_gettimeoffset   = atari_gettimeoffset;
212	mach_reset           = atari_reset;
213	mach_max_dma_address = 0xffffff;
214#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
215	mach_beep          = atari_mksound;
216#endif
217#ifdef CONFIG_HEARTBEAT
218	mach_heartbeat = atari_heartbeat;
219#endif
220
221	/* Set switches as requested by the user */
222	if (atari_switches & ATARI_SWITCH_IKBD)
223		acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
224	if (atari_switches & ATARI_SWITCH_MIDI)
225		acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
226	if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
227		sound_ym.rd_data_reg_sel = 14;
228		sound_ym.wd_data = sound_ym.rd_data_reg_sel |
229				   ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
230				   ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
231	}
232
233	/* ++bjoern:
234	 * Determine hardware present
235	 */
236
237	printk("Atari hardware found: ");
238	if (MACH_IS_MEDUSA) {
239		/* There's no Atari video hardware on the Medusa, but all the
240		 * addresses below generate a DTACK so no bus error occurs! */
241	} else if (hwreg_present(f030_xreg)) {
242		ATARIHW_SET(VIDEL_SHIFTER);
243		printk("VIDEL ");
244		/* This is a temporary hack: If there is Falcon video
245		 * hardware, we assume that the ST-DMA serves SCSI instead of
246		 * ACSI. In the future, there should be a better method for
247		 * this...
248		 */
249		ATARIHW_SET(ST_SCSI);
250		printk("STDMA-SCSI ");
251	} else if (hwreg_present(tt_palette)) {
252		ATARIHW_SET(TT_SHIFTER);
253		printk("TT_SHIFTER ");
254	} else if (hwreg_present(&shifter.bas_hi)) {
255		if (hwreg_present(&shifter.bas_lo) &&
256		    (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) {
257			ATARIHW_SET(EXTD_SHIFTER);
258			printk("EXTD_SHIFTER ");
259		} else {
260			ATARIHW_SET(STND_SHIFTER);
261			printk("STND_SHIFTER ");
262		}
263	}
264	if (hwreg_present(&st_mfp.par_dt_reg)) {
265		ATARIHW_SET(ST_MFP);
266		printk("ST_MFP ");
267	}
268	if (hwreg_present(&tt_mfp.par_dt_reg)) {
269		ATARIHW_SET(TT_MFP);
270		printk("TT_MFP ");
271	}
272	if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) {
273		ATARIHW_SET(SCSI_DMA);
274		printk("TT_SCSI_DMA ");
275	}
276	/*
277	 * The ST-DMA address registers aren't readable
278	 * on all Medusas, so the test below may fail
279	 */
280	if (MACH_IS_MEDUSA ||
281	    (hwreg_present(&st_dma.dma_vhi) &&
282	     (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
283	     st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
284	     (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
285	     st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
286		ATARIHW_SET(EXTD_DMA);
287		printk("EXTD_DMA ");
288	}
289	if (hwreg_present(&tt_scsi.scsi_data)) {
290		ATARIHW_SET(TT_SCSI);
291		printk("TT_SCSI ");
292	}
293	if (hwreg_present(&sound_ym.rd_data_reg_sel)) {
294		ATARIHW_SET(YM_2149);
295		printk("YM2149 ");
296	}
297	if (!MACH_IS_MEDUSA && hwreg_present(&tt_dmasnd.ctrl)) {
298		ATARIHW_SET(PCM_8BIT);
299		printk("PCM ");
300	}
301	if (hwreg_present(&falcon_codec.unused5)) {
302		ATARIHW_SET(CODEC);
303		printk("CODEC ");
304	}
305	if (hwreg_present(&dsp56k_host_interface.icr)) {
306		ATARIHW_SET(DSP56K);
307		printk("DSP56K ");
308	}
309	if (hwreg_present(&tt_scc_dma.dma_ctrl) &&
310#if 0
311	    /* This test sucks! Who knows some better? */
312	    (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
313	    (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
314#else
315	    !MACH_IS_MEDUSA
316#endif
317	    ) {
318		ATARIHW_SET(SCC_DMA);
319		printk("SCC_DMA ");
320	}
321	if (scc_test(&atari_scc.cha_a_ctrl)) {
322		ATARIHW_SET(SCC);
323		printk("SCC ");
324	}
325	if (scc_test(&st_escc.cha_b_ctrl)) {
326		ATARIHW_SET(ST_ESCC);
327		printk("ST_ESCC ");
328	}
329	if (hwreg_present(&tt_scu.sys_mask)) {
330		ATARIHW_SET(SCU);
331		/* Assume a VME bus if there's a SCU */
332		ATARIHW_SET(VME);
333		printk("VME SCU ");
334	}
335	if (hwreg_present((void *)(0xffff9210))) {
336		ATARIHW_SET(ANALOG_JOY);
337		printk("ANALOG_JOY ");
338	}
339	if (hwreg_present(blitter.halftone)) {
340		ATARIHW_SET(BLITTER);
341		printk("BLITTER ");
342	}
343	if (hwreg_present((void *)0xfff00039)) {
344		ATARIHW_SET(IDE);
345		printk("IDE ");
346	}
347#if 1 /* This maybe wrong */
348	if (!MACH_IS_MEDUSA && hwreg_present(&tt_microwire.data) &&
349	    hwreg_present(&tt_microwire.mask) &&
350	    (tt_microwire.mask = 0x7ff,
351	     udelay(1),
352	     tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
353	     udelay(1),
354	     tt_microwire.data != 0)) {
355		ATARIHW_SET(MICROWIRE);
356		while (tt_microwire.mask != 0x7ff)
357			;
358		printk("MICROWIRE ");
359	}
360#endif
361	if (hwreg_present(&tt_rtc.regsel)) {
362		ATARIHW_SET(TT_CLK);
363		printk("TT_CLK ");
364		mach_hwclk = atari_tt_hwclk;
365		mach_set_clock_mmss = atari_tt_set_clock_mmss;
366	}
367	if (hwreg_present(&mste_rtc.sec_ones)) {
368		ATARIHW_SET(MSTE_CLK);
369		printk("MSTE_CLK ");
370		mach_hwclk = atari_mste_hwclk;
371		mach_set_clock_mmss = atari_mste_set_clock_mmss;
372	}
373	if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
374	    hwreg_write(&dma_wd.fdc_speed, 0)) {
375		ATARIHW_SET(FDCSPEED);
376		printk("FDC_SPEED ");
377	}
378	if (!ATARIHW_PRESENT(ST_SCSI)) {
379		ATARIHW_SET(ACSI);
380		printk("ACSI ");
381	}
382	printk("\n");
383
384	if (CPU_IS_040_OR_060)
385		/* Now it seems to be safe to turn of the tt0 transparent
386		 * translation (the one that must not be turned off in
387		 * head.S...)
388		 */
389		asm volatile ("\n"
390			"	moveq	#0,%%d0\n"
391			"	.chip	68040\n"
392			"	movec	%%d0,%%itt0\n"
393			"	movec	%%d0,%%dtt0\n"
394			"	.chip	68k"
395			: /* no outputs */
396			: /* no inputs */
397			: "d0");
398
399	/* allocator for memory that must reside in st-ram */
400	atari_stram_init();
401
402	/* Set up a mapping for the VMEbus address region:
403	 *
404	 * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff
405	 * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at
406	 * 0xfe000000 virt., because this can be done with a single
407	 * transparent translation. On the 68040, lots of often unused
408	 * page tables would be needed otherwise. On a MegaSTE or similar,
409	 * the highest byte is stripped off by hardware due to the 24 bit
410	 * design of the bus.
411	 */
412
413	if (CPU_IS_020_OR_030) {
414		unsigned long tt1_val;
415		tt1_val = 0xfe008543;	/* Translate 0xfexxxxxx, enable, cache
416					 * inhibit, read and write, FDC mask = 3,
417					 * FDC val = 4 -> Supervisor only */
418		asm volatile ("\n"
419			"	.chip	68030\n"
420			"	pmove	%0,%/tt1\n"
421			"	.chip	68k"
422			: : "m" (tt1_val));
423	} else {
424	        asm volatile ("\n"
425			"	.chip	68040\n"
426			"	movec	%0,%%itt1\n"
427			"	movec	%0,%%dtt1\n"
428			"	.chip	68k"
429			:
430			: "d" (0xfe00a040));	/* Translate 0xfexxxxxx, enable,
431						 * supervisor only, non-cacheable/
432						 * serialized, writable */
433
434	}
435
436	/* Fetch tos version at Physical 2 */
437	/*
438	 * We my not be able to access this address if the kernel is
439	 * loaded to st ram, since the first page is unmapped.  On the
440	 * Medusa this is always the case and there is nothing we can do
441	 * about this, so we just assume the smaller offset.  For the TT
442	 * we use the fact that in head.S we have set up a mapping
443	 * 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
444	 * in the last 16MB of the address space.
445	 */
446	tos_version = (MACH_IS_MEDUSA) ?
447			0xfff : *(unsigned short *)0xff000002;
448	atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
449}
450
451#ifdef CONFIG_HEARTBEAT
452static void atari_heartbeat(int on)
453{
454	unsigned char tmp;
455	unsigned long flags;
456
457	if (atari_dont_touch_floppy_select)
458		return;
459
460	local_irq_save(flags);
461	sound_ym.rd_data_reg_sel = 14;	/* Select PSG Port A */
462	tmp = sound_ym.rd_data_reg_sel;
463	sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
464	local_irq_restore(flags);
465}
466#endif
467
468/* ++roman:
469 *
470 * This function does a reset on machines that lack the ability to
471 * assert the processor's _RESET signal somehow via hardware. It is
472 * based on the fact that you can find the initial SP and PC values
473 * after a reset at physical addresses 0 and 4. This works pretty well
474 * for Atari machines, since the lowest 8 bytes of physical memory are
475 * really ROM (mapped by hardware). For other 680x0 machines: don't
476 * know if it works...
477 *
478 * To get the values at addresses 0 and 4, the MMU better is turned
479 * off first. After that, we have to jump into physical address space
480 * (the PC before the pmove statement points to the virtual address of
481 * the code). Getting that physical address is not hard, but the code
482 * becomes a bit complex since I've tried to ensure that the jump
483 * statement after the pmove is in the cache already (otherwise the
484 * processor can't fetch it!). For that, the code first jumps to the
485 * jump statement with the (virtual) address of the pmove section in
486 * an address register . The jump statement is surely in the cache
487 * now. After that, that physical address of the reset code is loaded
488 * into the same address register, pmove is done and the same jump
489 * statements goes to the reset code. Since there are not many
490 * statements between the two jumps, I hope it stays in the cache.
491 *
492 * The C code makes heavy use of the GCC features that you can get the
493 * address of a C label. No hope to compile this with another compiler
494 * than GCC!
495 */
496
497/* ++andreas: no need for complicated code, just depend on prefetch */
498
499static void atari_reset(void)
500{
501	long tc_val = 0;
502	long reset_addr;
503
504	/*
505	 * On the Medusa, phys. 0x4 may contain garbage because it's no
506	 * ROM.  See above for explanation why we cannot use PTOV(4).
507	 */
508	reset_addr = MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
509		     *(unsigned long *) 0xff000004;
510
511	/* reset ACIA for switch off OverScan, if it's active */
512	if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
513		acia.key_ctrl = ACIA_RESET;
514	if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
515		acia.mid_ctrl = ACIA_RESET;
516
517	/* processor independent: turn off interrupts and reset the VBR;
518	 * the caches must be left enabled, else prefetching the final jump
519	 * instruction doesn't work.
520	 */
521	local_irq_disable();
522	asm volatile ("movec	%0,%%vbr"
523			: : "d" (0));
524
525	if (CPU_IS_040_OR_060) {
526		unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
527		if (CPU_IS_060) {
528			/* 68060: clear PCR to turn off superscalar operation */
529			asm volatile ("\n"
530				"	.chip 68060\n"
531				"	movec %0,%%pcr\n"
532				"	.chip 68k"
533				: : "d" (0));
534		}
535
536		asm volatile ("\n"
537			"	move.l	%0,%%d0\n"
538			"	and.l	#0xff000000,%%d0\n"
539			"	or.w	#0xe020,%%d0\n"   /* map 16 MB, enable, cacheable */
540			"	.chip	68040\n"
541			"	movec	%%d0,%%itt0\n"
542			"	movec	%%d0,%%dtt0\n"
543			"	.chip	68k\n"
544			"	jmp	%0@"
545			: : "a" (jmp_addr040)
546			: "d0");
547	jmp_addr_label040:
548		asm volatile ("\n"
549			"	moveq	#0,%%d0\n"
550			"	nop\n"
551			"	.chip	68040\n"
552			"	cinva	%%bc\n"
553			"	nop\n"
554			"	pflusha\n"
555			"	nop\n"
556			"	movec	%%d0,%%tc\n"
557			"	nop\n"
558			/* the following setup of transparent translations is needed on the
559			 * Afterburner040 to successfully reboot. Other machines shouldn't
560			 * care about a different tt regs setup, they also didn't care in
561			 * the past that the regs weren't turned off. */
562			"	move.l	#0xffc000,%%d0\n" /* whole insn space cacheable */
563			"	movec	%%d0,%%itt0\n"
564			"	movec	%%d0,%%itt1\n"
565			"	or.w	#0x40,%/d0\n" /* whole data space non-cacheable/ser. */
566			"	movec	%%d0,%%dtt0\n"
567			"	movec	%%d0,%%dtt1\n"
568			"	.chip	68k\n"
569			"	jmp	%0@"
570			: /* no outputs */
571			: "a" (reset_addr)
572			: "d0");
573	} else
574		asm volatile ("\n"
575			"	pmove	%0,%%tc\n"
576			"	jmp	%1@"
577			: /* no outputs */
578			: "m" (tc_val), "a" (reset_addr));
579}
580
581
582static void atari_get_model(char *model)
583{
584	strcpy(model, "Atari ");
585	switch (atari_mch_cookie >> 16) {
586	case ATARI_MCH_ST:
587		if (ATARIHW_PRESENT(MSTE_CLK))
588			strcat(model, "Mega ST");
589		else
590			strcat(model, "ST");
591		break;
592	case ATARI_MCH_STE:
593		if (MACH_IS_MSTE)
594			strcat(model, "Mega STE");
595		else
596			strcat(model, "STE");
597		break;
598	case ATARI_MCH_TT:
599		if (MACH_IS_MEDUSA)
600			/* Medusa has TT _MCH cookie */
601			strcat(model, "Medusa");
602		else
603			strcat(model, "TT");
604		break;
605	case ATARI_MCH_FALCON:
606		strcat(model, "Falcon");
607		if (MACH_IS_AB40)
608			strcat(model, " (with Afterburner040)");
609		break;
610	default:
611		sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
612			atari_mch_cookie);
613		break;
614	}
615}
616
617
618static void atari_get_hardware_list(struct seq_file *m)
619{
620	int i;
621
622	for (i = 0; i < m68k_num_memory; i++)
623		seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n",
624				m68k_memory[i].size >> 20, m68k_memory[i].addr,
625				(m68k_memory[i].addr & 0xff000000 ?
626				 "alternate RAM" : "ST-RAM"));
627
628#define ATARIHW_ANNOUNCE(name, str)			\
629	if (ATARIHW_PRESENT(name))			\
630		seq_printf(m, "\t%s\n", str)
631
632	seq_printf(m, "Detected hardware:\n");
633	ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
634	ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
635	ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
636	ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
637	ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
638	ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
639	ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
640	ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
641	ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
642	ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
643	ATARIHW_ANNOUNCE(IDE, "IDE Interface");
644	ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
645	ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
646	ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
647	ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
648	ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
649	ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
650	ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
651	ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
652	ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
653	ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
654	ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
655	ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
656	ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
657	ATARIHW_ANNOUNCE(SCU, "System Control Unit");
658	ATARIHW_ANNOUNCE(BLITTER, "Blitter");
659	ATARIHW_ANNOUNCE(VME, "VME Bus");
660	ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
661}
662
663/*
664 * MSch: initial platform device support for Atari,
665 * required for EtherNAT/EtherNEC/NetUSBee drivers
666 */
667
668#if defined(CONFIG_ATARI_ETHERNAT) || defined(CONFIG_ATARI_ETHERNEC)
669static void isp1160_delay(struct device *dev, int delay)
670{
671	ndelay(delay);
672}
673#endif
674
675#ifdef CONFIG_ATARI_ETHERNAT
676/*
677 * EtherNAT: SMC91C111 Ethernet chipset, handled by smc91x driver
678 */
679
680#define ATARI_ETHERNAT_IRQ		140
681
682static struct resource smc91x_resources[] = {
683	[0] = {
684		.name	= "smc91x-regs",
685		.start	= ATARI_ETHERNAT_PHYS_ADDR,
686		.end	= ATARI_ETHERNAT_PHYS_ADDR + 0xfffff,
687		.flags	= IORESOURCE_MEM,
688	},
689	[1] = {
690		.name	= "smc91x-irq",
691		.start	= ATARI_ETHERNAT_IRQ,
692		.end	= ATARI_ETHERNAT_IRQ,
693		.flags	= IORESOURCE_IRQ,
694	},
695};
696
697static struct platform_device smc91x_device = {
698	.name		= "smc91x",
699	.id		= -1,
700	.num_resources	= ARRAY_SIZE(smc91x_resources),
701	.resource	= smc91x_resources,
702};
703
704/*
705 * ISP 1160 - using the isp116x-hcd module
706 */
707
708#define ATARI_USB_PHYS_ADDR	0x80000012
709#define ATARI_USB_IRQ		139
710
711static struct resource isp1160_resources[] = {
712	[0] = {
713		.name	= "isp1160-data",
714		.start	= ATARI_USB_PHYS_ADDR,
715		.end	= ATARI_USB_PHYS_ADDR + 0x1,
716		.flags	= IORESOURCE_MEM,
717	},
718	[1] = {
719		.name	= "isp1160-regs",
720		.start	= ATARI_USB_PHYS_ADDR + 0x4,
721		.end	= ATARI_USB_PHYS_ADDR + 0x5,
722		.flags	= IORESOURCE_MEM,
723	},
724	[2] = {
725		.name	= "isp1160-irq",
726		.start	= ATARI_USB_IRQ,
727		.end	= ATARI_USB_IRQ,
728		.flags	= IORESOURCE_IRQ,
729	},
730};
731
732/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
733static struct isp116x_platform_data isp1160_platform_data = {
734	/* Enable internal resistors on downstream ports */
735	.sel15Kres		= 1,
736	/* On-chip overcurrent protection */
737	.oc_enable		= 1,
738	/* INT output polarity */
739	.int_act_high		= 1,
740	/* INT edge or level triggered */
741	.int_edge_triggered	= 0,
742
743	/* WAKEUP pin connected - NOT SUPPORTED  */
744	/* .remote_wakeup_connected = 0, */
745	/* Wakeup by devices on usb bus enabled */
746	.remote_wakeup_enable	= 0,
747	.delay			= isp1160_delay,
748};
749
750static struct platform_device isp1160_device = {
751	.name		= "isp116x-hcd",
752	.id		= 0,
753	.num_resources	= ARRAY_SIZE(isp1160_resources),
754	.resource	= isp1160_resources,
755	.dev			= {
756		.platform_data	= &isp1160_platform_data,
757	},
758};
759
760static struct platform_device *atari_ethernat_devices[] __initdata = {
761	&smc91x_device,
762	&isp1160_device
763};
764#endif /* CONFIG_ATARI_ETHERNAT */
765
766#ifdef CONFIG_ATARI_ETHERNEC
767/*
768 * EtherNEC: RTL8019 (NE2000 compatible) Ethernet chipset,
769 * handled by ne.c driver
770 */
771
772#define ATARI_ETHERNEC_PHYS_ADDR	0xfffa0000
773#define ATARI_ETHERNEC_BASE		0x300
774#define ATARI_ETHERNEC_IRQ		IRQ_MFP_TIMER1
775
776static struct resource rtl8019_resources[] = {
777	[0] = {
778		.name	= "rtl8019-regs",
779		.start	= ATARI_ETHERNEC_BASE,
780		.end	= ATARI_ETHERNEC_BASE + 0x20 - 1,
781		.flags	= IORESOURCE_IO,
782	},
783	[1] = {
784		.name	= "rtl8019-irq",
785		.start	= ATARI_ETHERNEC_IRQ,
786		.end	= ATARI_ETHERNEC_IRQ,
787		.flags	= IORESOURCE_IRQ,
788	},
789};
790
791static struct platform_device rtl8019_device = {
792	.name		= "ne",
793	.id		= -1,
794	.num_resources	= ARRAY_SIZE(rtl8019_resources),
795	.resource	= rtl8019_resources,
796};
797
798/*
799 * NetUSBee: ISP1160 USB host adapter via ROM-port adapter
800 */
801
802#define ATARI_NETUSBEE_PHYS_ADDR	0xfffa8000
803#define ATARI_NETUSBEE_BASE		0x340
804#define ATARI_NETUSBEE_IRQ		IRQ_MFP_TIMER2
805
806static struct resource netusbee_resources[] = {
807	[0] = {
808		.name	= "isp1160-data",
809		.start	= ATARI_NETUSBEE_BASE,
810		.end	= ATARI_NETUSBEE_BASE + 0x1,
811		.flags	= IORESOURCE_MEM,
812	},
813	[1] = {
814		.name	= "isp1160-regs",
815		.start	= ATARI_NETUSBEE_BASE + 0x20,
816		.end	= ATARI_NETUSBEE_BASE + 0x21,
817		.flags	= IORESOURCE_MEM,
818	},
819	[2] = {
820		.name	= "isp1160-irq",
821		.start	= ATARI_NETUSBEE_IRQ,
822		.end	= ATARI_NETUSBEE_IRQ,
823		.flags	= IORESOURCE_IRQ,
824	},
825};
826
827/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
828static struct isp116x_platform_data netusbee_platform_data = {
829	/* Enable internal resistors on downstream ports */
830	.sel15Kres		= 1,
831	/* On-chip overcurrent protection */
832	.oc_enable		= 1,
833	/* INT output polarity */
834	.int_act_high		= 1,
835	/* INT edge or level triggered */
836	.int_edge_triggered	= 0,
837
838	/* WAKEUP pin connected - NOT SUPPORTED  */
839	/* .remote_wakeup_connected = 0, */
840	/* Wakeup by devices on usb bus enabled */
841	.remote_wakeup_enable	= 0,
842	.delay			= isp1160_delay,
843};
844
845static struct platform_device netusbee_device = {
846	.name		= "isp116x-hcd",
847	.id		= 1,
848	.num_resources	= ARRAY_SIZE(netusbee_resources),
849	.resource	= netusbee_resources,
850	.dev			= {
851		.platform_data	= &netusbee_platform_data,
852	},
853};
854
855static struct platform_device *atari_netusbee_devices[] __initdata = {
856	&rtl8019_device,
857	&netusbee_device
858};
859#endif /* CONFIG_ATARI_ETHERNEC */
860
861int __init atari_platform_init(void)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862{
 
863	int rv = 0;
864
865	if (!MACH_IS_ATARI)
866		return -ENODEV;
867
868#ifdef CONFIG_ATARI_ETHERNAT
869	{
870		unsigned char *enatc_virt;
871		enatc_virt = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0xf);
872		if (hwreg_present(enatc_virt)) {
873			rv = platform_add_devices(atari_ethernat_devices,
874						ARRAY_SIZE(atari_ethernat_devices));
875		}
876		iounmap(enatc_virt);
877	}
878#endif
879
880#ifdef CONFIG_ATARI_ETHERNEC
881	{
882		int error;
883		unsigned char *enec_virt;
884		enec_virt = (unsigned char *)ioremap((ATARI_ETHERNEC_PHYS_ADDR), 0xf);
885		if (hwreg_present(enec_virt)) {
886			error = platform_add_devices(atari_netusbee_devices,
887						ARRAY_SIZE(atari_netusbee_devices));
888			if (error && !rv)
889				rv = error;
890		}
891		iounmap(enec_virt);
892	}
893#endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
894
895	return rv;
896}
897
898arch_initcall(atari_platform_init);
v6.8
  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/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/platform_device.h>
 35#include <linux/usb/isp116x.h>
 36#include <linux/vt_kern.h>
 37#include <linux/module.h>
 38
 39#include <asm/bootinfo.h>
 40#include <asm/bootinfo-atari.h>
 41#include <asm/byteorder.h>
 42#include <asm/setup.h>
 43#include <asm/atarihw.h>
 44#include <asm/atariints.h>
 45#include <asm/atari_stram.h>
 46#include <asm/machdep.h>
 47#include <asm/hwtest.h>
 48#include <asm/io.h>
 49#include <asm/config.h>
 50
 51#include "atari.h"
 52
 53u_long atari_mch_cookie;
 54EXPORT_SYMBOL(atari_mch_cookie);
 55
 56u_long atari_mch_type;
 57EXPORT_SYMBOL(atari_mch_type);
 58
 59struct atari_hw_present atari_hw_present;
 60EXPORT_SYMBOL(atari_hw_present);
 61
 62u_long atari_switches;
 63EXPORT_SYMBOL(atari_switches);
 64
 65int atari_dont_touch_floppy_select;
 66EXPORT_SYMBOL(atari_dont_touch_floppy_select);
 67
 68int atari_rtc_year_offset;
 69
 70/* local function prototypes */
 71static void atari_reset(void);
 72static void atari_get_model(char *model);
 73static void atari_get_hardware_list(struct seq_file *m);
 
 
 
 
 74#ifdef CONFIG_HEARTBEAT
 75static void atari_heartbeat(int on);
 76#endif
 77
 
 
 
 
 
 
 
 
 
 78/* ++roman: This is a more elaborate test for an SCC chip, since the plain
 79 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
 80 * board in the Medusa is possible. Also, the addresses where the ST_ESCC
 81 * resides generate DTACK without the chip, too.
 82 * The method is to write values into the interrupt vector register, that
 83 * should be readable without trouble (from channel A!).
 84 */
 85
 86static int __init scc_test(volatile char *ctla)
 87{
 88	if (!hwreg_present(ctla))
 89		return 0;
 90	MFPDELAY();
 91
 92	*ctla = 2;
 93	MFPDELAY();
 94	*ctla = 0x40;
 95	MFPDELAY();
 96
 97	*ctla = 2;
 98	MFPDELAY();
 99	if (*ctla != 0x40)
100		return 0;
101	MFPDELAY();
102
103	*ctla = 2;
104	MFPDELAY();
105	*ctla = 0x60;
106	MFPDELAY();
107
108	*ctla = 2;
109	MFPDELAY();
110	if (*ctla != 0x60)
111		return 0;
112
113	return 1;
114}
115
116
117    /*
118     *  Parse an Atari-specific record in the bootinfo
119     */
120
121int __init atari_parse_bootinfo(const struct bi_record *record)
122{
123	int unknown = 0;
124	const void *data = record->data;
125
126	switch (be16_to_cpu(record->tag)) {
127	case BI_ATARI_MCH_COOKIE:
128		atari_mch_cookie = be32_to_cpup(data);
129		break;
130	case BI_ATARI_MCH_TYPE:
131		atari_mch_type = be32_to_cpup(data);
132		break;
133	default:
134		unknown = 1;
135		break;
136	}
137	return unknown;
138}
139
140
141/* Parse the Atari-specific switches= option. */
142static int __init atari_switches_setup(char *str)
143{
144	char switches[COMMAND_LINE_SIZE];
145	char *p;
146	int ovsc_shift;
147	char *args = switches;
148
149	if (!MACH_IS_ATARI)
150		return 0;
151
152	/* copy string to local array, strsep works destructively... */
153	strcpy(switches, str);
154	atari_switches = 0;
155
156	/* parse the options */
157	while ((p = strsep(&args, ",")) != NULL) {
158		if (!*p)
159			continue;
160		ovsc_shift = 0;
161		if (strncmp(p, "ov_", 3) == 0) {
162			p += 3;
163			ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
164		}
165
166		if (strcmp(p, "ikbd") == 0) {
167			/* RTS line of IKBD ACIA */
168			atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
169		} else if (strcmp(p, "midi") == 0) {
170			/* RTS line of MIDI ACIA */
171			atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
172		} else if (strcmp(p, "snd6") == 0) {
173			atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
174		} else if (strcmp(p, "snd7") == 0) {
175			atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
176		}
177	}
178	return 0;
179}
180
181early_param("switches", atari_switches_setup);
182
183
184    /*
185     *  Setup the Atari configuration info
186     */
187
188void __init config_atari(void)
189{
190	unsigned short tos_version;
191
192	memset(&atari_hw_present, 0, sizeof(atari_hw_present));
193
194	/* Change size of I/O space from 64KB to 4GB. */
195	ioport_resource.end  = 0xFFFFFFFF;
196
197	mach_sched_init      = atari_sched_init;
198	mach_init_IRQ        = atari_init_IRQ;
199	mach_get_model	 = atari_get_model;
200	mach_get_hardware_list = atari_get_hardware_list;
 
201	mach_reset           = atari_reset;
202#if IS_ENABLED(CONFIG_INPUT_M68K_BEEP)
 
203	mach_beep          = atari_mksound;
204#endif
205#ifdef CONFIG_HEARTBEAT
206	mach_heartbeat = atari_heartbeat;
207#endif
208
209	/* Set switches as requested by the user */
210	if (atari_switches & ATARI_SWITCH_IKBD)
211		acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
212	if (atari_switches & ATARI_SWITCH_MIDI)
213		acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
214	if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
215		sound_ym.rd_data_reg_sel = 14;
216		sound_ym.wd_data = sound_ym.rd_data_reg_sel |
217				   ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
218				   ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
219	}
220
221	/* ++bjoern:
222	 * Determine hardware present
223	 */
224
225	pr_info("Atari hardware found:");
226	if (MACH_IS_MEDUSA) {
227		/* There's no Atari video hardware on the Medusa, but all the
228		 * addresses below generate a DTACK so no bus error occurs! */
229	} else if (hwreg_present(f030_xreg)) {
230		ATARIHW_SET(VIDEL_SHIFTER);
231		pr_cont(" VIDEL");
232		/* This is a temporary hack: If there is Falcon video
233		 * hardware, we assume that the ST-DMA serves SCSI instead of
234		 * ACSI. In the future, there should be a better method for
235		 * this...
236		 */
237		ATARIHW_SET(ST_SCSI);
238		pr_cont(" STDMA-SCSI");
239	} else if (hwreg_present(tt_palette)) {
240		ATARIHW_SET(TT_SHIFTER);
241		pr_cont(" TT_SHIFTER");
242	} else if (hwreg_present(&shifter_st.bas_hi)) {
243		if (hwreg_present(&shifter_st.bas_lo) &&
244		    (shifter_st.bas_lo = 0x0aau, shifter_st.bas_lo == 0x0aau)) {
245			ATARIHW_SET(EXTD_SHIFTER);
246			pr_cont(" EXTD_SHIFTER");
247		} else {
248			ATARIHW_SET(STND_SHIFTER);
249			pr_cont(" STND_SHIFTER");
250		}
251	}
252	if (hwreg_present(&st_mfp.par_dt_reg)) {
253		ATARIHW_SET(ST_MFP);
254		pr_cont(" ST_MFP");
255	}
256	if (hwreg_present(&tt_mfp.par_dt_reg)) {
257		ATARIHW_SET(TT_MFP);
258		pr_cont(" TT_MFP");
259	}
260	if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) {
261		ATARIHW_SET(SCSI_DMA);
262		pr_cont(" TT_SCSI_DMA");
263	}
264	/*
265	 * The ST-DMA address registers aren't readable
266	 * on all Medusas, so the test below may fail
267	 */
268	if (MACH_IS_MEDUSA ||
269	    (hwreg_present(&st_dma.dma_vhi) &&
270	     (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
271	     st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
272	     (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
273	     st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
274		ATARIHW_SET(EXTD_DMA);
275		pr_cont(" EXTD_DMA");
276	}
277	if (hwreg_present(&tt_scsi.scsi_data)) {
278		ATARIHW_SET(TT_SCSI);
279		pr_cont(" TT_SCSI");
280	}
281	if (hwreg_present(&sound_ym.rd_data_reg_sel)) {
282		ATARIHW_SET(YM_2149);
283		pr_cont(" YM2149");
284	}
285	if (!MACH_IS_MEDUSA && hwreg_present(&tt_dmasnd.ctrl)) {
286		ATARIHW_SET(PCM_8BIT);
287		pr_cont(" PCM");
288	}
289	if (hwreg_present(&falcon_codec.unused5)) {
290		ATARIHW_SET(CODEC);
291		pr_cont(" CODEC");
292	}
293	if (hwreg_present(&dsp56k_host_interface.icr)) {
294		ATARIHW_SET(DSP56K);
295		pr_cont(" DSP56K");
296	}
297	if (hwreg_present(&tt_scc_dma.dma_ctrl) &&
298#if 0
299	    /* This test sucks! Who knows some better? */
300	    (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
301	    (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
302#else
303	    !MACH_IS_MEDUSA
304#endif
305	    ) {
306		ATARIHW_SET(SCC_DMA);
307		pr_cont(" SCC_DMA");
308	}
309	if (scc_test(&atari_scc.cha_a_ctrl)) {
310		ATARIHW_SET(SCC);
311		pr_cont(" SCC");
312	}
313	if (scc_test(&st_escc.cha_b_ctrl)) {
314		ATARIHW_SET(ST_ESCC);
315		pr_cont(" ST_ESCC");
316	}
317	if (hwreg_present(&tt_scu.sys_mask)) {
318		ATARIHW_SET(SCU);
319		/* Assume a VME bus if there's a SCU */
320		ATARIHW_SET(VME);
321		pr_cont(" VME SCU");
322	}
323	if (hwreg_present((void *)(0xffff9210))) {
324		ATARIHW_SET(ANALOG_JOY);
325		pr_cont(" ANALOG_JOY");
326	}
327	if (hwreg_present(blitter.halftone)) {
328		ATARIHW_SET(BLITTER);
329		pr_cont(" BLITTER");
330	}
331	if (hwreg_present((void *)0xfff00039)) {
332		ATARIHW_SET(IDE);
333		pr_cont(" IDE");
334	}
335#if 1 /* This maybe wrong */
336	if (!MACH_IS_MEDUSA && hwreg_present(&tt_microwire.data) &&
337	    hwreg_present(&tt_microwire.mask) &&
338	    (tt_microwire.mask = 0x7ff,
339	     udelay(1),
340	     tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
341	     udelay(1),
342	     tt_microwire.data != 0)) {
343		ATARIHW_SET(MICROWIRE);
344		while (tt_microwire.mask != 0x7ff)
345			;
346		pr_cont(" MICROWIRE");
347	}
348#endif
349	if (hwreg_present(&tt_rtc.regsel)) {
350		ATARIHW_SET(TT_CLK);
351		pr_cont(" TT_CLK");
352		mach_hwclk = atari_tt_hwclk;
 
353	}
354	if (hwreg_present(&mste_rtc.sec_ones)) {
355		ATARIHW_SET(MSTE_CLK);
356		pr_cont(" MSTE_CLK");
357		mach_hwclk = atari_mste_hwclk;
 
358	}
359	if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
360	    hwreg_write(&dma_wd.fdc_speed, 0)) {
361		ATARIHW_SET(FDCSPEED);
362		pr_cont(" FDC_SPEED");
363	}
364	if (!ATARIHW_PRESENT(ST_SCSI)) {
365		ATARIHW_SET(ACSI);
366		pr_cont(" ACSI");
367	}
368	pr_cont("\n");
369
370	if (CPU_IS_040_OR_060)
371		/* Now it seems to be safe to turn of the tt0 transparent
372		 * translation (the one that must not be turned off in
373		 * head.S...)
374		 */
375		asm volatile ("\n"
376			"	moveq	#0,%%d0\n"
377			"	.chip	68040\n"
378			"	movec	%%d0,%%itt0\n"
379			"	movec	%%d0,%%dtt0\n"
380			"	.chip	68k"
381			: /* no outputs */
382			: /* no inputs */
383			: "d0");
384
385	/* allocator for memory that must reside in st-ram */
386	atari_stram_init();
387
388	/* Set up a mapping for the VMEbus address region:
389	 *
390	 * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff
391	 * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at
392	 * 0xfe000000 virt., because this can be done with a single
393	 * transparent translation. On the 68040, lots of often unused
394	 * page tables would be needed otherwise. On a MegaSTE or similar,
395	 * the highest byte is stripped off by hardware due to the 24 bit
396	 * design of the bus.
397	 */
398
399	if (CPU_IS_020_OR_030) {
400		unsigned long tt1_val;
401		tt1_val = 0xfe008543;	/* Translate 0xfexxxxxx, enable, cache
402					 * inhibit, read and write, FDC mask = 3,
403					 * FDC val = 4 -> Supervisor only */
404		asm volatile ("\n"
405			"	.chip	68030\n"
406			"	pmove	%0,%/tt1\n"
407			"	.chip	68k"
408			: : "m" (tt1_val));
409	} else {
410	        asm volatile ("\n"
411			"	.chip	68040\n"
412			"	movec	%0,%%itt1\n"
413			"	movec	%0,%%dtt1\n"
414			"	.chip	68k"
415			:
416			: "d" (0xfe00a040));	/* Translate 0xfexxxxxx, enable,
417						 * supervisor only, non-cacheable/
418						 * serialized, writable */
419
420	}
421
422	/* Fetch tos version at Physical 2 */
423	/*
424	 * We my not be able to access this address if the kernel is
425	 * loaded to st ram, since the first page is unmapped.  On the
426	 * Medusa this is always the case and there is nothing we can do
427	 * about this, so we just assume the smaller offset.  For the TT
428	 * we use the fact that in head.S we have set up a mapping
429	 * 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
430	 * in the last 16MB of the address space.
431	 */
432	tos_version = (MACH_IS_MEDUSA) ?
433			0xfff : *(unsigned short *)0xff000002;
434	atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
435}
436
437#ifdef CONFIG_HEARTBEAT
438static void atari_heartbeat(int on)
439{
440	unsigned char tmp;
441	unsigned long flags;
442
443	if (atari_dont_touch_floppy_select)
444		return;
445
446	local_irq_save(flags);
447	sound_ym.rd_data_reg_sel = 14;	/* Select PSG Port A */
448	tmp = sound_ym.rd_data_reg_sel;
449	sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
450	local_irq_restore(flags);
451}
452#endif
453
454/* ++roman:
455 *
456 * This function does a reset on machines that lack the ability to
457 * assert the processor's _RESET signal somehow via hardware. It is
458 * based on the fact that you can find the initial SP and PC values
459 * after a reset at physical addresses 0 and 4. This works pretty well
460 * for Atari machines, since the lowest 8 bytes of physical memory are
461 * really ROM (mapped by hardware). For other 680x0 machines: don't
462 * know if it works...
463 *
464 * To get the values at addresses 0 and 4, the MMU better is turned
465 * off first. After that, we have to jump into physical address space
466 * (the PC before the pmove statement points to the virtual address of
467 * the code). Getting that physical address is not hard, but the code
468 * becomes a bit complex since I've tried to ensure that the jump
469 * statement after the pmove is in the cache already (otherwise the
470 * processor can't fetch it!). For that, the code first jumps to the
471 * jump statement with the (virtual) address of the pmove section in
472 * an address register . The jump statement is surely in the cache
473 * now. After that, that physical address of the reset code is loaded
474 * into the same address register, pmove is done and the same jump
475 * statements goes to the reset code. Since there are not many
476 * statements between the two jumps, I hope it stays in the cache.
477 *
478 * The C code makes heavy use of the GCC features that you can get the
479 * address of a C label. No hope to compile this with another compiler
480 * than GCC!
481 */
482
483/* ++andreas: no need for complicated code, just depend on prefetch */
484
485static void atari_reset(void)
486{
487	long tc_val = 0;
488	long reset_addr;
489
490	/*
491	 * On the Medusa, phys. 0x4 may contain garbage because it's no
492	 * ROM.  See above for explanation why we cannot use PTOV(4).
493	 */
494	reset_addr = MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
495		     *(unsigned long *) 0xff000004;
496
497	/* reset ACIA for switch off OverScan, if it's active */
498	if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
499		acia.key_ctrl = ACIA_RESET;
500	if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
501		acia.mid_ctrl = ACIA_RESET;
502
503	/* processor independent: turn off interrupts and reset the VBR;
504	 * the caches must be left enabled, else prefetching the final jump
505	 * instruction doesn't work.
506	 */
507	local_irq_disable();
508	asm volatile ("movec	%0,%%vbr"
509			: : "d" (0));
510
511	if (CPU_IS_040_OR_060) {
512		unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
513		if (CPU_IS_060) {
514			/* 68060: clear PCR to turn off superscalar operation */
515			asm volatile ("\n"
516				"	.chip 68060\n"
517				"	movec %0,%%pcr\n"
518				"	.chip 68k"
519				: : "d" (0));
520		}
521
522		asm volatile ("\n"
523			"	move.l	%0,%%d0\n"
524			"	and.l	#0xff000000,%%d0\n"
525			"	or.w	#0xe020,%%d0\n"   /* map 16 MB, enable, cacheable */
526			"	.chip	68040\n"
527			"	movec	%%d0,%%itt0\n"
528			"	movec	%%d0,%%dtt0\n"
529			"	.chip	68k\n"
530			"	jmp	%0@"
531			: : "a" (jmp_addr040)
532			: "d0");
533	jmp_addr_label040:
534		asm volatile ("\n"
535			"	moveq	#0,%%d0\n"
536			"	nop\n"
537			"	.chip	68040\n"
538			"	cinva	%%bc\n"
539			"	nop\n"
540			"	pflusha\n"
541			"	nop\n"
542			"	movec	%%d0,%%tc\n"
543			"	nop\n"
544			/* the following setup of transparent translations is needed on the
545			 * Afterburner040 to successfully reboot. Other machines shouldn't
546			 * care about a different tt regs setup, they also didn't care in
547			 * the past that the regs weren't turned off. */
548			"	move.l	#0xffc000,%%d0\n" /* whole insn space cacheable */
549			"	movec	%%d0,%%itt0\n"
550			"	movec	%%d0,%%itt1\n"
551			"	or.w	#0x40,%/d0\n" /* whole data space non-cacheable/ser. */
552			"	movec	%%d0,%%dtt0\n"
553			"	movec	%%d0,%%dtt1\n"
554			"	.chip	68k\n"
555			"	jmp	%0@"
556			: /* no outputs */
557			: "a" (reset_addr)
558			: "d0");
559	} else
560		asm volatile ("\n"
561			"	pmove	%0,%%tc\n"
562			"	jmp	%1@"
563			: /* no outputs */
564			: "m" (tc_val), "a" (reset_addr));
565}
566
567
568static void atari_get_model(char *model)
569{
570	strcpy(model, "Atari ");
571	switch (atari_mch_cookie >> 16) {
572	case ATARI_MCH_ST:
573		if (ATARIHW_PRESENT(MSTE_CLK))
574			strcat(model, "Mega ST");
575		else
576			strcat(model, "ST");
577		break;
578	case ATARI_MCH_STE:
579		if (MACH_IS_MSTE)
580			strcat(model, "Mega STE");
581		else
582			strcat(model, "STE");
583		break;
584	case ATARI_MCH_TT:
585		if (MACH_IS_MEDUSA)
586			/* Medusa has TT _MCH cookie */
587			strcat(model, "Medusa");
588		else
589			strcat(model, "TT");
590		break;
591	case ATARI_MCH_FALCON:
592		strcat(model, "Falcon");
593		if (MACH_IS_AB40)
594			strcat(model, " (with Afterburner040)");
595		break;
596	default:
597		sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
598			atari_mch_cookie);
599		break;
600	}
601}
602
603
604static void atari_get_hardware_list(struct seq_file *m)
605{
606	int i;
607
608	for (i = 0; i < m68k_num_memory; i++)
609		seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n",
610				m68k_memory[i].size >> 20, m68k_memory[i].addr,
611				(m68k_memory[i].addr & 0xff000000 ?
612				 "alternate RAM" : "ST-RAM"));
613
614#define ATARIHW_ANNOUNCE(name, str)			\
615	if (ATARIHW_PRESENT(name))			\
616		seq_printf(m, "\t%s\n", str)
617
618	seq_puts(m, "Detected hardware:\n");
619	ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
620	ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
621	ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
622	ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
623	ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
624	ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
625	ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
626	ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
627	ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
628	ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
629	ATARIHW_ANNOUNCE(IDE, "IDE Interface");
630	ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
631	ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
632	ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
633	ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
634	ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
635	ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
636	ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
637	ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
638	ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
639	ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
640	ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
641	ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
642	ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
643	ATARIHW_ANNOUNCE(SCU, "System Control Unit");
644	ATARIHW_ANNOUNCE(BLITTER, "Blitter");
645	ATARIHW_ANNOUNCE(VME, "VME Bus");
646	ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
647}
648
649/*
650 * MSch: initial platform device support for Atari,
651 * required for EtherNAT/EtherNEC/NetUSBee drivers
652 */
653
654#if defined(CONFIG_ATARI_ETHERNAT) || defined(CONFIG_ATARI_ETHERNEC)
655static void isp1160_delay(struct device *dev, int delay)
656{
657	ndelay(delay);
658}
659#endif
660
661#ifdef CONFIG_ATARI_ETHERNAT
662/*
663 * EtherNAT: SMC91C111 Ethernet chipset, handled by smc91x driver
664 */
665
666#define ATARI_ETHERNAT_IRQ		140
667
668static struct resource smc91x_resources[] = {
669	[0] = {
670		.name	= "smc91x-regs",
671		.start	= ATARI_ETHERNAT_PHYS_ADDR,
672		.end	= ATARI_ETHERNAT_PHYS_ADDR + 0xfffff,
673		.flags	= IORESOURCE_MEM,
674	},
675	[1] = {
676		.name	= "smc91x-irq",
677		.start	= ATARI_ETHERNAT_IRQ,
678		.end	= ATARI_ETHERNAT_IRQ,
679		.flags	= IORESOURCE_IRQ,
680	},
681};
682
683static struct platform_device smc91x_device = {
684	.name		= "smc91x",
685	.id		= -1,
686	.num_resources	= ARRAY_SIZE(smc91x_resources),
687	.resource	= smc91x_resources,
688};
689
690/*
691 * ISP 1160 - using the isp116x-hcd module
692 */
693
694#define ATARI_USB_PHYS_ADDR	0x80000012
695#define ATARI_USB_IRQ		139
696
697static struct resource isp1160_resources[] = {
698	[0] = {
699		.name	= "isp1160-data",
700		.start	= ATARI_USB_PHYS_ADDR,
701		.end	= ATARI_USB_PHYS_ADDR + 0x1,
702		.flags	= IORESOURCE_MEM,
703	},
704	[1] = {
705		.name	= "isp1160-regs",
706		.start	= ATARI_USB_PHYS_ADDR + 0x4,
707		.end	= ATARI_USB_PHYS_ADDR + 0x5,
708		.flags	= IORESOURCE_MEM,
709	},
710	[2] = {
711		.name	= "isp1160-irq",
712		.start	= ATARI_USB_IRQ,
713		.end	= ATARI_USB_IRQ,
714		.flags	= IORESOURCE_IRQ,
715	},
716};
717
718/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
719static struct isp116x_platform_data isp1160_platform_data = {
720	/* Enable internal resistors on downstream ports */
721	.sel15Kres		= 1,
722	/* On-chip overcurrent protection */
723	.oc_enable		= 1,
724	/* INT output polarity */
725	.int_act_high		= 1,
726	/* INT edge or level triggered */
727	.int_edge_triggered	= 0,
728
729	/* WAKEUP pin connected - NOT SUPPORTED  */
730	/* .remote_wakeup_connected = 0, */
731	/* Wakeup by devices on usb bus enabled */
732	.remote_wakeup_enable	= 0,
733	.delay			= isp1160_delay,
734};
735
736static struct platform_device isp1160_device = {
737	.name		= "isp116x-hcd",
738	.id		= 0,
739	.num_resources	= ARRAY_SIZE(isp1160_resources),
740	.resource	= isp1160_resources,
741	.dev			= {
742		.platform_data	= &isp1160_platform_data,
743	},
744};
745
746static struct platform_device *atari_ethernat_devices[] __initdata = {
747	&smc91x_device,
748	&isp1160_device
749};
750#endif /* CONFIG_ATARI_ETHERNAT */
751
752#ifdef CONFIG_ATARI_ETHERNEC
753/*
754 * EtherNEC: RTL8019 (NE2000 compatible) Ethernet chipset,
755 * handled by ne.c driver
756 */
757
758#define ATARI_ETHERNEC_PHYS_ADDR	0xfffa0000
759#define ATARI_ETHERNEC_BASE		0x300
760#define ATARI_ETHERNEC_IRQ		IRQ_MFP_TIMER1
761
762static struct resource rtl8019_resources[] = {
763	[0] = {
764		.name	= "rtl8019-regs",
765		.start	= ATARI_ETHERNEC_BASE,
766		.end	= ATARI_ETHERNEC_BASE + 0x20 - 1,
767		.flags	= IORESOURCE_IO,
768	},
769	[1] = {
770		.name	= "rtl8019-irq",
771		.start	= ATARI_ETHERNEC_IRQ,
772		.end	= ATARI_ETHERNEC_IRQ,
773		.flags	= IORESOURCE_IRQ,
774	},
775};
776
777static struct platform_device rtl8019_device = {
778	.name		= "ne",
779	.id		= -1,
780	.num_resources	= ARRAY_SIZE(rtl8019_resources),
781	.resource	= rtl8019_resources,
782};
783
784/*
785 * NetUSBee: ISP1160 USB host adapter via ROM-port adapter
786 */
787
788#define ATARI_NETUSBEE_PHYS_ADDR	0xfffa8000
789#define ATARI_NETUSBEE_BASE		0x340
790#define ATARI_NETUSBEE_IRQ		IRQ_MFP_TIMER2
791
792static struct resource netusbee_resources[] = {
793	[0] = {
794		.name	= "isp1160-data",
795		.start	= ATARI_NETUSBEE_BASE,
796		.end	= ATARI_NETUSBEE_BASE + 0x1,
797		.flags	= IORESOURCE_MEM,
798	},
799	[1] = {
800		.name	= "isp1160-regs",
801		.start	= ATARI_NETUSBEE_BASE + 0x20,
802		.end	= ATARI_NETUSBEE_BASE + 0x21,
803		.flags	= IORESOURCE_MEM,
804	},
805	[2] = {
806		.name	= "isp1160-irq",
807		.start	= ATARI_NETUSBEE_IRQ,
808		.end	= ATARI_NETUSBEE_IRQ,
809		.flags	= IORESOURCE_IRQ,
810	},
811};
812
813/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
814static struct isp116x_platform_data netusbee_platform_data = {
815	/* Enable internal resistors on downstream ports */
816	.sel15Kres		= 1,
817	/* On-chip overcurrent protection */
818	.oc_enable		= 1,
819	/* INT output polarity */
820	.int_act_high		= 1,
821	/* INT edge or level triggered */
822	.int_edge_triggered	= 0,
823
824	/* WAKEUP pin connected - NOT SUPPORTED  */
825	/* .remote_wakeup_connected = 0, */
826	/* Wakeup by devices on usb bus enabled */
827	.remote_wakeup_enable	= 0,
828	.delay			= isp1160_delay,
829};
830
831static struct platform_device netusbee_device = {
832	.name		= "isp116x-hcd",
833	.id		= 1,
834	.num_resources	= ARRAY_SIZE(netusbee_resources),
835	.resource	= netusbee_resources,
836	.dev			= {
837		.platform_data	= &netusbee_platform_data,
838	},
839};
840
841static struct platform_device *atari_netusbee_devices[] __initdata = {
842	&rtl8019_device,
843	&netusbee_device
844};
845#endif /* CONFIG_ATARI_ETHERNEC */
846
847#if IS_ENABLED(CONFIG_ATARI_SCSI)
848static const struct resource atari_scsi_st_rsrc[] __initconst = {
849	{
850		.flags = IORESOURCE_IRQ,
851		.start = IRQ_MFP_FSCSI,
852		.end   = IRQ_MFP_FSCSI,
853	},
854};
855
856static const struct resource atari_scsi_tt_rsrc[] __initconst = {
857	{
858		.flags = IORESOURCE_IRQ,
859		.start = IRQ_TT_MFP_SCSI,
860		.end   = IRQ_TT_MFP_SCSI,
861	},
862};
863#endif
864
865/*
866 * Falcon IDE interface
867 */
868
869#define FALCON_IDE_BASE	0xfff00000
870
871static const struct resource atari_falconide_rsrc[] __initconst = {
872	DEFINE_RES_MEM(FALCON_IDE_BASE, 0x38),
873	DEFINE_RES_MEM(FALCON_IDE_BASE + 0x38, 2),
874};
875
876static int __init atari_platform_init(void)
877{
878	struct platform_device *pdev;
879	int rv = 0;
880
881	if (!MACH_IS_ATARI)
882		return -ENODEV;
883
884#ifdef CONFIG_ATARI_ETHERNAT
885	{
886		unsigned char *enatc_virt;
887		enatc_virt = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0xf);
888		if (hwreg_present(enatc_virt)) {
889			rv = platform_add_devices(atari_ethernat_devices,
890						ARRAY_SIZE(atari_ethernat_devices));
891		}
892		iounmap(enatc_virt);
893	}
894#endif
895
896#ifdef CONFIG_ATARI_ETHERNEC
897	{
898		int error;
899		unsigned char *enec_virt;
900		enec_virt = (unsigned char *)ioremap((ATARI_ETHERNEC_PHYS_ADDR), 0xf);
901		if (hwreg_present(enec_virt)) {
902			error = platform_add_devices(atari_netusbee_devices,
903						ARRAY_SIZE(atari_netusbee_devices));
904			if (error && !rv)
905				rv = error;
906		}
907		iounmap(enec_virt);
908	}
909#endif
910
911#if IS_ENABLED(CONFIG_ATARI_SCSI)
912	if (ATARIHW_PRESENT(ST_SCSI))
913		platform_device_register_simple("atari_scsi", -1,
914			atari_scsi_st_rsrc, ARRAY_SIZE(atari_scsi_st_rsrc));
915	else if (ATARIHW_PRESENT(TT_SCSI))
916		platform_device_register_simple("atari_scsi", -1,
917			atari_scsi_tt_rsrc, ARRAY_SIZE(atari_scsi_tt_rsrc));
918#endif
919
920	if (ATARIHW_PRESENT(IDE)) {
921		pdev = platform_device_register_simple("atari-falcon-ide", -1,
922			atari_falconide_rsrc, ARRAY_SIZE(atari_falconide_rsrc));
923		if (IS_ERR(pdev))
924			rv = PTR_ERR(pdev);
925	}
926
927	return rv;
928}
929
930arch_initcall(atari_platform_init);