setup.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * Setup pointers to hardware-dependent routines.
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1996, 97, 98, 2000, 03, 04, 06 Ralf Baechle (ralf@linux-mips.org)
  9. * Copyright (C) 2006,2007 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
  10. */
  11. #include <linux/eisa.h>
  12. #include <linux/init.h>
  13. #include <linux/export.h>
  14. #include <linux/console.h>
  15. #include <linux/screen_info.h>
  16. #include <linux/string.h>
  17. #ifdef CONFIG_FW_ARC
  18. #include <asm/fw/arc/types.h>
  19. #include <asm/sgialib.h>
  20. #endif
  21. #ifdef CONFIG_FW_SNIPROM
  22. #include <asm/mipsprom.h>
  23. #endif
  24. #include <asm/bootinfo.h>
  25. #include <asm/cpu.h>
  26. #include <asm/io.h>
  27. #include <asm/reboot.h>
  28. #include <asm/sni.h>
  29. unsigned int sni_brd_type;
  30. EXPORT_SYMBOL(sni_brd_type);
  31. extern void sni_machine_restart(char *command);
  32. extern void sni_machine_power_off(void);
  33. static void __init sni_display_setup(void)
  34. {
  35. #if defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_FW_ARC)
  36. static struct screen_info si;
  37. DISPLAY_STATUS *di;
  38. di = ArcGetDisplayStatus(1);
  39. if (di) {
  40. si.orig_x = di->CursorXPosition;
  41. si.orig_y = di->CursorYPosition;
  42. si.orig_video_cols = di->CursorMaxXPosition;
  43. si.orig_video_lines = di->CursorMaxYPosition;
  44. si.orig_video_isVGA = VIDEO_TYPE_VGAC;
  45. si.orig_video_points = 16;
  46. vgacon_register_screen(&si);
  47. }
  48. #endif
  49. }
  50. static void __init sni_console_setup(void)
  51. {
  52. #ifndef CONFIG_FW_ARC
  53. char *ctype;
  54. char *cdev;
  55. char *baud;
  56. int port;
  57. static char options[8] __initdata;
  58. cdev = prom_getenv("console_dev");
  59. if (strncmp(cdev, "tty", 3) == 0) {
  60. ctype = prom_getenv("console");
  61. switch (*ctype) {
  62. default:
  63. case 'l':
  64. port = 0;
  65. baud = prom_getenv("lbaud");
  66. break;
  67. case 'r':
  68. port = 1;
  69. baud = prom_getenv("rbaud");
  70. break;
  71. }
  72. if (baud)
  73. strscpy(options, baud);
  74. if (strncmp(cdev, "tty552", 6) == 0)
  75. add_preferred_console("ttyS", port,
  76. baud ? options : NULL);
  77. else
  78. add_preferred_console("ttySC", port,
  79. baud ? options : NULL);
  80. }
  81. #endif
  82. }
  83. #ifdef DEBUG
  84. static void __init sni_idprom_dump(void)
  85. {
  86. int i;
  87. pr_debug("SNI IDProm dump:\n");
  88. for (i = 0; i < 256; i++) {
  89. if (i%16 == 0)
  90. pr_debug("%04x ", i);
  91. printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i));
  92. if (i % 16 == 15)
  93. printk("\n");
  94. }
  95. }
  96. #endif
  97. void __init plat_mem_setup(void)
  98. {
  99. int cputype;
  100. set_io_port_base(SNI_PORT_BASE);
  101. // ioport_resource.end = sni_io_resource.end;
  102. /*
  103. * Setup (E)ISA I/O memory access stuff
  104. */
  105. #ifdef CONFIG_EISA
  106. EISA_bus = 1;
  107. #endif
  108. sni_brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
  109. cputype = *(unsigned char *)SNI_IDPROM_CPUTYPE;
  110. switch (sni_brd_type) {
  111. case SNI_BRD_TOWER_OASIC:
  112. switch (cputype) {
  113. case SNI_CPU_M8030:
  114. system_type = "RM400-330";
  115. break;
  116. case SNI_CPU_M8031:
  117. system_type = "RM400-430";
  118. break;
  119. case SNI_CPU_M8037:
  120. system_type = "RM400-530";
  121. break;
  122. case SNI_CPU_M8034:
  123. system_type = "RM400-730";
  124. break;
  125. default:
  126. system_type = "RM400-xxx";
  127. break;
  128. }
  129. break;
  130. case SNI_BRD_MINITOWER:
  131. switch (cputype) {
  132. case SNI_CPU_M8021:
  133. case SNI_CPU_M8043:
  134. system_type = "RM400-120";
  135. break;
  136. case SNI_CPU_M8040:
  137. system_type = "RM400-220";
  138. break;
  139. case SNI_CPU_M8053:
  140. system_type = "RM400-225";
  141. break;
  142. case SNI_CPU_M8050:
  143. system_type = "RM400-420";
  144. break;
  145. default:
  146. system_type = "RM400-xxx";
  147. break;
  148. }
  149. break;
  150. case SNI_BRD_PCI_TOWER:
  151. system_type = "RM400-Cxx";
  152. break;
  153. case SNI_BRD_RM200:
  154. system_type = "RM200-xxx";
  155. break;
  156. case SNI_BRD_PCI_MTOWER:
  157. system_type = "RM300-Cxx";
  158. break;
  159. case SNI_BRD_PCI_DESKTOP:
  160. switch (read_c0_prid() & PRID_IMP_MASK) {
  161. case PRID_IMP_R4600:
  162. case PRID_IMP_R4700:
  163. system_type = "RM200-C20";
  164. break;
  165. case PRID_IMP_R5000:
  166. system_type = "RM200-C40";
  167. break;
  168. default:
  169. system_type = "RM200-Cxx";
  170. break;
  171. }
  172. break;
  173. case SNI_BRD_PCI_TOWER_CPLUS:
  174. system_type = "RM400-Exx";
  175. break;
  176. case SNI_BRD_PCI_MTOWER_CPLUS:
  177. system_type = "RM300-Exx";
  178. break;
  179. }
  180. pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type, system_type);
  181. #ifdef DEBUG
  182. sni_idprom_dump();
  183. #endif
  184. switch (sni_brd_type) {
  185. case SNI_BRD_10:
  186. case SNI_BRD_10NEW:
  187. case SNI_BRD_TOWER_OASIC:
  188. case SNI_BRD_MINITOWER:
  189. sni_a20r_init();
  190. break;
  191. case SNI_BRD_PCI_TOWER:
  192. case SNI_BRD_PCI_TOWER_CPLUS:
  193. sni_pcit_init();
  194. break;
  195. case SNI_BRD_RM200:
  196. sni_rm200_init();
  197. break;
  198. case SNI_BRD_PCI_MTOWER:
  199. case SNI_BRD_PCI_DESKTOP:
  200. case SNI_BRD_PCI_MTOWER_CPLUS:
  201. sni_pcimt_init();
  202. break;
  203. }
  204. _machine_restart = sni_machine_restart;
  205. pm_power_off = sni_machine_power_off;
  206. sni_display_setup();
  207. sni_console_setup();
  208. }
  209. #ifdef CONFIG_PCI
  210. #include <linux/pci.h>
  211. #include <video/vga.h>
  212. #include <video/cirrus.h>
  213. static void quirk_cirrus_ram_size(struct pci_dev *dev)
  214. {
  215. u16 cmd;
  216. /*
  217. * firmware doesn't set the ram size correct, so we
  218. * need to do it here, otherwise we get screen corruption
  219. * on older Cirrus chips
  220. */
  221. pci_read_config_word(dev, PCI_COMMAND, &cmd);
  222. if ((cmd & (PCI_COMMAND_IO|PCI_COMMAND_MEMORY))
  223. == (PCI_COMMAND_IO|PCI_COMMAND_MEMORY)) {
  224. vga_wseq(NULL, CL_SEQR6, 0x12); /* unlock all extension registers */
  225. vga_wseq(NULL, CL_SEQRF, 0x18);
  226. }
  227. }
  228. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5434_8,
  229. quirk_cirrus_ram_size);
  230. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5436,
  231. quirk_cirrus_ram_size);
  232. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446,
  233. quirk_cirrus_ram_size);
  234. #endif