msp_setup.c 5.5 KB

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