m8260_setup.c 6.2 KB

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