blob: fb2d0bd9b3adab5304dc160a3bcf192aa0568a53 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/types.h>
28#include <linux/mm.h>
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040029#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/console.h>
31#include <linux/init.h>
32#include <linux/delay.h>
33#include <linux/ioport.h>
Michael Schmitz736b24d2013-04-06 13:26:39 +130034#include <linux/platform_device.h>
Michael Schmitz01a18d12013-04-06 13:26:45 +130035#include <linux/usb/isp116x.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/vt_kern.h>
Adrian Bunka3b20042008-02-04 22:30:26 -080037#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <asm/machdep.h>
45#include <asm/hwtest.h>
46#include <asm/io.h>
47
48u_long atari_mch_cookie;
Adrian Bunka3b20042008-02-04 22:30:26 -080049EXPORT_SYMBOL(atari_mch_cookie);
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051u_long atari_mch_type;
Adrian Bunka3b20042008-02-04 22:30:26 -080052EXPORT_SYMBOL(atari_mch_type);
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054struct atari_hw_present atari_hw_present;
Adrian Bunka3b20042008-02-04 22:30:26 -080055EXPORT_SYMBOL(atari_hw_present);
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057u_long atari_switches;
Adrian Bunka3b20042008-02-04 22:30:26 -080058EXPORT_SYMBOL(atari_switches);
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060int atari_dont_touch_floppy_select;
Adrian Bunka3b20042008-02-04 22:30:26 -080061EXPORT_SYMBOL(atari_dont_touch_floppy_select);
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063int atari_rtc_year_offset;
64
65/* local function prototypes */
Roman Zippel6ff58012007-05-01 22:32:43 +020066static void atari_reset(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067static void atari_get_model(char *model);
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040068static void atari_get_hardware_list(struct seq_file *m);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70/* atari specific irq functions */
71extern void atari_init_IRQ (void);
Roman Zippel6ff58012007-05-01 22:32:43 +020072extern void atari_mksound(unsigned int count, unsigned int ticks);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#ifdef CONFIG_HEARTBEAT
Roman Zippel6ff58012007-05-01 22:32:43 +020074static void atari_heartbeat(int on);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#endif
76
77/* atari specific timer functions (in time.c) */
Roman Zippel6ff58012007-05-01 22:32:43 +020078extern void atari_sched_init(irq_handler_t);
Stephen Warrenc8d5ba12012-11-08 11:34:55 -070079extern u32 atari_gettimeoffset(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080extern int atari_mste_hwclk (int, struct rtc_time *);
81extern int atari_tt_hwclk (int, struct rtc_time *);
82extern int atari_mste_set_clock_mmss (unsigned long);
83extern int atari_tt_set_clock_mmss (unsigned long);
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Linus Torvalds1da177e2005-04-16 15:20:36 -070086/* ++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
Roman Zippel6ff58012007-05-01 22:32:43 +020094static int __init scc_test(volatile char *ctla)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095{
Roman Zippel6ff58012007-05-01 22:32:43 +020096 if (!hwreg_present(ctla))
97 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 MFPDELAY();
99
Roman Zippel6ff58012007-05-01 22:32:43 +0200100 *ctla = 2;
101 MFPDELAY();
102 *ctla = 0x40;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 MFPDELAY();
104
Roman Zippel6ff58012007-05-01 22:32:43 +0200105 *ctla = 2;
106 MFPDELAY();
107 if (*ctla != 0x40)
108 return 0;
109 MFPDELAY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Roman Zippel6ff58012007-05-01 22:32:43 +0200111 *ctla = 2;
112 MFPDELAY();
113 *ctla = 0x60;
114 MFPDELAY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Roman Zippel6ff58012007-05-01 22:32:43 +0200116 *ctla = 2;
117 MFPDELAY();
118 if (*ctla != 0x60)
119 return 0;
120
121 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122}
123
124
125 /*
126 * Parse an Atari-specific record in the bootinfo
127 */
128
129int __init atari_parse_bootinfo(const struct bi_record *record)
130{
Roman Zippel6ff58012007-05-01 22:32:43 +0200131 int unknown = 0;
132 const u_long *data = record->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Roman Zippel6ff58012007-05-01 22:32:43 +0200134 switch (record->tag) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 case BI_ATARI_MCH_COOKIE:
Roman Zippel6ff58012007-05-01 22:32:43 +0200136 atari_mch_cookie = *data;
137 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 case BI_ATARI_MCH_TYPE:
Roman Zippel6ff58012007-05-01 22:32:43 +0200139 atari_mch_type = *data;
140 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 default:
Roman Zippel6ff58012007-05-01 22:32:43 +0200142 unknown = 1;
143 break;
144 }
145 return unknown;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146}
147
148
149/* Parse the Atari-specific switches= option. */
Roman Zippeld6713b42007-05-01 22:32:45 +0200150static int __init atari_switches_setup(char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151{
Roman Zippeld6713b42007-05-01 22:32:45 +0200152 char switches[strlen(str) + 1];
Roman Zippel6ff58012007-05-01 22:32:43 +0200153 char *p;
154 int ovsc_shift;
155 char *args = switches;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Roman Zippeld6713b42007-05-01 22:32:45 +0200157 if (!MACH_IS_ATARI)
158 return 0;
159
Roman Zippel6ff58012007-05-01 22:32:43 +0200160 /* copy string to local array, strsep works destructively... */
Roman Zippeld6713b42007-05-01 22:32:45 +0200161 strcpy(switches, str);
Roman Zippel6ff58012007-05-01 22:32:43 +0200162 atari_switches = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Roman Zippel6ff58012007-05-01 22:32:43 +0200164 /* 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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Roman Zippel6ff58012007-05-01 22:32:43 +0200174 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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 }
Roman Zippeld6713b42007-05-01 22:32:45 +0200186 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187}
188
Roman Zippeld6713b42007-05-01 22:32:45 +0200189early_param("switches", atari_switches_setup);
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192 /*
193 * Setup the Atari configuration info
194 */
195
196void __init config_atari(void)
197{
Roman Zippel6ff58012007-05-01 22:32:43 +0200198 unsigned short tos_version;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Roman Zippel6ff58012007-05-01 22:32:43 +0200200 memset(&atari_hw_present, 0, sizeof(atari_hw_present));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Roman Zippel6ff58012007-05-01 22:32:43 +0200202 /* Change size of I/O space from 64KB to 4GB. */
203 ioport_resource.end = 0xFFFFFFFF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Roman Zippel6ff58012007-05-01 22:32:43 +0200205 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;
Stephen Warrenc8d5ba12012-11-08 11:34:55 -0700209 arch_gettimeoffset = atari_gettimeoffset;
Roman Zippel6ff58012007-05-01 22:32:43 +0200210 mach_reset = atari_reset;
211 mach_max_dma_address = 0xffffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
Roman Zippel6ff58012007-05-01 22:32:43 +0200213 mach_beep = atari_mksound;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214#endif
215#ifdef CONFIG_HEARTBEAT
Roman Zippel6ff58012007-05-01 22:32:43 +0200216 mach_heartbeat = atari_heartbeat;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217#endif
218
Roman Zippel6ff58012007-05-01 22:32:43 +0200219 /* 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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
Roman Zippel6ff58012007-05-01 22:32:43 +0200231 /* ++bjoern:
232 * Determine hardware present
233 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
Roman Zippel6ff58012007-05-01 22:32:43 +0200235 printk("Atari hardware found: ");
Adrian Bunk29c8a242008-10-13 21:58:59 +0200236 if (MACH_IS_MEDUSA) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200237 /* 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 }
Geert Uytterhoeven3d92e8f2009-02-22 09:38:47 +0100262 if (hwreg_present(&st_mfp.par_dt_reg)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200263 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 }
Roman Zippel6ff58012007-05-01 22:32:43 +0200274 /*
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 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200295 if (!MACH_IS_MEDUSA && hwreg_present(&tt_dmasnd.ctrl)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200296 ATARIHW_SET(PCM_8BIT);
297 printk("PCM ");
298 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200299 if (hwreg_present(&falcon_codec.unused5)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200300 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) &&
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308#if 0
Roman Zippel6ff58012007-05-01 22:32:43 +0200309 /* 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)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312#else
Adrian Bunk29c8a242008-10-13 21:58:59 +0200313 !MACH_IS_MEDUSA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314#endif
Roman Zippel6ff58012007-05-01 22:32:43 +0200315 ) {
316 ATARIHW_SET(SCC_DMA);
317 printk("SCC_DMA ");
318 }
Geert Uytterhoevende339e42011-01-16 20:47:47 +0100319 if (scc_test(&atari_scc.cha_a_ctrl)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200320 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 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200327 if (hwreg_present(&tt_scu.sys_mask)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200328 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 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200337 if (hwreg_present(blitter.halftone)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200338 ATARIHW_SET(BLITTER);
339 printk("BLITTER ");
340 }
341 if (hwreg_present((void *)0xfff00039)) {
342 ATARIHW_SET(IDE);
343 printk("IDE ");
344 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345#if 1 /* This maybe wrong */
Adrian Bunk29c8a242008-10-13 21:58:59 +0200346 if (!MACH_IS_MEDUSA && hwreg_present(&tt_microwire.data) &&
Roman Zippel6ff58012007-05-01 22:32:43 +0200347 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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358#endif
Roman Zippel6ff58012007-05-01 22:32:43 +0200359 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 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200365 if (hwreg_present(&mste_rtc.sec_ones)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200366 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 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200371 if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
Roman Zippel6ff58012007-05-01 22:32:43 +0200372 hwreg_write(&dma_wd.fdc_speed, 0)) {
373 ATARIHW_SET(FDCSPEED);
374 printk("FDC_SPEED ");
375 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200376 if (!ATARIHW_PRESENT(ST_SCSI)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200377 ATARIHW_SET(ACSI);
378 printk("ACSI ");
379 }
380 printk("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
Roman Zippel6ff58012007-05-01 22:32:43 +0200382 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");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
Roman Zippel6ff58012007-05-01 22:32:43 +0200397 /* allocator for memory that must reside in st-ram */
398 atari_stram_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
Roman Zippel6ff58012007-05-01 22:32:43 +0200400 /* 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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
Roman Zippel6ff58012007-05-01 22:32:43 +0200411 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"
Andreas Schwab2a353502012-01-09 15:10:15 +0100418 " pmove %0,%/tt1\n"
Roman Zippel6ff58012007-05-01 22:32:43 +0200419 " .chip 68k"
Andreas Schwab2a353502012-01-09 15:10:15 +0100420 : : "m" (tt1_val));
Roman Zippel6ff58012007-05-01 22:32:43 +0200421 } 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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Roman Zippel6ff58012007-05-01 22:32:43 +0200432 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433
Roman Zippel6ff58012007-05-01 22:32:43 +0200434 /* 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 */
Adrian Bunk29c8a242008-10-13 21:58:59 +0200444 tos_version = (MACH_IS_MEDUSA) ?
Roman Zippel6ff58012007-05-01 22:32:43 +0200445 0xfff : *(unsigned short *)0xff000002;
446 atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447}
448
449#ifdef CONFIG_HEARTBEAT
Roman Zippel6ff58012007-05-01 22:32:43 +0200450static void atari_heartbeat(int on)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451{
Roman Zippel6ff58012007-05-01 22:32:43 +0200452 unsigned char tmp;
453 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Roman Zippel6ff58012007-05-01 22:32:43 +0200455 if (atari_dont_touch_floppy_select)
456 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457
Roman Zippel6ff58012007-05-01 22:32:43 +0200458 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463}
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
Roman Zippel6ff58012007-05-01 22:32:43 +0200497static void atari_reset(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498{
Roman Zippel6ff58012007-05-01 22:32:43 +0200499 long tc_val = 0;
500 long reset_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
Roman Zippel6ff58012007-05-01 22:32:43 +0200502 /*
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 */
Adrian Bunk29c8a242008-10-13 21:58:59 +0200506 reset_addr = MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
Roman Zippel6ff58012007-05-01 22:32:43 +0200507 *(unsigned long *) 0xff000004;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Roman Zippel6ff58012007-05-01 22:32:43 +0200509 /* 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514
Roman Zippel6ff58012007-05-01 22:32:43 +0200515 /* 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));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522
Roman Zippel6ff58012007-05-01 22:32:43 +0200523 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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
Roman Zippel6ff58012007-05-01 22:32:43 +0200534 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"
Andreas Schwab2a353502012-01-09 15:10:15 +0100573 " pmove %0,%%tc\n"
Roman Zippel6ff58012007-05-01 22:32:43 +0200574 " jmp %1@"
575 : /* no outputs */
Andreas Schwab2a353502012-01-09 15:10:15 +0100576 : "m" (tc_val), "a" (reset_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577}
578
579
580static void atari_get_model(char *model)
581{
Roman Zippel6ff58012007-05-01 22:32:43 +0200582 strcpy(model, "Atari ");
583 switch (atari_mch_cookie >> 16) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 case ATARI_MCH_ST:
Roman Zippel6ff58012007-05-01 22:32:43 +0200585 if (ATARIHW_PRESENT(MSTE_CLK))
586 strcat(model, "Mega ST");
587 else
588 strcat(model, "ST");
589 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 case ATARI_MCH_STE:
Roman Zippel6ff58012007-05-01 22:32:43 +0200591 if (MACH_IS_MSTE)
592 strcat(model, "Mega STE");
593 else
594 strcat(model, "STE");
595 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 case ATARI_MCH_TT:
Roman Zippel6ff58012007-05-01 22:32:43 +0200597 if (MACH_IS_MEDUSA)
598 /* Medusa has TT _MCH cookie */
599 strcat(model, "Medusa");
Roman Zippel6ff58012007-05-01 22:32:43 +0200600 else
601 strcat(model, "TT");
602 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 case ATARI_MCH_FALCON:
Roman Zippel6ff58012007-05-01 22:32:43 +0200604 strcat(model, "Falcon");
605 if (MACH_IS_AB40)
606 strcat(model, " (with Afterburner040)");
607 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 default:
Roman Zippel6ff58012007-05-01 22:32:43 +0200609 sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
610 atari_mch_cookie);
611 break;
612 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613}
614
615
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400616static void atari_get_hardware_list(struct seq_file *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617{
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400618 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619
Roman Zippel6ff58012007-05-01 22:32:43 +0200620 for (i = 0; i < m68k_num_memory; i++)
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400621 seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n",
Roman Zippel6ff58012007-05-01 22:32:43 +0200622 m68k_memory[i].size >> 20, m68k_memory[i].addr,
623 (m68k_memory[i].addr & 0xff000000 ?
624 "alternate RAM" : "ST-RAM"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Roman Zippel6ff58012007-05-01 22:32:43 +0200626#define ATARIHW_ANNOUNCE(name, str) \
627 if (ATARIHW_PRESENT(name)) \
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400628 seq_printf(m, "\t%s\n", str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400630 seq_printf(m, "Detected hardware:\n");
Roman Zippel6ff58012007-05-01 22:32:43 +0200631 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");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659}
Michael Schmitz736b24d2013-04-06 13:26:39 +1300660
661/*
662 * MSch: initial platform device support for Atari,
Michael Schmitz01a18d12013-04-06 13:26:45 +1300663 * required for EtherNAT/EtherNEC/NetUSBee drivers
Michael Schmitz736b24d2013-04-06 13:26:39 +1300664 */
665
Michael Schmitz01a18d12013-04-06 13:26:45 +1300666#if defined(CONFIG_ATARI_ETHERNAT) || defined(CONFIG_ATARI_ETHERNEC)
667static void isp1160_delay(struct device *dev, int delay)
668{
669 ndelay(delay);
670}
671#endif
672
Michael Schmitz736b24d2013-04-06 13:26:39 +1300673#ifdef CONFIG_ATARI_ETHERNAT
674/*
675 * EtherNAT: SMC91C111 Ethernet chipset, handled by smc91x driver
676 */
677
678#define ATARI_ETHERNAT_IRQ 140
679
680static 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
695static struct platform_device smc91x_device = {
696 .name = "smc91x",
697 .id = -1,
698 .num_resources = ARRAY_SIZE(smc91x_resources),
699 .resource = smc91x_resources,
700};
701
Michael Schmitz01a18d12013-04-06 13:26:45 +1300702/*
703 * ISP 1160 - using the isp116x-hcd module
704 */
705
706#define ATARI_USB_PHYS_ADDR 0x80000012
707#define ATARI_USB_IRQ 139
708
709static 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 ) */
731static 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
748static 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
Michael Schmitz736b24d2013-04-06 13:26:39 +1300758static struct platform_device *atari_ethernat_devices[] __initdata = {
Michael Schmitz01a18d12013-04-06 13:26:45 +1300759 &smc91x_device,
760 &isp1160_device
Michael Schmitz736b24d2013-04-06 13:26:39 +1300761};
762#endif /* CONFIG_ATARI_ETHERNAT */
763
Michael Schmitz1d87a8f2013-04-06 13:26:40 +1300764#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
774static 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
789static struct platform_device rtl8019_device = {
790 .name = "ne",
791 .id = -1,
792 .num_resources = ARRAY_SIZE(rtl8019_resources),
793 .resource = rtl8019_resources,
794};
795
Michael Schmitz01a18d12013-04-06 13:26:45 +1300796/*
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
804static 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 ) */
826static 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
843static 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
853static struct platform_device *atari_netusbee_devices[] __initdata = {
854 &rtl8019_device,
855 &netusbee_device
Michael Schmitz1d87a8f2013-04-06 13:26:40 +1300856};
857#endif /* CONFIG_ATARI_ETHERNEC */
858
Michael Schmitz736b24d2013-04-06 13:26:39 +1300859int __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
Michael Schmitz1d87a8f2013-04-06 13:26:40 +1300878#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)) {
Michael Schmitz01a18d12013-04-06 13:26:45 +1300884 error = platform_add_devices(atari_netusbee_devices,
885 ARRAY_SIZE(atari_netusbee_devices));
Michael Schmitz1d87a8f2013-04-06 13:26:40 +1300886 if (error && !rv)
887 rv = error;
888 }
889 iounmap(enec_virt);
890 }
891#endif
892
Michael Schmitz736b24d2013-04-06 13:26:39 +1300893 return rv;
894}
895
896arch_initcall(atari_platform_init);