Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Philippe Reynes and committed by
Shawn Guo
cec13c26 61186371

+18 -1
+18 -1
drivers/rtc/rtc-mxc.c
··· 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) ··· 99 97 } 100 98 }; 101 99 MODULE_DEVICE_TABLE(platform, imx_rtc_devtype); 100 + 101 + #ifdef CONFIG_OF 102 + static const struct of_device_id imx_rtc_dt_ids[] = { 103 + { .compatible = "fsl,imx1-rtc", .data = (const void *)IMX1_RTC }, 104 + { .compatible = "fsl,imx21-rtc", .data = (const void *)IMX21_RTC }, 105 + {} 106 + }; 107 + MODULE_DEVICE_TABLE(of, imx_rtc_dt_ids); 108 + #endif 102 109 103 110 static inline int is_imx1_rtc(struct rtc_plat_data *data) 104 111 { ··· 373 362 u32 reg; 374 363 unsigned long rate; 375 364 int ret; 365 + const struct of_device_id *of_id; 376 366 377 367 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 378 368 if (!pdata) 379 369 return -ENOMEM; 380 370 381 - pdata->devtype = pdev->id_entry->driver_data; 371 + of_id = of_match_device(imx_rtc_dt_ids, &pdev->dev); 372 + if (of_id) 373 + pdata->devtype = (enum imx_rtc_type)of_id->data; 374 + else 375 + pdata->devtype = pdev->id_entry->driver_data; 382 376 383 377 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 384 378 pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res); ··· 504 488 static struct platform_driver mxc_rtc_driver = { 505 489 .driver = { 506 490 .name = "mxc_rtc", 491 + .of_match_table = of_match_ptr(imx_rtc_dt_ids), 507 492 .pm = &mxc_rtc_pm_ops, 508 493 }, 509 494 .id_table = imx_rtc_devtype,