setup-sh5.c 3.8 KB

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