keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 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 | |
keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 13 | #include <linux/kernel.h> |
Magnus Damm | 8e26118 | 2014-06-06 16:21:11 +0900 | [diff] [blame^] | 14 | #include <linux/smp.h> |
Geert Uytterhoeven | 5201b5a | 2014-06-20 18:53:07 +0200 | [diff] [blame] | 15 | #include <asm/io.h> |
Magnus Damm | 8e26118 | 2014-06-06 16:21:11 +0900 | [diff] [blame^] | 16 | #include "common.h" |
keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 17 | #include "pm-rcar.h" |
Geert Uytterhoeven | 5201b5a | 2014-06-20 18:53:07 +0200 | [diff] [blame] | 18 | #include "r8a7791.h" |
keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 19 | |
Magnus Damm | 8e26118 | 2014-06-06 16:21:11 +0900 | [diff] [blame^] | 20 | #define RST 0xe6160000 |
| 21 | #define CA15BAR 0x0020 |
| 22 | #define CA15RESCNT 0x0040 |
| 23 | #define RAM 0xe6300000 |
| 24 | |
keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 25 | /* SYSC */ |
| 26 | #define SYSCIER 0x0c |
| 27 | #define SYSCIMR 0x10 |
| 28 | |
| 29 | #if defined(CONFIG_SMP) |
| 30 | |
| 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(0x0131000e, base + SYSCIER); |
| 37 | iowrite32(0, base + SYSCIMR); |
| 38 | } |
| 39 | |
| 40 | #else /* CONFIG_SMP */ |
| 41 | |
| 42 | static inline void r8a7791_sysc_init(void) {} |
| 43 | |
| 44 | #endif /* CONFIG_SMP */ |
| 45 | |
| 46 | void __init r8a7791_pm_init(void) |
| 47 | { |
Magnus Damm | 8e26118 | 2014-06-06 16:21:11 +0900 | [diff] [blame^] | 48 | void __iomem *p; |
| 49 | u32 bar; |
keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 50 | static int once; |
| 51 | |
| 52 | if (once++) |
| 53 | return; |
| 54 | |
Magnus Damm | 8e26118 | 2014-06-06 16:21:11 +0900 | [diff] [blame^] | 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 | |
keita kobayashi | 5f6108b | 2014-05-30 14:18:48 +0900 | [diff] [blame] | 71 | r8a7791_sysc_init(); |
| 72 | } |