Merge tag 'v3.14.25' into backport/v3.14.24-ltsi-rc1+v3.14.25/snapshot-merge.wip
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-shmobile / pm-r8a7790.c
1 /*
2  * r8a7790 Power management support
3  *
4  * Copyright (C) 2013  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
13 #include <linux/kernel.h>
14
15 #include <linux/smp.h>
16 #include <asm/io.h>
17
18 #include "common.h"
19 #include "pm-rcar.h"
20 #include "r8a7790.h"
21
22 /* RST */
23 #define RST             0xe6160000
24 #define CA15BAR         0x0020
25 #define CA7BAR          0x0030
26 #define CA15RESCNT      0x0040
27 #define CA7RESCNT       0x0044
28
29 /* On-chip RAM */
30 #define MERAM          0xe8080000
31
32 /* SYSC */
33 #define SYSCIER 0x0c
34 #define SYSCIMR 0x10
35
36 #if defined(CONFIG_SMP)
37
38 static void __init r8a7790_sysc_init(void)
39 {
40         void __iomem *base = rcar_sysc_init(0xe6180000);
41
42         /* enable all interrupt sources, but do not use interrupt handler */
43         iowrite32(0x0131000e, base + SYSCIER);
44         iowrite32(0, base + SYSCIMR);
45 }
46
47 #else /* CONFIG_SMP */
48
49 static inline void r8a7790_sysc_init(void) {}
50
51 #endif /* CONFIG_SMP */
52
53 void __init r8a7790_pm_init(void)
54 {
55         void __iomem *p;
56         u32 bar;
57         static int once;
58
59         if (once++)
60                 return;
61
62         /* MERAM for jump stub, because BAR requires 256KB aligned address */
63         p = ioremap_nocache(MERAM, shmobile_boot_size);
64         memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
65         iounmap(p);
66
67         /* setup reset vectors */
68         p = ioremap_nocache(RST, 0x63);
69         bar = (MERAM >> 8) & 0xfffffc00;
70         writel_relaxed(bar, p + CA15BAR);
71         writel_relaxed(bar, p + CA7BAR);
72         writel_relaxed(bar | 0x10, p + CA15BAR);
73         writel_relaxed(bar | 0x10, p + CA7BAR);
74
75         /* de-assert reset for all CPUs */
76         writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) | 0xa5a50000,
77                        p + CA15RESCNT);
78         writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) | 0x5a5a0000,
79                        p + CA7RESCNT);
80         iounmap(p);
81
82         r8a7790_sysc_init();
83         shmobile_smp_apmu_suspend_init();
84 }