a20r.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * A20R specific code
  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) 2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
  9. */
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/serial_8250.h>
  14. #include <asm/sni.h>
  15. #include <asm/time.h>
  16. #define PORT(_base,_irq) \
  17. { \
  18. .iobase = _base, \
  19. .irq = _irq, \
  20. .uartclk = 1843200, \
  21. .iotype = UPIO_PORT, \
  22. .flags = UPF_BOOT_AUTOCONF, \
  23. }
  24. static struct plat_serial8250_port a20r_data[] = {
  25. PORT(0x3f8, 4),
  26. PORT(0x2f8, 3),
  27. { },
  28. };
  29. static struct platform_device a20r_serial8250_device = {
  30. .name = "serial8250",
  31. .id = PLAT8250_DEV_PLATFORM,
  32. .dev = {
  33. .platform_data = a20r_data,
  34. },
  35. };
  36. static struct resource a20r_ds1216_rsrc[] = {
  37. {
  38. .start = 0x1c081ffc,
  39. .end = 0x1c081fff,
  40. .flags = IORESOURCE_MEM
  41. }
  42. };
  43. static struct platform_device a20r_ds1216_device = {
  44. .name = "rtc-ds1216",
  45. .num_resources = ARRAY_SIZE(a20r_ds1216_rsrc),
  46. .resource = a20r_ds1216_rsrc
  47. };
  48. static struct resource snirm_82596_rsrc[] = {
  49. {
  50. .start = 0x18000000,
  51. .end = 0x18000004,
  52. .flags = IORESOURCE_MEM
  53. },
  54. {
  55. .start = 0x18010000,
  56. .end = 0x18010004,
  57. .flags = IORESOURCE_MEM
  58. },
  59. {
  60. .start = 0x1ff00000,
  61. .end = 0x1ff00020,
  62. .flags = IORESOURCE_MEM
  63. },
  64. {
  65. .start = 22,
  66. .end = 22,
  67. .flags = IORESOURCE_IRQ
  68. },
  69. {
  70. .flags = 0x01 /* 16bit mpu port access */
  71. }
  72. };
  73. static struct platform_device snirm_82596_pdev = {
  74. .name = "snirm_82596",
  75. .num_resources = ARRAY_SIZE(snirm_82596_rsrc),
  76. .resource = snirm_82596_rsrc
  77. };
  78. static struct resource snirm_53c710_rsrc[] = {
  79. {
  80. .start = 0x19000000,
  81. .end = 0x190fffff,
  82. .flags = IORESOURCE_MEM
  83. },
  84. {
  85. .start = 19,
  86. .end = 19,
  87. .flags = IORESOURCE_IRQ
  88. }
  89. };
  90. static struct platform_device snirm_53c710_pdev = {
  91. .name = "snirm_53c710",
  92. .num_resources = ARRAY_SIZE(snirm_53c710_rsrc),
  93. .resource = snirm_53c710_rsrc
  94. };
  95. static struct resource sc26xx_rsrc[] = {
  96. {
  97. .start = 0x1c070000,
  98. .end = 0x1c0700ff,
  99. .flags = IORESOURCE_MEM
  100. },
  101. {
  102. .start = 20,
  103. .end = 20,
  104. .flags = IORESOURCE_IRQ
  105. }
  106. };
  107. static unsigned int sc26xx_data[2] = {
  108. /* DTR | RTS | DSR | CTS | DCD | RI */
  109. (8 << 0) | (4 << 4) | (6 << 8) | (0 << 12) | (6 << 16) | (0 << 20),
  110. (3 << 0) | (2 << 4) | (1 << 8) | (2 << 12) | (3 << 16) | (4 << 20)
  111. };
  112. static struct platform_device sc26xx_pdev = {
  113. .name = "SC26xx",
  114. .num_resources = ARRAY_SIZE(sc26xx_rsrc),
  115. .resource = sc26xx_rsrc,
  116. .dev = {
  117. .platform_data = sc26xx_data,
  118. }
  119. };
  120. static u32 a20r_ack_hwint(void)
  121. {
  122. u32 status = read_c0_status();
  123. write_c0_status(status | 0x00010000);
  124. asm volatile(
  125. " .set push \n"
  126. " .set noat \n"
  127. " .set noreorder \n"
  128. " lw $1, 0(%0) \n"
  129. " sb $0, 0(%1) \n"
  130. " sync \n"
  131. " lb %1, 0(%1) \n"
  132. " b 1f \n"
  133. " ori %1, $1, 2 \n"
  134. " .align 8 \n"
  135. "1: \n"
  136. " nop \n"
  137. " sw %1, 0(%0) \n"
  138. " sync \n"
  139. " li %1, 0x20 \n"
  140. "2: \n"
  141. " nop \n"
  142. " bnez %1,2b \n"
  143. " addiu %1, -1 \n"
  144. " sw $1, 0(%0) \n"
  145. " sync \n"
  146. ".set pop \n"
  147. :
  148. : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
  149. write_c0_status(status);
  150. return status;
  151. }
  152. static inline void unmask_a20r_irq(unsigned int irq)
  153. {
  154. set_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
  155. irq_enable_hazard();
  156. }
  157. static inline void mask_a20r_irq(unsigned int irq)
  158. {
  159. clear_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
  160. irq_disable_hazard();
  161. }
  162. static void end_a20r_irq(unsigned int irq)
  163. {
  164. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
  165. a20r_ack_hwint();
  166. unmask_a20r_irq(irq);
  167. }
  168. }
  169. static struct irq_chip a20r_irq_type = {
  170. .typename = "A20R",
  171. .ack = mask_a20r_irq,
  172. .mask = mask_a20r_irq,
  173. .mask_ack = mask_a20r_irq,
  174. .unmask = unmask_a20r_irq,
  175. .end = end_a20r_irq,
  176. };
  177. /*
  178. * hwint 0 receive all interrupts
  179. */
  180. static void a20r_hwint(void)
  181. {
  182. u32 cause, status;
  183. int irq;
  184. clear_c0_status(IE_IRQ0);
  185. status = a20r_ack_hwint();
  186. cause = read_c0_cause();
  187. irq = ffs(((cause & status) >> 8) & 0xf8);
  188. if (likely(irq > 0))
  189. do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
  190. set_c0_status(IE_IRQ0);
  191. }
  192. void __init sni_a20r_irq_init(void)
  193. {
  194. int i;
  195. for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
  196. set_irq_chip_and_handler(i, &a20r_irq_type, handle_level_irq);
  197. sni_hwint = a20r_hwint;
  198. change_c0_status(ST0_IM, IE_IRQ0);
  199. setup_irq(SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
  200. }
  201. void sni_a20r_init(void)
  202. {
  203. /* FIXME, remove if not needed */
  204. }
  205. static int __init snirm_a20r_setup_devinit(void)
  206. {
  207. switch (sni_brd_type) {
  208. case SNI_BRD_TOWER_OASIC:
  209. case SNI_BRD_MINITOWER:
  210. platform_device_register(&snirm_82596_pdev);
  211. platform_device_register(&snirm_53c710_pdev);
  212. platform_device_register(&sc26xx_pdev);
  213. platform_device_register(&a20r_serial8250_device);
  214. platform_device_register(&a20r_ds1216_device);
  215. sni_eisa_root_init();
  216. break;
  217. }
  218. return 0;
  219. }
  220. device_initcall(snirm_a20r_setup_devinit);