setup-sh7720.c 7.2 KB

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