setup.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2000,2001,2002,2003,2004 Broadcom Corporation
  4. */
  5. #include <linux/init.h>
  6. #include <linux/kernel.h>
  7. #include <linux/export.h>
  8. #include <linux/reboot.h>
  9. #include <linux/string.h>
  10. #include <asm/bootinfo.h>
  11. #include <asm/cpu.h>
  12. #include <asm/mipsregs.h>
  13. #include <asm/io.h>
  14. #include <asm/sibyte/sb1250.h>
  15. #include <asm/sibyte/bcm1480_regs.h>
  16. #include <asm/sibyte/bcm1480_scd.h>
  17. #include <asm/sibyte/sb1250_scd.h>
  18. unsigned int sb1_pass;
  19. unsigned int soc_pass;
  20. unsigned int soc_type;
  21. EXPORT_SYMBOL(soc_type);
  22. unsigned int periph_rev;
  23. EXPORT_SYMBOL_GPL(periph_rev);
  24. unsigned int zbbus_mhz;
  25. EXPORT_SYMBOL(zbbus_mhz);
  26. static unsigned int part_type;
  27. static char *soc_str;
  28. static char *pass_str;
  29. static int __init setup_bcm1x80_bcm1x55(void)
  30. {
  31. switch (soc_pass) {
  32. case K_SYS_REVISION_BCM1480_S0:
  33. periph_rev = 1;
  34. pass_str = "S0 (pass1)";
  35. break;
  36. case K_SYS_REVISION_BCM1480_A1:
  37. periph_rev = 1;
  38. pass_str = "A1 (pass1)";
  39. break;
  40. case K_SYS_REVISION_BCM1480_A2:
  41. periph_rev = 1;
  42. pass_str = "A2 (pass1)";
  43. break;
  44. case K_SYS_REVISION_BCM1480_A3:
  45. periph_rev = 1;
  46. pass_str = "A3 (pass1)";
  47. break;
  48. case K_SYS_REVISION_BCM1480_B0:
  49. periph_rev = 1;
  50. pass_str = "B0 (pass2)";
  51. break;
  52. default:
  53. printk("Unknown %s rev %x\n", soc_str, soc_pass);
  54. periph_rev = 1;
  55. pass_str = "Unknown Revision";
  56. break;
  57. }
  58. return 0;
  59. }
  60. /* Setup code likely to be common to all SiByte platforms */
  61. static int __init sys_rev_decode(void)
  62. {
  63. int ret = 0;
  64. switch (soc_type) {
  65. case K_SYS_SOC_TYPE_BCM1x80:
  66. if (part_type == K_SYS_PART_BCM1480)
  67. soc_str = "BCM1480";
  68. else if (part_type == K_SYS_PART_BCM1280)
  69. soc_str = "BCM1280";
  70. else
  71. soc_str = "BCM1x80";
  72. ret = setup_bcm1x80_bcm1x55();
  73. break;
  74. case K_SYS_SOC_TYPE_BCM1x55:
  75. if (part_type == K_SYS_PART_BCM1455)
  76. soc_str = "BCM1455";
  77. else if (part_type == K_SYS_PART_BCM1255)
  78. soc_str = "BCM1255";
  79. else
  80. soc_str = "BCM1x55";
  81. ret = setup_bcm1x80_bcm1x55();
  82. break;
  83. default:
  84. printk("Unknown part type %x\n", part_type);
  85. ret = 1;
  86. break;
  87. }
  88. return ret;
  89. }
  90. void __init bcm1480_setup(void)
  91. {
  92. uint64_t sys_rev;
  93. int plldiv;
  94. sb1_pass = read_c0_prid() & PRID_REV_MASK;
  95. sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
  96. soc_type = SYS_SOC_TYPE(sys_rev);
  97. part_type = G_SYS_PART(sys_rev);
  98. soc_pass = G_SYS_REVISION(sys_rev);
  99. if (sys_rev_decode()) {
  100. printk("Restart after failure to identify SiByte chip\n");
  101. machine_restart(NULL);
  102. }
  103. plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
  104. zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
  105. printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
  106. soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
  107. printk("Board type: %s\n", get_system_type());
  108. }