config.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /*
  2. * linux/arch/m68k/amiga/config.c
  3. *
  4. * Copyright (C) 1993 Hamish Macdonald
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. /*
  11. * Miscellaneous Amiga stuff
  12. */
  13. #include <linux/types.h>
  14. #include <linux/kernel.h>
  15. #include <linux/mm.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/tty.h>
  18. #include <linux/console.h>
  19. #include <linux/rtc.h>
  20. #include <linux/init.h>
  21. #include <linux/vt_kern.h>
  22. #include <linux/delay.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/zorro.h>
  25. #include <linux/module.h>
  26. #include <linux/keyboard.h>
  27. #include <asm/bootinfo.h>
  28. #include <asm/bootinfo-amiga.h>
  29. #include <asm/byteorder.h>
  30. #include <asm/setup.h>
  31. #include <asm/pgtable.h>
  32. #include <asm/amigahw.h>
  33. #include <asm/amigaints.h>
  34. #include <asm/irq.h>
  35. #include <asm/machdep.h>
  36. #include <asm/io.h>
  37. static unsigned long amiga_model;
  38. unsigned long amiga_eclock;
  39. EXPORT_SYMBOL(amiga_eclock);
  40. unsigned long amiga_colorclock;
  41. EXPORT_SYMBOL(amiga_colorclock);
  42. unsigned long amiga_chipset;
  43. EXPORT_SYMBOL(amiga_chipset);
  44. unsigned char amiga_vblank;
  45. EXPORT_SYMBOL(amiga_vblank);
  46. static unsigned char amiga_psfreq;
  47. struct amiga_hw_present amiga_hw_present;
  48. EXPORT_SYMBOL(amiga_hw_present);
  49. static char s_a500[] __initdata = "A500";
  50. static char s_a500p[] __initdata = "A500+";
  51. static char s_a600[] __initdata = "A600";
  52. static char s_a1000[] __initdata = "A1000";
  53. static char s_a1200[] __initdata = "A1200";
  54. static char s_a2000[] __initdata = "A2000";
  55. static char s_a2500[] __initdata = "A2500";
  56. static char s_a3000[] __initdata = "A3000";
  57. static char s_a3000t[] __initdata = "A3000T";
  58. static char s_a3000p[] __initdata = "A3000+";
  59. static char s_a4000[] __initdata = "A4000";
  60. static char s_a4000t[] __initdata = "A4000T";
  61. static char s_cdtv[] __initdata = "CDTV";
  62. static char s_cd32[] __initdata = "CD32";
  63. static char s_draco[] __initdata = "Draco";
  64. static char *amiga_models[] __initdata = {
  65. [AMI_500-AMI_500] = s_a500,
  66. [AMI_500PLUS-AMI_500] = s_a500p,
  67. [AMI_600-AMI_500] = s_a600,
  68. [AMI_1000-AMI_500] = s_a1000,
  69. [AMI_1200-AMI_500] = s_a1200,
  70. [AMI_2000-AMI_500] = s_a2000,
  71. [AMI_2500-AMI_500] = s_a2500,
  72. [AMI_3000-AMI_500] = s_a3000,
  73. [AMI_3000T-AMI_500] = s_a3000t,
  74. [AMI_3000PLUS-AMI_500] = s_a3000p,
  75. [AMI_4000-AMI_500] = s_a4000,
  76. [AMI_4000T-AMI_500] = s_a4000t,
  77. [AMI_CDTV-AMI_500] = s_cdtv,
  78. [AMI_CD32-AMI_500] = s_cd32,
  79. [AMI_DRACO-AMI_500] = s_draco,
  80. };
  81. static char amiga_model_name[13] = "Amiga ";
  82. static void amiga_sched_init(irq_handler_t handler);
  83. static void amiga_get_model(char *model);
  84. static void amiga_get_hardware_list(struct seq_file *m);
  85. /* amiga specific timer functions */
  86. static u32 amiga_gettimeoffset(void);
  87. extern void amiga_mksound(unsigned int count, unsigned int ticks);
  88. static void amiga_reset(void);
  89. extern void amiga_init_sound(void);
  90. static void amiga_mem_console_write(struct console *co, const char *b,
  91. unsigned int count);
  92. #ifdef CONFIG_HEARTBEAT
  93. static void amiga_heartbeat(int on);
  94. #endif
  95. static struct console amiga_console_driver = {
  96. .name = "debug",
  97. .flags = CON_PRINTBUFFER,
  98. .index = -1,
  99. };
  100. /*
  101. * Motherboard Resources present in all Amiga models
  102. */
  103. static struct {
  104. struct resource _ciab, _ciaa, _custom, _kickstart;
  105. } mb_resources = {
  106. ._ciab = {
  107. .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
  108. },
  109. ._ciaa = {
  110. .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
  111. },
  112. ._custom = {
  113. .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
  114. },
  115. ._kickstart = {
  116. .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
  117. }
  118. };
  119. static struct resource ram_resource[NUM_MEMINFO];
  120. /*
  121. * Parse an Amiga-specific record in the bootinfo
  122. */
  123. int __init amiga_parse_bootinfo(const struct bi_record *record)
  124. {
  125. int unknown = 0;
  126. const void *data = record->data;
  127. switch (be16_to_cpu(record->tag)) {
  128. case BI_AMIGA_MODEL:
  129. amiga_model = be32_to_cpup(data);
  130. break;
  131. case BI_AMIGA_ECLOCK:
  132. amiga_eclock = be32_to_cpup(data);
  133. break;
  134. case BI_AMIGA_CHIPSET:
  135. amiga_chipset = be32_to_cpup(data);
  136. break;
  137. case BI_AMIGA_CHIP_SIZE:
  138. amiga_chip_size = be32_to_cpup(data);
  139. break;
  140. case BI_AMIGA_VBLANK:
  141. amiga_vblank = *(const __u8 *)data;
  142. break;
  143. case BI_AMIGA_PSFREQ:
  144. amiga_psfreq = *(const __u8 *)data;
  145. break;
  146. case BI_AMIGA_AUTOCON:
  147. #ifdef CONFIG_ZORRO
  148. if (zorro_num_autocon < ZORRO_NUM_AUTO) {
  149. const struct ConfigDev *cd = data;
  150. struct zorro_dev_init *dev = &zorro_autocon_init[zorro_num_autocon++];
  151. dev->rom = cd->cd_Rom;
  152. dev->slotaddr = be16_to_cpu(cd->cd_SlotAddr);
  153. dev->slotsize = be16_to_cpu(cd->cd_SlotSize);
  154. dev->boardaddr = be32_to_cpu(cd->cd_BoardAddr);
  155. dev->boardsize = be32_to_cpu(cd->cd_BoardSize);
  156. } else
  157. pr_warn("amiga_parse_bootinfo: too many AutoConfig devices\n");
  158. #endif /* CONFIG_ZORRO */
  159. break;
  160. case BI_AMIGA_SERPER:
  161. /* serial port period: ignored here */
  162. break;
  163. default:
  164. unknown = 1;
  165. }
  166. return unknown;
  167. }
  168. /*
  169. * Identify builtin hardware
  170. */
  171. static void __init amiga_identify(void)
  172. {
  173. /* Fill in some default values, if necessary */
  174. if (amiga_eclock == 0)
  175. amiga_eclock = 709379;
  176. memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
  177. pr_info("Amiga hardware found: ");
  178. if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
  179. pr_cont("[%s] ", amiga_models[amiga_model-AMI_500]);
  180. strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
  181. }
  182. switch (amiga_model) {
  183. case AMI_UNKNOWN:
  184. goto Generic;
  185. case AMI_600:
  186. case AMI_1200:
  187. AMIGAHW_SET(A1200_IDE);
  188. AMIGAHW_SET(PCMCIA);
  189. case AMI_500:
  190. case AMI_500PLUS:
  191. case AMI_1000:
  192. case AMI_2000:
  193. case AMI_2500:
  194. AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
  195. goto Generic;
  196. case AMI_3000:
  197. case AMI_3000T:
  198. AMIGAHW_SET(AMBER_FF);
  199. AMIGAHW_SET(MAGIC_REKICK);
  200. /* fall through */
  201. case AMI_3000PLUS:
  202. AMIGAHW_SET(A3000_SCSI);
  203. AMIGAHW_SET(A3000_CLK);
  204. AMIGAHW_SET(ZORRO3);
  205. goto Generic;
  206. case AMI_4000T:
  207. AMIGAHW_SET(A4000_SCSI);
  208. /* fall through */
  209. case AMI_4000:
  210. AMIGAHW_SET(A4000_IDE);
  211. AMIGAHW_SET(A3000_CLK);
  212. AMIGAHW_SET(ZORRO3);
  213. goto Generic;
  214. case AMI_CDTV:
  215. case AMI_CD32:
  216. AMIGAHW_SET(CD_ROM);
  217. AMIGAHW_SET(A2000_CLK); /* Is this correct? */
  218. goto Generic;
  219. Generic:
  220. AMIGAHW_SET(AMI_VIDEO);
  221. AMIGAHW_SET(AMI_BLITTER);
  222. AMIGAHW_SET(AMI_AUDIO);
  223. AMIGAHW_SET(AMI_FLOPPY);
  224. AMIGAHW_SET(AMI_KEYBOARD);
  225. AMIGAHW_SET(AMI_MOUSE);
  226. AMIGAHW_SET(AMI_SERIAL);
  227. AMIGAHW_SET(AMI_PARALLEL);
  228. AMIGAHW_SET(CHIP_RAM);
  229. AMIGAHW_SET(PAULA);
  230. switch (amiga_chipset) {
  231. case CS_OCS:
  232. case CS_ECS:
  233. case CS_AGA:
  234. switch (amiga_custom.deniseid & 0xf) {
  235. case 0x0c:
  236. AMIGAHW_SET(DENISE_HR);
  237. break;
  238. case 0x08:
  239. AMIGAHW_SET(LISA);
  240. break;
  241. }
  242. break;
  243. default:
  244. AMIGAHW_SET(DENISE);
  245. break;
  246. }
  247. switch ((amiga_custom.vposr>>8) & 0x7f) {
  248. case 0x00:
  249. AMIGAHW_SET(AGNUS_PAL);
  250. break;
  251. case 0x10:
  252. AMIGAHW_SET(AGNUS_NTSC);
  253. break;
  254. case 0x20:
  255. case 0x21:
  256. AMIGAHW_SET(AGNUS_HR_PAL);
  257. break;
  258. case 0x30:
  259. case 0x31:
  260. AMIGAHW_SET(AGNUS_HR_NTSC);
  261. break;
  262. case 0x22:
  263. case 0x23:
  264. AMIGAHW_SET(ALICE_PAL);
  265. break;
  266. case 0x32:
  267. case 0x33:
  268. AMIGAHW_SET(ALICE_NTSC);
  269. break;
  270. }
  271. AMIGAHW_SET(ZORRO);
  272. break;
  273. case AMI_DRACO:
  274. panic("No support for Draco yet");
  275. default:
  276. panic("Unknown Amiga Model");
  277. }
  278. #define AMIGAHW_ANNOUNCE(name, str) \
  279. if (AMIGAHW_PRESENT(name)) \
  280. pr_cont(str)
  281. AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
  282. AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
  283. AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
  284. AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
  285. AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
  286. AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
  287. AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
  288. AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
  289. AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
  290. AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
  291. AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
  292. AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
  293. AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
  294. AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
  295. AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
  296. AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
  297. AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
  298. AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
  299. AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
  300. AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
  301. AMIGAHW_ANNOUNCE(LISA, "LISA ");
  302. AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
  303. AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
  304. AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
  305. AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
  306. AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
  307. AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
  308. AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
  309. AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
  310. if (AMIGAHW_PRESENT(ZORRO))
  311. pr_cont("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
  312. pr_cont("\n");
  313. #undef AMIGAHW_ANNOUNCE
  314. }
  315. static unsigned long amiga_random_get_entropy(void)
  316. {
  317. /* VPOSR/VHPOSR provide at least 17 bits of data changing at 1.79 MHz */
  318. return *(unsigned long *)&amiga_custom.vposr;
  319. }
  320. /*
  321. * Setup the Amiga configuration info
  322. */
  323. void __init config_amiga(void)
  324. {
  325. int i;
  326. amiga_identify();
  327. /* Yuk, we don't have PCI memory */
  328. iomem_resource.name = "Memory";
  329. for (i = 0; i < 4; i++)
  330. request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
  331. mach_sched_init = amiga_sched_init;
  332. mach_init_IRQ = amiga_init_IRQ;
  333. mach_get_model = amiga_get_model;
  334. mach_get_hardware_list = amiga_get_hardware_list;
  335. arch_gettimeoffset = amiga_gettimeoffset;
  336. /*
  337. * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI
  338. * code will not be able to allocate any mem for transfers, unless we are
  339. * dealing with a Z2 mem only system. /Jes
  340. */
  341. mach_max_dma_address = 0xffffffff;
  342. mach_reset = amiga_reset;
  343. #if IS_ENABLED(CONFIG_INPUT_M68K_BEEP)
  344. mach_beep = amiga_mksound;
  345. #endif
  346. #ifdef CONFIG_HEARTBEAT
  347. mach_heartbeat = amiga_heartbeat;
  348. #endif
  349. mach_random_get_entropy = amiga_random_get_entropy;
  350. /* Fill in the clock value (based on the 700 kHz E-Clock) */
  351. amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
  352. /* clear all DMA bits */
  353. amiga_custom.dmacon = DMAF_ALL;
  354. /* ensure that the DMA master bit is set */
  355. amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
  356. /* don't use Z2 RAM as system memory on Z3 capable machines */
  357. if (AMIGAHW_PRESENT(ZORRO3)) {
  358. int i, j;
  359. u32 disabled_z2mem = 0;
  360. for (i = 0; i < m68k_num_memory; i++) {
  361. if (m68k_memory[i].addr < 16*1024*1024) {
  362. if (i == 0) {
  363. /* don't cut off the branch we're sitting on */
  364. pr_warn("Warning: kernel runs in Zorro II memory\n");
  365. continue;
  366. }
  367. disabled_z2mem += m68k_memory[i].size;
  368. m68k_num_memory--;
  369. for (j = i; j < m68k_num_memory; j++)
  370. m68k_memory[j] = m68k_memory[j+1];
  371. i--;
  372. }
  373. }
  374. if (disabled_z2mem)
  375. pr_info("%dK of Zorro II memory will not be used as system memory\n",
  376. disabled_z2mem>>10);
  377. }
  378. /* request all RAM */
  379. for (i = 0; i < m68k_num_memory; i++) {
  380. ram_resource[i].name =
  381. (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
  382. (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
  383. "16-bit Slow RAM";
  384. ram_resource[i].start = m68k_memory[i].addr;
  385. ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
  386. request_resource(&iomem_resource, &ram_resource[i]);
  387. }
  388. /* initialize chipram allocator */
  389. amiga_chip_init();
  390. /* our beloved beeper */
  391. if (AMIGAHW_PRESENT(AMI_AUDIO))
  392. amiga_init_sound();
  393. /*
  394. * if it is an A3000, set the magic bit that forces
  395. * a hard rekick
  396. */
  397. if (AMIGAHW_PRESENT(MAGIC_REKICK))
  398. *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
  399. }
  400. static unsigned short jiffy_ticks;
  401. static void __init amiga_sched_init(irq_handler_t timer_routine)
  402. {
  403. static struct resource sched_res = {
  404. .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
  405. };
  406. jiffy_ticks = DIV_ROUND_CLOSEST(amiga_eclock, HZ);
  407. if (request_resource(&mb_resources._ciab, &sched_res))
  408. pr_warn("Cannot allocate ciab.ta{lo,hi}\n");
  409. ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */
  410. ciab.talo = jiffy_ticks % 256;
  411. ciab.tahi = jiffy_ticks / 256;
  412. /* install interrupt service routine for CIAB Timer A
  413. *
  414. * Please don't change this to use ciaa, as it interferes with the
  415. * SCSI code. We'll have to take a look at this later
  416. */
  417. if (request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL))
  418. pr_err("Couldn't register timer interrupt\n");
  419. /* start timer */
  420. ciab.cra |= 0x11;
  421. }
  422. #define TICK_SIZE 10000
  423. /* This is always executed with interrupts disabled. */
  424. static u32 amiga_gettimeoffset(void)
  425. {
  426. unsigned short hi, lo, hi2;
  427. u32 ticks, offset = 0;
  428. /* read CIA B timer A current value */
  429. hi = ciab.tahi;
  430. lo = ciab.talo;
  431. hi2 = ciab.tahi;
  432. if (hi != hi2) {
  433. lo = ciab.talo;
  434. hi = hi2;
  435. }
  436. ticks = hi << 8 | lo;
  437. if (ticks > jiffy_ticks / 2)
  438. /* check for pending interrupt */
  439. if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA)
  440. offset = 10000;
  441. ticks = jiffy_ticks - ticks;
  442. ticks = (10000 * ticks) / jiffy_ticks;
  443. return (ticks + offset) * 1000;
  444. }
  445. static void amiga_reset(void) __noreturn;
  446. static void amiga_reset(void)
  447. {
  448. unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
  449. unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
  450. local_irq_disable();
  451. if (CPU_IS_040_OR_060)
  452. /* Setup transparent translation registers for mapping
  453. * of 16 MB kernel segment before disabling translation
  454. */
  455. asm volatile ("\n"
  456. " move.l %0,%%d0\n"
  457. " and.l #0xff000000,%%d0\n"
  458. " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */
  459. " .chip 68040\n"
  460. " movec %%d0,%%itt0\n"
  461. " movec %%d0,%%dtt0\n"
  462. " .chip 68k\n"
  463. " jmp %0@\n"
  464. : /* no outputs */
  465. : "a" (jmp_addr040)
  466. : "d0");
  467. else
  468. /* for 680[23]0, just disable translation and jump to the physical
  469. * address of the label
  470. */
  471. asm volatile ("\n"
  472. " pmove %%tc,%@\n"
  473. " bclr #7,%@\n"
  474. " pmove %@,%%tc\n"
  475. " jmp %0@\n"
  476. : /* no outputs */
  477. : "a" (jmp_addr));
  478. jmp_addr_label040:
  479. /* disable translation on '040 now */
  480. asm volatile ("\n"
  481. " moveq #0,%%d0\n"
  482. " .chip 68040\n"
  483. " movec %%d0,%%tc\n" /* disable MMU */
  484. " .chip 68k\n"
  485. : /* no outputs */
  486. : /* no inputs */
  487. : "d0");
  488. jmp_addr_label:
  489. /* pickup reset address from AmigaOS ROM, reset devices and jump
  490. * to reset address
  491. */
  492. asm volatile ("\n"
  493. " move.w #0x2700,%sr\n"
  494. " lea 0x01000000,%a0\n"
  495. " sub.l %a0@(-0x14),%a0\n"
  496. " move.l %a0@(4),%a0\n"
  497. " subq.l #2,%a0\n"
  498. " jra 1f\n"
  499. /* align on a longword boundary */
  500. " " __ALIGN_STR "\n"
  501. "1:\n"
  502. " reset\n"
  503. " jmp %a0@");
  504. for (;;)
  505. ;
  506. }
  507. /*
  508. * Debugging
  509. */
  510. #define SAVEKMSG_MAXMEM 128*1024
  511. #define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */
  512. #define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
  513. struct savekmsg {
  514. unsigned long magic1; /* SAVEKMSG_MAGIC1 */
  515. unsigned long magic2; /* SAVEKMSG_MAGIC2 */
  516. unsigned long magicptr; /* address of magic1 */
  517. unsigned long size;
  518. char data[0];
  519. };
  520. static struct savekmsg *savekmsg;
  521. static void amiga_mem_console_write(struct console *co, const char *s,
  522. unsigned int count)
  523. {
  524. if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
  525. memcpy(savekmsg->data + savekmsg->size, s, count);
  526. savekmsg->size += count;
  527. }
  528. }
  529. static int __init amiga_savekmsg_setup(char *arg)
  530. {
  531. bool registered;
  532. if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
  533. return 0;
  534. if (amiga_chip_size < SAVEKMSG_MAXMEM) {
  535. pr_err("Not enough chipram for debugging\n");
  536. return -ENOMEM;
  537. }
  538. /* Just steal the block, the chipram allocator isn't functional yet */
  539. amiga_chip_size -= SAVEKMSG_MAXMEM;
  540. savekmsg = ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size);
  541. savekmsg->magic1 = SAVEKMSG_MAGIC1;
  542. savekmsg->magic2 = SAVEKMSG_MAGIC2;
  543. savekmsg->magicptr = ZTWO_PADDR(savekmsg);
  544. savekmsg->size = 0;
  545. registered = !!amiga_console_driver.write;
  546. amiga_console_driver.write = amiga_mem_console_write;
  547. if (!registered)
  548. register_console(&amiga_console_driver);
  549. return 0;
  550. }
  551. early_param("debug", amiga_savekmsg_setup);
  552. static void amiga_serial_putc(char c)
  553. {
  554. amiga_custom.serdat = (unsigned char)c | 0x100;
  555. while (!(amiga_custom.serdatr & 0x2000))
  556. ;
  557. }
  558. static void amiga_serial_console_write(struct console *co, const char *s,
  559. unsigned int count)
  560. {
  561. while (count--) {
  562. if (*s == '\n')
  563. amiga_serial_putc('\r');
  564. amiga_serial_putc(*s++);
  565. }
  566. }
  567. #if 0
  568. void amiga_serial_puts(const char *s)
  569. {
  570. amiga_serial_console_write(NULL, s, strlen(s));
  571. }
  572. int amiga_serial_console_wait_key(struct console *co)
  573. {
  574. int ch;
  575. while (!(amiga_custom.intreqr & IF_RBF))
  576. barrier();
  577. ch = amiga_custom.serdatr & 0xff;
  578. /* clear the interrupt, so that another character can be read */
  579. amiga_custom.intreq = IF_RBF;
  580. return ch;
  581. }
  582. void amiga_serial_gets(struct console *co, char *s, int len)
  583. {
  584. int ch, cnt = 0;
  585. while (1) {
  586. ch = amiga_serial_console_wait_key(co);
  587. /* Check for backspace. */
  588. if (ch == 8 || ch == 127) {
  589. if (cnt == 0) {
  590. amiga_serial_putc('\007');
  591. continue;
  592. }
  593. cnt--;
  594. amiga_serial_puts("\010 \010");
  595. continue;
  596. }
  597. /* Check for enter. */
  598. if (ch == 10 || ch == 13)
  599. break;
  600. /* See if line is too long. */
  601. if (cnt >= len + 1) {
  602. amiga_serial_putc(7);
  603. cnt--;
  604. continue;
  605. }
  606. /* Store and echo character. */
  607. s[cnt++] = ch;
  608. amiga_serial_putc(ch);
  609. }
  610. /* Print enter. */
  611. amiga_serial_puts("\r\n");
  612. s[cnt] = 0;
  613. }
  614. #endif
  615. static int __init amiga_debug_setup(char *arg)
  616. {
  617. bool registered;
  618. if (!MACH_IS_AMIGA || strcmp(arg, "ser"))
  619. return 0;
  620. /* no initialization required (?) */
  621. registered = !!amiga_console_driver.write;
  622. amiga_console_driver.write = amiga_serial_console_write;
  623. if (!registered)
  624. register_console(&amiga_console_driver);
  625. return 0;
  626. }
  627. early_param("debug", amiga_debug_setup);
  628. #ifdef CONFIG_HEARTBEAT
  629. static void amiga_heartbeat(int on)
  630. {
  631. if (on)
  632. ciaa.pra &= ~2;
  633. else
  634. ciaa.pra |= 2;
  635. }
  636. #endif
  637. /*
  638. * Amiga specific parts of /proc
  639. */
  640. static void amiga_get_model(char *model)
  641. {
  642. strcpy(model, amiga_model_name);
  643. }
  644. static void amiga_get_hardware_list(struct seq_file *m)
  645. {
  646. if (AMIGAHW_PRESENT(CHIP_RAM))
  647. seq_printf(m, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
  648. seq_printf(m, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
  649. amiga_psfreq, amiga_eclock);
  650. if (AMIGAHW_PRESENT(AMI_VIDEO)) {
  651. char *type;
  652. switch (amiga_chipset) {
  653. case CS_OCS:
  654. type = "OCS";
  655. break;
  656. case CS_ECS:
  657. type = "ECS";
  658. break;
  659. case CS_AGA:
  660. type = "AGA";
  661. break;
  662. default:
  663. type = "Old or Unknown";
  664. break;
  665. }
  666. seq_printf(m, "Graphics:\t%s\n", type);
  667. }
  668. #define AMIGAHW_ANNOUNCE(name, str) \
  669. if (AMIGAHW_PRESENT(name)) \
  670. seq_printf (m, "\t%s\n", str)
  671. seq_printf (m, "Detected hardware:\n");
  672. AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
  673. AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
  674. AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
  675. AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
  676. AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
  677. AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
  678. AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
  679. AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
  680. AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
  681. AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
  682. AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
  683. AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
  684. AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
  685. AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
  686. AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
  687. AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
  688. AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
  689. AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
  690. AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
  691. AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
  692. AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
  693. AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
  694. AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
  695. AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
  696. AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
  697. AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
  698. AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
  699. AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
  700. AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
  701. #ifdef CONFIG_ZORRO
  702. if (AMIGAHW_PRESENT(ZORRO))
  703. seq_printf(m, "\tZorro II%s AutoConfig: %d Expansion "
  704. "Device%s\n",
  705. AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
  706. zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
  707. #endif /* CONFIG_ZORRO */
  708. #undef AMIGAHW_ANNOUNCE
  709. }
  710. /*
  711. * The Amiga keyboard driver needs key_maps, but we cannot export it in
  712. * drivers/char/defkeymap.c, as it is autogenerated
  713. */
  714. #ifdef CONFIG_HW_CONSOLE
  715. EXPORT_SYMBOL_GPL(key_maps);
  716. #endif