setup.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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/mipsregs.h>
  25. #include <asm/io.h>
  26. #include <asm/sibyte/sb1250.h>
  27. #include <asm/sibyte/sb1250_regs.h>
  28. #include <asm/sibyte/sb1250_scd.h>
  29. unsigned int sb1_pass;
  30. unsigned int soc_pass;
  31. unsigned int soc_type;
  32. EXPORT_SYMBOL(soc_type);
  33. unsigned int periph_rev;
  34. unsigned int zbbus_mhz;
  35. EXPORT_SYMBOL(zbbus_mhz);
  36. static char *soc_str;
  37. static char *pass_str;
  38. static unsigned int war_pass; /* XXXKW don't overload PASS defines? */
  39. static inline int setup_bcm1250(void);
  40. static inline int setup_bcm112x(void);
  41. /* Setup code likely to be common to all SiByte platforms */
  42. static int __init sys_rev_decode(void)
  43. {
  44. int ret = 0;
  45. war_pass = soc_pass;
  46. switch (soc_type) {
  47. case K_SYS_SOC_TYPE_BCM1250:
  48. case K_SYS_SOC_TYPE_BCM1250_ALT:
  49. case K_SYS_SOC_TYPE_BCM1250_ALT2:
  50. soc_str = "BCM1250";
  51. ret = setup_bcm1250();
  52. break;
  53. case K_SYS_SOC_TYPE_BCM1120:
  54. soc_str = "BCM1120";
  55. ret = setup_bcm112x();
  56. break;
  57. case K_SYS_SOC_TYPE_BCM1125:
  58. soc_str = "BCM1125";
  59. ret = setup_bcm112x();
  60. break;
  61. case K_SYS_SOC_TYPE_BCM1125H:
  62. soc_str = "BCM1125H";
  63. ret = setup_bcm112x();
  64. break;
  65. default:
  66. printk("Unknown SOC type %x\n", soc_type);
  67. ret = 1;
  68. break;
  69. }
  70. return ret;
  71. }
  72. static int __init setup_bcm1250(void)
  73. {
  74. int ret = 0;
  75. switch (soc_pass) {
  76. case K_SYS_REVISION_BCM1250_PASS1:
  77. periph_rev = 1;
  78. pass_str = "Pass 1";
  79. break;
  80. case K_SYS_REVISION_BCM1250_A10:
  81. periph_rev = 2;
  82. pass_str = "A8/A10";
  83. /* XXXKW different war_pass? */
  84. war_pass = K_SYS_REVISION_BCM1250_PASS2;
  85. break;
  86. case K_SYS_REVISION_BCM1250_PASS2_2:
  87. periph_rev = 2;
  88. pass_str = "B1";
  89. break;
  90. case K_SYS_REVISION_BCM1250_B2:
  91. periph_rev = 2;
  92. pass_str = "B2";
  93. war_pass = K_SYS_REVISION_BCM1250_PASS2_2;
  94. break;
  95. case K_SYS_REVISION_BCM1250_PASS3:
  96. periph_rev = 3;
  97. pass_str = "C0";
  98. break;
  99. case K_SYS_REVISION_BCM1250_C1:
  100. periph_rev = 3;
  101. pass_str = "C1";
  102. break;
  103. default:
  104. if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) {
  105. periph_rev = 2;
  106. pass_str = "A0-A6";
  107. war_pass = K_SYS_REVISION_BCM1250_PASS2;
  108. } else {
  109. printk("Unknown BCM1250 rev %x\n", soc_pass);
  110. ret = 1;
  111. }
  112. break;
  113. }
  114. return ret;
  115. }
  116. static int __init setup_bcm112x(void)
  117. {
  118. int ret = 0;
  119. switch (soc_pass) {
  120. case 0:
  121. /* Early build didn't have revid set */
  122. periph_rev = 3;
  123. pass_str = "A1";
  124. war_pass = K_SYS_REVISION_BCM112x_A1;
  125. break;
  126. case K_SYS_REVISION_BCM112x_A1:
  127. periph_rev = 3;
  128. pass_str = "A1";
  129. break;
  130. case K_SYS_REVISION_BCM112x_A2:
  131. periph_rev = 3;
  132. pass_str = "A2";
  133. break;
  134. case K_SYS_REVISION_BCM112x_A3:
  135. periph_rev = 3;
  136. pass_str = "A3";
  137. break;
  138. case K_SYS_REVISION_BCM112x_A4:
  139. periph_rev = 3;
  140. pass_str = "A4";
  141. break;
  142. case K_SYS_REVISION_BCM112x_B0:
  143. periph_rev = 3;
  144. pass_str = "B0";
  145. break;
  146. default:
  147. printk("Unknown %s rev %x\n", soc_str, soc_pass);
  148. ret = 1;
  149. }
  150. return ret;
  151. }
  152. void __init sb1250_setup(void)
  153. {
  154. uint64_t sys_rev;
  155. int plldiv;
  156. int bad_config = 0;
  157. sb1_pass = read_c0_prid() & 0xff;
  158. sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
  159. soc_type = SYS_SOC_TYPE(sys_rev);
  160. soc_pass = G_SYS_REVISION(sys_rev);
  161. if (sys_rev_decode()) {
  162. printk("Restart after failure to identify SiByte chip\n");
  163. machine_restart(NULL);
  164. }
  165. plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
  166. zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
  167. printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
  168. soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
  169. printk("Board type: %s\n", get_system_type());
  170. switch (war_pass) {
  171. case K_SYS_REVISION_BCM1250_PASS1:
  172. #ifndef CONFIG_SB1_PASS_1_WORKAROUNDS
  173. printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, "
  174. "and the kernel doesn't have the proper "
  175. "workarounds compiled in. @@@@\n");
  176. bad_config = 1;
  177. #endif
  178. break;
  179. case K_SYS_REVISION_BCM1250_PASS2:
  180. /* Pass 2 - easiest as default for now - so many numbers */
  181. #if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \
  182. !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
  183. printk("@@@@ This is a BCM1250 A3-A10 board, and the "
  184. "kernel doesn't have the proper workarounds "
  185. "compiled in. @@@@\n");
  186. bad_config = 1;
  187. #endif
  188. #ifdef CONFIG_CPU_HAS_PREFETCH
  189. printk("@@@@ Prefetches may be enabled in this kernel, "
  190. "but are buggy on this board. @@@@\n");
  191. bad_config = 1;
  192. #endif
  193. break;
  194. case K_SYS_REVISION_BCM1250_PASS2_2:
  195. #ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
  196. printk("@@@@ This is a BCM1250 B1/B2. board, and the "
  197. "kernel doesn't have the proper workarounds "
  198. "compiled in. @@@@\n");
  199. bad_config = 1;
  200. #endif
  201. #if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \
  202. !defined(CONFIG_CPU_HAS_PREFETCH)
  203. printk("@@@@ This is a BCM1250 B1/B2, but the kernel is "
  204. "conservatively configured for an 'A' stepping. "
  205. "@@@@\n");
  206. #endif
  207. break;
  208. default:
  209. break;
  210. }
  211. if (bad_config) {
  212. printk("Invalid configuration for this chip.\n");
  213. machine_restart(NULL);
  214. }
  215. }