xref: /openbmc/linux/arch/m68k/atari/config.c (revision 3ff228af)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *  linux/arch/m68k/atari/config.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *  Copyright (C) 1994 Bjoern Brauel
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *  5/2/94 Roman Hodek:
71da177e4SLinus Torvalds  *    Added setting of time_adj to get a better clock.
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  *  5/14/94 Roman Hodek:
101da177e4SLinus Torvalds  *    gettod() for TT
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  *  5/15/94 Roman Hodek:
131da177e4SLinus Torvalds  *    hard_reset_now() for Atari (and others?)
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  *  94/12/30 Andreas Schwab:
161da177e4SLinus Torvalds  *    atari_sched_init fixed to get precise clock.
171da177e4SLinus Torvalds  *
181da177e4SLinus Torvalds  * This file is subject to the terms and conditions of the GNU General Public
191da177e4SLinus Torvalds  * License.  See the file COPYING in the main directory of this archive
201da177e4SLinus Torvalds  * for more details.
211da177e4SLinus Torvalds  */
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds /*
241da177e4SLinus Torvalds  * Miscellaneous atari stuff
251da177e4SLinus Torvalds  */
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds #include <linux/types.h>
281da177e4SLinus Torvalds #include <linux/mm.h>
29813dcf7aSAlexey Dobriyan #include <linux/seq_file.h>
301da177e4SLinus Torvalds #include <linux/console.h>
311da177e4SLinus Torvalds #include <linux/init.h>
321da177e4SLinus Torvalds #include <linux/delay.h>
331da177e4SLinus Torvalds #include <linux/ioport.h>
34736b24dbSMichael Schmitz #include <linux/platform_device.h>
3501a18d16SMichael Schmitz #include <linux/usb/isp116x.h>
361da177e4SLinus Torvalds #include <linux/vt_kern.h>
37a3b2004aSAdrian Bunk #include <linux/module.h>
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds #include <asm/bootinfo.h>
404c3c522bSGeert Uytterhoeven #include <asm/bootinfo-atari.h>
41abe48101SGeert Uytterhoeven #include <asm/byteorder.h>
421da177e4SLinus Torvalds #include <asm/setup.h>
431da177e4SLinus Torvalds #include <asm/atarihw.h>
441da177e4SLinus Torvalds #include <asm/atariints.h>
451da177e4SLinus Torvalds #include <asm/atari_stram.h>
461da177e4SLinus Torvalds #include <asm/machdep.h>
471da177e4SLinus Torvalds #include <asm/hwtest.h>
481da177e4SLinus Torvalds #include <asm/io.h>
491da177e4SLinus Torvalds 
501da177e4SLinus Torvalds u_long atari_mch_cookie;
51a3b2004aSAdrian Bunk EXPORT_SYMBOL(atari_mch_cookie);
52a3b2004aSAdrian Bunk 
531da177e4SLinus Torvalds u_long atari_mch_type;
54a3b2004aSAdrian Bunk EXPORT_SYMBOL(atari_mch_type);
55a3b2004aSAdrian Bunk 
561da177e4SLinus Torvalds struct atari_hw_present atari_hw_present;
57a3b2004aSAdrian Bunk EXPORT_SYMBOL(atari_hw_present);
58a3b2004aSAdrian Bunk 
591da177e4SLinus Torvalds u_long atari_switches;
60a3b2004aSAdrian Bunk EXPORT_SYMBOL(atari_switches);
61a3b2004aSAdrian Bunk 
621da177e4SLinus Torvalds int atari_dont_touch_floppy_select;
63a3b2004aSAdrian Bunk EXPORT_SYMBOL(atari_dont_touch_floppy_select);
64a3b2004aSAdrian Bunk 
651da177e4SLinus Torvalds int atari_rtc_year_offset;
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds /* local function prototypes */
681da177e4SLinus Torvalds static void atari_reset(void);
691da177e4SLinus Torvalds static void atari_get_model(char *model);
70813dcf7aSAlexey Dobriyan static void atari_get_hardware_list(struct seq_file *m);
711da177e4SLinus Torvalds 
721da177e4SLinus Torvalds /* atari specific irq functions */
731da177e4SLinus Torvalds extern void atari_init_IRQ (void);
741da177e4SLinus Torvalds extern void atari_mksound(unsigned int count, unsigned int ticks);
751da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT
761da177e4SLinus Torvalds static void atari_heartbeat(int on);
771da177e4SLinus Torvalds #endif
781da177e4SLinus Torvalds 
791da177e4SLinus Torvalds /* atari specific timer functions (in time.c) */
8040220c1aSDavid Howells extern void atari_sched_init(irq_handler_t);
81c8d5ba18SStephen Warren extern u32 atari_gettimeoffset(void);
821da177e4SLinus Torvalds extern int atari_mste_hwclk (int, struct rtc_time *);
831da177e4SLinus Torvalds extern int atari_tt_hwclk (int, struct rtc_time *);
841da177e4SLinus Torvalds extern int atari_mste_set_clock_mmss (unsigned long);
851da177e4SLinus Torvalds extern int atari_tt_set_clock_mmss (unsigned long);
861da177e4SLinus Torvalds 
871da177e4SLinus Torvalds 
881da177e4SLinus Torvalds /* ++roman: This is a more elaborate test for an SCC chip, since the plain
891da177e4SLinus Torvalds  * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
901da177e4SLinus Torvalds  * board in the Medusa is possible. Also, the addresses where the ST_ESCC
911da177e4SLinus Torvalds  * resides generate DTACK without the chip, too.
921da177e4SLinus Torvalds  * The method is to write values into the interrupt vector register, that
931da177e4SLinus Torvalds  * should be readable without trouble (from channel A!).
941da177e4SLinus Torvalds  */
951da177e4SLinus Torvalds 
961da177e4SLinus Torvalds static int __init scc_test(volatile char *ctla)
971da177e4SLinus Torvalds {
981da177e4SLinus Torvalds 	if (!hwreg_present(ctla))
996ff5801aSRoman Zippel 		return 0;
1001da177e4SLinus Torvalds 	MFPDELAY();
1011da177e4SLinus Torvalds 
1026ff5801aSRoman Zippel 	*ctla = 2;
1036ff5801aSRoman Zippel 	MFPDELAY();
1046ff5801aSRoman Zippel 	*ctla = 0x40;
1051da177e4SLinus Torvalds 	MFPDELAY();
1061da177e4SLinus Torvalds 
1076ff5801aSRoman Zippel 	*ctla = 2;
1086ff5801aSRoman Zippel 	MFPDELAY();
1096ff5801aSRoman Zippel 	if (*ctla != 0x40)
1106ff5801aSRoman Zippel 		return 0;
1116ff5801aSRoman Zippel 	MFPDELAY();
1121da177e4SLinus Torvalds 
1136ff5801aSRoman Zippel 	*ctla = 2;
1146ff5801aSRoman Zippel 	MFPDELAY();
1156ff5801aSRoman Zippel 	*ctla = 0x60;
1166ff5801aSRoman Zippel 	MFPDELAY();
1171da177e4SLinus Torvalds 
1186ff5801aSRoman Zippel 	*ctla = 2;
1196ff5801aSRoman Zippel 	MFPDELAY();
1206ff5801aSRoman Zippel 	if (*ctla != 0x60)
1216ff5801aSRoman Zippel 		return 0;
1226ff5801aSRoman Zippel 
1236ff5801aSRoman Zippel 	return 1;
1241da177e4SLinus Torvalds }
1251da177e4SLinus Torvalds 
1261da177e4SLinus Torvalds 
1271da177e4SLinus Torvalds     /*
1281da177e4SLinus Torvalds      *  Parse an Atari-specific record in the bootinfo
1291da177e4SLinus Torvalds      */
1301da177e4SLinus Torvalds 
1311da177e4SLinus Torvalds int __init atari_parse_bootinfo(const struct bi_record *record)
1321da177e4SLinus Torvalds {
1331da177e4SLinus Torvalds 	int unknown = 0;
134abe48101SGeert Uytterhoeven 	const void *data = record->data;
1351da177e4SLinus Torvalds 
136abe48101SGeert Uytterhoeven 	switch (be16_to_cpu(record->tag)) {
1371da177e4SLinus Torvalds 	case BI_ATARI_MCH_COOKIE:
138abe48101SGeert Uytterhoeven 		atari_mch_cookie = be32_to_cpup(data);
1391da177e4SLinus Torvalds 		break;
1401da177e4SLinus Torvalds 	case BI_ATARI_MCH_TYPE:
141abe48101SGeert Uytterhoeven 		atari_mch_type = be32_to_cpup(data);
1421da177e4SLinus Torvalds 		break;
1431da177e4SLinus Torvalds 	default:
1441da177e4SLinus Torvalds 		unknown = 1;
1456ff5801aSRoman Zippel 		break;
1461da177e4SLinus Torvalds 	}
1476ff5801aSRoman Zippel 	return unknown;
1481da177e4SLinus Torvalds }
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds 
1511da177e4SLinus Torvalds /* Parse the Atari-specific switches= option. */
152d6713b40SRoman Zippel static int __init atari_switches_setup(char *str)
1531da177e4SLinus Torvalds {
154d6713b40SRoman Zippel 	char switches[strlen(str) + 1];
1551da177e4SLinus Torvalds 	char *p;
1561da177e4SLinus Torvalds 	int ovsc_shift;
1571da177e4SLinus Torvalds 	char *args = switches;
1581da177e4SLinus Torvalds 
159d6713b40SRoman Zippel 	if (!MACH_IS_ATARI)
160d6713b40SRoman Zippel 		return 0;
161d6713b40SRoman Zippel 
1621da177e4SLinus Torvalds 	/* copy string to local array, strsep works destructively... */
163d6713b40SRoman Zippel 	strcpy(switches, str);
1641da177e4SLinus Torvalds 	atari_switches = 0;
1651da177e4SLinus Torvalds 
1661da177e4SLinus Torvalds 	/* parse the options */
1671da177e4SLinus Torvalds 	while ((p = strsep(&args, ",")) != NULL) {
1686ff5801aSRoman Zippel 		if (!*p)
1696ff5801aSRoman Zippel 			continue;
1701da177e4SLinus Torvalds 		ovsc_shift = 0;
1711da177e4SLinus Torvalds 		if (strncmp(p, "ov_", 3) == 0) {
1721da177e4SLinus Torvalds 			p += 3;
1731da177e4SLinus Torvalds 			ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
1741da177e4SLinus Torvalds 		}
1751da177e4SLinus Torvalds 
1761da177e4SLinus Torvalds 		if (strcmp(p, "ikbd") == 0) {
1771da177e4SLinus Torvalds 			/* RTS line of IKBD ACIA */
1781da177e4SLinus Torvalds 			atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
1796ff5801aSRoman Zippel 		} else if (strcmp(p, "midi") == 0) {
1801da177e4SLinus Torvalds 			/* RTS line of MIDI ACIA */
1811da177e4SLinus Torvalds 			atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
1826ff5801aSRoman Zippel 		} else if (strcmp(p, "snd6") == 0) {
1831da177e4SLinus Torvalds 			atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
1846ff5801aSRoman Zippel 		} else if (strcmp(p, "snd7") == 0) {
1851da177e4SLinus Torvalds 			atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
1861da177e4SLinus Torvalds 		}
1871da177e4SLinus Torvalds 	}
188d6713b40SRoman Zippel 	return 0;
1891da177e4SLinus Torvalds }
1901da177e4SLinus Torvalds 
191d6713b40SRoman Zippel early_param("switches", atari_switches_setup);
192d6713b40SRoman Zippel 
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds     /*
1951da177e4SLinus Torvalds      *  Setup the Atari configuration info
1961da177e4SLinus Torvalds      */
1971da177e4SLinus Torvalds 
1981da177e4SLinus Torvalds void __init config_atari(void)
1991da177e4SLinus Torvalds {
2001da177e4SLinus Torvalds 	unsigned short tos_version;
2011da177e4SLinus Torvalds 
2021da177e4SLinus Torvalds 	memset(&atari_hw_present, 0, sizeof(atari_hw_present));
2031da177e4SLinus Torvalds 
2046ff5801aSRoman Zippel 	/* Change size of I/O space from 64KB to 4GB. */
2056ff5801aSRoman Zippel 	ioport_resource.end  = 0xFFFFFFFF;
2061da177e4SLinus Torvalds 
2071da177e4SLinus Torvalds 	mach_sched_init      = atari_sched_init;
2081da177e4SLinus Torvalds 	mach_init_IRQ        = atari_init_IRQ;
2091da177e4SLinus Torvalds 	mach_get_model	 = atari_get_model;
2101da177e4SLinus Torvalds 	mach_get_hardware_list = atari_get_hardware_list;
211c8d5ba18SStephen Warren 	arch_gettimeoffset   = atari_gettimeoffset;
2121da177e4SLinus Torvalds 	mach_reset           = atari_reset;
2131da177e4SLinus Torvalds 	mach_max_dma_address = 0xffffff;
2141da177e4SLinus Torvalds #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
2151da177e4SLinus Torvalds 	mach_beep          = atari_mksound;
2161da177e4SLinus Torvalds #endif
2171da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT
2181da177e4SLinus Torvalds 	mach_heartbeat = atari_heartbeat;
2191da177e4SLinus Torvalds #endif
2201da177e4SLinus Torvalds 
2211da177e4SLinus Torvalds 	/* Set switches as requested by the user */
2221da177e4SLinus Torvalds 	if (atari_switches & ATARI_SWITCH_IKBD)
2231da177e4SLinus Torvalds 		acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
2241da177e4SLinus Torvalds 	if (atari_switches & ATARI_SWITCH_MIDI)
2251da177e4SLinus Torvalds 		acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
2261da177e4SLinus Torvalds 	if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
2271da177e4SLinus Torvalds 		sound_ym.rd_data_reg_sel = 14;
2281da177e4SLinus Torvalds 		sound_ym.wd_data = sound_ym.rd_data_reg_sel |
2291da177e4SLinus Torvalds 				   ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
2301da177e4SLinus Torvalds 				   ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
2311da177e4SLinus Torvalds 	}
2321da177e4SLinus Torvalds 
2331da177e4SLinus Torvalds 	/* ++bjoern:
2341da177e4SLinus Torvalds 	 * Determine hardware present
2351da177e4SLinus Torvalds 	 */
2361da177e4SLinus Torvalds 
2371da177e4SLinus Torvalds 	printk("Atari hardware found: ");
23829c8a246SAdrian Bunk 	if (MACH_IS_MEDUSA) {
2391da177e4SLinus Torvalds 		/* There's no Atari video hardware on the Medusa, but all the
2401da177e4SLinus Torvalds 		 * addresses below generate a DTACK so no bus error occurs! */
2416ff5801aSRoman Zippel 	} else if (hwreg_present(f030_xreg)) {
2421da177e4SLinus Torvalds 		ATARIHW_SET(VIDEL_SHIFTER);
2431da177e4SLinus Torvalds 		printk("VIDEL ");
2441da177e4SLinus Torvalds 		/* This is a temporary hack: If there is Falcon video
2451da177e4SLinus Torvalds 		 * hardware, we assume that the ST-DMA serves SCSI instead of
2461da177e4SLinus Torvalds 		 * ACSI. In the future, there should be a better method for
2471da177e4SLinus Torvalds 		 * this...
2481da177e4SLinus Torvalds 		 */
2491da177e4SLinus Torvalds 		ATARIHW_SET(ST_SCSI);
2501da177e4SLinus Torvalds 		printk("STDMA-SCSI ");
2516ff5801aSRoman Zippel 	} else if (hwreg_present(tt_palette)) {
2521da177e4SLinus Torvalds 		ATARIHW_SET(TT_SHIFTER);
2531da177e4SLinus Torvalds 		printk("TT_SHIFTER ");
2546ff5801aSRoman Zippel 	} else if (hwreg_present(&shifter.bas_hi)) {
2551da177e4SLinus Torvalds 		if (hwreg_present(&shifter.bas_lo) &&
2561da177e4SLinus Torvalds 		    (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) {
2571da177e4SLinus Torvalds 			ATARIHW_SET(EXTD_SHIFTER);
2581da177e4SLinus Torvalds 			printk("EXTD_SHIFTER ");
2596ff5801aSRoman Zippel 		} else {
2601da177e4SLinus Torvalds 			ATARIHW_SET(STND_SHIFTER);
2611da177e4SLinus Torvalds 			printk("STND_SHIFTER ");
2621da177e4SLinus Torvalds 		}
2631da177e4SLinus Torvalds 	}
2643d92e8f3SGeert Uytterhoeven 	if (hwreg_present(&st_mfp.par_dt_reg)) {
2651da177e4SLinus Torvalds 		ATARIHW_SET(ST_MFP);
2661da177e4SLinus Torvalds 		printk("ST_MFP ");
2671da177e4SLinus Torvalds 	}
2681da177e4SLinus Torvalds 	if (hwreg_present(&tt_mfp.par_dt_reg)) {
2691da177e4SLinus Torvalds 		ATARIHW_SET(TT_MFP);
2701da177e4SLinus Torvalds 		printk("TT_MFP ");
2711da177e4SLinus Torvalds 	}
2721da177e4SLinus Torvalds 	if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) {
2731da177e4SLinus Torvalds 		ATARIHW_SET(SCSI_DMA);
2741da177e4SLinus Torvalds 		printk("TT_SCSI_DMA ");
2751da177e4SLinus Torvalds 	}
2766ff5801aSRoman Zippel 	/*
2776ff5801aSRoman Zippel 	 * The ST-DMA address registers aren't readable
2786ff5801aSRoman Zippel 	 * on all Medusas, so the test below may fail
2796ff5801aSRoman Zippel 	 */
2806ff5801aSRoman Zippel 	if (MACH_IS_MEDUSA ||
2811da177e4SLinus Torvalds 	    (hwreg_present(&st_dma.dma_vhi) &&
2821da177e4SLinus Torvalds 	     (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
2831da177e4SLinus Torvalds 	     st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
2841da177e4SLinus Torvalds 	     (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
2851da177e4SLinus Torvalds 	     st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
2861da177e4SLinus Torvalds 		ATARIHW_SET(EXTD_DMA);
2871da177e4SLinus Torvalds 		printk("EXTD_DMA ");
2881da177e4SLinus Torvalds 	}
2891da177e4SLinus Torvalds 	if (hwreg_present(&tt_scsi.scsi_data)) {
2901da177e4SLinus Torvalds 		ATARIHW_SET(TT_SCSI);
2911da177e4SLinus Torvalds 		printk("TT_SCSI ");
2921da177e4SLinus Torvalds 	}
2931da177e4SLinus Torvalds 	if (hwreg_present(&sound_ym.rd_data_reg_sel)) {
2941da177e4SLinus Torvalds 		ATARIHW_SET(YM_2149);
2951da177e4SLinus Torvalds 		printk("YM2149 ");
2961da177e4SLinus Torvalds 	}
29729c8a246SAdrian Bunk 	if (!MACH_IS_MEDUSA && hwreg_present(&tt_dmasnd.ctrl)) {
2981da177e4SLinus Torvalds 		ATARIHW_SET(PCM_8BIT);
2991da177e4SLinus Torvalds 		printk("PCM ");
3001da177e4SLinus Torvalds 	}
30129c8a246SAdrian Bunk 	if (hwreg_present(&falcon_codec.unused5)) {
3021da177e4SLinus Torvalds 		ATARIHW_SET(CODEC);
3031da177e4SLinus Torvalds 		printk("CODEC ");
3041da177e4SLinus Torvalds 	}
3051da177e4SLinus Torvalds 	if (hwreg_present(&dsp56k_host_interface.icr)) {
3061da177e4SLinus Torvalds 		ATARIHW_SET(DSP56K);
3071da177e4SLinus Torvalds 		printk("DSP56K ");
3081da177e4SLinus Torvalds 	}
3091da177e4SLinus Torvalds 	if (hwreg_present(&tt_scc_dma.dma_ctrl) &&
3101da177e4SLinus Torvalds #if 0
3111da177e4SLinus Torvalds 	    /* This test sucks! Who knows some better? */
3121da177e4SLinus Torvalds 	    (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
3131da177e4SLinus Torvalds 	    (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
3141da177e4SLinus Torvalds #else
31529c8a246SAdrian Bunk 	    !MACH_IS_MEDUSA
3161da177e4SLinus Torvalds #endif
3171da177e4SLinus Torvalds 	    ) {
3181da177e4SLinus Torvalds 		ATARIHW_SET(SCC_DMA);
3191da177e4SLinus Torvalds 		printk("SCC_DMA ");
3201da177e4SLinus Torvalds 	}
321de339e4bSGeert Uytterhoeven 	if (scc_test(&atari_scc.cha_a_ctrl)) {
3221da177e4SLinus Torvalds 		ATARIHW_SET(SCC);
3231da177e4SLinus Torvalds 		printk("SCC ");
3241da177e4SLinus Torvalds 	}
3251da177e4SLinus Torvalds 	if (scc_test(&st_escc.cha_b_ctrl)) {
3261da177e4SLinus Torvalds 		ATARIHW_SET(ST_ESCC);
3271da177e4SLinus Torvalds 		printk("ST_ESCC ");
3281da177e4SLinus Torvalds 	}
32929c8a246SAdrian Bunk 	if (hwreg_present(&tt_scu.sys_mask)) {
3301da177e4SLinus Torvalds 		ATARIHW_SET(SCU);
3311da177e4SLinus Torvalds 		/* Assume a VME bus if there's a SCU */
3321da177e4SLinus Torvalds 		ATARIHW_SET(VME);
3331da177e4SLinus Torvalds 		printk("VME SCU ");
3341da177e4SLinus Torvalds 	}
3351da177e4SLinus Torvalds 	if (hwreg_present((void *)(0xffff9210))) {
3361da177e4SLinus Torvalds 		ATARIHW_SET(ANALOG_JOY);
3371da177e4SLinus Torvalds 		printk("ANALOG_JOY ");
3381da177e4SLinus Torvalds 	}
33929c8a246SAdrian Bunk 	if (hwreg_present(blitter.halftone)) {
3401da177e4SLinus Torvalds 		ATARIHW_SET(BLITTER);
3411da177e4SLinus Torvalds 		printk("BLITTER ");
3421da177e4SLinus Torvalds 	}
3431da177e4SLinus Torvalds 	if (hwreg_present((void *)0xfff00039)) {
3441da177e4SLinus Torvalds 		ATARIHW_SET(IDE);
3451da177e4SLinus Torvalds 		printk("IDE ");
3461da177e4SLinus Torvalds 	}
3471da177e4SLinus Torvalds #if 1 /* This maybe wrong */
34829c8a246SAdrian Bunk 	if (!MACH_IS_MEDUSA && hwreg_present(&tt_microwire.data) &&
3491da177e4SLinus Torvalds 	    hwreg_present(&tt_microwire.mask) &&
3501da177e4SLinus Torvalds 	    (tt_microwire.mask = 0x7ff,
3511da177e4SLinus Torvalds 	     udelay(1),
3521da177e4SLinus Torvalds 	     tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
3531da177e4SLinus Torvalds 	     udelay(1),
3541da177e4SLinus Torvalds 	     tt_microwire.data != 0)) {
3551da177e4SLinus Torvalds 		ATARIHW_SET(MICROWIRE);
3566ff5801aSRoman Zippel 		while (tt_microwire.mask != 0x7ff)
3576ff5801aSRoman Zippel 			;
3581da177e4SLinus Torvalds 		printk("MICROWIRE ");
3591da177e4SLinus Torvalds 	}
3601da177e4SLinus Torvalds #endif
3611da177e4SLinus Torvalds 	if (hwreg_present(&tt_rtc.regsel)) {
3621da177e4SLinus Torvalds 		ATARIHW_SET(TT_CLK);
3631da177e4SLinus Torvalds 		printk("TT_CLK ");
3641da177e4SLinus Torvalds 		mach_hwclk = atari_tt_hwclk;
3651da177e4SLinus Torvalds 		mach_set_clock_mmss = atari_tt_set_clock_mmss;
3661da177e4SLinus Torvalds 	}
36729c8a246SAdrian Bunk 	if (hwreg_present(&mste_rtc.sec_ones)) {
3681da177e4SLinus Torvalds 		ATARIHW_SET(MSTE_CLK);
3691da177e4SLinus Torvalds 		printk("MSTE_CLK ");
3701da177e4SLinus Torvalds 		mach_hwclk = atari_mste_hwclk;
3711da177e4SLinus Torvalds 		mach_set_clock_mmss = atari_mste_set_clock_mmss;
3721da177e4SLinus Torvalds 	}
37329c8a246SAdrian Bunk 	if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
3741da177e4SLinus Torvalds 	    hwreg_write(&dma_wd.fdc_speed, 0)) {
3751da177e4SLinus Torvalds 		ATARIHW_SET(FDCSPEED);
3761da177e4SLinus Torvalds 		printk("FDC_SPEED ");
3771da177e4SLinus Torvalds 	}
37829c8a246SAdrian Bunk 	if (!ATARIHW_PRESENT(ST_SCSI)) {
3791da177e4SLinus Torvalds 		ATARIHW_SET(ACSI);
3801da177e4SLinus Torvalds 		printk("ACSI ");
3811da177e4SLinus Torvalds 	}
3821da177e4SLinus Torvalds 	printk("\n");
3831da177e4SLinus Torvalds 
3841da177e4SLinus Torvalds 	if (CPU_IS_040_OR_060)
3851da177e4SLinus Torvalds 		/* Now it seems to be safe to turn of the tt0 transparent
3861da177e4SLinus Torvalds 		 * translation (the one that must not be turned off in
3871da177e4SLinus Torvalds 		 * head.S...)
3881da177e4SLinus Torvalds 		 */
3896ff5801aSRoman Zippel 		asm volatile ("\n"
3906ff5801aSRoman Zippel 			"	moveq	#0,%%d0\n"
3916ff5801aSRoman Zippel 			"	.chip	68040\n"
3926ff5801aSRoman Zippel 			"	movec	%%d0,%%itt0\n"
3936ff5801aSRoman Zippel 			"	movec	%%d0,%%dtt0\n"
3941da177e4SLinus Torvalds 			"	.chip	68k"
3951da177e4SLinus Torvalds 			: /* no outputs */
3961da177e4SLinus Torvalds 			: /* no inputs */
3971da177e4SLinus Torvalds 			: "d0");
3981da177e4SLinus Torvalds 
3991da177e4SLinus Torvalds 	/* allocator for memory that must reside in st-ram */
4001da177e4SLinus Torvalds 	atari_stram_init();
4011da177e4SLinus Torvalds 
4021da177e4SLinus Torvalds 	/* Set up a mapping for the VMEbus address region:
4031da177e4SLinus Torvalds 	 *
4041da177e4SLinus Torvalds 	 * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff
4051da177e4SLinus Torvalds 	 * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at
4061da177e4SLinus Torvalds 	 * 0xfe000000 virt., because this can be done with a single
4071da177e4SLinus Torvalds 	 * transparent translation. On the 68040, lots of often unused
4081da177e4SLinus Torvalds 	 * page tables would be needed otherwise. On a MegaSTE or similar,
4091da177e4SLinus Torvalds 	 * the highest byte is stripped off by hardware due to the 24 bit
4101da177e4SLinus Torvalds 	 * design of the bus.
4111da177e4SLinus Torvalds 	 */
4121da177e4SLinus Torvalds 
4131da177e4SLinus Torvalds 	if (CPU_IS_020_OR_030) {
4141da177e4SLinus Torvalds 		unsigned long tt1_val;
4151da177e4SLinus Torvalds 		tt1_val = 0xfe008543;	/* Translate 0xfexxxxxx, enable, cache
4161da177e4SLinus Torvalds 					 * inhibit, read and write, FDC mask = 3,
4171da177e4SLinus Torvalds 					 * FDC val = 4 -> Supervisor only */
4186ff5801aSRoman Zippel 		asm volatile ("\n"
4196ff5801aSRoman Zippel 			"	.chip	68030\n"
4202a353506SAndreas Schwab 			"	pmove	%0,%/tt1\n"
4211da177e4SLinus Torvalds 			"	.chip	68k"
4222a353506SAndreas Schwab 			: : "m" (tt1_val));
4236ff5801aSRoman Zippel 	} else {
4246ff5801aSRoman Zippel 	        asm volatile ("\n"
4256ff5801aSRoman Zippel 			"	.chip	68040\n"
4266ff5801aSRoman Zippel 			"	movec	%0,%%itt1\n"
4276ff5801aSRoman Zippel 			"	movec	%0,%%dtt1\n"
4281da177e4SLinus Torvalds 			"	.chip	68k"
4291da177e4SLinus Torvalds 			:
4306ff5801aSRoman Zippel 			: "d" (0xfe00a040));	/* Translate 0xfexxxxxx, enable,
4311da177e4SLinus Torvalds 						 * supervisor only, non-cacheable/
4321da177e4SLinus Torvalds 						 * serialized, writable */
4331da177e4SLinus Torvalds 
4341da177e4SLinus Torvalds 	}
4351da177e4SLinus Torvalds 
4361da177e4SLinus Torvalds 	/* Fetch tos version at Physical 2 */
4376ff5801aSRoman Zippel 	/*
4386ff5801aSRoman Zippel 	 * We my not be able to access this address if the kernel is
4396ff5801aSRoman Zippel 	 * loaded to st ram, since the first page is unmapped.  On the
4406ff5801aSRoman Zippel 	 * Medusa this is always the case and there is nothing we can do
4416ff5801aSRoman Zippel 	 * about this, so we just assume the smaller offset.  For the TT
4426ff5801aSRoman Zippel 	 * we use the fact that in head.S we have set up a mapping
4436ff5801aSRoman Zippel 	 * 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
4446ff5801aSRoman Zippel 	 * in the last 16MB of the address space.
4456ff5801aSRoman Zippel 	 */
44629c8a246SAdrian Bunk 	tos_version = (MACH_IS_MEDUSA) ?
4471da177e4SLinus Torvalds 			0xfff : *(unsigned short *)0xff000002;
4481da177e4SLinus Torvalds 	atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
4491da177e4SLinus Torvalds }
4501da177e4SLinus Torvalds 
4511da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT
4521da177e4SLinus Torvalds static void atari_heartbeat(int on)
4531da177e4SLinus Torvalds {
4541da177e4SLinus Torvalds 	unsigned char tmp;
4551da177e4SLinus Torvalds 	unsigned long flags;
4561da177e4SLinus Torvalds 
4571da177e4SLinus Torvalds 	if (atari_dont_touch_floppy_select)
4581da177e4SLinus Torvalds 		return;
4591da177e4SLinus Torvalds 
4601da177e4SLinus Torvalds 	local_irq_save(flags);
4611da177e4SLinus Torvalds 	sound_ym.rd_data_reg_sel = 14;	/* Select PSG Port A */
4621da177e4SLinus Torvalds 	tmp = sound_ym.rd_data_reg_sel;
4631da177e4SLinus Torvalds 	sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
4641da177e4SLinus Torvalds 	local_irq_restore(flags);
4651da177e4SLinus Torvalds }
4661da177e4SLinus Torvalds #endif
4671da177e4SLinus Torvalds 
4681da177e4SLinus Torvalds /* ++roman:
4691da177e4SLinus Torvalds  *
4701da177e4SLinus Torvalds  * This function does a reset on machines that lack the ability to
4711da177e4SLinus Torvalds  * assert the processor's _RESET signal somehow via hardware. It is
4721da177e4SLinus Torvalds  * based on the fact that you can find the initial SP and PC values
4731da177e4SLinus Torvalds  * after a reset at physical addresses 0 and 4. This works pretty well
4741da177e4SLinus Torvalds  * for Atari machines, since the lowest 8 bytes of physical memory are
4751da177e4SLinus Torvalds  * really ROM (mapped by hardware). For other 680x0 machines: don't
4761da177e4SLinus Torvalds  * know if it works...
4771da177e4SLinus Torvalds  *
4781da177e4SLinus Torvalds  * To get the values at addresses 0 and 4, the MMU better is turned
4791da177e4SLinus Torvalds  * off first. After that, we have to jump into physical address space
4801da177e4SLinus Torvalds  * (the PC before the pmove statement points to the virtual address of
4811da177e4SLinus Torvalds  * the code). Getting that physical address is not hard, but the code
4821da177e4SLinus Torvalds  * becomes a bit complex since I've tried to ensure that the jump
4831da177e4SLinus Torvalds  * statement after the pmove is in the cache already (otherwise the
4841da177e4SLinus Torvalds  * processor can't fetch it!). For that, the code first jumps to the
4851da177e4SLinus Torvalds  * jump statement with the (virtual) address of the pmove section in
4861da177e4SLinus Torvalds  * an address register . The jump statement is surely in the cache
4871da177e4SLinus Torvalds  * now. After that, that physical address of the reset code is loaded
4881da177e4SLinus Torvalds  * into the same address register, pmove is done and the same jump
4891da177e4SLinus Torvalds  * statements goes to the reset code. Since there are not many
4901da177e4SLinus Torvalds  * statements between the two jumps, I hope it stays in the cache.
4911da177e4SLinus Torvalds  *
4921da177e4SLinus Torvalds  * The C code makes heavy use of the GCC features that you can get the
4931da177e4SLinus Torvalds  * address of a C label. No hope to compile this with another compiler
4941da177e4SLinus Torvalds  * than GCC!
4951da177e4SLinus Torvalds  */
4961da177e4SLinus Torvalds 
4971da177e4SLinus Torvalds /* ++andreas: no need for complicated code, just depend on prefetch */
4981da177e4SLinus Torvalds 
4991da177e4SLinus Torvalds static void atari_reset(void)
5001da177e4SLinus Torvalds {
5011da177e4SLinus Torvalds 	long tc_val = 0;
5021da177e4SLinus Torvalds 	long reset_addr;
5031da177e4SLinus Torvalds 
5046ff5801aSRoman Zippel 	/*
5056ff5801aSRoman Zippel 	 * On the Medusa, phys. 0x4 may contain garbage because it's no
5066ff5801aSRoman Zippel 	 * ROM.  See above for explanation why we cannot use PTOV(4).
5076ff5801aSRoman Zippel 	 */
50829c8a246SAdrian Bunk 	reset_addr = MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
5091da177e4SLinus Torvalds 		     *(unsigned long *) 0xff000004;
5101da177e4SLinus Torvalds 
5111da177e4SLinus Torvalds 	/* reset ACIA for switch off OverScan, if it's active */
5121da177e4SLinus Torvalds 	if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
5131da177e4SLinus Torvalds 		acia.key_ctrl = ACIA_RESET;
5141da177e4SLinus Torvalds 	if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
5151da177e4SLinus Torvalds 		acia.mid_ctrl = ACIA_RESET;
5161da177e4SLinus Torvalds 
5171da177e4SLinus Torvalds 	/* processor independent: turn off interrupts and reset the VBR;
5181da177e4SLinus Torvalds 	 * the caches must be left enabled, else prefetching the final jump
5196ff5801aSRoman Zippel 	 * instruction doesn't work.
5206ff5801aSRoman Zippel 	 */
5211da177e4SLinus Torvalds 	local_irq_disable();
5226ff5801aSRoman Zippel 	asm volatile ("movec	%0,%%vbr"
5236ff5801aSRoman Zippel 			: : "d" (0));
5241da177e4SLinus Torvalds 
5251da177e4SLinus Torvalds 	if (CPU_IS_040_OR_060) {
5261da177e4SLinus Torvalds 		unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
5271da177e4SLinus Torvalds 		if (CPU_IS_060) {
5281da177e4SLinus Torvalds 			/* 68060: clear PCR to turn off superscalar operation */
5296ff5801aSRoman Zippel 			asm volatile ("\n"
5306ff5801aSRoman Zippel 				"	.chip 68060\n"
5316ff5801aSRoman Zippel 				"	movec %0,%%pcr\n"
5321da177e4SLinus Torvalds 				"	.chip 68k"
5336ff5801aSRoman Zippel 				: : "d" (0));
5341da177e4SLinus Torvalds 		}
5351da177e4SLinus Torvalds 
5366ff5801aSRoman Zippel 		asm volatile ("\n"
5376ff5801aSRoman Zippel 			"	move.l	%0,%%d0\n"
5386ff5801aSRoman Zippel 			"	and.l	#0xff000000,%%d0\n"
5396ff5801aSRoman Zippel 			"	or.w	#0xe020,%%d0\n"   /* map 16 MB, enable, cacheable */
5406ff5801aSRoman Zippel 			"	.chip	68040\n"
5416ff5801aSRoman Zippel 			"	movec	%%d0,%%itt0\n"
5426ff5801aSRoman Zippel 			"	movec	%%d0,%%dtt0\n"
5436ff5801aSRoman Zippel 			"	.chip	68k\n"
5446ff5801aSRoman Zippel 			"	jmp	%0@"
5456ff5801aSRoman Zippel 			: : "a" (jmp_addr040)
5461da177e4SLinus Torvalds 			: "d0");
5471da177e4SLinus Torvalds 	jmp_addr_label040:
5486ff5801aSRoman Zippel 		asm volatile ("\n"
5496ff5801aSRoman Zippel 			"	moveq	#0,%%d0\n"
5506ff5801aSRoman Zippel 			"	nop\n"
5516ff5801aSRoman Zippel 			"	.chip	68040\n"
5526ff5801aSRoman Zippel 			"	cinva	%%bc\n"
5536ff5801aSRoman Zippel 			"	nop\n"
5546ff5801aSRoman Zippel 			"	pflusha\n"
5556ff5801aSRoman Zippel 			"	nop\n"
5566ff5801aSRoman Zippel 			"	movec	%%d0,%%tc\n"
5576ff5801aSRoman Zippel 			"	nop\n"
5581da177e4SLinus Torvalds 			/* the following setup of transparent translations is needed on the
5591da177e4SLinus Torvalds 			 * Afterburner040 to successfully reboot. Other machines shouldn't
5601da177e4SLinus Torvalds 			 * care about a different tt regs setup, they also didn't care in
5611da177e4SLinus Torvalds 			 * the past that the regs weren't turned off. */
5626ff5801aSRoman Zippel 			"	move.l	#0xffc000,%%d0\n" /* whole insn space cacheable */
5636ff5801aSRoman Zippel 			"	movec	%%d0,%%itt0\n"
5646ff5801aSRoman Zippel 			"	movec	%%d0,%%itt1\n"
5656ff5801aSRoman Zippel 			"	or.w	#0x40,%/d0\n" /* whole data space non-cacheable/ser. */
5666ff5801aSRoman Zippel 			"	movec	%%d0,%%dtt0\n"
5676ff5801aSRoman Zippel 			"	movec	%%d0,%%dtt1\n"
5686ff5801aSRoman Zippel 			"	.chip	68k\n"
5691da177e4SLinus Torvalds 			"	jmp	%0@"
5701da177e4SLinus Torvalds 			: /* no outputs */
5711da177e4SLinus Torvalds 			: "a" (reset_addr)
5721da177e4SLinus Torvalds 			: "d0");
5736ff5801aSRoman Zippel 	} else
5746ff5801aSRoman Zippel 		asm volatile ("\n"
5752a353506SAndreas Schwab 			"	pmove	%0,%%tc\n"
5761da177e4SLinus Torvalds 			"	jmp	%1@"
5771da177e4SLinus Torvalds 			: /* no outputs */
5782a353506SAndreas Schwab 			: "m" (tc_val), "a" (reset_addr));
5791da177e4SLinus Torvalds }
5801da177e4SLinus Torvalds 
5811da177e4SLinus Torvalds 
5821da177e4SLinus Torvalds static void atari_get_model(char *model)
5831da177e4SLinus Torvalds {
5841da177e4SLinus Torvalds 	strcpy(model, "Atari ");
5851da177e4SLinus Torvalds 	switch (atari_mch_cookie >> 16) {
5861da177e4SLinus Torvalds 	case ATARI_MCH_ST:
5871da177e4SLinus Torvalds 		if (ATARIHW_PRESENT(MSTE_CLK))
5881da177e4SLinus Torvalds 			strcat(model, "Mega ST");
5891da177e4SLinus Torvalds 		else
5901da177e4SLinus Torvalds 			strcat(model, "ST");
5911da177e4SLinus Torvalds 		break;
5921da177e4SLinus Torvalds 	case ATARI_MCH_STE:
5931da177e4SLinus Torvalds 		if (MACH_IS_MSTE)
5941da177e4SLinus Torvalds 			strcat(model, "Mega STE");
5951da177e4SLinus Torvalds 		else
5961da177e4SLinus Torvalds 			strcat(model, "STE");
5971da177e4SLinus Torvalds 		break;
5981da177e4SLinus Torvalds 	case ATARI_MCH_TT:
5991da177e4SLinus Torvalds 		if (MACH_IS_MEDUSA)
6001da177e4SLinus Torvalds 			/* Medusa has TT _MCH cookie */
6011da177e4SLinus Torvalds 			strcat(model, "Medusa");
6021da177e4SLinus Torvalds 		else
6031da177e4SLinus Torvalds 			strcat(model, "TT");
6041da177e4SLinus Torvalds 		break;
6051da177e4SLinus Torvalds 	case ATARI_MCH_FALCON:
6061da177e4SLinus Torvalds 		strcat(model, "Falcon");
6071da177e4SLinus Torvalds 		if (MACH_IS_AB40)
6081da177e4SLinus Torvalds 			strcat(model, " (with Afterburner040)");
6091da177e4SLinus Torvalds 		break;
6101da177e4SLinus Torvalds 	default:
6111da177e4SLinus Torvalds 		sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
6121da177e4SLinus Torvalds 			atari_mch_cookie);
6131da177e4SLinus Torvalds 		break;
6141da177e4SLinus Torvalds 	}
6151da177e4SLinus Torvalds }
6161da177e4SLinus Torvalds 
6171da177e4SLinus Torvalds 
618813dcf7aSAlexey Dobriyan static void atari_get_hardware_list(struct seq_file *m)
6191da177e4SLinus Torvalds {
620813dcf7aSAlexey Dobriyan 	int i;
6211da177e4SLinus Torvalds 
6221da177e4SLinus Torvalds 	for (i = 0; i < m68k_num_memory; i++)
623813dcf7aSAlexey Dobriyan 		seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n",
6241da177e4SLinus Torvalds 				m68k_memory[i].size >> 20, m68k_memory[i].addr,
6251da177e4SLinus Torvalds 				(m68k_memory[i].addr & 0xff000000 ?
6261da177e4SLinus Torvalds 				 "alternate RAM" : "ST-RAM"));
6271da177e4SLinus Torvalds 
6281da177e4SLinus Torvalds #define ATARIHW_ANNOUNCE(name, str)			\
6291da177e4SLinus Torvalds 	if (ATARIHW_PRESENT(name))			\
630813dcf7aSAlexey Dobriyan 		seq_printf(m, "\t%s\n", str)
6311da177e4SLinus Torvalds 
632813dcf7aSAlexey Dobriyan 	seq_printf(m, "Detected hardware:\n");
6331da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
6341da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
6351da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
6361da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
6371da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
6381da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
6391da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
6401da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
6411da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
6421da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
6431da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(IDE, "IDE Interface");
6441da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
6451da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
6461da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
6471da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
6481da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
6491da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
6501da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
6511da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
6521da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
6531da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
6541da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
6551da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
6561da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
6571da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(SCU, "System Control Unit");
6581da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(BLITTER, "Blitter");
6591da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(VME, "VME Bus");
6601da177e4SLinus Torvalds 	ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
6611da177e4SLinus Torvalds }
662736b24dbSMichael Schmitz 
663736b24dbSMichael Schmitz /*
664736b24dbSMichael Schmitz  * MSch: initial platform device support for Atari,
66501a18d16SMichael Schmitz  * required for EtherNAT/EtherNEC/NetUSBee drivers
666736b24dbSMichael Schmitz  */
667736b24dbSMichael Schmitz 
66801a18d16SMichael Schmitz #if defined(CONFIG_ATARI_ETHERNAT) || defined(CONFIG_ATARI_ETHERNEC)
66901a18d16SMichael Schmitz static void isp1160_delay(struct device *dev, int delay)
67001a18d16SMichael Schmitz {
67101a18d16SMichael Schmitz 	ndelay(delay);
67201a18d16SMichael Schmitz }
67301a18d16SMichael Schmitz #endif
67401a18d16SMichael Schmitz 
675736b24dbSMichael Schmitz #ifdef CONFIG_ATARI_ETHERNAT
676736b24dbSMichael Schmitz /*
677736b24dbSMichael Schmitz  * EtherNAT: SMC91C111 Ethernet chipset, handled by smc91x driver
678736b24dbSMichael Schmitz  */
679736b24dbSMichael Schmitz 
680736b24dbSMichael Schmitz #define ATARI_ETHERNAT_IRQ		140
681736b24dbSMichael Schmitz 
682736b24dbSMichael Schmitz static struct resource smc91x_resources[] = {
683736b24dbSMichael Schmitz 	[0] = {
684736b24dbSMichael Schmitz 		.name	= "smc91x-regs",
685736b24dbSMichael Schmitz 		.start	= ATARI_ETHERNAT_PHYS_ADDR,
686736b24dbSMichael Schmitz 		.end	= ATARI_ETHERNAT_PHYS_ADDR + 0xfffff,
687736b24dbSMichael Schmitz 		.flags	= IORESOURCE_MEM,
688736b24dbSMichael Schmitz 	},
689736b24dbSMichael Schmitz 	[1] = {
690736b24dbSMichael Schmitz 		.name	= "smc91x-irq",
691736b24dbSMichael Schmitz 		.start	= ATARI_ETHERNAT_IRQ,
692736b24dbSMichael Schmitz 		.end	= ATARI_ETHERNAT_IRQ,
693736b24dbSMichael Schmitz 		.flags	= IORESOURCE_IRQ,
694736b24dbSMichael Schmitz 	},
695736b24dbSMichael Schmitz };
696736b24dbSMichael Schmitz 
697736b24dbSMichael Schmitz static struct platform_device smc91x_device = {
698736b24dbSMichael Schmitz 	.name		= "smc91x",
699736b24dbSMichael Schmitz 	.id		= -1,
700736b24dbSMichael Schmitz 	.num_resources	= ARRAY_SIZE(smc91x_resources),
701736b24dbSMichael Schmitz 	.resource	= smc91x_resources,
702736b24dbSMichael Schmitz };
703736b24dbSMichael Schmitz 
70401a18d16SMichael Schmitz /*
70501a18d16SMichael Schmitz  * ISP 1160 - using the isp116x-hcd module
70601a18d16SMichael Schmitz  */
70701a18d16SMichael Schmitz 
70801a18d16SMichael Schmitz #define ATARI_USB_PHYS_ADDR	0x80000012
70901a18d16SMichael Schmitz #define ATARI_USB_IRQ		139
71001a18d16SMichael Schmitz 
71101a18d16SMichael Schmitz static struct resource isp1160_resources[] = {
71201a18d16SMichael Schmitz 	[0] = {
71301a18d16SMichael Schmitz 		.name	= "isp1160-data",
71401a18d16SMichael Schmitz 		.start	= ATARI_USB_PHYS_ADDR,
71501a18d16SMichael Schmitz 		.end	= ATARI_USB_PHYS_ADDR + 0x1,
71601a18d16SMichael Schmitz 		.flags	= IORESOURCE_MEM,
71701a18d16SMichael Schmitz 	},
71801a18d16SMichael Schmitz 	[1] = {
71901a18d16SMichael Schmitz 		.name	= "isp1160-regs",
72001a18d16SMichael Schmitz 		.start	= ATARI_USB_PHYS_ADDR + 0x4,
72101a18d16SMichael Schmitz 		.end	= ATARI_USB_PHYS_ADDR + 0x5,
72201a18d16SMichael Schmitz 		.flags	= IORESOURCE_MEM,
72301a18d16SMichael Schmitz 	},
72401a18d16SMichael Schmitz 	[2] = {
72501a18d16SMichael Schmitz 		.name	= "isp1160-irq",
72601a18d16SMichael Schmitz 		.start	= ATARI_USB_IRQ,
72701a18d16SMichael Schmitz 		.end	= ATARI_USB_IRQ,
72801a18d16SMichael Schmitz 		.flags	= IORESOURCE_IRQ,
72901a18d16SMichael Schmitz 	},
73001a18d16SMichael Schmitz };
73101a18d16SMichael Schmitz 
73201a18d16SMichael Schmitz /* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
73301a18d16SMichael Schmitz static struct isp116x_platform_data isp1160_platform_data = {
73401a18d16SMichael Schmitz 	/* Enable internal resistors on downstream ports */
73501a18d16SMichael Schmitz 	.sel15Kres		= 1,
73601a18d16SMichael Schmitz 	/* On-chip overcurrent protection */
73701a18d16SMichael Schmitz 	.oc_enable		= 1,
73801a18d16SMichael Schmitz 	/* INT output polarity */
73901a18d16SMichael Schmitz 	.int_act_high		= 1,
74001a18d16SMichael Schmitz 	/* INT edge or level triggered */
74101a18d16SMichael Schmitz 	.int_edge_triggered	= 0,
74201a18d16SMichael Schmitz 
74301a18d16SMichael Schmitz 	/* WAKEUP pin connected - NOT SUPPORTED  */
74401a18d16SMichael Schmitz 	/* .remote_wakeup_connected = 0, */
74501a18d16SMichael Schmitz 	/* Wakeup by devices on usb bus enabled */
74601a18d16SMichael Schmitz 	.remote_wakeup_enable	= 0,
74701a18d16SMichael Schmitz 	.delay			= isp1160_delay,
74801a18d16SMichael Schmitz };
74901a18d16SMichael Schmitz 
75001a18d16SMichael Schmitz static struct platform_device isp1160_device = {
75101a18d16SMichael Schmitz 	.name		= "isp116x-hcd",
75201a18d16SMichael Schmitz 	.id		= 0,
75301a18d16SMichael Schmitz 	.num_resources	= ARRAY_SIZE(isp1160_resources),
75401a18d16SMichael Schmitz 	.resource	= isp1160_resources,
75501a18d16SMichael Schmitz 	.dev			= {
75601a18d16SMichael Schmitz 		.platform_data	= &isp1160_platform_data,
75701a18d16SMichael Schmitz 	},
75801a18d16SMichael Schmitz };
75901a18d16SMichael Schmitz 
760736b24dbSMichael Schmitz static struct platform_device *atari_ethernat_devices[] __initdata = {
76101a18d16SMichael Schmitz 	&smc91x_device,
76201a18d16SMichael Schmitz 	&isp1160_device
763736b24dbSMichael Schmitz };
764736b24dbSMichael Schmitz #endif /* CONFIG_ATARI_ETHERNAT */
765736b24dbSMichael Schmitz 
7661d87a8f2SMichael Schmitz #ifdef CONFIG_ATARI_ETHERNEC
7671d87a8f2SMichael Schmitz /*
7681d87a8f2SMichael Schmitz  * EtherNEC: RTL8019 (NE2000 compatible) Ethernet chipset,
7691d87a8f2SMichael Schmitz  * handled by ne.c driver
7701d87a8f2SMichael Schmitz  */
7711d87a8f2SMichael Schmitz 
7721d87a8f2SMichael Schmitz #define ATARI_ETHERNEC_PHYS_ADDR	0xfffa0000
7731d87a8f2SMichael Schmitz #define ATARI_ETHERNEC_BASE		0x300
7741d87a8f2SMichael Schmitz #define ATARI_ETHERNEC_IRQ		IRQ_MFP_TIMER1
7751d87a8f2SMichael Schmitz 
7761d87a8f2SMichael Schmitz static struct resource rtl8019_resources[] = {
7771d87a8f2SMichael Schmitz 	[0] = {
7781d87a8f2SMichael Schmitz 		.name	= "rtl8019-regs",
7791d87a8f2SMichael Schmitz 		.start	= ATARI_ETHERNEC_BASE,
7801d87a8f2SMichael Schmitz 		.end	= ATARI_ETHERNEC_BASE + 0x20 - 1,
7811d87a8f2SMichael Schmitz 		.flags	= IORESOURCE_IO,
7821d87a8f2SMichael Schmitz 	},
7831d87a8f2SMichael Schmitz 	[1] = {
7841d87a8f2SMichael Schmitz 		.name	= "rtl8019-irq",
7851d87a8f2SMichael Schmitz 		.start	= ATARI_ETHERNEC_IRQ,
7861d87a8f2SMichael Schmitz 		.end	= ATARI_ETHERNEC_IRQ,
7871d87a8f2SMichael Schmitz 		.flags	= IORESOURCE_IRQ,
7881d87a8f2SMichael Schmitz 	},
7891d87a8f2SMichael Schmitz };
7901d87a8f2SMichael Schmitz 
7911d87a8f2SMichael Schmitz static struct platform_device rtl8019_device = {
7921d87a8f2SMichael Schmitz 	.name		= "ne",
7931d87a8f2SMichael Schmitz 	.id		= -1,
7941d87a8f2SMichael Schmitz 	.num_resources	= ARRAY_SIZE(rtl8019_resources),
7951d87a8f2SMichael Schmitz 	.resource	= rtl8019_resources,
7961d87a8f2SMichael Schmitz };
7971d87a8f2SMichael Schmitz 
79801a18d16SMichael Schmitz /*
79901a18d16SMichael Schmitz  * NetUSBee: ISP1160 USB host adapter via ROM-port adapter
80001a18d16SMichael Schmitz  */
80101a18d16SMichael Schmitz 
80201a18d16SMichael Schmitz #define ATARI_NETUSBEE_PHYS_ADDR	0xfffa8000
80301a18d16SMichael Schmitz #define ATARI_NETUSBEE_BASE		0x340
80401a18d16SMichael Schmitz #define ATARI_NETUSBEE_IRQ		IRQ_MFP_TIMER2
80501a18d16SMichael Schmitz 
80601a18d16SMichael Schmitz static struct resource netusbee_resources[] = {
80701a18d16SMichael Schmitz 	[0] = {
80801a18d16SMichael Schmitz 		.name	= "isp1160-data",
80901a18d16SMichael Schmitz 		.start	= ATARI_NETUSBEE_BASE,
81001a18d16SMichael Schmitz 		.end	= ATARI_NETUSBEE_BASE + 0x1,
81101a18d16SMichael Schmitz 		.flags	= IORESOURCE_MEM,
81201a18d16SMichael Schmitz 	},
81301a18d16SMichael Schmitz 	[1] = {
81401a18d16SMichael Schmitz 		.name	= "isp1160-regs",
81501a18d16SMichael Schmitz 		.start	= ATARI_NETUSBEE_BASE + 0x20,
81601a18d16SMichael Schmitz 		.end	= ATARI_NETUSBEE_BASE + 0x21,
81701a18d16SMichael Schmitz 		.flags	= IORESOURCE_MEM,
81801a18d16SMichael Schmitz 	},
81901a18d16SMichael Schmitz 	[2] = {
82001a18d16SMichael Schmitz 		.name	= "isp1160-irq",
82101a18d16SMichael Schmitz 		.start	= ATARI_NETUSBEE_IRQ,
82201a18d16SMichael Schmitz 		.end	= ATARI_NETUSBEE_IRQ,
82301a18d16SMichael Schmitz 		.flags	= IORESOURCE_IRQ,
82401a18d16SMichael Schmitz 	},
82501a18d16SMichael Schmitz };
82601a18d16SMichael Schmitz 
82701a18d16SMichael Schmitz /* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
82801a18d16SMichael Schmitz static struct isp116x_platform_data netusbee_platform_data = {
82901a18d16SMichael Schmitz 	/* Enable internal resistors on downstream ports */
83001a18d16SMichael Schmitz 	.sel15Kres		= 1,
83101a18d16SMichael Schmitz 	/* On-chip overcurrent protection */
83201a18d16SMichael Schmitz 	.oc_enable		= 1,
83301a18d16SMichael Schmitz 	/* INT output polarity */
83401a18d16SMichael Schmitz 	.int_act_high		= 1,
83501a18d16SMichael Schmitz 	/* INT edge or level triggered */
83601a18d16SMichael Schmitz 	.int_edge_triggered	= 0,
83701a18d16SMichael Schmitz 
83801a18d16SMichael Schmitz 	/* WAKEUP pin connected - NOT SUPPORTED  */
83901a18d16SMichael Schmitz 	/* .remote_wakeup_connected = 0, */
84001a18d16SMichael Schmitz 	/* Wakeup by devices on usb bus enabled */
84101a18d16SMichael Schmitz 	.remote_wakeup_enable	= 0,
84201a18d16SMichael Schmitz 	.delay			= isp1160_delay,
84301a18d16SMichael Schmitz };
84401a18d16SMichael Schmitz 
84501a18d16SMichael Schmitz static struct platform_device netusbee_device = {
84601a18d16SMichael Schmitz 	.name		= "isp116x-hcd",
84701a18d16SMichael Schmitz 	.id		= 1,
84801a18d16SMichael Schmitz 	.num_resources	= ARRAY_SIZE(netusbee_resources),
84901a18d16SMichael Schmitz 	.resource	= netusbee_resources,
85001a18d16SMichael Schmitz 	.dev			= {
85101a18d16SMichael Schmitz 		.platform_data	= &netusbee_platform_data,
85201a18d16SMichael Schmitz 	},
85301a18d16SMichael Schmitz };
85401a18d16SMichael Schmitz 
85501a18d16SMichael Schmitz static struct platform_device *atari_netusbee_devices[] __initdata = {
85601a18d16SMichael Schmitz 	&rtl8019_device,
85701a18d16SMichael Schmitz 	&netusbee_device
8581d87a8f2SMichael Schmitz };
8591d87a8f2SMichael Schmitz #endif /* CONFIG_ATARI_ETHERNEC */
8601d87a8f2SMichael Schmitz 
8613ff228afSFinn Thain #ifdef CONFIG_ATARI_SCSI
8623ff228afSFinn Thain static const struct resource atari_scsi_st_rsrc[] __initconst = {
8633ff228afSFinn Thain 	{
8643ff228afSFinn Thain 		.flags = IORESOURCE_IRQ,
8653ff228afSFinn Thain 		.start = IRQ_MFP_FSCSI,
8663ff228afSFinn Thain 		.end   = IRQ_MFP_FSCSI,
8673ff228afSFinn Thain 	},
8683ff228afSFinn Thain };
8693ff228afSFinn Thain 
8703ff228afSFinn Thain static const struct resource atari_scsi_tt_rsrc[] __initconst = {
8713ff228afSFinn Thain 	{
8723ff228afSFinn Thain 		.flags = IORESOURCE_IRQ,
8733ff228afSFinn Thain 		.start = IRQ_TT_MFP_SCSI,
8743ff228afSFinn Thain 		.end   = IRQ_TT_MFP_SCSI,
8753ff228afSFinn Thain 	},
8763ff228afSFinn Thain };
8773ff228afSFinn Thain #endif
8783ff228afSFinn Thain 
879736b24dbSMichael Schmitz int __init atari_platform_init(void)
880736b24dbSMichael Schmitz {
881736b24dbSMichael Schmitz 	int rv = 0;
882736b24dbSMichael Schmitz 
883736b24dbSMichael Schmitz 	if (!MACH_IS_ATARI)
884736b24dbSMichael Schmitz 		return -ENODEV;
885736b24dbSMichael Schmitz 
886736b24dbSMichael Schmitz #ifdef CONFIG_ATARI_ETHERNAT
887736b24dbSMichael Schmitz 	{
888736b24dbSMichael Schmitz 		unsigned char *enatc_virt;
889736b24dbSMichael Schmitz 		enatc_virt = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0xf);
890736b24dbSMichael Schmitz 		if (hwreg_present(enatc_virt)) {
891736b24dbSMichael Schmitz 			rv = platform_add_devices(atari_ethernat_devices,
892736b24dbSMichael Schmitz 						ARRAY_SIZE(atari_ethernat_devices));
893736b24dbSMichael Schmitz 		}
894736b24dbSMichael Schmitz 		iounmap(enatc_virt);
895736b24dbSMichael Schmitz 	}
896736b24dbSMichael Schmitz #endif
897736b24dbSMichael Schmitz 
8981d87a8f2SMichael Schmitz #ifdef CONFIG_ATARI_ETHERNEC
8991d87a8f2SMichael Schmitz 	{
9001d87a8f2SMichael Schmitz 		int error;
9011d87a8f2SMichael Schmitz 		unsigned char *enec_virt;
9021d87a8f2SMichael Schmitz 		enec_virt = (unsigned char *)ioremap((ATARI_ETHERNEC_PHYS_ADDR), 0xf);
9031d87a8f2SMichael Schmitz 		if (hwreg_present(enec_virt)) {
90401a18d16SMichael Schmitz 			error = platform_add_devices(atari_netusbee_devices,
90501a18d16SMichael Schmitz 						ARRAY_SIZE(atari_netusbee_devices));
9061d87a8f2SMichael Schmitz 			if (error && !rv)
9071d87a8f2SMichael Schmitz 				rv = error;
9081d87a8f2SMichael Schmitz 		}
9091d87a8f2SMichael Schmitz 		iounmap(enec_virt);
9101d87a8f2SMichael Schmitz 	}
9111d87a8f2SMichael Schmitz #endif
9121d87a8f2SMichael Schmitz 
9133ff228afSFinn Thain #ifdef CONFIG_ATARI_SCSI
9143ff228afSFinn Thain 	if (ATARIHW_PRESENT(ST_SCSI))
9153ff228afSFinn Thain 		platform_device_register_simple("atari_scsi", -1,
9163ff228afSFinn Thain 			atari_scsi_st_rsrc, ARRAY_SIZE(atari_scsi_st_rsrc));
9173ff228afSFinn Thain 	else if (ATARIHW_PRESENT(TT_SCSI))
9183ff228afSFinn Thain 		platform_device_register_simple("atari_scsi", -1,
9193ff228afSFinn Thain 			atari_scsi_tt_rsrc, ARRAY_SIZE(atari_scsi_tt_rsrc));
9203ff228afSFinn Thain #endif
9213ff228afSFinn Thain 
922736b24dbSMichael Schmitz 	return rv;
923736b24dbSMichael Schmitz }
924736b24dbSMichael Schmitz 
925736b24dbSMichael Schmitz arch_initcall(atari_platform_init);
926