setup-sh7206.c 10.0 KB

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