setup-sh7203.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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. .flags = UPF_BOOT_AUTOCONF,
  159. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  160. SCSCR_REIE,
  161. .type = PORT_SCIF,
  162. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  163. };
  164. static struct resource scif0_resources[] = {
  165. DEFINE_RES_MEM(0xfffe8000, 0x100),
  166. DEFINE_RES_IRQ(192),
  167. };
  168. static struct platform_device scif0_device = {
  169. .name = "sh-sci",
  170. .id = 0,
  171. .resource = scif0_resources,
  172. .num_resources = ARRAY_SIZE(scif0_resources),
  173. .dev = {
  174. .platform_data = &scif0_platform_data,
  175. },
  176. };
  177. static struct plat_sci_port scif1_platform_data = {
  178. .flags = UPF_BOOT_AUTOCONF,
  179. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  180. SCSCR_REIE,
  181. .type = PORT_SCIF,
  182. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  183. };
  184. static struct resource scif1_resources[] = {
  185. DEFINE_RES_MEM(0xfffe8800, 0x100),
  186. DEFINE_RES_IRQ(196),
  187. };
  188. static struct platform_device scif1_device = {
  189. .name = "sh-sci",
  190. .id = 1,
  191. .resource = scif1_resources,
  192. .num_resources = ARRAY_SIZE(scif1_resources),
  193. .dev = {
  194. .platform_data = &scif1_platform_data,
  195. },
  196. };
  197. static struct plat_sci_port scif2_platform_data = {
  198. .flags = UPF_BOOT_AUTOCONF,
  199. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  200. SCSCR_REIE,
  201. .type = PORT_SCIF,
  202. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  203. };
  204. static struct resource scif2_resources[] = {
  205. DEFINE_RES_MEM(0xfffe9000, 0x100),
  206. DEFINE_RES_IRQ(200),
  207. };
  208. static struct platform_device scif2_device = {
  209. .name = "sh-sci",
  210. .id = 2,
  211. .resource = scif2_resources,
  212. .num_resources = ARRAY_SIZE(scif2_resources),
  213. .dev = {
  214. .platform_data = &scif2_platform_data,
  215. },
  216. };
  217. static struct plat_sci_port scif3_platform_data = {
  218. .flags = UPF_BOOT_AUTOCONF,
  219. .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE |
  220. SCSCR_REIE,
  221. .type = PORT_SCIF,
  222. .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  223. };
  224. static struct resource scif3_resources[] = {
  225. DEFINE_RES_MEM(0xfffe9800, 0x100),
  226. DEFINE_RES_IRQ(204),
  227. };
  228. static struct platform_device scif3_device = {
  229. .name = "sh-sci",
  230. .id = 3,
  231. .resource = scif3_resources,
  232. .num_resources = ARRAY_SIZE(scif3_resources),
  233. .dev = {
  234. .platform_data = &scif3_platform_data,
  235. },
  236. };
  237. static struct sh_timer_config cmt_platform_data = {
  238. .channels_mask = 3,
  239. };
  240. static struct resource cmt_resources[] = {
  241. DEFINE_RES_MEM(0xfffec000, 0x10),
  242. DEFINE_RES_IRQ(142),
  243. DEFINE_RES_IRQ(143),
  244. };
  245. static struct platform_device cmt_device = {
  246. .name = "sh-cmt-16",
  247. .id = 0,
  248. .dev = {
  249. .platform_data = &cmt_platform_data,
  250. },
  251. .resource = cmt_resources,
  252. .num_resources = ARRAY_SIZE(cmt_resources),
  253. };
  254. static struct resource mtu2_resources[] = {
  255. DEFINE_RES_MEM(0xfffe4000, 0x400),
  256. DEFINE_RES_IRQ_NAMED(146, "tgi0a"),
  257. DEFINE_RES_IRQ_NAMED(153, "tgi1a"),
  258. };
  259. static struct platform_device mtu2_device = {
  260. .name = "sh-mtu2",
  261. .id = -1,
  262. .resource = mtu2_resources,
  263. .num_resources = ARRAY_SIZE(mtu2_resources),
  264. };
  265. static struct resource rtc_resources[] = {
  266. [0] = {
  267. .start = 0xffff2000,
  268. .end = 0xffff2000 + 0x58 - 1,
  269. .flags = IORESOURCE_IO,
  270. },
  271. [1] = {
  272. /* Shared Period/Carry/Alarm IRQ */
  273. .start = 231,
  274. .flags = IORESOURCE_IRQ,
  275. },
  276. };
  277. static struct platform_device rtc_device = {
  278. .name = "sh-rtc",
  279. .id = -1,
  280. .num_resources = ARRAY_SIZE(rtc_resources),
  281. .resource = rtc_resources,
  282. };
  283. static struct platform_device *sh7203_devices[] __initdata = {
  284. &scif0_device,
  285. &scif1_device,
  286. &scif2_device,
  287. &scif3_device,
  288. &cmt_device,
  289. &mtu2_device,
  290. &rtc_device,
  291. };
  292. static int __init sh7203_devices_setup(void)
  293. {
  294. return platform_add_devices(sh7203_devices,
  295. ARRAY_SIZE(sh7203_devices));
  296. }
  297. arch_initcall(sh7203_devices_setup);
  298. void __init plat_irq_setup(void)
  299. {
  300. register_intc_controller(&intc_desc);
  301. }
  302. static struct platform_device *sh7203_early_devices[] __initdata = {
  303. &scif0_device,
  304. &scif1_device,
  305. &scif2_device,
  306. &scif3_device,
  307. &cmt_device,
  308. &mtu2_device,
  309. };
  310. #define STBCR3 0xfffe0408
  311. #define STBCR4 0xfffe040c
  312. void __init plat_early_device_setup(void)
  313. {
  314. /* enable CMT clock */
  315. __raw_writeb(__raw_readb(STBCR4) & ~0x04, STBCR4);
  316. /* enable MTU2 clock */
  317. __raw_writeb(__raw_readb(STBCR3) & ~0x20, STBCR3);
  318. early_platform_add_devices(sh7203_early_devices,
  319. ARRAY_SIZE(sh7203_early_devices));
  320. }