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