Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma
[linux-2.6-block.git] / arch / arm / mach-shmobile / pm-r8a7791.c
CommitLineData
5f6108bb 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
5f6108bb 13#include <linux/kernel.h>
8e26118d 14#include <linux/smp.h>
5201b5a7 15#include <asm/io.h>
8e26118d 16#include "common.h"
5f6108bb 17#include "pm-rcar.h"
5201b5a7 18#include "r8a7791.h"
5f6108bb 19
8e26118d
MD
20#define RST 0xe6160000
21#define CA15BAR 0x0020
22#define CA15RESCNT 0x0040
23#define RAM 0xe6300000
24
5f6108bb 25/* SYSC */
26#define SYSCIER 0x0c
27#define SYSCIMR 0x10
28
29#if defined(CONFIG_SMP)
30
31static 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(0x0131000e, base + SYSCIER);
37 iowrite32(0, base + SYSCIMR);
38}
39
40#else /* CONFIG_SMP */
41
42static inline void r8a7791_sysc_init(void) {}
43
44#endif /* CONFIG_SMP */
45
46void __init r8a7791_pm_init(void)
47{
8e26118d
MD
48 void __iomem *p;
49 u32 bar;
5f6108bb 50 static int once;
51
52 if (once++)
53 return;
54
8e26118d
MD
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
5f6108bb 71 r8a7791_sysc_init();
bfe4cfa8 72 shmobile_smp_apmu_suspend_init();
5f6108bb 73}