setup.c 6.4 KB

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