setup.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
  4. * Copyright (C) 2004 by Ralf Baechle ([email protected])
  5. */
  6. /*
  7. * Setup code for the SWARM board
  8. */
  9. #include <linux/spinlock.h>
  10. #include <linux/mm.h>
  11. #include <linux/memblock.h>
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/screen_info.h>
  15. #include <linux/initrd.h>
  16. #include <asm/irq.h>
  17. #include <asm/io.h>
  18. #include <asm/bootinfo.h>
  19. #include <asm/mipsregs.h>
  20. #include <asm/reboot.h>
  21. #include <asm/time.h>
  22. #include <asm/traps.h>
  23. #include <asm/sibyte/sb1250.h>
  24. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  25. #include <asm/sibyte/bcm1480_regs.h>
  26. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  27. #include <asm/sibyte/sb1250_regs.h>
  28. #else
  29. #error invalid SiByte board configuration
  30. #endif
  31. #include <asm/sibyte/sb1250_genbus.h>
  32. #include <asm/sibyte/board.h>
  33. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  34. extern void bcm1480_setup(void);
  35. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  36. extern void sb1250_setup(void);
  37. #else
  38. #error invalid SiByte board configuration
  39. #endif
  40. extern int xicor_probe(void);
  41. extern int xicor_set_time(time64_t);
  42. extern time64_t xicor_get_time(void);
  43. extern int m41t81_probe(void);
  44. extern int m41t81_set_time(time64_t);
  45. extern time64_t m41t81_get_time(void);
  46. const char *get_system_type(void)
  47. {
  48. return "SiByte " SIBYTE_BOARD_NAME;
  49. }
  50. int swarm_be_handler(struct pt_regs *regs, int is_fixup)
  51. {
  52. if (!is_fixup && (regs->cp0_cause & 4)) {
  53. /* Data bus error - print PA */
  54. printk("DBE physical address: %010Lx\n",
  55. __read_64bit_c0_register($26, 1));
  56. }
  57. return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
  58. }
  59. enum swarm_rtc_type {
  60. RTC_NONE,
  61. RTC_XICOR,
  62. RTC_M41T81,
  63. };
  64. enum swarm_rtc_type swarm_rtc_type;
  65. void read_persistent_clock64(struct timespec64 *ts)
  66. {
  67. time64_t sec;
  68. switch (swarm_rtc_type) {
  69. case RTC_XICOR:
  70. sec = xicor_get_time();
  71. break;
  72. case RTC_M41T81:
  73. sec = m41t81_get_time();
  74. break;
  75. case RTC_NONE:
  76. default:
  77. sec = mktime64(2000, 1, 1, 0, 0, 0);
  78. break;
  79. }
  80. ts->tv_sec = sec;
  81. ts->tv_nsec = 0;
  82. }
  83. int update_persistent_clock64(struct timespec64 now)
  84. {
  85. time64_t sec = now.tv_sec;
  86. switch (swarm_rtc_type) {
  87. case RTC_XICOR:
  88. return xicor_set_time(sec);
  89. case RTC_M41T81:
  90. return m41t81_set_time(sec);
  91. case RTC_NONE:
  92. default:
  93. return -1;
  94. }
  95. }
  96. void __init plat_mem_setup(void)
  97. {
  98. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  99. bcm1480_setup();
  100. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  101. sb1250_setup();
  102. #else
  103. #error invalid SiByte board configuration
  104. #endif
  105. mips_set_be_handler(swarm_be_handler);
  106. if (xicor_probe())
  107. swarm_rtc_type = RTC_XICOR;
  108. if (m41t81_probe())
  109. swarm_rtc_type = RTC_M41T81;
  110. #ifdef CONFIG_VT
  111. screen_info = (struct screen_info) {
  112. .orig_video_page = 52,
  113. .orig_video_mode = 3,
  114. .orig_video_cols = 80,
  115. .flags = 12,
  116. .orig_video_ega_bx = 3,
  117. .orig_video_lines = 25,
  118. .orig_video_isVGA = 0x22,
  119. .orig_video_points = 16,
  120. };
  121. /* XXXKW for CFE, get lines/cols from environment */
  122. #endif
  123. }
  124. #ifdef LEDS_PHYS
  125. #ifdef CONFIG_SIBYTE_CARMEL
  126. /* XXXKW need to detect Monterey/LittleSur/etc */
  127. #undef LEDS_PHYS
  128. #define LEDS_PHYS MLEDS_PHYS
  129. #endif
  130. void setleds(char *str)
  131. {
  132. void *reg;
  133. int i;
  134. for (i = 0; i < 4; i++) {
  135. reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);
  136. if (!str[i])
  137. writeb(' ', reg);
  138. else
  139. writeb(str[i], reg);
  140. }
  141. }
  142. #endif /* LEDS_PHYS */