setup-sh770x.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. .type = PORT_SCI,
  106. .irqs = { 23, 23, 23, 0 },
  107. },
  108. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  109. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  110. defined(CONFIG_CPU_SUBTYPE_SH7709)
  111. {
  112. .mapbase = 0xa4000150,
  113. .flags = UPF_BOOT_AUTOCONF,
  114. .type = PORT_SCIF,
  115. .irqs = { 56, 56, 56, 56 },
  116. },
  117. #endif
  118. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  119. defined(CONFIG_CPU_SUBTYPE_SH7709)
  120. {
  121. .mapbase = 0xa4000140,
  122. .flags = UPF_BOOT_AUTOCONF,
  123. .type = PORT_IRDA,
  124. .irqs = { 52, 52, 52, 52 },
  125. },
  126. #endif
  127. {
  128. .flags = 0,
  129. }
  130. };
  131. static struct platform_device sci_device = {
  132. .name = "sh-sci",
  133. .id = -1,
  134. .dev = {
  135. .platform_data = sci_platform_data,
  136. },
  137. };
  138. static struct sh_timer_config tmu0_platform_data = {
  139. .name = "TMU0",
  140. .channel_offset = 0x02,
  141. .timer_bit = 0,
  142. .clk = "peripheral_clk",
  143. .clockevent_rating = 200,
  144. };
  145. static struct resource tmu0_resources[] = {
  146. [0] = {
  147. .name = "TMU0",
  148. .start = 0xfffffe94,
  149. .end = 0xfffffe9f,
  150. .flags = IORESOURCE_MEM,
  151. },
  152. [1] = {
  153. .start = 16,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. };
  157. static struct platform_device tmu0_device = {
  158. .name = "sh_tmu",
  159. .id = 0,
  160. .dev = {
  161. .platform_data = &tmu0_platform_data,
  162. },
  163. .resource = tmu0_resources,
  164. .num_resources = ARRAY_SIZE(tmu0_resources),
  165. };
  166. static struct sh_timer_config tmu1_platform_data = {
  167. .name = "TMU1",
  168. .channel_offset = 0xe,
  169. .timer_bit = 1,
  170. .clk = "peripheral_clk",
  171. .clocksource_rating = 200,
  172. };
  173. static struct resource tmu1_resources[] = {
  174. [0] = {
  175. .name = "TMU1",
  176. .start = 0xfffffea0,
  177. .end = 0xfffffeab,
  178. .flags = IORESOURCE_MEM,
  179. },
  180. [1] = {
  181. .start = 17,
  182. .flags = IORESOURCE_IRQ,
  183. },
  184. };
  185. static struct platform_device tmu1_device = {
  186. .name = "sh_tmu",
  187. .id = 1,
  188. .dev = {
  189. .platform_data = &tmu1_platform_data,
  190. },
  191. .resource = tmu1_resources,
  192. .num_resources = ARRAY_SIZE(tmu1_resources),
  193. };
  194. static struct sh_timer_config tmu2_platform_data = {
  195. .name = "TMU2",
  196. .channel_offset = 0x1a,
  197. .timer_bit = 2,
  198. .clk = "peripheral_clk",
  199. };
  200. static struct resource tmu2_resources[] = {
  201. [0] = {
  202. .name = "TMU2",
  203. .start = 0xfffffeac,
  204. .end = 0xfffffebb,
  205. .flags = IORESOURCE_MEM,
  206. },
  207. [1] = {
  208. .start = 18,
  209. .flags = IORESOURCE_IRQ,
  210. },
  211. };
  212. static struct platform_device tmu2_device = {
  213. .name = "sh_tmu",
  214. .id = 2,
  215. .dev = {
  216. .platform_data = &tmu2_platform_data,
  217. },
  218. .resource = tmu2_resources,
  219. .num_resources = ARRAY_SIZE(tmu2_resources),
  220. };
  221. static struct platform_device *sh770x_devices[] __initdata = {
  222. &tmu0_device,
  223. &tmu1_device,
  224. &tmu2_device,
  225. &sci_device,
  226. &rtc_device,
  227. };
  228. static int __init sh770x_devices_setup(void)
  229. {
  230. return platform_add_devices(sh770x_devices,
  231. ARRAY_SIZE(sh770x_devices));
  232. }
  233. arch_initcall(sh770x_devices_setup);
  234. static struct platform_device *sh770x_early_devices[] __initdata = {
  235. &tmu0_device,
  236. &tmu1_device,
  237. &tmu2_device,
  238. };
  239. void __init plat_early_device_setup(void)
  240. {
  241. early_platform_add_devices(sh770x_early_devices,
  242. ARRAY_SIZE(sh770x_early_devices));
  243. }
  244. void __init plat_irq_setup(void)
  245. {
  246. register_intc_controller(&intc_desc);
  247. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  248. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  249. defined(CONFIG_CPU_SUBTYPE_SH7709)
  250. plat_irq_setup_sh3();
  251. #endif
  252. }