setup-r8a7790.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/irqchip.h>
  22. #include <linux/kernel.h>
  23. #include <linux/of_platform.h>
  24. #include <linux/serial_sci.h>
  25. #include <linux/platform_data/irq-renesas-irqc.h>
  26. #include <mach/common.h>
  27. #include <mach/irqs.h>
  28. #include <mach/r8a7790.h>
  29. #include <asm/mach/arch.h>
  30. static const struct resource pfc_resources[] = {
  31. DEFINE_RES_MEM(0xe6060000, 0x250),
  32. DEFINE_RES_MEM(0xe6050000, 0x5050),
  33. };
  34. void __init r8a7790_pinmux_init(void)
  35. {
  36. platform_device_register_simple("pfc-r8a7790", -1, pfc_resources,
  37. ARRAY_SIZE(pfc_resources));
  38. }
  39. #define SCIF_COMMON(scif_type, baseaddr, irq) \
  40. .type = scif_type, \
  41. .mapbase = baseaddr, \
  42. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  43. .irqs = SCIx_IRQ_MUXED(irq)
  44. #define SCIFA_DATA(index, baseaddr, irq) \
  45. [index] = { \
  46. SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
  47. .scbrr_algo_id = SCBRR_ALGO_4, \
  48. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
  49. }
  50. #define SCIFB_DATA(index, baseaddr, irq) \
  51. [index] = { \
  52. SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
  53. .scbrr_algo_id = SCBRR_ALGO_4, \
  54. .scscr = SCSCR_RE | SCSCR_TE, \
  55. }
  56. #define SCIF_DATA(index, baseaddr, irq) \
  57. [index] = { \
  58. SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
  59. .scbrr_algo_id = SCBRR_ALGO_2, \
  60. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
  61. }
  62. enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1 };
  63. static const struct plat_sci_port scif[] = {
  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. };
  73. static inline void r8a7790_register_scif(int idx)
  74. {
  75. platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
  76. sizeof(struct plat_sci_port));
  77. }
  78. static struct renesas_irqc_config irqc0_data = {
  79. .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
  80. };
  81. static struct resource irqc0_resources[] = {
  82. DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
  83. DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
  84. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
  85. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
  86. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
  87. };
  88. #define r8a7790_register_irqc(idx) \
  89. platform_device_register_resndata(&platform_bus, "renesas_irqc", \
  90. idx, irqc##idx##_resources, \
  91. ARRAY_SIZE(irqc##idx##_resources), \
  92. &irqc##idx##_data, \
  93. sizeof(struct renesas_irqc_config))
  94. void __init r8a7790_add_standard_devices(void)
  95. {
  96. r8a7790_register_scif(SCIFA0);
  97. r8a7790_register_scif(SCIFA1);
  98. r8a7790_register_scif(SCIFB0);
  99. r8a7790_register_scif(SCIFB1);
  100. r8a7790_register_scif(SCIFB2);
  101. r8a7790_register_scif(SCIFA2);
  102. r8a7790_register_scif(SCIF0);
  103. r8a7790_register_scif(SCIF1);
  104. r8a7790_register_irqc(0);
  105. }
  106. void __init r8a7790_timer_init(void)
  107. {
  108. void __iomem *cntcr;
  109. /* make sure arch timer is started by setting bit 0 of CNTCT */
  110. cntcr = ioremap(0xe6080000, PAGE_SIZE);
  111. iowrite32(1, cntcr);
  112. iounmap(cntcr);
  113. shmobile_timer_init();
  114. }
  115. #ifdef CONFIG_USE_OF
  116. void __init r8a7790_add_standard_devices_dt(void)
  117. {
  118. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  119. }
  120. static const char *r8a7790_boards_compat_dt[] __initdata = {
  121. "renesas,r8a7790",
  122. NULL,
  123. };
  124. DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
  125. .init_irq = irqchip_init,
  126. .init_machine = r8a7790_add_standard_devices_dt,
  127. .init_time = r8a7790_timer_init,
  128. .dt_compat = r8a7790_boards_compat_dt,
  129. MACHINE_END
  130. #endif /* CONFIG_USE_OF */