setup-sh4-202.c 4.3 KB

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