setup.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. */
  10. #include <linux/config.h>
  11. #include <linux/eisa.h>
  12. #include <linux/hdreg.h>
  13. #include <linux/ioport.h>
  14. #include <linux/sched.h>
  15. #include <linux/init.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/mc146818rtc.h>
  18. #include <linux/pm.h>
  19. #include <linux/pci.h>
  20. #include <linux/console.h>
  21. #include <linux/fb.h>
  22. #include <linux/tty.h>
  23. #ifdef CONFIG_ARC
  24. #include <asm/arc/types.h>
  25. #include <asm/sgialib.h>
  26. #endif
  27. #include <asm/bcache.h>
  28. #include <asm/bootinfo.h>
  29. #include <asm/io.h>
  30. #include <asm/irq.h>
  31. #include <asm/mc146818-time.h>
  32. #include <asm/processor.h>
  33. #include <asm/ptrace.h>
  34. #include <asm/reboot.h>
  35. #include <asm/sni.h>
  36. #include <asm/time.h>
  37. #include <asm/traps.h>
  38. extern void sni_machine_restart(char *command);
  39. extern void sni_machine_halt(void);
  40. extern void sni_machine_power_off(void);
  41. static void __init sni_rm200_pci_timer_setup(struct irqaction *irq)
  42. {
  43. /* set the clock to 100 Hz */
  44. outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
  45. outb_p(LATCH & 0xff , 0x40); /* LSB */
  46. outb(LATCH >> 8 , 0x40); /* MSB */
  47. setup_irq(0, irq);
  48. }
  49. /*
  50. * A bit more gossip about the iron we're running on ...
  51. */
  52. static inline void sni_pcimt_detect(void)
  53. {
  54. char boardtype[80];
  55. unsigned char csmsr;
  56. char *p = boardtype;
  57. unsigned int asic;
  58. csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
  59. p += sprintf(p, "%s PCI", (csmsr & 0x80) ? "RM200" : "RM300");
  60. if ((csmsr & 0x80) == 0)
  61. p += sprintf(p, ", board revision %s",
  62. (csmsr & 0x20) ? "D" : "C");
  63. asic = csmsr & 0x80;
  64. asic = (csmsr & 0x08) ? asic : !asic;
  65. p += sprintf(p, ", ASIC PCI Rev %s", asic ? "1.0" : "1.1");
  66. printk("%s.\n", boardtype);
  67. }
  68. static void __init sni_display_setup(void)
  69. {
  70. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_ARC)
  71. struct screen_info *si = &screen_info;
  72. DISPLAY_STATUS *di;
  73. di = ArcGetDisplayStatus(1);
  74. if (di) {
  75. si->orig_x = di->CursorXPosition;
  76. si->orig_y = di->CursorYPosition;
  77. si->orig_video_cols = di->CursorMaxXPosition;
  78. si->orig_video_lines = di->CursorMaxYPosition;
  79. si->orig_video_isVGA = VIDEO_TYPE_VGAC;
  80. si->orig_video_points = 16;
  81. }
  82. #endif
  83. }
  84. static struct resource sni_io_resource = {
  85. .start = 0x00001000UL,
  86. .end = 0x03bfffffUL,
  87. .name = "PCIMT IO MEM",
  88. .flags = IORESOURCE_IO,
  89. };
  90. static struct resource pcimt_io_resources[] = {
  91. {
  92. .start = 0x00,
  93. .end = 0x1f,
  94. .name = "dma1",
  95. .flags = IORESOURCE_BUSY
  96. }, {
  97. .start = 0x40,
  98. .end = 0x5f,
  99. .name = "timer",
  100. .flags = IORESOURCE_BUSY
  101. }, {
  102. .start = 0x60,
  103. .end = 0x6f,
  104. .name = "keyboard",
  105. .flags = IORESOURCE_BUSY
  106. }, {
  107. .start = 0x80,
  108. .end = 0x8f,
  109. .name = "dma page reg",
  110. .flags = IORESOURCE_BUSY
  111. }, {
  112. .start = 0xc0,
  113. .end = 0xdf,
  114. .name = "dma2",
  115. .flags = IORESOURCE_BUSY
  116. }, {
  117. .start = 0xcfc,
  118. .end = 0xcff,
  119. .name = "PCI config data",
  120. .flags = IORESOURCE_BUSY
  121. }
  122. };
  123. static struct resource sni_mem_resource = {
  124. .start = 0x10000000UL,
  125. .end = 0xffffffffUL,
  126. .name = "PCIMT PCI MEM",
  127. .flags = IORESOURCE_MEM
  128. };
  129. /*
  130. * The RM200/RM300 has a few holes in it's PCI/EISA memory address space used
  131. * for other purposes. Be paranoid and allocate all of the before the PCI
  132. * code gets a chance to to map anything else there ...
  133. *
  134. * This leaves the following areas available:
  135. *
  136. * 0x10000000 - 0x1009ffff (640kB) PCI/EISA/ISA Bus Memory
  137. * 0x10100000 - 0x13ffffff ( 15MB) PCI/EISA/ISA Bus Memory
  138. * 0x18000000 - 0x1fbfffff (124MB) PCI/EISA Bus Memory
  139. * 0x1ff08000 - 0x1ffeffff (816kB) PCI/EISA Bus Memory
  140. * 0xa0000000 - 0xffffffff (1.5GB) PCI/EISA Bus Memory
  141. */
  142. static struct resource pcimt_mem_resources[] = {
  143. {
  144. .start = 0x100a0000,
  145. .end = 0x100bffff,
  146. .name = "Video RAM area",
  147. .flags = IORESOURCE_BUSY
  148. }, {
  149. .start = 0x100c0000,
  150. .end = 0x100fffff,
  151. .name = "ISA Reserved",
  152. .flags = IORESOURCE_BUSY
  153. }, {
  154. .start = 0x14000000,
  155. .end = 0x17bfffff,
  156. .name = "PCI IO",
  157. .flags = IORESOURCE_BUSY
  158. }, {
  159. .start = 0x17c00000,
  160. .end = 0x17ffffff,
  161. .name = "Cache Replacement Area",
  162. .flags = IORESOURCE_BUSY
  163. }, {
  164. .start = 0x1a000000,
  165. .end = 0x1a000003,
  166. .name = "PCI INT Acknowledge",
  167. .flags = IORESOURCE_BUSY
  168. }, {
  169. .start = 0x1fc00000,
  170. .end = 0x1fc7ffff,
  171. .name = "Boot PROM",
  172. .flags = IORESOURCE_BUSY
  173. }, {
  174. .start = 0x1fc80000,
  175. .end = 0x1fcfffff,
  176. .name = "Diag PROM",
  177. .flags = IORESOURCE_BUSY
  178. }, {
  179. .start = 0x1fd00000,
  180. .end = 0x1fdfffff,
  181. .name = "X-Bus",
  182. .flags = IORESOURCE_BUSY
  183. }, {
  184. .start = 0x1fe00000,
  185. .end = 0x1fefffff,
  186. .name = "BIOS map",
  187. .flags = IORESOURCE_BUSY
  188. }, {
  189. .start = 0x1ff00000,
  190. .end = 0x1ff7ffff,
  191. .name = "NVRAM / EEPROM",
  192. .flags = IORESOURCE_BUSY
  193. }, {
  194. .start = 0x1fff0000,
  195. .end = 0x1fffefff,
  196. .name = "ASIC PCI",
  197. .flags = IORESOURCE_BUSY
  198. }, {
  199. .start = 0x1ffff000,
  200. .end = 0x1fffffff,
  201. .name = "MP Agent",
  202. .flags = IORESOURCE_BUSY
  203. }, {
  204. .start = 0x20000000,
  205. .end = 0x9fffffff,
  206. .name = "Main Memory",
  207. .flags = IORESOURCE_BUSY
  208. }
  209. };
  210. static void __init sni_resource_init(void)
  211. {
  212. int i;
  213. /* request I/O space for devices used on all i[345]86 PCs */
  214. for (i = 0; i < ARRAY_SIZE(pcimt_io_resources); i++)
  215. request_resource(&ioport_resource, pcimt_io_resources + i);
  216. /* request mem space for pcimt-specific devices */
  217. for (i = 0; i < ARRAY_SIZE(pcimt_mem_resources); i++)
  218. request_resource(&sni_mem_resource, pcimt_mem_resources + i);
  219. ioport_resource.end = sni_io_resource.end;
  220. }
  221. extern struct pci_ops sni_pci_ops;
  222. static struct pci_controller sni_controller = {
  223. .pci_ops = &sni_pci_ops,
  224. .mem_resource = &sni_mem_resource,
  225. .mem_offset = 0x10000000UL,
  226. .io_resource = &sni_io_resource,
  227. .io_offset = 0x00000000UL
  228. };
  229. static inline void sni_pcimt_time_init(void)
  230. {
  231. rtc_mips_get_time = mc146818_get_cmos_time;
  232. rtc_mips_set_time = mc146818_set_rtc_mmss;
  233. }
  234. void __init plat_mem_setup(void)
  235. {
  236. sni_pcimt_detect();
  237. sni_pcimt_sc_init();
  238. sni_pcimt_time_init();
  239. set_io_port_base(SNI_PORT_BASE);
  240. ioport_resource.end = sni_io_resource.end;
  241. /*
  242. * Setup (E)ISA I/O memory access stuff
  243. */
  244. isa_slot_offset = 0xb0000000;
  245. #ifdef CONFIG_EISA
  246. EISA_bus = 1;
  247. #endif
  248. sni_resource_init();
  249. board_timer_setup = sni_rm200_pci_timer_setup;
  250. _machine_restart = sni_machine_restart;
  251. _machine_halt = sni_machine_halt;
  252. pm_power_off = sni_machine_power_off;
  253. sni_display_setup();
  254. #ifdef CONFIG_PCI
  255. register_pci_controller(&sni_controller);
  256. #endif
  257. }