diff options
author | Olof Johansson <olof@lixom.net> | 2014-03-17 03:38:40 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2014-03-17 03:38:40 -0400 |
commit | 4664f3d339db54680ac0dbc488dc1ff74d91ac8b (patch) | |
tree | 7ac23d6ab903509c2f5820c3c4a6875d7df42df2 | |
parent | 07cb1ec1ae18828e0b187ef67e9e465623d1ea7b (diff) | |
parent | c4ca5d80e03559fd95c526ece5ce39fc732a2511 (diff) |
Merge tag 'renesas-soc2-for-v3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into next/soc
Merge "Second Round of Renesas ARM Based SoC Updates for v3.15" from Simon
Horman:
* R-Car Gen2 SoCs: r8a7791 (R-Car M2) and r8a7790 (R-Car H2)
- Remove __init from rcar_gen2_read_mode_pins()
* r8a7791 (R-Car M2)
- Use 64-bit dma_addr_t
* r8a7790 (R-Car H2)
- Add CA15-SCU, CA7-SCU
- Add SYSC setup code
- Use 64-bit dma_addr_t
* tag 'renesas-soc2-for-v3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas:
ARM: shmobile: Move SYSC base variable to inside ifdefs
ARM: shmobile: Remove __init from rcar_gen2_read_mode_pins()
ARM: shmobile: r8a7790 CA15-SCU enablement
ARM: shmobile: r8a7790 CA7-SCU enablement
ARM: shmobile: r8a7790 SYSC setup code
ARM: shmobile: Break out R-Car SYSC PM code
ARM: shmobile: Use 64-bit dma_addr_t on r8a7790/r8a7791
Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r-- | arch/arm/mach-shmobile/Kconfig | 3 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/include/mach/pm-rcar.h | 15 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/include/mach/r8a7779.h | 13 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/include/mach/r8a7790.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/pm-r8a7779.c | 131 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/pm-r8a7790.c | 45 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/pm-rcar.c | 141 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/setup-rcar-gen2.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/smp-r8a7779.c | 17 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/smp-r8a7790.c | 17 |
11 files changed, 244 insertions, 144 deletions
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index 8a685edf3bbc..c54db0046ce3 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig | |||
@@ -9,6 +9,7 @@ config ARCH_SHMOBILE_MULTI | |||
9 | select HAVE_ARM_TWD if SMP | 9 | select HAVE_ARM_TWD if SMP |
10 | select ARM_GIC | 10 | select ARM_GIC |
11 | select MIGHT_HAVE_PCI | 11 | select MIGHT_HAVE_PCI |
12 | select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE | ||
12 | select NO_IOPORT | 13 | select NO_IOPORT |
13 | select PINCTRL | 14 | select PINCTRL |
14 | select ARCH_REQUIRE_GPIOLIB | 15 | select ARCH_REQUIRE_GPIOLIB |
@@ -118,6 +119,7 @@ config ARCH_R8A7790 | |||
118 | select MIGHT_HAVE_PCI | 119 | select MIGHT_HAVE_PCI |
119 | select SH_CLK_CPG | 120 | select SH_CLK_CPG |
120 | select RENESAS_IRQC | 121 | select RENESAS_IRQC |
122 | select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE | ||
121 | 123 | ||
122 | config ARCH_R8A7791 | 124 | config ARCH_R8A7791 |
123 | bool "R-Car M2 (R8A77910)" | 125 | bool "R-Car M2 (R8A77910)" |
@@ -127,6 +129,7 @@ config ARCH_R8A7791 | |||
127 | select MIGHT_HAVE_PCI | 129 | select MIGHT_HAVE_PCI |
128 | select SH_CLK_CPG | 130 | select SH_CLK_CPG |
129 | select RENESAS_IRQC | 131 | select RENESAS_IRQC |
132 | select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE | ||
130 | 133 | ||
131 | config ARCH_EMEV2 | 134 | config ARCH_EMEV2 |
132 | bool "Emma Mobile EV2" | 135 | bool "Emma Mobile EV2" |
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index fe7d4ff706e4..d38a6362e5f8 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile | |||
@@ -52,7 +52,8 @@ obj-$(CONFIG_CPU_IDLE) += cpuidle.o | |||
52 | obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o pm-rmobile.o | 52 | obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o pm-rmobile.o |
53 | obj-$(CONFIG_ARCH_SH73A0) += pm-sh73a0.o | 53 | obj-$(CONFIG_ARCH_SH73A0) += pm-sh73a0.o |
54 | obj-$(CONFIG_ARCH_R8A7740) += pm-r8a7740.o pm-rmobile.o | 54 | obj-$(CONFIG_ARCH_R8A7740) += pm-r8a7740.o pm-rmobile.o |
55 | obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o | 55 | obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o pm-rcar.o |
56 | obj-$(CONFIG_ARCH_R8A7790) += pm-r8a7790.o pm-rcar.o | ||
56 | 57 | ||
57 | # Board objects | 58 | # Board objects |
58 | ifdef CONFIG_ARCH_SHMOBILE_MULTI | 59 | ifdef CONFIG_ARCH_SHMOBILE_MULTI |
diff --git a/arch/arm/mach-shmobile/include/mach/pm-rcar.h b/arch/arm/mach-shmobile/include/mach/pm-rcar.h new file mode 100644 index 000000000000..ef3a1ef628f1 --- /dev/null +++ b/arch/arm/mach-shmobile/include/mach/pm-rcar.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef PM_RCAR_H | ||
2 | #define PM_RCAR_H | ||
3 | |||
4 | struct rcar_sysc_ch { | ||
5 | unsigned long chan_offs; | ||
6 | unsigned int chan_bit; | ||
7 | unsigned int isr_bit; | ||
8 | }; | ||
9 | |||
10 | int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch); | ||
11 | int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch); | ||
12 | bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch); | ||
13 | void __iomem *rcar_sysc_init(phys_addr_t base); | ||
14 | |||
15 | #endif /* PM_RCAR_H */ | ||
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7779.h b/arch/arm/mach-shmobile/include/mach/r8a7779.h index b40e13631f6a..88eeceaf1088 100644 --- a/arch/arm/mach-shmobile/include/mach/r8a7779.h +++ b/arch/arm/mach-shmobile/include/mach/r8a7779.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/sh_clk.h> | 4 | #include <linux/sh_clk.h> |
5 | #include <linux/pm_domain.h> | 5 | #include <linux/pm_domain.h> |
6 | #include <mach/pm-rcar.h> | ||
6 | 7 | ||
7 | /* HPB-DMA slave IDs */ | 8 | /* HPB-DMA slave IDs */ |
8 | enum { | 9 | enum { |
@@ -11,18 +12,12 @@ enum { | |||
11 | HPBDMA_SLAVE_SDHI0_RX, | 12 | HPBDMA_SLAVE_SDHI0_RX, |
12 | }; | 13 | }; |
13 | 14 | ||
14 | struct r8a7779_pm_ch { | ||
15 | unsigned long chan_offs; | ||
16 | unsigned int chan_bit; | ||
17 | unsigned int isr_bit; | ||
18 | }; | ||
19 | |||
20 | struct r8a7779_pm_domain { | 15 | struct r8a7779_pm_domain { |
21 | struct generic_pm_domain genpd; | 16 | struct generic_pm_domain genpd; |
22 | struct r8a7779_pm_ch ch; | 17 | struct rcar_sysc_ch ch; |
23 | }; | 18 | }; |
24 | 19 | ||
25 | static inline struct r8a7779_pm_ch *to_r8a7779_ch(struct generic_pm_domain *d) | 20 | static inline struct rcar_sysc_ch *to_r8a7779_ch(struct generic_pm_domain *d) |
26 | { | 21 | { |
27 | return &container_of(d, struct r8a7779_pm_domain, genpd)->ch; | 22 | return &container_of(d, struct r8a7779_pm_domain, genpd)->ch; |
28 | } | 23 | } |
@@ -41,8 +36,6 @@ extern void r8a7779_clock_init(void); | |||
41 | extern void r8a7779_pinmux_init(void); | 36 | extern void r8a7779_pinmux_init(void); |
42 | extern void r8a7779_pm_init(void); | 37 | extern void r8a7779_pm_init(void); |
43 | extern void r8a7779_register_twd(void); | 38 | extern void r8a7779_register_twd(void); |
44 | extern int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch); | ||
45 | extern int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch); | ||
46 | 39 | ||
47 | #ifdef CONFIG_PM | 40 | #ifdef CONFIG_PM |
48 | extern void __init r8a7779_init_pm_domains(void); | 41 | extern void __init r8a7779_init_pm_domains(void); |
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7790.h b/arch/arm/mach-shmobile/include/mach/r8a7790.h index 5fbfa28b40b6..3389f0775def 100644 --- a/arch/arm/mach-shmobile/include/mach/r8a7790.h +++ b/arch/arm/mach-shmobile/include/mach/r8a7790.h | |||
@@ -7,6 +7,7 @@ void r8a7790_add_standard_devices(void); | |||
7 | void r8a7790_add_dt_devices(void); | 7 | void r8a7790_add_dt_devices(void); |
8 | void r8a7790_clock_init(void); | 8 | void r8a7790_clock_init(void); |
9 | void r8a7790_pinmux_init(void); | 9 | void r8a7790_pinmux_init(void); |
10 | void r8a7790_pm_init(void); | ||
10 | void r8a7790_init_early(void); | 11 | void r8a7790_init_early(void); |
11 | extern struct smp_operations r8a7790_smp_ops; | 12 | extern struct smp_operations r8a7790_smp_ops; |
12 | 13 | ||
diff --git a/arch/arm/mach-shmobile/pm-r8a7779.c b/arch/arm/mach-shmobile/pm-r8a7779.c index d50a8e9b94a4..d6fe189b2df6 100644 --- a/arch/arm/mach-shmobile/pm-r8a7779.c +++ b/arch/arm/mach-shmobile/pm-r8a7779.c | |||
@@ -20,132 +20,22 @@ | |||
20 | #include <linux/console.h> | 20 | #include <linux/console.h> |
21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
22 | #include <mach/common.h> | 22 | #include <mach/common.h> |
23 | #include <mach/pm-rcar.h> | ||
23 | #include <mach/r8a7779.h> | 24 | #include <mach/r8a7779.h> |
24 | 25 | ||
25 | static void __iomem *r8a7779_sysc_base; | ||
26 | |||
27 | /* SYSC */ | 26 | /* SYSC */ |
28 | #define SYSCSR 0x00 | ||
29 | #define SYSCISR 0x04 | ||
30 | #define SYSCISCR 0x08 | ||
31 | #define SYSCIER 0x0c | 27 | #define SYSCIER 0x0c |
32 | #define SYSCIMR 0x10 | 28 | #define SYSCIMR 0x10 |
33 | #define PWRSR0 0x40 | ||
34 | #define PWRSR1 0x80 | ||
35 | #define PWRSR2 0xc0 | ||
36 | #define PWRSR3 0x100 | ||
37 | #define PWRSR4 0x140 | ||
38 | |||
39 | #define PWRSR_OFFS 0x00 | ||
40 | #define PWROFFCR_OFFS 0x04 | ||
41 | #define PWRONCR_OFFS 0x0c | ||
42 | #define PWRER_OFFS 0x14 | ||
43 | |||
44 | #define SYSCSR_RETRIES 100 | ||
45 | #define SYSCSR_DELAY_US 1 | ||
46 | |||
47 | #define SYSCISR_RETRIES 1000 | ||
48 | #define SYSCISR_DELAY_US 1 | ||
49 | 29 | ||
50 | #if defined(CONFIG_PM) || defined(CONFIG_SMP) | 30 | #if defined(CONFIG_PM) || defined(CONFIG_SMP) |
51 | 31 | ||
52 | static DEFINE_SPINLOCK(r8a7779_sysc_lock); /* SMP CPUs + I/O devices */ | ||
53 | |||
54 | static int r8a7779_sysc_pwr_on_off(struct r8a7779_pm_ch *r8a7779_ch, | ||
55 | int sr_bit, int reg_offs) | ||
56 | { | ||
57 | int k; | ||
58 | |||
59 | for (k = 0; k < SYSCSR_RETRIES; k++) { | ||
60 | if (ioread32(r8a7779_sysc_base + SYSCSR) & (1 << sr_bit)) | ||
61 | break; | ||
62 | udelay(SYSCSR_DELAY_US); | ||
63 | } | ||
64 | |||
65 | if (k == SYSCSR_RETRIES) | ||
66 | return -EAGAIN; | ||
67 | |||
68 | iowrite32(1 << r8a7779_ch->chan_bit, | ||
69 | r8a7779_sysc_base + r8a7779_ch->chan_offs + reg_offs); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int r8a7779_sysc_pwr_off(struct r8a7779_pm_ch *r8a7779_ch) | ||
75 | { | ||
76 | return r8a7779_sysc_pwr_on_off(r8a7779_ch, 0, PWROFFCR_OFFS); | ||
77 | } | ||
78 | |||
79 | static int r8a7779_sysc_pwr_on(struct r8a7779_pm_ch *r8a7779_ch) | ||
80 | { | ||
81 | return r8a7779_sysc_pwr_on_off(r8a7779_ch, 1, PWRONCR_OFFS); | ||
82 | } | ||
83 | |||
84 | static int r8a7779_sysc_update(struct r8a7779_pm_ch *r8a7779_ch, | ||
85 | int (*on_off_fn)(struct r8a7779_pm_ch *)) | ||
86 | { | ||
87 | unsigned int isr_mask = 1 << r8a7779_ch->isr_bit; | ||
88 | unsigned int chan_mask = 1 << r8a7779_ch->chan_bit; | ||
89 | unsigned int status; | ||
90 | unsigned long flags; | ||
91 | int ret = 0; | ||
92 | int k; | ||
93 | |||
94 | spin_lock_irqsave(&r8a7779_sysc_lock, flags); | ||
95 | |||
96 | iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR); | ||
97 | |||
98 | do { | ||
99 | ret = on_off_fn(r8a7779_ch); | ||
100 | if (ret) | ||
101 | goto out; | ||
102 | |||
103 | status = ioread32(r8a7779_sysc_base + | ||
104 | r8a7779_ch->chan_offs + PWRER_OFFS); | ||
105 | } while (status & chan_mask); | ||
106 | |||
107 | for (k = 0; k < SYSCISR_RETRIES; k++) { | ||
108 | if (ioread32(r8a7779_sysc_base + SYSCISR) & isr_mask) | ||
109 | break; | ||
110 | udelay(SYSCISR_DELAY_US); | ||
111 | } | ||
112 | |||
113 | if (k == SYSCISR_RETRIES) | ||
114 | ret = -EIO; | ||
115 | |||
116 | iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR); | ||
117 | |||
118 | out: | ||
119 | spin_unlock_irqrestore(&r8a7779_sysc_lock, flags); | ||
120 | |||
121 | pr_debug("r8a7779 power domain %d: %02x %02x %02x %02x %02x -> %d\n", | ||
122 | r8a7779_ch->isr_bit, ioread32(r8a7779_sysc_base + PWRSR0), | ||
123 | ioread32(r8a7779_sysc_base + PWRSR1), | ||
124 | ioread32(r8a7779_sysc_base + PWRSR2), | ||
125 | ioread32(r8a7779_sysc_base + PWRSR3), | ||
126 | ioread32(r8a7779_sysc_base + PWRSR4), ret); | ||
127 | return ret; | ||
128 | } | ||
129 | |||
130 | int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch) | ||
131 | { | ||
132 | return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_off); | ||
133 | } | ||
134 | |||
135 | int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch) | ||
136 | { | ||
137 | return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_on); | ||
138 | } | ||
139 | |||
140 | static void __init r8a7779_sysc_init(void) | 32 | static void __init r8a7779_sysc_init(void) |
141 | { | 33 | { |
142 | r8a7779_sysc_base = ioremap_nocache(0xffd85000, PAGE_SIZE); | 34 | void __iomem *base = rcar_sysc_init(0xffd85000); |
143 | if (!r8a7779_sysc_base) | ||
144 | panic("unable to ioremap r8a7779 SYSC hardware block\n"); | ||
145 | 35 | ||
146 | /* enable all interrupt sources, but do not use interrupt handler */ | 36 | /* enable all interrupt sources, but do not use interrupt handler */ |
147 | iowrite32(0x0131000e, r8a7779_sysc_base + SYSCIER); | 37 | iowrite32(0x0131000e, base + SYSCIER); |
148 | iowrite32(0, r8a7779_sysc_base + SYSCIMR); | 38 | iowrite32(0, base + SYSCIMR); |
149 | } | 39 | } |
150 | 40 | ||
151 | #else /* CONFIG_PM || CONFIG_SMP */ | 41 | #else /* CONFIG_PM || CONFIG_SMP */ |
@@ -158,24 +48,17 @@ static inline void r8a7779_sysc_init(void) {} | |||
158 | 48 | ||
159 | static int pd_power_down(struct generic_pm_domain *genpd) | 49 | static int pd_power_down(struct generic_pm_domain *genpd) |
160 | { | 50 | { |
161 | return r8a7779_sysc_power_down(to_r8a7779_ch(genpd)); | 51 | return rcar_sysc_power_down(to_r8a7779_ch(genpd)); |
162 | } | 52 | } |
163 | 53 | ||
164 | static int pd_power_up(struct generic_pm_domain *genpd) | 54 | static int pd_power_up(struct generic_pm_domain *genpd) |
165 | { | 55 | { |
166 | return r8a7779_sysc_power_up(to_r8a7779_ch(genpd)); | 56 | return rcar_sysc_power_up(to_r8a7779_ch(genpd)); |
167 | } | 57 | } |
168 | 58 | ||
169 | static bool pd_is_off(struct generic_pm_domain *genpd) | 59 | static bool pd_is_off(struct generic_pm_domain *genpd) |
170 | { | 60 | { |
171 | struct r8a7779_pm_ch *r8a7779_ch = to_r8a7779_ch(genpd); | 61 | return rcar_sysc_power_is_off(to_r8a7779_ch(genpd)); |
172 | unsigned int st; | ||
173 | |||
174 | st = ioread32(r8a7779_sysc_base + r8a7779_ch->chan_offs + PWRSR_OFFS); | ||
175 | if (st & (1 << r8a7779_ch->chan_bit)) | ||
176 | return true; | ||
177 | |||
178 | return false; | ||
179 | } | 62 | } |
180 | 63 | ||
181 | static bool pd_active_wakeup(struct device *dev) | 64 | static bool pd_active_wakeup(struct device *dev) |
diff --git a/arch/arm/mach-shmobile/pm-r8a7790.c b/arch/arm/mach-shmobile/pm-r8a7790.c new file mode 100644 index 000000000000..fc82839e2c2a --- /dev/null +++ b/arch/arm/mach-shmobile/pm-r8a7790.c | |||
@@ -0,0 +1,45 @@ | |||
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 | #include <asm/io.h> | ||
15 | #include <mach/pm-rcar.h> | ||
16 | #include <mach/r8a7790.h> | ||
17 | |||
18 | /* SYSC */ | ||
19 | #define SYSCIER 0x0c | ||
20 | #define SYSCIMR 0x10 | ||
21 | |||
22 | #if defined(CONFIG_SMP) | ||
23 | |||
24 | static void __init r8a7790_sysc_init(void) | ||
25 | { | ||
26 | void __iomem *base = rcar_sysc_init(0xe6180000); | ||
27 | |||
28 | /* enable all interrupt sources, but do not use interrupt handler */ | ||
29 | iowrite32(0x0131000e, base + SYSCIER); | ||
30 | iowrite32(0, base + SYSCIMR); | ||
31 | } | ||
32 | |||
33 | #else /* CONFIG_SMP */ | ||
34 | |||
35 | static inline void r8a7790_sysc_init(void) {} | ||
36 | |||
37 | #endif /* CONFIG_SMP */ | ||
38 | |||
39 | void __init r8a7790_pm_init(void) | ||
40 | { | ||
41 | static int once; | ||
42 | |||
43 | if (!once++) | ||
44 | r8a7790_sysc_init(); | ||
45 | } | ||
diff --git a/arch/arm/mach-shmobile/pm-rcar.c b/arch/arm/mach-shmobile/pm-rcar.c new file mode 100644 index 000000000000..1f465a12d1b1 --- /dev/null +++ b/arch/arm/mach-shmobile/pm-rcar.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * R-Car SYSC Power management support | ||
3 | * | ||
4 | * Copyright (C) 2014 Magnus Damm | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/delay.h> | ||
12 | #include <linux/err.h> | ||
13 | #include <linux/mm.h> | ||
14 | #include <linux/spinlock.h> | ||
15 | #include <asm/io.h> | ||
16 | #include <mach/pm-rcar.h> | ||
17 | |||
18 | /* SYSC */ | ||
19 | #define SYSCSR 0x00 | ||
20 | #define SYSCISR 0x04 | ||
21 | #define SYSCISCR 0x08 | ||
22 | |||
23 | #define PWRSR_OFFS 0x00 | ||
24 | #define PWROFFCR_OFFS 0x04 | ||
25 | #define PWRONCR_OFFS 0x0c | ||
26 | #define PWRER_OFFS 0x14 | ||
27 | |||
28 | #define SYSCSR_RETRIES 100 | ||
29 | #define SYSCSR_DELAY_US 1 | ||
30 | |||
31 | #define SYSCISR_RETRIES 1000 | ||
32 | #define SYSCISR_DELAY_US 1 | ||
33 | |||
34 | #if defined(CONFIG_PM) || defined(CONFIG_SMP) | ||
35 | |||
36 | static void __iomem *rcar_sysc_base; | ||
37 | static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */ | ||
38 | |||
39 | static int rcar_sysc_pwr_on_off(struct rcar_sysc_ch *sysc_ch, | ||
40 | int sr_bit, int reg_offs) | ||
41 | { | ||
42 | int k; | ||
43 | |||
44 | for (k = 0; k < SYSCSR_RETRIES; k++) { | ||
45 | if (ioread32(rcar_sysc_base + SYSCSR) & (1 << sr_bit)) | ||
46 | break; | ||
47 | udelay(SYSCSR_DELAY_US); | ||
48 | } | ||
49 | |||
50 | if (k == SYSCSR_RETRIES) | ||
51 | return -EAGAIN; | ||
52 | |||
53 | iowrite32(1 << sysc_ch->chan_bit, | ||
54 | rcar_sysc_base + sysc_ch->chan_offs + reg_offs); | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int rcar_sysc_pwr_off(struct rcar_sysc_ch *sysc_ch) | ||
60 | { | ||
61 | return rcar_sysc_pwr_on_off(sysc_ch, 0, PWROFFCR_OFFS); | ||
62 | } | ||
63 | |||
64 | static int rcar_sysc_pwr_on(struct rcar_sysc_ch *sysc_ch) | ||
65 | { | ||
66 | return rcar_sysc_pwr_on_off(sysc_ch, 1, PWRONCR_OFFS); | ||
67 | } | ||
68 | |||
69 | static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch, | ||
70 | int (*on_off_fn)(struct rcar_sysc_ch *)) | ||
71 | { | ||
72 | unsigned int isr_mask = 1 << sysc_ch->isr_bit; | ||
73 | unsigned int chan_mask = 1 << sysc_ch->chan_bit; | ||
74 | unsigned int status; | ||
75 | unsigned long flags; | ||
76 | int ret = 0; | ||
77 | int k; | ||
78 | |||
79 | spin_lock_irqsave(&rcar_sysc_lock, flags); | ||
80 | |||
81 | iowrite32(isr_mask, rcar_sysc_base + SYSCISCR); | ||
82 | |||
83 | do { | ||
84 | ret = on_off_fn(sysc_ch); | ||
85 | if (ret) | ||
86 | goto out; | ||
87 | |||
88 | status = ioread32(rcar_sysc_base + | ||
89 | sysc_ch->chan_offs + PWRER_OFFS); | ||
90 | } while (status & chan_mask); | ||
91 | |||
92 | for (k = 0; k < SYSCISR_RETRIES; k++) { | ||
93 | if (ioread32(rcar_sysc_base + SYSCISR) & isr_mask) | ||
94 | break; | ||
95 | udelay(SYSCISR_DELAY_US); | ||
96 | } | ||
97 | |||
98 | if (k == SYSCISR_RETRIES) | ||
99 | ret = -EIO; | ||
100 | |||
101 | iowrite32(isr_mask, rcar_sysc_base + SYSCISCR); | ||
102 | |||
103 | out: | ||
104 | spin_unlock_irqrestore(&rcar_sysc_lock, flags); | ||
105 | |||
106 | pr_debug("sysc power domain %d: %08x -> %d\n", | ||
107 | sysc_ch->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret); | ||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch) | ||
112 | { | ||
113 | return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_off); | ||
114 | } | ||
115 | |||
116 | int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch) | ||
117 | { | ||
118 | return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_on); | ||
119 | } | ||
120 | |||
121 | bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch) | ||
122 | { | ||
123 | unsigned int st; | ||
124 | |||
125 | st = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRSR_OFFS); | ||
126 | if (st & (1 << sysc_ch->chan_bit)) | ||
127 | return true; | ||
128 | |||
129 | return false; | ||
130 | } | ||
131 | |||
132 | void __iomem *rcar_sysc_init(phys_addr_t base) | ||
133 | { | ||
134 | rcar_sysc_base = ioremap_nocache(base, PAGE_SIZE); | ||
135 | if (!rcar_sysc_base) | ||
136 | panic("unable to ioremap R-Car SYSC hardware block\n"); | ||
137 | |||
138 | return rcar_sysc_base; | ||
139 | } | ||
140 | |||
141 | #endif /* CONFIG_PM || CONFIG_SMP */ | ||
diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c index 69ccc6c6fd33..10604480f325 100644 --- a/arch/arm/mach-shmobile/setup-rcar-gen2.c +++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #define MODEMR 0xe6160060 | 29 | #define MODEMR 0xe6160060 |
30 | 30 | ||
31 | u32 __init rcar_gen2_read_mode_pins(void) | 31 | u32 rcar_gen2_read_mode_pins(void) |
32 | { | 32 | { |
33 | void __iomem *modemr = ioremap_nocache(MODEMR, 4); | 33 | void __iomem *modemr = ioremap_nocache(MODEMR, 4); |
34 | u32 mode; | 34 | u32 mode; |
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c index 627c1f0d9478..e7a3201473d0 100644 --- a/arch/arm/mach-shmobile/smp-r8a7779.c +++ b/arch/arm/mach-shmobile/smp-r8a7779.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <mach/common.h> | 26 | #include <mach/common.h> |
27 | #include <mach/pm-rcar.h> | ||
27 | #include <mach/r8a7779.h> | 28 | #include <mach/r8a7779.h> |
28 | #include <asm/cacheflush.h> | 29 | #include <asm/cacheflush.h> |
29 | #include <asm/smp_plat.h> | 30 | #include <asm/smp_plat.h> |
@@ -33,25 +34,25 @@ | |||
33 | #define AVECR IOMEM(0xfe700040) | 34 | #define AVECR IOMEM(0xfe700040) |
34 | #define R8A7779_SCU_BASE 0xf0000000 | 35 | #define R8A7779_SCU_BASE 0xf0000000 |
35 | 36 | ||
36 | static struct r8a7779_pm_ch r8a7779_ch_cpu1 = { | 37 | static struct rcar_sysc_ch r8a7779_ch_cpu1 = { |
37 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ | 38 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ |
38 | .chan_bit = 1, /* ARM1 */ | 39 | .chan_bit = 1, /* ARM1 */ |
39 | .isr_bit = 1, /* ARM1 */ | 40 | .isr_bit = 1, /* ARM1 */ |
40 | }; | 41 | }; |
41 | 42 | ||
42 | static struct r8a7779_pm_ch r8a7779_ch_cpu2 = { | 43 | static struct rcar_sysc_ch r8a7779_ch_cpu2 = { |
43 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ | 44 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ |
44 | .chan_bit = 2, /* ARM2 */ | 45 | .chan_bit = 2, /* ARM2 */ |
45 | .isr_bit = 2, /* ARM2 */ | 46 | .isr_bit = 2, /* ARM2 */ |
46 | }; | 47 | }; |
47 | 48 | ||
48 | static struct r8a7779_pm_ch r8a7779_ch_cpu3 = { | 49 | static struct rcar_sysc_ch r8a7779_ch_cpu3 = { |
49 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ | 50 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ |
50 | .chan_bit = 3, /* ARM3 */ | 51 | .chan_bit = 3, /* ARM3 */ |
51 | .isr_bit = 3, /* ARM3 */ | 52 | .isr_bit = 3, /* ARM3 */ |
52 | }; | 53 | }; |
53 | 54 | ||
54 | static struct r8a7779_pm_ch *r8a7779_ch_cpu[4] = { | 55 | static struct rcar_sysc_ch *r8a7779_ch_cpu[4] = { |
55 | [1] = &r8a7779_ch_cpu1, | 56 | [1] = &r8a7779_ch_cpu1, |
56 | [2] = &r8a7779_ch_cpu2, | 57 | [2] = &r8a7779_ch_cpu2, |
57 | [3] = &r8a7779_ch_cpu3, | 58 | [3] = &r8a7779_ch_cpu3, |
@@ -67,7 +68,7 @@ void __init r8a7779_register_twd(void) | |||
67 | 68 | ||
68 | static int r8a7779_platform_cpu_kill(unsigned int cpu) | 69 | static int r8a7779_platform_cpu_kill(unsigned int cpu) |
69 | { | 70 | { |
70 | struct r8a7779_pm_ch *ch = NULL; | 71 | struct rcar_sysc_ch *ch = NULL; |
71 | int ret = -EIO; | 72 | int ret = -EIO; |
72 | 73 | ||
73 | cpu = cpu_logical_map(cpu); | 74 | cpu = cpu_logical_map(cpu); |
@@ -76,14 +77,14 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu) | |||
76 | ch = r8a7779_ch_cpu[cpu]; | 77 | ch = r8a7779_ch_cpu[cpu]; |
77 | 78 | ||
78 | if (ch) | 79 | if (ch) |
79 | ret = r8a7779_sysc_power_down(ch); | 80 | ret = rcar_sysc_power_down(ch); |
80 | 81 | ||
81 | return ret ? ret : 1; | 82 | return ret ? ret : 1; |
82 | } | 83 | } |
83 | 84 | ||
84 | static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) | 85 | static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) |
85 | { | 86 | { |
86 | struct r8a7779_pm_ch *ch = NULL; | 87 | struct rcar_sysc_ch *ch = NULL; |
87 | unsigned int lcpu = cpu_logical_map(cpu); | 88 | unsigned int lcpu = cpu_logical_map(cpu); |
88 | int ret; | 89 | int ret; |
89 | 90 | ||
@@ -91,7 +92,7 @@ static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
91 | ch = r8a7779_ch_cpu[lcpu]; | 92 | ch = r8a7779_ch_cpu[lcpu]; |
92 | 93 | ||
93 | if (ch) | 94 | if (ch) |
94 | ret = r8a7779_sysc_power_up(ch); | 95 | ret = rcar_sysc_power_up(ch); |
95 | else | 96 | else |
96 | ret = -EIO; | 97 | ret = -EIO; |
97 | 98 | ||
diff --git a/arch/arm/mach-shmobile/smp-r8a7790.c b/arch/arm/mach-shmobile/smp-r8a7790.c index 015e2753de1f..591052799e8f 100644 --- a/arch/arm/mach-shmobile/smp-r8a7790.c +++ b/arch/arm/mach-shmobile/smp-r8a7790.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <asm/smp_plat.h> | 20 | #include <asm/smp_plat.h> |
21 | #include <mach/common.h> | 21 | #include <mach/common.h> |
22 | #include <mach/pm-rcar.h> | ||
23 | #include <mach/r8a7790.h> | ||
22 | 24 | ||
23 | #define RST 0xe6160000 | 25 | #define RST 0xe6160000 |
24 | #define CA15BAR 0x0020 | 26 | #define CA15BAR 0x0020 |
@@ -27,6 +29,16 @@ | |||
27 | #define CA7RESCNT 0x0044 | 29 | #define CA7RESCNT 0x0044 |
28 | #define MERAM 0xe8080000 | 30 | #define MERAM 0xe8080000 |
29 | 31 | ||
32 | static struct rcar_sysc_ch r8a7790_ca15_scu = { | ||
33 | .chan_offs = 0x180, /* PWRSR5 .. PWRER5 */ | ||
34 | .isr_bit = 12, /* CA15-SCU */ | ||
35 | }; | ||
36 | |||
37 | static struct rcar_sysc_ch r8a7790_ca7_scu = { | ||
38 | .chan_offs = 0x100, /* PWRSR3 .. PWRER3 */ | ||
39 | .isr_bit = 21, /* CA7-SCU */ | ||
40 | }; | ||
41 | |||
30 | static void __init r8a7790_smp_prepare_cpus(unsigned int max_cpus) | 42 | static void __init r8a7790_smp_prepare_cpus(unsigned int max_cpus) |
31 | { | 43 | { |
32 | void __iomem *p; | 44 | void __iomem *p; |
@@ -54,6 +66,11 @@ static void __init r8a7790_smp_prepare_cpus(unsigned int max_cpus) | |||
54 | writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) | 0x5a5a0000, | 66 | writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) | 0x5a5a0000, |
55 | p + CA7RESCNT); | 67 | p + CA7RESCNT); |
56 | iounmap(p); | 68 | iounmap(p); |
69 | |||
70 | /* turn on power to SCU */ | ||
71 | r8a7790_pm_init(); | ||
72 | rcar_sysc_power_up(&r8a7790_ca15_scu); | ||
73 | rcar_sysc_power_up(&r8a7790_ca7_scu); | ||
57 | } | 74 | } |
58 | 75 | ||
59 | struct smp_operations r8a7790_smp_ops __initdata = { | 76 | struct smp_operations r8a7790_smp_ops __initdata = { |