setup-sh7705.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*
  2. * SH7705 Setup
  3. *
  4. * Copyright (C) 2006 - 2009 Paul Mundt
  5. * Copyright (C) 2007 Nobuhiro Iwamatsu
  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/irq.h>
  14. #include <linux/serial.h>
  15. #include <linux/serial_sci.h>
  16. #include <linux/sh_timer.h>
  17. #include <asm/rtc.h>
  18. #include <cpu/serial.h>
  19. enum {
  20. UNUSED = 0,
  21. /* interrupt sources */
  22. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  23. PINT07, PINT815,
  24. DMAC, SCIF0, SCIF2, ADC_ADI, USB,
  25. TPU0, TPU1, TPU2, TPU3,
  26. TMU0, TMU1, TMU2,
  27. RTC, WDT, REF_RCMI,
  28. };
  29. static struct intc_vect vectors[] __initdata = {
  30. /* IRQ0->5 are handled in setup-sh3.c */
  31. INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
  32. INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
  33. INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
  34. INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
  35. INTC_VECT(SCIF0, 0x8e0),
  36. INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
  37. INTC_VECT(SCIF2, 0x960),
  38. INTC_VECT(ADC_ADI, 0x980),
  39. INTC_VECT(USB, 0xa20), INTC_VECT(USB, 0xa40),
  40. INTC_VECT(TPU0, 0xc00), INTC_VECT(TPU1, 0xc20),
  41. INTC_VECT(TPU2, 0xc80), INTC_VECT(TPU3, 0xca0),
  42. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  43. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  44. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  45. INTC_VECT(RTC, 0x4c0),
  46. INTC_VECT(WDT, 0x560),
  47. INTC_VECT(REF_RCMI, 0x580),
  48. };
  49. static struct intc_prio_reg prio_registers[] __initdata = {
  50. { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  51. { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, 0, 0 } },
  52. { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  53. { 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, IRQ5, IRQ4 } },
  54. { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, SCIF0, SCIF2, ADC_ADI } },
  55. { 0xa4080000, 0, 16, 4, /* IPRF */ { 0, 0, USB } },
  56. { 0xa4080002, 0, 16, 4, /* IPRG */ { TPU0, TPU1 } },
  57. { 0xa4080004, 0, 16, 4, /* IPRH */ { TPU2, TPU3 } },
  58. };
  59. static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, NULL,
  60. NULL, prio_registers, NULL);
  61. static struct plat_sci_port scif0_platform_data = {
  62. .mapbase = 0xa4410000,
  63. .flags = UPF_BOOT_AUTOCONF,
  64. .scscr = SCSCR_TIE | SCSCR_RIE | SCSCR_TE |
  65. SCSCR_RE | SCSCR_CKE1 | SCSCR_CKE0,
  66. .scbrr_algo_id = SCBRR_ALGO_4,
  67. .type = PORT_SCIF,
  68. .irqs = { 56, 56, 56 },
  69. .ops = &sh770x_sci_port_ops,
  70. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  71. };
  72. static struct platform_device scif0_device = {
  73. .name = "sh-sci",
  74. .id = 0,
  75. .dev = {
  76. .platform_data = &scif0_platform_data,
  77. },
  78. };
  79. static struct plat_sci_port scif1_platform_data = {
  80. .mapbase = 0xa4400000,
  81. .flags = UPF_BOOT_AUTOCONF,
  82. .scscr = SCSCR_TIE | SCSCR_RIE | SCSCR_TE | SCSCR_RE,
  83. .scbrr_algo_id = SCBRR_ALGO_4,
  84. .type = PORT_SCIF,
  85. .irqs = { 52, 52, 52 },
  86. .ops = &sh770x_sci_port_ops,
  87. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  88. };
  89. static struct platform_device scif1_device = {
  90. .name = "sh-sci",
  91. .id = 1,
  92. .dev = {
  93. .platform_data = &scif1_platform_data,
  94. },
  95. };
  96. static struct resource rtc_resources[] = {
  97. [0] = {
  98. .start = 0xfffffec0,
  99. .end = 0xfffffec0 + 0x1e,
  100. .flags = IORESOURCE_IO,
  101. },
  102. [1] = {
  103. .start = 20,
  104. .flags = IORESOURCE_IRQ,
  105. },
  106. };
  107. static struct sh_rtc_platform_info rtc_info = {
  108. .capabilities = RTC_CAP_4_DIGIT_YEAR,
  109. };
  110. static struct platform_device rtc_device = {
  111. .name = "sh-rtc",
  112. .id = -1,
  113. .num_resources = ARRAY_SIZE(rtc_resources),
  114. .resource = rtc_resources,
  115. .dev = {
  116. .platform_data = &rtc_info,
  117. },
  118. };
  119. static struct sh_timer_config tmu0_platform_data = {
  120. .channel_offset = 0x02,
  121. .timer_bit = 0,
  122. .clockevent_rating = 200,
  123. };
  124. static struct resource tmu0_resources[] = {
  125. [0] = {
  126. .start = 0xfffffe94,
  127. .end = 0xfffffe9f,
  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. .channel_offset = 0xe,
  146. .timer_bit = 1,
  147. .clocksource_rating = 200,
  148. };
  149. static struct resource tmu1_resources[] = {
  150. [0] = {
  151. .start = 0xfffffea0,
  152. .end = 0xfffffeab,
  153. .flags = IORESOURCE_MEM,
  154. },
  155. [1] = {
  156. .start = 17,
  157. .flags = IORESOURCE_IRQ,
  158. },
  159. };
  160. static struct platform_device tmu1_device = {
  161. .name = "sh_tmu",
  162. .id = 1,
  163. .dev = {
  164. .platform_data = &tmu1_platform_data,
  165. },
  166. .resource = tmu1_resources,
  167. .num_resources = ARRAY_SIZE(tmu1_resources),
  168. };
  169. static struct sh_timer_config tmu2_platform_data = {
  170. .channel_offset = 0x1a,
  171. .timer_bit = 2,
  172. };
  173. static struct resource tmu2_resources[] = {
  174. [0] = {
  175. .start = 0xfffffeac,
  176. .end = 0xfffffebb,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = 18,
  181. .flags = IORESOURCE_IRQ,
  182. },
  183. };
  184. static struct platform_device tmu2_device = {
  185. .name = "sh_tmu",
  186. .id = 2,
  187. .dev = {
  188. .platform_data = &tmu2_platform_data,
  189. },
  190. .resource = tmu2_resources,
  191. .num_resources = ARRAY_SIZE(tmu2_resources),
  192. };
  193. static struct platform_device *sh7705_devices[] __initdata = {
  194. &scif0_device,
  195. &scif1_device,
  196. &tmu0_device,
  197. &tmu1_device,
  198. &tmu2_device,
  199. &rtc_device,
  200. };
  201. static int __init sh7705_devices_setup(void)
  202. {
  203. return platform_add_devices(sh7705_devices,
  204. ARRAY_SIZE(sh7705_devices));
  205. }
  206. arch_initcall(sh7705_devices_setup);
  207. static struct platform_device *sh7705_early_devices[] __initdata = {
  208. &scif0_device,
  209. &scif1_device,
  210. &tmu0_device,
  211. &tmu1_device,
  212. &tmu2_device,
  213. };
  214. void __init plat_early_device_setup(void)
  215. {
  216. early_platform_add_devices(sh7705_early_devices,
  217. ARRAY_SIZE(sh7705_early_devices));
  218. }
  219. void __init plat_irq_setup(void)
  220. {
  221. register_intc_controller(&intc_desc);
  222. plat_irq_setup_sh3();
  223. }