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