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