setup-r8a7790.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 <mach/common.h>
  26. #include <mach/irqs.h>
  27. #include <mach/r8a7790.h>
  28. #include <asm/mach/arch.h>
  29. #define SCIF_COMMON(scif_type, baseaddr, irq) \
  30. .type = scif_type, \
  31. .mapbase = baseaddr, \
  32. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  33. .irqs = SCIx_IRQ_MUXED(irq)
  34. #define SCIFA_DATA(index, baseaddr, irq) \
  35. [index] = { \
  36. SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
  37. .scbrr_algo_id = SCBRR_ALGO_4, \
  38. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
  39. }
  40. #define SCIFB_DATA(index, baseaddr, irq) \
  41. [index] = { \
  42. SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
  43. .scbrr_algo_id = SCBRR_ALGO_4, \
  44. .scscr = SCSCR_RE | SCSCR_TE, \
  45. }
  46. #define SCIF_DATA(index, baseaddr, irq) \
  47. [index] = { \
  48. SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
  49. .scbrr_algo_id = SCBRR_ALGO_2, \
  50. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
  51. }
  52. enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1 };
  53. static const struct plat_sci_port scif[] = {
  54. SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
  55. SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
  56. SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
  57. SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
  58. SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
  59. SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */
  60. SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */
  61. SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */
  62. };
  63. static inline void r8a7790_register_scif(int idx)
  64. {
  65. platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
  66. sizeof(struct plat_sci_port));
  67. }
  68. void __init r8a7790_add_standard_devices(void)
  69. {
  70. r8a7790_register_scif(SCIFA0);
  71. r8a7790_register_scif(SCIFA1);
  72. r8a7790_register_scif(SCIFB0);
  73. r8a7790_register_scif(SCIFB1);
  74. r8a7790_register_scif(SCIFB2);
  75. r8a7790_register_scif(SCIFA2);
  76. r8a7790_register_scif(SCIF0);
  77. r8a7790_register_scif(SCIF1);
  78. }
  79. #ifdef CONFIG_USE_OF
  80. void __init r8a7790_add_standard_devices_dt(void)
  81. {
  82. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  83. }
  84. static const char *r8a7790_boards_compat_dt[] __initdata = {
  85. "renesas,r8a7790",
  86. NULL,
  87. };
  88. DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
  89. .init_irq = irqchip_init,
  90. .init_machine = r8a7790_add_standard_devices_dt,
  91. .init_time = shmobile_timer_init,
  92. .dt_compat = r8a7790_boards_compat_dt,
  93. MACHINE_END
  94. #endif /* CONFIG_USE_OF */