setup.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/reboot.h>
  22. #include <linux/string.h>
  23. #include <asm/bootinfo.h>
  24. #include <asm/cpu.h>
  25. #include <asm/mipsregs.h>
  26. #include <asm/io.h>
  27. #include <asm/sibyte/sb1250.h>
  28. #include <asm/sibyte/sb1250_regs.h>
  29. #include <asm/sibyte/sb1250_scd.h>
  30. unsigned int sb1_pass;
  31. unsigned int soc_pass;
  32. unsigned int soc_type;
  33. EXPORT_SYMBOL(soc_type);
  34. unsigned int periph_rev;
  35. unsigned int zbbus_mhz;
  36. EXPORT_SYMBOL(zbbus_mhz);
  37. static char *soc_str;
  38. static char *pass_str;
  39. static unsigned int war_pass; /* XXXKW don't overload PASS defines? */
  40. static int __init setup_bcm1250(void)
  41. {
  42. int ret = 0;
  43. switch (soc_pass) {
  44. case K_SYS_REVISION_BCM1250_PASS1:
  45. periph_rev = 1;
  46. pass_str = "Pass 1";
  47. break;
  48. case K_SYS_REVISION_BCM1250_A10:
  49. periph_rev = 2;
  50. pass_str = "A8/A10";
  51. /* XXXKW different war_pass? */
  52. war_pass = K_SYS_REVISION_BCM1250_PASS2;
  53. break;
  54. case K_SYS_REVISION_BCM1250_PASS2_2:
  55. periph_rev = 2;
  56. pass_str = "B1";
  57. break;
  58. case K_SYS_REVISION_BCM1250_B2:
  59. periph_rev = 2;
  60. pass_str = "B2";
  61. war_pass = K_SYS_REVISION_BCM1250_PASS2_2;
  62. break;
  63. case K_SYS_REVISION_BCM1250_PASS3:
  64. periph_rev = 3;
  65. pass_str = "C0";
  66. break;
  67. case K_SYS_REVISION_BCM1250_C1:
  68. periph_rev = 3;
  69. pass_str = "C1";
  70. break;
  71. default:
  72. if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) {
  73. periph_rev = 2;
  74. pass_str = "A0-A6";
  75. war_pass = K_SYS_REVISION_BCM1250_PASS2;
  76. } else {
  77. printk("Unknown BCM1250 rev %x\n", soc_pass);
  78. ret = 1;
  79. }
  80. break;
  81. }
  82. return ret;
  83. }
  84. int sb1250_m3_workaround_needed(void)
  85. {
  86. switch (soc_type) {
  87. case K_SYS_SOC_TYPE_BCM1250:
  88. case K_SYS_SOC_TYPE_BCM1250_ALT:
  89. case K_SYS_SOC_TYPE_BCM1250_ALT2:
  90. case K_SYS_SOC_TYPE_BCM1125:
  91. case K_SYS_SOC_TYPE_BCM1125H:
  92. return soc_pass < K_SYS_REVISION_BCM1250_C0;
  93. default:
  94. return 0;
  95. }
  96. }
  97. static int __init setup_bcm112x(void)
  98. {
  99. int ret = 0;
  100. switch (soc_pass) {
  101. case 0:
  102. /* Early build didn't have revid set */
  103. periph_rev = 3;
  104. pass_str = "A1";
  105. war_pass = K_SYS_REVISION_BCM112x_A1;
  106. break;
  107. case K_SYS_REVISION_BCM112x_A1:
  108. periph_rev = 3;
  109. pass_str = "A1";
  110. break;
  111. case K_SYS_REVISION_BCM112x_A2:
  112. periph_rev = 3;
  113. pass_str = "A2";
  114. break;
  115. case K_SYS_REVISION_BCM112x_A3:
  116. periph_rev = 3;
  117. pass_str = "A3";
  118. break;
  119. case K_SYS_REVISION_BCM112x_A4:
  120. periph_rev = 3;
  121. pass_str = "A4";
  122. break;
  123. case K_SYS_REVISION_BCM112x_B0:
  124. periph_rev = 3;
  125. pass_str = "B0";
  126. break;
  127. default:
  128. printk("Unknown %s rev %x\n", soc_str, soc_pass);
  129. ret = 1;
  130. }
  131. return ret;
  132. }
  133. /* Setup code likely to be common to all SiByte platforms */
  134. static int __init sys_rev_decode(void)
  135. {
  136. int ret = 0;
  137. war_pass = soc_pass;
  138. switch (soc_type) {
  139. case K_SYS_SOC_TYPE_BCM1250:
  140. case K_SYS_SOC_TYPE_BCM1250_ALT:
  141. case K_SYS_SOC_TYPE_BCM1250_ALT2:
  142. soc_str = "BCM1250";
  143. ret = setup_bcm1250();
  144. break;
  145. case K_SYS_SOC_TYPE_BCM1120:
  146. soc_str = "BCM1120";
  147. ret = setup_bcm112x();
  148. break;
  149. case K_SYS_SOC_TYPE_BCM1125:
  150. soc_str = "BCM1125";
  151. ret = setup_bcm112x();
  152. break;
  153. case K_SYS_SOC_TYPE_BCM1125H:
  154. soc_str = "BCM1125H";
  155. ret = setup_bcm112x();
  156. break;
  157. default:
  158. printk("Unknown SOC type %x\n", soc_type);
  159. ret = 1;
  160. break;
  161. }
  162. return ret;
  163. }
  164. void __init sb1250_setup(void)
  165. {
  166. uint64_t sys_rev;
  167. int plldiv;
  168. int bad_config = 0;
  169. sb1_pass = read_c0_prid() & PRID_REV_MASK;
  170. sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
  171. soc_type = SYS_SOC_TYPE(sys_rev);
  172. soc_pass = G_SYS_REVISION(sys_rev);
  173. if (sys_rev_decode()) {
  174. printk("Restart after failure to identify SiByte chip\n");
  175. machine_restart(NULL);
  176. }
  177. plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
  178. zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
  179. printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
  180. soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
  181. printk("Board type: %s\n", get_system_type());
  182. switch (war_pass) {
  183. case K_SYS_REVISION_BCM1250_PASS1:
  184. #ifndef CONFIG_SB1_PASS_1_WORKAROUNDS
  185. printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, "
  186. "and the kernel doesn't have the proper "
  187. "workarounds compiled in. @@@@\n");
  188. bad_config = 1;
  189. #endif
  190. break;
  191. case K_SYS_REVISION_BCM1250_PASS2:
  192. /* Pass 2 - easiest as default for now - so many numbers */
  193. #if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \
  194. !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
  195. printk("@@@@ This is a BCM1250 A3-A10 board, and the "
  196. "kernel doesn't have the proper workarounds "
  197. "compiled in. @@@@\n");
  198. bad_config = 1;
  199. #endif
  200. #ifdef CONFIG_CPU_HAS_PREFETCH
  201. printk("@@@@ Prefetches may be enabled in this kernel, "
  202. "but are buggy on this board. @@@@\n");
  203. bad_config = 1;
  204. #endif
  205. break;
  206. case K_SYS_REVISION_BCM1250_PASS2_2:
  207. #ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
  208. printk("@@@@ This is a BCM1250 B1/B2. board, and the "
  209. "kernel doesn't have the proper workarounds "
  210. "compiled in. @@@@\n");
  211. bad_config = 1;
  212. #endif
  213. #if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \
  214. !defined(CONFIG_CPU_HAS_PREFETCH)
  215. printk("@@@@ This is a BCM1250 B1/B2, but the kernel is "
  216. "conservatively configured for an 'A' stepping. "
  217. "@@@@\n");
  218. #endif
  219. break;
  220. default:
  221. break;
  222. }
  223. if (bad_config) {
  224. printk("Invalid configuration for this chip.\n");
  225. machine_restart(NULL);
  226. }
  227. }