public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] drivers/rtc: convert mvrtc to DM
Date: Mon, 28 May 2018 23:39:58 +1200	[thread overview]
Message-ID: <20180528113959.5317-2-judge.packham@gmail.com> (raw)
In-Reply-To: <20180528113959.5317-1-judge.packham@gmail.com>

Add DM support for the Marvell RTC driver.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

 drivers/rtc/Kconfig |  7 ++++++
 drivers/rtc/mvrtc.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/rtc/mvrtc.h |  5 ++++
 3 files changed, 68 insertions(+)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 277dc3de737c..a3f8c8aecc74 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -48,6 +48,13 @@ config RTC_RX8010SJ
 	help
 	  Support for Epson RX8010SJ Real Time Clock devices.
 
+config RTC_MV
+	bool "Enable Marvell RTC driver"
+	depends on DM_RTC
+	help
+	  Enable Marvell RTC driver. This driver supports the rtc that is present
+	  on some Marvell SoCs.
+
 config RTC_S35392A
 	bool "Enable S35392A driver"
 	select BITREVERSE
diff --git a/drivers/rtc/mvrtc.c b/drivers/rtc/mvrtc.c
index f7bf95c30292..94a065379c91 100644
--- a/drivers/rtc/mvrtc.c
+++ b/drivers/rtc/mvrtc.c
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <dm.h>
 #include <rtc.h>
 #include <asm/io.h>
 #include "mvrtc.h"
@@ -127,3 +128,58 @@ void rtc_reset(void)
 	__mv_rtc_reset(regs);
 }
 #endif /* !CONFIG_DM_RTC */
+
+#ifdef CONFIG_DM_RTC
+static int mv_rtc_get(struct udevice *dev, struct rtc_time *tm)
+{
+	struct mvrtc_pdata *pdata = dev_get_platdata(dev);
+	struct mvrtc_registers *regs = (struct mvrtc_registers *)pdata->iobase;
+
+	return __mv_rtc_get(regs, tm);
+}
+
+static int mv_rtc_set(struct udevice *dev, const struct rtc_time *tm)
+{
+	struct mvrtc_pdata *pdata = dev_get_platdata(dev);
+	struct mvrtc_registers *regs = (struct mvrtc_registers *)pdata->iobase;
+
+	return __mv_rtc_set(regs, tm);
+}
+
+static int mv_rtc_reset(struct udevice *dev)
+{
+	struct mvrtc_pdata *pdata = dev_get_platdata(dev);
+	struct mvrtc_registers *regs = (struct mvrtc_registers *)pdata->iobase;
+
+	__mv_rtc_reset(regs);
+	return 0;
+}
+
+static const struct rtc_ops mv_rtc_ops = {
+	.get = mv_rtc_get,
+	.set = mv_rtc_set,
+	.reset = mv_rtc_reset,
+};
+
+static const struct udevice_id mv_rtc_ids[] = {
+	{ .compatible = "marvell,kirkwood-rtc" },
+	{ .compatible = "marvell,orion-rtc" },
+	{ }
+};
+
+static int mv_rtc_ofdata_to_platdata(struct udevice *dev)
+{
+	struct mvrtc_pdata *pdata = dev_get_platdata(dev);
+
+	pdata->iobase = devfdt_get_addr(dev);
+	return 0;
+}
+
+U_BOOT_DRIVER(rtc_mv) = {
+	.name	= "rtc-mv",
+	.id	= UCLASS_RTC,
+	.ofdata_to_platdata = mv_rtc_ofdata_to_platdata,
+	.of_match = mv_rtc_ids,
+	.ops	= &mv_rtc_ops,
+};
+#endif /* CONFIG_DM_RTC */
diff --git a/drivers/rtc/mvrtc.h b/drivers/rtc/mvrtc.h
index dc470a9b73c9..87ff43299cad 100644
--- a/drivers/rtc/mvrtc.h
+++ b/drivers/rtc/mvrtc.h
@@ -20,6 +20,11 @@ struct mvrtc_registers {
 	u32 date;
 };
 
+/* Platform data */
+struct mvrtc_pdata {
+	phys_addr_t iobase;
+};
+
 /* time register */
 #define MVRTC_SEC_SFT		0
 #define MVRTC_SEC_MSK		0x7f
-- 
2.17.0

  reply	other threads:[~2018-05-28 11:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-28 11:39 [U-Boot] [PATCH 1/2] drivers/rtc: prepare mvrtc for DM conversion Chris Packham
2018-05-28 11:39 ` Chris Packham [this message]
2018-05-29  6:46   ` [U-Boot] [PATCH 2/2] drivers/rtc: convert mvrtc to DM Stefan Roese
2018-06-06 11:16   ` [U-Boot] [U-Boot,2/2] " Tom Rini
2018-05-29  6:45 ` [U-Boot] [PATCH 1/2] drivers/rtc: prepare mvrtc for DM conversion Stefan Roese
2018-06-06 11:16 ` [U-Boot] [U-Boot, " Tom Rini

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=20180528113959.5317-2-judge.packham@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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