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/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];
  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. isa_slot_offset = CKSEG1ADDR(0xb0000000);
  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