setup-sh4-202.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * SH4-202 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. * Copyright (C) 2009 Magnus Damm
  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. static struct plat_sci_port sci_platform_data[] = {
  18. {
  19. .mapbase = 0xffe80000,
  20. .flags = UPF_BOOT_AUTOCONF,
  21. .type = PORT_SCIF,
  22. .irqs = { 40, 41, 43, 42 },
  23. }, {
  24. .flags = 0,
  25. }
  26. };
  27. static struct platform_device sci_device = {
  28. .name = "sh-sci",
  29. .id = -1,
  30. .dev = {
  31. .platform_data = sci_platform_data,
  32. },
  33. };
  34. static struct sh_timer_config tmu0_platform_data = {
  35. .name = "TMU0",
  36. .channel_offset = 0x04,
  37. .timer_bit = 0,
  38. .clk = "peripheral_clk",
  39. .clockevent_rating = 200,
  40. };
  41. static struct resource tmu0_resources[] = {
  42. [0] = {
  43. .name = "TMU0",
  44. .start = 0xffd80008,
  45. .end = 0xffd80013,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. [1] = {
  49. .start = 16,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. };
  53. static struct platform_device tmu0_device = {
  54. .name = "sh_tmu",
  55. .id = 0,
  56. .dev = {
  57. .platform_data = &tmu0_platform_data,
  58. },
  59. .resource = tmu0_resources,
  60. .num_resources = ARRAY_SIZE(tmu0_resources),
  61. };
  62. static struct sh_timer_config tmu1_platform_data = {
  63. .name = "TMU1",
  64. .channel_offset = 0x10,
  65. .timer_bit = 1,
  66. .clk = "peripheral_clk",
  67. .clocksource_rating = 200,
  68. };
  69. static struct resource tmu1_resources[] = {
  70. [0] = {
  71. .name = "TMU1",
  72. .start = 0xffd80014,
  73. .end = 0xffd8001f,
  74. .flags = IORESOURCE_MEM,
  75. },
  76. [1] = {
  77. .start = 17,
  78. .flags = IORESOURCE_IRQ,
  79. },
  80. };
  81. static struct platform_device tmu1_device = {
  82. .name = "sh_tmu",
  83. .id = 1,
  84. .dev = {
  85. .platform_data = &tmu1_platform_data,
  86. },
  87. .resource = tmu1_resources,
  88. .num_resources = ARRAY_SIZE(tmu1_resources),
  89. };
  90. static struct sh_timer_config tmu2_platform_data = {
  91. .name = "TMU2",
  92. .channel_offset = 0x1c,
  93. .timer_bit = 2,
  94. .clk = "peripheral_clk",
  95. };
  96. static struct resource tmu2_resources[] = {
  97. [0] = {
  98. .name = "TMU2",
  99. .start = 0xffd80020,
  100. .end = 0xffd8002f,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. [1] = {
  104. .start = 18,
  105. .flags = IORESOURCE_IRQ,
  106. },
  107. };
  108. static struct platform_device tmu2_device = {
  109. .name = "sh_tmu",
  110. .id = 2,
  111. .dev = {
  112. .platform_data = &tmu2_platform_data,
  113. },
  114. .resource = tmu2_resources,
  115. .num_resources = ARRAY_SIZE(tmu2_resources),
  116. };
  117. static struct platform_device *sh4202_devices[] __initdata = {
  118. &sci_device,
  119. &tmu0_device,
  120. &tmu1_device,
  121. &tmu2_device,
  122. };
  123. static int __init sh4202_devices_setup(void)
  124. {
  125. return platform_add_devices(sh4202_devices,
  126. ARRAY_SIZE(sh4202_devices));
  127. }
  128. arch_initcall(sh4202_devices_setup);
  129. static struct platform_device *sh4202_early_devices[] __initdata = {
  130. &tmu0_device,
  131. &tmu1_device,
  132. &tmu2_device,
  133. };
  134. void __init plat_early_device_setup(void)
  135. {
  136. early_platform_add_devices(sh4202_early_devices,
  137. ARRAY_SIZE(sh4202_early_devices));
  138. }
  139. enum {
  140. UNUSED = 0,
  141. /* interrupt sources */
  142. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  143. HUDI, TMU0, TMU1, TMU2, RTC, SCIF, WDT,
  144. };
  145. static struct intc_vect vectors[] __initdata = {
  146. INTC_VECT(HUDI, 0x600),
  147. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  148. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  149. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  150. INTC_VECT(RTC, 0x4c0),
  151. INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
  152. INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
  153. INTC_VECT(WDT, 0x560),
  154. };
  155. static struct intc_prio_reg prio_registers[] __initdata = {
  156. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  157. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, 0, 0, 0 } },
  158. { 0xffd0000c, 0, 16, 4, /* IPRC */ { 0, 0, SCIF, HUDI } },
  159. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  160. };
  161. static DECLARE_INTC_DESC(intc_desc, "sh4-202", vectors, NULL,
  162. NULL, prio_registers, NULL);
  163. static struct intc_vect vectors_irlm[] __initdata = {
  164. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  165. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  166. };
  167. static DECLARE_INTC_DESC(intc_desc_irlm, "sh4-202_irlm", vectors_irlm, NULL,
  168. NULL, prio_registers, NULL);
  169. void __init plat_irq_setup(void)
  170. {
  171. register_intc_controller(&intc_desc);
  172. }
  173. #define INTC_ICR 0xffd00000UL
  174. #define INTC_ICR_IRLM (1<<7)
  175. void __init plat_irq_setup_pins(int mode)
  176. {
  177. switch (mode) {
  178. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  179. ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  180. register_intc_controller(&intc_desc_irlm);
  181. break;
  182. default:
  183. BUG();
  184. }
  185. }