apus_setup.c 19 KB

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