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. .mctrl_cfg[0] = MCTRL_SIG(DTR_OP, LINE_OP7) |
  112. MCTRL_SIG(RTS_OP, LINE_OP3) |
  113. MCTRL_SIG(DSR_IP, LINE_IP5) |
  114. MCTRL_SIG(DCD_IP, LINE_IP6),
  115. .mctrl_cfg[1] = MCTRL_SIG(DTR_OP, LINE_OP2) |
  116. MCTRL_SIG(RTS_OP, LINE_OP1) |
  117. MCTRL_SIG(DSR_IP, LINE_IP0) |
  118. MCTRL_SIG(CTS_IP, LINE_IP1) |
  119. MCTRL_SIG(DCD_IP, LINE_IP2) |
  120. MCTRL_SIG(RNG_IP, LINE_IP3),
  121. };
  122. static struct platform_device sc26xx_pdev = {
  123. .name = "sc2681",
  124. .resource = sc26xx_rsrc,
  125. .num_resources = ARRAY_SIZE(sc26xx_rsrc),
  126. .dev = {
  127. .platform_data = &sccnxp_data,
  128. },
  129. };
  130. static u32 a20r_ack_hwint(void)
  131. {
  132. u32 status = read_c0_status();
  133. write_c0_status(status | 0x00010000);
  134. asm volatile(
  135. " .set push \n"
  136. " .set noat \n"
  137. " .set noreorder \n"
  138. " lw $1, 0(%0) \n"
  139. " sb $0, 0(%1) \n"
  140. " sync \n"
  141. " lb %1, 0(%1) \n"
  142. " b 1f \n"
  143. " ori %1, $1, 2 \n"
  144. " .align 8 \n"
  145. "1: \n"
  146. " nop \n"
  147. " sw %1, 0(%0) \n"
  148. " sync \n"
  149. " li %1, 0x20 \n"
  150. "2: \n"
  151. " nop \n"
  152. " bnez %1,2b \n"
  153. " addiu %1, -1 \n"
  154. " sw $1, 0(%0) \n"
  155. " sync \n"
  156. ".set pop \n"
  157. :
  158. : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
  159. write_c0_status(status);
  160. return status;
  161. }
  162. static inline void unmask_a20r_irq(struct irq_data *d)
  163. {
  164. set_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
  165. irq_enable_hazard();
  166. }
  167. static inline void mask_a20r_irq(struct irq_data *d)
  168. {
  169. clear_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
  170. irq_disable_hazard();
  171. }
  172. static struct irq_chip a20r_irq_type = {
  173. .name = "A20R",
  174. .irq_mask = mask_a20r_irq,
  175. .irq_unmask = unmask_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. irq_set_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);