setup-sh7206.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * SH7206 Setup
  3. *
  4. * Copyright (C) 2006 Yoshinori Sato
  5. * Copyright (C) 2009 Paul Mundt
  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/serial.h>
  14. #include <linux/serial_sci.h>
  15. #include <linux/sh_timer.h>
  16. #include <linux/io.h>
  17. enum {
  18. UNUSED = 0,
  19. /* interrupt sources */
  20. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  21. PINT0, PINT1, PINT2, PINT3, PINT4, PINT5, PINT6, PINT7,
  22. ADC_ADI0, ADC_ADI1,
  23. DMAC0, DMAC1, DMAC2, DMAC3, DMAC4, DMAC5, DMAC6, DMAC7,
  24. MTU0_ABCD, MTU0_VEF, MTU1_AB, MTU1_VU, MTU2_AB, MTU2_VU,
  25. MTU3_ABCD, MTU4_ABCD, MTU5, POE2_12, MTU3S_ABCD, MTU4S_ABCD, MTU5S,
  26. IIC3,
  27. CMT0, CMT1, BSC, WDT,
  28. MTU2_TCI3V, MTU2_TCI4V, MTU2S_TCI3V, MTU2S_TCI4V,
  29. POE2_OEI3,
  30. SCIF0, SCIF1, SCIF2, SCIF3,
  31. /* interrupt groups */
  32. PINT,
  33. };
  34. static struct intc_vect vectors[] __initdata = {
  35. INTC_IRQ(IRQ0, 64), INTC_IRQ(IRQ1, 65),
  36. INTC_IRQ(IRQ2, 66), INTC_IRQ(IRQ3, 67),
  37. INTC_IRQ(IRQ4, 68), INTC_IRQ(IRQ5, 69),
  38. INTC_IRQ(IRQ6, 70), INTC_IRQ(IRQ7, 71),
  39. INTC_IRQ(PINT0, 80), INTC_IRQ(PINT1, 81),
  40. INTC_IRQ(PINT2, 82), INTC_IRQ(PINT3, 83),
  41. INTC_IRQ(PINT4, 84), INTC_IRQ(PINT5, 85),
  42. INTC_IRQ(PINT6, 86), INTC_IRQ(PINT7, 87),
  43. INTC_IRQ(ADC_ADI0, 92), INTC_IRQ(ADC_ADI1, 96),
  44. INTC_IRQ(DMAC0, 108), INTC_IRQ(DMAC0, 109),
  45. INTC_IRQ(DMAC1, 112), INTC_IRQ(DMAC1, 113),
  46. INTC_IRQ(DMAC2, 116), INTC_IRQ(DMAC2, 117),
  47. INTC_IRQ(DMAC3, 120), INTC_IRQ(DMAC3, 121),
  48. INTC_IRQ(DMAC4, 124), INTC_IRQ(DMAC4, 125),
  49. INTC_IRQ(DMAC5, 128), INTC_IRQ(DMAC5, 129),
  50. INTC_IRQ(DMAC6, 132), INTC_IRQ(DMAC6, 133),
  51. INTC_IRQ(DMAC7, 136), INTC_IRQ(DMAC7, 137),
  52. INTC_IRQ(CMT0, 140), INTC_IRQ(CMT1, 144),
  53. INTC_IRQ(BSC, 148), INTC_IRQ(WDT, 152),
  54. INTC_IRQ(MTU0_ABCD, 156), INTC_IRQ(MTU0_ABCD, 157),
  55. INTC_IRQ(MTU0_ABCD, 158), INTC_IRQ(MTU0_ABCD, 159),
  56. INTC_IRQ(MTU0_VEF, 160), INTC_IRQ(MTU0_VEF, 161),
  57. INTC_IRQ(MTU0_VEF, 162),
  58. INTC_IRQ(MTU1_AB, 164), INTC_IRQ(MTU1_AB, 165),
  59. INTC_IRQ(MTU1_VU, 168), INTC_IRQ(MTU1_VU, 169),
  60. INTC_IRQ(MTU2_AB, 172), INTC_IRQ(MTU2_AB, 173),
  61. INTC_IRQ(MTU2_VU, 176), INTC_IRQ(MTU2_VU, 177),
  62. INTC_IRQ(MTU3_ABCD, 180), INTC_IRQ(MTU3_ABCD, 181),
  63. INTC_IRQ(MTU3_ABCD, 182), INTC_IRQ(MTU3_ABCD, 183),
  64. INTC_IRQ(MTU2_TCI3V, 184),
  65. INTC_IRQ(MTU4_ABCD, 188), INTC_IRQ(MTU4_ABCD, 189),
  66. INTC_IRQ(MTU4_ABCD, 190), INTC_IRQ(MTU4_ABCD, 191),
  67. INTC_IRQ(MTU2_TCI4V, 192),
  68. INTC_IRQ(MTU5, 196), INTC_IRQ(MTU5, 197),
  69. INTC_IRQ(MTU5, 198),
  70. INTC_IRQ(POE2_12, 200), INTC_IRQ(POE2_12, 201),
  71. INTC_IRQ(MTU3S_ABCD, 204), INTC_IRQ(MTU3S_ABCD, 205),
  72. INTC_IRQ(MTU3S_ABCD, 206), INTC_IRQ(MTU3S_ABCD, 207),
  73. INTC_IRQ(MTU2S_TCI3V, 208),
  74. INTC_IRQ(MTU4S_ABCD, 212), INTC_IRQ(MTU4S_ABCD, 213),
  75. INTC_IRQ(MTU4S_ABCD, 214), INTC_IRQ(MTU4S_ABCD, 215),
  76. INTC_IRQ(MTU2S_TCI4V, 216),
  77. INTC_IRQ(MTU5S, 220), INTC_IRQ(MTU5S, 221),
  78. INTC_IRQ(MTU5S, 222),
  79. INTC_IRQ(POE2_OEI3, 224),
  80. INTC_IRQ(IIC3, 228), INTC_IRQ(IIC3, 229),
  81. INTC_IRQ(IIC3, 230), INTC_IRQ(IIC3, 231),
  82. INTC_IRQ(IIC3, 232),
  83. INTC_IRQ(SCIF0, 240), INTC_IRQ(SCIF0, 241),
  84. INTC_IRQ(SCIF0, 242), INTC_IRQ(SCIF0, 243),
  85. INTC_IRQ(SCIF1, 244), INTC_IRQ(SCIF1, 245),
  86. INTC_IRQ(SCIF1, 246), INTC_IRQ(SCIF1, 247),
  87. INTC_IRQ(SCIF2, 248), INTC_IRQ(SCIF2, 249),
  88. INTC_IRQ(SCIF2, 250), INTC_IRQ(SCIF2, 251),
  89. INTC_IRQ(SCIF3, 252), INTC_IRQ(SCIF3, 253),
  90. INTC_IRQ(SCIF3, 254), INTC_IRQ(SCIF3, 255),
  91. };
  92. static struct intc_group groups[] __initdata = {
  93. INTC_GROUP(PINT, PINT0, PINT1, PINT2, PINT3,
  94. PINT4, PINT5, PINT6, PINT7),
  95. };
  96. static struct intc_prio_reg prio_registers[] __initdata = {
  97. { 0xfffe0818, 0, 16, 4, /* IPR01 */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  98. { 0xfffe081a, 0, 16, 4, /* IPR02 */ { IRQ4, IRQ5, IRQ6, IRQ7 } },
  99. { 0xfffe0820, 0, 16, 4, /* IPR05 */ { PINT, 0, ADC_ADI0, ADC_ADI1 } },
  100. { 0xfffe0c00, 0, 16, 4, /* IPR06 */ { DMAC0, DMAC1, DMAC2, DMAC3 } },
  101. { 0xfffe0c02, 0, 16, 4, /* IPR07 */ { DMAC4, DMAC5, DMAC6, DMAC7 } },
  102. { 0xfffe0c04, 0, 16, 4, /* IPR08 */ { CMT0, CMT1, BSC, WDT } },
  103. { 0xfffe0c06, 0, 16, 4, /* IPR09 */ { MTU0_ABCD, MTU0_VEF,
  104. MTU1_AB, MTU1_VU } },
  105. { 0xfffe0c08, 0, 16, 4, /* IPR10 */ { MTU2_AB, MTU2_VU,
  106. MTU3_ABCD, MTU2_TCI3V } },
  107. { 0xfffe0c0a, 0, 16, 4, /* IPR11 */ { MTU4_ABCD, MTU2_TCI4V,
  108. MTU5, POE2_12 } },
  109. { 0xfffe0c0c, 0, 16, 4, /* IPR12 */ { MTU3S_ABCD, MTU2S_TCI3V,
  110. MTU4S_ABCD, MTU2S_TCI4V } },
  111. { 0xfffe0c0e, 0, 16, 4, /* IPR13 */ { MTU5S, POE2_OEI3, IIC3, 0 } },
  112. { 0xfffe0c10, 0, 16, 4, /* IPR14 */ { SCIF0, SCIF1, SCIF2, SCIF3 } },
  113. };
  114. static struct intc_mask_reg mask_registers[] __initdata = {
  115. { 0xfffe0808, 0, 16, /* PINTER */
  116. { 0, 0, 0, 0, 0, 0, 0, 0,
  117. PINT7, PINT6, PINT5, PINT4, PINT3, PINT2, PINT1, PINT0 } },
  118. };
  119. static DECLARE_INTC_DESC(intc_desc, "sh7206", vectors, groups,
  120. mask_registers, prio_registers, NULL);
  121. static struct plat_sci_port scif0_platform_data = {
  122. .flags = UPF_BOOT_AUTOCONF,
  123. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  124. .type = PORT_SCIF,
  125. };
  126. static struct resource scif0_resources[] = {
  127. DEFINE_RES_MEM(0xfffe8000, 0x100),
  128. DEFINE_RES_IRQ(240),
  129. };
  130. static struct platform_device scif0_device = {
  131. .name = "sh-sci",
  132. .id = 0,
  133. .resource = scif0_resources,
  134. .num_resources = ARRAY_SIZE(scif0_resources),
  135. .dev = {
  136. .platform_data = &scif0_platform_data,
  137. },
  138. };
  139. static struct plat_sci_port scif1_platform_data = {
  140. .flags = UPF_BOOT_AUTOCONF,
  141. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  142. .type = PORT_SCIF,
  143. };
  144. static struct resource scif1_resources[] = {
  145. DEFINE_RES_MEM(0xfffe8800, 0x100),
  146. DEFINE_RES_IRQ(244),
  147. };
  148. static struct platform_device scif1_device = {
  149. .name = "sh-sci",
  150. .id = 1,
  151. .resource = scif1_resources,
  152. .num_resources = ARRAY_SIZE(scif1_resources),
  153. .dev = {
  154. .platform_data = &scif1_platform_data,
  155. },
  156. };
  157. static struct plat_sci_port scif2_platform_data = {
  158. .flags = UPF_BOOT_AUTOCONF,
  159. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  160. .type = PORT_SCIF,
  161. };
  162. static struct resource scif2_resources[] = {
  163. DEFINE_RES_MEM(0xfffe9000, 0x100),
  164. DEFINE_RES_IRQ(248),
  165. };
  166. static struct platform_device scif2_device = {
  167. .name = "sh-sci",
  168. .id = 2,
  169. .resource = scif2_resources,
  170. .num_resources = ARRAY_SIZE(scif2_resources),
  171. .dev = {
  172. .platform_data = &scif2_platform_data,
  173. },
  174. };
  175. static struct plat_sci_port scif3_platform_data = {
  176. .flags = UPF_BOOT_AUTOCONF,
  177. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  178. .type = PORT_SCIF,
  179. };
  180. static struct resource scif3_resources[] = {
  181. DEFINE_RES_MEM(0xfffe9800, 0x100),
  182. DEFINE_RES_IRQ(252),
  183. };
  184. static struct platform_device scif3_device = {
  185. .name = "sh-sci",
  186. .id = 3,
  187. .resource = scif3_resources,
  188. .num_resources = ARRAY_SIZE(scif3_resources),
  189. .dev = {
  190. .platform_data = &scif3_platform_data,
  191. },
  192. };
  193. static struct sh_timer_config cmt_platform_data = {
  194. .channels_mask = 3,
  195. };
  196. static struct resource cmt_resources[] = {
  197. DEFINE_RES_MEM(0xfffec000, 0x10),
  198. DEFINE_RES_IRQ(140),
  199. DEFINE_RES_IRQ(144),
  200. };
  201. static struct platform_device cmt_device = {
  202. .name = "sh-cmt-16",
  203. .id = 0,
  204. .dev = {
  205. .platform_data = &cmt_platform_data,
  206. },
  207. .resource = cmt_resources,
  208. .num_resources = ARRAY_SIZE(cmt_resources),
  209. };
  210. static struct resource mtu2_resources[] = {
  211. DEFINE_RES_MEM(0xfffe4000, 0x400),
  212. DEFINE_RES_IRQ_NAMED(156, "tgi0a"),
  213. DEFINE_RES_IRQ_NAMED(164, "tgi1a"),
  214. DEFINE_RES_IRQ_NAMED(180, "tgi2a"),
  215. };
  216. static struct platform_device mtu2_device = {
  217. .name = "sh-mtu2s",
  218. .id = -1,
  219. .resource = mtu2_resources,
  220. .num_resources = ARRAY_SIZE(mtu2_resources),
  221. };
  222. static struct platform_device *sh7206_devices[] __initdata = {
  223. &scif0_device,
  224. &scif1_device,
  225. &scif2_device,
  226. &scif3_device,
  227. &cmt_device,
  228. &mtu2_device,
  229. };
  230. static int __init sh7206_devices_setup(void)
  231. {
  232. return platform_add_devices(sh7206_devices,
  233. ARRAY_SIZE(sh7206_devices));
  234. }
  235. arch_initcall(sh7206_devices_setup);
  236. void __init plat_irq_setup(void)
  237. {
  238. register_intc_controller(&intc_desc);
  239. }
  240. static struct platform_device *sh7206_early_devices[] __initdata = {
  241. &scif0_device,
  242. &scif1_device,
  243. &scif2_device,
  244. &scif3_device,
  245. &cmt_device,
  246. &mtu2_device,
  247. };
  248. #define STBCR3 0xfffe0408
  249. #define STBCR4 0xfffe040c
  250. void __init plat_early_device_setup(void)
  251. {
  252. /* enable CMT clock */
  253. __raw_writeb(__raw_readb(STBCR4) & ~0x04, STBCR4);
  254. /* enable MTU2 clock */
  255. __raw_writeb(__raw_readb(STBCR3) & ~0x20, STBCR3);
  256. early_platform_add_devices(sh7206_early_devices,
  257. ARRAY_SIZE(sh7206_early_devices));
  258. }