• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * r8a7791 Power management support
3  *
4  * Copyright (C) 2014  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 #include <linux/smp.h>
15 #include <asm/io.h>
16 #include "common.h"
17 #include "pm-rcar.h"
18 #include "r8a7791.h"
19 
20 #define RST		0xe6160000
21 #define CA15BAR		0x0020
22 #define CA15RESCNT	0x0040
23 #define RAM		0xe6300000
24 
25 /* SYSC */
26 #define SYSCIER 0x0c
27 #define SYSCIMR 0x10
28 
29 #if defined(CONFIG_SMP)
30 
r8a7791_sysc_init(void)31 static void __init r8a7791_sysc_init(void)
32 {
33 	void __iomem *base = rcar_sysc_init(0xe6180000);
34 
35 	/* enable all interrupt sources, but do not use interrupt handler */
36 	iowrite32(0x00111003, base + SYSCIER);
37 	iowrite32(0, base + SYSCIMR);
38 }
39 
40 #else /* CONFIG_SMP */
41 
r8a7791_sysc_init(void)42 static inline void r8a7791_sysc_init(void) {}
43 
44 #endif /* CONFIG_SMP */
45 
r8a7791_pm_init(void)46 void __init r8a7791_pm_init(void)
47 {
48 	void __iomem *p;
49 	u32 bar;
50 	static int once;
51 
52 	if (once++)
53 		return;
54 
55 	/* RAM for jump stub, because BAR requires 256KB aligned address */
56 	p = ioremap_nocache(RAM, shmobile_boot_size);
57 	memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
58 	iounmap(p);
59 
60 	/* setup reset vectors */
61 	p = ioremap_nocache(RST, 0x63);
62 	bar = (RAM >> 8) & 0xfffffc00;
63 	writel_relaxed(bar, p + CA15BAR);
64 	writel_relaxed(bar | 0x10, p + CA15BAR);
65 
66 	/* enable clocks to all CPUs */
67 	writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) | 0xa5a50000,
68 		       p + CA15RESCNT);
69 	iounmap(p);
70 
71 	r8a7791_sysc_init();
72 	shmobile_smp_apmu_suspend_init();
73 }
74