setup-sh7203.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. /*
  2. * SH7203 and SH7263 Setup
  3. *
  4. * Copyright (C) 2007 - 2009 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/serial_sci.h>
  14. #include <linux/sh_timer.h>
  15. #include <linux/io.h>
  16. enum {
  17. UNUSED = 0,
  18. /* interrupt sources */
  19. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  20. PINT0, PINT1, PINT2, PINT3, PINT4, PINT5, PINT6, PINT7,
  21. DMAC0, DMAC1, DMAC2, DMAC3, DMAC4, DMAC5, DMAC6, DMAC7,
  22. USB, LCDC, CMT0, CMT1, BSC, WDT,
  23. MTU0_ABCD, MTU0_VEF, MTU1_AB, MTU1_VU, MTU2_AB, MTU2_VU,
  24. MTU3_ABCD, MTU4_ABCD, MTU2_TCI3V, MTU2_TCI4V,
  25. ADC_ADI,
  26. IIC30, IIC31, IIC32, IIC33,
  27. SCIF0, SCIF1, SCIF2, SCIF3,
  28. SSU0, SSU1,
  29. SSI0_SSII, SSI1_SSII, SSI2_SSII, SSI3_SSII,
  30. /* ROM-DEC, SDHI, SRC, and IEB are SH7263 specific */
  31. ROMDEC, FLCTL, SDHI, RTC, RCAN0, RCAN1,
  32. SRC, IEBI,
  33. /* interrupt groups */
  34. PINT,
  35. };
  36. static struct intc_vect vectors[] __initdata = {
  37. INTC_IRQ(IRQ0, 64), INTC_IRQ(IRQ1, 65),
  38. INTC_IRQ(IRQ2, 66), INTC_IRQ(IRQ3, 67),
  39. INTC_IRQ(IRQ4, 68), INTC_IRQ(IRQ5, 69),
  40. INTC_IRQ(IRQ6, 70), INTC_IRQ(IRQ7, 71),
  41. INTC_IRQ(PINT0, 80), INTC_IRQ(PINT1, 81),
  42. INTC_IRQ(PINT2, 82), INTC_IRQ(PINT3, 83),
  43. INTC_IRQ(PINT4, 84), INTC_IRQ(PINT5, 85),
  44. INTC_IRQ(PINT6, 86), INTC_IRQ(PINT7, 87),
  45. INTC_IRQ(DMAC0, 108), INTC_IRQ(DMAC0, 109),
  46. INTC_IRQ(DMAC1, 112), INTC_IRQ(DMAC1, 113),
  47. INTC_IRQ(DMAC2, 116), INTC_IRQ(DMAC2, 117),
  48. INTC_IRQ(DMAC3, 120), INTC_IRQ(DMAC3, 121),
  49. INTC_IRQ(DMAC4, 124), INTC_IRQ(DMAC4, 125),
  50. INTC_IRQ(DMAC5, 128), INTC_IRQ(DMAC5, 129),
  51. INTC_IRQ(DMAC6, 132), INTC_IRQ(DMAC6, 133),
  52. INTC_IRQ(DMAC7, 136), INTC_IRQ(DMAC7, 137),
  53. INTC_IRQ(USB, 140), INTC_IRQ(LCDC, 141),
  54. INTC_IRQ(CMT0, 142), INTC_IRQ(CMT1, 143),
  55. INTC_IRQ(BSC, 144), INTC_IRQ(WDT, 145),
  56. INTC_IRQ(MTU0_ABCD, 146), INTC_IRQ(MTU0_ABCD, 147),
  57. INTC_IRQ(MTU0_ABCD, 148), INTC_IRQ(MTU0_ABCD, 149),
  58. INTC_IRQ(MTU0_VEF, 150),
  59. INTC_IRQ(MTU0_VEF, 151), INTC_IRQ(MTU0_VEF, 152),
  60. INTC_IRQ(MTU1_AB, 153), INTC_IRQ(MTU1_AB, 154),
  61. INTC_IRQ(MTU1_VU, 155), INTC_IRQ(MTU1_VU, 156),
  62. INTC_IRQ(MTU2_AB, 157), INTC_IRQ(MTU2_AB, 158),
  63. INTC_IRQ(MTU2_VU, 159), INTC_IRQ(MTU2_VU, 160),
  64. INTC_IRQ(MTU3_ABCD, 161), INTC_IRQ(MTU3_ABCD, 162),
  65. INTC_IRQ(MTU3_ABCD, 163), INTC_IRQ(MTU3_ABCD, 164),
  66. INTC_IRQ(MTU2_TCI3V, 165),
  67. INTC_IRQ(MTU4_ABCD, 166), INTC_IRQ(MTU4_ABCD, 167),
  68. INTC_IRQ(MTU4_ABCD, 168), INTC_IRQ(MTU4_ABCD, 169),
  69. INTC_IRQ(MTU2_TCI4V, 170),
  70. INTC_IRQ(ADC_ADI, 171),
  71. INTC_IRQ(IIC30, 172), INTC_IRQ(IIC30, 173),
  72. INTC_IRQ(IIC30, 174), INTC_IRQ(IIC30, 175),
  73. INTC_IRQ(IIC30, 176),
  74. INTC_IRQ(IIC31, 177), INTC_IRQ(IIC31, 178),
  75. INTC_IRQ(IIC31, 179), INTC_IRQ(IIC31, 180),
  76. INTC_IRQ(IIC31, 181),
  77. INTC_IRQ(IIC32, 182), INTC_IRQ(IIC32, 183),
  78. INTC_IRQ(IIC32, 184), INTC_IRQ(IIC32, 185),
  79. INTC_IRQ(IIC32, 186),
  80. INTC_IRQ(IIC33, 187), INTC_IRQ(IIC33, 188),
  81. INTC_IRQ(IIC33, 189), INTC_IRQ(IIC33, 190),
  82. INTC_IRQ(IIC33, 191),
  83. INTC_IRQ(SCIF0, 192), INTC_IRQ(SCIF0, 193),
  84. INTC_IRQ(SCIF0, 194), INTC_IRQ(SCIF0, 195),
  85. INTC_IRQ(SCIF1, 196), INTC_IRQ(SCIF1, 197),
  86. INTC_IRQ(SCIF1, 198), INTC_IRQ(SCIF1, 199),
  87. INTC_IRQ(SCIF2, 200), INTC_IRQ(SCIF2, 201),
  88. INTC_IRQ(SCIF2, 202), INTC_IRQ(SCIF2, 203),
  89. INTC_IRQ(SCIF3, 204), INTC_IRQ(SCIF3, 205),
  90. INTC_IRQ(SCIF3, 206), INTC_IRQ(SCIF3, 207),
  91. INTC_IRQ(SSU0, 208), INTC_IRQ(SSU0, 209),
  92. INTC_IRQ(SSU0, 210),
  93. INTC_IRQ(SSU1, 211), INTC_IRQ(SSU1, 212),
  94. INTC_IRQ(SSU1, 213),
  95. INTC_IRQ(SSI0_SSII, 214), INTC_IRQ(SSI1_SSII, 215),
  96. INTC_IRQ(SSI2_SSII, 216), INTC_IRQ(SSI3_SSII, 217),
  97. INTC_IRQ(FLCTL, 224), INTC_IRQ(FLCTL, 225),
  98. INTC_IRQ(FLCTL, 226), INTC_IRQ(FLCTL, 227),
  99. INTC_IRQ(RTC, 231), INTC_IRQ(RTC, 232),
  100. INTC_IRQ(RTC, 233),
  101. INTC_IRQ(RCAN0, 234), INTC_IRQ(RCAN0, 235),
  102. INTC_IRQ(RCAN0, 236), INTC_IRQ(RCAN0, 237),
  103. INTC_IRQ(RCAN0, 238),
  104. INTC_IRQ(RCAN1, 239), INTC_IRQ(RCAN1, 240),
  105. INTC_IRQ(RCAN1, 241), INTC_IRQ(RCAN1, 242),
  106. INTC_IRQ(RCAN1, 243),
  107. /* SH7263-specific trash */
  108. #ifdef CONFIG_CPU_SUBTYPE_SH7263
  109. INTC_IRQ(ROMDEC, 218), INTC_IRQ(ROMDEC, 219),
  110. INTC_IRQ(ROMDEC, 220), INTC_IRQ(ROMDEC, 221),
  111. INTC_IRQ(ROMDEC, 222), INTC_IRQ(ROMDEC, 223),
  112. INTC_IRQ(SDHI, 228), INTC_IRQ(SDHI, 229),
  113. INTC_IRQ(SDHI, 230),
  114. INTC_IRQ(SRC, 244), INTC_IRQ(SRC, 245),
  115. INTC_IRQ(SRC, 246),
  116. INTC_IRQ(IEBI, 247),
  117. #endif
  118. };
  119. static struct intc_group groups[] __initdata = {
  120. INTC_GROUP(PINT, PINT0, PINT1, PINT2, PINT3,
  121. PINT4, PINT5, PINT6, PINT7),
  122. };
  123. static struct intc_prio_reg prio_registers[] __initdata = {
  124. { 0xfffe0818, 0, 16, 4, /* IPR01 */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  125. { 0xfffe081a, 0, 16, 4, /* IPR02 */ { IRQ4, IRQ5, IRQ6, IRQ7 } },
  126. { 0xfffe0820, 0, 16, 4, /* IPR05 */ { PINT, 0, 0, 0 } },
  127. { 0xfffe0c00, 0, 16, 4, /* IPR06 */ { DMAC0, DMAC1, DMAC2, DMAC3 } },
  128. { 0xfffe0c02, 0, 16, 4, /* IPR07 */ { DMAC4, DMAC5, DMAC6, DMAC7 } },
  129. { 0xfffe0c04, 0, 16, 4, /* IPR08 */ { USB, LCDC, CMT0, CMT1 } },
  130. { 0xfffe0c06, 0, 16, 4, /* IPR09 */ { BSC, WDT, MTU0_ABCD, MTU0_VEF } },
  131. { 0xfffe0c08, 0, 16, 4, /* IPR10 */ { MTU1_AB, MTU1_VU, MTU2_AB,
  132. MTU2_VU } },
  133. { 0xfffe0c0a, 0, 16, 4, /* IPR11 */ { MTU3_ABCD, MTU2_TCI3V, MTU4_ABCD,
  134. MTU2_TCI4V } },
  135. { 0xfffe0c0c, 0, 16, 4, /* IPR12 */ { ADC_ADI, IIC30, IIC31, IIC32 } },
  136. { 0xfffe0c0e, 0, 16, 4, /* IPR13 */ { IIC33, SCIF0, SCIF1, SCIF2 } },
  137. { 0xfffe0c10, 0, 16, 4, /* IPR14 */ { SCIF3, SSU0, SSU1, SSI0_SSII } },
  138. #ifdef CONFIG_CPU_SUBTYPE_SH7203
  139. { 0xfffe0c12, 0, 16, 4, /* IPR15 */ { SSI1_SSII, SSI2_SSII,
  140. SSI3_SSII, 0 } },
  141. { 0xfffe0c14, 0, 16, 4, /* IPR16 */ { FLCTL, 0, RTC, RCAN0 } },
  142. { 0xfffe0c16, 0, 16, 4, /* IPR17 */ { RCAN1, 0, 0, 0 } },
  143. #else
  144. { 0xfffe0c12, 0, 16, 4, /* IPR15 */ { SSI1_SSII, SSI2_SSII,
  145. SSI3_SSII, ROMDEC } },
  146. { 0xfffe0c14, 0, 16, 4, /* IPR16 */ { FLCTL, SDHI, RTC, RCAN0 } },
  147. { 0xfffe0c16, 0, 16, 4, /* IPR17 */ { RCAN1, SRC, IEBI, 0 } },
  148. #endif
  149. };
  150. static struct intc_mask_reg mask_registers[] __initdata = {
  151. { 0xfffe0808, 0, 16, /* PINTER */
  152. { 0, 0, 0, 0, 0, 0, 0, 0,
  153. PINT7, PINT6, PINT5, PINT4, PINT3, PINT2, PINT1, PINT0 } },
  154. };
  155. static DECLARE_INTC_DESC(intc_desc, "sh7203", vectors, groups,
  156. mask_registers, prio_registers, NULL);
  157. static struct plat_sci_port scif0_platform_data = {
  158. .mapbase = 0xfffe8000,
  159. .flags = UPF_BOOT_AUTOCONF,
  160. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  161. SCSCR_REIE,
  162. .scbrr_algo_id = SCBRR_ALGO_2,
  163. .type = PORT_SCIF,
  164. .irqs = { 192, 192, 192, 192 },
  165. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  166. };
  167. static struct platform_device scif0_device = {
  168. .name = "sh-sci",
  169. .id = 0,
  170. .dev = {
  171. .platform_data = &scif0_platform_data,
  172. },
  173. };
  174. static struct plat_sci_port scif1_platform_data = {
  175. .mapbase = 0xfffe8800,
  176. .flags = UPF_BOOT_AUTOCONF,
  177. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  178. SCSCR_REIE,
  179. .scbrr_algo_id = SCBRR_ALGO_2,
  180. .type = PORT_SCIF,
  181. .irqs = { 196, 196, 196, 196 },
  182. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  183. };
  184. static struct platform_device scif1_device = {
  185. .name = "sh-sci",
  186. .id = 1,
  187. .dev = {
  188. .platform_data = &scif1_platform_data,
  189. },
  190. };
  191. static struct plat_sci_port scif2_platform_data = {
  192. .mapbase = 0xfffe9000,
  193. .flags = UPF_BOOT_AUTOCONF,
  194. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  195. SCSCR_REIE,
  196. .scbrr_algo_id = SCBRR_ALGO_2,
  197. .type = PORT_SCIF,
  198. .irqs = { 200, 200, 200, 200 },
  199. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  200. };
  201. static struct platform_device scif2_device = {
  202. .name = "sh-sci",
  203. .id = 2,
  204. .dev = {
  205. .platform_data = &scif2_platform_data,
  206. },
  207. };
  208. static struct plat_sci_port scif3_platform_data = {
  209. .mapbase = 0xfffe9800,
  210. .flags = UPF_BOOT_AUTOCONF,
  211. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  212. SCSCR_REIE,
  213. .scbrr_algo_id = SCBRR_ALGO_2,
  214. .type = PORT_SCIF,
  215. .irqs = { 204, 204, 204, 204 },
  216. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  217. };
  218. static struct platform_device scif3_device = {
  219. .name = "sh-sci",
  220. .id = 3,
  221. .dev = {
  222. .platform_data = &scif3_platform_data,
  223. },
  224. };
  225. static struct sh_timer_config cmt0_platform_data = {
  226. .channel_offset = 0x02,
  227. .timer_bit = 0,
  228. .clockevent_rating = 125,
  229. .clocksource_rating = 0, /* disabled due to code generation issues */
  230. };
  231. static struct resource cmt0_resources[] = {
  232. [0] = {
  233. .start = 0xfffec002,
  234. .end = 0xfffec007,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. [1] = {
  238. .start = 142,
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. };
  242. static struct platform_device cmt0_device = {
  243. .name = "sh_cmt",
  244. .id = 0,
  245. .dev = {
  246. .platform_data = &cmt0_platform_data,
  247. },
  248. .resource = cmt0_resources,
  249. .num_resources = ARRAY_SIZE(cmt0_resources),
  250. };
  251. static struct sh_timer_config cmt1_platform_data = {
  252. .channel_offset = 0x08,
  253. .timer_bit = 1,
  254. .clockevent_rating = 125,
  255. .clocksource_rating = 0, /* disabled due to code generation issues */
  256. };
  257. static struct resource cmt1_resources[] = {
  258. [0] = {
  259. .start = 0xfffec008,
  260. .end = 0xfffec00d,
  261. .flags = IORESOURCE_MEM,
  262. },
  263. [1] = {
  264. .start = 143,
  265. .flags = IORESOURCE_IRQ,
  266. },
  267. };
  268. static struct platform_device cmt1_device = {
  269. .name = "sh_cmt",
  270. .id = 1,
  271. .dev = {
  272. .platform_data = &cmt1_platform_data,
  273. },
  274. .resource = cmt1_resources,
  275. .num_resources = ARRAY_SIZE(cmt1_resources),
  276. };
  277. static struct sh_timer_config mtu2_0_platform_data = {
  278. .channel_offset = -0x80,
  279. .timer_bit = 0,
  280. .clockevent_rating = 200,
  281. };
  282. static struct resource mtu2_0_resources[] = {
  283. [0] = {
  284. .start = 0xfffe4300,
  285. .end = 0xfffe4326,
  286. .flags = IORESOURCE_MEM,
  287. },
  288. [1] = {
  289. .start = 146,
  290. .flags = IORESOURCE_IRQ,
  291. },
  292. };
  293. static struct platform_device mtu2_0_device = {
  294. .name = "sh_mtu2",
  295. .id = 0,
  296. .dev = {
  297. .platform_data = &mtu2_0_platform_data,
  298. },
  299. .resource = mtu2_0_resources,
  300. .num_resources = ARRAY_SIZE(mtu2_0_resources),
  301. };
  302. static struct sh_timer_config mtu2_1_platform_data = {
  303. .channel_offset = -0x100,
  304. .timer_bit = 1,
  305. .clockevent_rating = 200,
  306. };
  307. static struct resource mtu2_1_resources[] = {
  308. [0] = {
  309. .start = 0xfffe4380,
  310. .end = 0xfffe4390,
  311. .flags = IORESOURCE_MEM,
  312. },
  313. [1] = {
  314. .start = 153,
  315. .flags = IORESOURCE_IRQ,
  316. },
  317. };
  318. static struct platform_device mtu2_1_device = {
  319. .name = "sh_mtu2",
  320. .id = 1,
  321. .dev = {
  322. .platform_data = &mtu2_1_platform_data,
  323. },
  324. .resource = mtu2_1_resources,
  325. .num_resources = ARRAY_SIZE(mtu2_1_resources),
  326. };
  327. static struct resource rtc_resources[] = {
  328. [0] = {
  329. .start = 0xffff2000,
  330. .end = 0xffff2000 + 0x58 - 1,
  331. .flags = IORESOURCE_IO,
  332. },
  333. [1] = {
  334. /* Shared Period/Carry/Alarm IRQ */
  335. .start = 231,
  336. .flags = IORESOURCE_IRQ,
  337. },
  338. };
  339. static struct platform_device rtc_device = {
  340. .name = "sh-rtc",
  341. .id = -1,
  342. .num_resources = ARRAY_SIZE(rtc_resources),
  343. .resource = rtc_resources,
  344. };
  345. static struct platform_device *sh7203_devices[] __initdata = {
  346. &scif0_device,
  347. &scif1_device,
  348. &scif2_device,
  349. &scif3_device,
  350. &cmt0_device,
  351. &cmt1_device,
  352. &mtu2_0_device,
  353. &mtu2_1_device,
  354. &rtc_device,
  355. };
  356. static int __init sh7203_devices_setup(void)
  357. {
  358. return platform_add_devices(sh7203_devices,
  359. ARRAY_SIZE(sh7203_devices));
  360. }
  361. arch_initcall(sh7203_devices_setup);
  362. void __init plat_irq_setup(void)
  363. {
  364. register_intc_controller(&intc_desc);
  365. }
  366. static struct platform_device *sh7203_early_devices[] __initdata = {
  367. &scif0_device,
  368. &scif1_device,
  369. &scif2_device,
  370. &scif3_device,
  371. &cmt0_device,
  372. &cmt1_device,
  373. &mtu2_0_device,
  374. &mtu2_1_device,
  375. };
  376. #define STBCR3 0xfffe0408
  377. #define STBCR4 0xfffe040c
  378. void __init plat_early_device_setup(void)
  379. {
  380. /* enable CMT clock */
  381. __raw_writeb(__raw_readb(STBCR4) & ~0x04, STBCR4);
  382. /* enable MTU2 clock */
  383. __raw_writeb(__raw_readb(STBCR3) & ~0x20, STBCR3);
  384. early_platform_add_devices(sh7203_early_devices,
  385. ARRAY_SIZE(sh7203_early_devices));
  386. }