setup-sh770x.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 scif0_platform_data = {
  102. .mapbase = 0xfffffe80,
  103. .flags = UPF_BOOT_AUTOCONF,
  104. .type = PORT_SCI,
  105. .irqs = { 23, 23, 23, 0 },
  106. };
  107. static struct platform_device scif0_device = {
  108. .name = "sh-sci",
  109. .id = 0,
  110. .dev = {
  111. .platform_data = &scif0_platform_data,
  112. },
  113. };
  114. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  115. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  116. defined(CONFIG_CPU_SUBTYPE_SH7709)
  117. static struct plat_sci_port scif1_platform_data = {
  118. .mapbase = 0xa4000150,
  119. .flags = UPF_BOOT_AUTOCONF,
  120. .type = PORT_SCIF,
  121. .irqs = { 56, 56, 56, 56 },
  122. };
  123. static struct platform_device scif1_device = {
  124. .name = "sh-sci",
  125. .id = 1,
  126. .dev = {
  127. .platform_data = &scif1_platform_data,
  128. },
  129. };
  130. #endif
  131. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  132. defined(CONFIG_CPU_SUBTYPE_SH7709)
  133. static struct plat_sci_port scif2_platform_data = {
  134. .mapbase = 0xa4000140,
  135. .flags = UPF_BOOT_AUTOCONF,
  136. .type = PORT_IRDA,
  137. .irqs = { 52, 52, 52, 52 },
  138. };
  139. static struct platform_device scif2_device = {
  140. .name = "sh-sci",
  141. .id = 2,
  142. .dev = {
  143. .platform_data = &scif2_platform_data,
  144. },
  145. };
  146. #endif
  147. static struct sh_timer_config tmu0_platform_data = {
  148. .channel_offset = 0x02,
  149. .timer_bit = 0,
  150. .clockevent_rating = 200,
  151. };
  152. static struct resource tmu0_resources[] = {
  153. [0] = {
  154. .start = 0xfffffe94,
  155. .end = 0xfffffe9f,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. [1] = {
  159. .start = 16,
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device tmu0_device = {
  164. .name = "sh_tmu",
  165. .id = 0,
  166. .dev = {
  167. .platform_data = &tmu0_platform_data,
  168. },
  169. .resource = tmu0_resources,
  170. .num_resources = ARRAY_SIZE(tmu0_resources),
  171. };
  172. static struct sh_timer_config tmu1_platform_data = {
  173. .channel_offset = 0xe,
  174. .timer_bit = 1,
  175. .clocksource_rating = 200,
  176. };
  177. static struct resource tmu1_resources[] = {
  178. [0] = {
  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. .channel_offset = 0x1a,
  199. .timer_bit = 2,
  200. };
  201. static struct resource tmu2_resources[] = {
  202. [0] = {
  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. &scif0_device,
  223. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  224. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  225. defined(CONFIG_CPU_SUBTYPE_SH7709)
  226. &scif1_device,
  227. #endif
  228. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  229. defined(CONFIG_CPU_SUBTYPE_SH7709)
  230. &scif2_device,
  231. #endif
  232. &tmu0_device,
  233. &tmu1_device,
  234. &tmu2_device,
  235. &rtc_device,
  236. };
  237. static int __init sh770x_devices_setup(void)
  238. {
  239. return platform_add_devices(sh770x_devices,
  240. ARRAY_SIZE(sh770x_devices));
  241. }
  242. arch_initcall(sh770x_devices_setup);
  243. static struct platform_device *sh770x_early_devices[] __initdata = {
  244. &scif0_device,
  245. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  246. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  247. defined(CONFIG_CPU_SUBTYPE_SH7709)
  248. &scif1_device,
  249. #endif
  250. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  251. defined(CONFIG_CPU_SUBTYPE_SH7709)
  252. &scif2_device,
  253. #endif
  254. &tmu0_device,
  255. &tmu1_device,
  256. &tmu2_device,
  257. };
  258. void __init plat_early_device_setup(void)
  259. {
  260. early_platform_add_devices(sh770x_early_devices,
  261. ARRAY_SIZE(sh770x_early_devices));
  262. }
  263. void __init plat_irq_setup(void)
  264. {
  265. register_intc_controller(&intc_desc);
  266. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  267. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  268. defined(CONFIG_CPU_SUBTYPE_SH7709)
  269. plat_irq_setup_sh3();
  270. #endif
  271. }