msp_setup.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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/idle.h>
  15. #include <asm/r4kcache.h>
  16. #include <asm/reboot.h>
  17. #include <asm/smp-ops.h>
  18. #include <asm/time.h>
  19. #include <msp_prom.h>
  20. #include <msp_regs.h>
  21. #if defined(CONFIG_PMC_MSP7120_GW)
  22. #include <msp_regops.h>
  23. #define MSP_BOARD_RESET_GPIO 9
  24. #endif
  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, 0xf000, 0x8000);
  80. set_reg32(GPIO_DATA3_REG, 8);
  81. /*
  82. * In case GPIO9 doesn't reset the board (jumper configurable!)
  83. * fallback to device reset below.
  84. */
  85. #endif
  86. /* Set bit 1 of the MSP7120 reset register */
  87. *RST_SET_REG = 0x00000001;
  88. __asm__ __volatile__ (
  89. "endpoint: \n"
  90. );
  91. }
  92. #endif
  93. void msp_restart(char *command)
  94. {
  95. printk(KERN_WARNING "Now rebooting .......\n");
  96. #if defined(CONFIG_PMC_MSP7120_EVAL) || \
  97. defined(CONFIG_PMC_MSP7120_GW) || \
  98. defined(CONFIG_PMC_MSP7120_FPGA)
  99. msp7120_reset();
  100. #else
  101. /* No chip-specific reset code, just jump to the ROM reset vector */
  102. set_c0_status(ST0_BEV | ST0_ERL);
  103. change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
  104. flush_cache_all();
  105. write_c0_wired(0);
  106. __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
  107. #endif
  108. }
  109. void msp_halt(void)
  110. {
  111. printk(KERN_WARNING "\n** You can safely turn off the power\n");
  112. while (1)
  113. /* If possible call official function to get CPU WARs */
  114. if (cpu_wait)
  115. (*cpu_wait)();
  116. else
  117. __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
  118. }
  119. void msp_power_off(void)
  120. {
  121. msp_halt();
  122. }
  123. void __init plat_mem_setup(void)
  124. {
  125. _machine_restart = msp_restart;
  126. _machine_halt = msp_halt;
  127. pm_power_off = msp_power_off;
  128. }
  129. extern struct plat_smp_ops msp_smtc_smp_ops;
  130. void __init prom_init(void)
  131. {
  132. unsigned long family;
  133. unsigned long revision;
  134. prom_argc = fw_arg0;
  135. prom_argv = (char **)fw_arg1;
  136. prom_envp = (char **)fw_arg2;
  137. /*
  138. * Someday we can use this with PMON2000 to get a
  139. * platform call prom routines for output etc. without
  140. * having to use grody hacks. For now it's unused.
  141. *
  142. * struct callvectors *cv = (struct callvectors *) fw_arg3;
  143. */
  144. family = identify_family();
  145. revision = identify_revision();
  146. switch (family) {
  147. case FAMILY_FPGA:
  148. if (FPGA_IS_MSP4200(revision)) {
  149. /* Old-style revision ID */
  150. mips_machtype = MACH_MSP4200_FPGA;
  151. } else {
  152. mips_machtype = MACH_MSP_OTHER;
  153. }
  154. break;
  155. case FAMILY_MSP4200:
  156. #if defined(CONFIG_PMC_MSP4200_EVAL)
  157. mips_machtype = MACH_MSP4200_EVAL;
  158. #elif defined(CONFIG_PMC_MSP4200_GW)
  159. mips_machtype = MACH_MSP4200_GW;
  160. #else
  161. mips_machtype = MACH_MSP_OTHER;
  162. #endif
  163. break;
  164. case FAMILY_MSP4200_FPGA:
  165. mips_machtype = MACH_MSP4200_FPGA;
  166. break;
  167. case FAMILY_MSP7100:
  168. #if defined(CONFIG_PMC_MSP7120_EVAL)
  169. mips_machtype = MACH_MSP7120_EVAL;
  170. #elif defined(CONFIG_PMC_MSP7120_GW)
  171. mips_machtype = MACH_MSP7120_GW;
  172. #else
  173. mips_machtype = MACH_MSP_OTHER;
  174. #endif
  175. break;
  176. case FAMILY_MSP7100_FPGA:
  177. mips_machtype = MACH_MSP7120_FPGA;
  178. break;
  179. default:
  180. /* we don't recognize the machine */
  181. mips_machtype = MACH_UNKNOWN;
  182. panic("***Bogosity factor five***, exiting");
  183. break;
  184. }
  185. prom_init_cmdline();
  186. prom_meminit();
  187. /*
  188. * Sub-system setup follows.
  189. * Setup functions can either be called here or using the
  190. * subsys_initcall mechanism (i.e. see msp_pci_setup). The
  191. * order in which they are called can be changed by using the
  192. * link order in arch/mips/pmc-sierra/msp71xx/Makefile.
  193. *
  194. * NOTE: Please keep sub-system specific initialization code
  195. * in separate specific files.
  196. */
  197. msp_serial_setup();
  198. if (register_vsmp_smp_ops()) {
  199. #ifdef CONFIG_MIPS_MT_SMTC
  200. register_smp_ops(&msp_smtc_smp_ops);
  201. #endif
  202. }
  203. #ifdef CONFIG_PMCTWILED
  204. /*
  205. * Setup LED states before the subsys_initcall loads other
  206. * dependent drivers/modules.
  207. */
  208. pmctwiled_setup();
  209. #endif
  210. }