apus_setup.c 19 KB

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