oak.c 4.8 KB

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