setup-sh770x.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. #include <cpu/serial.h>
  23. enum {
  24. UNUSED = 0,
  25. /* interrupt sources */
  26. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  27. PINT07, PINT815,
  28. DMAC, SCIF0, SCIF2, SCI, ADC_ADI,
  29. LCDC, PCC0, PCC1,
  30. TMU0, TMU1, TMU2,
  31. RTC, WDT, REF,
  32. };
  33. static struct intc_vect vectors[] __initdata = {
  34. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  35. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  36. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  37. INTC_VECT(RTC, 0x4c0),
  38. INTC_VECT(SCI, 0x4e0), INTC_VECT(SCI, 0x500),
  39. INTC_VECT(SCI, 0x520), INTC_VECT(SCI, 0x540),
  40. INTC_VECT(WDT, 0x560),
  41. INTC_VECT(REF, 0x580),
  42. INTC_VECT(REF, 0x5a0),
  43. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  44. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  45. defined(CONFIG_CPU_SUBTYPE_SH7709)
  46. /* IRQ0->5 are handled in setup-sh3.c */
  47. INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
  48. INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
  49. INTC_VECT(ADC_ADI, 0x980),
  50. INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
  51. INTC_VECT(SCIF2, 0x940), INTC_VECT(SCIF2, 0x960),
  52. #endif
  53. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  54. defined(CONFIG_CPU_SUBTYPE_SH7709)
  55. INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
  56. INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
  57. INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
  58. #endif
  59. #if defined(CONFIG_CPU_SUBTYPE_SH7707)
  60. INTC_VECT(LCDC, 0x9a0),
  61. INTC_VECT(PCC0, 0x9c0), INTC_VECT(PCC1, 0x9e0),
  62. #endif
  63. };
  64. static struct intc_prio_reg prio_registers[] __initdata = {
  65. { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  66. { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, SCI, 0 } },
  67. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  68. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  69. defined(CONFIG_CPU_SUBTYPE_SH7709)
  70. { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  71. { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
  72. { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, 0, SCIF2, ADC_ADI } },
  73. #endif
  74. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  75. defined(CONFIG_CPU_SUBTYPE_SH7709)
  76. { 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, } },
  77. { 0xa400001a, 0, 16, 4, /* IPRE */ { 0, SCIF0 } },
  78. #endif
  79. #if defined(CONFIG_CPU_SUBTYPE_SH7707)
  80. { 0xa400001c, 0, 16, 4, /* IPRF */ { 0, LCDC, PCC0, PCC1, } },
  81. #endif
  82. };
  83. static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, NULL,
  84. NULL, prio_registers, NULL);
  85. static struct resource rtc_resources[] = {
  86. [0] = {
  87. .start = 0xfffffec0,
  88. .end = 0xfffffec0 + 0x1e,
  89. .flags = IORESOURCE_IO,
  90. },
  91. [1] = {
  92. .start = 20,
  93. .flags = IORESOURCE_IRQ,
  94. },
  95. };
  96. static struct platform_device rtc_device = {
  97. .name = "sh-rtc",
  98. .id = -1,
  99. .num_resources = ARRAY_SIZE(rtc_resources),
  100. .resource = rtc_resources,
  101. };
  102. static struct plat_sci_port scif0_platform_data = {
  103. .mapbase = 0xfffffe80,
  104. .port_reg = 0xa4000136,
  105. .flags = UPF_BOOT_AUTOCONF,
  106. .scscr = SCSCR_TE | SCSCR_RE,
  107. .scbrr_algo_id = SCBRR_ALGO_2,
  108. .type = PORT_SCI,
  109. .irqs = { 23, 23, 23, 0 },
  110. .ops = &sh770x_sci_port_ops,
  111. .regshift = 1,
  112. };
  113. static struct platform_device scif0_device = {
  114. .name = "sh-sci",
  115. .id = 0,
  116. .dev = {
  117. .platform_data = &scif0_platform_data,
  118. },
  119. };
  120. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  121. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  122. defined(CONFIG_CPU_SUBTYPE_SH7709)
  123. static struct plat_sci_port scif1_platform_data = {
  124. .mapbase = 0xa4000150,
  125. .flags = UPF_BOOT_AUTOCONF,
  126. .scscr = SCSCR_TE | SCSCR_RE,
  127. .scbrr_algo_id = SCBRR_ALGO_2,
  128. .type = PORT_SCIF,
  129. .irqs = { 56, 56, 56, 56 },
  130. .ops = &sh770x_sci_port_ops,
  131. .regtype = SCIx_SH3_SCIF_REGTYPE,
  132. };
  133. static struct platform_device scif1_device = {
  134. .name = "sh-sci",
  135. .id = 1,
  136. .dev = {
  137. .platform_data = &scif1_platform_data,
  138. },
  139. };
  140. #endif
  141. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  142. defined(CONFIG_CPU_SUBTYPE_SH7709)
  143. static struct plat_sci_port scif2_platform_data = {
  144. .mapbase = 0xa4000140,
  145. .port_reg = SCIx_NOT_SUPPORTED,
  146. .flags = UPF_BOOT_AUTOCONF,
  147. .scscr = SCSCR_TE | SCSCR_RE,
  148. .scbrr_algo_id = SCBRR_ALGO_2,
  149. .type = PORT_IRDA,
  150. .irqs = { 52, 52, 52, 52 },
  151. .ops = &sh770x_sci_port_ops,
  152. .regshift = 1,
  153. };
  154. static struct platform_device scif2_device = {
  155. .name = "sh-sci",
  156. .id = 2,
  157. .dev = {
  158. .platform_data = &scif2_platform_data,
  159. },
  160. };
  161. #endif
  162. static struct sh_timer_config tmu0_platform_data = {
  163. .channel_offset = 0x02,
  164. .timer_bit = 0,
  165. .clockevent_rating = 200,
  166. };
  167. static struct resource tmu0_resources[] = {
  168. [0] = {
  169. .start = 0xfffffe94,
  170. .end = 0xfffffe9f,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. [1] = {
  174. .start = 16,
  175. .flags = IORESOURCE_IRQ,
  176. },
  177. };
  178. static struct platform_device tmu0_device = {
  179. .name = "sh_tmu",
  180. .id = 0,
  181. .dev = {
  182. .platform_data = &tmu0_platform_data,
  183. },
  184. .resource = tmu0_resources,
  185. .num_resources = ARRAY_SIZE(tmu0_resources),
  186. };
  187. static struct sh_timer_config tmu1_platform_data = {
  188. .channel_offset = 0xe,
  189. .timer_bit = 1,
  190. .clocksource_rating = 200,
  191. };
  192. static struct resource tmu1_resources[] = {
  193. [0] = {
  194. .start = 0xfffffea0,
  195. .end = 0xfffffeab,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. [1] = {
  199. .start = 17,
  200. .flags = IORESOURCE_IRQ,
  201. },
  202. };
  203. static struct platform_device tmu1_device = {
  204. .name = "sh_tmu",
  205. .id = 1,
  206. .dev = {
  207. .platform_data = &tmu1_platform_data,
  208. },
  209. .resource = tmu1_resources,
  210. .num_resources = ARRAY_SIZE(tmu1_resources),
  211. };
  212. static struct sh_timer_config tmu2_platform_data = {
  213. .channel_offset = 0x1a,
  214. .timer_bit = 2,
  215. };
  216. static struct resource tmu2_resources[] = {
  217. [0] = {
  218. .start = 0xfffffeac,
  219. .end = 0xfffffebb,
  220. .flags = IORESOURCE_MEM,
  221. },
  222. [1] = {
  223. .start = 18,
  224. .flags = IORESOURCE_IRQ,
  225. },
  226. };
  227. static struct platform_device tmu2_device = {
  228. .name = "sh_tmu",
  229. .id = 2,
  230. .dev = {
  231. .platform_data = &tmu2_platform_data,
  232. },
  233. .resource = tmu2_resources,
  234. .num_resources = ARRAY_SIZE(tmu2_resources),
  235. };
  236. static struct platform_device *sh770x_devices[] __initdata = {
  237. &scif0_device,
  238. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  239. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  240. defined(CONFIG_CPU_SUBTYPE_SH7709)
  241. &scif1_device,
  242. #endif
  243. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  244. defined(CONFIG_CPU_SUBTYPE_SH7709)
  245. &scif2_device,
  246. #endif
  247. &tmu0_device,
  248. &tmu1_device,
  249. &tmu2_device,
  250. &rtc_device,
  251. };
  252. static int __init sh770x_devices_setup(void)
  253. {
  254. return platform_add_devices(sh770x_devices,
  255. ARRAY_SIZE(sh770x_devices));
  256. }
  257. arch_initcall(sh770x_devices_setup);
  258. static struct platform_device *sh770x_early_devices[] __initdata = {
  259. &scif0_device,
  260. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  261. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  262. defined(CONFIG_CPU_SUBTYPE_SH7709)
  263. &scif1_device,
  264. #endif
  265. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  266. defined(CONFIG_CPU_SUBTYPE_SH7709)
  267. &scif2_device,
  268. #endif
  269. &tmu0_device,
  270. &tmu1_device,
  271. &tmu2_device,
  272. };
  273. void __init plat_early_device_setup(void)
  274. {
  275. early_platform_add_devices(sh770x_early_devices,
  276. ARRAY_SIZE(sh770x_early_devices));
  277. }
  278. void __init plat_irq_setup(void)
  279. {
  280. register_intc_controller(&intc_desc);
  281. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  282. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  283. defined(CONFIG_CPU_SUBTYPE_SH7709)
  284. plat_irq_setup_sh3();
  285. #endif
  286. }