linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shc_work@mail.ru (Alexander Shiyan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 4/5] rtc: mxc_rtc: Add DT support
Date: Sat, 29 Jun 2013 12:40:42 +0400	[thread overview]
Message-ID: <1372495244-21215-3-git-send-email-shc_work@mail.ru> (raw)
In-Reply-To: <1372495244-21215-1-git-send-email-shc_work@mail.ru>

Add DT bindings for the mxc_rtc driver and read the device
configuration from the DT node at probe time if available.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 Documentation/devicetree/bindings/rtc/mxc-rtc.txt | 21 ++++++++++++++++++
 drivers/rtc/rtc-mxc.c                             | 27 +++++++++++++++++++----
 2 files changed, 44 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/mxc-rtc.txt

diff --git a/Documentation/devicetree/bindings/rtc/mxc-rtc.txt b/Documentation/devicetree/bindings/rtc/mxc-rtc.txt
new file mode 100644
index 0000000..ad8b0b3
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/mxc-rtc.txt
@@ -0,0 +1,21 @@
+* i.MX Real Time Clock controller
+
+This binding supports the following chips: i.MX1, i.MX27, i.MX31, i.MX35
+
+Required properties:
+- compatible: should be: "fsl,imx1-rtc" or "fsl,imx21-rtc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: rtc alarm interrupt
+- clocks : Should contain the rtc and ipg clocks, in the order
+  determined by the clock-names property.
+
+Example:
+
+rtc at 10007000 {
+	compatible = "fsl,imx27-rtc", "fsl,imx21-rtc";
+	reg = <0x10007000 0x1000>;
+	interrupts = <22>;
+	clocks = <&clks 2>, <&clks 33>;
+	clock-names = "rtc", "ipg";
+};
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 80c6f1f..5079c44 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -13,6 +13,8 @@
 #include <linux/rtc.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 
@@ -377,7 +379,16 @@ static int mxc_rtc_probe(struct platform_device *pdev)
 	/* Disable all interrupts */
 	writew(0, pdata->ioaddr + RTC_RTCIENR);
 
-	pdata->devtype = pdev->id_entry->driver_data;
+	if (pdev->dev.of_node) {
+		struct platform_driver *pdrv = container_of(pdev->dev.driver,
+						struct platform_driver, driver);
+		const struct of_device_id *of_id =
+			of_match_device(pdrv->driver.of_match_table, &pdev->dev);
+
+		pdata->devtype = (enum imx_rtc_type)of_id->data;
+	} else
+		pdata->devtype = pdev->id_entry->driver_data;
+
 	platform_set_drvdata(pdev, pdata);
 
 	pdata->rtc_ops.open		= mxc_rtc_open;
@@ -448,6 +459,13 @@ static int __maybe_unused mxc_rtc_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
 
+static const struct of_device_id mxc_rtc_dt_ids[] = {
+	{ .compatible = "fsl,imx1-rtc", .data = (void *)IMX1_RTC, },
+	{ .compatible = "fsl,imx21-rtc", .data = (void *)IMX21_RTC, },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, mxc_rtc_dt_ids);
+
 static const struct platform_device_id mxc_rtc_id_table[] = {
 	{ .name = "imx1-rtc", .driver_data = IMX1_RTC, },
 	{ .name = "imx21-rtc", .driver_data = IMX21_RTC, },
@@ -457,9 +475,10 @@ MODULE_DEVICE_TABLE(platform, mxc_rtc_id_table);
 
 static struct platform_driver mxc_rtc_driver = {
 	.driver	= {
-		.name	= "mxc_rtc",
-		.owner	= THIS_MODULE,
-		.pm	= &mxc_rtc_pm_ops,
+		.name		= "mxc_rtc",
+		.owner		= THIS_MODULE,
+		.of_match_table	= mxc_rtc_dt_ids,
+		.pm		= &mxc_rtc_pm_ops,
 	},
 	.id_table = mxc_rtc_id_table,
 	.probe	= mxc_rtc_probe,
-- 
1.8.1.5

  parent reply	other threads:[~2013-06-29  8:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-29  8:40 [PATCH v3 1/5] rtc: mxc_rtc: Driver rework Alexander Shiyan
2013-06-29  8:40 ` [PATCH v3 2/5] rtc: mxc_rtc: Cleanup code Alexander Shiyan
2013-06-29  8:40 ` Alexander Shiyan [this message]
2013-06-29  8:40 ` [PATCH v3 3/5] ARM: imx: Using proper clocks for RTC driver Alexander Shiyan
2013-06-29  8:40 ` [PATCH v3 5/5] ARM: imx: move i.MX1/21/27 RTC clk lookup into DT Alexander Shiyan
2013-06-29 12:14 ` [PATCH v3 1/5] rtc: mxc_rtc: Driver rework Sascha Hauer
2013-06-29 21:01   ` Re[2]: " Alexander Shiyan
2013-06-29 21:33     ` Re[3]: " Alexander Shiyan
2013-06-30  8:05       ` Sascha Hauer
2013-06-30  9:10         ` Re[2]: " Alexander Shiyan
2013-06-30 10:16           ` Sascha Hauer
2013-06-30  7:52 ` Sascha Hauer
2013-06-30  8:26   ` Re[2]: " Alexander Shiyan
2013-06-30  8:42     ` [PATCH v3 1/5] rtc: mxc_rtc: Driver re work Lothar Waßmann
2013-06-30  8:45       ` Re[4]: " Alexander Shiyan

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=1372495244-21215-3-git-send-email-shc_work@mail.ru \
    --to=shc_work@mail.ru \
    --cc=linux-arm-kernel@lists.infradead.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).