setup-sh5.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 scif0_platform_data = {
  19. .mapbase = PHYS_PERIPHERAL_BLOCK + 0x01030000,
  20. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  21. .type = PORT_SCIF,
  22. .irqs = { 39, 40, 42, 0 },
  23. };
  24. static struct platform_device scif0_device = {
  25. .name = "sh-sci",
  26. .id = 0,
  27. .dev = {
  28. .platform_data = &scif0_platform_data,
  29. },
  30. };
  31. static struct resource rtc_resources[] = {
  32. [0] = {
  33. .start = PHYS_PERIPHERAL_BLOCK + 0x01040000,
  34. .end = PHYS_PERIPHERAL_BLOCK + 0x01040000 + 0x58 - 1,
  35. .flags = IORESOURCE_IO,
  36. },
  37. [1] = {
  38. /* Period IRQ */
  39. .start = IRQ_PRI,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. [2] = {
  43. /* Carry IRQ */
  44. .start = IRQ_CUI,
  45. .flags = IORESOURCE_IRQ,
  46. },
  47. [3] = {
  48. /* Alarm IRQ */
  49. .start = IRQ_ATI,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. };
  53. static struct platform_device rtc_device = {
  54. .name = "sh-rtc",
  55. .id = -1,
  56. .num_resources = ARRAY_SIZE(rtc_resources),
  57. .resource = rtc_resources,
  58. };
  59. #define TMU_BLOCK_OFF 0x01020000
  60. #define TMU_BASE PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
  61. #define TMU0_BASE (TMU_BASE + 0x8 + (0xc * 0x0))
  62. #define TMU1_BASE (TMU_BASE + 0x8 + (0xc * 0x1))
  63. #define TMU2_BASE (TMU_BASE + 0x8 + (0xc * 0x2))
  64. static struct sh_timer_config tmu0_platform_data = {
  65. .name = "TMU0",
  66. .channel_offset = 0x04,
  67. .timer_bit = 0,
  68. .clk = "peripheral_clk",
  69. .clockevent_rating = 200,
  70. };
  71. static struct resource tmu0_resources[] = {
  72. [0] = {
  73. .name = "TMU0",
  74. .start = TMU0_BASE,
  75. .end = TMU0_BASE + 0xc - 1,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = {
  79. .start = IRQ_TUNI0,
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. };
  83. static struct platform_device tmu0_device = {
  84. .name = "sh_tmu",
  85. .id = 0,
  86. .dev = {
  87. .platform_data = &tmu0_platform_data,
  88. },
  89. .resource = tmu0_resources,
  90. .num_resources = ARRAY_SIZE(tmu0_resources),
  91. };
  92. static struct sh_timer_config tmu1_platform_data = {
  93. .name = "TMU1",
  94. .channel_offset = 0x10,
  95. .timer_bit = 1,
  96. .clk = "peripheral_clk",
  97. .clocksource_rating = 200,
  98. };
  99. static struct resource tmu1_resources[] = {
  100. [0] = {
  101. .name = "TMU1",
  102. .start = TMU1_BASE,
  103. .end = TMU1_BASE + 0xc - 1,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. [1] = {
  107. .start = IRQ_TUNI1,
  108. .flags = IORESOURCE_IRQ,
  109. },
  110. };
  111. static struct platform_device tmu1_device = {
  112. .name = "sh_tmu",
  113. .id = 1,
  114. .dev = {
  115. .platform_data = &tmu1_platform_data,
  116. },
  117. .resource = tmu1_resources,
  118. .num_resources = ARRAY_SIZE(tmu1_resources),
  119. };
  120. static struct sh_timer_config tmu2_platform_data = {
  121. .name = "TMU2",
  122. .channel_offset = 0x1c,
  123. .timer_bit = 2,
  124. .clk = "peripheral_clk",
  125. };
  126. static struct resource tmu2_resources[] = {
  127. [0] = {
  128. .name = "TMU2",
  129. .start = TMU2_BASE,
  130. .end = TMU2_BASE + 0xc - 1,
  131. .flags = IORESOURCE_MEM,
  132. },
  133. [1] = {
  134. .start = IRQ_TUNI2,
  135. .flags = IORESOURCE_IRQ,
  136. },
  137. };
  138. static struct platform_device tmu2_device = {
  139. .name = "sh_tmu",
  140. .id = 2,
  141. .dev = {
  142. .platform_data = &tmu2_platform_data,
  143. },
  144. .resource = tmu2_resources,
  145. .num_resources = ARRAY_SIZE(tmu2_resources),
  146. };
  147. static struct platform_device *sh5_early_devices[] __initdata = {
  148. &scif0_device,
  149. &tmu0_device,
  150. &tmu1_device,
  151. &tmu2_device,
  152. };
  153. static struct platform_device *sh5_devices[] __initdata = {
  154. &rtc_device,
  155. };
  156. static int __init sh5_devices_setup(void)
  157. {
  158. int ret;
  159. ret = platform_add_devices(sh5_early_devices,
  160. ARRAY_SIZE(sh5_early_devices));
  161. if (unlikely(ret != 0))
  162. return ret;
  163. return platform_add_devices(sh5_devices,
  164. ARRAY_SIZE(sh5_devices));
  165. }
  166. arch_initcall(sh5_devices_setup);
  167. void __init plat_early_device_setup(void)
  168. {
  169. early_platform_add_devices(sh5_early_devices,
  170. ARRAY_SIZE(sh5_early_devices));
  171. }