setup-sh7343.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /*
  2. * SH7343 Setup
  3. *
  4. * Copyright (C) 2006 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/uio_driver.h>
  15. #include <linux/sh_timer.h>
  16. #include <linux/sh_intc.h>
  17. #include <asm/clock.h>
  18. /* Serial */
  19. static struct plat_sci_port scif0_platform_data = {
  20. .flags = UPF_BOOT_AUTOCONF,
  21. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  22. .type = PORT_SCIF,
  23. };
  24. static struct resource scif0_resources[] = {
  25. DEFINE_RES_MEM(0xffe00000, 0x100),
  26. DEFINE_RES_IRQ(evt2irq(0xc00)),
  27. };
  28. static struct platform_device scif0_device = {
  29. .name = "sh-sci",
  30. .id = 0,
  31. .resource = scif0_resources,
  32. .num_resources = ARRAY_SIZE(scif0_resources),
  33. .dev = {
  34. .platform_data = &scif0_platform_data,
  35. },
  36. };
  37. static struct plat_sci_port scif1_platform_data = {
  38. .flags = UPF_BOOT_AUTOCONF,
  39. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  40. .type = PORT_SCIF,
  41. };
  42. static struct resource scif1_resources[] = {
  43. DEFINE_RES_MEM(0xffe10000, 0x100),
  44. DEFINE_RES_IRQ(evt2irq(0xc20)),
  45. };
  46. static struct platform_device scif1_device = {
  47. .name = "sh-sci",
  48. .id = 1,
  49. .resource = scif1_resources,
  50. .num_resources = ARRAY_SIZE(scif1_resources),
  51. .dev = {
  52. .platform_data = &scif1_platform_data,
  53. },
  54. };
  55. static struct plat_sci_port scif2_platform_data = {
  56. .flags = UPF_BOOT_AUTOCONF,
  57. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  58. .type = PORT_SCIF,
  59. };
  60. static struct resource scif2_resources[] = {
  61. DEFINE_RES_MEM(0xffe20000, 0x100),
  62. DEFINE_RES_IRQ(evt2irq(0xc40)),
  63. };
  64. static struct platform_device scif2_device = {
  65. .name = "sh-sci",
  66. .id = 2,
  67. .resource = scif2_resources,
  68. .num_resources = ARRAY_SIZE(scif2_resources),
  69. .dev = {
  70. .platform_data = &scif2_platform_data,
  71. },
  72. };
  73. static struct plat_sci_port scif3_platform_data = {
  74. .flags = UPF_BOOT_AUTOCONF,
  75. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  76. .type = PORT_SCIF,
  77. };
  78. static struct resource scif3_resources[] = {
  79. DEFINE_RES_MEM(0xffe30000, 0x100),
  80. DEFINE_RES_IRQ(evt2irq(0xc60)),
  81. };
  82. static struct platform_device scif3_device = {
  83. .name = "sh-sci",
  84. .id = 3,
  85. .resource = scif3_resources,
  86. .num_resources = ARRAY_SIZE(scif3_resources),
  87. .dev = {
  88. .platform_data = &scif3_platform_data,
  89. },
  90. };
  91. static struct resource iic0_resources[] = {
  92. [0] = {
  93. .name = "IIC0",
  94. .start = 0x04470000,
  95. .end = 0x04470017,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. [1] = {
  99. .start = evt2irq(0xe00),
  100. .end = evt2irq(0xe60),
  101. .flags = IORESOURCE_IRQ,
  102. },
  103. };
  104. static struct platform_device iic0_device = {
  105. .name = "i2c-sh_mobile",
  106. .id = 0, /* "i2c0" clock */
  107. .num_resources = ARRAY_SIZE(iic0_resources),
  108. .resource = iic0_resources,
  109. };
  110. static struct resource iic1_resources[] = {
  111. [0] = {
  112. .name = "IIC1",
  113. .start = 0x04750000,
  114. .end = 0x04750017,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. [1] = {
  118. .start = evt2irq(0x780),
  119. .end = evt2irq(0x7e0),
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device iic1_device = {
  124. .name = "i2c-sh_mobile",
  125. .id = 1, /* "i2c1" clock */
  126. .num_resources = ARRAY_SIZE(iic1_resources),
  127. .resource = iic1_resources,
  128. };
  129. static struct uio_info vpu_platform_data = {
  130. .name = "VPU4",
  131. .version = "0",
  132. .irq = evt2irq(0x980),
  133. };
  134. static struct resource vpu_resources[] = {
  135. [0] = {
  136. .name = "VPU",
  137. .start = 0xfe900000,
  138. .end = 0xfe9022eb,
  139. .flags = IORESOURCE_MEM,
  140. },
  141. [1] = {
  142. /* place holder for contiguous memory */
  143. },
  144. };
  145. static struct platform_device vpu_device = {
  146. .name = "uio_pdrv_genirq",
  147. .id = 0,
  148. .dev = {
  149. .platform_data = &vpu_platform_data,
  150. },
  151. .resource = vpu_resources,
  152. .num_resources = ARRAY_SIZE(vpu_resources),
  153. };
  154. static struct uio_info veu_platform_data = {
  155. .name = "VEU",
  156. .version = "0",
  157. .irq = evt2irq(0x8c0),
  158. };
  159. static struct resource veu_resources[] = {
  160. [0] = {
  161. .name = "VEU",
  162. .start = 0xfe920000,
  163. .end = 0xfe9200b7,
  164. .flags = IORESOURCE_MEM,
  165. },
  166. [1] = {
  167. /* place holder for contiguous memory */
  168. },
  169. };
  170. static struct platform_device veu_device = {
  171. .name = "uio_pdrv_genirq",
  172. .id = 1,
  173. .dev = {
  174. .platform_data = &veu_platform_data,
  175. },
  176. .resource = veu_resources,
  177. .num_resources = ARRAY_SIZE(veu_resources),
  178. };
  179. static struct uio_info jpu_platform_data = {
  180. .name = "JPU",
  181. .version = "0",
  182. .irq = evt2irq(0x560),
  183. };
  184. static struct resource jpu_resources[] = {
  185. [0] = {
  186. .name = "JPU",
  187. .start = 0xfea00000,
  188. .end = 0xfea102d3,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. [1] = {
  192. /* place holder for contiguous memory */
  193. },
  194. };
  195. static struct platform_device jpu_device = {
  196. .name = "uio_pdrv_genirq",
  197. .id = 2,
  198. .dev = {
  199. .platform_data = &jpu_platform_data,
  200. },
  201. .resource = jpu_resources,
  202. .num_resources = ARRAY_SIZE(jpu_resources),
  203. };
  204. static struct sh_timer_config cmt_platform_data = {
  205. .channels_mask = 0x20,
  206. };
  207. static struct resource cmt_resources[] = {
  208. DEFINE_RES_MEM(0x044a0000, 0x70),
  209. DEFINE_RES_IRQ(evt2irq(0xf00)),
  210. };
  211. static struct platform_device cmt_device = {
  212. .name = "sh-cmt-32",
  213. .id = 0,
  214. .dev = {
  215. .platform_data = &cmt_platform_data,
  216. },
  217. .resource = cmt_resources,
  218. .num_resources = ARRAY_SIZE(cmt_resources),
  219. };
  220. static struct sh_timer_config tmu0_platform_data = {
  221. .channels_mask = 7,
  222. };
  223. static struct resource tmu0_resources[] = {
  224. DEFINE_RES_MEM(0xffd80000, 0x2c),
  225. DEFINE_RES_IRQ(evt2irq(0x400)),
  226. DEFINE_RES_IRQ(evt2irq(0x420)),
  227. DEFINE_RES_IRQ(evt2irq(0x440)),
  228. };
  229. static struct platform_device tmu0_device = {
  230. .name = "sh-tmu",
  231. .id = 0,
  232. .dev = {
  233. .platform_data = &tmu0_platform_data,
  234. },
  235. .resource = tmu0_resources,
  236. .num_resources = ARRAY_SIZE(tmu0_resources),
  237. };
  238. static struct platform_device *sh7343_devices[] __initdata = {
  239. &scif0_device,
  240. &scif1_device,
  241. &scif2_device,
  242. &scif3_device,
  243. &cmt_device,
  244. &tmu0_device,
  245. &iic0_device,
  246. &iic1_device,
  247. &vpu_device,
  248. &veu_device,
  249. &jpu_device,
  250. };
  251. static int __init sh7343_devices_setup(void)
  252. {
  253. platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20);
  254. platform_resource_setup_memory(&veu_device, "veu", 2 << 20);
  255. platform_resource_setup_memory(&jpu_device, "jpu", 2 << 20);
  256. return platform_add_devices(sh7343_devices,
  257. ARRAY_SIZE(sh7343_devices));
  258. }
  259. arch_initcall(sh7343_devices_setup);
  260. static struct platform_device *sh7343_early_devices[] __initdata = {
  261. &scif0_device,
  262. &scif1_device,
  263. &scif2_device,
  264. &scif3_device,
  265. &cmt_device,
  266. &tmu0_device,
  267. };
  268. void __init plat_early_device_setup(void)
  269. {
  270. early_platform_add_devices(sh7343_early_devices,
  271. ARRAY_SIZE(sh7343_early_devices));
  272. }
  273. enum {
  274. UNUSED = 0,
  275. ENABLED,
  276. DISABLED,
  277. /* interrupt sources */
  278. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  279. DMAC0, DMAC1, DMAC2, DMAC3,
  280. VIO_CEUI, VIO_BEUI, VIO_VEUI, VOU,
  281. MFI, VPU, TPU, Z3D4, USBI0, USBI1,
  282. MMC_ERR, MMC_TRAN, MMC_FSTAT, MMC_FRDY,
  283. DMAC4, DMAC5, DMAC_DADERR,
  284. KEYSC,
  285. SCIF, SCIF1, SCIF2, SCIF3,
  286. SIOF0, SIOF1, SIO,
  287. FLCTL_FLSTEI, FLCTL_FLENDI, FLCTL_FLTREQ0I, FLCTL_FLTREQ1I,
  288. I2C0_ALI, I2C0_TACKI, I2C0_WAITI, I2C0_DTEI,
  289. I2C1_ALI, I2C1_TACKI, I2C1_WAITI, I2C1_DTEI,
  290. SIM_TEI, SIM_TXI, SIM_RXI, SIM_ERI,
  291. IRDA, SDHI, CMT, TSIF, SIU,
  292. TMU0, TMU1, TMU2,
  293. JPU, LCDC,
  294. /* interrupt groups */
  295. DMAC0123, VIOVOU, MMC, DMAC45, FLCTL, I2C0, I2C1, SIM, USB,
  296. };
  297. static struct intc_vect vectors[] __initdata = {
  298. INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
  299. INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
  300. INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
  301. INTC_VECT(IRQ6, 0x6c0), INTC_VECT(IRQ7, 0x6e0),
  302. INTC_VECT(I2C1_ALI, 0x780), INTC_VECT(I2C1_TACKI, 0x7a0),
  303. INTC_VECT(I2C1_WAITI, 0x7c0), INTC_VECT(I2C1_DTEI, 0x7e0),
  304. INTC_VECT(DMAC0, 0x800), INTC_VECT(DMAC1, 0x820),
  305. INTC_VECT(DMAC2, 0x840), INTC_VECT(DMAC3, 0x860),
  306. INTC_VECT(VIO_CEUI, 0x880), INTC_VECT(VIO_BEUI, 0x8a0),
  307. INTC_VECT(VIO_VEUI, 0x8c0), INTC_VECT(VOU, 0x8e0),
  308. INTC_VECT(MFI, 0x900), INTC_VECT(VPU, 0x980),
  309. INTC_VECT(TPU, 0x9a0), INTC_VECT(Z3D4, 0x9e0),
  310. INTC_VECT(USBI0, 0xa20), INTC_VECT(USBI1, 0xa40),
  311. INTC_VECT(MMC_ERR, 0xb00), INTC_VECT(MMC_TRAN, 0xb20),
  312. INTC_VECT(MMC_FSTAT, 0xb40), INTC_VECT(MMC_FRDY, 0xb60),
  313. INTC_VECT(DMAC4, 0xb80), INTC_VECT(DMAC5, 0xba0),
  314. INTC_VECT(DMAC_DADERR, 0xbc0), INTC_VECT(KEYSC, 0xbe0),
  315. INTC_VECT(SCIF, 0xc00), INTC_VECT(SCIF1, 0xc20),
  316. INTC_VECT(SCIF2, 0xc40), INTC_VECT(SCIF3, 0xc60),
  317. INTC_VECT(SIOF0, 0xc80), INTC_VECT(SIOF1, 0xca0),
  318. INTC_VECT(SIO, 0xd00),
  319. INTC_VECT(FLCTL_FLSTEI, 0xd80), INTC_VECT(FLCTL_FLENDI, 0xda0),
  320. INTC_VECT(FLCTL_FLTREQ0I, 0xdc0), INTC_VECT(FLCTL_FLTREQ1I, 0xde0),
  321. INTC_VECT(I2C0_ALI, 0xe00), INTC_VECT(I2C0_TACKI, 0xe20),
  322. INTC_VECT(I2C0_WAITI, 0xe40), INTC_VECT(I2C0_DTEI, 0xe60),
  323. INTC_VECT(SDHI, 0xe80), INTC_VECT(SDHI, 0xea0),
  324. INTC_VECT(SDHI, 0xec0), INTC_VECT(SDHI, 0xee0),
  325. INTC_VECT(CMT, 0xf00), INTC_VECT(TSIF, 0xf20),
  326. INTC_VECT(SIU, 0xf80),
  327. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  328. INTC_VECT(TMU2, 0x440),
  329. INTC_VECT(JPU, 0x560), INTC_VECT(LCDC, 0x580),
  330. };
  331. static struct intc_group groups[] __initdata = {
  332. INTC_GROUP(DMAC0123, DMAC0, DMAC1, DMAC2, DMAC3),
  333. INTC_GROUP(VIOVOU, VIO_CEUI, VIO_BEUI, VIO_VEUI, VOU),
  334. INTC_GROUP(MMC, MMC_FRDY, MMC_FSTAT, MMC_TRAN, MMC_ERR),
  335. INTC_GROUP(DMAC45, DMAC4, DMAC5, DMAC_DADERR),
  336. INTC_GROUP(FLCTL, FLCTL_FLSTEI, FLCTL_FLENDI,
  337. FLCTL_FLTREQ0I, FLCTL_FLTREQ1I),
  338. INTC_GROUP(I2C0, I2C0_ALI, I2C0_TACKI, I2C0_WAITI, I2C0_DTEI),
  339. INTC_GROUP(I2C1, I2C1_ALI, I2C1_TACKI, I2C1_WAITI, I2C1_DTEI),
  340. INTC_GROUP(SIM, SIM_TEI, SIM_TXI, SIM_RXI, SIM_ERI),
  341. INTC_GROUP(USB, USBI0, USBI1),
  342. };
  343. static struct intc_mask_reg mask_registers[] __initdata = {
  344. { 0xa4080084, 0xa40800c4, 8, /* IMR1 / IMCR1 */
  345. { VOU, VIO_VEUI, VIO_BEUI, VIO_CEUI, DMAC3, DMAC2, DMAC1, DMAC0 } },
  346. { 0xa4080088, 0xa40800c8, 8, /* IMR2 / IMCR2 */
  347. { 0, 0, 0, VPU, 0, 0, 0, MFI } },
  348. { 0xa408008c, 0xa40800cc, 8, /* IMR3 / IMCR3 */
  349. { SIM_TEI, SIM_TXI, SIM_RXI, SIM_ERI, 0, 0, 0, IRDA } },
  350. { 0xa4080090, 0xa40800d0, 8, /* IMR4 / IMCR4 */
  351. { 0, TMU2, TMU1, TMU0, JPU, 0, 0, LCDC } },
  352. { 0xa4080094, 0xa40800d4, 8, /* IMR5 / IMCR5 */
  353. { KEYSC, DMAC_DADERR, DMAC5, DMAC4, SCIF3, SCIF2, SCIF1, SCIF } },
  354. { 0xa4080098, 0xa40800d8, 8, /* IMR6 / IMCR6 */
  355. { 0, 0, 0, SIO, Z3D4, 0, SIOF1, SIOF0 } },
  356. { 0xa408009c, 0xa40800dc, 8, /* IMR7 / IMCR7 */
  357. { I2C0_DTEI, I2C0_WAITI, I2C0_TACKI, I2C0_ALI,
  358. FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLENDI, FLCTL_FLSTEI } },
  359. { 0xa40800a0, 0xa40800e0, 8, /* IMR8 / IMCR8 */
  360. { DISABLED, ENABLED, ENABLED, ENABLED, 0, 0, 0, SIU } },
  361. { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */
  362. { 0, 0, 0, CMT, 0, USBI1, USBI0 } },
  363. { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
  364. { MMC_FRDY, MMC_FSTAT, MMC_TRAN, MMC_ERR } },
  365. { 0xa40800ac, 0xa40800ec, 8, /* IMR11 / IMCR11 */
  366. { I2C1_DTEI, I2C1_WAITI, I2C1_TACKI, I2C1_ALI, TPU, 0, 0, TSIF } },
  367. { 0xa4140044, 0xa4140064, 8, /* INTMSK00 / INTMSKCLR00 */
  368. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  369. };
  370. static struct intc_prio_reg prio_registers[] __initdata = {
  371. { 0xa4080000, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2 } },
  372. { 0xa4080004, 0, 16, 4, /* IPRB */ { JPU, LCDC, SIM } },
  373. { 0xa4080010, 0, 16, 4, /* IPRE */ { DMAC0123, VIOVOU, MFI, VPU } },
  374. { 0xa4080014, 0, 16, 4, /* IPRF */ { KEYSC, DMAC45, USB, CMT } },
  375. { 0xa4080018, 0, 16, 4, /* IPRG */ { SCIF, SCIF1, SCIF2, SCIF3 } },
  376. { 0xa408001c, 0, 16, 4, /* IPRH */ { SIOF0, SIOF1, FLCTL, I2C0 } },
  377. { 0xa4080020, 0, 16, 4, /* IPRI */ { SIO, 0, TSIF, I2C1 } },
  378. { 0xa4080024, 0, 16, 4, /* IPRJ */ { Z3D4, 0, SIU } },
  379. { 0xa4080028, 0, 16, 4, /* IPRK */ { 0, MMC, 0, SDHI } },
  380. { 0xa408002c, 0, 16, 4, /* IPRL */ { 0, 0, TPU } },
  381. { 0xa4140010, 0, 32, 4, /* INTPRI00 */
  382. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  383. };
  384. static struct intc_sense_reg sense_registers[] __initdata = {
  385. { 0xa414001c, 16, 2, /* ICR1 */
  386. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  387. };
  388. static struct intc_mask_reg ack_registers[] __initdata = {
  389. { 0xa4140024, 0, 8, /* INTREQ00 */
  390. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  391. };
  392. static struct intc_desc intc_desc __initdata = {
  393. .name = "sh7343",
  394. .force_enable = ENABLED,
  395. .force_disable = DISABLED,
  396. .hw = INTC_HW_DESC(vectors, groups, mask_registers,
  397. prio_registers, sense_registers, ack_registers),
  398. };
  399. void __init plat_irq_setup(void)
  400. {
  401. register_intc_controller(&intc_desc);
  402. }