setup-sh7763.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /*
  2. * SH7763 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. * Copyright (C) 2007 Yoshihiro Shimoda
  6. * Copyright (C) 2008, 2009 Nobuhiro Iwamatsu
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/platform_device.h>
  13. #include <linux/init.h>
  14. #include <linux/serial.h>
  15. #include <linux/sh_timer.h>
  16. #include <linux/sh_intc.h>
  17. #include <linux/io.h>
  18. #include <linux/serial_sci.h>
  19. #include <linux/usb/ohci_pdriver.h>
  20. static struct plat_sci_port scif0_platform_data = {
  21. .scscr = SCSCR_REIE,
  22. .type = PORT_SCIF,
  23. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  24. };
  25. static struct resource scif0_resources[] = {
  26. DEFINE_RES_MEM(0xffe00000, 0x100),
  27. DEFINE_RES_IRQ(evt2irq(0x700)),
  28. };
  29. static struct platform_device scif0_device = {
  30. .name = "sh-sci",
  31. .id = 0,
  32. .resource = scif0_resources,
  33. .num_resources = ARRAY_SIZE(scif0_resources),
  34. .dev = {
  35. .platform_data = &scif0_platform_data,
  36. },
  37. };
  38. static struct plat_sci_port scif1_platform_data = {
  39. .scscr = SCSCR_REIE,
  40. .type = PORT_SCIF,
  41. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  42. };
  43. static struct resource scif1_resources[] = {
  44. DEFINE_RES_MEM(0xffe08000, 0x100),
  45. DEFINE_RES_IRQ(evt2irq(0xb80)),
  46. };
  47. static struct platform_device scif1_device = {
  48. .name = "sh-sci",
  49. .id = 1,
  50. .resource = scif1_resources,
  51. .num_resources = ARRAY_SIZE(scif1_resources),
  52. .dev = {
  53. .platform_data = &scif1_platform_data,
  54. },
  55. };
  56. static struct plat_sci_port scif2_platform_data = {
  57. .scscr = SCSCR_REIE,
  58. .type = PORT_SCIF,
  59. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  60. };
  61. static struct resource scif2_resources[] = {
  62. DEFINE_RES_MEM(0xffe10000, 0x100),
  63. DEFINE_RES_IRQ(evt2irq(0xf00)),
  64. };
  65. static struct platform_device scif2_device = {
  66. .name = "sh-sci",
  67. .id = 2,
  68. .resource = scif2_resources,
  69. .num_resources = ARRAY_SIZE(scif2_resources),
  70. .dev = {
  71. .platform_data = &scif2_platform_data,
  72. },
  73. };
  74. static struct resource rtc_resources[] = {
  75. [0] = {
  76. .start = 0xffe80000,
  77. .end = 0xffe80000 + 0x58 - 1,
  78. .flags = IORESOURCE_IO,
  79. },
  80. [1] = {
  81. /* Shared Period/Carry/Alarm IRQ */
  82. .start = evt2irq(0x480),
  83. .flags = IORESOURCE_IRQ,
  84. },
  85. };
  86. static struct platform_device rtc_device = {
  87. .name = "sh-rtc",
  88. .id = -1,
  89. .num_resources = ARRAY_SIZE(rtc_resources),
  90. .resource = rtc_resources,
  91. };
  92. static struct resource usb_ohci_resources[] = {
  93. [0] = {
  94. .start = 0xffec8000,
  95. .end = 0xffec80ff,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. [1] = {
  99. .start = evt2irq(0xc60),
  100. .end = evt2irq(0xc60),
  101. .flags = IORESOURCE_IRQ,
  102. },
  103. };
  104. static u64 usb_ohci_dma_mask = 0xffffffffUL;
  105. static struct usb_ohci_pdata usb_ohci_pdata;
  106. static struct platform_device usb_ohci_device = {
  107. .name = "ohci-platform",
  108. .id = -1,
  109. .dev = {
  110. .dma_mask = &usb_ohci_dma_mask,
  111. .coherent_dma_mask = 0xffffffff,
  112. .platform_data = &usb_ohci_pdata,
  113. },
  114. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  115. .resource = usb_ohci_resources,
  116. };
  117. static struct resource usbf_resources[] = {
  118. [0] = {
  119. .start = 0xffec0000,
  120. .end = 0xffec00ff,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [1] = {
  124. .start = evt2irq(0xc80),
  125. .end = evt2irq(0xc80),
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static struct platform_device usbf_device = {
  130. .name = "sh_udc",
  131. .id = -1,
  132. .dev = {
  133. .dma_mask = NULL,
  134. .coherent_dma_mask = 0xffffffff,
  135. },
  136. .num_resources = ARRAY_SIZE(usbf_resources),
  137. .resource = usbf_resources,
  138. };
  139. static struct sh_timer_config tmu0_platform_data = {
  140. .channels_mask = 7,
  141. };
  142. static struct resource tmu0_resources[] = {
  143. DEFINE_RES_MEM(0xffd80000, 0x30),
  144. DEFINE_RES_IRQ(evt2irq(0x580)),
  145. DEFINE_RES_IRQ(evt2irq(0x5a0)),
  146. DEFINE_RES_IRQ(evt2irq(0x5c0)),
  147. };
  148. static struct platform_device tmu0_device = {
  149. .name = "sh-tmu",
  150. .id = 0,
  151. .dev = {
  152. .platform_data = &tmu0_platform_data,
  153. },
  154. .resource = tmu0_resources,
  155. .num_resources = ARRAY_SIZE(tmu0_resources),
  156. };
  157. static struct sh_timer_config tmu1_platform_data = {
  158. .channels_mask = 7,
  159. };
  160. static struct resource tmu1_resources[] = {
  161. DEFINE_RES_MEM(0xffd88000, 0x2c),
  162. DEFINE_RES_IRQ(evt2irq(0xe00)),
  163. DEFINE_RES_IRQ(evt2irq(0xe20)),
  164. DEFINE_RES_IRQ(evt2irq(0xe40)),
  165. };
  166. static struct platform_device tmu1_device = {
  167. .name = "sh-tmu",
  168. .id = 1,
  169. .dev = {
  170. .platform_data = &tmu1_platform_data,
  171. },
  172. .resource = tmu1_resources,
  173. .num_resources = ARRAY_SIZE(tmu1_resources),
  174. };
  175. static struct platform_device *sh7763_devices[] __initdata = {
  176. &scif0_device,
  177. &scif1_device,
  178. &scif2_device,
  179. &tmu0_device,
  180. &tmu1_device,
  181. &rtc_device,
  182. &usb_ohci_device,
  183. &usbf_device,
  184. };
  185. static int __init sh7763_devices_setup(void)
  186. {
  187. return platform_add_devices(sh7763_devices,
  188. ARRAY_SIZE(sh7763_devices));
  189. }
  190. arch_initcall(sh7763_devices_setup);
  191. static struct platform_device *sh7763_early_devices[] __initdata = {
  192. &scif0_device,
  193. &scif1_device,
  194. &scif2_device,
  195. &tmu0_device,
  196. &tmu1_device,
  197. };
  198. void __init plat_early_device_setup(void)
  199. {
  200. early_platform_add_devices(sh7763_early_devices,
  201. ARRAY_SIZE(sh7763_early_devices));
  202. }
  203. enum {
  204. UNUSED = 0,
  205. /* interrupt sources */
  206. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  207. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  208. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  209. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  210. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  211. RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,
  212. HUDI, LCDC, DMAC, SCIF0, IIC0, IIC1, CMT, GETHER, HAC,
  213. PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,
  214. STIF0, STIF1, SCIF1, SIOF0, SIOF1, SIOF2,
  215. USBH, USBF, TPU, PCC, MMCIF, SIM,
  216. TMU3, TMU4, TMU5, ADC, SSI0, SSI1, SSI2, SSI3,
  217. SCIF2, GPIO,
  218. /* interrupt groups */
  219. TMU012, TMU345,
  220. };
  221. static struct intc_vect vectors[] __initdata = {
  222. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  223. INTC_VECT(RTC, 0x4c0),
  224. INTC_VECT(WDT, 0x560), INTC_VECT(TMU0, 0x580),
  225. INTC_VECT(TMU1, 0x5a0), INTC_VECT(TMU2, 0x5c0),
  226. INTC_VECT(TMU2_TICPI, 0x5e0), INTC_VECT(HUDI, 0x600),
  227. INTC_VECT(LCDC, 0x620),
  228. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  229. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  230. INTC_VECT(DMAC, 0x6c0),
  231. INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),
  232. INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),
  233. INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),
  234. INTC_VECT(IIC0, 0x8A0), INTC_VECT(IIC1, 0x8C0),
  235. INTC_VECT(CMT, 0x900), INTC_VECT(GETHER, 0x920),
  236. INTC_VECT(GETHER, 0x940), INTC_VECT(GETHER, 0x960),
  237. INTC_VECT(HAC, 0x980),
  238. INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),
  239. INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),
  240. INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),
  241. INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),
  242. INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),
  243. INTC_VECT(STIF0, 0xb40), INTC_VECT(STIF1, 0xb60),
  244. INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),
  245. INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),
  246. INTC_VECT(SIOF0, 0xc00), INTC_VECT(SIOF1, 0xc20),
  247. INTC_VECT(USBH, 0xc60), INTC_VECT(USBF, 0xc80),
  248. INTC_VECT(USBF, 0xca0),
  249. INTC_VECT(TPU, 0xcc0), INTC_VECT(PCC, 0xce0),
  250. INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),
  251. INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),
  252. INTC_VECT(SIM, 0xd80), INTC_VECT(SIM, 0xda0),
  253. INTC_VECT(SIM, 0xdc0), INTC_VECT(SIM, 0xde0),
  254. INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
  255. INTC_VECT(TMU5, 0xe40), INTC_VECT(ADC, 0xe60),
  256. INTC_VECT(SSI0, 0xe80), INTC_VECT(SSI1, 0xea0),
  257. INTC_VECT(SSI2, 0xec0), INTC_VECT(SSI3, 0xee0),
  258. INTC_VECT(SCIF2, 0xf00), INTC_VECT(SCIF2, 0xf20),
  259. INTC_VECT(SCIF2, 0xf40), INTC_VECT(SCIF2, 0xf60),
  260. INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),
  261. INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),
  262. };
  263. static struct intc_group groups[] __initdata = {
  264. INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),
  265. INTC_GROUP(TMU345, TMU3, TMU4, TMU5),
  266. };
  267. static struct intc_mask_reg mask_registers[] __initdata = {
  268. { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
  269. { 0, 0, 0, 0, 0, 0, GPIO, 0,
  270. SSI0, MMCIF, 0, SIOF0, PCIC5, PCIINTD, PCIINTC, PCIINTB,
  271. PCIINTA, PCISERR, HAC, CMT, 0, 0, 0, DMAC,
  272. HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },
  273. { 0xffd400d0, 0xffd400d4, 32, /* INT2MSKR1 / INT2MSKCR1 */
  274. { 0, 0, 0, 0, 0, 0, SCIF2, USBF,
  275. 0, 0, STIF1, STIF0, 0, 0, USBH, GETHER,
  276. PCC, 0, 0, ADC, TPU, SIM, SIOF2, SIOF1,
  277. LCDC, 0, IIC1, IIC0, SSI3, SSI2, SSI1, 0 } },
  278. };
  279. static struct intc_prio_reg prio_registers[] __initdata = {
  280. { 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,
  281. TMU2, TMU2_TICPI } },
  282. { 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },
  283. { 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },
  284. { 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC, ADC } },
  285. { 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,
  286. PCISERR, PCIINTA } },
  287. { 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,
  288. PCIINTD, PCIC5 } },
  289. { 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF0, USBF, MMCIF, SSI0 } },
  290. { 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { SCIF2, GPIO } },
  291. { 0xffd400a0, 0, 32, 8, /* INT2PRI8 */ { SSI3, SSI2, SSI1, 0 } },
  292. { 0xffd400a4, 0, 32, 8, /* INT2PRI9 */ { LCDC, 0, IIC1, IIC0 } },
  293. { 0xffd400a8, 0, 32, 8, /* INT2PRI10 */ { TPU, SIM, SIOF2, SIOF1 } },
  294. { 0xffd400ac, 0, 32, 8, /* INT2PRI11 */ { PCC } },
  295. { 0xffd400b0, 0, 32, 8, /* INT2PRI12 */ { 0, 0, USBH, GETHER } },
  296. { 0xffd400b4, 0, 32, 8, /* INT2PRI13 */ { 0, 0, STIF1, STIF0 } },
  297. };
  298. static DECLARE_INTC_DESC(intc_desc, "sh7763", vectors, groups,
  299. mask_registers, prio_registers, NULL);
  300. /* Support for external interrupt pins in IRQ mode */
  301. static struct intc_vect irq_vectors[] __initdata = {
  302. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  303. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  304. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  305. INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),
  306. };
  307. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  308. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  309. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  310. };
  311. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  312. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  313. IRQ4, IRQ5, IRQ6, IRQ7 } },
  314. };
  315. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  316. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  317. IRQ4, IRQ5, IRQ6, IRQ7 } },
  318. };
  319. static struct intc_mask_reg irq_ack_registers[] __initdata = {
  320. { 0xffd00024, 0, 32, /* INTREQ */
  321. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  322. };
  323. static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7763-irq", irq_vectors,
  324. NULL, irq_mask_registers, irq_prio_registers,
  325. irq_sense_registers, irq_ack_registers);
  326. /* External interrupt pins in IRL mode */
  327. static struct intc_vect irl_vectors[] __initdata = {
  328. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  329. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  330. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  331. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  332. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  333. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  334. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  335. INTC_VECT(IRL_HHHL, 0x3c0),
  336. };
  337. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  338. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  339. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  340. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  341. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  342. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  343. };
  344. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  345. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  346. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  347. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  348. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  349. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  350. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  351. };
  352. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7763-irl7654", irl_vectors,
  353. NULL, irl7654_mask_registers, NULL, NULL);
  354. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7763-irl3210", irl_vectors,
  355. NULL, irl3210_mask_registers, NULL, NULL);
  356. #define INTC_ICR0 0xffd00000
  357. #define INTC_INTMSK0 0xffd00044
  358. #define INTC_INTMSK1 0xffd00048
  359. #define INTC_INTMSK2 0xffd40080
  360. #define INTC_INTMSKCLR1 0xffd00068
  361. #define INTC_INTMSKCLR2 0xffd40084
  362. void __init plat_irq_setup(void)
  363. {
  364. /* disable IRQ7-0 */
  365. __raw_writel(0xff000000, INTC_INTMSK0);
  366. /* disable IRL3-0 + IRL7-4 */
  367. __raw_writel(0xc0000000, INTC_INTMSK1);
  368. __raw_writel(0xfffefffe, INTC_INTMSK2);
  369. register_intc_controller(&intc_desc);
  370. }
  371. void __init plat_irq_setup_pins(int mode)
  372. {
  373. switch (mode) {
  374. case IRQ_MODE_IRQ:
  375. /* select IRQ mode for IRL3-0 + IRL7-4 */
  376. __raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  377. register_intc_controller(&intc_irq_desc);
  378. break;
  379. case IRQ_MODE_IRL7654:
  380. /* enable IRL7-4 but don't provide any masking */
  381. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  382. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  383. break;
  384. case IRQ_MODE_IRL3210:
  385. /* enable IRL0-3 but don't provide any masking */
  386. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  387. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  388. break;
  389. case IRQ_MODE_IRL7654_MASK:
  390. /* enable IRL7-4 and mask using cpu intc controller */
  391. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  392. register_intc_controller(&intc_irl7654_desc);
  393. break;
  394. case IRQ_MODE_IRL3210_MASK:
  395. /* enable IRL0-3 and mask using cpu intc controller */
  396. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  397. register_intc_controller(&intc_irl3210_desc);
  398. break;
  399. default:
  400. BUG();
  401. }
  402. }