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