setup.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
  3. * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20. * Setup code for the SWARM board
  21. */
  22. #include <linux/spinlock.h>
  23. #include <linux/mm.h>
  24. #include <linux/bootmem.h>
  25. #include <linux/blkdev.h>
  26. #include <linux/init.h>
  27. #include <linux/kernel.h>
  28. #include <linux/screen_info.h>
  29. #include <linux/initrd.h>
  30. #include <asm/irq.h>
  31. #include <asm/io.h>
  32. #include <asm/bootinfo.h>
  33. #include <asm/mipsregs.h>
  34. #include <asm/reboot.h>
  35. #include <asm/time.h>
  36. #include <asm/traps.h>
  37. #include <asm/sibyte/sb1250.h>
  38. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  39. #include <asm/sibyte/bcm1480_regs.h>
  40. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  41. #include <asm/sibyte/sb1250_regs.h>
  42. #else
  43. #error invalid SiByte board configuration
  44. #endif
  45. #include <asm/sibyte/sb1250_genbus.h>
  46. #include <asm/sibyte/board.h>
  47. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  48. extern void bcm1480_setup(void);
  49. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  50. extern void sb1250_setup(void);
  51. #else
  52. #error invalid SiByte board configuration
  53. #endif
  54. extern int xicor_probe(void);
  55. extern int xicor_set_time(unsigned long);
  56. extern unsigned long xicor_get_time(void);
  57. extern int m41t81_probe(void);
  58. extern int m41t81_set_time(unsigned long);
  59. extern unsigned long m41t81_get_time(void);
  60. const char *get_system_type(void)
  61. {
  62. return "SiByte " SIBYTE_BOARD_NAME;
  63. }
  64. int swarm_be_handler(struct pt_regs *regs, int is_fixup)
  65. {
  66. if (!is_fixup && (regs->cp0_cause & 4)) {
  67. /* Data bus error - print PA */
  68. printk("DBE physical address: %010Lx\n",
  69. __read_64bit_c0_register($26, 1));
  70. }
  71. return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
  72. }
  73. enum swarm_rtc_type {
  74. RTC_NONE,
  75. RTC_XICOR,
  76. RTC_M41T81,
  77. };
  78. enum swarm_rtc_type swarm_rtc_type;
  79. void read_persistent_clock(struct timespec *ts)
  80. {
  81. unsigned long sec;
  82. switch (swarm_rtc_type) {
  83. case RTC_XICOR:
  84. sec = xicor_get_time();
  85. break;
  86. case RTC_M41T81:
  87. sec = m41t81_get_time();
  88. break;
  89. case RTC_NONE:
  90. default:
  91. sec = mktime(2000, 1, 1, 0, 0, 0);
  92. break;
  93. }
  94. ts->tv_sec = sec;
  95. ts->tv_nsec = 0;
  96. }
  97. int rtc_mips_set_time(unsigned long sec)
  98. {
  99. switch (swarm_rtc_type) {
  100. case RTC_XICOR:
  101. return xicor_set_time(sec);
  102. case RTC_M41T81:
  103. return m41t81_set_time(sec);
  104. case RTC_NONE:
  105. default:
  106. return -1;
  107. }
  108. }
  109. void __init plat_mem_setup(void)
  110. {
  111. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  112. bcm1480_setup();
  113. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  114. sb1250_setup();
  115. #else
  116. #error invalid SiByte board configuration
  117. #endif
  118. board_be_handler = swarm_be_handler;
  119. if (xicor_probe())
  120. swarm_rtc_type = RTC_XICOR;
  121. if (m41t81_probe())
  122. swarm_rtc_type = RTC_M41T81;
  123. #ifdef CONFIG_VT
  124. screen_info = (struct screen_info) {
  125. .orig_video_page = 52,
  126. .orig_video_mode = 3,
  127. .orig_video_cols = 80,
  128. .flags = 12,
  129. .orig_video_ega_bx = 3,
  130. .orig_video_lines = 25,
  131. .orig_video_isVGA = 0x22,
  132. .orig_video_points = 16,
  133. };
  134. /* XXXKW for CFE, get lines/cols from environment */
  135. #endif
  136. }
  137. #ifdef LEDS_PHYS
  138. #ifdef CONFIG_SIBYTE_CARMEL
  139. /* XXXKW need to detect Monterey/LittleSur/etc */
  140. #undef LEDS_PHYS
  141. #define LEDS_PHYS MLEDS_PHYS
  142. #endif
  143. void setleds(char *str)
  144. {
  145. void *reg;
  146. int i;
  147. for (i = 0; i < 4; i++) {
  148. reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);
  149. if (!str[i])
  150. writeb(' ', reg);
  151. else
  152. writeb(str[i], reg);
  153. }
  154. }
  155. #endif /* LEDS_PHYS */