aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Reynes <tremyfr@gmail.com>2015-07-26 17:37:52 -0400
committerShawn Guo <shawnguo@kernel.org>2015-08-05 08:03:56 -0400
commitcec13c26e90e53015360c09574a7a2cde8d29495 (patch)
tree29cb048867a82c44ec70ca1a7d000305f4530a96
parent61186371570e3ca62585e29e307f7a9c42ab789a (diff)
rtc: mxc: add support of device tree
Add device tree support for the mxc rtc driver. Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Philippe Reynes <tremyfr@gmail.com> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
-rw-r--r--drivers/rtc/rtc-mxc.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 880d485d5cc1..7bd89d90048f 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -16,6 +16,8 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/clk.h> 18#include <linux/clk.h>
19#include <linux/of.h>
20#include <linux/of_device.h>
19 21
20#define RTC_INPUT_CLK_32768HZ (0x00 << 5) 22#define RTC_INPUT_CLK_32768HZ (0x00 << 5)
21#define RTC_INPUT_CLK_32000HZ (0x01 << 5) 23#define RTC_INPUT_CLK_32000HZ (0x01 << 5)
@@ -98,6 +100,15 @@ static const struct platform_device_id imx_rtc_devtype[] = {
98}; 100};
99MODULE_DEVICE_TABLE(platform, imx_rtc_devtype); 101MODULE_DEVICE_TABLE(platform, imx_rtc_devtype);
100 102
103#ifdef CONFIG_OF
104static const struct of_device_id imx_rtc_dt_ids[] = {
105 { .compatible = "fsl,imx1-rtc", .data = (const void *)IMX1_RTC },
106 { .compatible = "fsl,imx21-rtc", .data = (const void *)IMX21_RTC },
107 {}
108};
109MODULE_DEVICE_TABLE(of, imx_rtc_dt_ids);
110#endif
111
101static inline int is_imx1_rtc(struct rtc_plat_data *data) 112static inline int is_imx1_rtc(struct rtc_plat_data *data)
102{ 113{
103 return data->devtype == IMX1_RTC; 114 return data->devtype == IMX1_RTC;
@@ -362,12 +373,17 @@ static int mxc_rtc_probe(struct platform_device *pdev)
362 u32 reg; 373 u32 reg;
363 unsigned long rate; 374 unsigned long rate;
364 int ret; 375 int ret;
376 const struct of_device_id *of_id;
365 377
366 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 378 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
367 if (!pdata) 379 if (!pdata)
368 return -ENOMEM; 380 return -ENOMEM;
369 381
370 pdata->devtype = pdev->id_entry->driver_data; 382 of_id = of_match_device(imx_rtc_dt_ids, &pdev->dev);
383 if (of_id)
384 pdata->devtype = (enum imx_rtc_type)of_id->data;
385 else
386 pdata->devtype = pdev->id_entry->driver_data;
371 387
372 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 388 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
373 pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res); 389 pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res);
@@ -488,6 +504,7 @@ static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
488static struct platform_driver mxc_rtc_driver = { 504static struct platform_driver mxc_rtc_driver = {
489 .driver = { 505 .driver = {
490 .name = "mxc_rtc", 506 .name = "mxc_rtc",
507 .of_match_table = of_match_ptr(imx_rtc_dt_ids),
491 .pm = &mxc_rtc_pm_ops, 508 .pm = &mxc_rtc_pm_ops,
492 }, 509 },
493 .id_table = imx_rtc_devtype, 510 .id_table = imx_rtc_devtype,