diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 42 | ||||
-rw-r--r-- | drivers/rtc/Makefile | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 20 | ||||
-rw-r--r-- | drivers/rtc/rtc-ep93xx.c | 24 | ||||
-rw-r--r-- | drivers/rtc/rtc-lpc32xx.c | 12 | ||||
-rw-r--r-- | drivers/rtc/rtc-m41t93.c | 46 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 44 | ||||
-rw-r--r-- | drivers/rtc/rtc-pl031.c | 14 | ||||
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-spear.c | 10 | ||||
-rw-r--r-- | drivers/rtc/rtc-tegra.c | 50 |
11 files changed, 152 insertions, 114 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4161bfe462cd..08cbdb900a18 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -620,27 +620,6 @@ config RTC_DRV_MSM6242 | |||
620 | This driver can also be built as a module. If so, the module | 620 | This driver can also be built as a module. If so, the module |
621 | will be called rtc-msm6242. | 621 | will be called rtc-msm6242. |
622 | 622 | ||
623 | config RTC_DRV_IMXDI | ||
624 | tristate "Freescale IMX DryIce Real Time Clock" | ||
625 | depends on ARCH_MX25 | ||
626 | depends on RTC_CLASS | ||
627 | help | ||
628 | Support for Freescale IMX DryIce RTC | ||
629 | |||
630 | This driver can also be built as a module, if so, the module | ||
631 | will be called "rtc-imxdi". | ||
632 | |||
633 | config RTC_MXC | ||
634 | tristate "Freescale MXC Real Time Clock" | ||
635 | depends on ARCH_MXC | ||
636 | depends on RTC_CLASS | ||
637 | help | ||
638 | If you say yes here you get support for the Freescale MXC | ||
639 | RTC module. | ||
640 | |||
641 | This driver can also be built as a module, if so, the module | ||
642 | will be called "rtc-mxc". | ||
643 | |||
644 | config RTC_DRV_BQ4802 | 623 | config RTC_DRV_BQ4802 |
645 | tristate "TI BQ4802" | 624 | tristate "TI BQ4802" |
646 | help | 625 | help |
@@ -738,6 +717,16 @@ config RTC_DRV_DAVINCI | |||
738 | This driver can also be built as a module. If so, the module | 717 | This driver can also be built as a module. If so, the module |
739 | will be called rtc-davinci. | 718 | will be called rtc-davinci. |
740 | 719 | ||
720 | config RTC_DRV_IMXDI | ||
721 | tristate "Freescale IMX DryIce Real Time Clock" | ||
722 | depends on SOC_IMX25 | ||
723 | depends on RTC_CLASS | ||
724 | help | ||
725 | Support for Freescale IMX DryIce RTC | ||
726 | |||
727 | This driver can also be built as a module, if so, the module | ||
728 | will be called "rtc-imxdi". | ||
729 | |||
741 | config RTC_DRV_OMAP | 730 | config RTC_DRV_OMAP |
742 | tristate "TI OMAP1" | 731 | tristate "TI OMAP1" |
743 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX | 732 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX |
@@ -1087,4 +1076,15 @@ config RTC_DRV_LOONGSON1 | |||
1087 | This driver can also be built as a module. If so, the module | 1076 | This driver can also be built as a module. If so, the module |
1088 | will be called rtc-ls1x. | 1077 | will be called rtc-ls1x. |
1089 | 1078 | ||
1079 | config RTC_DRV_MXC | ||
1080 | tristate "Freescale MXC Real Time Clock" | ||
1081 | depends on ARCH_MXC | ||
1082 | depends on RTC_CLASS | ||
1083 | help | ||
1084 | If you say yes here you get support for the Freescale MXC | ||
1085 | RTC module. | ||
1086 | |||
1087 | This driver can also be built as a module, if so, the module | ||
1088 | will be called "rtc-mxc". | ||
1089 | |||
1090 | endif # RTC_CLASS | 1090 | endif # RTC_CLASS |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 727ae7786e6c..2973921c30d8 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -61,7 +61,7 @@ obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o | |||
61 | obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o | 61 | obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o |
62 | obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o | 62 | obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o |
63 | obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o | 63 | obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o |
64 | obj-$(CONFIG_RTC_MXC) += rtc-mxc.o | 64 | obj-$(CONFIG_RTC_DRV_MXC) += rtc-mxc.o |
65 | obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o | 65 | obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o |
66 | obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o | 66 | obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o |
67 | obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o | 67 | obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index c293d0cdb104..836710ce750e 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -17,8 +17,7 @@ | |||
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/bcd.h> | 19 | #include <linux/bcd.h> |
20 | 20 | #include <linux/rtc/ds1307.h> | |
21 | |||
22 | 21 | ||
23 | /* | 22 | /* |
24 | * We can't determine type by probing, but if we expect pre-Linux code | 23 | * We can't determine type by probing, but if we expect pre-Linux code |
@@ -92,7 +91,8 @@ enum ds_type { | |||
92 | # define DS1337_BIT_A2I 0x02 | 91 | # define DS1337_BIT_A2I 0x02 |
93 | # define DS1337_BIT_A1I 0x01 | 92 | # define DS1337_BIT_A1I 0x01 |
94 | #define DS1339_REG_ALARM1_SECS 0x07 | 93 | #define DS1339_REG_ALARM1_SECS 0x07 |
95 | #define DS1339_REG_TRICKLE 0x10 | 94 | |
95 | #define DS13XX_TRICKLE_CHARGER_MAGIC 0xa0 | ||
96 | 96 | ||
97 | #define RX8025_REG_CTRL1 0x0e | 97 | #define RX8025_REG_CTRL1 0x0e |
98 | # define RX8025_BIT_2412 0x20 | 98 | # define RX8025_BIT_2412 0x20 |
@@ -124,6 +124,7 @@ struct chip_desc { | |||
124 | unsigned alarm:1; | 124 | unsigned alarm:1; |
125 | u16 nvram_offset; | 125 | u16 nvram_offset; |
126 | u16 nvram_size; | 126 | u16 nvram_size; |
127 | u16 trickle_charger_reg; | ||
127 | }; | 128 | }; |
128 | 129 | ||
129 | static const struct chip_desc chips[last_ds_type] = { | 130 | static const struct chip_desc chips[last_ds_type] = { |
@@ -140,6 +141,13 @@ static const struct chip_desc chips[last_ds_type] = { | |||
140 | }, | 141 | }, |
141 | [ds_1339] = { | 142 | [ds_1339] = { |
142 | .alarm = 1, | 143 | .alarm = 1, |
144 | .trickle_charger_reg = 0x10, | ||
145 | }, | ||
146 | [ds_1340] = { | ||
147 | .trickle_charger_reg = 0x08, | ||
148 | }, | ||
149 | [ds_1388] = { | ||
150 | .trickle_charger_reg = 0x0a, | ||
143 | }, | 151 | }, |
144 | [ds_3231] = { | 152 | [ds_3231] = { |
145 | .alarm = 1, | 153 | .alarm = 1, |
@@ -619,6 +627,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
619 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 627 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
620 | int want_irq = false; | 628 | int want_irq = false; |
621 | unsigned char *buf; | 629 | unsigned char *buf; |
630 | struct ds1307_platform_data *pdata = client->dev.platform_data; | ||
622 | static const int bbsqi_bitpos[] = { | 631 | static const int bbsqi_bitpos[] = { |
623 | [ds_1337] = 0, | 632 | [ds_1337] = 0, |
624 | [ds_1339] = DS1339_BIT_BBSQI, | 633 | [ds_1339] = DS1339_BIT_BBSQI, |
@@ -637,7 +646,10 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
637 | 646 | ||
638 | ds1307->client = client; | 647 | ds1307->client = client; |
639 | ds1307->type = id->driver_data; | 648 | ds1307->type = id->driver_data; |
640 | ds1307->offset = 0; | 649 | |
650 | if (pdata && pdata->trickle_charger_setup && chip->trickle_charger_reg) | ||
651 | i2c_smbus_write_byte_data(client, chip->trickle_charger_reg, | ||
652 | DS13XX_TRICKLE_CHARGER_MAGIC | pdata->trickle_charger_setup); | ||
641 | 653 | ||
642 | buf = ds1307->regs; | 654 | buf = ds1307->regs; |
643 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { | 655 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { |
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 14a42a1edc66..9602278ff988 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -127,7 +127,7 @@ static const struct attribute_group ep93xx_rtc_sysfs_files = { | |||
127 | .attrs = ep93xx_rtc_attrs, | 127 | .attrs = ep93xx_rtc_attrs, |
128 | }; | 128 | }; |
129 | 129 | ||
130 | static int __init ep93xx_rtc_probe(struct platform_device *pdev) | 130 | static int __devinit ep93xx_rtc_probe(struct platform_device *pdev) |
131 | { | 131 | { |
132 | struct ep93xx_rtc *ep93xx_rtc; | 132 | struct ep93xx_rtc *ep93xx_rtc; |
133 | struct resource *res; | 133 | struct resource *res; |
@@ -174,7 +174,7 @@ exit: | |||
174 | return err; | 174 | return err; |
175 | } | 175 | } |
176 | 176 | ||
177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | 177 | static int __devexit ep93xx_rtc_remove(struct platform_device *pdev) |
178 | { | 178 | { |
179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); | 179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); |
180 | 180 | ||
@@ -186,31 +186,19 @@ static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | /* work with hotplug and coldplug */ | ||
190 | MODULE_ALIAS("platform:ep93xx-rtc"); | ||
191 | |||
192 | static struct platform_driver ep93xx_rtc_driver = { | 189 | static struct platform_driver ep93xx_rtc_driver = { |
193 | .driver = { | 190 | .driver = { |
194 | .name = "ep93xx-rtc", | 191 | .name = "ep93xx-rtc", |
195 | .owner = THIS_MODULE, | 192 | .owner = THIS_MODULE, |
196 | }, | 193 | }, |
197 | .remove = __exit_p(ep93xx_rtc_remove), | 194 | .probe = ep93xx_rtc_probe, |
195 | .remove = __devexit_p(ep93xx_rtc_remove), | ||
198 | }; | 196 | }; |
199 | 197 | ||
200 | static int __init ep93xx_rtc_init(void) | 198 | module_platform_driver(ep93xx_rtc_driver); |
201 | { | ||
202 | return platform_driver_probe(&ep93xx_rtc_driver, ep93xx_rtc_probe); | ||
203 | } | ||
204 | |||
205 | static void __exit ep93xx_rtc_exit(void) | ||
206 | { | ||
207 | platform_driver_unregister(&ep93xx_rtc_driver); | ||
208 | } | ||
209 | 199 | ||
210 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | 200 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); |
211 | MODULE_DESCRIPTION("EP93XX RTC driver"); | 201 | MODULE_DESCRIPTION("EP93XX RTC driver"); |
212 | MODULE_LICENSE("GPL"); | 202 | MODULE_LICENSE("GPL"); |
213 | MODULE_VERSION(DRV_VERSION); | 203 | MODULE_VERSION(DRV_VERSION); |
214 | 204 | MODULE_ALIAS("platform:ep93xx-rtc"); | |
215 | module_init(ep93xx_rtc_init); | ||
216 | module_exit(ep93xx_rtc_exit); | ||
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c index 63c72189c64b..d5218553741f 100644 --- a/drivers/rtc/rtc-lpc32xx.c +++ b/drivers/rtc/rtc-lpc32xx.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/of.h> | ||
22 | 23 | ||
23 | /* | 24 | /* |
24 | * Clock and Power control register offsets | 25 | * Clock and Power control register offsets |
@@ -386,13 +387,22 @@ static const struct dev_pm_ops lpc32xx_rtc_pm_ops = { | |||
386 | #define LPC32XX_RTC_PM_OPS NULL | 387 | #define LPC32XX_RTC_PM_OPS NULL |
387 | #endif | 388 | #endif |
388 | 389 | ||
390 | #ifdef CONFIG_OF | ||
391 | static const struct of_device_id lpc32xx_rtc_match[] = { | ||
392 | { .compatible = "nxp,lpc3220-rtc" }, | ||
393 | { } | ||
394 | }; | ||
395 | MODULE_DEVICE_TABLE(of, lpc32xx_rtc_match); | ||
396 | #endif | ||
397 | |||
389 | static struct platform_driver lpc32xx_rtc_driver = { | 398 | static struct platform_driver lpc32xx_rtc_driver = { |
390 | .probe = lpc32xx_rtc_probe, | 399 | .probe = lpc32xx_rtc_probe, |
391 | .remove = __devexit_p(lpc32xx_rtc_remove), | 400 | .remove = __devexit_p(lpc32xx_rtc_remove), |
392 | .driver = { | 401 | .driver = { |
393 | .name = RTC_NAME, | 402 | .name = RTC_NAME, |
394 | .owner = THIS_MODULE, | 403 | .owner = THIS_MODULE, |
395 | .pm = LPC32XX_RTC_PM_OPS | 404 | .pm = LPC32XX_RTC_PM_OPS, |
405 | .of_match_table = of_match_ptr(lpc32xx_rtc_match), | ||
396 | }, | 406 | }, |
397 | }; | 407 | }; |
398 | 408 | ||
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c index 10f1c29436ec..efab3d48cb15 100644 --- a/drivers/rtc/rtc-m41t93.c +++ b/drivers/rtc/rtc-m41t93.c | |||
@@ -48,6 +48,7 @@ static inline int m41t93_set_reg(struct spi_device *spi, u8 addr, u8 data) | |||
48 | static int m41t93_set_time(struct device *dev, struct rtc_time *tm) | 48 | static int m41t93_set_time(struct device *dev, struct rtc_time *tm) |
49 | { | 49 | { |
50 | struct spi_device *spi = to_spi_device(dev); | 50 | struct spi_device *spi = to_spi_device(dev); |
51 | int tmp; | ||
51 | u8 buf[9] = {0x80}; /* write cmd + 8 data bytes */ | 52 | u8 buf[9] = {0x80}; /* write cmd + 8 data bytes */ |
52 | u8 * const data = &buf[1]; /* ptr to first data byte */ | 53 | u8 * const data = &buf[1]; /* ptr to first data byte */ |
53 | 54 | ||
@@ -62,6 +63,30 @@ static int m41t93_set_time(struct device *dev, struct rtc_time *tm) | |||
62 | return -EINVAL; | 63 | return -EINVAL; |
63 | } | 64 | } |
64 | 65 | ||
66 | tmp = spi_w8r8(spi, M41T93_REG_FLAGS); | ||
67 | if (tmp < 0) | ||
68 | return tmp; | ||
69 | |||
70 | if (tmp & M41T93_FLAG_OF) { | ||
71 | dev_warn(&spi->dev, "OF bit is set, resetting.\n"); | ||
72 | m41t93_set_reg(spi, M41T93_REG_FLAGS, tmp & ~M41T93_FLAG_OF); | ||
73 | |||
74 | tmp = spi_w8r8(spi, M41T93_REG_FLAGS); | ||
75 | if (tmp < 0) { | ||
76 | return tmp; | ||
77 | } else if (tmp & M41T93_FLAG_OF) { | ||
78 | /* OF cannot be immediately reset: oscillator has to be | ||
79 | * restarted. */ | ||
80 | u8 reset_osc = buf[M41T93_REG_ST_SEC] | M41T93_FLAG_ST; | ||
81 | |||
82 | dev_warn(&spi->dev, | ||
83 | "OF bit is still set, kickstarting clock.\n"); | ||
84 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
85 | reset_osc &= ~M41T93_FLAG_ST; | ||
86 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
87 | } | ||
88 | } | ||
89 | |||
65 | data[M41T93_REG_SSEC] = 0; | 90 | data[M41T93_REG_SSEC] = 0; |
66 | data[M41T93_REG_ST_SEC] = bin2bcd(tm->tm_sec); | 91 | data[M41T93_REG_ST_SEC] = bin2bcd(tm->tm_sec); |
67 | data[M41T93_REG_MIN] = bin2bcd(tm->tm_min); | 92 | data[M41T93_REG_MIN] = bin2bcd(tm->tm_min); |
@@ -89,10 +114,7 @@ static int m41t93_get_time(struct device *dev, struct rtc_time *tm) | |||
89 | 1. halt bit (HT) is set: the clock is running but update of readout | 114 | 1. halt bit (HT) is set: the clock is running but update of readout |
90 | registers has been disabled due to power failure. This is normal | 115 | registers has been disabled due to power failure. This is normal |
91 | case after poweron. Time is valid after resetting HT bit. | 116 | case after poweron. Time is valid after resetting HT bit. |
92 | 2. oscillator fail bit (OF) is set. Oscillator has be stopped and | 117 | 2. oscillator fail bit (OF) is set: time is invalid. |
93 | time is invalid: | ||
94 | a) OF can be immeditely reset. | ||
95 | b) OF cannot be immediately reset: oscillator has to be restarted. | ||
96 | */ | 118 | */ |
97 | tmp = spi_w8r8(spi, M41T93_REG_ALM_HOUR_HT); | 119 | tmp = spi_w8r8(spi, M41T93_REG_ALM_HOUR_HT); |
98 | if (tmp < 0) | 120 | if (tmp < 0) |
@@ -110,21 +132,7 @@ static int m41t93_get_time(struct device *dev, struct rtc_time *tm) | |||
110 | 132 | ||
111 | if (tmp & M41T93_FLAG_OF) { | 133 | if (tmp & M41T93_FLAG_OF) { |
112 | ret = -EINVAL; | 134 | ret = -EINVAL; |
113 | dev_warn(&spi->dev, "OF bit is set, resetting.\n"); | 135 | dev_warn(&spi->dev, "OF bit is set, write time to restart.\n"); |
114 | m41t93_set_reg(spi, M41T93_REG_FLAGS, tmp & ~M41T93_FLAG_OF); | ||
115 | |||
116 | tmp = spi_w8r8(spi, M41T93_REG_FLAGS); | ||
117 | if (tmp < 0) | ||
118 | return tmp; | ||
119 | else if (tmp & M41T93_FLAG_OF) { | ||
120 | u8 reset_osc = buf[M41T93_REG_ST_SEC] | M41T93_FLAG_ST; | ||
121 | |||
122 | dev_warn(&spi->dev, | ||
123 | "OF bit is still set, kickstarting clock.\n"); | ||
124 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
125 | reset_osc &= ~M41T93_FLAG_ST; | ||
126 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
127 | } | ||
128 | } | 136 | } |
129 | 137 | ||
130 | if (tmp & M41T93_FLAG_BL) | 138 | if (tmp & M41T93_FLAG_BL) |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index bc0677de1996..97a3284bb7c6 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -64,6 +64,7 @@ struct pcf8563 { | |||
64 | * 1970...2069. | 64 | * 1970...2069. |
65 | */ | 65 | */ |
66 | int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */ | 66 | int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */ |
67 | int voltage_low; /* incicates if a low_voltage was detected */ | ||
67 | }; | 68 | }; |
68 | 69 | ||
69 | /* | 70 | /* |
@@ -86,9 +87,11 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
86 | return -EIO; | 87 | return -EIO; |
87 | } | 88 | } |
88 | 89 | ||
89 | if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) | 90 | if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) { |
91 | pcf8563->voltage_low = 1; | ||
90 | dev_info(&client->dev, | 92 | dev_info(&client->dev, |
91 | "low voltage detected, date/time is not reliable.\n"); | 93 | "low voltage detected, date/time is not reliable.\n"); |
94 | } | ||
92 | 95 | ||
93 | dev_dbg(&client->dev, | 96 | dev_dbg(&client->dev, |
94 | "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, " | 97 | "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, " |
@@ -173,6 +176,44 @@ static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
173 | return 0; | 176 | return 0; |
174 | } | 177 | } |
175 | 178 | ||
179 | #ifdef CONFIG_RTC_INTF_DEV | ||
180 | static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
181 | { | ||
182 | struct pcf8563 *pcf8563 = i2c_get_clientdata(to_i2c_client(dev)); | ||
183 | struct rtc_time tm; | ||
184 | |||
185 | switch (cmd) { | ||
186 | case RTC_VL_READ: | ||
187 | if (pcf8563->voltage_low) | ||
188 | dev_info(dev, "low voltage detected, date/time is not reliable.\n"); | ||
189 | |||
190 | if (copy_to_user((void __user *)arg, &pcf8563->voltage_low, | ||
191 | sizeof(int))) | ||
192 | return -EFAULT; | ||
193 | return 0; | ||
194 | case RTC_VL_CLR: | ||
195 | /* | ||
196 | * Clear the VL bit in the seconds register in case | ||
197 | * the time has not been set already (which would | ||
198 | * have cleared it). This does not really matter | ||
199 | * because of the cached voltage_low value but do it | ||
200 | * anyway for consistency. | ||
201 | */ | ||
202 | if (pcf8563_get_datetime(to_i2c_client(dev), &tm)) | ||
203 | pcf8563_set_datetime(to_i2c_client(dev), &tm); | ||
204 | |||
205 | /* Clear the cached value. */ | ||
206 | pcf8563->voltage_low = 0; | ||
207 | |||
208 | return 0; | ||
209 | default: | ||
210 | return -ENOIOCTLCMD; | ||
211 | } | ||
212 | } | ||
213 | #else | ||
214 | #define pcf8563_rtc_ioctl NULL | ||
215 | #endif | ||
216 | |||
176 | static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) | 217 | static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) |
177 | { | 218 | { |
178 | return pcf8563_get_datetime(to_i2c_client(dev), tm); | 219 | return pcf8563_get_datetime(to_i2c_client(dev), tm); |
@@ -184,6 +225,7 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
184 | } | 225 | } |
185 | 226 | ||
186 | static const struct rtc_class_ops pcf8563_rtc_ops = { | 227 | static const struct rtc_class_ops pcf8563_rtc_ops = { |
228 | .ioctl = pcf8563_rtc_ioctl, | ||
187 | .read_time = pcf8563_rtc_read_time, | 229 | .read_time = pcf8563_rtc_read_time, |
188 | .set_time = pcf8563_rtc_set_time, | 230 | .set_time = pcf8563_rtc_set_time, |
189 | }; | 231 | }; |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index f027c063fb20..cc0533994f6e 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -220,17 +220,9 @@ static irqreturn_t pl031_interrupt(int irq, void *dev_id) | |||
220 | unsigned long events = 0; | 220 | unsigned long events = 0; |
221 | 221 | ||
222 | rtcmis = readl(ldata->base + RTC_MIS); | 222 | rtcmis = readl(ldata->base + RTC_MIS); |
223 | if (rtcmis) { | 223 | if (rtcmis & RTC_BIT_AI) { |
224 | writel(rtcmis, ldata->base + RTC_ICR); | 224 | writel(RTC_BIT_AI, ldata->base + RTC_ICR); |
225 | 225 | events |= (RTC_AF | RTC_IRQF); | |
226 | if (rtcmis & RTC_BIT_AI) | ||
227 | events |= (RTC_AF | RTC_IRQF); | ||
228 | |||
229 | /* Timer interrupt is only available in ST variants */ | ||
230 | if ((rtcmis & RTC_BIT_PI) && | ||
231 | (ldata->hw_designer == AMBA_VENDOR_ST)) | ||
232 | events |= (RTC_PF | RTC_IRQF); | ||
233 | |||
234 | rtc_update_irq(ldata->rtc, 1, events); | 226 | rtc_update_irq(ldata->rtc, 1, events); |
235 | 227 | ||
236 | return IRQ_HANDLED; | 228 | return IRQ_HANDLED; |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 3f3a29752369..7e6af0b22f17 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -670,6 +670,7 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
670 | #define s3c_rtc_resume NULL | 670 | #define s3c_rtc_resume NULL |
671 | #endif | 671 | #endif |
672 | 672 | ||
673 | #ifdef CONFIG_OF | ||
673 | static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { | 674 | static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { |
674 | [TYPE_S3C2410] = { TYPE_S3C2410 }, | 675 | [TYPE_S3C2410] = { TYPE_S3C2410 }, |
675 | [TYPE_S3C2416] = { TYPE_S3C2416 }, | 676 | [TYPE_S3C2416] = { TYPE_S3C2416 }, |
@@ -677,7 +678,6 @@ static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { | |||
677 | [TYPE_S3C64XX] = { TYPE_S3C64XX }, | 678 | [TYPE_S3C64XX] = { TYPE_S3C64XX }, |
678 | }; | 679 | }; |
679 | 680 | ||
680 | #ifdef CONFIG_OF | ||
681 | static const struct of_device_id s3c_rtc_dt_match[] = { | 681 | static const struct of_device_id s3c_rtc_dt_match[] = { |
682 | { | 682 | { |
683 | .compatible = "samsung,s3c2410-rtc", | 683 | .compatible = "samsung,s3c2410-rtc", |
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index e38da0dc4187..1f76320e545b 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/of.h> | ||
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
20 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
@@ -519,6 +520,14 @@ static void spear_rtc_shutdown(struct platform_device *pdev) | |||
519 | clk_disable(config->clk); | 520 | clk_disable(config->clk); |
520 | } | 521 | } |
521 | 522 | ||
523 | #ifdef CONFIG_OF | ||
524 | static const struct of_device_id spear_rtc_id_table[] = { | ||
525 | { .compatible = "st,spear600-rtc" }, | ||
526 | {} | ||
527 | }; | ||
528 | MODULE_DEVICE_TABLE(of, spear_rtc_id_table); | ||
529 | #endif | ||
530 | |||
522 | static struct platform_driver spear_rtc_driver = { | 531 | static struct platform_driver spear_rtc_driver = { |
523 | .probe = spear_rtc_probe, | 532 | .probe = spear_rtc_probe, |
524 | .remove = __devexit_p(spear_rtc_remove), | 533 | .remove = __devexit_p(spear_rtc_remove), |
@@ -527,6 +536,7 @@ static struct platform_driver spear_rtc_driver = { | |||
527 | .shutdown = spear_rtc_shutdown, | 536 | .shutdown = spear_rtc_shutdown, |
528 | .driver = { | 537 | .driver = { |
529 | .name = "rtc-spear", | 538 | .name = "rtc-spear", |
539 | .of_match_table = of_match_ptr(spear_rtc_id_table), | ||
530 | }, | 540 | }, |
531 | }; | 541 | }; |
532 | 542 | ||
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c index 75259fe38602..c006025cecc8 100644 --- a/drivers/rtc/rtc-tegra.c +++ b/drivers/rtc/rtc-tegra.c | |||
@@ -309,7 +309,8 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
309 | struct resource *res; | 309 | struct resource *res; |
310 | int ret; | 310 | int ret; |
311 | 311 | ||
312 | info = kzalloc(sizeof(struct tegra_rtc_info), GFP_KERNEL); | 312 | info = devm_kzalloc(&pdev->dev, sizeof(struct tegra_rtc_info), |
313 | GFP_KERNEL); | ||
313 | if (!info) | 314 | if (!info) |
314 | return -ENOMEM; | 315 | return -ENOMEM; |
315 | 316 | ||
@@ -317,29 +318,18 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
317 | if (!res) { | 318 | if (!res) { |
318 | dev_err(&pdev->dev, | 319 | dev_err(&pdev->dev, |
319 | "Unable to allocate resources for device.\n"); | 320 | "Unable to allocate resources for device.\n"); |
320 | ret = -EBUSY; | 321 | return -EBUSY; |
321 | goto err_free_info; | ||
322 | } | 322 | } |
323 | 323 | ||
324 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { | 324 | info->rtc_base = devm_request_and_ioremap(&pdev->dev, res); |
325 | dev_err(&pdev->dev, | 325 | if (!info->rtc_base) { |
326 | "Unable to request mem region for device.\n"); | 326 | dev_err(&pdev->dev, "Unable to request mem region and grab IOs for device.\n"); |
327 | ret = -EBUSY; | 327 | return -EBUSY; |
328 | goto err_free_info; | ||
329 | } | 328 | } |
330 | 329 | ||
331 | info->tegra_rtc_irq = platform_get_irq(pdev, 0); | 330 | info->tegra_rtc_irq = platform_get_irq(pdev, 0); |
332 | if (info->tegra_rtc_irq <= 0) { | 331 | if (info->tegra_rtc_irq <= 0) |
333 | ret = -EBUSY; | 332 | return -EBUSY; |
334 | goto err_release_mem_region; | ||
335 | } | ||
336 | |||
337 | info->rtc_base = ioremap_nocache(res->start, resource_size(res)); | ||
338 | if (!info->rtc_base) { | ||
339 | dev_err(&pdev->dev, "Unable to grab IOs for device.\n"); | ||
340 | ret = -EBUSY; | ||
341 | goto err_release_mem_region; | ||
342 | } | ||
343 | 333 | ||
344 | /* set context info. */ | 334 | /* set context info. */ |
345 | info->pdev = pdev; | 335 | info->pdev = pdev; |
@@ -362,11 +352,12 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
362 | dev_err(&pdev->dev, | 352 | dev_err(&pdev->dev, |
363 | "Unable to register device (err=%d).\n", | 353 | "Unable to register device (err=%d).\n", |
364 | ret); | 354 | ret); |
365 | goto err_iounmap; | 355 | return ret; |
366 | } | 356 | } |
367 | 357 | ||
368 | ret = request_irq(info->tegra_rtc_irq, tegra_rtc_irq_handler, | 358 | ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, |
369 | IRQF_TRIGGER_HIGH, "rtc alarm", &pdev->dev); | 359 | tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, |
360 | "rtc alarm", &pdev->dev); | ||
370 | if (ret) { | 361 | if (ret) { |
371 | dev_err(&pdev->dev, | 362 | dev_err(&pdev->dev, |
372 | "Unable to request interrupt for device (err=%d).\n", | 363 | "Unable to request interrupt for device (err=%d).\n", |
@@ -380,12 +371,6 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
380 | 371 | ||
381 | err_dev_unreg: | 372 | err_dev_unreg: |
382 | rtc_device_unregister(info->rtc_dev); | 373 | rtc_device_unregister(info->rtc_dev); |
383 | err_iounmap: | ||
384 | iounmap(info->rtc_base); | ||
385 | err_release_mem_region: | ||
386 | release_mem_region(res->start, resource_size(res)); | ||
387 | err_free_info: | ||
388 | kfree(info); | ||
389 | 374 | ||
390 | return ret; | 375 | return ret; |
391 | } | 376 | } |
@@ -393,17 +378,8 @@ err_free_info: | |||
393 | static int __devexit tegra_rtc_remove(struct platform_device *pdev) | 378 | static int __devexit tegra_rtc_remove(struct platform_device *pdev) |
394 | { | 379 | { |
395 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | 380 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); |
396 | struct resource *res; | ||
397 | |||
398 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
399 | if (!res) | ||
400 | return -EBUSY; | ||
401 | 381 | ||
402 | free_irq(info->tegra_rtc_irq, &pdev->dev); | ||
403 | rtc_device_unregister(info->rtc_dev); | 382 | rtc_device_unregister(info->rtc_dev); |
404 | iounmap(info->rtc_base); | ||
405 | release_mem_region(res->start, resource_size(res)); | ||
406 | kfree(info); | ||
407 | 383 | ||
408 | platform_set_drvdata(pdev, NULL); | 384 | platform_set_drvdata(pdev, NULL); |
409 | 385 | ||