setup-sh7710.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * SH3 Setup code for SH7710, SH7712
  3. *
  4. * Copyright (C) 2006 - 2009 Paul Mundt
  5. * Copyright (C) 2007 Nobuhiro Iwamatsu
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <linux/serial.h>
  15. #include <linux/serial_sci.h>
  16. #include <linux/sh_timer.h>
  17. #include <linux/sh_intc.h>
  18. #include <asm/rtc.h>
  19. enum {
  20. UNUSED = 0,
  21. /* interrupt sources */
  22. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  23. DMAC1, SCIF0, SCIF1, DMAC2, IPSEC,
  24. EDMAC0, EDMAC1, EDMAC2,
  25. SIOF0, SIOF1,
  26. TMU0, TMU1, TMU2,
  27. RTC, WDT, REF,
  28. };
  29. static struct intc_vect vectors[] __initdata = {
  30. /* IRQ0->5 are handled in setup-sh3.c */
  31. INTC_VECT(DMAC1, 0x800), INTC_VECT(DMAC1, 0x820),
  32. INTC_VECT(DMAC1, 0x840), INTC_VECT(DMAC1, 0x860),
  33. INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
  34. INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
  35. INTC_VECT(SCIF1, 0x900), INTC_VECT(SCIF1, 0x920),
  36. INTC_VECT(SCIF1, 0x940), INTC_VECT(SCIF1, 0x960),
  37. INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
  38. #ifdef CONFIG_CPU_SUBTYPE_SH7710
  39. INTC_VECT(IPSEC, 0xbe0),
  40. #endif
  41. INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20),
  42. INTC_VECT(EDMAC2, 0xc40),
  43. INTC_VECT(SIOF0, 0xe00), INTC_VECT(SIOF0, 0xe20),
  44. INTC_VECT(SIOF0, 0xe40), INTC_VECT(SIOF0, 0xe60),
  45. INTC_VECT(SIOF1, 0xe80), INTC_VECT(SIOF1, 0xea0),
  46. INTC_VECT(SIOF1, 0xec0), INTC_VECT(SIOF1, 0xee0),
  47. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  48. INTC_VECT(TMU2, 0x440),
  49. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  50. INTC_VECT(RTC, 0x4c0),
  51. INTC_VECT(WDT, 0x560),
  52. INTC_VECT(REF, 0x580),
  53. };
  54. static struct intc_prio_reg prio_registers[] __initdata = {
  55. { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  56. { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } },
  57. { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  58. { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
  59. { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } },
  60. { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } },
  61. { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } },
  62. { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } },
  63. { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } },
  64. };
  65. static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, NULL,
  66. NULL, prio_registers, NULL);
  67. static struct resource rtc_resources[] = {
  68. [0] = {
  69. .start = 0xa413fec0,
  70. .end = 0xa413fec0 + 0x1e,
  71. .flags = IORESOURCE_IO,
  72. },
  73. [1] = {
  74. .start = evt2irq(0x480),
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. static struct sh_rtc_platform_info rtc_info = {
  79. .capabilities = RTC_CAP_4_DIGIT_YEAR,
  80. };
  81. static struct platform_device rtc_device = {
  82. .name = "sh-rtc",
  83. .id = -1,
  84. .num_resources = ARRAY_SIZE(rtc_resources),
  85. .resource = rtc_resources,
  86. .dev = {
  87. .platform_data = &rtc_info,
  88. },
  89. };
  90. static struct plat_sci_port scif0_platform_data = {
  91. .mapbase = 0xa4400000,
  92. .flags = UPF_BOOT_AUTOCONF,
  93. .scscr = SCSCR_TE | SCSCR_RE | SCSCR_REIE |
  94. SCSCR_CKE1 | SCSCR_CKE0,
  95. .scbrr_algo_id = SCBRR_ALGO_2,
  96. .type = PORT_SCIF,
  97. .irqs = SCIx_IRQ_MUXED(evt2irq(0x880)),
  98. };
  99. static struct platform_device scif0_device = {
  100. .name = "sh-sci",
  101. .id = 0,
  102. .dev = {
  103. .platform_data = &scif0_platform_data,
  104. },
  105. };
  106. static struct plat_sci_port scif1_platform_data = {
  107. .mapbase = 0xa4410000,
  108. .flags = UPF_BOOT_AUTOCONF,
  109. .scscr = SCSCR_TE | SCSCR_RE | SCSCR_REIE |
  110. SCSCR_CKE1 | SCSCR_CKE0,
  111. .scbrr_algo_id = SCBRR_ALGO_2,
  112. .type = PORT_SCIF,
  113. .irqs = SCIx_IRQ_MUXED(evt2irq(0x900)),
  114. };
  115. static struct platform_device scif1_device = {
  116. .name = "sh-sci",
  117. .id = 1,
  118. .dev = {
  119. .platform_data = &scif1_platform_data,
  120. },
  121. };
  122. static struct sh_timer_config tmu0_platform_data = {
  123. .channel_offset = 0x02,
  124. .timer_bit = 0,
  125. .clockevent_rating = 200,
  126. };
  127. static struct resource tmu0_resources[] = {
  128. [0] = {
  129. .start = 0xa412fe94,
  130. .end = 0xa412fe9f,
  131. .flags = IORESOURCE_MEM,
  132. },
  133. [1] = {
  134. .start = evt2irq(0x400),
  135. .flags = IORESOURCE_IRQ,
  136. },
  137. };
  138. static struct platform_device tmu0_device = {
  139. .name = "sh_tmu",
  140. .id = 0,
  141. .dev = {
  142. .platform_data = &tmu0_platform_data,
  143. },
  144. .resource = tmu0_resources,
  145. .num_resources = ARRAY_SIZE(tmu0_resources),
  146. };
  147. static struct sh_timer_config tmu1_platform_data = {
  148. .channel_offset = 0xe,
  149. .timer_bit = 1,
  150. .clocksource_rating = 200,
  151. };
  152. static struct resource tmu1_resources[] = {
  153. [0] = {
  154. .start = 0xa412fea0,
  155. .end = 0xa412feab,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. [1] = {
  159. .start = evt2irq(0x420),
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device tmu1_device = {
  164. .name = "sh_tmu",
  165. .id = 1,
  166. .dev = {
  167. .platform_data = &tmu1_platform_data,
  168. },
  169. .resource = tmu1_resources,
  170. .num_resources = ARRAY_SIZE(tmu1_resources),
  171. };
  172. static struct sh_timer_config tmu2_platform_data = {
  173. .channel_offset = 0x1a,
  174. .timer_bit = 2,
  175. };
  176. static struct resource tmu2_resources[] = {
  177. [0] = {
  178. .start = 0xa412feac,
  179. .end = 0xa412feb5,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. [1] = {
  183. .start = evt2irq(0x440),
  184. .flags = IORESOURCE_IRQ,
  185. },
  186. };
  187. static struct platform_device tmu2_device = {
  188. .name = "sh_tmu",
  189. .id = 2,
  190. .dev = {
  191. .platform_data = &tmu2_platform_data,
  192. },
  193. .resource = tmu2_resources,
  194. .num_resources = ARRAY_SIZE(tmu2_resources),
  195. };
  196. static struct platform_device *sh7710_devices[] __initdata = {
  197. &scif0_device,
  198. &scif1_device,
  199. &tmu0_device,
  200. &tmu1_device,
  201. &tmu2_device,
  202. &rtc_device,
  203. };
  204. static int __init sh7710_devices_setup(void)
  205. {
  206. return platform_add_devices(sh7710_devices,
  207. ARRAY_SIZE(sh7710_devices));
  208. }
  209. arch_initcall(sh7710_devices_setup);
  210. static struct platform_device *sh7710_early_devices[] __initdata = {
  211. &scif0_device,
  212. &scif1_device,
  213. &tmu0_device,
  214. &tmu1_device,
  215. &tmu2_device,
  216. };
  217. void __init plat_early_device_setup(void)
  218. {
  219. early_platform_add_devices(sh7710_early_devices,
  220. ARRAY_SIZE(sh7710_early_devices));
  221. }
  222. void __init plat_irq_setup(void)
  223. {
  224. register_intc_controller(&intc_desc);
  225. plat_irq_setup_sh3();
  226. }