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