setup.c 5.5 KB

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