setup-sh770x.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /*
  2. * SH3 Setup code for SH7706, SH7707, SH7708, SH7709
  3. *
  4. * Copyright (C) 2007 Magnus Damm
  5. * Copyright (C) 2009 Paul Mundt
  6. *
  7. * Based on setup-sh7709.c
  8. *
  9. * Copyright (C) 2006 Paul Mundt
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/io.h>
  17. #include <linux/irq.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/serial.h>
  20. #include <linux/serial_sci.h>
  21. #include <linux/sh_timer.h>
  22. enum {
  23. UNUSED = 0,
  24. /* interrupt sources */
  25. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  26. PINT07, PINT815,
  27. DMAC, SCIF0, SCIF2, SCI, ADC_ADI,
  28. LCDC, PCC0, PCC1,
  29. TMU0, TMU1, TMU2,
  30. RTC, WDT, REF,
  31. };
  32. static struct intc_vect vectors[] __initdata = {
  33. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  34. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  35. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  36. INTC_VECT(RTC, 0x4c0),
  37. INTC_VECT(SCI, 0x4e0), INTC_VECT(SCI, 0x500),
  38. INTC_VECT(SCI, 0x520), INTC_VECT(SCI, 0x540),
  39. INTC_VECT(WDT, 0x560),
  40. INTC_VECT(REF, 0x580),
  41. INTC_VECT(REF, 0x5a0),
  42. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  43. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  44. defined(CONFIG_CPU_SUBTYPE_SH7709)
  45. /* IRQ0->5 are handled in setup-sh3.c */
  46. INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
  47. INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
  48. INTC_VECT(ADC_ADI, 0x980),
  49. INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
  50. INTC_VECT(SCIF2, 0x940), INTC_VECT(SCIF2, 0x960),
  51. #endif
  52. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  53. defined(CONFIG_CPU_SUBTYPE_SH7709)
  54. INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
  55. INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
  56. INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
  57. #endif
  58. #if defined(CONFIG_CPU_SUBTYPE_SH7707)
  59. INTC_VECT(LCDC, 0x9a0),
  60. INTC_VECT(PCC0, 0x9c0), INTC_VECT(PCC1, 0x9e0),
  61. #endif
  62. };
  63. static struct intc_prio_reg prio_registers[] __initdata = {
  64. { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  65. { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, SCI, 0 } },
  66. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  67. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  68. defined(CONFIG_CPU_SUBTYPE_SH7709)
  69. { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  70. { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
  71. { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, 0, SCIF2, ADC_ADI } },
  72. #endif
  73. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  74. defined(CONFIG_CPU_SUBTYPE_SH7709)
  75. { 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, } },
  76. { 0xa400001a, 0, 16, 4, /* IPRE */ { 0, SCIF0 } },
  77. #endif
  78. #if defined(CONFIG_CPU_SUBTYPE_SH7707)
  79. { 0xa400001c, 0, 16, 4, /* IPRF */ { 0, LCDC, PCC0, PCC1, } },
  80. #endif
  81. };
  82. static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, NULL,
  83. NULL, prio_registers, NULL);
  84. static struct resource rtc_resources[] = {
  85. [0] = {
  86. .start = 0xfffffec0,
  87. .end = 0xfffffec0 + 0x1e,
  88. .flags = IORESOURCE_IO,
  89. },
  90. [1] = {
  91. .start = 20,
  92. .flags = IORESOURCE_IRQ,
  93. },
  94. };
  95. static struct platform_device rtc_device = {
  96. .name = "sh-rtc",
  97. .id = -1,
  98. .num_resources = ARRAY_SIZE(rtc_resources),
  99. .resource = rtc_resources,
  100. };
  101. static struct plat_sci_port sci_platform_data[] = {
  102. {
  103. .mapbase = 0xfffffe80,
  104. .flags = UPF_BOOT_AUTOCONF,
  105. .scscr = SCSCR_TE | SCSCR_RE,
  106. .type = PORT_SCI,
  107. .irqs = { 23, 23, 23, 0 },
  108. },
  109. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  110. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  111. defined(CONFIG_CPU_SUBTYPE_SH7709)
  112. {
  113. .mapbase = 0xa4000150,
  114. .flags = UPF_BOOT_AUTOCONF,
  115. .scscr = SCSCR_TE | SCSCR_RE,
  116. .type = PORT_SCIF,
  117. .irqs = { 56, 56, 56, 56 },
  118. },
  119. #endif
  120. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  121. defined(CONFIG_CPU_SUBTYPE_SH7709)
  122. {
  123. .mapbase = 0xa4000140,
  124. .flags = UPF_BOOT_AUTOCONF,
  125. .scscr = SCSCR_TE | SCSCR_RE,
  126. .type = PORT_IRDA,
  127. .irqs = { 52, 52, 52, 52 },
  128. },
  129. #endif
  130. {
  131. .flags = 0,
  132. }
  133. };
  134. static struct platform_device sci_device = {
  135. .name = "sh-sci",
  136. .id = -1,
  137. .dev = {
  138. .platform_data = sci_platform_data,
  139. },
  140. };
  141. static struct sh_timer_config tmu0_platform_data = {
  142. .name = "TMU0",
  143. .channel_offset = 0x02,
  144. .timer_bit = 0,
  145. .clk = "peripheral_clk",
  146. .clockevent_rating = 200,
  147. };
  148. static struct resource tmu0_resources[] = {
  149. [0] = {
  150. .name = "TMU0",
  151. .start = 0xfffffe94,
  152. .end = 0xfffffe9f,
  153. .flags = IORESOURCE_MEM,
  154. },
  155. [1] = {
  156. .start = 16,
  157. .flags = IORESOURCE_IRQ,
  158. },
  159. };
  160. static struct platform_device tmu0_device = {
  161. .name = "sh_tmu",
  162. .id = 0,
  163. .dev = {
  164. .platform_data = &tmu0_platform_data,
  165. },
  166. .resource = tmu0_resources,
  167. .num_resources = ARRAY_SIZE(tmu0_resources),
  168. };
  169. static struct sh_timer_config tmu1_platform_data = {
  170. .name = "TMU1",
  171. .channel_offset = 0xe,
  172. .timer_bit = 1,
  173. .clk = "peripheral_clk",
  174. .clocksource_rating = 200,
  175. };
  176. static struct resource tmu1_resources[] = {
  177. [0] = {
  178. .name = "TMU1",
  179. .start = 0xfffffea0,
  180. .end = 0xfffffeab,
  181. .flags = IORESOURCE_MEM,
  182. },
  183. [1] = {
  184. .start = 17,
  185. .flags = IORESOURCE_IRQ,
  186. },
  187. };
  188. static struct platform_device tmu1_device = {
  189. .name = "sh_tmu",
  190. .id = 1,
  191. .dev = {
  192. .platform_data = &tmu1_platform_data,
  193. },
  194. .resource = tmu1_resources,
  195. .num_resources = ARRAY_SIZE(tmu1_resources),
  196. };
  197. static struct sh_timer_config tmu2_platform_data = {
  198. .name = "TMU2",
  199. .channel_offset = 0x1a,
  200. .timer_bit = 2,
  201. .clk = "peripheral_clk",
  202. };
  203. static struct resource tmu2_resources[] = {
  204. [0] = {
  205. .name = "TMU2",
  206. .start = 0xfffffeac,
  207. .end = 0xfffffebb,
  208. .flags = IORESOURCE_MEM,
  209. },
  210. [1] = {
  211. .start = 18,
  212. .flags = IORESOURCE_IRQ,
  213. },
  214. };
  215. static struct platform_device tmu2_device = {
  216. .name = "sh_tmu",
  217. .id = 2,
  218. .dev = {
  219. .platform_data = &tmu2_platform_data,
  220. },
  221. .resource = tmu2_resources,
  222. .num_resources = ARRAY_SIZE(tmu2_resources),
  223. };
  224. static struct platform_device *sh770x_devices[] __initdata = {
  225. &tmu0_device,
  226. &tmu1_device,
  227. &tmu2_device,
  228. &sci_device,
  229. &rtc_device,
  230. };
  231. static int __init sh770x_devices_setup(void)
  232. {
  233. return platform_add_devices(sh770x_devices,
  234. ARRAY_SIZE(sh770x_devices));
  235. }
  236. __initcall(sh770x_devices_setup);
  237. static struct platform_device *sh770x_early_devices[] __initdata = {
  238. &tmu0_device,
  239. &tmu1_device,
  240. &tmu2_device,
  241. };
  242. void __init plat_early_device_setup(void)
  243. {
  244. early_platform_add_devices(sh770x_early_devices,
  245. ARRAY_SIZE(sh770x_early_devices));
  246. }
  247. void __init plat_irq_setup(void)
  248. {
  249. register_intc_controller(&intc_desc);
  250. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  251. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  252. defined(CONFIG_CPU_SUBTYPE_SH7709)
  253. plat_irq_setup_sh3();
  254. #endif
  255. }