setup.c 5.5 KB

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