setup-sh7720.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Setup code for SH7720, SH7721.
  4. *
  5. * Copyright (C) 2007 Markus Brunner, Mark Jonas
  6. * Copyright (C) 2009 Paul Mundt
  7. *
  8. * Based on arch/sh/kernel/cpu/sh4/setup-sh7750.c:
  9. *
  10. * Copyright (C) 2006 Paul Mundt
  11. * Copyright (C) 2006 Jamie Lenehan
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/init.h>
  15. #include <linux/serial.h>
  16. #include <linux/io.h>
  17. #include <linux/serial_sci.h>
  18. #include <linux/sh_timer.h>
  19. #include <linux/sh_intc.h>
  20. #include <linux/usb/ohci_pdriver.h>
  21. #include <asm/rtc.h>
  22. #include <asm/platform_early.h>
  23. #include <cpu/serial.h>
  24. static struct resource rtc_resources[] = {
  25. [0] = {
  26. .start = 0xa413fec0,
  27. .end = 0xa413fec0 + 0x28 - 1,
  28. .flags = IORESOURCE_IO,
  29. },
  30. [1] = {
  31. /* Shared Period/Carry/Alarm IRQ */
  32. .start = evt2irq(0x480),
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. };
  36. static struct sh_rtc_platform_info rtc_info = {
  37. .capabilities = RTC_CAP_4_DIGIT_YEAR,
  38. };
  39. static struct platform_device rtc_device = {
  40. .name = "sh-rtc",
  41. .id = -1,
  42. .num_resources = ARRAY_SIZE(rtc_resources),
  43. .resource = rtc_resources,
  44. .dev = {
  45. .platform_data = &rtc_info,
  46. },
  47. };
  48. static struct plat_sci_port scif0_platform_data = {
  49. .type = PORT_SCIF,
  50. .ops = &sh7720_sci_port_ops,
  51. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  52. };
  53. static struct resource scif0_resources[] = {
  54. DEFINE_RES_MEM(0xa4430000, 0x100),
  55. DEFINE_RES_IRQ(evt2irq(0xc00)),
  56. };
  57. static struct platform_device scif0_device = {
  58. .name = "sh-sci",
  59. .id = 0,
  60. .resource = scif0_resources,
  61. .num_resources = ARRAY_SIZE(scif0_resources),
  62. .dev = {
  63. .platform_data = &scif0_platform_data,
  64. },
  65. };
  66. static struct plat_sci_port scif1_platform_data = {
  67. .type = PORT_SCIF,
  68. .ops = &sh7720_sci_port_ops,
  69. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  70. };
  71. static struct resource scif1_resources[] = {
  72. DEFINE_RES_MEM(0xa4438000, 0x100),
  73. DEFINE_RES_IRQ(evt2irq(0xc20)),
  74. };
  75. static struct platform_device scif1_device = {
  76. .name = "sh-sci",
  77. .id = 1,
  78. .resource = scif1_resources,
  79. .num_resources = ARRAY_SIZE(scif1_resources),
  80. .dev = {
  81. .platform_data = &scif1_platform_data,
  82. },
  83. };
  84. static struct resource usb_ohci_resources[] = {
  85. [0] = {
  86. .start = 0xA4428000,
  87. .end = 0xA44280FF,
  88. .flags = IORESOURCE_MEM,
  89. },
  90. [1] = {
  91. .start = evt2irq(0xa60),
  92. .end = evt2irq(0xa60),
  93. .flags = IORESOURCE_IRQ,
  94. },
  95. };
  96. static u64 usb_ohci_dma_mask = 0xffffffffUL;
  97. static struct usb_ohci_pdata usb_ohci_pdata;
  98. static struct platform_device usb_ohci_device = {
  99. .name = "ohci-platform",
  100. .id = -1,
  101. .dev = {
  102. .dma_mask = &usb_ohci_dma_mask,
  103. .coherent_dma_mask = 0xffffffff,
  104. .platform_data = &usb_ohci_pdata,
  105. },
  106. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  107. .resource = usb_ohci_resources,
  108. };
  109. static struct resource usbf_resources[] = {
  110. [0] = {
  111. .name = "sh_udc",
  112. .start = 0xA4420000,
  113. .end = 0xA44200FF,
  114. .flags = IORESOURCE_MEM,
  115. },
  116. [1] = {
  117. .name = "sh_udc",
  118. .start = evt2irq(0xa20),
  119. .end = evt2irq(0xa20),
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device usbf_device = {
  124. .name = "sh_udc",
  125. .id = -1,
  126. .dev = {
  127. .dma_mask = NULL,
  128. .coherent_dma_mask = 0xffffffff,
  129. },
  130. .num_resources = ARRAY_SIZE(usbf_resources),
  131. .resource = usbf_resources,
  132. };
  133. static struct sh_timer_config cmt_platform_data = {
  134. .channels_mask = 0x1f,
  135. };
  136. static struct resource cmt_resources[] = {
  137. DEFINE_RES_MEM(0x044a0000, 0x60),
  138. DEFINE_RES_IRQ(evt2irq(0xf00)),
  139. };
  140. static struct platform_device cmt_device = {
  141. .name = "sh-cmt-32",
  142. .id = 0,
  143. .dev = {
  144. .platform_data = &cmt_platform_data,
  145. },
  146. .resource = cmt_resources,
  147. .num_resources = ARRAY_SIZE(cmt_resources),
  148. };
  149. static struct sh_timer_config tmu0_platform_data = {
  150. .channels_mask = 7,
  151. };
  152. static struct resource tmu0_resources[] = {
  153. DEFINE_RES_MEM(0xa412fe90, 0x28),
  154. DEFINE_RES_IRQ(evt2irq(0x400)),
  155. DEFINE_RES_IRQ(evt2irq(0x420)),
  156. DEFINE_RES_IRQ(evt2irq(0x440)),
  157. };
  158. static struct platform_device tmu0_device = {
  159. .name = "sh-tmu-sh3",
  160. .id = 0,
  161. .dev = {
  162. .platform_data = &tmu0_platform_data,
  163. },
  164. .resource = tmu0_resources,
  165. .num_resources = ARRAY_SIZE(tmu0_resources),
  166. };
  167. static struct platform_device *sh7720_devices[] __initdata = {
  168. &scif0_device,
  169. &scif1_device,
  170. &cmt_device,
  171. &tmu0_device,
  172. &rtc_device,
  173. &usb_ohci_device,
  174. &usbf_device,
  175. };
  176. static int __init sh7720_devices_setup(void)
  177. {
  178. return platform_add_devices(sh7720_devices,
  179. ARRAY_SIZE(sh7720_devices));
  180. }
  181. arch_initcall(sh7720_devices_setup);
  182. static struct platform_device *sh7720_early_devices[] __initdata = {
  183. &scif0_device,
  184. &scif1_device,
  185. &cmt_device,
  186. &tmu0_device,
  187. };
  188. void __init plat_early_device_setup(void)
  189. {
  190. sh_early_platform_add_devices(sh7720_early_devices,
  191. ARRAY_SIZE(sh7720_early_devices));
  192. }
  193. enum {
  194. UNUSED = 0,
  195. /* interrupt sources */
  196. TMU0, TMU1, TMU2, RTC,
  197. WDT, REF_RCMI, SIM,
  198. IRQ0, IRQ1, IRQ2, IRQ3,
  199. USBF_SPD, TMU_SUNI, IRQ5, IRQ4,
  200. DMAC1, LCDC, SSL,
  201. ADC, DMAC2, USBFI, CMT,
  202. SCIF0, SCIF1,
  203. PINT07, PINT815, TPU, IIC,
  204. SIOF0, SIOF1, MMC, PCC,
  205. USBHI, AFEIF,
  206. H_UDI,
  207. };
  208. static struct intc_vect vectors[] __initdata = {
  209. /* IRQ0->5 are handled in setup-sh3.c */
  210. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  211. INTC_VECT(TMU2, 0x440), INTC_VECT(RTC, 0x480),
  212. INTC_VECT(RTC, 0x4a0), INTC_VECT(RTC, 0x4c0),
  213. INTC_VECT(SIM, 0x4e0), INTC_VECT(SIM, 0x500),
  214. INTC_VECT(SIM, 0x520), INTC_VECT(SIM, 0x540),
  215. INTC_VECT(WDT, 0x560), INTC_VECT(REF_RCMI, 0x580),
  216. /* H_UDI cannot be masked */ INTC_VECT(TMU_SUNI, 0x6c0),
  217. INTC_VECT(USBF_SPD, 0x6e0), INTC_VECT(DMAC1, 0x800),
  218. INTC_VECT(DMAC1, 0x820), INTC_VECT(DMAC1, 0x840),
  219. INTC_VECT(DMAC1, 0x860), INTC_VECT(LCDC, 0x900),
  220. #if defined(CONFIG_CPU_SUBTYPE_SH7720)
  221. INTC_VECT(SSL, 0x980),
  222. #endif
  223. INTC_VECT(USBFI, 0xa20), INTC_VECT(USBFI, 0xa40),
  224. INTC_VECT(USBHI, 0xa60),
  225. INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
  226. INTC_VECT(ADC, 0xbe0), INTC_VECT(SCIF0, 0xc00),
  227. INTC_VECT(SCIF1, 0xc20), INTC_VECT(PINT07, 0xc80),
  228. INTC_VECT(PINT815, 0xca0), INTC_VECT(SIOF0, 0xd00),
  229. INTC_VECT(SIOF1, 0xd20), INTC_VECT(TPU, 0xd80),
  230. INTC_VECT(TPU, 0xda0), INTC_VECT(TPU, 0xdc0),
  231. INTC_VECT(TPU, 0xde0), INTC_VECT(IIC, 0xe00),
  232. INTC_VECT(MMC, 0xe80), INTC_VECT(MMC, 0xea0),
  233. INTC_VECT(MMC, 0xec0), INTC_VECT(MMC, 0xee0),
  234. INTC_VECT(CMT, 0xf00), INTC_VECT(PCC, 0xf60),
  235. INTC_VECT(AFEIF, 0xfe0),
  236. };
  237. static struct intc_prio_reg prio_registers[] __initdata = {
  238. { 0xA414FEE2UL, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  239. { 0xA414FEE4UL, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, SIM, 0 } },
  240. { 0xA4140016UL, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  241. { 0xA4140018UL, 0, 16, 4, /* IPRD */ { USBF_SPD, TMU_SUNI, IRQ5, IRQ4 } },
  242. { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, SSL } },
  243. { 0xA4080000UL, 0, 16, 4, /* IPRF */ { ADC, DMAC2, USBFI, CMT } },
  244. { 0xA4080002UL, 0, 16, 4, /* IPRG */ { SCIF0, SCIF1, 0, 0 } },
  245. { 0xA4080004UL, 0, 16, 4, /* IPRH */ { PINT07, PINT815, TPU, IIC } },
  246. { 0xA4080006UL, 0, 16, 4, /* IPRI */ { SIOF0, SIOF1, MMC, PCC } },
  247. { 0xA4080008UL, 0, 16, 4, /* IPRJ */ { 0, USBHI, 0, AFEIF } },
  248. };
  249. static DECLARE_INTC_DESC(intc_desc, "sh7720", vectors, NULL,
  250. NULL, prio_registers, NULL);
  251. void __init plat_irq_setup(void)
  252. {
  253. register_intc_controller(&intc_desc);
  254. plat_irq_setup_sh3();
  255. }