Skip to content

Commit 6a7d2c6

Browse files
Uwe Kleine-KönigRussell King
authored andcommitted
ARM: 7828/1: ARMv7-M: implement restart routine common to all v7-M machines
The newly introduced function is to be used as .restart callback for ARMv7-M machines. The used register is architecturally defined, so it should work for all M-class machines. Acked-by: Jonathan Austin <jonathan.austin@arm.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 84b6504 commit 6a7d2c6

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

arch/arm/include/asm/v7m.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
#define V7M_SCB_VTOR 0x08
1717

18+
#define V7M_SCB_AIRCR 0x0c
19+
#define V7M_SCB_AIRCR_VECTKEY (0x05fa << 16)
20+
#define V7M_SCB_AIRCR_SYSRESETREQ (1 << 2)
21+
1822
#define V7M_SCB_SCR 0x10
1923
#define V7M_SCB_SCR_SLEEPDEEP (1 << 2)
2024

@@ -42,3 +46,11 @@
4246
*/
4347
#define EXC_RET_STACK_MASK 0x00000004
4448
#define EXC_RET_THREADMODE_PROCESSSTACK 0xfffffffd
49+
50+
#ifndef __ASSEMBLY__
51+
52+
enum reboot_mode;
53+
54+
void armv7m_restart(enum reboot_mode mode, const char *cmd);
55+
56+
#endif /* __ASSEMBLY__ */

arch/arm/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ obj-$(CONFIG_ATAGS_PROC) += atags_proc.o
2424
obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += atags_compat.o
2525

2626
ifeq ($(CONFIG_CPU_V7M),y)
27-
obj-y += entry-v7m.o
27+
obj-y += entry-v7m.o v7m.o
2828
else
2929
obj-y += entry-armv.o
3030
endif

arch/arm/kernel/v7m.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (C) 2013 Uwe Kleine-Koenig for Pengutronix
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License version 2 as published by the
6+
* Free Software Foundation.
7+
*/
8+
#include <linux/io.h>
9+
#include <linux/reboot.h>
10+
#include <asm/barrier.h>
11+
#include <asm/v7m.h>
12+
13+
void armv7m_restart(enum reboot_mode mode, const char *cmd)
14+
{
15+
dsb();
16+
__raw_writel(V7M_SCB_AIRCR_VECTKEY | V7M_SCB_AIRCR_SYSRESETREQ,
17+
BASEADDR_V7M_SCB + V7M_SCB_AIRCR);
18+
dsb();
19+
}

0 commit comments

Comments
 (0)