setup-sh4-202.c 4.4 KB

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