diff options
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/rtc/Makefile | 1 | ||||
| -rw-r--r-- | drivers/rtc/interface.c | 2 | ||||
| -rw-r--r-- | drivers/rtc/rtc-88pm80x.c | 369 | ||||
| -rw-r--r-- | drivers/rtc/rtc-ab8500.c | 42 | ||||
| -rw-r--r-- | drivers/rtc/rtc-at91rm9200.c | 1 | ||||
| -rw-r--r-- | drivers/rtc/rtc-coh901331.c | 61 | ||||
| -rw-r--r-- | drivers/rtc/rtc-da9052.c | 5 | ||||
| -rw-r--r-- | drivers/rtc/rtc-max8925.c | 13 | ||||
| -rw-r--r-- | drivers/rtc/rtc-mc13xxx.c | 6 | ||||
| -rw-r--r-- | drivers/rtc/rtc-mv.c | 2 | ||||
| -rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 11 | ||||
| -rw-r--r-- | drivers/rtc/rtc-pl031.c | 95 | ||||
| -rw-r--r-- | drivers/rtc/rtc-r9701.c | 6 | ||||
| -rw-r--r-- | drivers/rtc/rtc-s3c.c | 4 | ||||
| -rw-r--r-- | drivers/rtc/rtc-stmp3xxx.c | 8 | ||||
| -rw-r--r-- | drivers/rtc/rtc-wm831x.c | 24 |
17 files changed, 555 insertions, 106 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 08cbdb900a18..fabc99a75c65 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
| @@ -135,6 +135,16 @@ config RTC_DRV_88PM860X | |||
| 135 | This driver can also be built as a module. If so, the module | 135 | This driver can also be built as a module. If so, the module |
| 136 | will be called rtc-88pm860x. | 136 | will be called rtc-88pm860x. |
| 137 | 137 | ||
| 138 | config RTC_DRV_88PM80X | ||
| 139 | tristate "Marvell 88PM80x" | ||
| 140 | depends on RTC_CLASS && I2C && MFD_88PM800 | ||
| 141 | help | ||
| 142 | If you say yes here you get support for RTC function in Marvell | ||
| 143 | 88PM80x chips. | ||
| 144 | |||
| 145 | This driver can also be built as a module. If so, the module | ||
| 146 | will be called rtc-88pm80x. | ||
| 147 | |||
| 138 | config RTC_DRV_DS1307 | 148 | config RTC_DRV_DS1307 |
| 139 | tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025" | 149 | tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025" |
| 140 | help | 150 | help |
| @@ -694,6 +704,7 @@ config RTC_DRV_AB3100 | |||
| 694 | config RTC_DRV_AB8500 | 704 | config RTC_DRV_AB8500 |
| 695 | tristate "ST-Ericsson AB8500 RTC" | 705 | tristate "ST-Ericsson AB8500 RTC" |
| 696 | depends on AB8500_CORE | 706 | depends on AB8500_CORE |
| 707 | select RTC_INTF_DEV_UIE_EMUL | ||
| 697 | help | 708 | help |
| 698 | Select this to enable the ST-Ericsson AB8500 power management IC RTC | 709 | Select this to enable the ST-Ericsson AB8500 power management IC RTC |
| 699 | support. This chip contains a battery- and capacitor-backed RTC. | 710 | support. This chip contains a battery- and capacitor-backed RTC. |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 2973921c30d8..0d5b2b66f90d 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
| @@ -16,6 +16,7 @@ rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o | |||
| 16 | # Keep the list ordered. | 16 | # Keep the list ordered. |
| 17 | 17 | ||
| 18 | obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o | 18 | obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o |
| 19 | obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o | ||
| 19 | obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o | 20 | obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o |
| 20 | obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o | 21 | obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o |
| 21 | obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o | 22 | obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index eb415bd76494..9592b936b71b 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
| @@ -582,6 +582,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer) | |||
| 582 | void rtc_update_irq(struct rtc_device *rtc, | 582 | void rtc_update_irq(struct rtc_device *rtc, |
| 583 | unsigned long num, unsigned long events) | 583 | unsigned long num, unsigned long events) |
| 584 | { | 584 | { |
| 585 | pm_stay_awake(rtc->dev.parent); | ||
| 585 | schedule_work(&rtc->irqwork); | 586 | schedule_work(&rtc->irqwork); |
| 586 | } | 587 | } |
| 587 | EXPORT_SYMBOL_GPL(rtc_update_irq); | 588 | EXPORT_SYMBOL_GPL(rtc_update_irq); |
| @@ -844,6 +845,7 @@ void rtc_timer_do_work(struct work_struct *work) | |||
| 844 | 845 | ||
| 845 | mutex_lock(&rtc->ops_lock); | 846 | mutex_lock(&rtc->ops_lock); |
| 846 | again: | 847 | again: |
| 848 | pm_relax(rtc->dev.parent); | ||
| 847 | __rtc_read_time(rtc, &tm); | 849 | __rtc_read_time(rtc, &tm); |
| 848 | now = rtc_tm_to_ktime(tm); | 850 | now = rtc_tm_to_ktime(tm); |
| 849 | while ((next = timerqueue_getnext(&rtc->timerqueue))) { | 851 | while ((next = timerqueue_getnext(&rtc->timerqueue))) { |
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c new file mode 100644 index 000000000000..6367984e0565 --- /dev/null +++ b/drivers/rtc/rtc-88pm80x.c | |||
| @@ -0,0 +1,369 @@ | |||
| 1 | /* | ||
| 2 | * Real Time Clock driver for Marvell 88PM80x PMIC | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Marvell International Ltd. | ||
| 5 | * Wenzeng Chen<wzch@marvell.com> | ||
| 6 | * Qiao Zhou <zhouqiao@marvell.com> | ||
| 7 | * | ||
| 8 | * This file is subject to the terms and conditions of the GNU General | ||
| 9 | * Public License. See the file "COPYING" in the main directory of this | ||
| 10 | * archive for more details. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/module.h> | ||
| 24 | #include <linux/slab.h> | ||
| 25 | #include <linux/regmap.h> | ||
| 26 | #include <linux/mfd/core.h> | ||
| 27 | #include <linux/mfd/88pm80x.h> | ||
| 28 | #include <linux/rtc.h> | ||
| 29 | |||
| 30 | #define PM800_RTC_COUNTER1 (0xD1) | ||
| 31 | #define PM800_RTC_COUNTER2 (0xD2) | ||
| 32 | #define PM800_RTC_COUNTER3 (0xD3) | ||
| 33 | #define PM800_RTC_COUNTER4 (0xD4) | ||
| 34 | #define PM800_RTC_EXPIRE1_1 (0xD5) | ||
| 35 | #define PM800_RTC_EXPIRE1_2 (0xD6) | ||
| 36 | #define PM800_RTC_EXPIRE1_3 (0xD7) | ||
| 37 | #define PM800_RTC_EXPIRE1_4 (0xD8) | ||
| 38 | #define PM800_RTC_TRIM1 (0xD9) | ||
| 39 | #define PM800_RTC_TRIM2 (0xDA) | ||
| 40 | #define PM800_RTC_TRIM3 (0xDB) | ||
| 41 | #define PM800_RTC_TRIM4 (0xDC) | ||
| 42 | #define PM800_RTC_EXPIRE2_1 (0xDD) | ||
| 43 | #define PM800_RTC_EXPIRE2_2 (0xDE) | ||
| 44 | #define PM800_RTC_EXPIRE2_3 (0xDF) | ||
| 45 | #define PM800_RTC_EXPIRE2_4 (0xE0) | ||
| 46 | |||
| 47 | #define PM800_POWER_DOWN_LOG1 (0xE5) | ||
| 48 | #define PM800_POWER_DOWN_LOG2 (0xE6) | ||
| 49 | |||
| 50 | struct pm80x_rtc_info { | ||
| 51 | struct pm80x_chip *chip; | ||
| 52 | struct regmap *map; | ||
| 53 | struct rtc_device *rtc_dev; | ||
| 54 | struct device *dev; | ||
| 55 | struct delayed_work calib_work; | ||
| 56 | |||
| 57 | int irq; | ||
| 58 | int vrtc; | ||
| 59 | }; | ||
| 60 | |||
| 61 | static irqreturn_t rtc_update_handler(int irq, void *data) | ||
| 62 | { | ||
| 63 | struct pm80x_rtc_info *info = (struct pm80x_rtc_info *)data; | ||
| 64 | int mask; | ||
| 65 | |||
| 66 | mask = PM800_ALARM | PM800_ALARM_WAKEUP; | ||
| 67 | regmap_update_bits(info->map, PM800_RTC_CONTROL, mask | PM800_ALARM1_EN, | ||
| 68 | mask); | ||
| 69 | rtc_update_irq(info->rtc_dev, 1, RTC_AF); | ||
| 70 | return IRQ_HANDLED; | ||
| 71 | } | ||
| 72 | |||
| 73 | static int pm80x_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
| 74 | { | ||
| 75 | struct pm80x_rtc_info *info = dev_get_drvdata(dev); | ||
| 76 | |||
| 77 | if (enabled) | ||
| 78 | regmap_update_bits(info->map, PM800_RTC_CONTROL, | ||
| 79 | PM800_ALARM1_EN, PM800_ALARM1_EN); | ||
| 80 | else | ||
| 81 | regmap_update_bits(info->map, PM800_RTC_CONTROL, | ||
| 82 | PM800_ALARM1_EN, 0); | ||
| 83 | return 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | /* | ||
| 87 | * Calculate the next alarm time given the requested alarm time mask | ||
| 88 | * and the current time. | ||
| 89 | */ | ||
| 90 | static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, | ||
| 91 | struct rtc_time *alrm) | ||
| 92 | { | ||
| 93 | unsigned long next_time; | ||
| 94 | unsigned long now_time; | ||
| 95 | |||
| 96 | next->tm_year = now->tm_year; | ||
| 97 | next->tm_mon = now->tm_mon; | ||
| 98 | next->tm_mday = now->tm_mday; | ||
| 99 | next->tm_hour = alrm->tm_hour; | ||
| 100 | next->tm_min = alrm->tm_min; | ||
| 101 | next->tm_sec = alrm->tm_sec; | ||
| 102 | |||
| 103 | rtc_tm_to_time(now, &now_time); | ||
| 104 | rtc_tm_to_time(next, &next_time); | ||
| 105 | |||
| 106 | if (next_time < now_time) { | ||
| 107 | /* Advance one day */ | ||
| 108 | next_time += 60 * 60 * 24; | ||
| 109 | rtc_time_to_tm(next_time, next); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | static int pm80x_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
| 114 | { | ||
| 115 | struct pm80x_rtc_info *info = dev_get_drvdata(dev); | ||
| 116 | unsigned char buf[4]; | ||
| 117 | unsigned long ticks, base, data; | ||
| 118 | regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4); | ||
| 119 | base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 120 | dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]); | ||
| 121 | |||
| 122 | /* load 32-bit read-only counter */ | ||
| 123 | regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4); | ||
| 124 | data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 125 | ticks = base + data; | ||
| 126 | dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", | ||
| 127 | base, data, ticks); | ||
| 128 | rtc_time_to_tm(ticks, tm); | ||
| 129 | return 0; | ||
| 130 | } | ||
| 131 | |||
| 132 | static int pm80x_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
| 133 | { | ||
| 134 | struct pm80x_rtc_info *info = dev_get_drvdata(dev); | ||
| 135 | unsigned char buf[4]; | ||
| 136 | unsigned long ticks, base, data; | ||
| 137 | if ((tm->tm_year < 70) || (tm->tm_year > 138)) { | ||
| 138 | dev_dbg(info->dev, | ||
| 139 | "Set time %d out of range. Please set time between 1970 to 2038.\n", | ||
| 140 | 1900 + tm->tm_year); | ||
| 141 | return -EINVAL; | ||
| 142 | } | ||
| 143 | rtc_tm_to_time(tm, &ticks); | ||
| 144 | |||
| 145 | /* load 32-bit read-only counter */ | ||
| 146 | regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4); | ||
| 147 | data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 148 | base = ticks - data; | ||
| 149 | dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", | ||
| 150 | base, data, ticks); | ||
| 151 | buf[0] = base & 0xFF; | ||
| 152 | buf[1] = (base >> 8) & 0xFF; | ||
| 153 | buf[2] = (base >> 16) & 0xFF; | ||
| 154 | buf[3] = (base >> 24) & 0xFF; | ||
| 155 | regmap_raw_write(info->map, PM800_RTC_EXPIRE2_1, buf, 4); | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | } | ||
| 159 | |||
| 160 | static int pm80x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
| 161 | { | ||
| 162 | struct pm80x_rtc_info *info = dev_get_drvdata(dev); | ||
| 163 | unsigned char buf[4]; | ||
| 164 | unsigned long ticks, base, data; | ||
| 165 | int ret; | ||
| 166 | |||
| 167 | regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4); | ||
| 168 | base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 169 | dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]); | ||
| 170 | |||
| 171 | regmap_raw_read(info->map, PM800_RTC_EXPIRE1_1, buf, 4); | ||
| 172 | data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 173 | ticks = base + data; | ||
| 174 | dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", | ||
| 175 | base, data, ticks); | ||
| 176 | |||
| 177 | rtc_time_to_tm(ticks, &alrm->time); | ||
| 178 | regmap_read(info->map, PM800_RTC_CONTROL, &ret); | ||
| 179 | alrm->enabled = (ret & PM800_ALARM1_EN) ? 1 : 0; | ||
| 180 | alrm->pending = (ret & (PM800_ALARM | PM800_ALARM_WAKEUP)) ? 1 : 0; | ||
| 181 | return 0; | ||
| 182 | } | ||
| 183 | |||
| 184 | static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
| 185 | { | ||
| 186 | struct pm80x_rtc_info *info = dev_get_drvdata(dev); | ||
| 187 | struct rtc_time now_tm, alarm_tm; | ||
| 188 | unsigned long ticks, base, data; | ||
| 189 | unsigned char buf[4]; | ||
| 190 | int mask; | ||
| 191 | |||
| 192 | regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_ALARM1_EN, 0); | ||
| 193 | |||
| 194 | regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4); | ||
| 195 | base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 196 | dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]); | ||
| 197 | |||
| 198 | /* load 32-bit read-only counter */ | ||
| 199 | regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4); | ||
| 200 | data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
| 201 | ticks = base + data; | ||
| 202 | dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", | ||
| 203 | base, data, ticks); | ||
| 204 | |||
| 205 | rtc_time_to_tm(ticks, &now_tm); | ||
| 206 | dev_dbg(info->dev, "%s, now time : %lu\n", __func__, ticks); | ||
| 207 | rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time); | ||
| 208 | /* get new ticks for alarm in 24 hours */ | ||
| 209 | rtc_tm_to_time(&alarm_tm, &ticks); | ||
| 210 | dev_dbg(info->dev, "%s, alarm time: %lu\n", __func__, ticks); | ||
| 211 | data = ticks - base; | ||
| 212 | |||
| 213 | buf[0] = data & 0xff; | ||
| 214 | buf[1] = (data >> 8) & 0xff; | ||
| 215 | buf[2] = (data >> 16) & 0xff; | ||
| 216 | buf[3] = (data >> 24) & 0xff; | ||
| 217 | regmap_raw_write(info->map, PM800_RTC_EXPIRE1_1, buf, 4); | ||
| 218 | if (alrm->enabled) { | ||
| 219 | mask = PM800_ALARM | PM800_ALARM_WAKEUP | PM800_ALARM1_EN; | ||
| 220 | regmap_update_bits(info->map, PM800_RTC_CONTROL, mask, mask); | ||
| 221 | } else { | ||
| 222 | mask = PM800_ALARM | PM800_ALARM_WAKEUP | PM800_ALARM1_EN; | ||
| 223 | regmap_update_bits(info->map, PM800_RTC_CONTROL, mask, | ||
| 224 | PM800_ALARM | PM800_ALARM_WAKEUP); | ||
| 225 | } | ||
| 226 | return 0; | ||
| 227 | } | ||
| 228 | |||
| 229 | static const struct rtc_class_ops pm80x_rtc_ops = { | ||
| 230 | .read_time = pm80x_rtc_read_time, | ||
| 231 | .set_time = pm80x_rtc_set_time, | ||
| 232 | .read_alarm = pm80x_rtc_read_alarm, | ||
| 233 | .set_alarm = pm80x_rtc_set_alarm, | ||
| 234 | .alarm_irq_enable = pm80x_rtc_alarm_irq_enable, | ||
| 235 | }; | ||
| 236 | |||
| 237 | #ifdef CONFIG_PM | ||
| 238 | static int pm80x_rtc_suspend(struct device *dev) | ||
| 239 | { | ||
| 240 | return pm80x_dev_suspend(dev); | ||
| 241 | } | ||
| 242 | |||
| 243 | static int pm80x_rtc_resume(struct device *dev) | ||
| 244 | { | ||
| 245 | return pm80x_dev_resume(dev); | ||
| 246 | } | ||
| 247 | #endif | ||
| 248 | |||
| 249 | static SIMPLE_DEV_PM_OPS(pm80x_rtc_pm_ops, pm80x_rtc_suspend, pm80x_rtc_resume); | ||
| 250 | |||
| 251 | static int __devinit pm80x_rtc_probe(struct platform_device *pdev) | ||
| 252 | { | ||
| 253 | struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); | ||
| 254 | struct pm80x_platform_data *pm80x_pdata; | ||
| 255 | struct pm80x_rtc_pdata *pdata = NULL; | ||
| 256 | struct pm80x_rtc_info *info; | ||
| 257 | struct rtc_time tm; | ||
| 258 | unsigned long ticks = 0; | ||
| 259 | int ret; | ||
| 260 | |||
| 261 | pdata = pdev->dev.platform_data; | ||
| 262 | if (pdata == NULL) | ||
| 263 | dev_warn(&pdev->dev, "No platform data!\n"); | ||
| 264 | |||
| 265 | info = | ||
| 266 | devm_kzalloc(&pdev->dev, sizeof(struct pm80x_rtc_info), GFP_KERNEL); | ||
| 267 | if (!info) | ||
| 268 | return -ENOMEM; | ||
| 269 | info->irq = platform_get_irq(pdev, 0); | ||
| 270 | if (info->irq < 0) { | ||
| 271 | dev_err(&pdev->dev, "No IRQ resource!\n"); | ||
| 272 | ret = -EINVAL; | ||
| 273 | goto out; | ||
| 274 | } | ||
| 275 | |||
| 276 | info->chip = chip; | ||
| 277 | info->map = chip->regmap; | ||
| 278 | if (!info->map) { | ||
| 279 | dev_err(&pdev->dev, "no regmap!\n"); | ||
| 280 | ret = -EINVAL; | ||
| 281 | goto out; | ||
| 282 | } | ||
| 283 | |||
| 284 | info->dev = &pdev->dev; | ||
| 285 | dev_set_drvdata(&pdev->dev, info); | ||
| 286 | |||
| 287 | ret = pm80x_request_irq(chip, info->irq, rtc_update_handler, | ||
| 288 | IRQF_ONESHOT, "rtc", info); | ||
| 289 | if (ret < 0) { | ||
| 290 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", | ||
| 291 | info->irq, ret); | ||
| 292 | goto out; | ||
| 293 | } | ||
| 294 | |||
| 295 | ret = pm80x_rtc_read_time(&pdev->dev, &tm); | ||
| 296 | if (ret < 0) { | ||
| 297 | dev_err(&pdev->dev, "Failed to read initial time.\n"); | ||
| 298 | goto out_rtc; | ||
| 299 | } | ||
| 300 | if ((tm.tm_year < 70) || (tm.tm_year > 138)) { | ||
| 301 | tm.tm_year = 70; | ||
| 302 | tm.tm_mon = 0; | ||
| 303 | tm.tm_mday = 1; | ||
| 304 | tm.tm_hour = 0; | ||
| 305 | tm.tm_min = 0; | ||
| 306 | tm.tm_sec = 0; | ||
| 307 | ret = pm80x_rtc_set_time(&pdev->dev, &tm); | ||
| 308 | if (ret < 0) { | ||
| 309 | dev_err(&pdev->dev, "Failed to set initial time.\n"); | ||
| 310 | goto out_rtc; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | rtc_tm_to_time(&tm, &ticks); | ||
| 314 | |||
| 315 | info->rtc_dev = rtc_device_register("88pm80x-rtc", &pdev->dev, | ||
| 316 | &pm80x_rtc_ops, THIS_MODULE); | ||
| 317 | if (IS_ERR(info->rtc_dev)) { | ||
| 318 | ret = PTR_ERR(info->rtc_dev); | ||
| 319 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); | ||
| 320 | goto out_rtc; | ||
| 321 | } | ||
| 322 | /* | ||
| 323 | * enable internal XO instead of internal 3.25MHz clock since it can | ||
| 324 | * free running in PMIC power-down state. | ||
| 325 | */ | ||
| 326 | regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_RTC1_USE_XO, | ||
| 327 | PM800_RTC1_USE_XO); | ||
| 328 | |||
| 329 | if (pdev->dev.parent->platform_data) { | ||
| 330 | pm80x_pdata = pdev->dev.parent->platform_data; | ||
| 331 | pdata = pm80x_pdata->rtc; | ||
| 332 | if (pdata) | ||
| 333 | info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup; | ||
| 334 | } | ||
| 335 | |||
| 336 | device_init_wakeup(&pdev->dev, 1); | ||
| 337 | |||
| 338 | return 0; | ||
| 339 | out_rtc: | ||
| 340 | pm80x_free_irq(chip, info->irq, info); | ||
| 341 | out: | ||
| 342 | return ret; | ||
| 343 | } | ||
| 344 | |||
| 345 | static int __devexit pm80x_rtc_remove(struct platform_device *pdev) | ||
| 346 | { | ||
| 347 | struct pm80x_rtc_info *info = platform_get_drvdata(pdev); | ||
| 348 | platform_set_drvdata(pdev, NULL); | ||
| 349 | rtc_device_unregister(info->rtc_dev); | ||
| 350 | pm80x_free_irq(info->chip, info->irq, info); | ||
| 351 | return 0; | ||
| 352 | } | ||
| 353 | |||
| 354 | static struct platform_driver pm80x_rtc_driver = { | ||
| 355 | .driver = { | ||
| 356 | .name = "88pm80x-rtc", | ||
| 357 | .owner = THIS_MODULE, | ||
| 358 | .pm = &pm80x_rtc_pm_ops, | ||
| 359 | }, | ||
| 360 | .probe = pm80x_rtc_probe, | ||
| 361 | .remove = __devexit_p(pm80x_rtc_remove), | ||
| 362 | }; | ||
| 363 | |||
| 364 | module_platform_driver(pm80x_rtc_driver); | ||
| 365 | |||
| 366 | MODULE_LICENSE("GPL"); | ||
| 367 | MODULE_DESCRIPTION("Marvell 88PM80x RTC driver"); | ||
| 368 | MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>"); | ||
| 369 | MODULE_ALIAS("platform:88pm80x-rtc"); | ||
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index 370889d0489b..bf3c2f669c3c 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c | |||
| @@ -89,22 +89,17 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
| 89 | if (retval < 0) | 89 | if (retval < 0) |
| 90 | return retval; | 90 | return retval; |
| 91 | 91 | ||
| 92 | /* Early AB8500 chips will not clear the rtc read request bit */ | 92 | /* Wait for some cycles after enabling the rtc read in ab8500 */ |
| 93 | if (abx500_get_chip_id(dev) == 0) { | 93 | while (time_before(jiffies, timeout)) { |
| 94 | usleep_range(1000, 1000); | 94 | retval = abx500_get_register_interruptible(dev, |
| 95 | } else { | 95 | AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value); |
| 96 | /* Wait for some cycles after enabling the rtc read in ab8500 */ | 96 | if (retval < 0) |
| 97 | while (time_before(jiffies, timeout)) { | 97 | return retval; |
| 98 | retval = abx500_get_register_interruptible(dev, | 98 | |
| 99 | AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value); | 99 | if (!(value & RTC_READ_REQUEST)) |
| 100 | if (retval < 0) | 100 | break; |
| 101 | return retval; | 101 | |
| 102 | 102 | usleep_range(1000, 5000); | |
| 103 | if (!(value & RTC_READ_REQUEST)) | ||
| 104 | break; | ||
| 105 | |||
| 106 | usleep_range(1000, 5000); | ||
| 107 | } | ||
| 108 | } | 103 | } |
| 109 | 104 | ||
| 110 | /* Read the Watchtime registers */ | 105 | /* Read the Watchtime registers */ |
| @@ -225,7 +220,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
| 225 | { | 220 | { |
| 226 | int retval, i; | 221 | int retval, i; |
| 227 | unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; | 222 | unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; |
| 228 | unsigned long mins, secs = 0; | 223 | unsigned long mins, secs = 0, cursec = 0; |
| 224 | struct rtc_time curtm; | ||
| 229 | 225 | ||
| 230 | if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { | 226 | if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { |
| 231 | dev_dbg(dev, "year should be equal to or greater than %d\n", | 227 | dev_dbg(dev, "year should be equal to or greater than %d\n", |
| @@ -237,6 +233,18 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
| 237 | rtc_tm_to_time(&alarm->time, &secs); | 233 | rtc_tm_to_time(&alarm->time, &secs); |
| 238 | 234 | ||
| 239 | /* | 235 | /* |
| 236 | * Check whether alarm is set less than 1min. | ||
| 237 | * Since our RTC doesn't support alarm resolution less than 1min, | ||
| 238 | * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON | ||
| 239 | */ | ||
| 240 | ab8500_rtc_read_time(dev, &curtm); /* Read current time */ | ||
| 241 | rtc_tm_to_time(&curtm, &cursec); | ||
| 242 | if ((secs - cursec) < 59) { | ||
| 243 | dev_dbg(dev, "Alarm less than 1 minute not supported\r\n"); | ||
| 244 | return -EINVAL; | ||
| 245 | } | ||
| 246 | |||
| 247 | /* | ||
| 240 | * Convert it to the number of seconds since 01-01-2000 00:00:00, since | 248 | * Convert it to the number of seconds since 01-01-2000 00:00:00, since |
| 241 | * we only have a small counter in the RTC. | 249 | * we only have a small counter in the RTC. |
| 242 | */ | 250 | */ |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index dc474bc6522d..fca9790c7de7 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/ioctl.h> | 28 | #include <linux/ioctl.h> |
| 29 | #include <linux/completion.h> | 29 | #include <linux/completion.h> |
| 30 | #include <linux/io.h> | ||
| 30 | 31 | ||
| 31 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
| 32 | 33 | ||
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index a5b8a0c4ea84..76b2156d3c62 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
| @@ -155,13 +155,10 @@ static int __exit coh901331_remove(struct platform_device *pdev) | |||
| 155 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 155 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); |
| 156 | 156 | ||
| 157 | if (rtap) { | 157 | if (rtap) { |
| 158 | free_irq(rtap->irq, rtap); | ||
| 159 | rtc_device_unregister(rtap->rtc); | 158 | rtc_device_unregister(rtap->rtc); |
| 159 | clk_unprepare(rtap->clk); | ||
| 160 | clk_put(rtap->clk); | 160 | clk_put(rtap->clk); |
| 161 | iounmap(rtap->virtbase); | ||
| 162 | release_mem_region(rtap->phybase, rtap->physize); | ||
| 163 | platform_set_drvdata(pdev, NULL); | 161 | platform_set_drvdata(pdev, NULL); |
| 164 | kfree(rtap); | ||
| 165 | } | 162 | } |
| 166 | 163 | ||
| 167 | return 0; | 164 | return 0; |
| @@ -174,49 +171,43 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
| 174 | struct coh901331_port *rtap; | 171 | struct coh901331_port *rtap; |
| 175 | struct resource *res; | 172 | struct resource *res; |
| 176 | 173 | ||
| 177 | rtap = kzalloc(sizeof(struct coh901331_port), GFP_KERNEL); | 174 | rtap = devm_kzalloc(&pdev->dev, |
| 175 | sizeof(struct coh901331_port), GFP_KERNEL); | ||
| 178 | if (!rtap) | 176 | if (!rtap) |
| 179 | return -ENOMEM; | 177 | return -ENOMEM; |
| 180 | 178 | ||
| 181 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 179 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 182 | if (!res) { | 180 | if (!res) |
| 183 | ret = -ENOENT; | 181 | return -ENOENT; |
| 184 | goto out_no_resource; | 182 | |
| 185 | } | ||
| 186 | rtap->phybase = res->start; | 183 | rtap->phybase = res->start; |
| 187 | rtap->physize = resource_size(res); | 184 | rtap->physize = resource_size(res); |
| 188 | 185 | ||
| 189 | if (request_mem_region(rtap->phybase, rtap->physize, | 186 | if (devm_request_mem_region(&pdev->dev, rtap->phybase, rtap->physize, |
| 190 | "rtc-coh901331") == NULL) { | 187 | "rtc-coh901331") == NULL) |
| 191 | ret = -EBUSY; | 188 | return -EBUSY; |
| 192 | goto out_no_memregion; | ||
| 193 | } | ||
| 194 | 189 | ||
| 195 | rtap->virtbase = ioremap(rtap->phybase, rtap->physize); | 190 | rtap->virtbase = devm_ioremap(&pdev->dev, rtap->phybase, rtap->physize); |
| 196 | if (!rtap->virtbase) { | 191 | if (!rtap->virtbase) |
| 197 | ret = -ENOMEM; | 192 | return -ENOMEM; |
| 198 | goto out_no_remap; | ||
| 199 | } | ||
| 200 | 193 | ||
| 201 | rtap->irq = platform_get_irq(pdev, 0); | 194 | rtap->irq = platform_get_irq(pdev, 0); |
| 202 | if (request_irq(rtap->irq, coh901331_interrupt, 0, | 195 | if (devm_request_irq(&pdev->dev, rtap->irq, coh901331_interrupt, 0, |
| 203 | "RTC COH 901 331 Alarm", rtap)) { | 196 | "RTC COH 901 331 Alarm", rtap)) |
| 204 | ret = -EIO; | 197 | return -EIO; |
| 205 | goto out_no_irq; | ||
| 206 | } | ||
| 207 | 198 | ||
| 208 | rtap->clk = clk_get(&pdev->dev, NULL); | 199 | rtap->clk = clk_get(&pdev->dev, NULL); |
| 209 | if (IS_ERR(rtap->clk)) { | 200 | if (IS_ERR(rtap->clk)) { |
| 210 | ret = PTR_ERR(rtap->clk); | 201 | ret = PTR_ERR(rtap->clk); |
| 211 | dev_err(&pdev->dev, "could not get clock\n"); | 202 | dev_err(&pdev->dev, "could not get clock\n"); |
| 212 | goto out_no_clk; | 203 | return ret; |
| 213 | } | 204 | } |
| 214 | 205 | ||
| 215 | /* We enable/disable the clock only to assure it works */ | 206 | /* We enable/disable the clock only to assure it works */ |
| 216 | ret = clk_enable(rtap->clk); | 207 | ret = clk_prepare_enable(rtap->clk); |
| 217 | if (ret) { | 208 | if (ret) { |
| 218 | dev_err(&pdev->dev, "could not enable clock\n"); | 209 | dev_err(&pdev->dev, "could not enable clock\n"); |
| 219 | goto out_no_clk_enable; | 210 | goto out_no_clk_prepenable; |
| 220 | } | 211 | } |
| 221 | clk_disable(rtap->clk); | 212 | clk_disable(rtap->clk); |
| 222 | 213 | ||
| @@ -232,18 +223,9 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
| 232 | 223 | ||
| 233 | out_no_rtc: | 224 | out_no_rtc: |
| 234 | platform_set_drvdata(pdev, NULL); | 225 | platform_set_drvdata(pdev, NULL); |
| 235 | out_no_clk_enable: | 226 | clk_unprepare(rtap->clk); |
| 227 | out_no_clk_prepenable: | ||
| 236 | clk_put(rtap->clk); | 228 | clk_put(rtap->clk); |
| 237 | out_no_clk: | ||
| 238 | free_irq(rtap->irq, rtap); | ||
| 239 | out_no_irq: | ||
| 240 | iounmap(rtap->virtbase); | ||
| 241 | out_no_remap: | ||
| 242 | platform_set_drvdata(pdev, NULL); | ||
| 243 | out_no_memregion: | ||
| 244 | release_mem_region(rtap->phybase, SZ_4K); | ||
| 245 | out_no_resource: | ||
| 246 | kfree(rtap); | ||
| 247 | return ret; | 229 | return ret; |
| 248 | } | 230 | } |
| 249 | 231 | ||
| @@ -265,6 +247,7 @@ static int coh901331_suspend(struct platform_device *pdev, pm_message_t state) | |||
| 265 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | 247 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); |
| 266 | clk_disable(rtap->clk); | 248 | clk_disable(rtap->clk); |
| 267 | } | 249 | } |
| 250 | clk_unprepare(rtap->clk); | ||
| 268 | return 0; | 251 | return 0; |
| 269 | } | 252 | } |
| 270 | 253 | ||
| @@ -272,6 +255,7 @@ static int coh901331_resume(struct platform_device *pdev) | |||
| 272 | { | 255 | { |
| 273 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 256 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); |
| 274 | 257 | ||
| 258 | clk_prepare(rtap->clk); | ||
| 275 | if (device_may_wakeup(&pdev->dev)) { | 259 | if (device_may_wakeup(&pdev->dev)) { |
| 276 | disable_irq_wake(rtap->irq); | 260 | disable_irq_wake(rtap->irq); |
| 277 | } else { | 261 | } else { |
| @@ -293,6 +277,7 @@ static void coh901331_shutdown(struct platform_device *pdev) | |||
| 293 | clk_enable(rtap->clk); | 277 | clk_enable(rtap->clk); |
| 294 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | 278 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); |
| 295 | clk_disable(rtap->clk); | 279 | clk_disable(rtap->clk); |
| 280 | clk_unprepare(rtap->clk); | ||
| 296 | } | 281 | } |
| 297 | 282 | ||
| 298 | static struct platform_driver coh901331_driver = { | 283 | static struct platform_driver coh901331_driver = { |
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c index da6ab5291a41..78070255bd3f 100644 --- a/drivers/rtc/rtc-da9052.c +++ b/drivers/rtc/rtc-da9052.c | |||
| @@ -245,7 +245,7 @@ static int __devinit da9052_rtc_probe(struct platform_device *pdev) | |||
| 245 | "ALM", rtc); | 245 | "ALM", rtc); |
| 246 | if (ret != 0) { | 246 | if (ret != 0) { |
| 247 | rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); | 247 | rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); |
| 248 | goto err_mem; | 248 | return ret; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 251 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, |
| @@ -259,8 +259,6 @@ static int __devinit da9052_rtc_probe(struct platform_device *pdev) | |||
| 259 | 259 | ||
| 260 | err_free_irq: | 260 | err_free_irq: |
| 261 | free_irq(rtc->irq, rtc); | 261 | free_irq(rtc->irq, rtc); |
| 262 | err_mem: | ||
| 263 | devm_kfree(&pdev->dev, rtc); | ||
| 264 | return ret; | 262 | return ret; |
| 265 | } | 263 | } |
| 266 | 264 | ||
| @@ -271,7 +269,6 @@ static int __devexit da9052_rtc_remove(struct platform_device *pdev) | |||
| 271 | rtc_device_unregister(rtc->rtc); | 269 | rtc_device_unregister(rtc->rtc); |
| 272 | free_irq(rtc->irq, rtc); | 270 | free_irq(rtc->irq, rtc); |
| 273 | platform_set_drvdata(pdev, NULL); | 271 | platform_set_drvdata(pdev, NULL); |
| 274 | devm_kfree(&pdev->dev, rtc); | ||
| 275 | 272 | ||
| 276 | return 0; | 273 | return 0; |
| 277 | } | 274 | } |
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 1459055a83aa..34e4349611db 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
| @@ -69,6 +69,7 @@ struct max8925_rtc_info { | |||
| 69 | struct max8925_chip *chip; | 69 | struct max8925_chip *chip; |
| 70 | struct i2c_client *rtc; | 70 | struct i2c_client *rtc; |
| 71 | struct device *dev; | 71 | struct device *dev; |
| 72 | int irq; | ||
| 72 | }; | 73 | }; |
| 73 | 74 | ||
| 74 | static irqreturn_t rtc_update_handler(int irq, void *data) | 75 | static irqreturn_t rtc_update_handler(int irq, void *data) |
| @@ -250,7 +251,7 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
| 250 | { | 251 | { |
| 251 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); | 252 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); |
| 252 | struct max8925_rtc_info *info; | 253 | struct max8925_rtc_info *info; |
| 253 | int irq, ret; | 254 | int ret; |
| 254 | 255 | ||
| 255 | info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL); | 256 | info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL); |
| 256 | if (!info) | 257 | if (!info) |
| @@ -258,13 +259,13 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
| 258 | info->chip = chip; | 259 | info->chip = chip; |
| 259 | info->rtc = chip->rtc; | 260 | info->rtc = chip->rtc; |
| 260 | info->dev = &pdev->dev; | 261 | info->dev = &pdev->dev; |
| 261 | irq = chip->irq_base + MAX8925_IRQ_RTC_ALARM0; | 262 | info->irq = platform_get_irq(pdev, 0); |
| 262 | 263 | ||
| 263 | ret = request_threaded_irq(irq, NULL, rtc_update_handler, | 264 | ret = request_threaded_irq(info->irq, NULL, rtc_update_handler, |
| 264 | IRQF_ONESHOT, "rtc-alarm0", info); | 265 | IRQF_ONESHOT, "rtc-alarm0", info); |
| 265 | if (ret < 0) { | 266 | if (ret < 0) { |
| 266 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", | 267 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", |
| 267 | irq, ret); | 268 | info->irq, ret); |
| 268 | goto out_irq; | 269 | goto out_irq; |
| 269 | } | 270 | } |
| 270 | 271 | ||
| @@ -285,7 +286,7 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
| 285 | return 0; | 286 | return 0; |
| 286 | out_rtc: | 287 | out_rtc: |
| 287 | platform_set_drvdata(pdev, NULL); | 288 | platform_set_drvdata(pdev, NULL); |
| 288 | free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); | 289 | free_irq(info->irq, info); |
| 289 | out_irq: | 290 | out_irq: |
| 290 | kfree(info); | 291 | kfree(info); |
| 291 | return ret; | 292 | return ret; |
| @@ -296,7 +297,7 @@ static int __devexit max8925_rtc_remove(struct platform_device *pdev) | |||
| 296 | struct max8925_rtc_info *info = platform_get_drvdata(pdev); | 297 | struct max8925_rtc_info *info = platform_get_drvdata(pdev); |
| 297 | 298 | ||
| 298 | if (info) { | 299 | if (info) { |
| 299 | free_irq(info->chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); | 300 | free_irq(info->irq, info); |
| 300 | rtc_device_unregister(info->rtc_dev); | 301 | rtc_device_unregister(info->rtc_dev); |
| 301 | kfree(info); | 302 | kfree(info); |
| 302 | } | 303 | } |
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index 546f6850bffb..2643d8874925 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
| @@ -404,9 +404,12 @@ static const struct platform_device_id mc13xxx_rtc_idtable[] = { | |||
| 404 | .name = "mc13783-rtc", | 404 | .name = "mc13783-rtc", |
| 405 | }, { | 405 | }, { |
| 406 | .name = "mc13892-rtc", | 406 | .name = "mc13892-rtc", |
| 407 | }, { | ||
| 408 | .name = "mc34708-rtc", | ||
| 407 | }, | 409 | }, |
| 408 | { } | 410 | { /* sentinel */ } |
| 409 | }; | 411 | }; |
| 412 | MODULE_DEVICE_TABLE(platform, mc13xxx_rtc_idtable); | ||
| 410 | 413 | ||
| 411 | static struct platform_driver mc13xxx_rtc_driver = { | 414 | static struct platform_driver mc13xxx_rtc_driver = { |
| 412 | .id_table = mc13xxx_rtc_idtable, | 415 | .id_table = mc13xxx_rtc_idtable, |
| @@ -432,4 +435,3 @@ module_exit(mc13xxx_rtc_exit); | |||
| 432 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | 435 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
| 433 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); | 436 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); |
| 434 | MODULE_LICENSE("GPL v2"); | 437 | MODULE_LICENSE("GPL v2"); |
| 435 | MODULE_ALIAS("platform:" DRIVER_NAME); | ||
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index b2185f4255aa..ebc1649d45d6 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
| @@ -297,7 +297,7 @@ static int __exit mv_rtc_remove(struct platform_device *pdev) | |||
| 297 | 297 | ||
| 298 | #ifdef CONFIG_OF | 298 | #ifdef CONFIG_OF |
| 299 | static struct of_device_id rtc_mv_of_match_table[] = { | 299 | static struct of_device_id rtc_mv_of_match_table[] = { |
| 300 | { .compatible = "mrvl,orion-rtc", }, | 300 | { .compatible = "marvell,orion-rtc", }, |
| 301 | {} | 301 | {} |
| 302 | }; | 302 | }; |
| 303 | #endif | 303 | #endif |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 97a3284bb7c6..c2fe426a6ef2 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.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/module.h> | 21 | #include <linux/module.h> |
| 22 | #include <linux/of.h> | ||
| 22 | 23 | ||
| 23 | #define DRV_VERSION "0.4.3" | 24 | #define DRV_VERSION "0.4.3" |
| 24 | 25 | ||
| @@ -285,9 +286,19 @@ static const struct i2c_device_id pcf8563_id[] = { | |||
| 285 | }; | 286 | }; |
| 286 | MODULE_DEVICE_TABLE(i2c, pcf8563_id); | 287 | MODULE_DEVICE_TABLE(i2c, pcf8563_id); |
| 287 | 288 | ||
| 289 | #ifdef CONFIG_OF | ||
| 290 | static const struct of_device_id pcf8563_of_match[] __devinitconst = { | ||
| 291 | { .compatible = "nxp,pcf8563" }, | ||
| 292 | {} | ||
| 293 | }; | ||
| 294 | MODULE_DEVICE_TABLE(of, pcf8563_of_match); | ||
| 295 | #endif | ||
| 296 | |||
| 288 | static struct i2c_driver pcf8563_driver = { | 297 | static struct i2c_driver pcf8563_driver = { |
| 289 | .driver = { | 298 | .driver = { |
| 290 | .name = "rtc-pcf8563", | 299 | .name = "rtc-pcf8563", |
| 300 | .owner = THIS_MODULE, | ||
| 301 | .of_match_table = of_match_ptr(pcf8563_of_match), | ||
| 291 | }, | 302 | }, |
| 292 | .probe = pcf8563_probe, | 303 | .probe = pcf8563_probe, |
| 293 | .remove = pcf8563_remove, | 304 | .remove = pcf8563_remove, |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index cc0533994f6e..08378e3cc21c 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
| @@ -68,11 +68,26 @@ | |||
| 68 | 68 | ||
| 69 | #define RTC_TIMER_FREQ 32768 | 69 | #define RTC_TIMER_FREQ 32768 |
| 70 | 70 | ||
| 71 | /** | ||
| 72 | * struct pl031_vendor_data - per-vendor variations | ||
| 73 | * @ops: the vendor-specific operations used on this silicon version | ||
| 74 | * @clockwatch: if this is an ST Microelectronics silicon version with a | ||
| 75 | * clockwatch function | ||
| 76 | * @st_weekday: if this is an ST Microelectronics silicon version that need | ||
| 77 | * the weekday fix | ||
| 78 | * @irqflags: special IRQ flags per variant | ||
| 79 | */ | ||
| 80 | struct pl031_vendor_data { | ||
| 81 | struct rtc_class_ops ops; | ||
| 82 | bool clockwatch; | ||
| 83 | bool st_weekday; | ||
| 84 | unsigned long irqflags; | ||
| 85 | }; | ||
| 86 | |||
| 71 | struct pl031_local { | 87 | struct pl031_local { |
| 88 | struct pl031_vendor_data *vendor; | ||
| 72 | struct rtc_device *rtc; | 89 | struct rtc_device *rtc; |
| 73 | void __iomem *base; | 90 | void __iomem *base; |
| 74 | u8 hw_designer; | ||
| 75 | u8 hw_revision:4; | ||
| 76 | }; | 91 | }; |
| 77 | 92 | ||
| 78 | static int pl031_alarm_irq_enable(struct device *dev, | 93 | static int pl031_alarm_irq_enable(struct device *dev, |
| @@ -303,7 +318,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 303 | { | 318 | { |
| 304 | int ret; | 319 | int ret; |
| 305 | struct pl031_local *ldata; | 320 | struct pl031_local *ldata; |
| 306 | struct rtc_class_ops *ops = id->data; | 321 | struct pl031_vendor_data *vendor = id->data; |
| 322 | struct rtc_class_ops *ops = &vendor->ops; | ||
| 307 | unsigned long time; | 323 | unsigned long time; |
| 308 | 324 | ||
| 309 | ret = amba_request_regions(adev, NULL); | 325 | ret = amba_request_regions(adev, NULL); |
| @@ -315,6 +331,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 315 | ret = -ENOMEM; | 331 | ret = -ENOMEM; |
| 316 | goto out; | 332 | goto out; |
| 317 | } | 333 | } |
| 334 | ldata->vendor = vendor; | ||
| 318 | 335 | ||
| 319 | ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); | 336 | ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); |
| 320 | 337 | ||
| @@ -325,14 +342,11 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 325 | 342 | ||
| 326 | amba_set_drvdata(adev, ldata); | 343 | amba_set_drvdata(adev, ldata); |
| 327 | 344 | ||
| 328 | ldata->hw_designer = amba_manf(adev); | 345 | dev_dbg(&adev->dev, "designer ID = 0x%02x\n", amba_manf(adev)); |
| 329 | ldata->hw_revision = amba_rev(adev); | 346 | dev_dbg(&adev->dev, "revision = 0x%01x\n", amba_rev(adev)); |
| 330 | |||
| 331 | dev_dbg(&adev->dev, "designer ID = 0x%02x\n", ldata->hw_designer); | ||
| 332 | dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision); | ||
| 333 | 347 | ||
| 334 | /* Enable the clockwatch on ST Variants */ | 348 | /* Enable the clockwatch on ST Variants */ |
| 335 | if (ldata->hw_designer == AMBA_VENDOR_ST) | 349 | if (vendor->clockwatch) |
| 336 | writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, | 350 | writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, |
| 337 | ldata->base + RTC_CR); | 351 | ldata->base + RTC_CR); |
| 338 | 352 | ||
| @@ -340,7 +354,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 340 | * On ST PL031 variants, the RTC reset value does not provide correct | 354 | * On ST PL031 variants, the RTC reset value does not provide correct |
| 341 | * weekday for 2000-01-01. Correct the erroneous sunday to saturday. | 355 | * weekday for 2000-01-01. Correct the erroneous sunday to saturday. |
| 342 | */ | 356 | */ |
| 343 | if (ldata->hw_designer == AMBA_VENDOR_ST) { | 357 | if (vendor->st_weekday) { |
| 344 | if (readl(ldata->base + RTC_YDR) == 0x2000) { | 358 | if (readl(ldata->base + RTC_YDR) == 0x2000) { |
| 345 | time = readl(ldata->base + RTC_DR); | 359 | time = readl(ldata->base + RTC_DR); |
| 346 | if ((time & | 360 | if ((time & |
| @@ -361,7 +375,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 361 | } | 375 | } |
| 362 | 376 | ||
| 363 | if (request_irq(adev->irq[0], pl031_interrupt, | 377 | if (request_irq(adev->irq[0], pl031_interrupt, |
| 364 | 0, "rtc-pl031", ldata)) { | 378 | vendor->irqflags, "rtc-pl031", ldata)) { |
| 365 | ret = -EIO; | 379 | ret = -EIO; |
| 366 | goto out_no_irq; | 380 | goto out_no_irq; |
| 367 | } | 381 | } |
| @@ -383,48 +397,65 @@ err_req: | |||
| 383 | } | 397 | } |
| 384 | 398 | ||
| 385 | /* Operations for the original ARM version */ | 399 | /* Operations for the original ARM version */ |
| 386 | static struct rtc_class_ops arm_pl031_ops = { | 400 | static struct pl031_vendor_data arm_pl031 = { |
| 387 | .read_time = pl031_read_time, | 401 | .ops = { |
| 388 | .set_time = pl031_set_time, | 402 | .read_time = pl031_read_time, |
| 389 | .read_alarm = pl031_read_alarm, | 403 | .set_time = pl031_set_time, |
| 390 | .set_alarm = pl031_set_alarm, | 404 | .read_alarm = pl031_read_alarm, |
| 391 | .alarm_irq_enable = pl031_alarm_irq_enable, | 405 | .set_alarm = pl031_set_alarm, |
| 406 | .alarm_irq_enable = pl031_alarm_irq_enable, | ||
| 407 | }, | ||
| 408 | .irqflags = IRQF_NO_SUSPEND, | ||
| 392 | }; | 409 | }; |
| 393 | 410 | ||
| 394 | /* The First ST derivative */ | 411 | /* The First ST derivative */ |
| 395 | static struct rtc_class_ops stv1_pl031_ops = { | 412 | static struct pl031_vendor_data stv1_pl031 = { |
| 396 | .read_time = pl031_read_time, | 413 | .ops = { |
| 397 | .set_time = pl031_set_time, | 414 | .read_time = pl031_read_time, |
| 398 | .read_alarm = pl031_read_alarm, | 415 | .set_time = pl031_set_time, |
| 399 | .set_alarm = pl031_set_alarm, | 416 | .read_alarm = pl031_read_alarm, |
| 400 | .alarm_irq_enable = pl031_alarm_irq_enable, | 417 | .set_alarm = pl031_set_alarm, |
| 418 | .alarm_irq_enable = pl031_alarm_irq_enable, | ||
| 419 | }, | ||
| 420 | .clockwatch = true, | ||
| 421 | .st_weekday = true, | ||
| 422 | .irqflags = IRQF_NO_SUSPEND, | ||
| 401 | }; | 423 | }; |
| 402 | 424 | ||
| 403 | /* And the second ST derivative */ | 425 | /* And the second ST derivative */ |
| 404 | static struct rtc_class_ops stv2_pl031_ops = { | 426 | static struct pl031_vendor_data stv2_pl031 = { |
| 405 | .read_time = pl031_stv2_read_time, | 427 | .ops = { |
| 406 | .set_time = pl031_stv2_set_time, | 428 | .read_time = pl031_stv2_read_time, |
| 407 | .read_alarm = pl031_stv2_read_alarm, | 429 | .set_time = pl031_stv2_set_time, |
| 408 | .set_alarm = pl031_stv2_set_alarm, | 430 | .read_alarm = pl031_stv2_read_alarm, |
| 409 | .alarm_irq_enable = pl031_alarm_irq_enable, | 431 | .set_alarm = pl031_stv2_set_alarm, |
| 432 | .alarm_irq_enable = pl031_alarm_irq_enable, | ||
| 433 | }, | ||
| 434 | .clockwatch = true, | ||
| 435 | .st_weekday = true, | ||
| 436 | /* | ||
| 437 | * This variant shares the IRQ with another block and must not | ||
| 438 | * suspend that IRQ line. | ||
| 439 | */ | ||
| 440 | .irqflags = IRQF_SHARED | IRQF_NO_SUSPEND, | ||
| 410 | }; | 441 | }; |
| 411 | 442 | ||
| 412 | static struct amba_id pl031_ids[] = { | 443 | static struct amba_id pl031_ids[] = { |
| 413 | { | 444 | { |
| 414 | .id = 0x00041031, | 445 | .id = 0x00041031, |
| 415 | .mask = 0x000fffff, | 446 | .mask = 0x000fffff, |
| 416 | .data = &arm_pl031_ops, | 447 | .data = &arm_pl031, |
| 417 | }, | 448 | }, |
| 418 | /* ST Micro variants */ | 449 | /* ST Micro variants */ |
| 419 | { | 450 | { |
| 420 | .id = 0x00180031, | 451 | .id = 0x00180031, |
| 421 | .mask = 0x00ffffff, | 452 | .mask = 0x00ffffff, |
| 422 | .data = &stv1_pl031_ops, | 453 | .data = &stv1_pl031, |
| 423 | }, | 454 | }, |
| 424 | { | 455 | { |
| 425 | .id = 0x00280031, | 456 | .id = 0x00280031, |
| 426 | .mask = 0x00ffffff, | 457 | .mask = 0x00ffffff, |
| 427 | .data = &stv2_pl031_ops, | 458 | .data = &stv2_pl031, |
| 428 | }, | 459 | }, |
| 429 | {0, 0}, | 460 | {0, 0}, |
| 430 | }; | 461 | }; |
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index 33b6ba0afa0d..2c183ebff715 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c | |||
| @@ -138,8 +138,7 @@ static int __devinit r9701_probe(struct spi_device *spi) | |||
| 138 | * contain invalid values. If so, try to write a default date: | 138 | * contain invalid values. If so, try to write a default date: |
| 139 | * 2000/1/1 00:00:00 | 139 | * 2000/1/1 00:00:00 |
| 140 | */ | 140 | */ |
| 141 | r9701_get_datetime(&spi->dev, &dt); | 141 | if (r9701_get_datetime(&spi->dev, &dt)) { |
| 142 | if (rtc_valid_tm(&dt)) { | ||
| 143 | dev_info(&spi->dev, "trying to repair invalid date/time\n"); | 142 | dev_info(&spi->dev, "trying to repair invalid date/time\n"); |
| 144 | dt.tm_sec = 0; | 143 | dt.tm_sec = 0; |
| 145 | dt.tm_min = 0; | 144 | dt.tm_min = 0; |
| @@ -148,7 +147,8 @@ static int __devinit r9701_probe(struct spi_device *spi) | |||
| 148 | dt.tm_mon = 0; | 147 | dt.tm_mon = 0; |
| 149 | dt.tm_year = 100; | 148 | dt.tm_year = 100; |
| 150 | 149 | ||
| 151 | if (r9701_set_datetime(&spi->dev, &dt)) { | 150 | if (r9701_set_datetime(&spi->dev, &dt) || |
| 151 | r9701_get_datetime(&spi->dev, &dt)) { | ||
| 152 | dev_err(&spi->dev, "cannot repair RTC register\n"); | 152 | dev_err(&spi->dev, "cannot repair RTC register\n"); |
| 153 | return -ENODEV; | 153 | return -ENODEV; |
| 154 | } | 154 | } |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 7e6af0b22f17..bfbd92c8d1c9 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
| @@ -26,10 +26,10 @@ | |||
| 26 | #include <linux/log2.h> | 26 | #include <linux/log2.h> |
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/of.h> | 28 | #include <linux/of.h> |
| 29 | #include <linux/uaccess.h> | ||
| 30 | #include <linux/io.h> | ||
| 29 | 31 | ||
| 30 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
| 31 | #include <asm/uaccess.h> | ||
| 32 | #include <asm/io.h> | ||
| 33 | #include <asm/irq.h> | 33 | #include <asm/irq.h> |
| 34 | #include <plat/regs-rtc.h> | 34 | #include <plat/regs-rtc.h> |
| 35 | 35 | ||
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 10287865e330..739ef55694f4 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/rtc.h> | 26 | #include <linux/rtc.h> |
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/of_device.h> | ||
| 28 | 29 | ||
| 29 | #include <mach/common.h> | 30 | #include <mach/common.h> |
| 30 | 31 | ||
| @@ -265,6 +266,12 @@ static int stmp3xxx_rtc_resume(struct platform_device *dev) | |||
| 265 | #define stmp3xxx_rtc_resume NULL | 266 | #define stmp3xxx_rtc_resume NULL |
| 266 | #endif | 267 | #endif |
| 267 | 268 | ||
| 269 | static const struct of_device_id rtc_dt_ids[] = { | ||
| 270 | { .compatible = "fsl,stmp3xxx-rtc", }, | ||
| 271 | { /* sentinel */ } | ||
| 272 | }; | ||
| 273 | MODULE_DEVICE_TABLE(of, rtc_dt_ids); | ||
| 274 | |||
| 268 | static struct platform_driver stmp3xxx_rtcdrv = { | 275 | static struct platform_driver stmp3xxx_rtcdrv = { |
| 269 | .probe = stmp3xxx_rtc_probe, | 276 | .probe = stmp3xxx_rtc_probe, |
| 270 | .remove = stmp3xxx_rtc_remove, | 277 | .remove = stmp3xxx_rtc_remove, |
| @@ -273,6 +280,7 @@ static struct platform_driver stmp3xxx_rtcdrv = { | |||
| 273 | .driver = { | 280 | .driver = { |
| 274 | .name = "stmp3xxx-rtc", | 281 | .name = "stmp3xxx-rtc", |
| 275 | .owner = THIS_MODULE, | 282 | .owner = THIS_MODULE, |
| 283 | .of_match_table = rtc_dt_ids, | ||
| 276 | }, | 284 | }, |
| 277 | }; | 285 | }; |
| 278 | 286 | ||
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index 59c6245e0421..ea5c6f857ca5 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #include <linux/mfd/wm831x/core.h> | 24 | #include <linux/mfd/wm831x/core.h> |
| 25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
| 26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
| 27 | 27 | #include <linux/random.h> | |
| 28 | 28 | ||
| 29 | /* | 29 | /* |
| 30 | * R16416 (0x4020) - RTC Write Counter | 30 | * R16416 (0x4020) - RTC Write Counter |
| @@ -96,6 +96,26 @@ struct wm831x_rtc { | |||
| 96 | unsigned int alarm_enabled:1; | 96 | unsigned int alarm_enabled:1; |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | static void wm831x_rtc_add_randomness(struct wm831x *wm831x) | ||
| 100 | { | ||
| 101 | int ret; | ||
| 102 | u16 reg; | ||
| 103 | |||
| 104 | /* | ||
| 105 | * The write counter contains a pseudo-random number which is | ||
| 106 | * regenerated every time we set the RTC so it should be a | ||
| 107 | * useful per-system source of entropy. | ||
| 108 | */ | ||
| 109 | ret = wm831x_reg_read(wm831x, WM831X_RTC_WRITE_COUNTER); | ||
| 110 | if (ret >= 0) { | ||
| 111 | reg = ret; | ||
| 112 | add_device_randomness(®, sizeof(reg)); | ||
| 113 | } else { | ||
| 114 | dev_warn(wm831x->dev, "Failed to read RTC write counter: %d\n", | ||
| 115 | ret); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 99 | /* | 119 | /* |
| 100 | * Read current time and date in RTC | 120 | * Read current time and date in RTC |
| 101 | */ | 121 | */ |
| @@ -431,6 +451,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev) | |||
| 431 | alm_irq, ret); | 451 | alm_irq, ret); |
| 432 | } | 452 | } |
| 433 | 453 | ||
| 454 | wm831x_rtc_add_randomness(wm831x); | ||
| 455 | |||
| 434 | return 0; | 456 | return 0; |
| 435 | 457 | ||
| 436 | err: | 458 | err: |
