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