setup.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright (C) 2000, 2001 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. /*
  19.  * Setup code for the SWARM board
  20.  */
  21. #include <linux/spinlock.h>
  22. #include <linux/mm.h>
  23. #include <linux/bootmem.h>
  24. #include <linux/blk.h>
  25. #include <linux/init.h>
  26. #include <linux/ide.h>
  27. #include <linux/console.h>
  28. #include <asm/irq.h>
  29. #include <asm/io.h>
  30. #include <asm/bootinfo.h>
  31. #include <asm/reboot.h>
  32. #include <asm/time.h>
  33. #include <asm/sibyte/sb1250.h>
  34. #include <asm/sibyte/sb1250_regs.h>
  35. #include <asm/sibyte/sb1250_genbus.h>
  36. #include <asm/sibyte/64bit.h>
  37. #include <asm/sibyte/swarm.h>
  38. extern struct rtc_ops *rtc_ops;
  39. extern struct rtc_ops swarm_rtc_ops;
  40. #ifdef CONFIG_BLK_DEV_IDE
  41. extern struct ide_ops std_ide_ops;
  42. #ifdef CONFIG_BLK_DEV_IDE_SIBYTE
  43. extern struct ide_ops sibyte_ide_ops;
  44. #endif
  45. #endif
  46. #ifdef CONFIG_L3DEMO
  47. extern void *l3info;
  48. #endif
  49. static unsigned char *led_ptr;
  50. #define LED_BASE_ADDR (A_IO_EXT_REG(R_IO_EXT_REG(R_IO_EXT_START_ADDR, LEDS_CS)))
  51. #define setled(index, c) led_ptr[(3-((index)&3)) << 3] = (c)
  52. const char *get_system_type(void)
  53. {
  54. return "SiByte Swarm";
  55. }
  56. void __init bus_error_init(void)
  57. {
  58. }
  59. void __init swarm_timer_setup(struct irqaction *irq)
  60. {
  61.         /*
  62.          * we don't set up irqaction, because we will deliver timer
  63.          * interrupts through low-level (direct) meachanism.
  64.          */
  65.         /* We only need to setup the generic timer */
  66.         sb1250_time_init();
  67. }
  68. extern int xicor_set_time(unsigned long);
  69. extern unsigned long xicor_get_time(void);
  70. extern void sb1250_setup(void);
  71. void __init swarm_setup(void)
  72. {
  73. extern int panic_timeout;
  74. sb1250_setup();
  75. panic_timeout = 5;  /* For debug.  */
  76.         board_timer_setup = swarm_timer_setup;
  77.         rtc_get_time = xicor_get_time;
  78.         rtc_set_time = xicor_set_time;
  79. #ifdef CONFIG_L3DEMO
  80. if (l3info != NULL) {
  81. printk("n");
  82. }
  83. #endif
  84. printk("This kernel optimized for "
  85. #ifdef CONFIG_SIMULATION
  86.        "simulation"
  87. #else
  88.        "board"
  89. #endif
  90.        " runs "
  91. #ifdef CONFIG_SIBYTE_CFE
  92.        "with"
  93. #else
  94.        "without"
  95. #endif
  96.        " CFEn");
  97. #ifdef CONFIG_BLK_DEV_IDE
  98. #ifdef CONFIG_BLK_DEV_IDE_SIBYTE
  99. ide_ops = &sibyte_ide_ops;
  100. #else
  101. ide_ops = &std_ide_ops;
  102. #endif
  103. #endif
  104. /* Set up the LED base address */
  105. #ifdef __MIPSEL__
  106. /* Pass1 workaround (bug 1624) */
  107. if (sb1250_pass == K_SYS_REVISION_PASS1)
  108. led_ptr = (unsigned char *)
  109. ((unsigned long)(KSEG1 | (G_IO_START_ADDR(csr_in32(4+(KSEG1|LED_BASE_ADDR))) << S_IO_ADDRBASE))+0x20);
  110. else
  111. #endif
  112. led_ptr = (unsigned char *)
  113. ((unsigned long)(KSEG1 | (G_IO_START_ADDR(csr_in32(KSEG1|LED_BASE_ADDR)) << S_IO_ADDRBASE))+0x20);
  114. #ifdef CONFIG_VT
  115. #ifdef CONFIG_DUMMY_CONSOLE
  116. conswitchp = &dummy_con;
  117. #endif
  118. screen_info = (struct screen_info) {
  119. 0, 0,           /* orig-x, orig-y */
  120. 0,              /* unused */
  121. 52,             /* orig_video_page */
  122. 3,              /* orig_video_mode */
  123. 80,             /* orig_video_cols */
  124. 4626, 3, 9,     /* unused, ega_bx, unused */
  125. 25,             /* orig_video_lines */
  126. 0x22,           /* orig_video_isVGA */
  127. 16              /* orig_video_points */
  128.        };
  129.        /* XXXKW for CFE, get lines/cols from environment */
  130. #endif
  131. }
  132. void setleds(char *str)
  133. {
  134. int i;
  135. for (i = 0; i < 4; i++) {
  136. if (!str[i]) {
  137. for (; i < 4; i++) {
  138. setled(' ', str[i]);
  139. }
  140. } else {
  141. setled(i, str[i]);
  142. }
  143. }
  144. }
  145. #include <linux/timer.h>
  146. static struct timer_list led_timer;
  147. static unsigned char default_led_msg[] =
  148. "Today: the CSWARM.  Tomorrow: the WORLD!!!!           ";
  149. static unsigned char *led_msg = default_led_msg;
  150. static unsigned char *led_msg_ptr = default_led_msg;
  151. void set_led_msg(char *new_msg)
  152. {
  153. led_msg = new_msg;
  154. led_msg_ptr = new_msg;
  155. setleds("    ");
  156. }
  157. static void move_leds(unsigned long arg)
  158. {
  159. int i;
  160. unsigned char *tmp = led_msg_ptr;
  161. for (i = 0; i < 4; i++) {
  162. setled(i, *tmp);
  163. tmp++;
  164. if (!*tmp) {
  165. tmp = led_msg;
  166. }
  167. }
  168. led_msg_ptr++;
  169. if (!*led_msg_ptr) {
  170.   led_msg_ptr = led_msg;
  171. }
  172. del_timer(&led_timer);
  173. led_timer.expires = jiffies + (HZ/8);
  174. add_timer(&led_timer);
  175. }
  176. void hack_leds(void)
  177. {
  178. init_timer(&led_timer);
  179. led_timer.expires = jiffies + (HZ/8);
  180. led_timer.data = 0;
  181. led_timer.function = move_leds;
  182. add_timer(&led_timer);
  183. }