blob: 49c28cdbea5c5bf6cc89d00be99eee339900838c [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>
34#include <linux/vt_kern.h>
Adrian Bunka3b20042008-02-04 22:30:26 -080035#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37#include <asm/bootinfo.h>
38#include <asm/setup.h>
39#include <asm/atarihw.h>
40#include <asm/atariints.h>
41#include <asm/atari_stram.h>
42#include <asm/system.h>
43#include <asm/machdep.h>
44#include <asm/hwtest.h>
45#include <asm/io.h>
46
47u_long atari_mch_cookie;
Adrian Bunka3b20042008-02-04 22:30:26 -080048EXPORT_SYMBOL(atari_mch_cookie);
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050u_long atari_mch_type;
Adrian Bunka3b20042008-02-04 22:30:26 -080051EXPORT_SYMBOL(atari_mch_type);
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053struct atari_hw_present atari_hw_present;
Adrian Bunka3b20042008-02-04 22:30:26 -080054EXPORT_SYMBOL(atari_hw_present);
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056u_long atari_switches;
Adrian Bunka3b20042008-02-04 22:30:26 -080057EXPORT_SYMBOL(atari_switches);
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059int atari_dont_touch_floppy_select;
Adrian Bunka3b20042008-02-04 22:30:26 -080060EXPORT_SYMBOL(atari_dont_touch_floppy_select);
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062int atari_rtc_year_offset;
63
64/* local function prototypes */
Roman Zippel6ff58012007-05-01 22:32:43 +020065static void atari_reset(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static void atari_get_model(char *model);
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040067static void atari_get_hardware_list(struct seq_file *m);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69/* atari specific irq functions */
70extern void atari_init_IRQ (void);
Roman Zippel6ff58012007-05-01 22:32:43 +020071extern void atari_mksound(unsigned int count, unsigned int ticks);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072#ifdef CONFIG_HEARTBEAT
Roman Zippel6ff58012007-05-01 22:32:43 +020073static void atari_heartbeat(int on);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#endif
75
76/* atari specific timer functions (in time.c) */
Roman Zippel6ff58012007-05-01 22:32:43 +020077extern void atari_sched_init(irq_handler_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern unsigned long atari_gettimeoffset (void);
79extern int atari_mste_hwclk (int, struct rtc_time *);
80extern int atari_tt_hwclk (int, struct rtc_time *);
81extern int atari_mste_set_clock_mmss (unsigned long);
82extern int atari_tt_set_clock_mmss (unsigned long);
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Linus Torvalds1da177e2005-04-16 15:20:36 -070085/* ++roman: This is a more elaborate test for an SCC chip, since the plain
86 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
87 * board in the Medusa is possible. Also, the addresses where the ST_ESCC
88 * resides generate DTACK without the chip, too.
89 * The method is to write values into the interrupt vector register, that
90 * should be readable without trouble (from channel A!).
91 */
92
Roman Zippel6ff58012007-05-01 22:32:43 +020093static int __init scc_test(volatile char *ctla)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094{
Roman Zippel6ff58012007-05-01 22:32:43 +020095 if (!hwreg_present(ctla))
96 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 MFPDELAY();
98
Roman Zippel6ff58012007-05-01 22:32:43 +020099 *ctla = 2;
100 MFPDELAY();
101 *ctla = 0x40;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 MFPDELAY();
103
Roman Zippel6ff58012007-05-01 22:32:43 +0200104 *ctla = 2;
105 MFPDELAY();
106 if (*ctla != 0x40)
107 return 0;
108 MFPDELAY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Roman Zippel6ff58012007-05-01 22:32:43 +0200110 *ctla = 2;
111 MFPDELAY();
112 *ctla = 0x60;
113 MFPDELAY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Roman Zippel6ff58012007-05-01 22:32:43 +0200115 *ctla = 2;
116 MFPDELAY();
117 if (*ctla != 0x60)
118 return 0;
119
120 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121}
122
123
124 /*
125 * Parse an Atari-specific record in the bootinfo
126 */
127
128int __init atari_parse_bootinfo(const struct bi_record *record)
129{
Roman Zippel6ff58012007-05-01 22:32:43 +0200130 int unknown = 0;
131 const u_long *data = record->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
Roman Zippel6ff58012007-05-01 22:32:43 +0200133 switch (record->tag) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 case BI_ATARI_MCH_COOKIE:
Roman Zippel6ff58012007-05-01 22:32:43 +0200135 atari_mch_cookie = *data;
136 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 case BI_ATARI_MCH_TYPE:
Roman Zippel6ff58012007-05-01 22:32:43 +0200138 atari_mch_type = *data;
139 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 default:
Roman Zippel6ff58012007-05-01 22:32:43 +0200141 unknown = 1;
142 break;
143 }
144 return unknown;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145}
146
147
148/* Parse the Atari-specific switches= option. */
Roman Zippeld6713b42007-05-01 22:32:45 +0200149static int __init atari_switches_setup(char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
Roman Zippeld6713b42007-05-01 22:32:45 +0200151 char switches[strlen(str) + 1];
Roman Zippel6ff58012007-05-01 22:32:43 +0200152 char *p;
153 int ovsc_shift;
154 char *args = switches;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Roman Zippeld6713b42007-05-01 22:32:45 +0200156 if (!MACH_IS_ATARI)
157 return 0;
158
Roman Zippel6ff58012007-05-01 22:32:43 +0200159 /* copy string to local array, strsep works destructively... */
Roman Zippeld6713b42007-05-01 22:32:45 +0200160 strcpy(switches, str);
Roman Zippel6ff58012007-05-01 22:32:43 +0200161 atari_switches = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Roman Zippel6ff58012007-05-01 22:32:43 +0200163 /* parse the options */
164 while ((p = strsep(&args, ",")) != NULL) {
165 if (!*p)
166 continue;
167 ovsc_shift = 0;
168 if (strncmp(p, "ov_", 3) == 0) {
169 p += 3;
170 ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
171 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Roman Zippel6ff58012007-05-01 22:32:43 +0200173 if (strcmp(p, "ikbd") == 0) {
174 /* RTS line of IKBD ACIA */
175 atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
176 } else if (strcmp(p, "midi") == 0) {
177 /* RTS line of MIDI ACIA */
178 atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
179 } else if (strcmp(p, "snd6") == 0) {
180 atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
181 } else if (strcmp(p, "snd7") == 0) {
182 atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
183 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 }
Roman Zippeld6713b42007-05-01 22:32:45 +0200185 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186}
187
Roman Zippeld6713b42007-05-01 22:32:45 +0200188early_param("switches", atari_switches_setup);
189
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
191 /*
192 * Setup the Atari configuration info
193 */
194
195void __init config_atari(void)
196{
Roman Zippel6ff58012007-05-01 22:32:43 +0200197 unsigned short tos_version;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Roman Zippel6ff58012007-05-01 22:32:43 +0200199 memset(&atari_hw_present, 0, sizeof(atari_hw_present));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Roman Zippel6ff58012007-05-01 22:32:43 +0200201 /* Change size of I/O space from 64KB to 4GB. */
202 ioport_resource.end = 0xFFFFFFFF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Roman Zippel6ff58012007-05-01 22:32:43 +0200204 mach_sched_init = atari_sched_init;
205 mach_init_IRQ = atari_init_IRQ;
206 mach_get_model = atari_get_model;
207 mach_get_hardware_list = atari_get_hardware_list;
208 mach_gettimeoffset = atari_gettimeoffset;
209 mach_reset = atari_reset;
210 mach_max_dma_address = 0xffffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
Roman Zippel6ff58012007-05-01 22:32:43 +0200212 mach_beep = atari_mksound;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213#endif
214#ifdef CONFIG_HEARTBEAT
Roman Zippel6ff58012007-05-01 22:32:43 +0200215 mach_heartbeat = atari_heartbeat;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216#endif
217
Roman Zippel6ff58012007-05-01 22:32:43 +0200218 /* Set switches as requested by the user */
219 if (atari_switches & ATARI_SWITCH_IKBD)
220 acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
221 if (atari_switches & ATARI_SWITCH_MIDI)
222 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
223 if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
224 sound_ym.rd_data_reg_sel = 14;
225 sound_ym.wd_data = sound_ym.rd_data_reg_sel |
226 ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
227 ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
228 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Roman Zippel6ff58012007-05-01 22:32:43 +0200230 /* ++bjoern:
231 * Determine hardware present
232 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
Roman Zippel6ff58012007-05-01 22:32:43 +0200234 printk("Atari hardware found: ");
Adrian Bunk29c8a242008-10-13 21:58:59 +0200235 if (MACH_IS_MEDUSA) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200236 /* There's no Atari video hardware on the Medusa, but all the
237 * addresses below generate a DTACK so no bus error occurs! */
238 } else if (hwreg_present(f030_xreg)) {
239 ATARIHW_SET(VIDEL_SHIFTER);
240 printk("VIDEL ");
241 /* This is a temporary hack: If there is Falcon video
242 * hardware, we assume that the ST-DMA serves SCSI instead of
243 * ACSI. In the future, there should be a better method for
244 * this...
245 */
246 ATARIHW_SET(ST_SCSI);
247 printk("STDMA-SCSI ");
248 } else if (hwreg_present(tt_palette)) {
249 ATARIHW_SET(TT_SHIFTER);
250 printk("TT_SHIFTER ");
251 } else if (hwreg_present(&shifter.bas_hi)) {
252 if (hwreg_present(&shifter.bas_lo) &&
253 (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) {
254 ATARIHW_SET(EXTD_SHIFTER);
255 printk("EXTD_SHIFTER ");
256 } else {
257 ATARIHW_SET(STND_SHIFTER);
258 printk("STND_SHIFTER ");
259 }
260 }
261 if (hwreg_present(&mfp.par_dt_reg)) {
262 ATARIHW_SET(ST_MFP);
263 printk("ST_MFP ");
264 }
265 if (hwreg_present(&tt_mfp.par_dt_reg)) {
266 ATARIHW_SET(TT_MFP);
267 printk("TT_MFP ");
268 }
269 if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) {
270 ATARIHW_SET(SCSI_DMA);
271 printk("TT_SCSI_DMA ");
272 }
Roman Zippel6ff58012007-05-01 22:32:43 +0200273 /*
274 * The ST-DMA address registers aren't readable
275 * on all Medusas, so the test below may fail
276 */
277 if (MACH_IS_MEDUSA ||
278 (hwreg_present(&st_dma.dma_vhi) &&
279 (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
280 st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
281 (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
282 st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
283 ATARIHW_SET(EXTD_DMA);
284 printk("EXTD_DMA ");
285 }
286 if (hwreg_present(&tt_scsi.scsi_data)) {
287 ATARIHW_SET(TT_SCSI);
288 printk("TT_SCSI ");
289 }
290 if (hwreg_present(&sound_ym.rd_data_reg_sel)) {
291 ATARIHW_SET(YM_2149);
292 printk("YM2149 ");
293 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200294 if (!MACH_IS_MEDUSA && hwreg_present(&tt_dmasnd.ctrl)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200295 ATARIHW_SET(PCM_8BIT);
296 printk("PCM ");
297 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200298 if (hwreg_present(&falcon_codec.unused5)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200299 ATARIHW_SET(CODEC);
300 printk("CODEC ");
301 }
302 if (hwreg_present(&dsp56k_host_interface.icr)) {
303 ATARIHW_SET(DSP56K);
304 printk("DSP56K ");
305 }
306 if (hwreg_present(&tt_scc_dma.dma_ctrl) &&
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307#if 0
Roman Zippel6ff58012007-05-01 22:32:43 +0200308 /* This test sucks! Who knows some better? */
309 (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
310 (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311#else
Adrian Bunk29c8a242008-10-13 21:58:59 +0200312 !MACH_IS_MEDUSA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313#endif
Roman Zippel6ff58012007-05-01 22:32:43 +0200314 ) {
315 ATARIHW_SET(SCC_DMA);
316 printk("SCC_DMA ");
317 }
318 if (scc_test(&scc.cha_a_ctrl)) {
319 ATARIHW_SET(SCC);
320 printk("SCC ");
321 }
322 if (scc_test(&st_escc.cha_b_ctrl)) {
323 ATARIHW_SET(ST_ESCC);
324 printk("ST_ESCC ");
325 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200326 if (hwreg_present(&tt_scu.sys_mask)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200327 ATARIHW_SET(SCU);
328 /* Assume a VME bus if there's a SCU */
329 ATARIHW_SET(VME);
330 printk("VME SCU ");
331 }
332 if (hwreg_present((void *)(0xffff9210))) {
333 ATARIHW_SET(ANALOG_JOY);
334 printk("ANALOG_JOY ");
335 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200336 if (hwreg_present(blitter.halftone)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200337 ATARIHW_SET(BLITTER);
338 printk("BLITTER ");
339 }
340 if (hwreg_present((void *)0xfff00039)) {
341 ATARIHW_SET(IDE);
342 printk("IDE ");
343 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344#if 1 /* This maybe wrong */
Adrian Bunk29c8a242008-10-13 21:58:59 +0200345 if (!MACH_IS_MEDUSA && hwreg_present(&tt_microwire.data) &&
Roman Zippel6ff58012007-05-01 22:32:43 +0200346 hwreg_present(&tt_microwire.mask) &&
347 (tt_microwire.mask = 0x7ff,
348 udelay(1),
349 tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
350 udelay(1),
351 tt_microwire.data != 0)) {
352 ATARIHW_SET(MICROWIRE);
353 while (tt_microwire.mask != 0x7ff)
354 ;
355 printk("MICROWIRE ");
356 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357#endif
Roman Zippel6ff58012007-05-01 22:32:43 +0200358 if (hwreg_present(&tt_rtc.regsel)) {
359 ATARIHW_SET(TT_CLK);
360 printk("TT_CLK ");
361 mach_hwclk = atari_tt_hwclk;
362 mach_set_clock_mmss = atari_tt_set_clock_mmss;
363 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200364 if (hwreg_present(&mste_rtc.sec_ones)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200365 ATARIHW_SET(MSTE_CLK);
366 printk("MSTE_CLK ");
367 mach_hwclk = atari_mste_hwclk;
368 mach_set_clock_mmss = atari_mste_set_clock_mmss;
369 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200370 if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
Roman Zippel6ff58012007-05-01 22:32:43 +0200371 hwreg_write(&dma_wd.fdc_speed, 0)) {
372 ATARIHW_SET(FDCSPEED);
373 printk("FDC_SPEED ");
374 }
Adrian Bunk29c8a242008-10-13 21:58:59 +0200375 if (!ATARIHW_PRESENT(ST_SCSI)) {
Roman Zippel6ff58012007-05-01 22:32:43 +0200376 ATARIHW_SET(ACSI);
377 printk("ACSI ");
378 }
379 printk("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
Roman Zippel6ff58012007-05-01 22:32:43 +0200381 if (CPU_IS_040_OR_060)
382 /* Now it seems to be safe to turn of the tt0 transparent
383 * translation (the one that must not be turned off in
384 * head.S...)
385 */
386 asm volatile ("\n"
387 " moveq #0,%%d0\n"
388 " .chip 68040\n"
389 " movec %%d0,%%itt0\n"
390 " movec %%d0,%%dtt0\n"
391 " .chip 68k"
392 : /* no outputs */
393 : /* no inputs */
394 : "d0");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Roman Zippel6ff58012007-05-01 22:32:43 +0200396 /* allocator for memory that must reside in st-ram */
397 atari_stram_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
Roman Zippel6ff58012007-05-01 22:32:43 +0200399 /* Set up a mapping for the VMEbus address region:
400 *
401 * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff
402 * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at
403 * 0xfe000000 virt., because this can be done with a single
404 * transparent translation. On the 68040, lots of often unused
405 * page tables would be needed otherwise. On a MegaSTE or similar,
406 * the highest byte is stripped off by hardware due to the 24 bit
407 * design of the bus.
408 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
Roman Zippel6ff58012007-05-01 22:32:43 +0200410 if (CPU_IS_020_OR_030) {
411 unsigned long tt1_val;
412 tt1_val = 0xfe008543; /* Translate 0xfexxxxxx, enable, cache
413 * inhibit, read and write, FDC mask = 3,
414 * FDC val = 4 -> Supervisor only */
415 asm volatile ("\n"
416 " .chip 68030\n"
417 " pmove %0@,%/tt1\n"
418 " .chip 68k"
419 : : "a" (&tt1_val));
420 } else {
421 asm volatile ("\n"
422 " .chip 68040\n"
423 " movec %0,%%itt1\n"
424 " movec %0,%%dtt1\n"
425 " .chip 68k"
426 :
427 : "d" (0xfe00a040)); /* Translate 0xfexxxxxx, enable,
428 * supervisor only, non-cacheable/
429 * serialized, writable */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
Roman Zippel6ff58012007-05-01 22:32:43 +0200431 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Roman Zippel6ff58012007-05-01 22:32:43 +0200433 /* Fetch tos version at Physical 2 */
434 /*
435 * We my not be able to access this address if the kernel is
436 * loaded to st ram, since the first page is unmapped. On the
437 * Medusa this is always the case and there is nothing we can do
438 * about this, so we just assume the smaller offset. For the TT
439 * we use the fact that in head.S we have set up a mapping
440 * 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
441 * in the last 16MB of the address space.
442 */
Adrian Bunk29c8a242008-10-13 21:58:59 +0200443 tos_version = (MACH_IS_MEDUSA) ?
Roman Zippel6ff58012007-05-01 22:32:43 +0200444 0xfff : *(unsigned short *)0xff000002;
445 atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446}
447
448#ifdef CONFIG_HEARTBEAT
Roman Zippel6ff58012007-05-01 22:32:43 +0200449static void atari_heartbeat(int on)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450{
Roman Zippel6ff58012007-05-01 22:32:43 +0200451 unsigned char tmp;
452 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
Roman Zippel6ff58012007-05-01 22:32:43 +0200454 if (atari_dont_touch_floppy_select)
455 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
Roman Zippel6ff58012007-05-01 22:32:43 +0200457 local_irq_save(flags);
458 sound_ym.rd_data_reg_sel = 14; /* Select PSG Port A */
459 tmp = sound_ym.rd_data_reg_sel;
460 sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
461 local_irq_restore(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462}
463#endif
464
465/* ++roman:
466 *
467 * This function does a reset on machines that lack the ability to
468 * assert the processor's _RESET signal somehow via hardware. It is
469 * based on the fact that you can find the initial SP and PC values
470 * after a reset at physical addresses 0 and 4. This works pretty well
471 * for Atari machines, since the lowest 8 bytes of physical memory are
472 * really ROM (mapped by hardware). For other 680x0 machines: don't
473 * know if it works...
474 *
475 * To get the values at addresses 0 and 4, the MMU better is turned
476 * off first. After that, we have to jump into physical address space
477 * (the PC before the pmove statement points to the virtual address of
478 * the code). Getting that physical address is not hard, but the code
479 * becomes a bit complex since I've tried to ensure that the jump
480 * statement after the pmove is in the cache already (otherwise the
481 * processor can't fetch it!). For that, the code first jumps to the
482 * jump statement with the (virtual) address of the pmove section in
483 * an address register . The jump statement is surely in the cache
484 * now. After that, that physical address of the reset code is loaded
485 * into the same address register, pmove is done and the same jump
486 * statements goes to the reset code. Since there are not many
487 * statements between the two jumps, I hope it stays in the cache.
488 *
489 * The C code makes heavy use of the GCC features that you can get the
490 * address of a C label. No hope to compile this with another compiler
491 * than GCC!
492 */
493
494/* ++andreas: no need for complicated code, just depend on prefetch */
495
Roman Zippel6ff58012007-05-01 22:32:43 +0200496static void atari_reset(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
Roman Zippel6ff58012007-05-01 22:32:43 +0200498 long tc_val = 0;
499 long reset_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
Roman Zippel6ff58012007-05-01 22:32:43 +0200501 /*
502 * On the Medusa, phys. 0x4 may contain garbage because it's no
503 * ROM. See above for explanation why we cannot use PTOV(4).
504 */
Adrian Bunk29c8a242008-10-13 21:58:59 +0200505 reset_addr = MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
Roman Zippel6ff58012007-05-01 22:32:43 +0200506 *(unsigned long *) 0xff000004;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
Roman Zippel6ff58012007-05-01 22:32:43 +0200508 /* reset ACIA for switch off OverScan, if it's active */
509 if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
510 acia.key_ctrl = ACIA_RESET;
511 if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
512 acia.mid_ctrl = ACIA_RESET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
Roman Zippel6ff58012007-05-01 22:32:43 +0200514 /* processor independent: turn off interrupts and reset the VBR;
515 * the caches must be left enabled, else prefetching the final jump
516 * instruction doesn't work.
517 */
518 local_irq_disable();
519 asm volatile ("movec %0,%%vbr"
520 : : "d" (0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Roman Zippel6ff58012007-05-01 22:32:43 +0200522 if (CPU_IS_040_OR_060) {
523 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
524 if (CPU_IS_060) {
525 /* 68060: clear PCR to turn off superscalar operation */
526 asm volatile ("\n"
527 " .chip 68060\n"
528 " movec %0,%%pcr\n"
529 " .chip 68k"
530 : : "d" (0));
531 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
Roman Zippel6ff58012007-05-01 22:32:43 +0200533 asm volatile ("\n"
534 " move.l %0,%%d0\n"
535 " and.l #0xff000000,%%d0\n"
536 " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */
537 " .chip 68040\n"
538 " movec %%d0,%%itt0\n"
539 " movec %%d0,%%dtt0\n"
540 " .chip 68k\n"
541 " jmp %0@"
542 : : "a" (jmp_addr040)
543 : "d0");
544 jmp_addr_label040:
545 asm volatile ("\n"
546 " moveq #0,%%d0\n"
547 " nop\n"
548 " .chip 68040\n"
549 " cinva %%bc\n"
550 " nop\n"
551 " pflusha\n"
552 " nop\n"
553 " movec %%d0,%%tc\n"
554 " nop\n"
555 /* the following setup of transparent translations is needed on the
556 * Afterburner040 to successfully reboot. Other machines shouldn't
557 * care about a different tt regs setup, they also didn't care in
558 * the past that the regs weren't turned off. */
559 " move.l #0xffc000,%%d0\n" /* whole insn space cacheable */
560 " movec %%d0,%%itt0\n"
561 " movec %%d0,%%itt1\n"
562 " or.w #0x40,%/d0\n" /* whole data space non-cacheable/ser. */
563 " movec %%d0,%%dtt0\n"
564 " movec %%d0,%%dtt1\n"
565 " .chip 68k\n"
566 " jmp %0@"
567 : /* no outputs */
568 : "a" (reset_addr)
569 : "d0");
570 } else
571 asm volatile ("\n"
572 " pmove %0@,%%tc\n"
573 " jmp %1@"
574 : /* no outputs */
575 : "a" (&tc_val), "a" (reset_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576}
577
578
579static void atari_get_model(char *model)
580{
Roman Zippel6ff58012007-05-01 22:32:43 +0200581 strcpy(model, "Atari ");
582 switch (atari_mch_cookie >> 16) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 case ATARI_MCH_ST:
Roman Zippel6ff58012007-05-01 22:32:43 +0200584 if (ATARIHW_PRESENT(MSTE_CLK))
585 strcat(model, "Mega ST");
586 else
587 strcat(model, "ST");
588 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 case ATARI_MCH_STE:
Roman Zippel6ff58012007-05-01 22:32:43 +0200590 if (MACH_IS_MSTE)
591 strcat(model, "Mega STE");
592 else
593 strcat(model, "STE");
594 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 case ATARI_MCH_TT:
Roman Zippel6ff58012007-05-01 22:32:43 +0200596 if (MACH_IS_MEDUSA)
597 /* Medusa has TT _MCH cookie */
598 strcat(model, "Medusa");
Roman Zippel6ff58012007-05-01 22:32:43 +0200599 else
600 strcat(model, "TT");
601 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 case ATARI_MCH_FALCON:
Roman Zippel6ff58012007-05-01 22:32:43 +0200603 strcat(model, "Falcon");
604 if (MACH_IS_AB40)
605 strcat(model, " (with Afterburner040)");
606 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 default:
Roman Zippel6ff58012007-05-01 22:32:43 +0200608 sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
609 atari_mch_cookie);
610 break;
611 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612}
613
614
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400615static void atari_get_hardware_list(struct seq_file *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616{
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400617 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618
Roman Zippel6ff58012007-05-01 22:32:43 +0200619 for (i = 0; i < m68k_num_memory; i++)
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400620 seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n",
Roman Zippel6ff58012007-05-01 22:32:43 +0200621 m68k_memory[i].size >> 20, m68k_memory[i].addr,
622 (m68k_memory[i].addr & 0xff000000 ?
623 "alternate RAM" : "ST-RAM"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
Roman Zippel6ff58012007-05-01 22:32:43 +0200625#define ATARIHW_ANNOUNCE(name, str) \
626 if (ATARIHW_PRESENT(name)) \
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400627 seq_printf(m, "\t%s\n", str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
Alexey Dobriyan813dcf72008-10-03 22:42:36 +0400629 seq_printf(m, "Detected hardware:\n");
Roman Zippel6ff58012007-05-01 22:32:43 +0200630 ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
631 ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
632 ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
633 ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
634 ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
635 ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
636 ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
637 ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
638 ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
639 ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
640 ATARIHW_ANNOUNCE(IDE, "IDE Interface");
641 ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
642 ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
643 ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
644 ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
645 ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
646 ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
647 ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
648 ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
649 ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
650 ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
651 ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
652 ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
653 ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
654 ATARIHW_ANNOUNCE(SCU, "System Control Unit");
655 ATARIHW_ANNOUNCE(BLITTER, "Blitter");
656 ATARIHW_ANNOUNCE(VME, "VME Bus");
657 ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658}