setup.c 5.7 KB

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