From: Freddy Hsin <freddy.hsin@mediatek.com>
To: <linux-mediatek@lists.infradead.or>,
<linux-arm-kernel@lists.infradead.org>,
"Ahmed S. Darwish" <a.darwish@linutronix.de>,
Paul Cercueil <paul@crapouillou.net>,
"Ben Dooks (Codethink)" <ben.dooks@codethink.co.uk>,
Matthias Brugger <matthias.bgg@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Saravana Kannan <saravanak@google.com>,
<linux-kernel@vger.kernel.org>, <chang-an.chen@mediatek.com>,
Baolin Wang <baolin.wang7@gmail.com>, <wsd_upstream@mediatek.com>,
<kuohong.wang@mediatek.com>, <stanley.chu@mediatek.com>,
Freddy Hsin <freddy.hsin@mediatek.com>
Subject: [PATCH v1 2/2] timer: mt6873: porting Mediatek timer driver to loadable module
Date: Tue, 28 Jul 2020 18:16:17 +0800 [thread overview]
Message-ID: <1595931377-21627-3-git-send-email-freddy.hsin@mediatek.com> (raw)
In-Reply-To: <1595931377-21627-1-git-send-email-freddy.hsin@mediatek.com>
porting Mediatek timer driver to loadable module
Signed-off-by: Freddy Hsin <freddy.hsin@mediatek.com>
---
drivers/clocksource/Kconfig | 2 +-
drivers/clocksource/mmio.c | 4 +++-
drivers/clocksource/timer-mediatek.c | 39 ++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 9141838..538351a 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT
bool
config MTK_TIMER
- bool "Mediatek timer driver" if COMPILE_TEST
+ tristate "Mediatek timer driver"
depends on HAS_IOMEM
select TIMER_OF
select CLKSRC_MMIO
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
index 9de7515..5504569 100644
--- a/drivers/clocksource/mmio.c
+++ b/drivers/clocksource/mmio.c
@@ -21,6 +21,7 @@ u64 clocksource_mmio_readl_up(struct clocksource *c)
{
return (u64)readl_relaxed(to_mmio_clksrc(c)->reg);
}
+EXPORT_SYMBOL(clocksource_mmio_readl_up);
u64 clocksource_mmio_readl_down(struct clocksource *c)
{
@@ -46,7 +47,7 @@ u64 clocksource_mmio_readw_down(struct clocksource *c)
* @bits: Number of valid bits
* @read: One of clocksource_mmio_read*() above
*/
-int __init clocksource_mmio_init(void __iomem *base, const char *name,
+int clocksource_mmio_init(void __iomem *base, const char *name,
unsigned long hz, int rating, unsigned bits,
u64 (*read)(struct clocksource *))
{
@@ -68,3 +69,4 @@ int __init clocksource_mmio_init(void __iomem *base, const char *name,
return clocksource_register_hz(&cs->clksrc, hz);
}
+EXPORT_SYMBOL(clocksource_mmio_init);
diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index 9318edc..5c89b6b 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -13,6 +13,9 @@
#include <linux/clocksource.h>
#include <linux/interrupt.h>
#include <linux/irqreturn.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
#include <linux/sched_clock.h>
#include <linux/slab.h>
#include "timer-of.h"
@@ -309,5 +312,41 @@ static int __init mtk_gpt_init(struct device_node *node)
return 0;
}
+
+#ifdef MODULE
+static int mtk_timer_probe(struct platform_device *pdev)
+{
+ int (*timer_init)(struct device_node *node);
+ struct device_node *np = pdev->dev.of_node;
+
+ timer_init = of_device_get_match_data(&pdev->dev);
+ return timer_init(np);
+}
+
+static const struct of_device_id mtk_timer_match_table[] = {
+ {
+ .compatible = "mediatek,mt6577-timer",
+ .data = mtk_gpt_init,
+ },
+ {
+ .compatible = "mediatek,mt6765-timer",
+ .data = mtk_syst_init,
+ },
+ {}
+};
+
+static struct platform_driver mtk_timer_driver = {
+ .probe = mtk_timer_probe,
+ .driver = {
+ .name = "mtk-timer",
+ .of_match_table = mtk_timer_match_table,
+ },
+};
+MODULE_DESCRIPTION("MEDIATEK Module timer driver");
+MODULE_LICENSE("GPL v2");
+
+module_platform_driver(mtk_timer_driver);
+#else
TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
+#endif
--
1.7.9.5
next prev parent reply other threads:[~2020-07-28 10:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 10:16 [PATCH v1] Porting Mediatek timer driver to kernel module Freddy Hsin
2020-07-28 10:16 ` [PATCH v1 1/2] kernel: time: export sched_clock_register function Freddy Hsin
2020-07-29 12:47 ` Thomas Gleixner
2020-07-29 14:09 ` Daniel Lezcano
2020-07-28 10:16 ` Freddy Hsin [this message]
2020-07-29 13:02 ` [PATCH v1 2/2] timer: mt6873: porting Mediatek timer driver to loadable module Thomas Gleixner
2020-07-29 18:42 ` 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=1595931377-21627-3-git-send-email-freddy.hsin@mediatek.com \
--to=freddy.hsin@mediatek.com \
--cc=a.darwish@linutronix.de \
--cc=baolin.wang7@gmail.com \
--cc=ben.dooks@codethink.co.uk \
--cc=chang-an.chen@mediatek.com \
--cc=daniel.lezcano@linaro.org \
--cc=kuohong.wang@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.or \
--cc=matthias.bgg@gmail.com \
--cc=paul@crapouillou.net \
--cc=saravanak@google.com \
--cc=stanley.chu@mediatek.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).