msp_setup.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * The generic setup file for PMC-Sierra MSP processors
  3. *
  4. * Copyright 2005-2007 PMC-Sierra, Inc,
  5. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <asm/bootinfo.h>
  13. #include <asm/cacheflush.h>
  14. #include <asm/r4kcache.h>
  15. #include <asm/reboot.h>
  16. #include <asm/time.h>
  17. #include <msp_prom.h>
  18. #include <msp_regs.h>
  19. #if defined(CONFIG_PMC_MSP7120_GW)
  20. #include <msp_regops.h>
  21. #include <msp_gpio.h>
  22. #define MSP_BOARD_RESET_GPIO 9
  23. #endif
  24. extern void msp_timer_init(void);
  25. extern void msp_serial_setup(void);
  26. extern void pmctwiled_setup(void);
  27. #if defined(CONFIG_PMC_MSP7120_EVAL) || \
  28. defined(CONFIG_PMC_MSP7120_GW) || \
  29. defined(CONFIG_PMC_MSP7120_FPGA)
  30. /*
  31. * Performs the reset for MSP7120-based boards
  32. */
  33. void msp7120_reset(void)
  34. {
  35. void *start, *end, *iptr;
  36. register int i;
  37. /* Diasble all interrupts */
  38. local_irq_disable();
  39. #ifdef CONFIG_SYS_SUPPORTS_MULTITHREADING
  40. dvpe();
  41. #endif
  42. /* Cache the reset code of this function */
  43. __asm__ __volatile__ (
  44. " .set push \n"
  45. " .set mips3 \n"
  46. " la %0,startpoint \n"
  47. " la %1,endpoint \n"
  48. " .set pop \n"
  49. : "=r" (start), "=r" (end)
  50. :
  51. );
  52. for (iptr = (void *)((unsigned int)start & ~(L1_CACHE_BYTES - 1));
  53. iptr < end; iptr += L1_CACHE_BYTES)
  54. cache_op(Fill, iptr);
  55. __asm__ __volatile__ (
  56. "startpoint: \n"
  57. );
  58. /* Put the DDRC into self-refresh mode */
  59. DDRC_INDIRECT_WRITE(DDRC_CTL(10), 0xb, 1 << 16);
  60. /*
  61. * IMPORTANT!
  62. * DO NOT do anything from here on out that might even
  63. * think about fetching from RAM - i.e., don't call any
  64. * non-inlined functions, and be VERY sure that any inline
  65. * functions you do call do NOT access any sort of RAM
  66. * anywhere!
  67. */
  68. /* Wait a bit for the DDRC to settle */
  69. for (i = 0; i < 100000000; i++);
  70. #if defined(CONFIG_PMC_MSP7120_GW)
  71. /*
  72. * Set GPIO 9 HI, (tied to board reset logic)
  73. * GPIO 9 is the 4th GPIO of register 3
  74. *
  75. * NOTE: We cannot use the higher-level msp_gpio_mode()/out()
  76. * as GPIO char driver may not be enabled and it would look up
  77. * data inRAM!
  78. */
  79. set_value_reg32(GPIO_CFG3_REG,
  80. basic_mode_mask(MSP_BOARD_RESET_GPIO),
  81. basic_mode(MSP_GPIO_OUTPUT, MSP_BOARD_RESET_GPIO));
  82. set_reg32(GPIO_DATA3_REG,
  83. basic_data_mask(MSP_BOARD_RESET_GPIO));
  84. /*
  85. * In case GPIO9 doesn't reset the board (jumper configurable!)
  86. * fallback to device reset below.
  87. */
  88. #endif
  89. /* Set bit 1 of the MSP7120 reset register */
  90. *RST_SET_REG = 0x00000001;
  91. __asm__ __volatile__ (
  92. "endpoint: \n"
  93. );
  94. }
  95. #endif
  96. void msp_restart(char *command)
  97. {
  98. printk(KERN_WARNING "Now rebooting .......\n");
  99. #if defined(CONFIG_PMC_MSP7120_EVAL) || \
  100. defined(CONFIG_PMC_MSP7120_GW) || \
  101. defined(CONFIG_PMC_MSP7120_FPGA)
  102. msp7120_reset();
  103. #else
  104. /* No chip-specific reset code, just jump to the ROM reset vector */
  105. set_c0_status(ST0_BEV | ST0_ERL);
  106. change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
  107. flush_cache_all();
  108. write_c0_wired(0);
  109. __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
  110. #endif
  111. }
  112. void msp_halt(void)
  113. {
  114. printk(KERN_WARNING "\n** You can safely turn off the power\n");
  115. while (1)
  116. /* If possible call official function to get CPU WARs */
  117. if (cpu_wait)
  118. (*cpu_wait)();
  119. else
  120. __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
  121. }
  122. void msp_power_off(void)
  123. {
  124. msp_halt();
  125. }
  126. void __init plat_mem_setup(void)
  127. {
  128. _machine_restart = msp_restart;
  129. _machine_halt = msp_halt;
  130. pm_power_off = msp_power_off;
  131. board_time_init = msp_timer_init;
  132. }
  133. void __init prom_init(void)
  134. {
  135. unsigned long family;
  136. unsigned long revision;
  137. prom_argc = fw_arg0;
  138. prom_argv = (char **)fw_arg1;
  139. prom_envp = (char **)fw_arg2;
  140. /*
  141. * Someday we can use this with PMON2000 to get a
  142. * platform call prom routines for output etc. without
  143. * having to use grody hacks. For now it's unused.
  144. *
  145. * struct callvectors *cv = (struct callvectors *) fw_arg3;
  146. */
  147. family = identify_family();
  148. revision = identify_revision();
  149. switch (family) {
  150. case FAMILY_FPGA:
  151. if (FPGA_IS_MSP4200(revision)) {
  152. /* Old-style revision ID */
  153. mips_machgroup = MACH_GROUP_MSP;
  154. mips_machtype = MACH_MSP4200_FPGA;
  155. } else {
  156. mips_machgroup = MACH_GROUP_MSP;
  157. mips_machtype = MACH_MSP_OTHER;
  158. }
  159. break;
  160. case FAMILY_MSP4200:
  161. mips_machgroup = MACH_GROUP_MSP;
  162. #if defined(CONFIG_PMC_MSP4200_EVAL)
  163. mips_machtype = MACH_MSP4200_EVAL;
  164. #elif defined(CONFIG_PMC_MSP4200_GW)
  165. mips_machtype = MACH_MSP4200_GW;
  166. #else
  167. mips_machtype = MACH_MSP_OTHER;
  168. #endif
  169. break;
  170. case FAMILY_MSP4200_FPGA:
  171. mips_machgroup = MACH_GROUP_MSP;
  172. mips_machtype = MACH_MSP4200_FPGA;
  173. break;
  174. case FAMILY_MSP7100:
  175. mips_machgroup = MACH_GROUP_MSP;
  176. #if defined(CONFIG_PMC_MSP7120_EVAL)
  177. mips_machtype = MACH_MSP7120_EVAL;
  178. #elif defined(CONFIG_PMC_MSP7120_GW)
  179. mips_machtype = MACH_MSP7120_GW;
  180. #else
  181. mips_machtype = MACH_MSP_OTHER;
  182. #endif
  183. break;
  184. case FAMILY_MSP7100_FPGA:
  185. mips_machgroup = MACH_GROUP_MSP;
  186. mips_machtype = MACH_MSP7120_FPGA;
  187. break;
  188. default:
  189. /* we don't recognize the machine */
  190. mips_machgroup = MACH_GROUP_UNKNOWN;
  191. mips_machtype = MACH_UNKNOWN;
  192. break;
  193. }
  194. /* make sure we have the right initialization routine - sanity */
  195. if (mips_machgroup != MACH_GROUP_MSP) {
  196. ppfinit("Unknown machine group in a "
  197. "MSP initialization routine\n");
  198. panic("***Bogosity factor five***, exiting\n");
  199. }
  200. prom_init_cmdline();
  201. prom_meminit();
  202. /*
  203. * Sub-system setup follows.
  204. * Setup functions can either be called here or using the
  205. * subsys_initcall mechanism (i.e. see msp_pci_setup). The
  206. * order in which they are called can be changed by using the
  207. * link order in arch/mips/pmc-sierra/msp71xx/Makefile.
  208. *
  209. * NOTE: Please keep sub-system specific initialization code
  210. * in separate specific files.
  211. */
  212. msp_serial_setup();
  213. #ifdef CONFIG_PMCTWILED
  214. /*
  215. * Setup LED states before the subsys_initcall loads other
  216. * dependant drivers/modules.
  217. */
  218. pmctwiled_setup();
  219. #endif
  220. }