aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-mxc.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index cd0106293a49..7304139934aa 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -17,8 +17,6 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/clk.h> 18#include <linux/clk.h>
19 19
20#include <mach/hardware.h>
21
22#define RTC_INPUT_CLK_32768HZ (0x00 << 5) 20#define RTC_INPUT_CLK_32768HZ (0x00 << 5)
23#define RTC_INPUT_CLK_32000HZ (0x01 << 5) 21#define RTC_INPUT_CLK_32000HZ (0x01 << 5)
24#define RTC_INPUT_CLK_38400HZ (0x02 << 5) 22#define RTC_INPUT_CLK_38400HZ (0x02 << 5)
@@ -72,14 +70,38 @@ static const u32 PIE_BIT_DEF[MAX_PIE_NUM][2] = {
72#define RTC_TEST2 0x2C /* 32bit rtc test reg 2 */ 70#define RTC_TEST2 0x2C /* 32bit rtc test reg 2 */
73#define RTC_TEST3 0x30 /* 32bit rtc test reg 3 */ 71#define RTC_TEST3 0x30 /* 32bit rtc test reg 3 */
74 72
73enum imx_rtc_type {
74 IMX1_RTC,
75 IMX21_RTC,
76};
77
75struct rtc_plat_data { 78struct rtc_plat_data {
76 struct rtc_device *rtc; 79 struct rtc_device *rtc;
77 void __iomem *ioaddr; 80 void __iomem *ioaddr;
78 int irq; 81 int irq;
79 struct clk *clk; 82 struct clk *clk;
80 struct rtc_time g_rtc_alarm; 83 struct rtc_time g_rtc_alarm;
84 enum imx_rtc_type devtype;
81}; 85};
82 86
87static struct platform_device_id imx_rtc_devtype[] = {
88 {
89 .name = "imx1-rtc",
90 .driver_data = IMX1_RTC,
91 }, {
92 .name = "imx21-rtc",
93 .driver_data = IMX21_RTC,
94 }, {
95 /* sentinel */
96 }
97};
98MODULE_DEVICE_TABLE(platform, imx_rtc_devtype);
99
100static inline int is_imx1_rtc(struct rtc_plat_data *data)
101{
102 return data->devtype == IMX1_RTC;
103}
104
83/* 105/*
84 * This function is used to obtain the RTC time or the alarm value in 106 * This function is used to obtain the RTC time or the alarm value in
85 * second. 107 * second.
@@ -278,10 +300,13 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
278 */ 300 */
279static int mxc_rtc_set_mmss(struct device *dev, unsigned long time) 301static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
280{ 302{
303 struct platform_device *pdev = to_platform_device(dev);
304 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
305
281 /* 306 /*
282 * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only 307 * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only
283 */ 308 */
284 if (cpu_is_mx1()) { 309 if (is_imx1_rtc(pdata)) {
285 struct rtc_time tm; 310 struct rtc_time tm;
286 311
287 rtc_time_to_tm(time, &tm); 312 rtc_time_to_tm(time, &tm);
@@ -360,6 +385,8 @@ static int __devinit mxc_rtc_probe(struct platform_device *pdev)
360 if (!pdata) 385 if (!pdata)
361 return -ENOMEM; 386 return -ENOMEM;
362 387
388 pdata->devtype = pdev->id_entry->driver_data;
389
363 if (!devm_request_mem_region(&pdev->dev, res->start, 390 if (!devm_request_mem_region(&pdev->dev, res->start,
364 resource_size(res), pdev->name)) 391 resource_size(res), pdev->name))
365 return -EBUSY; 392 return -EBUSY;
@@ -480,6 +507,7 @@ static struct platform_driver mxc_rtc_driver = {
480#endif 507#endif
481 .owner = THIS_MODULE, 508 .owner = THIS_MODULE,
482 }, 509 },
510 .id_table = imx_rtc_devtype,
483 .probe = mxc_rtc_probe, 511 .probe = mxc_rtc_probe,
484 .remove = __devexit_p(mxc_rtc_remove), 512 .remove = __devexit_p(mxc_rtc_remove),
485}; 513};