a20r.c 5.0 KB

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