setup-sh7720.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * SH7720 Setup
  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 <asm/rtc.h>
  23. static struct resource rtc_resources[] = {
  24. [0] = {
  25. .start = 0xa413fec0,
  26. .end = 0xa413fec0 + 0x28 - 1,
  27. .flags = IORESOURCE_IO,
  28. },
  29. [1] = {
  30. /* Shared Period/Carry/Alarm IRQ */
  31. .start = 20,
  32. .flags = IORESOURCE_IRQ,
  33. },
  34. };
  35. static struct sh_rtc_platform_info rtc_info = {
  36. .capabilities = RTC_CAP_4_DIGIT_YEAR,
  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. .dev = {
  44. .platform_data = &rtc_info,
  45. },
  46. };
  47. static struct plat_sci_port sci_platform_data[] = {
  48. {
  49. .mapbase = 0xa4430000,
  50. .flags = UPF_BOOT_AUTOCONF,
  51. .type = PORT_SCIF,
  52. .irqs = { 80, 80, 80, 80 },
  53. }, {
  54. .mapbase = 0xa4438000,
  55. .flags = UPF_BOOT_AUTOCONF,
  56. .type = PORT_SCIF,
  57. .irqs = { 81, 81, 81, 81 },
  58. }, {
  59. .flags = 0,
  60. }
  61. };
  62. static struct platform_device sci_device = {
  63. .name = "sh-sci",
  64. .id = -1,
  65. .dev = {
  66. .platform_data = sci_platform_data,
  67. },
  68. };
  69. static struct resource usb_ohci_resources[] = {
  70. [0] = {
  71. .start = 0xA4428000,
  72. .end = 0xA44280FF,
  73. .flags = IORESOURCE_MEM,
  74. },
  75. [1] = {
  76. .start = 67,
  77. .end = 67,
  78. .flags = IORESOURCE_IRQ,
  79. },
  80. };
  81. static u64 usb_ohci_dma_mask = 0xffffffffUL;
  82. static struct platform_device usb_ohci_device = {
  83. .name = "sh_ohci",
  84. .id = -1,
  85. .dev = {
  86. .dma_mask = &usb_ohci_dma_mask,
  87. .coherent_dma_mask = 0xffffffff,
  88. },
  89. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  90. .resource = usb_ohci_resources,
  91. };
  92. static struct resource usbf_resources[] = {
  93. [0] = {
  94. .name = "sh_udc",
  95. .start = 0xA4420000,
  96. .end = 0xA44200FF,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. [1] = {
  100. .name = "sh_udc",
  101. .start = 65,
  102. .end = 65,
  103. .flags = IORESOURCE_IRQ,
  104. },
  105. };
  106. static struct platform_device usbf_device = {
  107. .name = "sh_udc",
  108. .id = -1,
  109. .dev = {
  110. .dma_mask = NULL,
  111. .coherent_dma_mask = 0xffffffff,
  112. },
  113. .num_resources = ARRAY_SIZE(usbf_resources),
  114. .resource = usbf_resources,
  115. };
  116. static struct sh_timer_config tmu0_platform_data = {
  117. .name = "TMU0",
  118. .channel_offset = 0x02,
  119. .timer_bit = 0,
  120. .clk = "module_clk",
  121. .clockevent_rating = 200,
  122. };
  123. static struct resource tmu0_resources[] = {
  124. [0] = {
  125. .name = "TMU0",
  126. .start = 0xa412fe94,
  127. .end = 0xa412fe9f,
  128. .flags = IORESOURCE_MEM,
  129. },
  130. [1] = {
  131. .start = 16,
  132. .flags = IORESOURCE_IRQ,
  133. },
  134. };
  135. static struct platform_device tmu0_device = {
  136. .name = "sh_tmu",
  137. .id = 0,
  138. .dev = {
  139. .platform_data = &tmu0_platform_data,
  140. },
  141. .resource = tmu0_resources,
  142. .num_resources = ARRAY_SIZE(tmu0_resources),
  143. };
  144. static struct sh_timer_config tmu1_platform_data = {
  145. .name = "TMU1",
  146. .channel_offset = 0xe,
  147. .timer_bit = 1,
  148. .clk = "module_clk",
  149. .clocksource_rating = 200,
  150. };
  151. static struct resource tmu1_resources[] = {
  152. [0] = {
  153. .name = "TMU1",
  154. .start = 0xa412fea0,
  155. .end = 0xa412feab,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. [1] = {
  159. .start = 17,
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device tmu1_device = {
  164. .name = "sh_tmu",
  165. .id = 1,
  166. .dev = {
  167. .platform_data = &tmu1_platform_data,
  168. },
  169. .resource = tmu1_resources,
  170. .num_resources = ARRAY_SIZE(tmu1_resources),
  171. };
  172. static struct sh_timer_config tmu2_platform_data = {
  173. .name = "TMU2",
  174. .channel_offset = 0x1a,
  175. .timer_bit = 2,
  176. .clk = "module_clk",
  177. };
  178. static struct resource tmu2_resources[] = {
  179. [0] = {
  180. .name = "TMU2",
  181. .start = 0xa412feac,
  182. .end = 0xa412feb5,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. [1] = {
  186. .start = 18,
  187. .flags = IORESOURCE_IRQ,
  188. },
  189. };
  190. static struct platform_device tmu2_device = {
  191. .name = "sh_tmu",
  192. .id = 2,
  193. .dev = {
  194. .platform_data = &tmu2_platform_data,
  195. },
  196. .resource = tmu2_resources,
  197. .num_resources = ARRAY_SIZE(tmu2_resources),
  198. };
  199. static struct platform_device *sh7720_devices[] __initdata = {
  200. &tmu0_device,
  201. &tmu1_device,
  202. &tmu2_device,
  203. &rtc_device,
  204. &sci_device,
  205. &usb_ohci_device,
  206. &usbf_device,
  207. };
  208. static int __init sh7720_devices_setup(void)
  209. {
  210. return platform_add_devices(sh7720_devices,
  211. ARRAY_SIZE(sh7720_devices));
  212. }
  213. __initcall(sh7720_devices_setup);
  214. static struct platform_device *sh7720_early_devices[] __initdata = {
  215. &tmu0_device,
  216. &tmu1_device,
  217. &tmu2_device,
  218. };
  219. void __init plat_early_device_setup(void)
  220. {
  221. early_platform_add_devices(sh7720_early_devices,
  222. ARRAY_SIZE(sh7720_early_devices));
  223. }
  224. enum {
  225. UNUSED = 0,
  226. /* interrupt sources */
  227. TMU0, TMU1, TMU2, RTC,
  228. WDT, REF_RCMI, SIM,
  229. IRQ0, IRQ1, IRQ2, IRQ3,
  230. USBF_SPD, TMU_SUNI, IRQ5, IRQ4,
  231. DMAC1, LCDC, SSL,
  232. ADC, DMAC2, USBFI, CMT,
  233. SCIF0, SCIF1,
  234. PINT07, PINT815, TPU, IIC,
  235. SIOF0, SIOF1, MMC, PCC,
  236. USBHI, AFEIF,
  237. H_UDI,
  238. };
  239. static struct intc_vect vectors[] __initdata = {
  240. /* IRQ0->5 are handled in setup-sh3.c */
  241. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  242. INTC_VECT(TMU2, 0x440), INTC_VECT(RTC, 0x480),
  243. INTC_VECT(RTC, 0x4a0), INTC_VECT(RTC, 0x4c0),
  244. INTC_VECT(SIM, 0x4e0), INTC_VECT(SIM, 0x500),
  245. INTC_VECT(SIM, 0x520), INTC_VECT(SIM, 0x540),
  246. INTC_VECT(WDT, 0x560), INTC_VECT(REF_RCMI, 0x580),
  247. /* H_UDI cannot be masked */ INTC_VECT(TMU_SUNI, 0x6c0),
  248. INTC_VECT(USBF_SPD, 0x6e0), INTC_VECT(DMAC1, 0x800),
  249. INTC_VECT(DMAC1, 0x820), INTC_VECT(DMAC1, 0x840),
  250. INTC_VECT(DMAC1, 0x860), INTC_VECT(LCDC, 0x900),
  251. #if defined(CONFIG_CPU_SUBTYPE_SH7720)
  252. INTC_VECT(SSL, 0x980),
  253. #endif
  254. INTC_VECT(USBFI, 0xa20), INTC_VECT(USBFI, 0xa40),
  255. INTC_VECT(USBHI, 0xa60),
  256. INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
  257. INTC_VECT(ADC, 0xbe0), INTC_VECT(SCIF0, 0xc00),
  258. INTC_VECT(SCIF1, 0xc20), INTC_VECT(PINT07, 0xc80),
  259. INTC_VECT(PINT815, 0xca0), INTC_VECT(SIOF0, 0xd00),
  260. INTC_VECT(SIOF1, 0xd20), INTC_VECT(TPU, 0xd80),
  261. INTC_VECT(TPU, 0xda0), INTC_VECT(TPU, 0xdc0),
  262. INTC_VECT(TPU, 0xde0), INTC_VECT(IIC, 0xe00),
  263. INTC_VECT(MMC, 0xe80), INTC_VECT(MMC, 0xea0),
  264. INTC_VECT(MMC, 0xec0), INTC_VECT(MMC, 0xee0),
  265. INTC_VECT(CMT, 0xf00), INTC_VECT(PCC, 0xf60),
  266. INTC_VECT(AFEIF, 0xfe0),
  267. };
  268. static struct intc_prio_reg prio_registers[] __initdata = {
  269. { 0xA414FEE2UL, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  270. { 0xA414FEE4UL, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, SIM, 0 } },
  271. { 0xA4140016UL, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  272. { 0xA4140018UL, 0, 16, 4, /* IPRD */ { USBF_SPD, TMU_SUNI, IRQ5, IRQ4 } },
  273. { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, SSL } },
  274. { 0xA4080000UL, 0, 16, 4, /* IPRF */ { ADC, DMAC2, USBFI, CMT } },
  275. { 0xA4080002UL, 0, 16, 4, /* IPRG */ { SCIF0, SCIF1, 0, 0 } },
  276. { 0xA4080004UL, 0, 16, 4, /* IPRH */ { PINT07, PINT815, TPU, IIC } },
  277. { 0xA4080006UL, 0, 16, 4, /* IPRI */ { SIOF0, SIOF1, MMC, PCC } },
  278. { 0xA4080008UL, 0, 16, 4, /* IPRJ */ { 0, USBHI, 0, AFEIF } },
  279. };
  280. static DECLARE_INTC_DESC(intc_desc, "sh7720", vectors, NULL,
  281. NULL, prio_registers, NULL);
  282. void __init plat_irq_setup(void)
  283. {
  284. register_intc_controller(&intc_desc);
  285. plat_irq_setup_sh3();
  286. }