setup.c 6.4 KB

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