setup-sh5.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. .channel_offset = 0x04,
  66. .timer_bit = 0,
  67. .clockevent_rating = 200,
  68. };
  69. static struct resource tmu0_resources[] = {
  70. [0] = {
  71. .start = TMU0_BASE,
  72. .end = TMU0_BASE + 0xc - 1,
  73. .flags = IORESOURCE_MEM,
  74. },
  75. [1] = {
  76. .start = IRQ_TUNI0,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. static struct platform_device tmu0_device = {
  81. .name = "sh_tmu",
  82. .id = 0,
  83. .dev = {
  84. .platform_data = &tmu0_platform_data,
  85. },
  86. .resource = tmu0_resources,
  87. .num_resources = ARRAY_SIZE(tmu0_resources),
  88. };
  89. static struct sh_timer_config tmu1_platform_data = {
  90. .channel_offset = 0x10,
  91. .timer_bit = 1,
  92. .clocksource_rating = 200,
  93. };
  94. static struct resource tmu1_resources[] = {
  95. [0] = {
  96. .start = TMU1_BASE,
  97. .end = TMU1_BASE + 0xc - 1,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. [1] = {
  101. .start = IRQ_TUNI1,
  102. .flags = IORESOURCE_IRQ,
  103. },
  104. };
  105. static struct platform_device tmu1_device = {
  106. .name = "sh_tmu",
  107. .id = 1,
  108. .dev = {
  109. .platform_data = &tmu1_platform_data,
  110. },
  111. .resource = tmu1_resources,
  112. .num_resources = ARRAY_SIZE(tmu1_resources),
  113. };
  114. static struct sh_timer_config tmu2_platform_data = {
  115. .channel_offset = 0x1c,
  116. .timer_bit = 2,
  117. };
  118. static struct resource tmu2_resources[] = {
  119. [0] = {
  120. .start = TMU2_BASE,
  121. .end = TMU2_BASE + 0xc - 1,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = IRQ_TUNI2,
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static struct platform_device tmu2_device = {
  130. .name = "sh_tmu",
  131. .id = 2,
  132. .dev = {
  133. .platform_data = &tmu2_platform_data,
  134. },
  135. .resource = tmu2_resources,
  136. .num_resources = ARRAY_SIZE(tmu2_resources),
  137. };
  138. static struct platform_device *sh5_early_devices[] __initdata = {
  139. &scif0_device,
  140. &tmu0_device,
  141. &tmu1_device,
  142. &tmu2_device,
  143. };
  144. static struct platform_device *sh5_devices[] __initdata = {
  145. &rtc_device,
  146. };
  147. static int __init sh5_devices_setup(void)
  148. {
  149. int ret;
  150. ret = platform_add_devices(sh5_early_devices,
  151. ARRAY_SIZE(sh5_early_devices));
  152. if (unlikely(ret != 0))
  153. return ret;
  154. return platform_add_devices(sh5_devices,
  155. ARRAY_SIZE(sh5_devices));
  156. }
  157. arch_initcall(sh5_devices_setup);
  158. void __init plat_early_device_setup(void)
  159. {
  160. early_platform_add_devices(sh5_early_devices,
  161. ARRAY_SIZE(sh5_early_devices));
  162. }