Skip to content

Commit 0575fb7

Browse files
Shawn GuoRussell King
authored andcommitted
ARM: 7198/1: arm/imx6: add restart support for imx6q
The restart support was missed from the initial imx6q submission. The mxc_restart() does not work for imx6q. Instead, this patch adds the restart for imx6q. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent f88b897 commit 0575fb7

4 files changed

Lines changed: 58 additions & 3 deletions

File tree

‎arch/arm/mach-imx/clock-imx6q.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,14 +1931,12 @@ int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
19311931
val |= 0x1 << BP_CLPCR_LPM;
19321932
val &= ~BM_CLPCR_VSTBY;
19331933
val &= ~BM_CLPCR_SBYOS;
1934-
val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;
19351934
break;
19361935
case STOP_POWER_OFF:
19371936
val |= 0x2 << BP_CLPCR_LPM;
19381937
val |= 0x3 << BP_CLPCR_STBY_COUNT;
19391938
val |= BM_CLPCR_VSTBY;
19401939
val |= BM_CLPCR_SBYOS;
1941-
val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;
19421940
break;
19431941
default:
19441942
return -EINVAL;

‎arch/arm/mach-imx/mach-imx6q.c‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
* http://www.gnu.org/copyleft/gpl.html
1111
*/
1212

13+
#include <linux/delay.h>
1314
#include <linux/init.h>
15+
#include <linux/io.h>
1416
#include <linux/irq.h>
1517
#include <linux/irqdomain.h>
1618
#include <linux/of.h>
19+
#include <linux/of_address.h>
1720
#include <linux/of_irq.h>
1821
#include <linux/of_platform.h>
1922
#include <asm/hardware/cache-l2x0.h>
@@ -23,6 +26,36 @@
2326
#include <mach/common.h>
2427
#include <mach/hardware.h>
2528

29+
void imx6q_restart(char mode, const char *cmd)
30+
{
31+
struct device_node *np;
32+
void __iomem *wdog_base;
33+
34+
np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-wdt");
35+
wdog_base = of_iomap(np, 0);
36+
if (!wdog_base)
37+
goto soft;
38+
39+
imx_src_prepare_restart();
40+
41+
/* enable wdog */
42+
writew_relaxed(1 << 2, wdog_base);
43+
/* write twice to ensure the request will not get ignored */
44+
writew_relaxed(1 << 2, wdog_base);
45+
46+
/* wait for reset to assert ... */
47+
mdelay(500);
48+
49+
pr_err("Watchdog reset failed to assert reset\n");
50+
51+
/* delay to allow the serial port to show the message */
52+
mdelay(50);
53+
54+
soft:
55+
/* we'll take a jump through zero as a poor second */
56+
soft_restart(0);
57+
}
58+
2659
static void __init imx6q_init_machine(void)
2760
{
2861
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -83,5 +116,5 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad (Device Tree)")
83116
.timer = &imx6q_timer,
84117
.init_machine = imx6q_init_machine,
85118
.dt_compat = imx6q_dt_compat,
86-
.restart = mxc_restart,
119+
.restart = imx6q_restart,
87120
MACHINE_END

‎arch/arm/mach-imx/src.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#define SRC_SCR 0x000
2121
#define SRC_GPR1 0x020
22+
#define BP_SRC_SCR_WARM_RESET_ENABLE 0
2223
#define BP_SRC_SCR_CORE1_RST 14
2324
#define BP_SRC_SCR_CORE1_ENABLE 22
2425

@@ -46,11 +47,33 @@ void imx_set_cpu_jump(int cpu, void *jump_addr)
4647
src_base + SRC_GPR1 + cpu * 8);
4748
}
4849

50+
void imx_src_prepare_restart(void)
51+
{
52+
u32 val;
53+
54+
/* clear enable bits of secondary cores */
55+
val = readl_relaxed(src_base + SRC_SCR);
56+
val &= ~(0x7 << BP_SRC_SCR_CORE1_ENABLE);
57+
writel_relaxed(val, src_base + SRC_SCR);
58+
59+
/* clear persistent entry register of primary core */
60+
writel_relaxed(0, src_base + SRC_GPR1);
61+
}
62+
4963
void __init imx_src_init(void)
5064
{
5165
struct device_node *np;
66+
u32 val;
5267

5368
np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
5469
src_base = of_iomap(np, 0);
5570
WARN_ON(!src_base);
71+
72+
/*
73+
* force warm reset sources to generate cold reset
74+
* for a more reliable restart
75+
*/
76+
val = readl_relaxed(src_base + SRC_SCR);
77+
val &= ~(1 << BP_SRC_SCR_WARM_RESET_ENABLE);
78+
writel_relaxed(val, src_base + SRC_SCR);
5679
}

‎arch/arm/plat-mxc/include/mach/common.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static inline void imx_smp_prepare(void) {}
122122
extern void imx_enable_cpu(int cpu, bool enable);
123123
extern void imx_set_cpu_jump(int cpu, void *jump_addr);
124124
extern void imx_src_init(void);
125+
extern void imx_src_prepare_restart(void);
125126
extern void imx_gpc_init(void);
126127
extern void imx_gpc_pre_suspend(void);
127128
extern void imx_gpc_post_resume(void);

0 commit comments

Comments
 (0)