setup.c 5.6 KB

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