setup-sh7367.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * sh7367 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/input.h>
  27. #include <linux/io.h>
  28. #include <linux/serial_sci.h>
  29. #include <linux/sh_timer.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. /* SCIFA0 */
  34. static struct plat_sci_port scif0_platform_data = {
  35. .mapbase = 0xe6c40000,
  36. .flags = UPF_BOOT_AUTOCONF,
  37. .scscr = SCSCR_RE | SCSCR_TE,
  38. .scbrr_algo_id = SCBRR_ALGO_4,
  39. .type = PORT_SCIF,
  40. .irqs = { evt2irq(0xc00), evt2irq(0xc00),
  41. evt2irq(0xc00), evt2irq(0xc00) },
  42. };
  43. static struct platform_device scif0_device = {
  44. .name = "sh-sci",
  45. .id = 0,
  46. .dev = {
  47. .platform_data = &scif0_platform_data,
  48. },
  49. };
  50. /* SCIFA1 */
  51. static struct plat_sci_port scif1_platform_data = {
  52. .mapbase = 0xe6c50000,
  53. .flags = UPF_BOOT_AUTOCONF,
  54. .scscr = SCSCR_RE | SCSCR_TE,
  55. .scbrr_algo_id = SCBRR_ALGO_4,
  56. .type = PORT_SCIF,
  57. .irqs = { evt2irq(0xc20), evt2irq(0xc20),
  58. evt2irq(0xc20), evt2irq(0xc20) },
  59. };
  60. static struct platform_device scif1_device = {
  61. .name = "sh-sci",
  62. .id = 1,
  63. .dev = {
  64. .platform_data = &scif1_platform_data,
  65. },
  66. };
  67. /* SCIFA2 */
  68. static struct plat_sci_port scif2_platform_data = {
  69. .mapbase = 0xe6c60000,
  70. .flags = UPF_BOOT_AUTOCONF,
  71. .scscr = SCSCR_RE | SCSCR_TE,
  72. .scbrr_algo_id = SCBRR_ALGO_4,
  73. .type = PORT_SCIF,
  74. .irqs = { evt2irq(0xc40), evt2irq(0xc40),
  75. evt2irq(0xc40), evt2irq(0xc40) },
  76. };
  77. static struct platform_device scif2_device = {
  78. .name = "sh-sci",
  79. .id = 2,
  80. .dev = {
  81. .platform_data = &scif2_platform_data,
  82. },
  83. };
  84. /* SCIFA3 */
  85. static struct plat_sci_port scif3_platform_data = {
  86. .mapbase = 0xe6c70000,
  87. .flags = UPF_BOOT_AUTOCONF,
  88. .scscr = SCSCR_RE | SCSCR_TE,
  89. .scbrr_algo_id = SCBRR_ALGO_4,
  90. .type = PORT_SCIF,
  91. .irqs = { evt2irq(0xc60), evt2irq(0xc60),
  92. evt2irq(0xc60), evt2irq(0xc60) },
  93. };
  94. static struct platform_device scif3_device = {
  95. .name = "sh-sci",
  96. .id = 3,
  97. .dev = {
  98. .platform_data = &scif3_platform_data,
  99. },
  100. };
  101. /* SCIFA4 */
  102. static struct plat_sci_port scif4_platform_data = {
  103. .mapbase = 0xe6c80000,
  104. .flags = UPF_BOOT_AUTOCONF,
  105. .scscr = SCSCR_RE | SCSCR_TE,
  106. .scbrr_algo_id = SCBRR_ALGO_4,
  107. .type = PORT_SCIF,
  108. .irqs = { evt2irq(0xd20), evt2irq(0xd20),
  109. evt2irq(0xd20), evt2irq(0xd20) },
  110. };
  111. static struct platform_device scif4_device = {
  112. .name = "sh-sci",
  113. .id = 4,
  114. .dev = {
  115. .platform_data = &scif4_platform_data,
  116. },
  117. };
  118. /* SCIFA5 */
  119. static struct plat_sci_port scif5_platform_data = {
  120. .mapbase = 0xe6cb0000,
  121. .flags = UPF_BOOT_AUTOCONF,
  122. .scscr = SCSCR_RE | SCSCR_TE,
  123. .scbrr_algo_id = SCBRR_ALGO_4,
  124. .type = PORT_SCIF,
  125. .irqs = { evt2irq(0xd40), evt2irq(0xd40),
  126. evt2irq(0xd40), evt2irq(0xd40) },
  127. };
  128. static struct platform_device scif5_device = {
  129. .name = "sh-sci",
  130. .id = 5,
  131. .dev = {
  132. .platform_data = &scif5_platform_data,
  133. },
  134. };
  135. /* SCIFB */
  136. static struct plat_sci_port scif6_platform_data = {
  137. .mapbase = 0xe6c30000,
  138. .flags = UPF_BOOT_AUTOCONF,
  139. .scscr = SCSCR_RE | SCSCR_TE,
  140. .scbrr_algo_id = SCBRR_ALGO_4,
  141. .type = PORT_SCIF,
  142. .irqs = { evt2irq(0xd60), evt2irq(0xd60),
  143. evt2irq(0xd60), evt2irq(0xd60) },
  144. };
  145. static struct platform_device scif6_device = {
  146. .name = "sh-sci",
  147. .id = 6,
  148. .dev = {
  149. .platform_data = &scif6_platform_data,
  150. },
  151. };
  152. static struct sh_timer_config cmt10_platform_data = {
  153. .name = "CMT10",
  154. .channel_offset = 0x10,
  155. .timer_bit = 0,
  156. .clockevent_rating = 125,
  157. .clocksource_rating = 125,
  158. };
  159. static struct resource cmt10_resources[] = {
  160. [0] = {
  161. .name = "CMT10",
  162. .start = 0xe6138010,
  163. .end = 0xe613801b,
  164. .flags = IORESOURCE_MEM,
  165. },
  166. [1] = {
  167. .start = evt2irq(0xb00), /* CMT1_CMT10 */
  168. .flags = IORESOURCE_IRQ,
  169. },
  170. };
  171. static struct platform_device cmt10_device = {
  172. .name = "sh_cmt",
  173. .id = 10,
  174. .dev = {
  175. .platform_data = &cmt10_platform_data,
  176. },
  177. .resource = cmt10_resources,
  178. .num_resources = ARRAY_SIZE(cmt10_resources),
  179. };
  180. static struct platform_device *sh7367_early_devices[] __initdata = {
  181. &scif0_device,
  182. &scif1_device,
  183. &scif2_device,
  184. &scif3_device,
  185. &scif4_device,
  186. &scif5_device,
  187. &scif6_device,
  188. &cmt10_device,
  189. };
  190. void __init sh7367_add_standard_devices(void)
  191. {
  192. platform_add_devices(sh7367_early_devices,
  193. ARRAY_SIZE(sh7367_early_devices));
  194. }
  195. #define SYMSTPCR2 0xe6158048
  196. #define SYMSTPCR2_CMT1 (1 << 29)
  197. void __init sh7367_add_early_devices(void)
  198. {
  199. /* enable clock to CMT1 */
  200. __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2);
  201. early_platform_add_devices(sh7367_early_devices,
  202. ARRAY_SIZE(sh7367_early_devices));
  203. }