From: Baolin Wang <baolin.wang7@gmail.com>
To: daniel.lezcano@linaro.org, tglx@linutronix.de
Cc: saravanak@google.com, orsonzhai@gmail.com, zhang.lyra@gmail.com,
baolin.wang7@gmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] clocksource/drivers/sprd: Add module support to Spreadtrum timer
Date: Tue, 24 Mar 2020 13:59:37 +0800 [thread overview]
Message-ID: <182aae1ed5e5d2b124f1a32686e5566c9a27c980.1585021186.git.baolin.wang7@gmail.com> (raw)
In-Reply-To: <d2934f74d77c637c41d7cb98710cb5363d09e83b.1585021186.git.baolin.wang7@gmail.com>
In-Reply-To: <d2934f74d77c637c41d7cb98710cb5363d09e83b.1585021186.git.baolin.wang7@gmail.com>
Timers still have devices created for them. So, when compiling a timer
driver as a module, implement it as a normal platform device driver.
Signed-off-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
drivers/clocksource/Kconfig | 2 +-
drivers/clocksource/timer-sprd.c | 37 +++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index cc909e4..404f7dc 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -481,7 +481,7 @@ config MTK_TIMER
Support for Mediatek timer driver.
config SPRD_TIMER
- bool "Spreadtrum timer driver" if EXPERT
+ tristate "Spreadtrum timer driver" if EXPERT
depends on HAS_IOMEM
depends on (ARCH_SPRD || COMPILE_TEST)
default ARCH_SPRD
diff --git a/drivers/clocksource/timer-sprd.c b/drivers/clocksource/timer-sprd.c
index 430cb99..5461789 100644
--- a/drivers/clocksource/timer-sprd.c
+++ b/drivers/clocksource/timer-sprd.c
@@ -5,6 +5,8 @@
#include <linux/init.h>
#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
#include "timer-of.h"
@@ -141,7 +143,7 @@ static irqreturn_t sprd_timer_interrupt(int irq, void *dev_id)
},
};
-static int __init sprd_timer_init(struct device_node *np)
+static int sprd_timer_init(struct device_node *np)
{
int ret;
@@ -190,7 +192,7 @@ static void sprd_suspend_timer_disable(struct clocksource *cs)
.flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP,
};
-static int __init sprd_suspend_timer_init(struct device_node *np)
+static int sprd_suspend_timer_init(struct device_node *np)
{
int ret;
@@ -204,6 +206,37 @@ static int __init sprd_suspend_timer_init(struct device_node *np)
return 0;
}
+#ifdef MODULE
+static int sprd_timer_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+
+ if (of_property_read_bool(np, "interrupts"))
+ return sprd_timer_init(np);
+
+ return sprd_suspend_timer_init(np);
+}
+
+static const struct of_device_id sprd_timer_match_table[] = {
+ { .compatible = "sprd,sc9860-suspend-timer" },
+ { .compatible = "sprd,sc9860-timer" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, sprd_timer_match_table);
+
+static struct platform_driver sprd_timer_driver = {
+ .probe = sprd_timer_probe,
+ .driver = {
+ .name = "sprd-timer",
+ .of_match_table = sprd_timer_match_table,
+ },
+};
+module_platform_driver(sprd_timer_driver);
+
+#else
TIMER_OF_DECLARE(sc9860_timer, "sprd,sc9860-timer", sprd_timer_init);
TIMER_OF_DECLARE(sc9860_persistent_timer, "sprd,sc9860-suspend-timer",
sprd_suspend_timer_init);
+#endif
+
+MODULE_LICENSE("GPL v2");
--
1.9.1
next prev parent reply other threads:[~2020-03-24 5:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 5:59 [PATCH 1/2] drivers/clocksource/timer-of: Remove __init markings Baolin Wang
2020-03-24 5:59 ` Baolin Wang [this message]
2020-04-13 2:55 ` Baolin Wang
2020-04-27 17:13 ` Daniel Lezcano
2020-04-27 19:04 ` Saravana Kannan
2020-04-27 20:09 ` Daniel Lezcano
2020-04-27 20:12 ` Saravana Kannan
2020-04-27 20:50 ` Daniel Lezcano
2020-04-27 22:17 ` Sandeep Patil
2020-04-28 7:02 ` Daniel Lezcano
2020-04-28 18:23 ` Saravana Kannan
2020-04-28 18:31 ` Daniel Lezcano
2020-04-30 12:56 ` Ulf Hansson
2020-04-30 16:52 ` Saravana Kannan
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=182aae1ed5e5d2b124f1a32686e5566c9a27c980.1585021186.git.baolin.wang7@gmail.com \
--to=baolin.wang7@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=saravanak@google.com \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®