setup-sh7619.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * SH7619 Setup
  3. *
  4. * Copyright (C) 2006 Yoshinori Sato
  5. * Copyright (C) 2009 Paul Mundt
  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/serial.h>
  14. #include <linux/serial_sci.h>
  15. #include <linux/sh_timer.h>
  16. #include <linux/io.h>
  17. enum {
  18. UNUSED = 0,
  19. /* interrupt sources */
  20. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  21. WDT, EDMAC, CMT0, CMT1,
  22. SCIF0, SCIF1, SCIF2,
  23. HIF_HIFI, HIF_HIFBI,
  24. DMAC0, DMAC1, DMAC2, DMAC3,
  25. SIOF,
  26. };
  27. static struct intc_vect vectors[] __initdata = {
  28. INTC_IRQ(IRQ0, 64), INTC_IRQ(IRQ1, 65),
  29. INTC_IRQ(IRQ2, 66), INTC_IRQ(IRQ3, 67),
  30. INTC_IRQ(IRQ4, 80), INTC_IRQ(IRQ5, 81),
  31. INTC_IRQ(IRQ6, 82), INTC_IRQ(IRQ7, 83),
  32. INTC_IRQ(WDT, 84), INTC_IRQ(EDMAC, 85),
  33. INTC_IRQ(CMT0, 86), INTC_IRQ(CMT1, 87),
  34. INTC_IRQ(SCIF0, 88), INTC_IRQ(SCIF0, 89),
  35. INTC_IRQ(SCIF0, 90), INTC_IRQ(SCIF0, 91),
  36. INTC_IRQ(SCIF1, 92), INTC_IRQ(SCIF1, 93),
  37. INTC_IRQ(SCIF1, 94), INTC_IRQ(SCIF1, 95),
  38. INTC_IRQ(SCIF2, 96), INTC_IRQ(SCIF2, 97),
  39. INTC_IRQ(SCIF2, 98), INTC_IRQ(SCIF2, 99),
  40. INTC_IRQ(HIF_HIFI, 100), INTC_IRQ(HIF_HIFBI, 101),
  41. INTC_IRQ(DMAC0, 104), INTC_IRQ(DMAC1, 105),
  42. INTC_IRQ(DMAC2, 106), INTC_IRQ(DMAC3, 107),
  43. INTC_IRQ(SIOF, 108),
  44. };
  45. static struct intc_prio_reg prio_registers[] __initdata = {
  46. { 0xf8140006, 0, 16, 4, /* IPRA */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  47. { 0xf8140008, 0, 16, 4, /* IPRB */ { IRQ4, IRQ5, IRQ6, IRQ7 } },
  48. { 0xf8080000, 0, 16, 4, /* IPRC */ { WDT, EDMAC, CMT0, CMT1 } },
  49. { 0xf8080002, 0, 16, 4, /* IPRD */ { SCIF0, SCIF1, SCIF2 } },
  50. { 0xf8080004, 0, 16, 4, /* IPRE */ { HIF_HIFI, HIF_HIFBI } },
  51. { 0xf8080006, 0, 16, 4, /* IPRF */ { DMAC0, DMAC1, DMAC2, DMAC3 } },
  52. { 0xf8080008, 0, 16, 4, /* IPRG */ { SIOF } },
  53. };
  54. static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL,
  55. NULL, prio_registers, NULL);
  56. static struct plat_sci_port scif0_platform_data = {
  57. .mapbase = 0xf8400000,
  58. .flags = UPF_BOOT_AUTOCONF,
  59. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  60. .scbrr_algo_id = SCBRR_ALGO_2,
  61. .type = PORT_SCIF,
  62. .irqs = { 88, 88, 88, 88 },
  63. };
  64. static struct platform_device scif0_device = {
  65. .name = "sh-sci",
  66. .id = 0,
  67. .dev = {
  68. .platform_data = &scif0_platform_data,
  69. },
  70. };
  71. static struct plat_sci_port scif1_platform_data = {
  72. .mapbase = 0xf8410000,
  73. .flags = UPF_BOOT_AUTOCONF,
  74. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  75. .scbrr_algo_id = SCBRR_ALGO_2,
  76. .type = PORT_SCIF,
  77. .irqs = { 92, 92, 92, 92 },
  78. };
  79. static struct platform_device scif1_device = {
  80. .name = "sh-sci",
  81. .id = 1,
  82. .dev = {
  83. .platform_data = &scif1_platform_data,
  84. },
  85. };
  86. static struct plat_sci_port scif2_platform_data = {
  87. .mapbase = 0xf8420000,
  88. .flags = UPF_BOOT_AUTOCONF,
  89. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  90. .scbrr_algo_id = SCBRR_ALGO_2,
  91. .type = PORT_SCIF,
  92. .irqs = { 96, 96, 96, 96 },
  93. };
  94. static struct platform_device scif2_device = {
  95. .name = "sh-sci",
  96. .id = 2,
  97. .dev = {
  98. .platform_data = &scif2_platform_data,
  99. },
  100. };
  101. static struct resource eth_resources[] = {
  102. [0] = {
  103. .start = 0xfb000000,
  104. .end = 0xfb0001c8,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. [1] = {
  108. .start = 85,
  109. .end = 85,
  110. .flags = IORESOURCE_IRQ,
  111. },
  112. };
  113. static struct platform_device eth_device = {
  114. .name = "sh-eth",
  115. .id = -1,
  116. .dev = {
  117. .platform_data = (void *)1,
  118. },
  119. .num_resources = ARRAY_SIZE(eth_resources),
  120. .resource = eth_resources,
  121. };
  122. static struct sh_timer_config cmt0_platform_data = {
  123. .channel_offset = 0x02,
  124. .timer_bit = 0,
  125. .clockevent_rating = 125,
  126. .clocksource_rating = 0, /* disabled due to code generation issues */
  127. };
  128. static struct resource cmt0_resources[] = {
  129. [0] = {
  130. .start = 0xf84a0072,
  131. .end = 0xf84a0077,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. [1] = {
  135. .start = 86,
  136. .flags = IORESOURCE_IRQ,
  137. },
  138. };
  139. static struct platform_device cmt0_device = {
  140. .name = "sh_cmt",
  141. .id = 0,
  142. .dev = {
  143. .platform_data = &cmt0_platform_data,
  144. },
  145. .resource = cmt0_resources,
  146. .num_resources = ARRAY_SIZE(cmt0_resources),
  147. };
  148. static struct sh_timer_config cmt1_platform_data = {
  149. .channel_offset = 0x08,
  150. .timer_bit = 1,
  151. .clockevent_rating = 125,
  152. .clocksource_rating = 0, /* disabled due to code generation issues */
  153. };
  154. static struct resource cmt1_resources[] = {
  155. [0] = {
  156. .start = 0xf84a0078,
  157. .end = 0xf84a007d,
  158. .flags = IORESOURCE_MEM,
  159. },
  160. [1] = {
  161. .start = 87,
  162. .flags = IORESOURCE_IRQ,
  163. },
  164. };
  165. static struct platform_device cmt1_device = {
  166. .name = "sh_cmt",
  167. .id = 1,
  168. .dev = {
  169. .platform_data = &cmt1_platform_data,
  170. },
  171. .resource = cmt1_resources,
  172. .num_resources = ARRAY_SIZE(cmt1_resources),
  173. };
  174. static struct platform_device *sh7619_devices[] __initdata = {
  175. &scif0_device,
  176. &scif1_device,
  177. &scif2_device,
  178. &eth_device,
  179. &cmt0_device,
  180. &cmt1_device,
  181. };
  182. static int __init sh7619_devices_setup(void)
  183. {
  184. return platform_add_devices(sh7619_devices,
  185. ARRAY_SIZE(sh7619_devices));
  186. }
  187. arch_initcall(sh7619_devices_setup);
  188. void __init plat_irq_setup(void)
  189. {
  190. register_intc_controller(&intc_desc);
  191. }
  192. static struct platform_device *sh7619_early_devices[] __initdata = {
  193. &scif0_device,
  194. &scif1_device,
  195. &scif2_device,
  196. &cmt0_device,
  197. &cmt1_device,
  198. };
  199. #define STBCR3 0xf80a0000
  200. void __init plat_early_device_setup(void)
  201. {
  202. /* enable CMT clock */
  203. __raw_writeb(__raw_readb(STBCR3) & ~0x10, STBCR3);
  204. early_platform_add_devices(sh7619_early_devices,
  205. ARRAY_SIZE(sh7619_early_devices));
  206. }