From 1d2c68babbc13d92589f734095ca0051cdd00ff6 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 18 Jan 2014 12:48:05 +0100 Subject: ARM: pxa: add reset source detection Use PXA register RCSR to detect which is the reset cause. When triggering a reset, clear the former reset source first. Signed-off-by: Robert Jarzmik Signed-off-by: Sascha Hauer --- arch/arm/mach-pxa/reset_source.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 arch/arm/mach-pxa/reset_source.c (limited to 'arch/arm/mach-pxa/reset_source.c') diff --git a/arch/arm/mach-pxa/reset_source.c b/arch/arm/mach-pxa/reset_source.c new file mode 100644 index 0000000000..2b650c644d --- /dev/null +++ b/arch/arm/mach-pxa/reset_source.c @@ -0,0 +1,41 @@ +/* + * (C) Copyright 2014 Robert Jarzmik + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include + +static int pxa_detect_reset_source(void) +{ + u32 reg = RCSR; + + /* + * Order is important, as many bits can be set together + */ + if (reg & RCSR_GPR) + set_reset_source(RESET_RST); + else if (reg & RCSR_WDR) + set_reset_source(RESET_WDG); + else if (reg & RCSR_HWR) + set_reset_source(RESET_POR); + else if (reg & RCSR_SMR) + set_reset_source(RESET_WKE); + else + set_reset_source(RESET_UKWN); + + return 0; +} + +device_initcall(pxa_detect_reset_source); -- cgit v1.2.3