From: Freddy Hsin <freddy.hsin@mediatek.com>
To: Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>,
Matthias Brugger <matthias.bgg@gmail.com>,
<linux-kernel@vger.kernel.org>, <linux-watchdog@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>
Cc: kuohong.wang@mediatek.com, chun-hung.wu@mediatek.com,
chang-an.chen@mediatek.com, wsd_upstream@mediatek.com,
Freddy Hsin <freddy.hsin@mediatek.com>
Subject: [PATCH v1 1/1] driver: watchdog: Add mtk_wdt_init for mediatek watchdog hw init
Date: Fri, 28 Aug 2020 15:49:28 +0800 [thread overview]
Message-ID: <1598600968-28498-2-git-send-email-freddy.hsin@mediatek.com> (raw)
In-Reply-To: <1598600968-28498-1-git-send-email-freddy.hsin@mediatek.com>
1. add a hw initialization function
2. enable/disable the watchdog depends on the original hw setting
3. set WDOD_HW_RUNNING in start function in order to start
kicker after driver probe and clear the bit in stop function
Change-Id: I25aa797f3b88288f26984455e499e599e27f09fa
Signed-off-by: Freddy Hsin <freddy.hsin@mediatek.com>
---
drivers/watchdog/mtk_wdt.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index d6a6393..59b5061 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -57,6 +57,9 @@
static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int timeout;
+static int mtk_wdt_start(struct watchdog_device *wdt_dev);
+static int mtk_wdt_stop(struct watchdog_device *wdt_dev);
+
struct mtk_wdt_dev {
struct watchdog_device wdt_dev;
void __iomem *wdt_base;
@@ -148,6 +151,19 @@ static int toprgu_register_reset_controller(struct platform_device *pdev,
return ret;
}
+static int mtk_wdt_init(struct watchdog_device *wdt_dev)
+{
+ struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdt_dev);
+ void __iomem *wdt_base;
+
+ wdt_base = mtk_wdt->wdt_base;
+
+ if (readl(wdt_base + WDT_MODE) & WDT_MODE_EN)
+ mtk_wdt_start(wdt_dev);
+ else
+ mtk_wdt_stop(wdt_dev);
+}
+
static int mtk_wdt_restart(struct watchdog_device *wdt_dev,
unsigned long action, void *data)
{
@@ -206,6 +222,8 @@ static int mtk_wdt_stop(struct watchdog_device *wdt_dev)
reg |= WDT_MODE_KEY;
iowrite32(reg, wdt_base + WDT_MODE);
+ clear_bit(WDOG_HW_RUNNING, &wdt_dev->status);
+
return 0;
}
@@ -225,6 +243,8 @@ static int mtk_wdt_start(struct watchdog_device *wdt_dev)
reg |= (WDT_MODE_EN | WDT_MODE_KEY);
iowrite32(reg, wdt_base + WDT_MODE);
+ set_bit(WDOG_HW_RUNNING, &wdt_dev->status);
+
return 0;
}
@@ -274,7 +294,7 @@ static int mtk_wdt_probe(struct platform_device *pdev)
watchdog_set_drvdata(&mtk_wdt->wdt_dev, mtk_wdt);
- mtk_wdt_stop(&mtk_wdt->wdt_dev);
+ mtk_wdt_init(&mtk_wdt->wdt_dev);
watchdog_stop_on_reboot(&mtk_wdt->wdt_dev);
err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
--
1.7.9.5
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-08-28 8:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-28 7:49 [PATCH 0/1] Refine mtk wdt driver init flow Freddy Hsin
2020-08-28 7:49 ` Freddy Hsin [this message]
2020-08-28 14:26 ` [PATCH v1 1/1] driver: watchdog: Add mtk_wdt_init for mediatek watchdog hw init Guenter Roeck
2020-08-29 6:26 ` Freddy.Hsin
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=1598600968-28498-2-git-send-email-freddy.hsin@mediatek.com \
--to=freddy.hsin@mediatek.com \
--cc=chang-an.chen@mediatek.com \
--cc=chun-hung.wu@mediatek.com \
--cc=kuohong.wang@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=matthias.bgg@gmail.com \
--cc=wim@linux-watchdog.org \
--cc=wsd_upstream@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox