setup-r8a7790.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. * r8a7790 processor support
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2013 Magnus Damm
  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/irq.h>
  21. #include <linux/kernel.h>
  22. #include <linux/of_platform.h>
  23. #include <linux/platform_data/gpio-rcar.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/r8a7790.h>
  30. #include <asm/mach/arch.h>
  31. static const struct resource pfc_resources[] __initconst = {
  32. DEFINE_RES_MEM(0xe6060000, 0x250),
  33. };
  34. #define r8a7790_register_pfc() \
  35. platform_device_register_simple("pfc-r8a7790", -1, pfc_resources, \
  36. ARRAY_SIZE(pfc_resources))
  37. #define R8A7790_GPIO(idx) \
  38. static const struct resource r8a7790_gpio##idx##_resources[] __initconst = { \
  39. DEFINE_RES_MEM(0xe6050000 + 0x1000 * (idx), 0x50), \
  40. DEFINE_RES_IRQ(gic_spi(4 + (idx))), \
  41. }; \
  42. \
  43. static const struct gpio_rcar_config \
  44. r8a7790_gpio##idx##_platform_data __initconst = { \
  45. .gpio_base = 32 * (idx), \
  46. .irq_base = 0, \
  47. .number_of_pins = 32, \
  48. .pctl_name = "pfc-r8a7790", \
  49. .has_both_edge_trigger = 1, \
  50. }; \
  51. R8A7790_GPIO(0);
  52. R8A7790_GPIO(1);
  53. R8A7790_GPIO(2);
  54. R8A7790_GPIO(3);
  55. R8A7790_GPIO(4);
  56. R8A7790_GPIO(5);
  57. #define r8a7790_register_gpio(idx) \
  58. platform_device_register_resndata(&platform_bus, "gpio_rcar", idx, \
  59. r8a7790_gpio##idx##_resources, \
  60. ARRAY_SIZE(r8a7790_gpio##idx##_resources), \
  61. &r8a7790_gpio##idx##_platform_data, \
  62. sizeof(r8a7790_gpio##idx##_platform_data))
  63. static struct resource i2c_resources[] __initdata = {
  64. /* I2C0 */
  65. DEFINE_RES_MEM(0xE6508000, 0x40),
  66. DEFINE_RES_IRQ(gic_spi(287)),
  67. /* I2C1 */
  68. DEFINE_RES_MEM(0xE6518000, 0x40),
  69. DEFINE_RES_IRQ(gic_spi(288)),
  70. /* I2C2 */
  71. DEFINE_RES_MEM(0xE6530000, 0x40),
  72. DEFINE_RES_IRQ(gic_spi(286)),
  73. /* I2C3 */
  74. DEFINE_RES_MEM(0xE6540000, 0x40),
  75. DEFINE_RES_IRQ(gic_spi(290)),
  76. };
  77. #define r8a7790_register_i2c(idx) \
  78. platform_device_register_simple( \
  79. "i2c-rcar_gen2", idx, \
  80. i2c_resources + (2 * idx), 2); \
  81. void __init r8a7790_pinmux_init(void)
  82. {
  83. r8a7790_register_pfc();
  84. r8a7790_register_gpio(0);
  85. r8a7790_register_gpio(1);
  86. r8a7790_register_gpio(2);
  87. r8a7790_register_gpio(3);
  88. r8a7790_register_gpio(4);
  89. r8a7790_register_gpio(5);
  90. r8a7790_register_i2c(0);
  91. r8a7790_register_i2c(1);
  92. r8a7790_register_i2c(2);
  93. r8a7790_register_i2c(3);
  94. }
  95. #define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \
  96. static struct plat_sci_port scif##index##_platform_data = { \
  97. .type = scif_type, \
  98. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  99. .scscr = _scscr, \
  100. }; \
  101. \
  102. static struct resource scif##index##_resources[] = { \
  103. DEFINE_RES_MEM(baseaddr, 0x100), \
  104. DEFINE_RES_IRQ(irq), \
  105. }
  106. #define R8A7790_SCIF(index, baseaddr, irq) \
  107. __R8A7790_SCIF(PORT_SCIF, SCSCR_RE | SCSCR_TE, \
  108. index, baseaddr, irq)
  109. #define R8A7790_SCIFA(index, baseaddr, irq) \
  110. __R8A7790_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
  111. index, baseaddr, irq)
  112. #define R8A7790_SCIFB(index, baseaddr, irq) \
  113. __R8A7790_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
  114. index, baseaddr, irq)
  115. #define R8A7790_HSCIF(index, baseaddr, irq) \
  116. __R8A7790_SCIF(PORT_HSCIF, SCSCR_RE | SCSCR_TE, \
  117. index, baseaddr, irq)
  118. R8A7790_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
  119. R8A7790_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
  120. R8A7790_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
  121. R8A7790_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
  122. R8A7790_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
  123. R8A7790_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
  124. R8A7790_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
  125. R8A7790_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
  126. R8A7790_HSCIF(8, 0xe62c0000, gic_spi(154)); /* HSCIF0 */
  127. R8A7790_HSCIF(9, 0xe62c8000, gic_spi(155)); /* HSCIF1 */
  128. #define r8a7790_register_scif(index) \
  129. platform_device_register_resndata(&platform_bus, "sh-sci", index, \
  130. scif##index##_resources, \
  131. ARRAY_SIZE(scif##index##_resources), \
  132. &scif##index##_platform_data, \
  133. sizeof(scif##index##_platform_data))
  134. static const struct renesas_irqc_config irqc0_data __initconst = {
  135. .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
  136. };
  137. static const struct resource irqc0_resources[] __initconst = {
  138. DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
  139. DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
  140. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
  141. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
  142. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
  143. };
  144. #define r8a7790_register_irqc(idx) \
  145. platform_device_register_resndata(&platform_bus, "renesas_irqc", \
  146. idx, irqc##idx##_resources, \
  147. ARRAY_SIZE(irqc##idx##_resources), \
  148. &irqc##idx##_data, \
  149. sizeof(struct renesas_irqc_config))
  150. static const struct resource thermal_resources[] __initconst = {
  151. DEFINE_RES_MEM(0xe61f0000, 0x14),
  152. DEFINE_RES_MEM(0xe61f0100, 0x38),
  153. DEFINE_RES_IRQ(gic_spi(69)),
  154. };
  155. #define r8a7790_register_thermal() \
  156. platform_device_register_simple("rcar_thermal", -1, \
  157. thermal_resources, \
  158. ARRAY_SIZE(thermal_resources))
  159. static const struct sh_timer_config cmt00_platform_data __initconst = {
  160. .name = "CMT00",
  161. .timer_bit = 0,
  162. .clockevent_rating = 80,
  163. };
  164. static const struct resource cmt00_resources[] __initconst = {
  165. DEFINE_RES_MEM(0xffca0510, 0x0c),
  166. DEFINE_RES_MEM(0xffca0500, 0x04),
  167. DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
  168. };
  169. #define r8a7790_register_cmt(idx) \
  170. platform_device_register_resndata(&platform_bus, "sh_cmt", \
  171. idx, cmt##idx##_resources, \
  172. ARRAY_SIZE(cmt##idx##_resources), \
  173. &cmt##idx##_platform_data, \
  174. sizeof(struct sh_timer_config))
  175. void __init r8a7790_add_dt_devices(void)
  176. {
  177. r8a7790_register_scif(0);
  178. r8a7790_register_scif(1);
  179. r8a7790_register_scif(2);
  180. r8a7790_register_scif(3);
  181. r8a7790_register_scif(4);
  182. r8a7790_register_scif(5);
  183. r8a7790_register_scif(6);
  184. r8a7790_register_scif(7);
  185. r8a7790_register_scif(8);
  186. r8a7790_register_scif(9);
  187. r8a7790_register_cmt(00);
  188. }
  189. void __init r8a7790_add_standard_devices(void)
  190. {
  191. r8a7790_add_dt_devices();
  192. r8a7790_register_irqc(0);
  193. r8a7790_register_thermal();
  194. }
  195. void __init r8a7790_init_early(void)
  196. {
  197. #ifndef CONFIG_ARM_ARCH_TIMER
  198. shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
  199. #endif
  200. }
  201. #ifdef CONFIG_USE_OF
  202. static const char * const r8a7790_boards_compat_dt[] __initconst = {
  203. "renesas,r8a7790",
  204. NULL,
  205. };
  206. DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
  207. .smp = smp_ops(r8a7790_smp_ops),
  208. .init_early = r8a7790_init_early,
  209. .init_time = rcar_gen2_timer_init,
  210. .dt_compat = r8a7790_boards_compat_dt,
  211. MACHINE_END
  212. #endif /* CONFIG_USE_OF */