setup.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2000,2001,2002,2003,2004 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/kernel.h>
  20. #include <linux/module.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/bcm1480_regs.h>
  28. #include <asm/sibyte/bcm1480_scd.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 unsigned int part_type;
  38. static char *soc_str;
  39. static char *pass_str;
  40. static inline int setup_bcm1x80_bcm1x55(void);
  41. /* Setup code likely to be common to all SiByte platforms */
  42. static inline int sys_rev_decode(void)
  43. {
  44. int ret = 0;
  45. switch (soc_type) {
  46. case K_SYS_SOC_TYPE_BCM1x80:
  47. if (part_type == K_SYS_PART_BCM1480)
  48. soc_str = "BCM1480";
  49. else if (part_type == K_SYS_PART_BCM1280)
  50. soc_str = "BCM1280";
  51. else
  52. soc_str = "BCM1x80";
  53. ret = setup_bcm1x80_bcm1x55();
  54. break;
  55. case K_SYS_SOC_TYPE_BCM1x55:
  56. if (part_type == K_SYS_PART_BCM1455)
  57. soc_str = "BCM1455";
  58. else if (part_type == K_SYS_PART_BCM1255)
  59. soc_str = "BCM1255";
  60. else
  61. soc_str = "BCM1x55";
  62. ret = setup_bcm1x80_bcm1x55();
  63. break;
  64. default:
  65. printk("Unknown part type %x\n", part_type);
  66. ret = 1;
  67. break;
  68. }
  69. return ret;
  70. }
  71. static inline int setup_bcm1x80_bcm1x55(void)
  72. {
  73. int ret = 0;
  74. switch (soc_pass) {
  75. case K_SYS_REVISION_BCM1480_S0:
  76. periph_rev = 1;
  77. pass_str = "S0 (pass1)";
  78. break;
  79. case K_SYS_REVISION_BCM1480_A1:
  80. periph_rev = 1;
  81. pass_str = "A1 (pass1)";
  82. break;
  83. case K_SYS_REVISION_BCM1480_A2:
  84. periph_rev = 1;
  85. pass_str = "A2 (pass1)";
  86. break;
  87. case K_SYS_REVISION_BCM1480_A3:
  88. periph_rev = 1;
  89. pass_str = "A3 (pass1)";
  90. break;
  91. case K_SYS_REVISION_BCM1480_B0:
  92. periph_rev = 1;
  93. pass_str = "B0 (pass2)";
  94. break;
  95. default:
  96. printk("Unknown %s rev %x\n", soc_str, soc_pass);
  97. periph_rev = 1;
  98. pass_str = "Unknown Revision";
  99. break;
  100. }
  101. return ret;
  102. }
  103. void bcm1480_setup(void)
  104. {
  105. uint64_t sys_rev;
  106. int plldiv;
  107. sb1_pass = read_c0_prid() & 0xff;
  108. sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
  109. soc_type = SYS_SOC_TYPE(sys_rev);
  110. part_type = G_SYS_PART(sys_rev);
  111. soc_pass = G_SYS_REVISION(sys_rev);
  112. if (sys_rev_decode()) {
  113. printk("Restart after failure to identify SiByte chip\n");
  114. machine_restart(NULL);
  115. }
  116. plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
  117. zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
  118. printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
  119. soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
  120. printk("Board type: %s\n", get_system_type());
  121. }