config.c 24 KB

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