setup-sh7710.c 5.6 KB

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