pm-rcar-gen2.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * R-Car Generation 2 Power management support
  3. *
  4. * Copyright (C) 2013 - 2015 Renesas Electronics Corporation
  5. * Copyright (C) 2011 Renesas Solutions Corp.
  6. * Copyright (C) 2011 Magnus Damm
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/of.h>
  14. #include <linux/smp.h>
  15. #include <asm/io.h>
  16. #include "common.h"
  17. #include "pm-rcar.h"
  18. #include "rcar-gen2.h"
  19. /* RST */
  20. #define RST 0xe6160000
  21. #define CA15BAR 0x0020
  22. #define CA7BAR 0x0030
  23. #define CA15RESCNT 0x0040
  24. #define CA7RESCNT 0x0044
  25. /* On-chip RAM */
  26. #define MERAM 0xe8080000
  27. #define RAM 0xe6300000
  28. /* SYSC */
  29. #define SYSCIER 0x0c
  30. #define SYSCIMR 0x10
  31. #if defined(CONFIG_SMP)
  32. static void __init rcar_gen2_sysc_init(u32 syscier)
  33. {
  34. void __iomem *base = rcar_sysc_init(0xe6180000);
  35. /* enable all interrupt sources, but do not use interrupt handler */
  36. iowrite32(syscier, base + SYSCIER);
  37. iowrite32(0, base + SYSCIMR);
  38. }
  39. #else /* CONFIG_SMP */
  40. static inline void rcar_gen2_sysc_init(u32 syscier) {}
  41. #endif /* CONFIG_SMP */
  42. void __init rcar_gen2_pm_init(void)
  43. {
  44. void __iomem *p;
  45. u32 bar;
  46. static int once;
  47. struct device_node *np, *cpus;
  48. bool has_a7 = false;
  49. bool has_a15 = false;
  50. phys_addr_t boot_vector_addr = 0;
  51. u32 syscier = 0;
  52. if (once++)
  53. return;
  54. cpus = of_find_node_by_path("/cpus");
  55. if (!cpus)
  56. return;
  57. for_each_child_of_node(cpus, np) {
  58. if (of_device_is_compatible(np, "arm,cortex-a15"))
  59. has_a15 = true;
  60. else if (of_device_is_compatible(np, "arm,cortex-a7"))
  61. has_a7 = true;
  62. }
  63. if (of_machine_is_compatible("renesas,r8a7790")) {
  64. boot_vector_addr = MERAM;
  65. syscier = 0x013111ef;
  66. } else if (of_machine_is_compatible("renesas,r8a7791")) {
  67. boot_vector_addr = RAM;
  68. syscier = 0x00111003;
  69. }
  70. /* RAM for jump stub, because BAR requires 256KB aligned address */
  71. p = ioremap_nocache(boot_vector_addr, shmobile_boot_size);
  72. memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
  73. iounmap(p);
  74. /* setup reset vectors */
  75. p = ioremap_nocache(RST, 0x63);
  76. bar = (boot_vector_addr >> 8) & 0xfffffc00;
  77. if (has_a15) {
  78. writel_relaxed(bar, p + CA15BAR);
  79. writel_relaxed(bar | 0x10, p + CA15BAR);
  80. /* de-assert reset for CA15 CPUs */
  81. writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) |
  82. 0xa5a50000, p + CA15RESCNT);
  83. }
  84. if (has_a7) {
  85. writel_relaxed(bar, p + CA7BAR);
  86. writel_relaxed(bar | 0x10, p + CA7BAR);
  87. /* de-assert reset for CA7 CPUs */
  88. writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) |
  89. 0x5a5a0000, p + CA7RESCNT);
  90. }
  91. iounmap(p);
  92. rcar_gen2_sysc_init(syscier);
  93. shmobile_smp_apmu_suspend_init();
  94. }