setup-sh7619.c 4.7 KB

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