All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com,
	orsonzhai@gmail.com, zhang.lyra@gmail.com
Cc: weicx@spreadst.com, sherry.zong@unisoc.com,
	baolin.wang@linaro.org, vincent.guittot@linaro.org,
	linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] spi: sprd: adi: Add a reset reason for watchdog mode
Date: Fri, 26 Jul 2019 15:20:51 +0800	[thread overview]
Message-ID: <1563f3de43c6c2262d597a25d6138b5de61ea23d.1564125131.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <cover.1564125131.git.baolin.wang@linaro.org>
In-Reply-To: <cover.1564125131.git.baolin.wang@linaro.org>

From: Sherry Zong <sherry.zong@unisoc.com>

When the system was rebooted by watchdog, now we did not save the watchdog
reset mode which will make system enter a incorrect mode after rebooting.

Thus we should set the watchdog reset mode as default when opening the
watchdog configuration, that means if the system was rebooted by other
reason through the restart_handler(), then we will clear the default
watchdog reset mode to save the correct reset mode.

Signed-off-by: Sherry Zong <sherry.zong@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/spi/spi-sprd-adi.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
index 509ce69..0d767eb 100644
--- a/drivers/spi/spi-sprd-adi.c
+++ b/drivers/spi/spi-sprd-adi.c
@@ -99,6 +99,7 @@
 #define HWRST_STATUS_IQMODE		0xb0
 #define HWRST_STATUS_SPRDISK		0xc0
 #define HWRST_STATUS_FACTORYTEST	0xe0
+#define HWRST_STATUS_WATCHDOG		0xf0
 
 /* Use default timeout 50 ms that converts to watchdog values */
 #define WDG_LOAD_VAL			((50 * 1000) / 32768)
@@ -309,6 +310,18 @@ static int sprd_adi_transfer_one(struct spi_controller *ctlr,
 	return 0;
 }
 
+static void sprd_adi_set_wdt_rst_mode(struct sprd_adi *sadi)
+{
+#ifdef CONFIG_SPRD_WATCHDOG
+	u32 val;
+
+	/* Set default watchdog reboot mode */
+	sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val);
+	val |= HWRST_STATUS_WATCHDOG;
+	sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val);
+#endif
+}
+
 static int sprd_adi_restart_handler(struct notifier_block *this,
 				    unsigned long mode, void *cmd)
 {
@@ -347,6 +360,7 @@ static int sprd_adi_restart_handler(struct notifier_block *this,
 
 	/* Record the reboot mode */
 	sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val);
+	val &= ~HWRST_STATUS_WATCHDOG;
 	val |= reboot_mode;
 	sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val);
 
@@ -475,6 +489,7 @@ static int sprd_adi_probe(struct platform_device *pdev)
 	}
 
 	sprd_adi_hw_init(sadi);
+	sprd_adi_set_wdt_rst_mode(sadi);
 
 	ctlr->dev.of_node = pdev->dev.of_node;
 	ctlr->bus_num = pdev->id;
-- 
1.7.9.5


  parent reply	other threads:[~2019-07-26  7:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  7:20 [PATCH 0/6] Optimize Spreadtrum ADI driver Baolin Wang
2019-07-26  7:20 ` [PATCH 1/6] spi: sprd: adi: Remove redundant address bits setting Baolin Wang
2019-07-26 12:12   ` Applied "spi: sprd: adi: Remove redundant address bits setting" to the spi tree Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26  7:20 ` [PATCH 2/6] spi: sprd: adi: Add a reset reason for TOS panic Baolin Wang
2019-07-26 12:12   ` Applied "spi: sprd: adi: Add a reset reason for TOS panic" to the spi tree Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26  7:20 ` [PATCH 3/6] spi: sprd: adi: Add a reset reason for factory test mode Baolin Wang
2019-07-26 12:12   ` Applied "spi: sprd: adi: Add a reset reason for factory test mode" to the spi tree Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26  7:20 ` Baolin Wang [this message]
2019-07-26 12:12   ` Applied "spi: sprd: adi: Add a reset reason for watchdog " Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26  7:20 ` [PATCH 5/6] spi: sprd: adi: Change hwlock to be optional Baolin Wang
2019-07-26 12:12   ` Applied "spi: sprd: adi: Change hwlock to be optional" to the spi tree Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26  7:20 ` [PATCH 6/6] dt-bindings: spi: sprd: Change the hwlock support to be optional Baolin Wang
2019-07-26 11:29   ` Mark Brown
2019-07-26 12:10     ` Baolin Wang
2019-07-26 12:12   ` Applied "spi: sprd: Change the hwlock support to be optional" to the spi tree Mark Brown
2019-07-26 12:12     ` Mark Brown
2019-07-26 12:12     ` Mark Brown

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=1563f3de43c6c2262d597a25d6138b5de61ea23d.1564125131.git.baolin.wang@linaro.org \
    --to=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=orsonzhai@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sherry.zong@unisoc.com \
    --cc=vincent.guittot@linaro.org \
    --cc=weicx@spreadst.com \
    --cc=zhang.lyra@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.