setup-r8a7791.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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/gpio-rcar.h>
  25. #include <linux/platform_data/irq-renesas-irqc.h>
  26. #include <linux/serial_sci.h>
  27. #include <linux/sh_timer.h>
  28. #include <asm/mach/arch.h>
  29. #include "common.h"
  30. #include "irqs.h"
  31. #include "r8a7791.h"
  32. #include "rcar-gen2.h"
  33. static const struct resource pfc_resources[] __initconst = {
  34. DEFINE_RES_MEM(0xe6060000, 0x250),
  35. };
  36. #define r8a7791_register_pfc() \
  37. platform_device_register_simple("pfc-r8a7791", -1, pfc_resources, \
  38. ARRAY_SIZE(pfc_resources))
  39. #define R8A7791_GPIO(idx, base, nr) \
  40. static const struct resource r8a7791_gpio##idx##_resources[] __initconst = { \
  41. DEFINE_RES_MEM((base), 0x50), \
  42. DEFINE_RES_IRQ(gic_spi(4 + (idx))), \
  43. }; \
  44. \
  45. static const struct gpio_rcar_config \
  46. r8a7791_gpio##idx##_platform_data __initconst = { \
  47. .gpio_base = 32 * (idx), \
  48. .irq_base = 0, \
  49. .number_of_pins = (nr), \
  50. .pctl_name = "pfc-r8a7791", \
  51. .has_both_edge_trigger = 1, \
  52. }; \
  53. R8A7791_GPIO(0, 0xe6050000, 32);
  54. R8A7791_GPIO(1, 0xe6051000, 32);
  55. R8A7791_GPIO(2, 0xe6052000, 32);
  56. R8A7791_GPIO(3, 0xe6053000, 32);
  57. R8A7791_GPIO(4, 0xe6054000, 32);
  58. R8A7791_GPIO(5, 0xe6055000, 32);
  59. R8A7791_GPIO(6, 0xe6055400, 32);
  60. R8A7791_GPIO(7, 0xe6055800, 26);
  61. #define r8a7791_register_gpio(idx) \
  62. platform_device_register_resndata(NULL, "gpio_rcar", idx, \
  63. r8a7791_gpio##idx##_resources, \
  64. ARRAY_SIZE(r8a7791_gpio##idx##_resources), \
  65. &r8a7791_gpio##idx##_platform_data, \
  66. sizeof(r8a7791_gpio##idx##_platform_data))
  67. void __init r8a7791_pinmux_init(void)
  68. {
  69. r8a7791_register_pfc();
  70. r8a7791_register_gpio(0);
  71. r8a7791_register_gpio(1);
  72. r8a7791_register_gpio(2);
  73. r8a7791_register_gpio(3);
  74. r8a7791_register_gpio(4);
  75. r8a7791_register_gpio(5);
  76. r8a7791_register_gpio(6);
  77. r8a7791_register_gpio(7);
  78. }
  79. #define __R8A7791_SCIF(scif_type, index, baseaddr, irq) \
  80. static struct plat_sci_port scif##index##_platform_data = { \
  81. .type = scif_type, \
  82. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  83. .scscr = SCSCR_RE | SCSCR_TE, \
  84. }; \
  85. \
  86. static struct resource scif##index##_resources[] = { \
  87. DEFINE_RES_MEM(baseaddr, 0x100), \
  88. DEFINE_RES_IRQ(irq), \
  89. }
  90. #define R8A7791_SCIF(index, baseaddr, irq) \
  91. __R8A7791_SCIF(PORT_SCIF, index, baseaddr, irq)
  92. #define R8A7791_SCIFA(index, baseaddr, irq) \
  93. __R8A7791_SCIF(PORT_SCIFA, index, baseaddr, irq)
  94. #define R8A7791_SCIFB(index, baseaddr, irq) \
  95. __R8A7791_SCIF(PORT_SCIFB, index, baseaddr, irq)
  96. R8A7791_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
  97. R8A7791_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
  98. R8A7791_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
  99. R8A7791_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
  100. R8A7791_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
  101. R8A7791_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
  102. R8A7791_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
  103. R8A7791_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
  104. R8A7791_SCIF(8, 0xe6e58000, gic_spi(22)); /* SCIF2 */
  105. R8A7791_SCIF(9, 0xe6ea8000, gic_spi(23)); /* SCIF3 */
  106. R8A7791_SCIF(10, 0xe6ee0000, gic_spi(24)); /* SCIF4 */
  107. R8A7791_SCIF(11, 0xe6ee8000, gic_spi(25)); /* SCIF5 */
  108. R8A7791_SCIFA(12, 0xe6c70000, gic_spi(29)); /* SCIFA3 */
  109. R8A7791_SCIFA(13, 0xe6c78000, gic_spi(30)); /* SCIFA4 */
  110. R8A7791_SCIFA(14, 0xe6c80000, gic_spi(31)); /* SCIFA5 */
  111. #define r8a7791_register_scif(index) \
  112. platform_device_register_resndata(NULL, "sh-sci", index, \
  113. scif##index##_resources, \
  114. ARRAY_SIZE(scif##index##_resources), \
  115. &scif##index##_platform_data, \
  116. sizeof(scif##index##_platform_data))
  117. static struct sh_timer_config cmt0_platform_data = {
  118. .channels_mask = 0x60,
  119. };
  120. static struct resource cmt0_resources[] = {
  121. DEFINE_RES_MEM(0xffca0000, 0x1004),
  122. DEFINE_RES_IRQ(gic_spi(142)),
  123. };
  124. #define r8a7791_register_cmt(idx) \
  125. platform_device_register_resndata(NULL, "sh-cmt-48-gen2", \
  126. idx, cmt##idx##_resources, \
  127. ARRAY_SIZE(cmt##idx##_resources), \
  128. &cmt##idx##_platform_data, \
  129. sizeof(struct sh_timer_config))
  130. static struct renesas_irqc_config irqc0_data = {
  131. .irq_base = irq_pin(0), /* IRQ0 -> IRQ9 */
  132. };
  133. static struct resource irqc0_resources[] = {
  134. DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
  135. DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
  136. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
  137. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
  138. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
  139. DEFINE_RES_IRQ(gic_spi(12)), /* IRQ4 */
  140. DEFINE_RES_IRQ(gic_spi(13)), /* IRQ5 */
  141. DEFINE_RES_IRQ(gic_spi(14)), /* IRQ6 */
  142. DEFINE_RES_IRQ(gic_spi(15)), /* IRQ7 */
  143. DEFINE_RES_IRQ(gic_spi(16)), /* IRQ8 */
  144. DEFINE_RES_IRQ(gic_spi(17)), /* IRQ9 */
  145. };
  146. #define r8a7791_register_irqc(idx) \
  147. platform_device_register_resndata(NULL, "renesas_irqc", \
  148. idx, irqc##idx##_resources, \
  149. ARRAY_SIZE(irqc##idx##_resources), \
  150. &irqc##idx##_data, \
  151. sizeof(struct renesas_irqc_config))
  152. static const struct resource thermal_resources[] __initconst = {
  153. DEFINE_RES_MEM(0xe61f0000, 0x14),
  154. DEFINE_RES_MEM(0xe61f0100, 0x38),
  155. DEFINE_RES_IRQ(gic_spi(69)),
  156. };
  157. #define r8a7791_register_thermal() \
  158. platform_device_register_simple("rcar_thermal", -1, \
  159. thermal_resources, \
  160. ARRAY_SIZE(thermal_resources))
  161. void __init r8a7791_add_standard_devices(void)
  162. {
  163. r8a7791_register_scif(0);
  164. r8a7791_register_scif(1);
  165. r8a7791_register_scif(2);
  166. r8a7791_register_scif(3);
  167. r8a7791_register_scif(4);
  168. r8a7791_register_scif(5);
  169. r8a7791_register_scif(6);
  170. r8a7791_register_scif(7);
  171. r8a7791_register_scif(8);
  172. r8a7791_register_scif(9);
  173. r8a7791_register_scif(10);
  174. r8a7791_register_scif(11);
  175. r8a7791_register_scif(12);
  176. r8a7791_register_scif(13);
  177. r8a7791_register_scif(14);
  178. r8a7791_register_cmt(0);
  179. r8a7791_register_irqc(0);
  180. r8a7791_register_thermal();
  181. }
  182. #ifdef CONFIG_USE_OF
  183. static const char *r8a7791_boards_compat_dt[] __initdata = {
  184. "renesas,r8a7791",
  185. NULL,
  186. };
  187. DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
  188. .smp = smp_ops(r8a7791_smp_ops),
  189. .init_early = shmobile_init_delay,
  190. .init_time = rcar_gen2_timer_init,
  191. .init_late = shmobile_init_late,
  192. .reserve = rcar_gen2_reserve,
  193. .dt_compat = r8a7791_boards_compat_dt,
  194. MACHINE_END
  195. #endif /* CONFIG_USE_OF */