oak_setup.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * BK Id: %F% %I% %G% %U% %#%
  3.  */
  4. /*
  5.  *
  6.  *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
  7.  *
  8.  *    Module name: oak_setup.c
  9.  *
  10.  *    Description:
  11.  *      Architecture- / platform-specific boot-time initialization code for
  12.  *      the IBM PowerPC 403GCX "Oak" evaluation board. Adapted from original
  13.  *      code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
  14.  *      <dan@net4x.com>.
  15.  *
  16.  */
  17. #include <linux/config.h>
  18. #include <linux/init.h>
  19. #include <linux/smp.h>
  20. #include <linux/threads.h>
  21. #include <linux/param.h>
  22. #include <linux/string.h>
  23. #include <linux/blk.h>
  24. #include <linux/irq.h>
  25. #include <linux/seq_file.h>
  26. #include <asm/processor.h>
  27. #include <asm/board.h>
  28. #include <asm/machdep.h>
  29. #include <asm/page.h>
  30. #include <asm/bootinfo.h>
  31. #include <asm/ppc4xx_pic.h>
  32. #include <asm/time.h>
  33. #include "oak_setup.h"
  34. /* Function Prototypes */
  35. extern void abort(void);
  36. /* Global Variables */
  37. unsigned char __res[sizeof(bd_t)];
  38. /*
  39.  * void __init oak_init()
  40.  *
  41.  * Description:
  42.  *   This routine...
  43.  *
  44.  * Input(s):
  45.  *   r3 - Optional pointer to a board information structure.
  46.  *   r4 - Optional pointer to the physical starting address of the init RAM
  47.  *        disk.
  48.  *   r5 - Optional pointer to the physical ending address of the init RAM
  49.  *        disk.
  50.  *   r6 - Optional pointer to the physical starting address of any kernel
  51.  *        command-line parameters.
  52.  *   r7 - Optional pointer to the physical ending address of any kernel
  53.  *        command-line parameters.
  54.  *
  55.  * Output(s):
  56.  *   N/A
  57.  *
  58.  * Returns:
  59.  *   N/A
  60.  *
  61.  */
  62. void __init
  63. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  64.       unsigned long r6, unsigned long r7)
  65. {
  66. parse_bootinfo(find_bootinfo());
  67. /*
  68.  * If we were passed in a board information, copy it into the
  69.  * residual data area.
  70.  */
  71. if (r3) {
  72. memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t));
  73. }
  74. #if defined(CONFIG_BLK_DEV_INITRD)
  75. /*
  76.  * If the init RAM disk has been configured in, and there's a valid
  77.  * starting address for it, set it up.
  78.  */
  79. if (r4) {
  80. initrd_start = r4 + KERNELBASE;
  81. initrd_end = r5 + KERNELBASE;
  82. }
  83. #endif /* CONFIG_BLK_DEV_INITRD */
  84. /* Copy the kernel command line arguments to a safe place. */
  85. if (r6) {
  86.   *(char *)(r7 + KERNELBASE) = 0;
  87. strcpy(cmd_line, (char *)(r6 + KERNELBASE));
  88. }
  89. /* Initialize machine-dependency vectors */
  90. ppc_md.setup_arch   = oak_setup_arch;
  91. ppc_md.show_percpuinfo   = oak_show_percpuinfo;
  92. ppc_md.irq_cannonicalize  = NULL;
  93. ppc_md.init_IRQ   = oak_init_IRQ;
  94. ppc_md.get_irq   = oak_get_irq;
  95. ppc_md.init   = NULL;
  96. ppc_md.restart   = oak_restart;
  97. ppc_md.power_off   = oak_power_off;
  98. ppc_md.halt   = oak_halt;
  99. ppc_md.time_init   = oak_time_init;
  100. ppc_md.set_rtc_time   = oak_set_rtc_time;
  101. ppc_md.get_rtc_time   = oak_get_rtc_time;
  102. ppc_md.calibrate_decr   = oak_calibrate_decr;
  103. ppc_md.kbd_setkeycode     = NULL;
  104. ppc_md.kbd_getkeycode     = NULL;
  105. ppc_md.kbd_translate      = NULL;
  106. ppc_md.kbd_unexpected_up  = NULL;
  107. ppc_md.kbd_leds           = NULL;
  108. ppc_md.kbd_init_hw        = NULL;
  109. ppc_md.ppc_kbd_sysrq_xlate = NULL;
  110. }
  111. /*
  112.  * Document me.
  113.  */
  114. void __init
  115. oak_setup_arch(void)
  116. {
  117. /* XXX - Implement me */
  118. }
  119. /*
  120.  * int oak_show_percpuinfo()
  121.  *
  122.  * Description:
  123.  *   This routine pretty-prints the platform's internal CPU and bus clock
  124.  *   frequencies into the buffer for usage in /proc/cpuinfo.
  125.  *
  126.  * Input(s):
  127.  *  *buffer - Buffer into which CPU and bus clock frequencies are to be
  128.  *            printed.
  129.  *
  130.  * Output(s):
  131.  *  *buffer - Buffer with the CPU and bus clock frequencies.
  132.  *
  133.  * Returns:
  134.  *   The number of bytes copied into 'buffer' if OK, otherwise zero or less
  135.  *   on error.
  136.  */
  137. int
  138. oak_show_percpuinfo(struct seq_file *m, int i)
  139. {
  140. bd_t *bp = (bd_t *)__res;
  141. seq_printf(m, "clocktt: %dMHzn"
  142.    "bus clocktt: %dMHzn",
  143.    bp->bi_intfreq / 1000000,
  144.    bp->bi_busfreq / 1000000);
  145. return 0;
  146. }
  147. /*
  148.  * Document me.
  149.  */
  150. void __init
  151. oak_init_IRQ(void)
  152. {
  153. int i;
  154. ppc4xx_pic_init();
  155. for (i = 0; i < NR_IRQS; i++) {
  156. irq_desc[i].handler = ppc4xx_pic;
  157. }
  158. return;
  159. }
  160. /*
  161.  * Document me.
  162.  */
  163. int
  164. oak_get_irq(struct pt_regs *regs)
  165. {
  166. return (ppc4xx_pic_get_irq(regs));
  167. }
  168. /*
  169.  * Document me.
  170.  */
  171. void
  172. oak_restart(char *cmd)
  173. {
  174. abort();
  175. }
  176. /*
  177.  * Document me.
  178.  */
  179. void
  180. oak_power_off(void)
  181. {
  182. oak_restart(NULL);
  183. }
  184. /*
  185.  * Document me.
  186.  */
  187. void
  188. oak_halt(void)
  189. {
  190. oak_restart(NULL);
  191. }
  192. /*
  193.  * Document me.
  194.  */
  195. long __init
  196. oak_time_init(void)
  197. {
  198. /* XXX - Implement me */
  199. return 0;
  200. }
  201. /*
  202.  * Document me.
  203.  */
  204. int __init
  205. oak_set_rtc_time(unsigned long time)
  206. {
  207. /* XXX - Implement me */
  208. return (0);
  209. }
  210. /*
  211.  * Document me.
  212.  */
  213. unsigned long __init
  214. oak_get_rtc_time(void)
  215. {
  216. /* XXX - Implement me */
  217. return (0);
  218. }
  219. /*
  220.  * void __init oak_calibrate_decr()
  221.  *
  222.  * Description:
  223.  *   This routine retrieves the internal processor frequency from the board
  224.  *   information structure, sets up the kernel timer decrementer based on
  225.  *   that value, enables the 403 programmable interval timer (PIT) and sets
  226.  *   it up for auto-reload.
  227.  *
  228.  * Input(s):
  229.  *   N/A
  230.  *
  231.  * Output(s):
  232.  *   N/A
  233.  *
  234.  * Returns:
  235.  *   N/A
  236.  *
  237.  */
  238. void __init
  239. oak_calibrate_decr(void)
  240. {
  241. unsigned int freq;
  242. bd_t *bip = (bd_t *)__res;
  243. freq = bip->bi_intfreq;
  244. decrementer_count = freq / HZ;
  245. count_period_num = 1;
  246. count_period_den = freq;
  247. /* Enable the PIT and set auto-reload of its value */
  248. mtspr(SPRN_TCR, TCR_PIE | TCR_ARE);
  249. /* Clear any pending timer interrupts */
  250. mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_PIS | TSR_FIS);
  251. }