apus_setup.c 19 KB

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