From: Srinivas Neeli <srinivas.neeli@xilinx.com>
To: <linux@roeck-us.net>, <michal.simek@xilinx.com>,
<shubhrajyoti.datta@xilinx.com>, <sgoud@xilinx.com>
Cc: <wim@linux-watchdog.org>, <linux-watchdog@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <git@xilinx.com>,
Srinivas Neeli <srinivas.neeli@xilinx.com>,
Srinivas Goud <srinivas.goud@xilinx.com>
Subject: [PATCH 4/9] watchdog: of_xilinx_wdt: Initialize watchdog via data structure
Date: Mon, 15 Mar 2021 16:16:49 +0530 [thread overview]
Message-ID: <1615805214-24857-5-git-send-email-srinivas.neeli@xilinx.com> (raw)
In-Reply-To: <1615805214-24857-1-git-send-email-srinivas.neeli@xilinx.com>
This patch is preparation for adding new watchdog based on this driver.
of_id->data is storing link xwdt_devtype_data which stores watchdog
info and ops pointers to structures.
Signed-off-by: Srinivas Goud <srinivas.goud@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
drivers/watchdog/of_xilinx_wdt.c | 50 +++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
index 9e67b598907e..b2ce1b90237e 100644
--- a/drivers/watchdog/of_xilinx_wdt.c
+++ b/drivers/watchdog/of_xilinx_wdt.c
@@ -37,6 +37,11 @@
#define WATCHDOG_NAME "Xilinx Watchdog"
+struct xwdt_devtype_data {
+ const struct watchdog_ops *xwdt_ops;
+ const struct watchdog_info *xwdt_info;
+};
+
struct xwdt_device {
void __iomem *base;
u32 wdt_interval;
@@ -160,6 +165,20 @@ static void xwdt_clk_disable_unprepare(void *data)
clk_disable_unprepare(data);
}
+static const struct xwdt_devtype_data xwdt_wdt_data = {
+ .xwdt_info = &xilinx_wdt_ident,
+ .xwdt_ops = &xilinx_wdt_ops,
+};
+
+static const struct of_device_id xwdt_of_match[] = {
+ { .compatible = "xlnx,xps-timebase-wdt-1.00.a",
+ .data = &xwdt_wdt_data },
+ { .compatible = "xlnx,xps-timebase-wdt-1.01.a",
+ .data = &xwdt_wdt_data },
+ {},
+};
+MODULE_DEVICE_TABLE(of, xwdt_of_match);
+
static int xwdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -167,14 +186,23 @@ static int xwdt_probe(struct platform_device *pdev)
u32 pfreq = 0, enable_once = 0;
struct xwdt_device *xdev;
struct watchdog_device *xilinx_wdt_wdd;
+ const struct of_device_id *of_id;
+ const struct xwdt_devtype_data *devtype;
xdev = devm_kzalloc(dev, sizeof(*xdev), GFP_KERNEL);
if (!xdev)
return -ENOMEM;
xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd;
- xilinx_wdt_wdd->info = &xilinx_wdt_ident;
- xilinx_wdt_wdd->ops = &xilinx_wdt_ops;
+
+ of_id = of_match_device(xwdt_of_match, &pdev->dev);
+ if (!of_id)
+ return -EINVAL;
+
+ devtype = of_id->data;
+
+ xilinx_wdt_wdd->info = devtype->xwdt_info;
+ xilinx_wdt_wdd->ops = devtype->xwdt_ops;
xilinx_wdt_wdd->parent = dev;
xdev->base = devm_platform_ioremap_resource(pdev, 0);
@@ -264,9 +292,10 @@ static int xwdt_probe(struct platform_device *pdev)
static int __maybe_unused xwdt_suspend(struct device *dev)
{
struct xwdt_device *xdev = dev_get_drvdata(dev);
+ struct watchdog_device *xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd;
- if (watchdog_active(&xdev->xilinx_wdt_wdd))
- xilinx_wdt_stop(&xdev->xilinx_wdt_wdd);
+ if (watchdog_active(xilinx_wdt_wdd))
+ xilinx_wdt_wdd->ops->stop(xilinx_wdt_wdd);
return 0;
}
@@ -280,24 +309,17 @@ static int __maybe_unused xwdt_suspend(struct device *dev)
static int __maybe_unused xwdt_resume(struct device *dev)
{
struct xwdt_device *xdev = dev_get_drvdata(dev);
+ struct watchdog_device *xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd;
int ret = 0;
- if (watchdog_active(&xdev->xilinx_wdt_wdd))
- ret = xilinx_wdt_start(&xdev->xilinx_wdt_wdd);
+ if (watchdog_active(xilinx_wdt_wdd))
+ ret = xilinx_wdt_wdd->ops->start(xilinx_wdt_wdd);
return ret;
}
static SIMPLE_DEV_PM_OPS(xwdt_pm_ops, xwdt_suspend, xwdt_resume);
-/* Match table for of_platform binding */
-static const struct of_device_id xwdt_of_match[] = {
- { .compatible = "xlnx,xps-timebase-wdt-1.00.a", },
- { .compatible = "xlnx,xps-timebase-wdt-1.01.a", },
- {},
-};
-MODULE_DEVICE_TABLE(of, xwdt_of_match);
-
static struct platform_driver xwdt_driver = {
.probe = xwdt_probe,
.driver = {
--
2.7.4
next prev parent reply other threads:[~2021-03-15 10:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 10:46 [PATCH 0/9] watchdog: of_xilinx_wdt: Update on xilinx watchdog driver Srinivas Neeli
2021-03-15 10:46 ` [PATCH 1/9] watchdog: of_xilinx_wdt: Add comment to spinlock Srinivas Neeli
2021-03-16 2:21 ` Guenter Roeck
2021-03-15 10:46 ` [PATCH 2/9] watchdog: of_xilinx_wdt: Used BIT macro Srinivas Neeli
2021-03-16 2:23 ` Guenter Roeck
2021-03-24 6:06 ` Srinivas Neeli
2021-03-15 10:46 ` [PATCH 3/9] watchdog: of_xilinx_wdt: Used dev_dbg() Srinivas Neeli
2021-03-16 2:27 ` Guenter Roeck
2021-03-15 10:46 ` Srinivas Neeli [this message]
2021-03-15 10:46 ` [PATCH 5/9] watchdog: of_xilinx_wdt: Introduce wdttype enum for identification Srinivas Neeli
2021-03-15 10:46 ` [PATCH 6/9] dt-bindings: watchdog: xilinx: Add binding for Versal watchdog Srinivas Neeli
2021-03-15 10:46 ` [PATCH 7/9] watchdog: of_xilinx_wdt: Add Versal Window watchdog support Srinivas Neeli
2021-03-16 2:31 ` Guenter Roeck
2021-03-24 6:04 ` Srinivas Neeli
2021-03-24 14:01 ` Guenter Roeck
2021-03-15 10:46 ` [PATCH 8/9] watchdog: of_xilinx_wdt: Remove passing null pointer Srinivas Neeli
2021-03-16 2:33 ` Guenter Roeck
2021-03-15 10:46 ` [PATCH 9/9] watchdog: of_xilinx_wdt: Skip printing pointer value Srinivas Neeli
2021-03-16 2:34 ` Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2020-01-16 13:26 [PATCH 0/9] watchdog: of_xilinx_wdt: Update on watchdog driver Srinivas Neeli
2020-01-16 13:26 ` [PATCH 4/9] watchdog: of_xilinx_wdt: Initialize watchdog via data structure Srinivas Neeli
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=1615805214-24857-5-git-send-email-srinivas.neeli@xilinx.com \
--to=srinivas.neeli@xilinx.com \
--cc=git@xilinx.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=michal.simek@xilinx.com \
--cc=sgoud@xilinx.com \
--cc=shubhrajyoti.datta@xilinx.com \
--cc=srinivas.goud@xilinx.com \
--cc=wim@linux-watchdog.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).