aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2014-05-05 16:44:24 -0400
committerOlof Johansson <olof@lixom.net>2014-05-05 16:44:24 -0400
commit15e824dd2261f23cd80c9c65571d445697c84ace (patch)
treeaf8257175d2101b0cda12f8e4432afe8f3f3a50d
parent89ca3b881987f5a4be4c5dbaa7f0df12bbdde2fd (diff)
parente35db38d66d1e4007cfc1bb90a05e11b4aaee2a8 (diff)
Merge tag 'renesas-soc-for-v3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into next/soc
Merge "Renesas ARM Based SoC Updates for v3.16" from Simon Horman: SH Mobile shared SoC code * Add shared shmobile_init_delay() r8a7791 (R-Car M2) and r8a7790 (R-Car H2) SoCs (R-Car Gen2 shared code) * Cache Mode Monitor Register Value r8a7791 (R-Car M2) SoC Check r8a7791 MD21 at SMP boot r8a7790 (R-Car H2) SoC * Make use of r8a7790_add_standard_devices() * Update r8a7791 CPU freq to 1500MHz r8a7778 (R-Car M1) SoC * Move "select RENESAS_INTC_IRQPIN" under SoC emev2 (Emma Mobale EV2) SoC * Remove legacy EMEV2 SoC support * tag 'renesas-soc-for-v3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas: ARM: shmobile: r8a7778/bockw: Move "select RENESAS_INTC_IRQPIN" under SoC ARM: shmobile: Check r8a7791 MD21 at SMP boot ARM: shmobile: rcar-gen2: Cache Mode Monitor Register Value ARM: shmobile: Make use of r8a7790_add_standard_devices() ARM: shmobile: Remove EMEV2 header file ARM: shmobile: Remove legacy EMEV2 SoC support ARM: shmobile: Add shared shmobile_init_delay() ARM: shmobile: Update r8a7791 CPU freq to 1500MHz in C Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--arch/arm/boot/dts/Makefile3
-rw-r--r--arch/arm/mach-shmobile/Kconfig13
-rw-r--r--arch/arm/mach-shmobile/Makefile1
-rw-r--r--arch/arm/mach-shmobile/clock-emev2.c231
-rw-r--r--arch/arm/mach-shmobile/include/mach/common.h1
-rw-r--r--arch/arm/mach-shmobile/include/mach/emev2.h9
-rw-r--r--arch/arm/mach-shmobile/setup-emev2.c11
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7790.c12
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7791.c2
-rw-r--r--arch/arm/mach-shmobile/setup-rcar-gen2.c16
-rw-r--r--arch/arm/mach-shmobile/smp-emev2.c1
-rw-r--r--arch/arm/mach-shmobile/smp-r8a7791.c15
-rw-r--r--arch/arm/mach-shmobile/timer.c28
13 files changed, 66 insertions, 277 deletions
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 377b7c364033..3a1bf5bfb6df 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -297,8 +297,7 @@ dtb-$(CONFIG_ARCH_QCOM) += qcom-msm8660-surf.dtb \
297dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb 297dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb
298dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \ 298dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \
299 s3c6410-smdk6410.dtb 299 s3c6410-smdk6410.dtb
300dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \ 300dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += r7s72100-genmai.dtb \
301 r7s72100-genmai.dtb \
302 r7s72100-genmai-reference.dtb \ 301 r7s72100-genmai-reference.dtb \
303 r8a7740-armadillo800eva.dtb \ 302 r8a7740-armadillo800eva.dtb \
304 r8a7778-bockw.dtb \ 303 r8a7778-bockw.dtb \
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 0f92ba8e7884..58bc6db6e79d 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -108,6 +108,7 @@ config ARCH_R8A7778
108 select SH_CLK_CPG 108 select SH_CLK_CPG
109 select ARM_GIC 109 select ARM_GIC
110 select SYS_SUPPORTS_SH_TMU 110 select SYS_SUPPORTS_SH_TMU
111 select RENESAS_INTC_IRQPIN
111 112
112config ARCH_R8A7779 113config ARCH_R8A7779
113 bool "R-Car H1 (R8A77790)" 114 bool "R-Car H1 (R8A77790)"
@@ -140,16 +141,6 @@ config ARCH_R8A7791
140 select SYS_SUPPORTS_SH_CMT 141 select SYS_SUPPORTS_SH_CMT
141 select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE 142 select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
142 143
143config ARCH_EMEV2
144 bool "Emma Mobile EV2"
145 select ARCH_WANT_OPTIONAL_GPIOLIB
146 select ARM_GIC
147 select CPU_V7
148 select MIGHT_HAVE_PCI
149 select USE_OF
150 select AUTO_ZRELADDR
151 select SYS_SUPPORTS_EM_STI
152
153config ARCH_R7S72100 144config ARCH_R7S72100
154 bool "RZ/A1H (R7S72100)" 145 bool "RZ/A1H (R7S72100)"
155 select ARCH_WANT_OPTIONAL_GPIOLIB 146 select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -216,7 +207,6 @@ config MACH_BOCKW
216 depends on ARCH_R8A7778 207 depends on ARCH_R8A7778
217 select ARCH_REQUIRE_GPIOLIB 208 select ARCH_REQUIRE_GPIOLIB
218 select REGULATOR_FIXED_VOLTAGE if REGULATOR 209 select REGULATOR_FIXED_VOLTAGE if REGULATOR
219 select RENESAS_INTC_IRQPIN
220 select SND_SOC_AK4554 if SND_SIMPLE_CARD 210 select SND_SOC_AK4554 if SND_SIMPLE_CARD
221 select SND_SOC_AK4642 if SND_SIMPLE_CARD 211 select SND_SOC_AK4642 if SND_SIMPLE_CARD
222 select USE_OF 212 select USE_OF
@@ -225,7 +215,6 @@ config MACH_BOCKW_REFERENCE
225 bool "BOCK-W - Reference Device Tree Implementation" 215 bool "BOCK-W - Reference Device Tree Implementation"
226 depends on ARCH_R8A7778 216 depends on ARCH_R8A7778
227 select ARCH_REQUIRE_GPIOLIB 217 select ARCH_REQUIRE_GPIOLIB
228 select RENESAS_INTC_IRQPIN
229 select REGULATOR_FIXED_VOLTAGE if REGULATOR 218 select REGULATOR_FIXED_VOLTAGE if REGULATOR
230 select USE_OF 219 select USE_OF
231 ---help--- 220 ---help---
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 4caffc912a81..76053770aa04 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_ARCH_R8A7778) += clock-r8a7778.o
31obj-$(CONFIG_ARCH_R8A7779) += clock-r8a7779.o 31obj-$(CONFIG_ARCH_R8A7779) += clock-r8a7779.o
32obj-$(CONFIG_ARCH_R8A7790) += clock-r8a7790.o 32obj-$(CONFIG_ARCH_R8A7790) += clock-r8a7790.o
33obj-$(CONFIG_ARCH_R8A7791) += clock-r8a7791.o 33obj-$(CONFIG_ARCH_R8A7791) += clock-r8a7791.o
34obj-$(CONFIG_ARCH_EMEV2) += clock-emev2.o
35obj-$(CONFIG_ARCH_R7S72100) += clock-r7s72100.o 34obj-$(CONFIG_ARCH_R7S72100) += clock-r7s72100.o
36endif 35endif
37 36
diff --git a/arch/arm/mach-shmobile/clock-emev2.c b/arch/arm/mach-shmobile/clock-emev2.c
deleted file mode 100644
index 5ac13ba71d54..000000000000
--- a/arch/arm/mach-shmobile/clock-emev2.c
+++ /dev/null
@@ -1,231 +0,0 @@
1/*
2 * Emma Mobile EV2 clock framework support
3 *
4 * Copyright (C) 2012 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#include <linux/init.h>
20#include <linux/kernel.h>
21#include <linux/io.h>
22#include <linux/sh_clk.h>
23#include <linux/clkdev.h>
24#include <mach/common.h>
25
26#define EMEV2_SMU_BASE 0xe0110000
27
28/* EMEV2 SMU registers */
29#define USIAU0_RSTCTRL 0x094
30#define USIBU1_RSTCTRL 0x0ac
31#define USIBU2_RSTCTRL 0x0b0
32#define USIBU3_RSTCTRL 0x0b4
33#define STI_RSTCTRL 0x124
34#define USIAU0GCLKCTRL 0x4a0
35#define USIBU1GCLKCTRL 0x4b8
36#define USIBU2GCLKCTRL 0x4bc
37#define USIBU3GCLKCTRL 0x04c0
38#define STIGCLKCTRL 0x528
39#define USIAU0SCLKDIV 0x61c
40#define USIB2SCLKDIV 0x65c
41#define USIB3SCLKDIV 0x660
42#define STI_CLKSEL 0x688
43
44/* not pretty, but hey */
45static void __iomem *smu_base;
46
47static void emev2_smu_write(unsigned long value, int offs)
48{
49 BUG_ON(!smu_base || (offs >= PAGE_SIZE));
50 iowrite32(value, smu_base + offs);
51}
52
53static struct clk_mapping smu_mapping = {
54 .phys = EMEV2_SMU_BASE,
55 .len = PAGE_SIZE,
56};
57
58/* Fixed 32 KHz root clock from C32K pin */
59static struct clk c32k_clk = {
60 .rate = 32768,
61 .mapping = &smu_mapping,
62};
63
64/* PLL3 multiplies C32K with 7000 */
65static unsigned long pll3_recalc(struct clk *clk)
66{
67 return clk->parent->rate * 7000;
68}
69
70static struct sh_clk_ops pll3_clk_ops = {
71 .recalc = pll3_recalc,
72};
73
74static struct clk pll3_clk = {
75 .ops = &pll3_clk_ops,
76 .parent = &c32k_clk,
77};
78
79static struct clk *main_clks[] = {
80 &c32k_clk,
81 &pll3_clk,
82};
83
84enum { SCLKDIV_USIAU0, SCLKDIV_USIBU2, SCLKDIV_USIBU1, SCLKDIV_USIBU3,
85 SCLKDIV_NR };
86
87#define SCLKDIV(_reg, _shift) \
88{ \
89 .parent = &pll3_clk, \
90 .enable_reg = IOMEM(EMEV2_SMU_BASE + (_reg)), \
91 .enable_bit = _shift, \
92}
93
94static struct clk sclkdiv_clks[SCLKDIV_NR] = {
95 [SCLKDIV_USIAU0] = SCLKDIV(USIAU0SCLKDIV, 0),
96 [SCLKDIV_USIBU2] = SCLKDIV(USIB2SCLKDIV, 16),
97 [SCLKDIV_USIBU1] = SCLKDIV(USIB2SCLKDIV, 0),
98 [SCLKDIV_USIBU3] = SCLKDIV(USIB3SCLKDIV, 0),
99};
100
101enum { GCLK_USIAU0_SCLK, GCLK_USIBU1_SCLK, GCLK_USIBU2_SCLK, GCLK_USIBU3_SCLK,
102 GCLK_STI_SCLK,
103 GCLK_NR };
104
105#define GCLK_SCLK(_parent, _reg) \
106{ \
107 .parent = _parent, \
108 .enable_reg = IOMEM(EMEV2_SMU_BASE + (_reg)), \
109 .enable_bit = 1, /* SCLK_GCC */ \
110}
111
112static struct clk gclk_clks[GCLK_NR] = {
113 [GCLK_USIAU0_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIAU0],
114 USIAU0GCLKCTRL),
115 [GCLK_USIBU1_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU1],
116 USIBU1GCLKCTRL),
117 [GCLK_USIBU2_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU2],
118 USIBU2GCLKCTRL),
119 [GCLK_USIBU3_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU3],
120 USIBU3GCLKCTRL),
121 [GCLK_STI_SCLK] = GCLK_SCLK(&c32k_clk, STIGCLKCTRL),
122};
123
124static int emev2_gclk_enable(struct clk *clk)
125{
126 iowrite32(ioread32(clk->mapped_reg) | (1 << clk->enable_bit),
127 clk->mapped_reg);
128 return 0;
129}
130
131static void emev2_gclk_disable(struct clk *clk)
132{
133 iowrite32(ioread32(clk->mapped_reg) & ~(1 << clk->enable_bit),
134 clk->mapped_reg);
135}
136
137static struct sh_clk_ops emev2_gclk_clk_ops = {
138 .enable = emev2_gclk_enable,
139 .disable = emev2_gclk_disable,
140 .recalc = followparent_recalc,
141};
142
143static int __init emev2_gclk_register(struct clk *clks, int nr)
144{
145 struct clk *clkp;
146 int ret = 0;
147 int k;
148
149 for (k = 0; !ret && (k < nr); k++) {
150 clkp = clks + k;
151 clkp->ops = &emev2_gclk_clk_ops;
152 ret |= clk_register(clkp);
153 }
154
155 return ret;
156}
157
158static unsigned long emev2_sclkdiv_recalc(struct clk *clk)
159{
160 unsigned int sclk_div;
161
162 sclk_div = (ioread32(clk->mapped_reg) >> clk->enable_bit) & 0xff;
163
164 return clk->parent->rate / (sclk_div + 1);
165}
166
167static struct sh_clk_ops emev2_sclkdiv_clk_ops = {
168 .recalc = emev2_sclkdiv_recalc,
169};
170
171static int __init emev2_sclkdiv_register(struct clk *clks, int nr)
172{
173 struct clk *clkp;
174 int ret = 0;
175 int k;
176
177 for (k = 0; !ret && (k < nr); k++) {
178 clkp = clks + k;
179 clkp->ops = &emev2_sclkdiv_clk_ops;
180 ret |= clk_register(clkp);
181 }
182
183 return ret;
184}
185
186static struct clk_lookup lookups[] = {
187 CLKDEV_DEV_ID("serial8250-em.0", &gclk_clks[GCLK_USIAU0_SCLK]),
188 CLKDEV_DEV_ID("e1020000.uart", &gclk_clks[GCLK_USIAU0_SCLK]),
189 CLKDEV_DEV_ID("serial8250-em.1", &gclk_clks[GCLK_USIBU1_SCLK]),
190 CLKDEV_DEV_ID("e1030000.uart", &gclk_clks[GCLK_USIBU1_SCLK]),
191 CLKDEV_DEV_ID("serial8250-em.2", &gclk_clks[GCLK_USIBU2_SCLK]),
192 CLKDEV_DEV_ID("e1040000.uart", &gclk_clks[GCLK_USIBU2_SCLK]),
193 CLKDEV_DEV_ID("serial8250-em.3", &gclk_clks[GCLK_USIBU3_SCLK]),
194 CLKDEV_DEV_ID("e1050000.uart", &gclk_clks[GCLK_USIBU3_SCLK]),
195 CLKDEV_DEV_ID("em_sti.0", &gclk_clks[GCLK_STI_SCLK]),
196 CLKDEV_DEV_ID("e0180000.sti", &gclk_clks[GCLK_STI_SCLK]),
197};
198
199void __init emev2_clock_init(void)
200{
201 int k, ret = 0;
202
203 smu_base = ioremap(EMEV2_SMU_BASE, PAGE_SIZE);
204 BUG_ON(!smu_base);
205
206 /* setup STI timer to run on 32.768 kHz and deassert reset */
207 emev2_smu_write(0, STI_CLKSEL);
208 emev2_smu_write(1, STI_RSTCTRL);
209
210 /* deassert reset for UART0->UART3 */
211 emev2_smu_write(2, USIAU0_RSTCTRL);
212 emev2_smu_write(2, USIBU1_RSTCTRL);
213 emev2_smu_write(2, USIBU2_RSTCTRL);
214 emev2_smu_write(2, USIBU3_RSTCTRL);
215
216 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
217 ret = clk_register(main_clks[k]);
218
219 if (!ret)
220 ret = emev2_sclkdiv_register(sclkdiv_clks, SCLKDIV_NR);
221
222 if (!ret)
223 ret = emev2_gclk_register(gclk_clks, GCLK_NR);
224
225 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
226
227 if (!ret)
228 shmobile_clk_init();
229 else
230 panic("failed to setup emev2 clocks\n");
231}
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index cb8e32deb2a3..f7a360edcc35 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -4,6 +4,7 @@
4extern void shmobile_earlytimer_init(void); 4extern void shmobile_earlytimer_init(void);
5extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz, 5extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
6 unsigned int mult, unsigned int div); 6 unsigned int mult, unsigned int div);
7extern void shmobile_init_delay(void);
7struct twd_local_timer; 8struct twd_local_timer;
8extern void shmobile_setup_console(void); 9extern void shmobile_setup_console(void);
9extern void shmobile_boot_vector(void); 10extern void shmobile_boot_vector(void);
diff --git a/arch/arm/mach-shmobile/include/mach/emev2.h b/arch/arm/mach-shmobile/include/mach/emev2.h
deleted file mode 100644
index fcb142a14e07..000000000000
--- a/arch/arm/mach-shmobile/include/mach/emev2.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef __ASM_EMEV2_H__
2#define __ASM_EMEV2_H__
3
4extern void emev2_map_io(void);
5extern void emev2_init_delay(void);
6extern void emev2_clock_init(void);
7extern struct smp_operations emev2_smp_ops;
8
9#endif /* __ASM_EMEV2_H__ */
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index c71d667007b8..d953ff6e78a2 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -21,7 +21,6 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <mach/common.h> 23#include <mach/common.h>
24#include <mach/emev2.h>
25#include <asm/mach-types.h> 24#include <asm/mach-types.h>
26#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
27#include <asm/mach/map.h> 26#include <asm/mach/map.h>
@@ -38,23 +37,19 @@ static struct map_desc emev2_io_desc[] __initdata = {
38#endif 37#endif
39}; 38};
40 39
41void __init emev2_map_io(void) 40static void __init emev2_map_io(void)
42{ 41{
43 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc)); 42 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
44} 43}
45 44
46void __init emev2_init_delay(void) 45static void __init emev2_init_delay(void)
47{ 46{
48 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */ 47 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
49} 48}
50 49
51static void __init emev2_add_standard_devices_dt(void) 50static void __init emev2_add_standard_devices_dt(void)
52{ 51{
53#ifdef CONFIG_COMMON_CLK
54 of_clk_init(NULL); 52 of_clk_init(NULL);
55#else
56 emev2_clock_init();
57#endif
58 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 53 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
59} 54}
60 55
@@ -63,6 +58,8 @@ static const char *emev2_boards_compat_dt[] __initconst = {
63 NULL, 58 NULL,
64}; 59};
65 60
61extern struct smp_operations emev2_smp_ops;
62
66DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)") 63DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
67 .smp = smp_ops(emev2_smp_ops), 64 .smp = smp_ops(emev2_smp_ops),
68 .map_io = emev2_map_io, 65 .map_io = emev2_map_io,
diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c
index c4616f0698c6..a901d9ef53f6 100644
--- a/arch/arm/mach-shmobile/setup-r8a7790.c
+++ b/arch/arm/mach-shmobile/setup-r8a7790.c
@@ -185,12 +185,6 @@ void __init r8a7790_pinmux_init(void)
185 r8a7790_register_gpio(3); 185 r8a7790_register_gpio(3);
186 r8a7790_register_gpio(4); 186 r8a7790_register_gpio(4);
187 r8a7790_register_gpio(5); 187 r8a7790_register_gpio(5);
188 r8a7790_register_i2c(0);
189 r8a7790_register_i2c(1);
190 r8a7790_register_i2c(2);
191 r8a7790_register_i2c(3);
192 r8a7790_register_audio_dmac(0);
193 r8a7790_register_audio_dmac(1);
194} 188}
195 189
196#define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \ 190#define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \
@@ -308,6 +302,12 @@ void __init r8a7790_add_standard_devices(void)
308 r8a7790_add_dt_devices(); 302 r8a7790_add_dt_devices();
309 r8a7790_register_irqc(0); 303 r8a7790_register_irqc(0);
310 r8a7790_register_thermal(); 304 r8a7790_register_thermal();
305 r8a7790_register_i2c(0);
306 r8a7790_register_i2c(1);
307 r8a7790_register_i2c(2);
308 r8a7790_register_i2c(3);
309 r8a7790_register_audio_dmac(0);
310 r8a7790_register_audio_dmac(1);
311} 311}
312 312
313void __init r8a7790_init_early(void) 313void __init r8a7790_init_early(void)
diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c
index e28404e43860..a7e4966f5e18 100644
--- a/arch/arm/mach-shmobile/setup-r8a7791.c
+++ b/arch/arm/mach-shmobile/setup-r8a7791.c
@@ -213,7 +213,7 @@ void __init r8a7791_add_standard_devices(void)
213void __init r8a7791_init_early(void) 213void __init r8a7791_init_early(void)
214{ 214{
215#ifndef CONFIG_ARM_ARCH_TIMER 215#ifndef CONFIG_ARM_ARCH_TIMER
216 shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */ 216 shmobile_setup_delay(1500, 2, 4); /* Cortex-A15 @ 1500MHz */
217#endif 217#endif
218} 218}
219 219
diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c
index 10604480f325..542c5a47173f 100644
--- a/arch/arm/mach-shmobile/setup-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c
@@ -30,12 +30,16 @@
30 30
31u32 rcar_gen2_read_mode_pins(void) 31u32 rcar_gen2_read_mode_pins(void)
32{ 32{
33 void __iomem *modemr = ioremap_nocache(MODEMR, 4); 33 static u32 mode;
34 u32 mode; 34 static bool mode_valid;
35 35
36 BUG_ON(!modemr); 36 if (!mode_valid) {
37 mode = ioread32(modemr); 37 void __iomem *modemr = ioremap_nocache(MODEMR, 4);
38 iounmap(modemr); 38 BUG_ON(!modemr);
39 mode = ioread32(modemr);
40 iounmap(modemr);
41 mode_valid = true;
42 }
39 43
40 return mode; 44 return mode;
41} 45}
diff --git a/arch/arm/mach-shmobile/smp-emev2.c b/arch/arm/mach-shmobile/smp-emev2.c
index f2ca92308f75..2dfd748da7f3 100644
--- a/arch/arm/mach-shmobile/smp-emev2.c
+++ b/arch/arm/mach-shmobile/smp-emev2.c
@@ -24,7 +24,6 @@
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/emev2.h>
28#include <asm/smp_plat.h> 27#include <asm/smp_plat.h>
29#include <asm/smp_scu.h> 28#include <asm/smp_scu.h>
30 29
diff --git a/arch/arm/mach-shmobile/smp-r8a7791.c b/arch/arm/mach-shmobile/smp-r8a7791.c
index 2df5bd190fe4..ec979529f30f 100644
--- a/arch/arm/mach-shmobile/smp-r8a7791.c
+++ b/arch/arm/mach-shmobile/smp-r8a7791.c
@@ -20,6 +20,7 @@
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/r8a7791.h> 22#include <mach/r8a7791.h>
23#include <mach/rcar-gen2.h>
23 24
24#define RST 0xe6160000 25#define RST 0xe6160000
25#define CA15BAR 0x0020 26#define CA15BAR 0x0020
@@ -51,9 +52,21 @@ static void __init r8a7791_smp_prepare_cpus(unsigned int max_cpus)
51 iounmap(p); 52 iounmap(p);
52} 53}
53 54
55static int r8a7791_smp_boot_secondary(unsigned int cpu,
56 struct task_struct *idle)
57{
58 /* Error out when hardware debug mode is enabled */
59 if (rcar_gen2_read_mode_pins() & BIT(21)) {
60 pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu);
61 return -ENOTSUPP;
62 }
63
64 return shmobile_smp_apmu_boot_secondary(cpu, idle);
65}
66
54struct smp_operations r8a7791_smp_ops __initdata = { 67struct smp_operations r8a7791_smp_ops __initdata = {
55 .smp_prepare_cpus = r8a7791_smp_prepare_cpus, 68 .smp_prepare_cpus = r8a7791_smp_prepare_cpus,
56 .smp_boot_secondary = shmobile_smp_apmu_boot_secondary, 69 .smp_boot_secondary = r8a7791_smp_boot_secondary,
57#ifdef CONFIG_HOTPLUG_CPU 70#ifdef CONFIG_HOTPLUG_CPU
58 .cpu_disable = shmobile_smp_cpu_disable, 71 .cpu_disable = shmobile_smp_cpu_disable,
59 .cpu_die = shmobile_smp_apmu_cpu_die, 72 .cpu_die = shmobile_smp_apmu_cpu_die,
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 62d7052d6f21..ccecde9a3362 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/clocksource.h> 22#include <linux/clocksource.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/of_address.h>
24 25
25void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz, 26void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz,
26 unsigned int mult, unsigned int div) 27 unsigned int mult, unsigned int div)
@@ -39,6 +40,33 @@ void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz,
39 preset_lpj = max_cpu_core_mhz * value; 40 preset_lpj = max_cpu_core_mhz * value;
40} 41}
41 42
43void __init shmobile_init_delay(void)
44{
45 struct device_node *np, *parent;
46 u32 max_freq, freq;
47
48 max_freq = 0;
49
50 parent = of_find_node_by_path("/cpus");
51 if (parent) {
52 for_each_child_of_node(parent, np) {
53 if (!of_property_read_u32(np, "clock-frequency", &freq))
54 max_freq = max(max_freq, freq);
55 }
56 of_node_put(parent);
57 }
58
59 if (max_freq) {
60 if (of_find_compatible_node(NULL, NULL, "arm,cortex-a8"))
61 shmobile_setup_delay(max_freq, 1, 3);
62 else if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9"))
63 shmobile_setup_delay(max_freq, 1, 3);
64 else if (of_find_compatible_node(NULL, NULL, "arm,cortex-a15"))
65 if (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER))
66 shmobile_setup_delay(max_freq, 2, 4);
67 }
68}
69
42static void __init shmobile_late_time_init(void) 70static void __init shmobile_late_time_init(void)
43{ 71{
44 /* 72 /*