setup.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 configuation
  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 configuation
  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. void __init swarm_time_init(void)
  65. {
  66. #if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  67. /* Setup HPT */
  68. sb1250_hpt_setup();
  69. #endif
  70. }
  71. void __init plat_timer_setup(struct irqaction *irq)
  72. {
  73. /*
  74. * we don't set up irqaction, because we will deliver timer
  75. * interrupts through low-level (direct) meachanism.
  76. */
  77. /* We only need to setup the generic timer */
  78. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  79. bcm1480_time_init();
  80. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  81. sb1250_time_init();
  82. #else
  83. #error invalid SiByte board configuation
  84. #endif
  85. }
  86. int swarm_be_handler(struct pt_regs *regs, int is_fixup)
  87. {
  88. if (!is_fixup && (regs->cp0_cause & 4)) {
  89. /* Data bus error - print PA */
  90. printk("DBE physical address: %010Lx\n",
  91. __read_64bit_c0_register($26, 1));
  92. }
  93. return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
  94. }
  95. void __init plat_mem_setup(void)
  96. {
  97. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  98. bcm1480_setup();
  99. #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
  100. sb1250_setup();
  101. #else
  102. #error invalid SiByte board configuation
  103. #endif
  104. panic_timeout = 5; /* For debug. */
  105. board_time_init = swarm_time_init;
  106. board_be_handler = swarm_be_handler;
  107. if (xicor_probe()) {
  108. printk("swarm setup: Xicor 1241 RTC detected.\n");
  109. rtc_mips_get_time = xicor_get_time;
  110. rtc_mips_set_time = xicor_set_time;
  111. }
  112. if (m41t81_probe()) {
  113. printk("swarm setup: M41T81 RTC detected.\n");
  114. rtc_mips_get_time = m41t81_get_time;
  115. rtc_mips_set_time = m41t81_set_time;
  116. }
  117. printk("This kernel optimized for "
  118. #ifdef CONFIG_SIMULATION
  119. "simulation"
  120. #else
  121. "board"
  122. #endif
  123. " runs "
  124. #ifdef CONFIG_SIBYTE_CFE
  125. "with"
  126. #else
  127. "without"
  128. #endif
  129. " CFE\n");
  130. #ifdef CONFIG_VT
  131. screen_info = (struct screen_info) {
  132. 0, 0, /* orig-x, orig-y */
  133. 0, /* unused */
  134. 52, /* orig_video_page */
  135. 3, /* orig_video_mode */
  136. 80, /* orig_video_cols */
  137. 4626, 3, 9, /* unused, ega_bx, unused */
  138. 25, /* orig_video_lines */
  139. 0x22, /* orig_video_isVGA */
  140. 16 /* orig_video_points */
  141. };
  142. /* XXXKW for CFE, get lines/cols from environment */
  143. #endif
  144. }
  145. #ifdef LEDS_PHYS
  146. #ifdef CONFIG_SIBYTE_CARMEL
  147. /* XXXKW need to detect Monterey/LittleSur/etc */
  148. #undef LEDS_PHYS
  149. #define LEDS_PHYS MLEDS_PHYS
  150. #endif
  151. #define setled(index, c) \
  152. ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c)
  153. void setleds(char *str)
  154. {
  155. int i;
  156. for (i = 0; i < 4; i++) {
  157. if (!str[i]) {
  158. setled(i, ' ');
  159. } else {
  160. setled(i, str[i]);
  161. }
  162. }
  163. }
  164. #endif