|
16 | 16 | #include <linux/interrupt.h> |
17 | 17 | #include <linux/platform_device.h> |
18 | 18 | #include <linux/clk.h> |
| 19 | +#include <linux/of.h> |
| 20 | +#include <linux/of_device.h> |
19 | 21 |
|
20 | 22 | #define RTC_INPUT_CLK_32768HZ (0x00 << 5) |
21 | 23 | #define RTC_INPUT_CLK_32000HZ (0x01 << 5) |
@@ -98,6 +100,15 @@ static const struct platform_device_id imx_rtc_devtype[] = { |
98 | 100 | }; |
99 | 101 | MODULE_DEVICE_TABLE(platform, imx_rtc_devtype); |
100 | 102 |
|
| 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 | + |
101 | 112 | static inline int is_imx1_rtc(struct rtc_plat_data *data) |
102 | 113 | { |
103 | 114 | return data->devtype == IMX1_RTC; |
@@ -362,12 +373,17 @@ static int mxc_rtc_probe(struct platform_device *pdev) |
362 | 373 | u32 reg; |
363 | 374 | unsigned long rate; |
364 | 375 | int ret; |
| 376 | + const struct of_device_id *of_id; |
365 | 377 |
|
366 | 378 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
367 | 379 | if (!pdata) |
368 | 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 | 388 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
373 | 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); |
488 | 504 | static struct platform_driver mxc_rtc_driver = { |
489 | 505 | .driver = { |
490 | 506 | .name = "mxc_rtc", |
| 507 | + .of_match_table = of_match_ptr(imx_rtc_dt_ids), |
491 | 508 | .pm = &mxc_rtc_pm_ops, |
492 | 509 | }, |
493 | 510 | .id_table = imx_rtc_devtype, |
|
0 commit comments