diff mbox

[3/6] rtc: omap: dt support

Message ID a1bbb4ca059980175a755bc189b40c3f1e597db7.1343046707.git.afzal@ti.com (mailing list archive)
State Superseded
Headers show

Commit Message

Afzal Mohammed July 23, 2012, 1:42 p.m. UTC
Enhance rtc-omap driver with DT capability

Signed-off-by: Afzal Mohammed <afzal@ti.com>
---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |   20 ++++++++++++++++++++
 drivers/rtc/rtc-omap.c                             |   18 ++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-omap.txt
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
new file mode 100644
index 0000000..858c4b0
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -0,0 +1,20 @@ 
+TI Real Time Clock
+
+Required properties:
+- compatible: "ti,am1808-rtc"
+- reg: Address range of rtc register set
+- interrupts: rtc timer, alarm interrupts in order
+- interrupt-parent: phandle for the interrupt controller
+
+Alternative for reg and interrupt properties on OMAP:
+- ti,hwmods: Name of the hwmod associated to the RTC
+
+Example:
+
+rtc@1c23000 {
+	compatible = "ti,am1808-rtc";
+	reg = <0x23000 0x1000>;
+	interrupts = <19
+		      19>;
+	interrupt-parent = <&intc>;
+};
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 65eda29..f7cc4b0 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -20,6 +20,8 @@ 
 #include <linux/rtc.h>
 #include <linux/bcd.h>
 #include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/io.h>
 
@@ -308,12 +310,27 @@  static struct platform_device_id omap_rtc_devtype[] = {
 };
 MODULE_DEVICE_TABLE(platform, omap_rtc_devtype);
 
+#define	OMAP_RTC_DATA_AM1808_IDX	1
+
+static const struct of_device_id omap_rtc_of_match[] = {
+	{	.compatible	= "ti,am1808-rtc",
+		.data		= &omap_rtc_devtype[OMAP_RTC_DATA_AM1808_IDX],
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
+
 static int __init omap_rtc_probe(struct platform_device *pdev)
 {
 	struct resource		*res, *mem;
 	struct rtc_device	*rtc;
 	u8			reg, new_ctrl;
 	const struct platform_device_id *id_entry;
+	const struct of_device_id *of_id;
+
+	of_id = of_match_device(omap_rtc_of_match, &pdev->dev);
+	if (of_id)
+		pdev->id_entry = of_id->data;
 
 	omap_rtc_timer = platform_get_irq(pdev, 0);
 	if (omap_rtc_timer <= 0) {
@@ -509,6 +526,7 @@  static struct platform_driver omap_rtc_driver = {
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(omap_rtc_of_match),
 	},
 	.id_table	= omap_rtc_devtype,
 };