setup-sh7763.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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/io.h>
  16. #include <linux/serial_sci.h>
  17. static struct resource rtc_resources[] = {
  18. [0] = {
  19. .start = 0xffe80000,
  20. .end = 0xffe80000 + 0x58 - 1,
  21. .flags = IORESOURCE_IO,
  22. },
  23. [1] = {
  24. /* Shared Period/Carry/Alarm IRQ */
  25. .start = 20,
  26. .flags = IORESOURCE_IRQ,
  27. },
  28. };
  29. static struct platform_device rtc_device = {
  30. .name = "sh-rtc",
  31. .id = -1,
  32. .num_resources = ARRAY_SIZE(rtc_resources),
  33. .resource = rtc_resources,
  34. };
  35. static struct plat_sci_port sci_platform_data[] = {
  36. {
  37. .mapbase = 0xffe00000,
  38. .flags = UPF_BOOT_AUTOCONF,
  39. .type = PORT_SCIF,
  40. .irqs = { 40, 40, 40, 40 },
  41. }, {
  42. .mapbase = 0xffe08000,
  43. .flags = UPF_BOOT_AUTOCONF,
  44. .type = PORT_SCIF,
  45. .irqs = { 76, 76, 76, 76 },
  46. }, {
  47. .mapbase = 0xffe10000,
  48. .flags = UPF_BOOT_AUTOCONF,
  49. .type = PORT_SCIF,
  50. .irqs = { 104, 104, 104, 104 },
  51. }, {
  52. .flags = 0,
  53. }
  54. };
  55. static struct platform_device sci_device = {
  56. .name = "sh-sci",
  57. .id = -1,
  58. .dev = {
  59. .platform_data = sci_platform_data,
  60. },
  61. };
  62. static struct resource usb_ohci_resources[] = {
  63. [0] = {
  64. .start = 0xffec8000,
  65. .end = 0xffec80ff,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. [1] = {
  69. .start = 83,
  70. .end = 83,
  71. .flags = IORESOURCE_IRQ,
  72. },
  73. };
  74. static u64 usb_ohci_dma_mask = 0xffffffffUL;
  75. static struct platform_device usb_ohci_device = {
  76. .name = "sh_ohci",
  77. .id = -1,
  78. .dev = {
  79. .dma_mask = &usb_ohci_dma_mask,
  80. .coherent_dma_mask = 0xffffffff,
  81. },
  82. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  83. .resource = usb_ohci_resources,
  84. };
  85. static struct resource usbf_resources[] = {
  86. [0] = {
  87. .start = 0xffec0000,
  88. .end = 0xffec00ff,
  89. .flags = IORESOURCE_MEM,
  90. },
  91. [1] = {
  92. .start = 84,
  93. .end = 84,
  94. .flags = IORESOURCE_IRQ,
  95. },
  96. };
  97. static struct platform_device usbf_device = {
  98. .name = "sh_udc",
  99. .id = -1,
  100. .dev = {
  101. .dma_mask = NULL,
  102. .coherent_dma_mask = 0xffffffff,
  103. },
  104. .num_resources = ARRAY_SIZE(usbf_resources),
  105. .resource = usbf_resources,
  106. };
  107. static struct platform_device *sh7763_devices[] __initdata = {
  108. &rtc_device,
  109. &sci_device,
  110. &usb_ohci_device,
  111. &usbf_device,
  112. };
  113. static int __init sh7763_devices_setup(void)
  114. {
  115. return platform_add_devices(sh7763_devices,
  116. ARRAY_SIZE(sh7763_devices));
  117. }
  118. __initcall(sh7763_devices_setup);
  119. enum {
  120. UNUSED = 0,
  121. /* interrupt sources */
  122. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  123. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  124. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  125. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  126. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  127. RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,
  128. HUDI, LCDC, DMAC, SCIF0, IIC0, IIC1, CMT, GETHER, HAC,
  129. PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,
  130. STIF0, STIF1, SCIF1, SIOF0, SIOF1, SIOF2,
  131. USBH, USBF, TPU, PCC, MMCIF, SIM,
  132. TMU3, TMU4, TMU5, ADC, SSI0, SSI1, SSI2, SSI3,
  133. SCIF2, GPIO,
  134. /* interrupt groups */
  135. TMU012, TMU345,
  136. };
  137. static struct intc_vect vectors[] __initdata = {
  138. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  139. INTC_VECT(RTC, 0x4c0),
  140. INTC_VECT(WDT, 0x560), INTC_VECT(TMU0, 0x580),
  141. INTC_VECT(TMU1, 0x5a0), INTC_VECT(TMU2, 0x5c0),
  142. INTC_VECT(TMU2_TICPI, 0x5e0), INTC_VECT(HUDI, 0x600),
  143. INTC_VECT(LCDC, 0x620),
  144. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  145. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  146. INTC_VECT(DMAC, 0x6c0),
  147. INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),
  148. INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),
  149. INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),
  150. INTC_VECT(IIC0, 0x8A0), INTC_VECT(IIC1, 0x8C0),
  151. INTC_VECT(CMT, 0x900), INTC_VECT(GETHER, 0x920),
  152. INTC_VECT(GETHER, 0x940), INTC_VECT(GETHER, 0x960),
  153. INTC_VECT(HAC, 0x980),
  154. INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),
  155. INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),
  156. INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),
  157. INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),
  158. INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),
  159. INTC_VECT(STIF0, 0xb40), INTC_VECT(STIF1, 0xb60),
  160. INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),
  161. INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),
  162. INTC_VECT(SIOF0, 0xc00), INTC_VECT(SIOF1, 0xc20),
  163. INTC_VECT(USBH, 0xc60), INTC_VECT(USBF, 0xc80),
  164. INTC_VECT(USBF, 0xca0),
  165. INTC_VECT(TPU, 0xcc0), INTC_VECT(PCC, 0xce0),
  166. INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),
  167. INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),
  168. INTC_VECT(SIM, 0xd80), INTC_VECT(SIM, 0xda0),
  169. INTC_VECT(SIM, 0xdc0), INTC_VECT(SIM, 0xde0),
  170. INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
  171. INTC_VECT(TMU5, 0xe40), INTC_VECT(ADC, 0xe60),
  172. INTC_VECT(SSI0, 0xe80), INTC_VECT(SSI1, 0xea0),
  173. INTC_VECT(SSI2, 0xec0), INTC_VECT(SSI3, 0xee0),
  174. INTC_VECT(SCIF2, 0xf00), INTC_VECT(SCIF2, 0xf20),
  175. INTC_VECT(SCIF2, 0xf40), INTC_VECT(SCIF2, 0xf60),
  176. INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),
  177. INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),
  178. };
  179. static struct intc_group groups[] __initdata = {
  180. INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),
  181. INTC_GROUP(TMU345, TMU3, TMU4, TMU5),
  182. };
  183. static struct intc_mask_reg mask_registers[] __initdata = {
  184. { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
  185. { 0, 0, 0, 0, 0, 0, GPIO, 0,
  186. SSI0, MMCIF, 0, SIOF0, PCIC5, PCIINTD, PCIINTC, PCIINTB,
  187. PCIINTA, PCISERR, HAC, CMT, 0, 0, 0, DMAC,
  188. HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },
  189. { 0xffd400d0, 0xffd400d4, 32, /* INT2MSKR1 / INT2MSKCR1 */
  190. { 0, 0, 0, 0, 0, 0, SCIF2, USBF,
  191. 0, 0, STIF1, STIF0, 0, 0, USBH, GETHER,
  192. PCC, 0, 0, ADC, TPU, SIM, SIOF2, SIOF1,
  193. LCDC, 0, IIC1, IIC0, SSI3, SSI2, SSI1, 0 } },
  194. };
  195. static struct intc_prio_reg prio_registers[] __initdata = {
  196. { 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,
  197. TMU2, TMU2_TICPI } },
  198. { 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },
  199. { 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },
  200. { 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC, ADC } },
  201. { 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,
  202. PCISERR, PCIINTA } },
  203. { 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,
  204. PCIINTD, PCIC5 } },
  205. { 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF0, USBF, MMCIF, SSI0 } },
  206. { 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { SCIF2, GPIO } },
  207. { 0xffd400a0, 0, 32, 8, /* INT2PRI8 */ { SSI3, SSI2, SSI1, 0 } },
  208. { 0xffd400a4, 0, 32, 8, /* INT2PRI9 */ { LCDC, 0, IIC1, IIC0 } },
  209. { 0xffd400a8, 0, 32, 8, /* INT2PRI10 */ { TPU, SIM, SIOF2, SIOF1 } },
  210. { 0xffd400ac, 0, 32, 8, /* INT2PRI11 */ { PCC } },
  211. { 0xffd400b0, 0, 32, 8, /* INT2PRI12 */ { 0, 0, USBH, GETHER } },
  212. { 0xffd400b4, 0, 32, 8, /* INT2PRI13 */ { 0, 0, STIF1, STIF0 } },
  213. };
  214. static DECLARE_INTC_DESC(intc_desc, "sh7763", vectors, groups,
  215. mask_registers, prio_registers, NULL);
  216. /* Support for external interrupt pins in IRQ mode */
  217. static struct intc_vect irq_vectors[] __initdata = {
  218. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  219. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  220. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  221. INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),
  222. };
  223. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  224. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  225. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  226. };
  227. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  228. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  229. IRQ4, IRQ5, IRQ6, IRQ7 } },
  230. };
  231. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  232. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  233. IRQ4, IRQ5, IRQ6, IRQ7 } },
  234. };
  235. static struct intc_mask_reg irq_ack_registers[] __initdata = {
  236. { 0xffd00024, 0, 32, /* INTREQ */
  237. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  238. };
  239. static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7763-irq", irq_vectors,
  240. NULL, irq_mask_registers, irq_prio_registers,
  241. irq_sense_registers, irq_ack_registers);
  242. /* External interrupt pins in IRL mode */
  243. static struct intc_vect irl_vectors[] __initdata = {
  244. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  245. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  246. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  247. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  248. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  249. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  250. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  251. INTC_VECT(IRL_HHHL, 0x3c0),
  252. };
  253. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  254. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  255. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  256. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  257. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  258. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  259. };
  260. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  261. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  262. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  263. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  264. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  265. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  266. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  267. };
  268. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7763-irl7654", irl_vectors,
  269. NULL, irl7654_mask_registers, NULL, NULL);
  270. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7763-irl3210", irl_vectors,
  271. NULL, irl3210_mask_registers, NULL, NULL);
  272. #define INTC_ICR0 0xffd00000
  273. #define INTC_INTMSK0 0xffd00044
  274. #define INTC_INTMSK1 0xffd00048
  275. #define INTC_INTMSK2 0xffd40080
  276. #define INTC_INTMSKCLR1 0xffd00068
  277. #define INTC_INTMSKCLR2 0xffd40084
  278. void __init plat_irq_setup(void)
  279. {
  280. /* disable IRQ7-0 */
  281. ctrl_outl(0xff000000, INTC_INTMSK0);
  282. /* disable IRL3-0 + IRL7-4 */
  283. ctrl_outl(0xc0000000, INTC_INTMSK1);
  284. ctrl_outl(0xfffefffe, INTC_INTMSK2);
  285. register_intc_controller(&intc_desc);
  286. }
  287. void __init plat_irq_setup_pins(int mode)
  288. {
  289. switch (mode) {
  290. case IRQ_MODE_IRQ:
  291. /* select IRQ mode for IRL3-0 + IRL7-4 */
  292. ctrl_outl(ctrl_inl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  293. register_intc_controller(&intc_irq_desc);
  294. break;
  295. case IRQ_MODE_IRL7654:
  296. /* enable IRL7-4 but don't provide any masking */
  297. ctrl_outl(0x40000000, INTC_INTMSKCLR1);
  298. ctrl_outl(0x0000fffe, INTC_INTMSKCLR2);
  299. break;
  300. case IRQ_MODE_IRL3210:
  301. /* enable IRL0-3 but don't provide any masking */
  302. ctrl_outl(0x80000000, INTC_INTMSKCLR1);
  303. ctrl_outl(0xfffe0000, INTC_INTMSKCLR2);
  304. break;
  305. case IRQ_MODE_IRL7654_MASK:
  306. /* enable IRL7-4 and mask using cpu intc controller */
  307. ctrl_outl(0x40000000, INTC_INTMSKCLR1);
  308. register_intc_controller(&intc_irl7654_desc);
  309. break;
  310. case IRQ_MODE_IRL3210_MASK:
  311. /* enable IRL0-3 and mask using cpu intc controller */
  312. ctrl_outl(0x80000000, INTC_INTMSKCLR1);
  313. register_intc_controller(&intc_irl3210_desc);
  314. break;
  315. default:
  316. BUG();
  317. }
  318. }