setup-r8a7791.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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/platform_data/irq-renesas-irqc.h>
  25. #include <linux/serial_sci.h>
  26. #include <linux/sh_timer.h>
  27. #include <mach/common.h>
  28. #include <mach/irqs.h>
  29. #include <mach/r8a7791.h>
  30. #include <mach/rcar-gen2.h>
  31. #include <asm/mach/arch.h>
  32. #define SCIF_COMMON(scif_type, baseaddr, irq) \
  33. .type = scif_type, \
  34. .mapbase = baseaddr, \
  35. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  36. .irqs = SCIx_IRQ_MUXED(irq)
  37. #define SCIFA_DATA(index, baseaddr, irq) \
  38. [index] = { \
  39. SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
  40. .scbrr_algo_id = SCBRR_ALGO_4, \
  41. .scscr = SCSCR_RE | SCSCR_TE, \
  42. }
  43. #define SCIFB_DATA(index, baseaddr, irq) \
  44. [index] = { \
  45. SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
  46. .scbrr_algo_id = SCBRR_ALGO_4, \
  47. .scscr = SCSCR_RE | SCSCR_TE, \
  48. }
  49. #define SCIF_DATA(index, baseaddr, irq) \
  50. [index] = { \
  51. SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
  52. .scbrr_algo_id = SCBRR_ALGO_2, \
  53. .scscr = SCSCR_RE | SCSCR_TE, \
  54. }
  55. #define HSCIF_DATA(index, baseaddr, irq) \
  56. [index] = { \
  57. SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
  58. .scbrr_algo_id = SCBRR_ALGO_6, \
  59. .scscr = SCSCR_RE | SCSCR_TE, \
  60. }
  61. enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1,
  62. SCIF2, SCIF3, SCIF4, SCIF5, SCIFA3, SCIFA4, SCIFA5 };
  63. static const struct plat_sci_port scif[] __initconst = {
  64. SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
  65. SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
  66. SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
  67. SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
  68. SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
  69. SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */
  70. SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */
  71. SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */
  72. SCIF_DATA(SCIF2, 0xe6e58000, gic_spi(22)), /* SCIF2 */
  73. SCIF_DATA(SCIF3, 0xe6ea8000, gic_spi(23)), /* SCIF3 */
  74. SCIF_DATA(SCIF4, 0xe6ee0000, gic_spi(24)), /* SCIF4 */
  75. SCIF_DATA(SCIF5, 0xe6ee8000, gic_spi(25)), /* SCIF5 */
  76. SCIFA_DATA(SCIFA3, 0xe6c70000, gic_spi(29)), /* SCIFA3 */
  77. SCIFA_DATA(SCIFA4, 0xe6c78000, gic_spi(30)), /* SCIFA4 */
  78. SCIFA_DATA(SCIFA5, 0xe6c80000, gic_spi(31)), /* SCIFA5 */
  79. };
  80. static inline void r8a7791_register_scif(int idx)
  81. {
  82. platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
  83. sizeof(struct plat_sci_port));
  84. }
  85. static const struct sh_timer_config cmt00_platform_data __initconst = {
  86. .name = "CMT00",
  87. .timer_bit = 0,
  88. .clockevent_rating = 80,
  89. };
  90. static const struct resource cmt00_resources[] __initconst = {
  91. DEFINE_RES_MEM(0xffca0510, 0x0c),
  92. DEFINE_RES_MEM(0xffca0500, 0x04),
  93. DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
  94. };
  95. #define r8a7791_register_cmt(idx) \
  96. platform_device_register_resndata(&platform_bus, "sh_cmt", \
  97. idx, cmt##idx##_resources, \
  98. ARRAY_SIZE(cmt##idx##_resources), \
  99. &cmt##idx##_platform_data, \
  100. sizeof(struct sh_timer_config))
  101. static struct renesas_irqc_config irqc0_data = {
  102. .irq_base = irq_pin(0), /* IRQ0 -> IRQ9 */
  103. };
  104. static struct resource irqc0_resources[] = {
  105. DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
  106. DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
  107. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
  108. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
  109. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
  110. DEFINE_RES_IRQ(gic_spi(12)), /* IRQ4 */
  111. DEFINE_RES_IRQ(gic_spi(13)), /* IRQ5 */
  112. DEFINE_RES_IRQ(gic_spi(14)), /* IRQ6 */
  113. DEFINE_RES_IRQ(gic_spi(15)), /* IRQ7 */
  114. DEFINE_RES_IRQ(gic_spi(16)), /* IRQ8 */
  115. DEFINE_RES_IRQ(gic_spi(17)), /* IRQ9 */
  116. };
  117. #define r8a7791_register_irqc(idx) \
  118. platform_device_register_resndata(&platform_bus, "renesas_irqc", \
  119. idx, irqc##idx##_resources, \
  120. ARRAY_SIZE(irqc##idx##_resources), \
  121. &irqc##idx##_data, \
  122. sizeof(struct renesas_irqc_config))
  123. void __init r8a7791_add_dt_devices(void)
  124. {
  125. r8a7791_register_scif(SCIFA0);
  126. r8a7791_register_scif(SCIFA1);
  127. r8a7791_register_scif(SCIFB0);
  128. r8a7791_register_scif(SCIFB1);
  129. r8a7791_register_scif(SCIFB2);
  130. r8a7791_register_scif(SCIFA2);
  131. r8a7791_register_scif(SCIF0);
  132. r8a7791_register_scif(SCIF1);
  133. r8a7791_register_scif(SCIF2);
  134. r8a7791_register_scif(SCIF3);
  135. r8a7791_register_scif(SCIF4);
  136. r8a7791_register_scif(SCIF5);
  137. r8a7791_register_scif(SCIFA3);
  138. r8a7791_register_scif(SCIFA4);
  139. r8a7791_register_scif(SCIFA5);
  140. r8a7791_register_cmt(00);
  141. }
  142. void __init r8a7791_add_standard_devices(void)
  143. {
  144. r8a7791_add_dt_devices();
  145. r8a7791_register_irqc(0);
  146. }
  147. void __init r8a7791_init_early(void)
  148. {
  149. #ifndef CONFIG_ARM_ARCH_TIMER
  150. shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
  151. #endif
  152. }
  153. #ifdef CONFIG_USE_OF
  154. static const char *r8a7791_boards_compat_dt[] __initdata = {
  155. "renesas,r8a7791",
  156. NULL,
  157. };
  158. DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
  159. .smp = smp_ops(r8a7791_smp_ops),
  160. .init_early = r8a7791_init_early,
  161. .init_time = rcar_gen2_timer_init,
  162. .dt_compat = r8a7791_boards_compat_dt,
  163. MACHINE_END
  164. #endif /* CONFIG_USE_OF */