setup-sh7206.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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 sci_platform_data[] = {
  122. {
  123. .mapbase = 0xfffe8000,
  124. .flags = UPF_BOOT_AUTOCONF,
  125. .type = PORT_SCIF,
  126. .irqs = { 240, 240, 240, 240 },
  127. }, {
  128. .mapbase = 0xfffe8800,
  129. .flags = UPF_BOOT_AUTOCONF,
  130. .type = PORT_SCIF,
  131. .irqs = { 244, 244, 244, 244 },
  132. }, {
  133. .mapbase = 0xfffe9000,
  134. .flags = UPF_BOOT_AUTOCONF,
  135. .type = PORT_SCIF,
  136. .irqs = { 248, 248, 248, 248 },
  137. }, {
  138. .mapbase = 0xfffe9800,
  139. .flags = UPF_BOOT_AUTOCONF,
  140. .type = PORT_SCIF,
  141. .irqs = { 252, 252, 252, 252 },
  142. }, {
  143. .flags = 0,
  144. }
  145. };
  146. static struct platform_device sci_device = {
  147. .name = "sh-sci",
  148. .id = -1,
  149. .dev = {
  150. .platform_data = sci_platform_data,
  151. },
  152. };
  153. static struct sh_timer_config cmt0_platform_data = {
  154. .name = "CMT0",
  155. .channel_offset = 0x02,
  156. .timer_bit = 0,
  157. .clk = "peripheral_clk",
  158. .clockevent_rating = 125,
  159. .clocksource_rating = 0, /* disabled due to code generation issues */
  160. };
  161. static struct resource cmt0_resources[] = {
  162. [0] = {
  163. .name = "CMT0",
  164. .start = 0xfffec002,
  165. .end = 0xfffec007,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. [1] = {
  169. .start = 140,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. };
  173. static struct platform_device cmt0_device = {
  174. .name = "sh_cmt",
  175. .id = 0,
  176. .dev = {
  177. .platform_data = &cmt0_platform_data,
  178. },
  179. .resource = cmt0_resources,
  180. .num_resources = ARRAY_SIZE(cmt0_resources),
  181. };
  182. static struct sh_timer_config cmt1_platform_data = {
  183. .name = "CMT1",
  184. .channel_offset = 0x08,
  185. .timer_bit = 1,
  186. .clk = "peripheral_clk",
  187. .clockevent_rating = 125,
  188. .clocksource_rating = 0, /* disabled due to code generation issues */
  189. };
  190. static struct resource cmt1_resources[] = {
  191. [0] = {
  192. .name = "CMT1",
  193. .start = 0xfffec008,
  194. .end = 0xfffec00d,
  195. .flags = IORESOURCE_MEM,
  196. },
  197. [1] = {
  198. .start = 144,
  199. .flags = IORESOURCE_IRQ,
  200. },
  201. };
  202. static struct platform_device cmt1_device = {
  203. .name = "sh_cmt",
  204. .id = 1,
  205. .dev = {
  206. .platform_data = &cmt1_platform_data,
  207. },
  208. .resource = cmt1_resources,
  209. .num_resources = ARRAY_SIZE(cmt1_resources),
  210. };
  211. static struct sh_timer_config mtu2_0_platform_data = {
  212. .name = "MTU2_0",
  213. .channel_offset = -0x80,
  214. .timer_bit = 0,
  215. .clk = "peripheral_clk",
  216. .clockevent_rating = 200,
  217. };
  218. static struct resource mtu2_0_resources[] = {
  219. [0] = {
  220. .name = "MTU2_0",
  221. .start = 0xfffe4300,
  222. .end = 0xfffe4326,
  223. .flags = IORESOURCE_MEM,
  224. },
  225. [1] = {
  226. .start = 156,
  227. .flags = IORESOURCE_IRQ,
  228. },
  229. };
  230. static struct platform_device mtu2_0_device = {
  231. .name = "sh_mtu2",
  232. .id = 0,
  233. .dev = {
  234. .platform_data = &mtu2_0_platform_data,
  235. },
  236. .resource = mtu2_0_resources,
  237. .num_resources = ARRAY_SIZE(mtu2_0_resources),
  238. };
  239. static struct sh_timer_config mtu2_1_platform_data = {
  240. .name = "MTU2_1",
  241. .channel_offset = -0x100,
  242. .timer_bit = 1,
  243. .clk = "peripheral_clk",
  244. .clockevent_rating = 200,
  245. };
  246. static struct resource mtu2_1_resources[] = {
  247. [0] = {
  248. .name = "MTU2_1",
  249. .start = 0xfffe4380,
  250. .end = 0xfffe4390,
  251. .flags = IORESOURCE_MEM,
  252. },
  253. [1] = {
  254. .start = 164,
  255. .flags = IORESOURCE_IRQ,
  256. },
  257. };
  258. static struct platform_device mtu2_1_device = {
  259. .name = "sh_mtu2",
  260. .id = 1,
  261. .dev = {
  262. .platform_data = &mtu2_1_platform_data,
  263. },
  264. .resource = mtu2_1_resources,
  265. .num_resources = ARRAY_SIZE(mtu2_1_resources),
  266. };
  267. static struct sh_timer_config mtu2_2_platform_data = {
  268. .name = "MTU2_2",
  269. .channel_offset = 0x80,
  270. .timer_bit = 2,
  271. .clk = "peripheral_clk",
  272. .clockevent_rating = 200,
  273. };
  274. static struct resource mtu2_2_resources[] = {
  275. [0] = {
  276. .name = "MTU2_2",
  277. .start = 0xfffe4000,
  278. .end = 0xfffe400a,
  279. .flags = IORESOURCE_MEM,
  280. },
  281. [1] = {
  282. .start = 180,
  283. .flags = IORESOURCE_IRQ,
  284. },
  285. };
  286. static struct platform_device mtu2_2_device = {
  287. .name = "sh_mtu2",
  288. .id = 2,
  289. .dev = {
  290. .platform_data = &mtu2_2_platform_data,
  291. },
  292. .resource = mtu2_2_resources,
  293. .num_resources = ARRAY_SIZE(mtu2_2_resources),
  294. };
  295. static struct platform_device *sh7206_devices[] __initdata = {
  296. &sci_device,
  297. &cmt0_device,
  298. &cmt1_device,
  299. &mtu2_0_device,
  300. &mtu2_1_device,
  301. &mtu2_2_device,
  302. };
  303. static int __init sh7206_devices_setup(void)
  304. {
  305. return platform_add_devices(sh7206_devices,
  306. ARRAY_SIZE(sh7206_devices));
  307. }
  308. arch_initcall(sh7206_devices_setup);
  309. void __init plat_irq_setup(void)
  310. {
  311. register_intc_controller(&intc_desc);
  312. }
  313. static struct platform_device *sh7206_early_devices[] __initdata = {
  314. &cmt0_device,
  315. &cmt1_device,
  316. &mtu2_0_device,
  317. &mtu2_1_device,
  318. &mtu2_2_device,
  319. };
  320. #define STBCR3 0xfffe0408
  321. #define STBCR4 0xfffe040c
  322. void __init plat_early_device_setup(void)
  323. {
  324. /* enable CMT clock */
  325. __raw_writeb(__raw_readb(STBCR4) & ~0x04, STBCR4);
  326. /* enable MTU2 clock */
  327. __raw_writeb(__raw_readb(STBCR3) & ~0x20, STBCR3);
  328. early_platform_add_devices(sh7206_early_devices,
  329. ARRAY_SIZE(sh7206_early_devices));
  330. }