config.c 24 KB

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