apus_setup.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. /*
  2. * arch/ppc/platforms/apus_setup.c
  3. *
  4. * Copyright (C) 1998, 1999 Jesper Skov
  5. *
  6. * Basically what is needed to replace functionality found in
  7. * arch/m68k allowing Amiga drivers to work under APUS.
  8. * Bits of code and/or ideas from arch/m68k and arch/ppc files.
  9. *
  10. * TODO:
  11. * This file needs a *really* good cleanup. Restructure and optimize.
  12. * Make sure it can be compiled for non-APUS configs. Begin to move
  13. * Amiga specific stuff into mach/amiga.
  14. */
  15. #include <linux/config.h>
  16. #include <linux/kernel.h>
  17. #include <linux/sched.h>
  18. #include <linux/init.h>
  19. #include <linux/initrd.h>
  20. #include <linux/seq_file.h>
  21. /* Needs INITSERIAL call in head.S! */
  22. #undef APUS_DEBUG
  23. #include <asm/bootinfo.h>
  24. #include <asm/setup.h>
  25. #include <asm/amigahw.h>
  26. #include <asm/amigaints.h>
  27. #include <asm/amigappc.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/dma.h>
  30. #include <asm/machdep.h>
  31. #include <asm/time.h>
  32. unsigned long m68k_machtype;
  33. char debug_device[6] = "";
  34. extern void amiga_init_IRQ(void);
  35. extern void apus_setup_pci_ptrs(void);
  36. void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *)) __initdata = NULL;
  37. /* machine dependent irq functions */
  38. void (*mach_init_IRQ) (void) __initdata = NULL;
  39. void (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
  40. void (*mach_get_model) (char *model) = NULL;
  41. int (*mach_get_hardware_list) (char *buffer) = NULL;
  42. int (*mach_get_irq_list) (struct seq_file *, void *) = NULL;
  43. void (*mach_process_int) (int, struct pt_regs *) = NULL;
  44. /* machine dependent timer functions */
  45. unsigned long (*mach_gettimeoffset) (void);
  46. void (*mach_gettod) (int*, int*, int*, int*, int*, int*);
  47. int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
  48. int (*mach_set_clock_mmss) (unsigned long) = NULL;
  49. void (*mach_reset)( void );
  50. long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
  51. #if defined(CONFIG_AMIGA_FLOPPY)
  52. void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
  53. #endif
  54. #ifdef CONFIG_HEARTBEAT
  55. void (*mach_heartbeat) (int) = NULL;
  56. extern void apus_heartbeat (void);
  57. #endif
  58. extern unsigned long amiga_model;
  59. extern unsigned decrementer_count;/* count value for 1e6/HZ microseconds */
  60. extern unsigned count_period_num; /* 1 decrementer count equals */
  61. extern unsigned count_period_den; /* count_period_num / count_period_den us */
  62. int num_memory = 0;
  63. struct mem_info memory[NUM_MEMINFO];/* memory description */
  64. /* FIXME: Duplicate memory data to avoid conflicts with m68k shared code. */
  65. int m68k_realnum_memory = 0;
  66. struct mem_info m68k_memory[NUM_MEMINFO];/* memory description */
  67. struct mem_info ramdisk;
  68. extern void amiga_floppy_setup(char *, int *);
  69. extern void config_amiga(void);
  70. static int __60nsram = 0;
  71. /* for cpuinfo */
  72. static int __bus_speed = 0;
  73. static int __speed_test_failed = 0;
  74. /********************************************** COMPILE PROTECTION */
  75. /* Provide some stubs that links to Amiga specific functions.
  76. * This allows CONFIG_APUS to be removed from generic PPC files while
  77. * preventing link errors for other PPC targets.
  78. */
  79. unsigned long apus_get_rtc_time(void)
  80. {
  81. #ifdef CONFIG_APUS
  82. extern unsigned long m68k_get_rtc_time(void);
  83. return m68k_get_rtc_time ();
  84. #else
  85. return 0;
  86. #endif
  87. }
  88. int apus_set_rtc_time(unsigned long nowtime)
  89. {
  90. #ifdef CONFIG_APUS
  91. extern int m68k_set_rtc_time(unsigned long nowtime);
  92. return m68k_set_rtc_time (nowtime);
  93. #else
  94. return 0;
  95. #endif
  96. }
  97. /*********************************************************** SETUP */
  98. /* From arch/m68k/kernel/setup.c. */
  99. void __init apus_setup_arch(void)
  100. {
  101. #ifdef CONFIG_APUS
  102. extern char cmd_line[];
  103. int i;
  104. char *p, *q;
  105. /* Let m68k-shared code know it should do the Amiga thing. */
  106. m68k_machtype = MACH_AMIGA;
  107. /* Parse the command line for arch-specific options.
  108. * For the m68k, this is currently only "debug=xxx" to enable printing
  109. * certain kernel messages to some machine-specific device. */
  110. for( p = cmd_line; p && *p; ) {
  111. i = 0;
  112. if (!strncmp( p, "debug=", 6 )) {
  113. strlcpy( debug_device, p+6, sizeof(debug_device) );
  114. if ((q = strchr( debug_device, ' ' ))) *q = 0;
  115. i = 1;
  116. } else if (!strncmp( p, "60nsram", 7 )) {
  117. APUS_WRITE (APUS_REG_WAITSTATE,
  118. REGWAITSTATE_SETRESET
  119. |REGWAITSTATE_PPCR
  120. |REGWAITSTATE_PPCW);
  121. __60nsram = 1;
  122. i = 1;
  123. }
  124. if (i) {
  125. /* option processed, delete it */
  126. if ((q = strchr( p, ' ' )))
  127. strcpy( p, q+1 );
  128. else
  129. *p = 0;
  130. } else {
  131. if ((p = strchr( p, ' ' ))) ++p;
  132. }
  133. }
  134. config_amiga();
  135. #if 0 /* Enable for logging - also include logging.o in Makefile rule */
  136. {
  137. #define LOG_SIZE 4096
  138. void* base;
  139. /* Throw away some memory - the P5 firmare stomps on top
  140. * of CHIP memory during bootup.
  141. */
  142. amiga_chip_alloc(0x1000);
  143. base = amiga_chip_alloc(LOG_SIZE+sizeof(klog_data_t));
  144. LOG_INIT(base, base+sizeof(klog_data_t), LOG_SIZE);
  145. }
  146. #endif
  147. #endif
  148. }
  149. int
  150. apus_show_cpuinfo(struct seq_file *m)
  151. {
  152. extern int __map_without_bats;
  153. extern unsigned long powerup_PCI_present;
  154. seq_printf(m, "machine\t\t: Amiga\n");
  155. seq_printf(m, "bus speed\t: %d%s", __bus_speed,
  156. (__speed_test_failed) ? " [failed]\n" : "\n");
  157. seq_printf(m, "using BATs\t: %s\n",
  158. (__map_without_bats) ? "No" : "Yes");
  159. seq_printf(m, "ram speed\t: %dns\n", (__60nsram) ? 60 : 70);
  160. seq_printf(m, "PCI bridge\t: %s\n",
  161. (powerup_PCI_present) ? "Yes" : "No");
  162. return 0;
  163. }
  164. static void get_current_tb(unsigned long long *time)
  165. {
  166. __asm __volatile ("1:mftbu 4 \n\t"
  167. " mftb 5 \n\t"
  168. " mftbu 6 \n\t"
  169. " cmpw 4,6 \n\t"
  170. " bne 1b \n\t"
  171. " stw 4,0(%0)\n\t"
  172. " stw 5,4(%0)\n\t"
  173. :
  174. : "r" (time)
  175. : "r4", "r5", "r6");
  176. }
  177. void apus_calibrate_decr(void)
  178. {
  179. #ifdef CONFIG_APUS
  180. unsigned long freq;
  181. /* This algorithm for determining the bus speed was
  182. contributed by Ralph Schmidt. */
  183. unsigned long long start, stop;
  184. int bus_speed;
  185. int speed_test_failed = 0;
  186. {
  187. unsigned long loop = amiga_eclock / 10;
  188. get_current_tb (&start);
  189. while (loop--) {
  190. unsigned char tmp;
  191. tmp = ciaa.pra;
  192. }
  193. get_current_tb (&stop);
  194. }
  195. bus_speed = (((unsigned long)(stop-start))*10*4) / 1000000;
  196. if (AMI_1200 == amiga_model)
  197. bus_speed /= 2;
  198. if ((bus_speed >= 47) && (bus_speed < 53)) {
  199. bus_speed = 50;
  200. freq = 12500000;
  201. } else if ((bus_speed >= 57) && (bus_speed < 63)) {
  202. bus_speed = 60;
  203. freq = 15000000;
  204. } else if ((bus_speed >= 63) && (bus_speed < 69)) {
  205. bus_speed = 67;
  206. freq = 16666667;
  207. } else {
  208. printk ("APUS: Unable to determine bus speed (%d). "
  209. "Defaulting to 50MHz", bus_speed);
  210. bus_speed = 50;
  211. freq = 12500000;
  212. speed_test_failed = 1;
  213. }
  214. /* Ease diagnostics... */
  215. {
  216. extern int __map_without_bats;
  217. extern unsigned long powerup_PCI_present;
  218. printk ("APUS: BATs=%d, BUS=%dMHz",
  219. (__map_without_bats) ? 0 : 1,
  220. bus_speed);
  221. if (speed_test_failed)
  222. printk ("[FAILED - please report]");
  223. printk (", RAM=%dns, PCI bridge=%d\n",
  224. (__60nsram) ? 60 : 70,
  225. (powerup_PCI_present) ? 1 : 0);
  226. /* print a bit more if asked politely... */
  227. if (!(ciaa.pra & 0x40)){
  228. extern unsigned int bat_addrs[4][3];
  229. int b;
  230. for (b = 0; b < 4; ++b) {
  231. printk ("APUS: BAT%d ", b);
  232. printk ("%08x-%08x -> %08x\n",
  233. bat_addrs[b][0],
  234. bat_addrs[b][1],
  235. bat_addrs[b][2]);
  236. }
  237. }
  238. }
  239. printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
  240. freq/1000000, freq%1000000);
  241. tb_ticks_per_jiffy = freq / HZ;
  242. tb_to_us = mulhwu_scale_factor(freq, 1000000);
  243. __bus_speed = bus_speed;
  244. __speed_test_failed = speed_test_failed;
  245. #endif
  246. }
  247. void arch_gettod(int *year, int *mon, int *day, int *hour,
  248. int *min, int *sec)
  249. {
  250. #ifdef CONFIG_APUS
  251. if (mach_gettod)
  252. mach_gettod(year, mon, day, hour, min, sec);
  253. else
  254. *year = *mon = *day = *hour = *min = *sec = 0;
  255. #endif
  256. }
  257. /* for "kbd-reset" cmdline param */
  258. __init
  259. void kbd_reset_setup(char *str, int *ints)
  260. {
  261. }
  262. /*********************************************************** FLOPPY */
  263. #if defined(CONFIG_AMIGA_FLOPPY)
  264. __init
  265. void floppy_setup(char *str, int *ints)
  266. {
  267. if (mach_floppy_setup)
  268. mach_floppy_setup (str, ints);
  269. }
  270. #endif
  271. /*********************************************************** MEMORY */
  272. #define KMAP_MAX 32
  273. unsigned long kmap_chunks[KMAP_MAX*3];
  274. int kmap_chunk_count = 0;
  275. /* From pgtable.h */
  276. static __inline__ pte_t *my_find_pte(struct mm_struct *mm,unsigned long va)
  277. {
  278. pgd_t *dir = 0;
  279. pmd_t *pmd = 0;
  280. pte_t *pte = 0;
  281. va &= PAGE_MASK;
  282. dir = pgd_offset( mm, va );
  283. if (dir)
  284. {
  285. pmd = pmd_offset(dir, va & PAGE_MASK);
  286. if (pmd && pmd_present(*pmd))
  287. {
  288. pte = pte_offset(pmd, va);
  289. }
  290. }
  291. return pte;
  292. }
  293. /* Again simulating an m68k/mm/kmap.c function. */
  294. void kernel_set_cachemode( unsigned long address, unsigned long size,
  295. unsigned int cmode )
  296. {
  297. unsigned long mask, flags;
  298. switch (cmode)
  299. {
  300. case IOMAP_FULL_CACHING:
  301. mask = ~(_PAGE_NO_CACHE | _PAGE_GUARDED);
  302. flags = 0;
  303. break;
  304. case IOMAP_NOCACHE_SER:
  305. mask = ~0;
  306. flags = (_PAGE_NO_CACHE | _PAGE_GUARDED);
  307. break;
  308. default:
  309. panic ("kernel_set_cachemode() doesn't support mode %d\n",
  310. cmode);
  311. break;
  312. }
  313. size /= PAGE_SIZE;
  314. address &= PAGE_MASK;
  315. while (size--)
  316. {
  317. pte_t *pte;
  318. pte = my_find_pte(&init_mm, address);
  319. if ( !pte )
  320. {
  321. printk("pte NULL in kernel_set_cachemode()\n");
  322. return;
  323. }
  324. pte_val (*pte) &= mask;
  325. pte_val (*pte) |= flags;
  326. flush_tlb_page(find_vma(&init_mm,address),address);
  327. address += PAGE_SIZE;
  328. }
  329. }
  330. unsigned long mm_ptov (unsigned long paddr)
  331. {
  332. unsigned long ret;
  333. if (paddr < 16*1024*1024)
  334. ret = ZTWO_VADDR(paddr);
  335. else {
  336. int i;
  337. for (i = 0; i < kmap_chunk_count;){
  338. unsigned long phys = kmap_chunks[i++];
  339. unsigned long size = kmap_chunks[i++];
  340. unsigned long virt = kmap_chunks[i++];
  341. if (paddr >= phys
  342. && paddr < (phys + size)){
  343. ret = virt + paddr - phys;
  344. goto exit;
  345. }
  346. }
  347. ret = (unsigned long) __va(paddr);
  348. }
  349. exit:
  350. #ifdef DEBUGPV
  351. printk ("PTOV(%lx)=%lx\n", paddr, ret);
  352. #endif
  353. return ret;
  354. }
  355. int mm_end_of_chunk (unsigned long addr, int len)
  356. {
  357. if (memory[0].addr + memory[0].size == addr + len)
  358. return 1;
  359. return 0;
  360. }
  361. /*********************************************************** CACHE */
  362. #define L1_CACHE_BYTES 32
  363. #define MAX_CACHE_SIZE 8192
  364. void cache_push(__u32 addr, int length)
  365. {
  366. addr = mm_ptov(addr);
  367. if (MAX_CACHE_SIZE < length)
  368. length = MAX_CACHE_SIZE;
  369. while(length > 0){
  370. __asm ("dcbf 0,%0\n\t"
  371. : : "r" (addr));
  372. addr += L1_CACHE_BYTES;
  373. length -= L1_CACHE_BYTES;
  374. }
  375. /* Also flush trailing block */
  376. __asm ("dcbf 0,%0\n\t"
  377. "sync \n\t"
  378. : : "r" (addr));
  379. }
  380. void cache_clear(__u32 addr, int length)
  381. {
  382. if (MAX_CACHE_SIZE < length)
  383. length = MAX_CACHE_SIZE;
  384. addr = mm_ptov(addr);
  385. __asm ("dcbf 0,%0\n\t"
  386. "sync \n\t"
  387. "icbi 0,%0 \n\t"
  388. "isync \n\t"
  389. : : "r" (addr));
  390. addr += L1_CACHE_BYTES;
  391. length -= L1_CACHE_BYTES;
  392. while(length > 0){
  393. __asm ("dcbf 0,%0\n\t"
  394. "sync \n\t"
  395. "icbi 0,%0 \n\t"
  396. "isync \n\t"
  397. : : "r" (addr));
  398. addr += L1_CACHE_BYTES;
  399. length -= L1_CACHE_BYTES;
  400. }
  401. __asm ("dcbf 0,%0\n\t"
  402. "sync \n\t"
  403. "icbi 0,%0 \n\t"
  404. "isync \n\t"
  405. : : "r" (addr));
  406. }
  407. /****************************************************** from setup.c */
  408. void
  409. apus_restart(char *cmd)
  410. {
  411. local_irq_disable();
  412. APUS_WRITE(APUS_REG_LOCK,
  413. REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK2);
  414. APUS_WRITE(APUS_REG_LOCK,
  415. REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK3);
  416. APUS_WRITE(APUS_REG_LOCK,
  417. REGLOCK_BLACKMAGICK2|REGLOCK_BLACKMAGICK3);
  418. APUS_WRITE(APUS_REG_SHADOW, REGSHADOW_SELFRESET);
  419. APUS_WRITE(APUS_REG_RESET, REGRESET_AMIGARESET);
  420. for(;;);
  421. }
  422. void
  423. apus_power_off(void)
  424. {
  425. for (;;);
  426. }
  427. void
  428. apus_halt(void)
  429. {
  430. apus_restart(NULL);
  431. }
  432. /****************************************************** IRQ stuff */
  433. static unsigned char last_ipl[8];
  434. int apus_get_irq(struct pt_regs* regs)
  435. {
  436. unsigned char ipl_emu, mask;
  437. unsigned int level;
  438. APUS_READ(APUS_IPL_EMU, ipl_emu);
  439. level = (ipl_emu >> 3) & IPLEMU_IPLMASK;
  440. mask = IPLEMU_SETRESET|IPLEMU_DISABLEINT|level;
  441. level ^= 7;
  442. /* Save previous IPL value */
  443. if (last_ipl[level])
  444. return -2;
  445. last_ipl[level] = ipl_emu;
  446. /* Set to current IPL value */
  447. APUS_WRITE(APUS_IPL_EMU, mask);
  448. APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT|level);
  449. #ifdef __INTERRUPT_DEBUG
  450. printk("<%d:%d>", level, ~ipl_emu & IPLEMU_IPLMASK);
  451. #endif
  452. return level + IRQ_AMIGA_AUTO;
  453. }
  454. void apus_end_irq(unsigned int irq)
  455. {
  456. unsigned char ipl_emu;
  457. unsigned int level = irq - IRQ_AMIGA_AUTO;
  458. #ifdef __INTERRUPT_DEBUG
  459. printk("{%d}", ~last_ipl[level] & IPLEMU_IPLMASK);
  460. #endif
  461. /* Restore IPL to the previous value */
  462. ipl_emu = last_ipl[level] & IPLEMU_IPLMASK;
  463. APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET|IPLEMU_DISABLEINT|ipl_emu);
  464. last_ipl[level] = 0;
  465. ipl_emu ^= 7;
  466. APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT|ipl_emu);
  467. }
  468. /****************************************************** debugging */
  469. /* some serial hardware definitions */
  470. #define SDR_OVRUN (1<<15)
  471. #define SDR_RBF (1<<14)
  472. #define SDR_TBE (1<<13)
  473. #define SDR_TSRE (1<<12)
  474. #define AC_SETCLR (1<<15)
  475. #define AC_UARTBRK (1<<11)
  476. #define SER_DTR (1<<7)
  477. #define SER_RTS (1<<6)
  478. #define SER_DCD (1<<5)
  479. #define SER_CTS (1<<4)
  480. #define SER_DSR (1<<3)
  481. static __inline__ void ser_RTSon(void)
  482. {
  483. ciab.pra &= ~SER_RTS; /* active low */
  484. }
  485. int __debug_ser_out( unsigned char c )
  486. {
  487. custom.serdat = c | 0x100;
  488. mb();
  489. while (!(custom.serdatr & 0x2000))
  490. barrier();
  491. return 1;
  492. }
  493. unsigned char __debug_ser_in( void )
  494. {
  495. unsigned char c;
  496. /* XXX: is that ok?? derived from amiga_ser.c... */
  497. while( !(custom.intreqr & IF_RBF) )
  498. barrier();
  499. c = custom.serdatr;
  500. /* clear the interrupt, so that another character can be read */
  501. custom.intreq = IF_RBF;
  502. return c;
  503. }
  504. int __debug_serinit( void )
  505. {
  506. unsigned long flags;
  507. local_irq_save(flags);
  508. /* turn off Rx and Tx interrupts */
  509. custom.intena = IF_RBF | IF_TBE;
  510. /* clear any pending interrupt */
  511. custom.intreq = IF_RBF | IF_TBE;
  512. local_irq_restore(flags);
  513. /*
  514. * set the appropriate directions for the modem control flags,
  515. * and clear RTS and DTR
  516. */
  517. ciab.ddra |= (SER_DTR | SER_RTS); /* outputs */
  518. ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */
  519. #ifdef CONFIG_KGDB
  520. /* turn Rx interrupts on for GDB */
  521. custom.intena = IF_SETCLR | IF_RBF;
  522. ser_RTSon();
  523. #endif
  524. return 0;
  525. }
  526. void __debug_print_hex(unsigned long x)
  527. {
  528. int i;
  529. char hexchars[] = "0123456789ABCDEF";
  530. for (i = 0; i < 8; i++) {
  531. __debug_ser_out(hexchars[(x >> 28) & 15]);
  532. x <<= 4;
  533. }
  534. __debug_ser_out('\n');
  535. __debug_ser_out('\r');
  536. }
  537. void __debug_print_string(char* s)
  538. {
  539. unsigned char c;
  540. while((c = *s++))
  541. __debug_ser_out(c);
  542. __debug_ser_out('\n');
  543. __debug_ser_out('\r');
  544. }
  545. static void apus_progress(char *s, unsigned short value)
  546. {
  547. __debug_print_string(s);
  548. }
  549. /****************************************************** init */
  550. /* The number of spurious interrupts */
  551. volatile unsigned int num_spurious;
  552. extern struct irqaction amiga_sys_irqaction[AUTO_IRQS];
  553. extern void amiga_enable_irq(unsigned int irq);
  554. extern void amiga_disable_irq(unsigned int irq);
  555. struct hw_interrupt_type amiga_sys_irqctrl = {
  556. .typename = "Amiga IPL",
  557. .end = apus_end_irq,
  558. };
  559. struct hw_interrupt_type amiga_irqctrl = {
  560. .typename = "Amiga ",
  561. .enable = amiga_enable_irq,
  562. .disable = amiga_disable_irq,
  563. };
  564. #define HARDWARE_MAPPED_SIZE (512*1024)
  565. unsigned long __init apus_find_end_of_memory(void)
  566. {
  567. int shadow = 0;
  568. unsigned long total;
  569. /* The memory size reported by ADOS excludes the 512KB
  570. reserved for PPC exception registers and possibly 512KB
  571. containing a shadow of the ADOS ROM. */
  572. {
  573. unsigned long size = memory[0].size;
  574. /* If 2MB aligned, size was probably user
  575. specified. We can't tell anything about shadowing
  576. in this case so skip shadow assignment. */
  577. if (0 != (size & 0x1fffff)){
  578. /* Align to 512KB to ensure correct handling
  579. of both memfile and system specified
  580. sizes. */
  581. size = ((size+0x0007ffff) & 0xfff80000);
  582. /* If memory is 1MB aligned, assume
  583. shadowing. */
  584. shadow = !(size & 0x80000);
  585. }
  586. /* Add the chunk that ADOS does not see. by aligning
  587. the size to the nearest 2MB limit upwards. */
  588. memory[0].size = ((size+0x001fffff) & 0xffe00000);
  589. }
  590. ppc_memstart = memory[0].addr;
  591. ppc_memoffset = PAGE_OFFSET - PPC_MEMSTART;
  592. total = memory[0].size;
  593. /* Remove the memory chunks that are controlled by special
  594. Phase5 hardware. */
  595. /* Remove the upper 512KB if it contains a shadow of
  596. the ADOS ROM. FIXME: It might be possible to
  597. disable this shadow HW. Check the booter
  598. (ppc_boot.c) */
  599. if (shadow)
  600. total -= HARDWARE_MAPPED_SIZE;
  601. /* Remove the upper 512KB where the PPC exception
  602. vectors are mapped. */
  603. total -= HARDWARE_MAPPED_SIZE;
  604. /* Linux/APUS only handles one block of memory -- the one on
  605. the PowerUP board. Other system memory is horrible slow in
  606. comparison. The user can use other memory for swapping
  607. using the z2ram device. */
  608. return total;
  609. }
  610. static void __init
  611. apus_map_io(void)
  612. {
  613. /* Map PPC exception vectors. */
  614. io_block_mapping(0xfff00000, 0xfff00000, 0x00020000, _PAGE_KERNEL);
  615. /* Map chip and ZorroII memory */
  616. io_block_mapping(zTwoBase, 0x00000000, 0x01000000, _PAGE_IO);
  617. }
  618. __init
  619. void apus_init_IRQ(void)
  620. {
  621. struct irqaction *action;
  622. int i;
  623. #ifdef CONFIG_PCI
  624. apus_setup_pci_ptrs();
  625. #endif
  626. for ( i = 0 ; i < AMI_IRQS; i++ ) {
  627. irq_desc[i].status = IRQ_LEVEL;
  628. if (i < IRQ_AMIGA_AUTO) {
  629. irq_desc[i].handler = &amiga_irqctrl;
  630. } else {
  631. irq_desc[i].handler = &amiga_sys_irqctrl;
  632. action = &amiga_sys_irqaction[i-IRQ_AMIGA_AUTO];
  633. if (action->name)
  634. setup_irq(i, action);
  635. }
  636. }
  637. amiga_init_IRQ();
  638. }
  639. __init
  640. void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  641. unsigned long r6, unsigned long r7)
  642. {
  643. extern int parse_bootinfo(const struct bi_record *);
  644. extern char _end[];
  645. /* Parse bootinfo. The bootinfo is located right after
  646. the kernel bss */
  647. parse_bootinfo((const struct bi_record *)&_end);
  648. #ifdef CONFIG_BLK_DEV_INITRD
  649. /* Take care of initrd if we have one. Use data from
  650. bootinfo to avoid the need to initialize PPC
  651. registers when kernel is booted via a PPC reset. */
  652. if ( ramdisk.addr ) {
  653. initrd_start = (unsigned long) __va(ramdisk.addr);
  654. initrd_end = (unsigned long)
  655. __va(ramdisk.size + ramdisk.addr);
  656. }
  657. #endif /* CONFIG_BLK_DEV_INITRD */
  658. ISA_DMA_THRESHOLD = 0x00ffffff;
  659. ppc_md.setup_arch = apus_setup_arch;
  660. ppc_md.show_cpuinfo = apus_show_cpuinfo;
  661. ppc_md.init_IRQ = apus_init_IRQ;
  662. ppc_md.get_irq = apus_get_irq;
  663. #ifdef CONFIG_HEARTBEAT
  664. ppc_md.heartbeat = apus_heartbeat;
  665. ppc_md.heartbeat_count = 1;
  666. #endif
  667. #ifdef APUS_DEBUG
  668. __debug_serinit();
  669. ppc_md.progress = apus_progress;
  670. #endif
  671. ppc_md.init = NULL;
  672. ppc_md.restart = apus_restart;
  673. ppc_md.power_off = apus_power_off;
  674. ppc_md.halt = apus_halt;
  675. ppc_md.time_init = NULL;
  676. ppc_md.set_rtc_time = apus_set_rtc_time;
  677. ppc_md.get_rtc_time = apus_get_rtc_time;
  678. ppc_md.calibrate_decr = apus_calibrate_decr;
  679. ppc_md.find_end_of_memory = apus_find_end_of_memory;
  680. ppc_md.setup_io_mappings = apus_map_io;
  681. }