linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Walmsley <paul@pwsan.com>
To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/7] ARM: OMAP1: create read_reset_sources() function (for initial use by watchdog)
Date: Mon, 15 Oct 2012 19:32:11 -0600	[thread overview]
Message-ID: <20121016013210.21844.77150.stgit@dusk.lan> (raw)
In-Reply-To: <20121016012448.21844.92339.stgit@dusk.lan>

On OMAP1, the existing OMAP watchdog driver reads a register directly
from a non-watchdog IP block.  It also does not convert the register's
contents into the standard WDIOF_* bits expected from the
GETBOOTSTATUS ioctl().

To move towards fixing these problems, create an function in
arch/arm/mach-omap1 to return the reset source data.  A subsequent
patch will provide this function to the watchdog driver via
platform_data.

In the long term, the best approach would be to move this function
to a new OMAP1 driver that handles access to the OMAP1 Clock
Generation and Reset Management IP block.  Then no platform_data would
be needed.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap1/common.h |    2 ++
 arch/arm/mach-omap1/reset.c  |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index c2552b2..e83fd70 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -90,4 +90,6 @@ extern int ocpi_enable(void);
 static inline int ocpi_enable(void) { return 0; }
 #endif
 
+extern u32 omap1_read_reset_sources(void);
+
 #endif /* __ARCH_ARM_MACH_OMAP1_COMMON_H */
diff --git a/arch/arm/mach-omap1/reset.c b/arch/arm/mach-omap1/reset.c
index b177091..3e894fb 100644
--- a/arch/arm/mach-omap1/reset.c
+++ b/arch/arm/mach-omap1/reset.c
@@ -8,8 +8,22 @@
 
 #include <mach/hardware.h>
 
+#include "iomap.h"
 #include "common.h"
 
+/* ARM_SYSST bit shifts related to SoC reset sources */
+#define ARM_SYSST_POR_SHIFT				5
+#define ARM_SYSST_EXT_RST_SHIFT				4
+#define ARM_SYSST_ARM_WDRST_SHIFT			2
+#define ARM_SYSST_GLOB_SWRST_SHIFT			1
+
+/* Standardized reset source bits (across all OMAP SoCs) */
+#define OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT		0
+#define OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT		1
+#define OMAP_MPU_WD_RST_SRC_ID_SHIFT			3
+#define OMAP_EXTWARM_RST_SRC_ID_SHIFT			5
+
+
 void omap1_restart(char mode, const char *cmd)
 {
 	/*
@@ -23,3 +37,28 @@ void omap1_restart(char mode, const char *cmd)
 
 	omap_writew(1, ARM_RSTCT1);
 }
+
+/**
+ * omap1_read_reset_sources - return the source of the SoC's last reset
+ *
+ * Returns bits that represent the last reset source for the SoC.  The
+ * format is standardized across OMAPs for use by the OMAP watchdog.
+ */
+u32 omap1_read_reset_sources(void)
+{
+	int ret = 0;
+	u16 rs;
+
+	rs = __raw_readw(OMAP1_IO_ADDRESS(ARM_SYSST));
+
+	if (rs & (1 << ARM_SYSST_POR_SHIFT))
+		ret |= 1 << OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT;
+	if (rs & (1 << ARM_SYSST_EXT_RST_SHIFT))
+		ret |= 1 << OMAP_EXTWARM_RST_SRC_ID_SHIFT;
+	if (rs & (1 << ARM_SYSST_ARM_WDRST_SHIFT))
+		ret |= 1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT;
+	if (rs & (1 << ARM_SYSST_GLOB_SWRST_SHIFT))
+		ret |= 1 << OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT;
+
+	return ret;
+}



  parent reply	other threads:[~2012-10-16  1:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-16  1:32 [PATCH 0/7] ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8 Paul Walmsley
2012-10-16  1:32 ` [PATCH 1/7] ARM: OMAP2+: PRM: prepare for use of prm_ll_data function pointers Paul Walmsley
2012-10-16  1:32 ` [PATCH 2/7] ARM: OMAP2+: CM: prepare for use of cm_ll_data " Paul Walmsley
2012-10-16  1:32 ` Paul Walmsley [this message]
2012-10-16  1:32 ` [PATCH 4/7] ARM: OMAP2+: PRM: create PRM reset source API for the watchdog timer driver Paul Walmsley
2012-10-16  1:32 ` [PATCH 5/7] ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer Paul Walmsley
2012-10-23  8:02   ` Wim Van Sebroeck
2012-10-25 15:38   ` Aaro Koskinen
2012-10-25 18:51     ` Paul Walmsley
2012-10-25 18:57       ` Tony Lindgren
2012-10-25 19:09         ` Paul Walmsley
2012-10-25 19:19           ` Tony Lindgren
2012-10-25 19:31             ` Paul Walmsley
2012-10-25 19:34               ` Tony Lindgren
2012-10-25 19:42                 ` Tony Lindgren
2012-10-25 19:57                 ` Paul Walmsley
2012-10-25 20:08                   ` Aaro Koskinen
2012-10-25 20:09                     ` Paul Walmsley
2012-11-08 19:26   ` Paul Walmsley
2012-10-16  1:32 ` [PATCH 6/7] watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr Paul Walmsley
2012-10-23  8:03   ` Wim Van Sebroeck
2012-10-25 20:14   ` Jon Hunter
2012-10-25 20:16     ` Paul Walmsley
2012-10-25 20:29       ` Paul Walmsley
2012-10-25 20:59         ` Felipe Balbi
2012-10-25 21:09           ` Paul Walmsley
2012-10-16  1:32 ` [PATCH 7/7] ARM: OMAP2+: PRCM: remove omap_prcm_get_reset_sources() Paul Walmsley
2012-10-22 12:14 ` [PATCH 0/7] ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8 Benoit Cousson
2012-10-22 17:06   ` Paul Walmsley
2012-10-22 17:29     ` Benoit Cousson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121016013210.21844.77150.stgit@dusk.lan \
    --to=paul@pwsan.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).