setup-sh4-202.c 4.5 KB

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