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