setup-r8a7791.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * r8a7791 processor support
  3. *
  4. * Copyright (C) 2013 Renesas Electronics Corporation
  5. * Copyright (C) 2013 Renesas Solutions Corp.
  6. * Copyright (C) 2013 Magnus Damm
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/irq.h>
  22. #include <linux/kernel.h>
  23. #include <linux/of_platform.h>
  24. #include <linux/serial_sci.h>
  25. #include <linux/sh_timer.h>
  26. #include <mach/common.h>
  27. #include <mach/irqs.h>
  28. #include <mach/r8a7791.h>
  29. #include <asm/mach/arch.h>
  30. #define SCIF_COMMON(scif_type, baseaddr, irq) \
  31. .type = scif_type, \
  32. .mapbase = baseaddr, \
  33. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  34. .irqs = SCIx_IRQ_MUXED(irq)
  35. #define SCIFA_DATA(index, baseaddr, irq) \
  36. [index] = { \
  37. SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
  38. .scbrr_algo_id = SCBRR_ALGO_4, \
  39. .scscr = SCSCR_RE | SCSCR_TE, \
  40. }
  41. #define SCIFB_DATA(index, baseaddr, irq) \
  42. [index] = { \
  43. SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
  44. .scbrr_algo_id = SCBRR_ALGO_4, \
  45. .scscr = SCSCR_RE | SCSCR_TE, \
  46. }
  47. #define SCIF_DATA(index, baseaddr, irq) \
  48. [index] = { \
  49. SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
  50. .scbrr_algo_id = SCBRR_ALGO_2, \
  51. .scscr = SCSCR_RE | SCSCR_TE, \
  52. }
  53. #define HSCIF_DATA(index, baseaddr, irq) \
  54. [index] = { \
  55. SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
  56. .scbrr_algo_id = SCBRR_ALGO_6, \
  57. .scscr = SCSCR_RE | SCSCR_TE, \
  58. }
  59. enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1,
  60. SCIF2, SCIF3, SCIF4, SCIF5, SCIFA3, SCIFA4, SCIFA5 };
  61. static const struct plat_sci_port scif[] __initconst = {
  62. SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
  63. SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
  64. SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
  65. SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
  66. SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
  67. SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */
  68. SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */
  69. SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */
  70. SCIF_DATA(SCIF2, 0xe6e58000, gic_spi(22)), /* SCIF2 */
  71. SCIF_DATA(SCIF3, 0xe6ea8000, gic_spi(23)), /* SCIF3 */
  72. SCIF_DATA(SCIF4, 0xe6ee0000, gic_spi(24)), /* SCIF4 */
  73. SCIF_DATA(SCIF5, 0xe6ee8000, gic_spi(25)), /* SCIF5 */
  74. SCIFA_DATA(SCIFA3, 0xe6c70000, gic_spi(29)), /* SCIFA3 */
  75. SCIFA_DATA(SCIFA4, 0xe6c78000, gic_spi(30)), /* SCIFA4 */
  76. SCIFA_DATA(SCIFA5, 0xe6c80000, gic_spi(31)), /* SCIFA5 */
  77. };
  78. static inline void r8a7791_register_scif(int idx)
  79. {
  80. platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
  81. sizeof(struct plat_sci_port));
  82. }
  83. static const struct sh_timer_config cmt00_platform_data __initconst = {
  84. .name = "CMT00",
  85. .timer_bit = 0,
  86. .clockevent_rating = 80,
  87. };
  88. static const struct resource cmt00_resources[] __initconst = {
  89. DEFINE_RES_MEM(0xffca0510, 0x0c),
  90. DEFINE_RES_MEM(0xffca0500, 0x04),
  91. DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
  92. };
  93. #define r8a7791_register_cmt(idx) \
  94. platform_device_register_resndata(&platform_bus, "sh_cmt", \
  95. idx, cmt##idx##_resources, \
  96. ARRAY_SIZE(cmt##idx##_resources), \
  97. &cmt##idx##_platform_data, \
  98. sizeof(struct sh_timer_config))
  99. void __init r8a7791_add_dt_devices(void)
  100. {
  101. r8a7791_register_scif(SCIFA0);
  102. r8a7791_register_scif(SCIFA1);
  103. r8a7791_register_scif(SCIFB0);
  104. r8a7791_register_scif(SCIFB1);
  105. r8a7791_register_scif(SCIFB2);
  106. r8a7791_register_scif(SCIFA2);
  107. r8a7791_register_scif(SCIF0);
  108. r8a7791_register_scif(SCIF1);
  109. r8a7791_register_scif(SCIF2);
  110. r8a7791_register_scif(SCIF3);
  111. r8a7791_register_scif(SCIF4);
  112. r8a7791_register_scif(SCIF5);
  113. r8a7791_register_scif(SCIFA3);
  114. r8a7791_register_scif(SCIFA4);
  115. r8a7791_register_scif(SCIFA5);
  116. r8a7791_register_cmt(00);
  117. }
  118. void __init r8a7791_add_standard_devices(void)
  119. {
  120. r8a7791_add_dt_devices();
  121. }
  122. void __init r8a7791_init_early(void)
  123. {
  124. #ifndef CONFIG_ARM_ARCH_TIMER
  125. shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
  126. #endif
  127. }
  128. #ifdef CONFIG_USE_OF
  129. static const char *r8a7791_boards_compat_dt[] __initdata = {
  130. "renesas,r8a7791",
  131. NULL,
  132. };
  133. DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
  134. .init_early = r8a7791_init_early,
  135. .dt_compat = r8a7791_boards_compat_dt,
  136. MACHINE_END
  137. #endif /* CONFIG_USE_OF */