m8260_setup.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * arch/ppc/syslib/m8260_setup.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Adapted from 'alpha' version by Gary Thomas
  6. * Modified by Cort Dougan (cort@cs.nmt.edu)
  7. * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
  8. * Further modified for generic 8xx and 8260 by Dan.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/sched.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/stddef.h>
  15. #include <linux/slab.h>
  16. #include <linux/init.h>
  17. #include <linux/initrd.h>
  18. #include <linux/root_dev.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/irq.h>
  21. #include <asm/mmu.h>
  22. #include <asm/io.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/mpc8260.h>
  25. #include <asm/immap_cpm2.h>
  26. #include <asm/machdep.h>
  27. #include <asm/bootinfo.h>
  28. #include <asm/time.h>
  29. #include "cpm2_pic.h"
  30. unsigned char __res[sizeof(bd_t)];
  31. extern void cpm2_reset(void);
  32. extern void pq2_find_bridges(void);
  33. extern void pq2pci_init_irq(void);
  34. extern void idma_pci9_init(void);
  35. /* Place-holder for board-specific init */
  36. void __attribute__ ((weak)) __init
  37. m82xx_board_setup(void)
  38. {
  39. }
  40. static void __init
  41. m8260_setup_arch(void)
  42. {
  43. /* Print out Vendor and Machine info. */
  44. printk(KERN_INFO "%s %s port\n", CPUINFO_VENDOR, CPUINFO_MACHINE);
  45. /* Reset the Communication Processor Module. */
  46. cpm2_reset();
  47. #ifdef CONFIG_8260_PCI9
  48. /* Initialise IDMA for PCI erratum workaround */
  49. idma_pci9_init();
  50. #endif
  51. #ifdef CONFIG_PCI_8260
  52. pq2_find_bridges();
  53. #endif
  54. #ifdef CONFIG_BLK_DEV_INITRD
  55. if (initrd_start)
  56. ROOT_DEV = Root_RAM0;
  57. #endif
  58. m82xx_board_setup();
  59. }
  60. /* The decrementer counts at the system (internal) clock frequency
  61. * divided by four.
  62. */
  63. static void __init
  64. m8260_calibrate_decr(void)
  65. {
  66. bd_t *binfo = (bd_t *)__res;
  67. int freq, divisor;
  68. freq = binfo->bi_busfreq;
  69. divisor = 4;
  70. tb_ticks_per_jiffy = freq / HZ / divisor;
  71. tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
  72. }
  73. /* The 8260 has an internal 1-second timer update register that
  74. * we should use for this purpose.
  75. */
  76. static uint rtc_time;
  77. static int
  78. m8260_set_rtc_time(unsigned long time)
  79. {
  80. rtc_time = time;
  81. return(0);
  82. }
  83. static unsigned long
  84. m8260_get_rtc_time(void)
  85. {
  86. /* Get time from the RTC.
  87. */
  88. return((unsigned long)rtc_time);
  89. }
  90. #ifndef BOOTROM_RESTART_ADDR
  91. #warning "Using default BOOTROM_RESTART_ADDR!"
  92. #define BOOTROM_RESTART_ADDR 0xff000104
  93. #endif
  94. static void
  95. m8260_restart(char *cmd)
  96. {
  97. extern void m8260_gorom(bd_t *bi, uint addr);
  98. uint startaddr;
  99. /* Most boot roms have a warmstart as the second instruction
  100. * of the reset vector. If that doesn't work for you, change this
  101. * or the reboot program to send a proper address.
  102. */
  103. startaddr = BOOTROM_RESTART_ADDR;
  104. if (cmd != NULL) {
  105. if (!strncmp(cmd, "startaddr=", 10))
  106. startaddr = simple_strtoul(&cmd[10], NULL, 0);
  107. }
  108. m8260_gorom((void*)__pa(__res), startaddr);
  109. }
  110. static void
  111. m8260_halt(void)
  112. {
  113. local_irq_disable();
  114. while (1);
  115. }
  116. static void
  117. m8260_power_off(void)
  118. {
  119. m8260_halt();
  120. }
  121. static int
  122. m8260_show_cpuinfo(struct seq_file *m)
  123. {
  124. bd_t *bp = (bd_t *)__res;
  125. seq_printf(m, "vendor\t\t: %s\n"
  126. "machine\t\t: %s\n"
  127. "\n"
  128. "mem size\t\t: 0x%08x\n"
  129. "console baud\t\t: %d\n"
  130. "\n"
  131. "core clock\t: %u MHz\n"
  132. "CPM clock\t: %u MHz\n"
  133. "bus clock\t: %u MHz\n",
  134. CPUINFO_VENDOR, CPUINFO_MACHINE, bp->bi_memsize,
  135. bp->bi_baudrate, bp->bi_intfreq / 1000000,
  136. bp->bi_cpmfreq / 1000000, bp->bi_busfreq / 1000000);
  137. return 0;
  138. }
  139. /* Initialize the internal interrupt controller. The number of
  140. * interrupts supported can vary with the processor type, and the
  141. * 8260 family can have up to 64.
  142. * External interrupts can be either edge or level triggered, and
  143. * need to be initialized by the appropriate driver.
  144. */
  145. static void __init
  146. m8260_init_IRQ(void)
  147. {
  148. cpm2_init_IRQ();
  149. /* Initialize the default interrupt mapping priorities,
  150. * in case the boot rom changed something on us.
  151. */
  152. cpm2_immr->im_intctl.ic_siprr = 0x05309770;
  153. #if defined(CONFIG_PCI) && (defined(CONFIG_ADS8272) || defined(CONFIG_PQ2FADS))
  154. /* Initialize stuff for the 82xx CPLD IC and install demux */
  155. pq2pci_init_irq();
  156. #endif
  157. }
  158. /*
  159. * Same hack as 8xx
  160. */
  161. static unsigned long __init
  162. m8260_find_end_of_memory(void)
  163. {
  164. bd_t *binfo = (bd_t *)__res;
  165. return binfo->bi_memsize;
  166. }
  167. /* Map the IMMR, plus anything else we can cover
  168. * in that upper space according to the memory controller
  169. * chip select mapping. Grab another bunch of space
  170. * below that for stuff we can't cover in the upper.
  171. */
  172. static void __init
  173. m8260_map_io(void)
  174. {
  175. uint addr;
  176. /* Map IMMR region to a 256MB BAT */
  177. addr = (cpm2_immr != NULL) ? (uint)cpm2_immr : CPM_MAP_ADDR;
  178. io_block_mapping(addr, addr, 0x10000000, _PAGE_IO);
  179. /* Map I/O region to a 256MB BAT */
  180. io_block_mapping(IO_VIRT_ADDR, IO_PHYS_ADDR, 0x10000000, _PAGE_IO);
  181. }
  182. /* Place-holder for board-specific ppc_md hooking */
  183. void __attribute__ ((weak)) __init
  184. m82xx_board_init(void)
  185. {
  186. }
  187. /* Inputs:
  188. * r3 - Optional pointer to a board information structure.
  189. * r4 - Optional pointer to the physical starting address of the init RAM
  190. * disk.
  191. * r5 - Optional pointer to the physical ending address of the init RAM
  192. * disk.
  193. * r6 - Optional pointer to the physical starting address of any kernel
  194. * command-line parameters.
  195. * r7 - Optional pointer to the physical ending address of any kernel
  196. * command-line parameters.
  197. */
  198. void __init
  199. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  200. unsigned long r6, unsigned long r7)
  201. {
  202. parse_bootinfo(find_bootinfo());
  203. if ( r3 )
  204. memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
  205. #ifdef CONFIG_BLK_DEV_INITRD
  206. /* take care of initrd if we have one */
  207. if ( r4 ) {
  208. initrd_start = r4 + KERNELBASE;
  209. initrd_end = r5 + KERNELBASE;
  210. }
  211. #endif /* CONFIG_BLK_DEV_INITRD */
  212. /* take care of cmd line */
  213. if ( r6 ) {
  214. *(char *)(r7+KERNELBASE) = 0;
  215. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  216. }
  217. ppc_md.setup_arch = m8260_setup_arch;
  218. ppc_md.show_cpuinfo = m8260_show_cpuinfo;
  219. ppc_md.init_IRQ = m8260_init_IRQ;
  220. ppc_md.get_irq = cpm2_get_irq;
  221. ppc_md.restart = m8260_restart;
  222. ppc_md.power_off = m8260_power_off;
  223. ppc_md.halt = m8260_halt;
  224. ppc_md.set_rtc_time = m8260_set_rtc_time;
  225. ppc_md.get_rtc_time = m8260_get_rtc_time;
  226. ppc_md.calibrate_decr = m8260_calibrate_decr;
  227. ppc_md.find_end_of_memory = m8260_find_end_of_memory;
  228. ppc_md.setup_io_mappings = m8260_map_io;
  229. /* Call back for board-specific settings and overrides. */
  230. m82xx_board_init();
  231. }