a20r.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 struct platform_device sc26xx_pdev = {
  108. .name = "SC26xx",
  109. .num_resources = ARRAY_SIZE(sc26xx_rsrc),
  110. .resource = sc26xx_rsrc
  111. };
  112. static u32 a20r_ack_hwint(void)
  113. {
  114. u32 status = read_c0_status();
  115. write_c0_status(status | 0x00010000);
  116. asm volatile(
  117. " .set push \n"
  118. " .set noat \n"
  119. " .set noreorder \n"
  120. " lw $1, 0(%0) \n"
  121. " sb $0, 0(%1) \n"
  122. " sync \n"
  123. " lb %1, 0(%1) \n"
  124. " b 1f \n"
  125. " ori %1, $1, 2 \n"
  126. " .align 8 \n"
  127. "1: \n"
  128. " nop \n"
  129. " sw %1, 0(%0) \n"
  130. " sync \n"
  131. " li %1, 0x20 \n"
  132. "2: \n"
  133. " nop \n"
  134. " bnez %1,2b \n"
  135. " addiu %1, -1 \n"
  136. " sw $1, 0(%0) \n"
  137. " sync \n"
  138. ".set pop \n"
  139. :
  140. : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
  141. write_c0_status(status);
  142. return status;
  143. }
  144. static inline void unmask_a20r_irq(unsigned int irq)
  145. {
  146. set_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
  147. irq_enable_hazard();
  148. }
  149. static inline void mask_a20r_irq(unsigned int irq)
  150. {
  151. clear_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
  152. irq_disable_hazard();
  153. }
  154. static void end_a20r_irq(unsigned int irq)
  155. {
  156. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
  157. a20r_ack_hwint();
  158. unmask_a20r_irq(irq);
  159. }
  160. }
  161. static struct irq_chip a20r_irq_type = {
  162. .typename = "A20R",
  163. .ack = mask_a20r_irq,
  164. .mask = mask_a20r_irq,
  165. .mask_ack = mask_a20r_irq,
  166. .unmask = unmask_a20r_irq,
  167. .end = end_a20r_irq,
  168. };
  169. /*
  170. * hwint 0 receive all interrupts
  171. */
  172. static void a20r_hwint(void)
  173. {
  174. u32 cause, status;
  175. int irq;
  176. clear_c0_status(IE_IRQ0);
  177. status = a20r_ack_hwint();
  178. cause = read_c0_cause();
  179. irq = ffs(((cause & status) >> 8) & 0xf8);
  180. if (likely(irq > 0))
  181. do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
  182. set_c0_status(IE_IRQ0);
  183. }
  184. void __init sni_a20r_irq_init(void)
  185. {
  186. int i;
  187. for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
  188. set_irq_chip(i, &a20r_irq_type);
  189. sni_hwint = a20r_hwint;
  190. change_c0_status(ST0_IM, IE_IRQ0);
  191. setup_irq(SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
  192. }
  193. void sni_a20r_init(void)
  194. {
  195. /* FIXME, remove if not needed */
  196. }
  197. static int __init snirm_a20r_setup_devinit(void)
  198. {
  199. switch (sni_brd_type) {
  200. case SNI_BRD_TOWER_OASIC:
  201. case SNI_BRD_MINITOWER:
  202. platform_device_register(&snirm_82596_pdev);
  203. platform_device_register(&snirm_53c710_pdev);
  204. platform_device_register(&sc26xx_pdev);
  205. platform_device_register(&a20r_serial8250_device);
  206. platform_device_register(&a20r_ds1216_device);
  207. break;
  208. }
  209. return 0;
  210. }
  211. device_initcall(snirm_a20r_setup_devinit);