setup-sh5.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * SH5-101/SH5-103 CPU Setup
  3. *
  4. * Copyright (C) 2009 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/serial_sci.h>
  14. #include <linux/io.h>
  15. #include <linux/mm.h>
  16. #include <linux/sh_timer.h>
  17. #include <asm/addrspace.h>
  18. static struct plat_sci_port sci_platform_data[] = {
  19. {
  20. .mapbase = PHYS_PERIPHERAL_BLOCK + 0x01030000,
  21. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  22. .type = PORT_SCIF,
  23. .irqs = { 39, 40, 42, 0 },
  24. }, {
  25. .flags = 0,
  26. }
  27. };
  28. static struct platform_device sci_device = {
  29. .name = "sh-sci",
  30. .id = -1,
  31. .dev = {
  32. .platform_data = sci_platform_data,
  33. },
  34. };
  35. static struct resource rtc_resources[] = {
  36. [0] = {
  37. .start = PHYS_PERIPHERAL_BLOCK + 0x01040000,
  38. .end = PHYS_PERIPHERAL_BLOCK + 0x01040000 + 0x58 - 1,
  39. .flags = IORESOURCE_IO,
  40. },
  41. [1] = {
  42. /* Period IRQ */
  43. .start = IRQ_PRI,
  44. .flags = IORESOURCE_IRQ,
  45. },
  46. [2] = {
  47. /* Carry IRQ */
  48. .start = IRQ_CUI,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. [3] = {
  52. /* Alarm IRQ */
  53. .start = IRQ_ATI,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. };
  57. static struct platform_device rtc_device = {
  58. .name = "sh-rtc",
  59. .id = -1,
  60. .num_resources = ARRAY_SIZE(rtc_resources),
  61. .resource = rtc_resources,
  62. };
  63. #define TMU_BLOCK_OFF 0x01020000
  64. #define TMU_BASE PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
  65. #define TMU0_BASE (TMU_BASE + 0x8 + (0xc * 0x0))
  66. #define TMU1_BASE (TMU_BASE + 0x8 + (0xc * 0x1))
  67. #define TMU2_BASE (TMU_BASE + 0x8 + (0xc * 0x2))
  68. static struct sh_timer_config tmu0_platform_data = {
  69. .name = "TMU0",
  70. .channel_offset = 0x04,
  71. .timer_bit = 0,
  72. .clk = "peripheral_clk",
  73. .clockevent_rating = 200,
  74. };
  75. static struct resource tmu0_resources[] = {
  76. [0] = {
  77. .name = "TMU0",
  78. .start = TMU0_BASE,
  79. .end = TMU0_BASE + 0xc - 1,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. [1] = {
  83. .start = IRQ_TUNI0,
  84. .flags = IORESOURCE_IRQ,
  85. },
  86. };
  87. static struct platform_device tmu0_device = {
  88. .name = "sh_tmu",
  89. .id = 0,
  90. .dev = {
  91. .platform_data = &tmu0_platform_data,
  92. },
  93. .resource = tmu0_resources,
  94. .num_resources = ARRAY_SIZE(tmu0_resources),
  95. };
  96. static struct sh_timer_config tmu1_platform_data = {
  97. .name = "TMU1",
  98. .channel_offset = 0x10,
  99. .timer_bit = 1,
  100. .clk = "peripheral_clk",
  101. .clocksource_rating = 200,
  102. };
  103. static struct resource tmu1_resources[] = {
  104. [0] = {
  105. .name = "TMU1",
  106. .start = TMU1_BASE,
  107. .end = TMU1_BASE + 0xc - 1,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. [1] = {
  111. .start = IRQ_TUNI1,
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct platform_device tmu1_device = {
  116. .name = "sh_tmu",
  117. .id = 1,
  118. .dev = {
  119. .platform_data = &tmu1_platform_data,
  120. },
  121. .resource = tmu1_resources,
  122. .num_resources = ARRAY_SIZE(tmu1_resources),
  123. };
  124. static struct sh_timer_config tmu2_platform_data = {
  125. .name = "TMU2",
  126. .channel_offset = 0x1c,
  127. .timer_bit = 2,
  128. .clk = "peripheral_clk",
  129. };
  130. static struct resource tmu2_resources[] = {
  131. [0] = {
  132. .name = "TMU2",
  133. .start = TMU2_BASE,
  134. .end = TMU2_BASE + 0xc - 1,
  135. .flags = IORESOURCE_MEM,
  136. },
  137. [1] = {
  138. .start = IRQ_TUNI2,
  139. .flags = IORESOURCE_IRQ,
  140. },
  141. };
  142. static struct platform_device tmu2_device = {
  143. .name = "sh_tmu",
  144. .id = 2,
  145. .dev = {
  146. .platform_data = &tmu2_platform_data,
  147. },
  148. .resource = tmu2_resources,
  149. .num_resources = ARRAY_SIZE(tmu2_resources),
  150. };
  151. static struct platform_device *sh5_early_devices[] __initdata = {
  152. &tmu0_device,
  153. &tmu1_device,
  154. &tmu2_device,
  155. };
  156. static struct platform_device *sh5_devices[] __initdata = {
  157. &sci_device,
  158. &rtc_device,
  159. };
  160. static int __init sh5_devices_setup(void)
  161. {
  162. int ret;
  163. ret = platform_add_devices(sh5_early_devices,
  164. ARRAY_SIZE(sh5_early_devices));
  165. if (unlikely(ret != 0))
  166. return ret;
  167. return platform_add_devices(sh5_devices,
  168. ARRAY_SIZE(sh5_devices));
  169. }
  170. arch_initcall(sh5_devices_setup);
  171. void __init plat_early_device_setup(void)
  172. {
  173. early_platform_add_devices(sh5_early_devices,
  174. ARRAY_SIZE(sh5_early_devices));
  175. }