m8260_setup.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:6k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * BK Id: SCCS/s.m8260_setup.c 1.30 11/13/01 21:26:07 paulus
  3.  */
  4. /*
  5.  *  linux/arch/ppc/kernel/setup.c
  6.  *
  7.  *  Copyright (C) 1995  Linus Torvalds
  8.  *  Adapted from 'alpha' version by Gary Thomas
  9.  *  Modified by Cort Dougan (cort@cs.nmt.edu)
  10.  *  Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
  11.  *  Further modified for generic 8xx and 8260 by Dan.
  12.  */
  13. /*
  14.  * bootup setup stuff..
  15.  */
  16. #include <linux/config.h>
  17. #include <linux/errno.h>
  18. #include <linux/sched.h>
  19. #include <linux/kernel.h>
  20. #include <linux/mm.h>
  21. #include <linux/stddef.h>
  22. #include <linux/unistd.h>
  23. #include <linux/ptrace.h>
  24. #include <linux/slab.h>
  25. #include <linux/user.h>
  26. #include <linux/a.out.h>
  27. #include <linux/tty.h>
  28. #include <linux/major.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/reboot.h>
  31. #include <linux/init.h>
  32. #include <linux/blk.h>
  33. #include <linux/ioport.h>
  34. #include <linux/ide.h>
  35. #include <linux/seq_file.h>
  36. #include <asm/mmu.h>
  37. #include <asm/processor.h>
  38. #include <asm/residual.h>
  39. #include <asm/io.h>
  40. #include <asm/pgtable.h>
  41. #include <asm/ide.h>
  42. #include <asm/mpc8260.h>
  43. #include <asm/immap_8260.h>
  44. #include <asm/machdep.h>
  45. #include <asm/time.h>
  46. #include "ppc8260_pic.h"
  47. static int m8260_set_rtc_time(unsigned long time);
  48. static unsigned long m8260_get_rtc_time(void);
  49. static void m8260_calibrate_decr(void);
  50. unsigned char __res[sizeof(bd_t)];
  51. extern void m8260_cpm_reset(void);
  52. static void __init
  53. m8260_setup_arch(void)
  54. {
  55. /* Reset the Communication Processor Module.
  56. */
  57. m8260_cpm_reset();
  58. }
  59. static void
  60. abort(void)
  61. {
  62. #ifdef CONFIG_XMON
  63. extern void xmon(void *);
  64. xmon(0);
  65. #endif
  66. machine_restart(NULL);
  67. }
  68. /* The decrementer counts at the system (internal) clock frequency
  69.  * divided by four.
  70.  */
  71. static void __init
  72. m8260_calibrate_decr(void)
  73. {
  74. bd_t *binfo = (bd_t *)__res;
  75. int freq, divisor;
  76. freq = binfo->bi_busfreq;
  77.         divisor = 4;
  78.         tb_ticks_per_jiffy = freq / HZ / divisor;
  79. tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
  80. }
  81. /* The 8260 has an internal 1-second timer update register that
  82.  * we should use for this purpose.
  83.  */
  84. static uint rtc_time;
  85. static static int
  86. m8260_set_rtc_time(unsigned long time)
  87. {
  88. rtc_time = time;
  89. return(0);
  90. }
  91. static unsigned long
  92. m8260_get_rtc_time(void)
  93. {
  94. /* Get time from the RTC.
  95. */
  96. return((unsigned long)rtc_time);
  97. }
  98. static void
  99. m8260_restart(char *cmd)
  100. {
  101. extern void m8260_gorom(bd_t *bi, uint addr);
  102. uint startaddr;
  103. /* Most boot roms have a warmstart as the second instruction
  104.  * of the reset vector.  If that doesn't work for you, change this
  105.  * or the reboot program to send a proper address.
  106.  */
  107. startaddr = 0xff000104;
  108. if (cmd != NULL) {
  109. if (!strncmp(cmd, "startaddr=", 10))
  110. startaddr = simple_strtoul(&cmd[10], NULL, 0);
  111. }
  112. m8260_gorom((unsigned int)__pa(__res), startaddr);
  113. }
  114. static void
  115. m8260_power_off(void)
  116. {
  117.    m8260_restart(NULL);
  118. }
  119. static void
  120. m8260_halt(void)
  121. {
  122.    m8260_restart(NULL);
  123. }
  124. static int
  125. m8260_show_percpuinfo(struct seq_file *m, int i)
  126. {
  127. bd_t *bp;
  128. bp = (bd_t *)__res;
  129. seq_printf(m, "core clockt: %d MHzn"
  130.    "CPM  clockt: %d MHzn"
  131.    "bus  clockt: %d MHzn",
  132.    bp->bi_intfreq / 1000000,
  133.    bp->bi_cpmfreq / 1000000,
  134.    bp->bi_busfreq / 1000000);
  135. return 0;
  136. }
  137. /* Initialize the internal interrupt controller.  The number of
  138.  * interrupts supported can vary with the processor type, and the
  139.  * 8260 family can have up to 64.
  140.  * External interrupts can be either edge or level triggered, and
  141.  * need to be initialized by the appropriate driver.
  142.  */
  143. static void __init
  144. m8260_init_IRQ(void)
  145. {
  146. int i;
  147. void cpm_interrupt_init(void);
  148. #if 0
  149.         ppc8260_pic.irq_offset = 0;
  150. #endif
  151.         for ( i = 0 ; i < NR_SIU_INTS ; i++ )
  152.                 irq_desc[i].handler = &ppc8260_pic;
  153. /* Initialize the default interrupt mapping priorities,
  154.  * in case the boot rom changed something on us.
  155.  */
  156. immr->im_intctl.ic_sicr = 0;
  157. immr->im_intctl.ic_siprr = 0x05309770;
  158. immr->im_intctl.ic_scprrh = 0x05309770;
  159. immr->im_intctl.ic_scprrl = 0x05309770;
  160. }
  161. /*
  162.  * Same hack as 8xx
  163.  */
  164. static unsigned long __init
  165. m8260_find_end_of_memory(void)
  166. {
  167. bd_t *binfo;
  168. extern unsigned char __res[];
  169. binfo = (bd_t *)__res;
  170. return binfo->bi_memsize;
  171. }
  172. /* Map the IMMR, plus anything else we can cover
  173.  * in that upper space according to the memory controller
  174.  * chip select mapping.  Grab another bunch of space
  175.  * below that for stuff we can't cover in the upper.
  176.  */
  177. static void __init
  178. m8260_map_io(void)
  179. {
  180. io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
  181. io_block_mapping(0xe0000000, 0xe0000000, 0x10000000, _PAGE_IO);
  182. }
  183. void __init
  184. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  185.       unsigned long r6, unsigned long r7)
  186. {
  187. if ( r3 )
  188. memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
  189. #ifdef CONFIG_BLK_DEV_INITRD
  190. /* take care of initrd if we have one */
  191. if ( r4 )
  192. {
  193. initrd_start = r4 + KERNELBASE;
  194. initrd_end = r5 + KERNELBASE;
  195. }
  196. #endif /* CONFIG_BLK_DEV_INITRD */
  197. /* take care of cmd line */
  198. if ( r6 )
  199. {
  200. *(char *)(r7+KERNELBASE) = 0;
  201. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  202. }
  203. ppc_md.setup_arch = m8260_setup_arch;
  204. ppc_md.show_percpuinfo = m8260_show_percpuinfo;
  205. ppc_md.irq_cannonicalize = NULL;
  206. ppc_md.init_IRQ = m8260_init_IRQ;
  207. ppc_md.get_irq = m8260_get_irq;
  208. ppc_md.init = NULL;
  209. ppc_md.restart = m8260_restart;
  210. ppc_md.power_off = m8260_power_off;
  211. ppc_md.halt = m8260_halt;
  212. ppc_md.time_init = NULL;
  213. ppc_md.set_rtc_time = m8260_set_rtc_time;
  214. ppc_md.get_rtc_time = m8260_get_rtc_time;
  215. ppc_md.calibrate_decr = m8260_calibrate_decr;
  216. ppc_md.find_end_of_memory = m8260_find_end_of_memory;
  217. ppc_md.setup_io_mappings = m8260_map_io;
  218. ppc_md.kbd_setkeycode = NULL;
  219. ppc_md.kbd_getkeycode = NULL;
  220. ppc_md.kbd_translate = NULL;
  221. ppc_md.kbd_unexpected_up = NULL;
  222. ppc_md.kbd_leds = NULL;
  223. ppc_md.kbd_init_hw = NULL;
  224. ppc_md.ppc_kbd_sysrq_xlate = NULL;
  225. }
  226. /* Mainly for ksyms.
  227. */
  228. int
  229. request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
  230.        unsigned long flag, const char *naem, void *dev)
  231. {
  232. panic("request IRQn");
  233. }