setup-sh770x.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * SH3 Setup code for SH7706, SH7707, SH7708, SH7709
  3. *
  4. * Copyright (C) 2007 Magnus Damm
  5. * Copyright (C) 2009 Paul Mundt
  6. *
  7. * Based on setup-sh7709.c
  8. *
  9. * Copyright (C) 2006 Paul Mundt
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/io.h>
  17. #include <linux/irq.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/serial.h>
  20. #include <linux/serial_sci.h>
  21. enum {
  22. UNUSED = 0,
  23. /* interrupt sources */
  24. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  25. PINT07, PINT815,
  26. DMAC, SCIF0, SCIF2, SCI, ADC_ADI,
  27. LCDC, PCC0, PCC1,
  28. TMU0, TMU1, TMU2,
  29. RTC, WDT, REF,
  30. };
  31. static struct intc_vect vectors[] __initdata = {
  32. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  33. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  34. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  35. INTC_VECT(RTC, 0x4c0),
  36. INTC_VECT(SCI, 0x4e0), INTC_VECT(SCI, 0x500),
  37. INTC_VECT(SCI, 0x520), INTC_VECT(SCI, 0x540),
  38. INTC_VECT(WDT, 0x560),
  39. INTC_VECT(REF, 0x580),
  40. INTC_VECT(REF, 0x5a0),
  41. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  42. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  43. defined(CONFIG_CPU_SUBTYPE_SH7709)
  44. /* IRQ0->5 are handled in setup-sh3.c */
  45. INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
  46. INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
  47. INTC_VECT(ADC_ADI, 0x980),
  48. INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
  49. INTC_VECT(SCIF2, 0x940), INTC_VECT(SCIF2, 0x960),
  50. #endif
  51. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  52. defined(CONFIG_CPU_SUBTYPE_SH7709)
  53. INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
  54. INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
  55. INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
  56. #endif
  57. #if defined(CONFIG_CPU_SUBTYPE_SH7707)
  58. INTC_VECT(LCDC, 0x9a0),
  59. INTC_VECT(PCC0, 0x9c0), INTC_VECT(PCC1, 0x9e0),
  60. #endif
  61. };
  62. static struct intc_prio_reg prio_registers[] __initdata = {
  63. { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  64. { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, SCI, 0 } },
  65. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  66. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  67. defined(CONFIG_CPU_SUBTYPE_SH7709)
  68. { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  69. { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
  70. { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, 0, SCIF2, ADC_ADI } },
  71. #endif
  72. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  73. defined(CONFIG_CPU_SUBTYPE_SH7709)
  74. { 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, } },
  75. { 0xa400001a, 0, 16, 4, /* IPRE */ { 0, SCIF0 } },
  76. #endif
  77. #if defined(CONFIG_CPU_SUBTYPE_SH7707)
  78. { 0xa400001c, 0, 16, 4, /* IPRF */ { 0, LCDC, PCC0, PCC1, } },
  79. #endif
  80. };
  81. static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, NULL,
  82. NULL, prio_registers, NULL);
  83. static struct resource rtc_resources[] = {
  84. [0] = {
  85. .start = 0xfffffec0,
  86. .end = 0xfffffec0 + 0x1e,
  87. .flags = IORESOURCE_IO,
  88. },
  89. [1] = {
  90. .start = 20,
  91. .flags = IORESOURCE_IRQ,
  92. },
  93. };
  94. static struct platform_device rtc_device = {
  95. .name = "sh-rtc",
  96. .id = -1,
  97. .num_resources = ARRAY_SIZE(rtc_resources),
  98. .resource = rtc_resources,
  99. };
  100. static struct plat_sci_port sci_platform_data[] = {
  101. {
  102. .mapbase = 0xfffffe80,
  103. .flags = UPF_BOOT_AUTOCONF,
  104. .type = PORT_SCI,
  105. .irqs = { 23, 23, 23, 0 },
  106. },
  107. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  108. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  109. defined(CONFIG_CPU_SUBTYPE_SH7709)
  110. {
  111. .mapbase = 0xa4000150,
  112. .flags = UPF_BOOT_AUTOCONF,
  113. .type = PORT_SCIF,
  114. .irqs = { 56, 56, 56, 56 },
  115. },
  116. #endif
  117. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  118. defined(CONFIG_CPU_SUBTYPE_SH7709)
  119. {
  120. .mapbase = 0xa4000140,
  121. .flags = UPF_BOOT_AUTOCONF,
  122. .type = PORT_IRDA,
  123. .irqs = { 52, 52, 52, 52 },
  124. },
  125. #endif
  126. {
  127. .flags = 0,
  128. }
  129. };
  130. static struct platform_device sci_device = {
  131. .name = "sh-sci",
  132. .id = -1,
  133. .dev = {
  134. .platform_data = sci_platform_data,
  135. },
  136. };
  137. static struct platform_device *sh770x_devices[] __initdata = {
  138. &sci_device,
  139. &rtc_device,
  140. };
  141. static int __init sh770x_devices_setup(void)
  142. {
  143. return platform_add_devices(sh770x_devices,
  144. ARRAY_SIZE(sh770x_devices));
  145. }
  146. __initcall(sh770x_devices_setup);
  147. void __init plat_irq_setup(void)
  148. {
  149. register_intc_controller(&intc_desc);
  150. #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  151. defined(CONFIG_CPU_SUBTYPE_SH7707) || \
  152. defined(CONFIG_CPU_SUBTYPE_SH7709)
  153. plat_irq_setup_sh3();
  154. #endif
  155. }