setup-sh7720.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. .flags = UPF_BOOT_AUTOCONF,
  52. .scscr = SCSCR_RE | SCSCR_TE,
  53. .type = PORT_SCIF,
  54. .ops = &sh7720_sci_port_ops,
  55. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  56. };
  57. static struct resource scif0_resources[] = {
  58. DEFINE_RES_MEM(0xa4430000, 0x100),
  59. DEFINE_RES_IRQ(evt2irq(0xc00)),
  60. };
  61. static struct platform_device scif0_device = {
  62. .name = "sh-sci",
  63. .id = 0,
  64. .resource = scif0_resources,
  65. .num_resources = ARRAY_SIZE(scif0_resources),
  66. .dev = {
  67. .platform_data = &scif0_platform_data,
  68. },
  69. };
  70. static struct plat_sci_port scif1_platform_data = {
  71. .flags = UPF_BOOT_AUTOCONF,
  72. .scscr = SCSCR_RE | SCSCR_TE,
  73. .type = PORT_SCIF,
  74. .ops = &sh7720_sci_port_ops,
  75. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  76. };
  77. static struct resource scif1_resources[] = {
  78. DEFINE_RES_MEM(0xa4438000, 0x100),
  79. DEFINE_RES_IRQ(evt2irq(0xc20)),
  80. };
  81. static struct platform_device scif1_device = {
  82. .name = "sh-sci",
  83. .id = 1,
  84. .resource = scif1_resources,
  85. .num_resources = ARRAY_SIZE(scif1_resources),
  86. .dev = {
  87. .platform_data = &scif1_platform_data,
  88. },
  89. };
  90. static struct resource usb_ohci_resources[] = {
  91. [0] = {
  92. .start = 0xA4428000,
  93. .end = 0xA44280FF,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. [1] = {
  97. .start = evt2irq(0xa60),
  98. .end = evt2irq(0xa60),
  99. .flags = IORESOURCE_IRQ,
  100. },
  101. };
  102. static u64 usb_ohci_dma_mask = 0xffffffffUL;
  103. static struct usb_ohci_pdata usb_ohci_pdata;
  104. static struct platform_device usb_ohci_device = {
  105. .name = "ohci-platform",
  106. .id = -1,
  107. .dev = {
  108. .dma_mask = &usb_ohci_dma_mask,
  109. .coherent_dma_mask = 0xffffffff,
  110. .platform_data = &usb_ohci_pdata,
  111. },
  112. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  113. .resource = usb_ohci_resources,
  114. };
  115. static struct resource usbf_resources[] = {
  116. [0] = {
  117. .name = "sh_udc",
  118. .start = 0xA4420000,
  119. .end = 0xA44200FF,
  120. .flags = IORESOURCE_MEM,
  121. },
  122. [1] = {
  123. .name = "sh_udc",
  124. .start = evt2irq(0xa20),
  125. .end = evt2irq(0xa20),
  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 cmt_platform_data = {
  140. .channels_mask = 0x1f,
  141. };
  142. static struct resource cmt_resources[] = {
  143. DEFINE_RES_MEM(0x044a0000, 0x60),
  144. DEFINE_RES_IRQ(evt2irq(0xf00)),
  145. };
  146. static struct platform_device cmt_device = {
  147. .name = "sh-cmt-32",
  148. .id = 0,
  149. .dev = {
  150. .platform_data = &cmt_platform_data,
  151. },
  152. .resource = cmt_resources,
  153. .num_resources = ARRAY_SIZE(cmt_resources),
  154. };
  155. static struct sh_timer_config tmu0_platform_data = {
  156. .channels_mask = 7,
  157. };
  158. static struct resource tmu0_resources[] = {
  159. DEFINE_RES_MEM(0xa412fe90, 0x28),
  160. DEFINE_RES_IRQ(evt2irq(0x400)),
  161. DEFINE_RES_IRQ(evt2irq(0x420)),
  162. DEFINE_RES_IRQ(evt2irq(0x440)),
  163. };
  164. static struct platform_device tmu0_device = {
  165. .name = "sh-tmu-sh3",
  166. .id = 0,
  167. .dev = {
  168. .platform_data = &tmu0_platform_data,
  169. },
  170. .resource = tmu0_resources,
  171. .num_resources = ARRAY_SIZE(tmu0_resources),
  172. };
  173. static struct platform_device *sh7720_devices[] __initdata = {
  174. &scif0_device,
  175. &scif1_device,
  176. &cmt_device,
  177. &tmu0_device,
  178. &rtc_device,
  179. &usb_ohci_device,
  180. &usbf_device,
  181. };
  182. static int __init sh7720_devices_setup(void)
  183. {
  184. return platform_add_devices(sh7720_devices,
  185. ARRAY_SIZE(sh7720_devices));
  186. }
  187. arch_initcall(sh7720_devices_setup);
  188. static struct platform_device *sh7720_early_devices[] __initdata = {
  189. &scif0_device,
  190. &scif1_device,
  191. &cmt_device,
  192. &tmu0_device,
  193. };
  194. void __init plat_early_device_setup(void)
  195. {
  196. early_platform_add_devices(sh7720_early_devices,
  197. ARRAY_SIZE(sh7720_early_devices));
  198. }
  199. enum {
  200. UNUSED = 0,
  201. /* interrupt sources */
  202. TMU0, TMU1, TMU2, RTC,
  203. WDT, REF_RCMI, SIM,
  204. IRQ0, IRQ1, IRQ2, IRQ3,
  205. USBF_SPD, TMU_SUNI, IRQ5, IRQ4,
  206. DMAC1, LCDC, SSL,
  207. ADC, DMAC2, USBFI, CMT,
  208. SCIF0, SCIF1,
  209. PINT07, PINT815, TPU, IIC,
  210. SIOF0, SIOF1, MMC, PCC,
  211. USBHI, AFEIF,
  212. H_UDI,
  213. };
  214. static struct intc_vect vectors[] __initdata = {
  215. /* IRQ0->5 are handled in setup-sh3.c */
  216. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  217. INTC_VECT(TMU2, 0x440), INTC_VECT(RTC, 0x480),
  218. INTC_VECT(RTC, 0x4a0), INTC_VECT(RTC, 0x4c0),
  219. INTC_VECT(SIM, 0x4e0), INTC_VECT(SIM, 0x500),
  220. INTC_VECT(SIM, 0x520), INTC_VECT(SIM, 0x540),
  221. INTC_VECT(WDT, 0x560), INTC_VECT(REF_RCMI, 0x580),
  222. /* H_UDI cannot be masked */ INTC_VECT(TMU_SUNI, 0x6c0),
  223. INTC_VECT(USBF_SPD, 0x6e0), INTC_VECT(DMAC1, 0x800),
  224. INTC_VECT(DMAC1, 0x820), INTC_VECT(DMAC1, 0x840),
  225. INTC_VECT(DMAC1, 0x860), INTC_VECT(LCDC, 0x900),
  226. #if defined(CONFIG_CPU_SUBTYPE_SH7720)
  227. INTC_VECT(SSL, 0x980),
  228. #endif
  229. INTC_VECT(USBFI, 0xa20), INTC_VECT(USBFI, 0xa40),
  230. INTC_VECT(USBHI, 0xa60),
  231. INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
  232. INTC_VECT(ADC, 0xbe0), INTC_VECT(SCIF0, 0xc00),
  233. INTC_VECT(SCIF1, 0xc20), INTC_VECT(PINT07, 0xc80),
  234. INTC_VECT(PINT815, 0xca0), INTC_VECT(SIOF0, 0xd00),
  235. INTC_VECT(SIOF1, 0xd20), INTC_VECT(TPU, 0xd80),
  236. INTC_VECT(TPU, 0xda0), INTC_VECT(TPU, 0xdc0),
  237. INTC_VECT(TPU, 0xde0), INTC_VECT(IIC, 0xe00),
  238. INTC_VECT(MMC, 0xe80), INTC_VECT(MMC, 0xea0),
  239. INTC_VECT(MMC, 0xec0), INTC_VECT(MMC, 0xee0),
  240. INTC_VECT(CMT, 0xf00), INTC_VECT(PCC, 0xf60),
  241. INTC_VECT(AFEIF, 0xfe0),
  242. };
  243. static struct intc_prio_reg prio_registers[] __initdata = {
  244. { 0xA414FEE2UL, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  245. { 0xA414FEE4UL, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, SIM, 0 } },
  246. { 0xA4140016UL, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  247. { 0xA4140018UL, 0, 16, 4, /* IPRD */ { USBF_SPD, TMU_SUNI, IRQ5, IRQ4 } },
  248. { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, SSL } },
  249. { 0xA4080000UL, 0, 16, 4, /* IPRF */ { ADC, DMAC2, USBFI, CMT } },
  250. { 0xA4080002UL, 0, 16, 4, /* IPRG */ { SCIF0, SCIF1, 0, 0 } },
  251. { 0xA4080004UL, 0, 16, 4, /* IPRH */ { PINT07, PINT815, TPU, IIC } },
  252. { 0xA4080006UL, 0, 16, 4, /* IPRI */ { SIOF0, SIOF1, MMC, PCC } },
  253. { 0xA4080008UL, 0, 16, 4, /* IPRJ */ { 0, USBHI, 0, AFEIF } },
  254. };
  255. static DECLARE_INTC_DESC(intc_desc, "sh7720", vectors, NULL,
  256. NULL, prio_registers, NULL);
  257. void __init plat_irq_setup(void)
  258. {
  259. register_intc_controller(&intc_desc);
  260. plat_irq_setup_sh3();
  261. }