setup-sh7619.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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_eth.h>
  16. #include <linux/sh_timer.h>
  17. #include <linux/io.h>
  18. enum {
  19. UNUSED = 0,
  20. /* interrupt sources */
  21. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  22. WDT, EDMAC, CMT0, CMT1,
  23. SCIF0, SCIF1, SCIF2,
  24. HIF_HIFI, HIF_HIFBI,
  25. DMAC0, DMAC1, DMAC2, DMAC3,
  26. SIOF,
  27. };
  28. static struct intc_vect vectors[] __initdata = {
  29. INTC_IRQ(IRQ0, 64), INTC_IRQ(IRQ1, 65),
  30. INTC_IRQ(IRQ2, 66), INTC_IRQ(IRQ3, 67),
  31. INTC_IRQ(IRQ4, 80), INTC_IRQ(IRQ5, 81),
  32. INTC_IRQ(IRQ6, 82), INTC_IRQ(IRQ7, 83),
  33. INTC_IRQ(WDT, 84), INTC_IRQ(EDMAC, 85),
  34. INTC_IRQ(CMT0, 86), INTC_IRQ(CMT1, 87),
  35. INTC_IRQ(SCIF0, 88), INTC_IRQ(SCIF0, 89),
  36. INTC_IRQ(SCIF0, 90), INTC_IRQ(SCIF0, 91),
  37. INTC_IRQ(SCIF1, 92), INTC_IRQ(SCIF1, 93),
  38. INTC_IRQ(SCIF1, 94), INTC_IRQ(SCIF1, 95),
  39. INTC_IRQ(SCIF2, 96), INTC_IRQ(SCIF2, 97),
  40. INTC_IRQ(SCIF2, 98), INTC_IRQ(SCIF2, 99),
  41. INTC_IRQ(HIF_HIFI, 100), INTC_IRQ(HIF_HIFBI, 101),
  42. INTC_IRQ(DMAC0, 104), INTC_IRQ(DMAC1, 105),
  43. INTC_IRQ(DMAC2, 106), INTC_IRQ(DMAC3, 107),
  44. INTC_IRQ(SIOF, 108),
  45. };
  46. static struct intc_prio_reg prio_registers[] __initdata = {
  47. { 0xf8140006, 0, 16, 4, /* IPRA */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  48. { 0xf8140008, 0, 16, 4, /* IPRB */ { IRQ4, IRQ5, IRQ6, IRQ7 } },
  49. { 0xf8080000, 0, 16, 4, /* IPRC */ { WDT, EDMAC, CMT0, CMT1 } },
  50. { 0xf8080002, 0, 16, 4, /* IPRD */ { SCIF0, SCIF1, SCIF2 } },
  51. { 0xf8080004, 0, 16, 4, /* IPRE */ { HIF_HIFI, HIF_HIFBI } },
  52. { 0xf8080006, 0, 16, 4, /* IPRF */ { DMAC0, DMAC1, DMAC2, DMAC3 } },
  53. { 0xf8080008, 0, 16, 4, /* IPRG */ { SIOF } },
  54. };
  55. static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL,
  56. NULL, prio_registers, NULL);
  57. static struct plat_sci_port scif0_platform_data = {
  58. .scscr = SCSCR_REIE,
  59. .type = PORT_SCIF,
  60. };
  61. static struct resource scif0_resources[] = {
  62. DEFINE_RES_MEM(0xf8400000, 0x100),
  63. DEFINE_RES_IRQ(88),
  64. };
  65. static struct platform_device scif0_device = {
  66. .name = "sh-sci",
  67. .id = 0,
  68. .resource = scif0_resources,
  69. .num_resources = ARRAY_SIZE(scif0_resources),
  70. .dev = {
  71. .platform_data = &scif0_platform_data,
  72. },
  73. };
  74. static struct plat_sci_port scif1_platform_data = {
  75. .scscr = SCSCR_REIE,
  76. .type = PORT_SCIF,
  77. };
  78. static struct resource scif1_resources[] = {
  79. DEFINE_RES_MEM(0xf8410000, 0x100),
  80. DEFINE_RES_IRQ(92),
  81. };
  82. static struct platform_device scif1_device = {
  83. .name = "sh-sci",
  84. .id = 1,
  85. .resource = scif1_resources,
  86. .num_resources = ARRAY_SIZE(scif1_resources),
  87. .dev = {
  88. .platform_data = &scif1_platform_data,
  89. },
  90. };
  91. static struct plat_sci_port scif2_platform_data = {
  92. .scscr = SCSCR_REIE,
  93. .type = PORT_SCIF,
  94. };
  95. static struct resource scif2_resources[] = {
  96. DEFINE_RES_MEM(0xf8420000, 0x100),
  97. DEFINE_RES_IRQ(96),
  98. };
  99. static struct platform_device scif2_device = {
  100. .name = "sh-sci",
  101. .id = 2,
  102. .resource = scif2_resources,
  103. .num_resources = ARRAY_SIZE(scif2_resources),
  104. .dev = {
  105. .platform_data = &scif2_platform_data,
  106. },
  107. };
  108. static struct sh_eth_plat_data eth_platform_data = {
  109. .phy = 1,
  110. .phy_interface = PHY_INTERFACE_MODE_MII,
  111. };
  112. static struct resource eth_resources[] = {
  113. [0] = {
  114. .start = 0xfb000000,
  115. .end = 0xfb0001c7,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. [1] = {
  119. .start = 85,
  120. .end = 85,
  121. .flags = IORESOURCE_IRQ,
  122. },
  123. };
  124. static struct platform_device eth_device = {
  125. .name = "sh7619-ether",
  126. .id = -1,
  127. .dev = {
  128. .platform_data = &eth_platform_data,
  129. },
  130. .num_resources = ARRAY_SIZE(eth_resources),
  131. .resource = eth_resources,
  132. };
  133. static struct sh_timer_config cmt_platform_data = {
  134. .channels_mask = 3,
  135. };
  136. static struct resource cmt_resources[] = {
  137. DEFINE_RES_MEM(0xf84a0070, 0x10),
  138. DEFINE_RES_IRQ(86),
  139. DEFINE_RES_IRQ(87),
  140. };
  141. static struct platform_device cmt_device = {
  142. .name = "sh-cmt-16",
  143. .id = 0,
  144. .dev = {
  145. .platform_data = &cmt_platform_data,
  146. },
  147. .resource = cmt_resources,
  148. .num_resources = ARRAY_SIZE(cmt_resources),
  149. };
  150. static struct platform_device *sh7619_devices[] __initdata = {
  151. &scif0_device,
  152. &scif1_device,
  153. &scif2_device,
  154. &eth_device,
  155. &cmt_device,
  156. };
  157. static int __init sh7619_devices_setup(void)
  158. {
  159. return platform_add_devices(sh7619_devices,
  160. ARRAY_SIZE(sh7619_devices));
  161. }
  162. arch_initcall(sh7619_devices_setup);
  163. void __init plat_irq_setup(void)
  164. {
  165. register_intc_controller(&intc_desc);
  166. }
  167. static struct platform_device *sh7619_early_devices[] __initdata = {
  168. &scif0_device,
  169. &scif1_device,
  170. &scif2_device,
  171. &cmt_device,
  172. };
  173. #define STBCR3 0xf80a0000
  174. void __init plat_early_device_setup(void)
  175. {
  176. /* enable CMT clock */
  177. __raw_writeb(__raw_readb(STBCR3) & ~0x10, STBCR3);
  178. early_platform_add_devices(sh7619_early_devices,
  179. ARRAY_SIZE(sh7619_early_devices));
  180. }