setup-sh7710.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * SH3 Setup code for SH7710, SH7712
  4. *
  5. * Copyright (C) 2006 - 2009 Paul Mundt
  6. * Copyright (C) 2007 Nobuhiro Iwamatsu
  7. */
  8. #include <linux/platform_device.h>
  9. #include <linux/init.h>
  10. #include <linux/irq.h>
  11. #include <linux/serial.h>
  12. #include <linux/serial_sci.h>
  13. #include <linux/sh_timer.h>
  14. #include <linux/sh_intc.h>
  15. #include <asm/rtc.h>
  16. #include <asm/platform_early.h>
  17. enum {
  18. UNUSED = 0,
  19. /* interrupt sources */
  20. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  21. DMAC1, SCIF0, SCIF1, DMAC2, IPSEC,
  22. EDMAC0, EDMAC1, EDMAC2,
  23. SIOF0, SIOF1,
  24. TMU0, TMU1, TMU2,
  25. RTC, WDT, REF,
  26. };
  27. static struct intc_vect vectors[] __initdata = {
  28. /* IRQ0->5 are handled in setup-sh3.c */
  29. INTC_VECT(DMAC1, 0x800), INTC_VECT(DMAC1, 0x820),
  30. INTC_VECT(DMAC1, 0x840), INTC_VECT(DMAC1, 0x860),
  31. INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
  32. INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
  33. INTC_VECT(SCIF1, 0x900), INTC_VECT(SCIF1, 0x920),
  34. INTC_VECT(SCIF1, 0x940), INTC_VECT(SCIF1, 0x960),
  35. INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
  36. #ifdef CONFIG_CPU_SUBTYPE_SH7710
  37. INTC_VECT(IPSEC, 0xbe0),
  38. #endif
  39. INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20),
  40. INTC_VECT(EDMAC2, 0xc40),
  41. INTC_VECT(SIOF0, 0xe00), INTC_VECT(SIOF0, 0xe20),
  42. INTC_VECT(SIOF0, 0xe40), INTC_VECT(SIOF0, 0xe60),
  43. INTC_VECT(SIOF1, 0xe80), INTC_VECT(SIOF1, 0xea0),
  44. INTC_VECT(SIOF1, 0xec0), INTC_VECT(SIOF1, 0xee0),
  45. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  46. INTC_VECT(TMU2, 0x440),
  47. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  48. INTC_VECT(RTC, 0x4c0),
  49. INTC_VECT(WDT, 0x560),
  50. INTC_VECT(REF, 0x580),
  51. };
  52. static struct intc_prio_reg prio_registers[] __initdata = {
  53. { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  54. { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } },
  55. { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  56. { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
  57. { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } },
  58. { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } },
  59. { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } },
  60. { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } },
  61. { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } },
  62. };
  63. static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, NULL,
  64. NULL, prio_registers, NULL);
  65. static struct resource rtc_resources[] = {
  66. [0] = {
  67. .start = 0xa413fec0,
  68. .end = 0xa413fec0 + 0x1e,
  69. .flags = IORESOURCE_IO,
  70. },
  71. [1] = {
  72. .start = evt2irq(0x480),
  73. .flags = IORESOURCE_IRQ,
  74. },
  75. };
  76. static struct sh_rtc_platform_info rtc_info = {
  77. .capabilities = RTC_CAP_4_DIGIT_YEAR,
  78. };
  79. static struct platform_device rtc_device = {
  80. .name = "sh-rtc",
  81. .id = -1,
  82. .num_resources = ARRAY_SIZE(rtc_resources),
  83. .resource = rtc_resources,
  84. .dev = {
  85. .platform_data = &rtc_info,
  86. },
  87. };
  88. static struct plat_sci_port scif0_platform_data = {
  89. .scscr = SCSCR_REIE | SCSCR_CKE1,
  90. .type = PORT_SCIF,
  91. };
  92. static struct resource scif0_resources[] = {
  93. DEFINE_RES_MEM(0xa4400000, 0x100),
  94. DEFINE_RES_IRQ(evt2irq(0x880)),
  95. };
  96. static struct platform_device scif0_device = {
  97. .name = "sh-sci",
  98. .id = 0,
  99. .resource = scif0_resources,
  100. .num_resources = ARRAY_SIZE(scif0_resources),
  101. .dev = {
  102. .platform_data = &scif0_platform_data,
  103. },
  104. };
  105. static struct plat_sci_port scif1_platform_data = {
  106. .scscr = SCSCR_REIE | SCSCR_CKE1,
  107. .type = PORT_SCIF,
  108. };
  109. static struct resource scif1_resources[] = {
  110. DEFINE_RES_MEM(0xa4410000, 0x100),
  111. DEFINE_RES_IRQ(evt2irq(0x900)),
  112. };
  113. static struct platform_device scif1_device = {
  114. .name = "sh-sci",
  115. .id = 1,
  116. .resource = scif1_resources,
  117. .num_resources = ARRAY_SIZE(scif1_resources),
  118. .dev = {
  119. .platform_data = &scif1_platform_data,
  120. },
  121. };
  122. static struct sh_timer_config tmu0_platform_data = {
  123. .channels_mask = 7,
  124. };
  125. static struct resource tmu0_resources[] = {
  126. DEFINE_RES_MEM(0xa412fe90, 0x28),
  127. DEFINE_RES_IRQ(evt2irq(0x400)),
  128. DEFINE_RES_IRQ(evt2irq(0x420)),
  129. DEFINE_RES_IRQ(evt2irq(0x440)),
  130. };
  131. static struct platform_device tmu0_device = {
  132. .name = "sh-tmu-sh3",
  133. .id = 0,
  134. .dev = {
  135. .platform_data = &tmu0_platform_data,
  136. },
  137. .resource = tmu0_resources,
  138. .num_resources = ARRAY_SIZE(tmu0_resources),
  139. };
  140. static struct platform_device *sh7710_devices[] __initdata = {
  141. &scif0_device,
  142. &scif1_device,
  143. &tmu0_device,
  144. &rtc_device,
  145. };
  146. static int __init sh7710_devices_setup(void)
  147. {
  148. return platform_add_devices(sh7710_devices,
  149. ARRAY_SIZE(sh7710_devices));
  150. }
  151. arch_initcall(sh7710_devices_setup);
  152. static struct platform_device *sh7710_early_devices[] __initdata = {
  153. &scif0_device,
  154. &scif1_device,
  155. &tmu0_device,
  156. };
  157. void __init plat_early_device_setup(void)
  158. {
  159. sh_early_platform_add_devices(sh7710_early_devices,
  160. ARRAY_SIZE(sh7710_early_devices));
  161. }
  162. void __init plat_irq_setup(void)
  163. {
  164. register_intc_controller(&intc_desc);
  165. plat_irq_setup_sh3();
  166. }