2 * R-Car Generation 2 Power management support
4 * Copyright (C) 2013 - 2015 Renesas Electronics Corporation
5 * Copyright (C) 2011 Renesas Solutions Corp.
6 * Copyright (C) 2011 Magnus Damm
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
13 #include <linux/kernel.h>
15 #include <linux/smp.h>
19 #include "rcar-gen2.h"
22 #define RST 0xe6160000
23 #define CA15BAR 0x0020
25 #define CA15RESCNT 0x0040
26 #define CA7RESCNT 0x0044
29 #define MERAM 0xe8080000
30 #define RAM 0xe6300000
36 #if defined(CONFIG_SMP)
38 static void __init rcar_gen2_sysc_init(u32 syscier)
40 void __iomem *base = rcar_sysc_init(0xe6180000);
42 /* enable all interrupt sources, but do not use interrupt handler */
43 iowrite32(syscier, base + SYSCIER);
44 iowrite32(0, base + SYSCIMR);
47 #else /* CONFIG_SMP */
49 static inline void rcar_gen2_sysc_init(u32 syscier) {}
51 #endif /* CONFIG_SMP */
53 void __init rcar_gen2_pm_init(void)
58 struct device_node *np, *cpus;
61 phys_addr_t boot_vector_addr = 0;
67 cpus = of_find_node_by_path("/cpus");
71 for_each_child_of_node(cpus, np) {
72 if (of_device_is_compatible(np, "arm,cortex-a15"))
74 else if (of_device_is_compatible(np, "arm,cortex-a7"))
78 if (of_machine_is_compatible("renesas,r8a7790")) {
79 boot_vector_addr = MERAM;
82 } else if (of_machine_is_compatible("renesas,r8a7791")) {
83 boot_vector_addr = RAM;
87 /* RAM for jump stub, because BAR requires 256KB aligned address */
88 p = ioremap_nocache(boot_vector_addr, shmobile_boot_size);
89 memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
92 /* setup reset vectors */
93 p = ioremap_nocache(RST, 0x63);
94 bar = (boot_vector_addr >> 8) & 0xfffffc00;
96 writel_relaxed(bar, p + CA15BAR);
97 writel_relaxed(bar | 0x10, p + CA15BAR);
99 /* de-assert reset for CA15 CPUs */
100 writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) |
101 0xa5a50000, p + CA15RESCNT);
104 writel_relaxed(bar, p + CA7BAR);
105 writel_relaxed(bar | 0x10, p + CA7BAR);
107 /* de-assert reset for CA7 CPUs */
108 writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) |
109 0x5a5a0000, p + CA7RESCNT);
113 rcar_gen2_sysc_init(syscier);
114 shmobile_smp_apmu_suspend_init();