Skip to content

Commit cec13c2

Browse files
Philippe ReynesShawn Guo
authored andcommitted
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>
1 parent 6118637 commit cec13c2

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎drivers/rtc/rtc-mxc.c‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/interrupt.h>
1717
#include <linux/platform_device.h>
1818
#include <linux/clk.h>
19+
#include <linux/of.h>
20+
#include <linux/of_device.h>
1921

2022
#define RTC_INPUT_CLK_32768HZ (0x00 << 5)
2123
#define RTC_INPUT_CLK_32000HZ (0x01 << 5)
@@ -98,6 +100,15 @@ static const struct platform_device_id imx_rtc_devtype[] = {
98100
};
99101
MODULE_DEVICE_TABLE(platform, imx_rtc_devtype);
100102

103+
#ifdef CONFIG_OF
104+
static 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+
};
109+
MODULE_DEVICE_TABLE(of, imx_rtc_dt_ids);
110+
#endif
111+
101112
static inline int is_imx1_rtc(struct rtc_plat_data *data)
102113
{
103114
return data->devtype == IMX1_RTC;
@@ -362,12 +373,17 @@ static int mxc_rtc_probe(struct platform_device *pdev)
362373
u32 reg;
363374
unsigned long rate;
364375
int ret;
376+
const struct of_device_id *of_id;
365377

366378
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
367379
if (!pdata)
368380
return -ENOMEM;
369381

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;
371387

372388
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
373389
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);
488504
static struct platform_driver mxc_rtc_driver = {
489505
.driver = {
490506
.name = "mxc_rtc",
507+
.of_match_table = of_match_ptr(imx_rtc_dt_ids),
491508
.pm = &mxc_rtc_pm_ops,
492509
},
493510
.id_table = imx_rtc_devtype,

0 commit comments

Comments
 (0)