setup-sh7763.c 12 KB

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