Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Real Time Clock driver for Freescale MC13XXX PMIC |
| 3 | * |
| 4 | * (C) 2009 Sascha Hauer, Pengutronix |
| 5 | * (C) 2009 Uwe Kleine-Koenig, Pengutronix |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/mfd/mc13xxx.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/slab.h> |
| 17 | #include <linux/rtc.h> |
| 18 | |
| 19 | #define DRIVER_NAME "mc13xxx-rtc" |
| 20 | |
| 21 | #define MC13XXX_RTCTOD 20 |
| 22 | #define MC13XXX_RTCTODA 21 |
| 23 | #define MC13XXX_RTCDAY 22 |
| 24 | #define MC13XXX_RTCDAYA 23 |
| 25 | |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 26 | #define SEC_PER_DAY (24 * 60 * 60) |
| 27 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 28 | struct mc13xxx_rtc { |
| 29 | struct rtc_device *rtc; |
| 30 | struct mc13xxx *mc13xxx; |
| 31 | int valid; |
| 32 | }; |
| 33 | |
| 34 | static int mc13xxx_rtc_irq_enable_unlocked(struct device *dev, |
| 35 | unsigned int enabled, int irq) |
| 36 | { |
| 37 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
| 38 | int (*func)(struct mc13xxx *mc13xxx, int irq); |
| 39 | |
| 40 | if (!priv->valid) |
| 41 | return -ENODATA; |
| 42 | |
| 43 | func = enabled ? mc13xxx_irq_unmask : mc13xxx_irq_mask; |
| 44 | return func(priv->mc13xxx, irq); |
| 45 | } |
| 46 | |
Alexander Shiyan | 2fb004a | 2014-04-03 14:49:58 -0700 | [diff] [blame] | 47 | static int mc13xxx_rtc_alarm_irq_enable(struct device *dev, |
| 48 | unsigned int enabled) |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 49 | { |
| 50 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
| 51 | int ret; |
| 52 | |
| 53 | mc13xxx_lock(priv->mc13xxx); |
| 54 | |
Alexander Shiyan | 2fb004a | 2014-04-03 14:49:58 -0700 | [diff] [blame] | 55 | ret = mc13xxx_rtc_irq_enable_unlocked(dev, enabled, MC13XXX_IRQ_TODA); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 56 | |
| 57 | mc13xxx_unlock(priv->mc13xxx); |
| 58 | |
| 59 | return ret; |
| 60 | } |
| 61 | |
| 62 | static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) |
| 63 | { |
| 64 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
| 65 | unsigned int seconds, days1, days2; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 66 | |
Alexander Shiyan | 12de362 | 2014-04-03 14:50:00 -0700 | [diff] [blame] | 67 | if (!priv->valid) |
| 68 | return -ENODATA; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 69 | |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 70 | do { |
| 71 | int ret; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 72 | |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 73 | ret = mc13xxx_reg_read(priv->mc13xxx, MC13XXX_RTCDAY, &days1); |
| 74 | if (ret) |
| 75 | return ret; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 76 | |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 77 | ret = mc13xxx_reg_read(priv->mc13xxx, MC13XXX_RTCTOD, &seconds); |
| 78 | if (ret) |
| 79 | return ret; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 80 | |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 81 | ret = mc13xxx_reg_read(priv->mc13xxx, MC13XXX_RTCDAY, &days2); |
| 82 | if (ret) |
| 83 | return ret; |
| 84 | } while (days1 != days2); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 85 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 86 | rtc_time64_to_tm((time64_t)days1 * SEC_PER_DAY + seconds, tm); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 87 | |
| 88 | return rtc_valid_tm(tm); |
| 89 | } |
| 90 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 91 | static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs) |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 92 | { |
| 93 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
| 94 | unsigned int seconds, days; |
| 95 | unsigned int alarmseconds; |
| 96 | int ret; |
| 97 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 98 | days = div_s64_rem(secs, SEC_PER_DAY, &seconds); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 99 | |
| 100 | mc13xxx_lock(priv->mc13xxx); |
| 101 | |
| 102 | /* |
| 103 | * temporarily invalidate alarm to prevent triggering it when the day is |
| 104 | * already updated while the time isn't yet. |
| 105 | */ |
| 106 | ret = mc13xxx_reg_read(priv->mc13xxx, MC13XXX_RTCTODA, &alarmseconds); |
| 107 | if (unlikely(ret)) |
| 108 | goto out; |
| 109 | |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 110 | if (alarmseconds < SEC_PER_DAY) { |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 111 | ret = mc13xxx_reg_write(priv->mc13xxx, |
| 112 | MC13XXX_RTCTODA, 0x1ffff); |
| 113 | if (unlikely(ret)) |
| 114 | goto out; |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | * write seconds=0 to prevent a day switch between writing days |
| 119 | * and seconds below |
| 120 | */ |
| 121 | ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCTOD, 0); |
| 122 | if (unlikely(ret)) |
| 123 | goto out; |
| 124 | |
| 125 | ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCDAY, days); |
| 126 | if (unlikely(ret)) |
| 127 | goto out; |
| 128 | |
| 129 | ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCTOD, seconds); |
| 130 | if (unlikely(ret)) |
| 131 | goto out; |
| 132 | |
| 133 | /* restore alarm */ |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 134 | if (alarmseconds < SEC_PER_DAY) { |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 135 | ret = mc13xxx_reg_write(priv->mc13xxx, |
| 136 | MC13XXX_RTCTODA, alarmseconds); |
| 137 | if (unlikely(ret)) |
| 138 | goto out; |
| 139 | } |
| 140 | |
Alexander Shiyan | 12de362 | 2014-04-03 14:50:00 -0700 | [diff] [blame] | 141 | if (!priv->valid) { |
| 142 | ret = mc13xxx_irq_ack(priv->mc13xxx, MC13XXX_IRQ_RTCRST); |
| 143 | if (unlikely(ret)) |
| 144 | goto out; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 145 | |
Alexander Shiyan | 12de362 | 2014-04-03 14:50:00 -0700 | [diff] [blame] | 146 | ret = mc13xxx_irq_unmask(priv->mc13xxx, MC13XXX_IRQ_RTCRST); |
| 147 | } |
| 148 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 149 | out: |
| 150 | priv->valid = !ret; |
| 151 | |
| 152 | mc13xxx_unlock(priv->mc13xxx); |
| 153 | |
| 154 | return ret; |
| 155 | } |
| 156 | |
| 157 | static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
| 158 | { |
| 159 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
| 160 | unsigned seconds, days; |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 161 | time64_t s1970; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 162 | int enabled, pending; |
| 163 | int ret; |
| 164 | |
| 165 | mc13xxx_lock(priv->mc13xxx); |
| 166 | |
| 167 | ret = mc13xxx_reg_read(priv->mc13xxx, MC13XXX_RTCTODA, &seconds); |
| 168 | if (unlikely(ret)) |
| 169 | goto out; |
Alexander Shiyan | 6a2b342 | 2014-04-03 14:50:01 -0700 | [diff] [blame] | 170 | if (seconds >= SEC_PER_DAY) { |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 171 | ret = -ENODATA; |
| 172 | goto out; |
| 173 | } |
| 174 | |
| 175 | ret = mc13xxx_reg_read(priv->mc13xxx, MC13XXX_RTCDAY, &days); |
| 176 | if (unlikely(ret)) |
| 177 | goto out; |
| 178 | |
| 179 | ret = mc13xxx_irq_status(priv->mc13xxx, MC13XXX_IRQ_TODA, |
| 180 | &enabled, &pending); |
| 181 | |
| 182 | out: |
| 183 | mc13xxx_unlock(priv->mc13xxx); |
| 184 | |
| 185 | if (ret) |
| 186 | return ret; |
| 187 | |
| 188 | alarm->enabled = enabled; |
| 189 | alarm->pending = pending; |
| 190 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 191 | s1970 = (time64_t)days * SEC_PER_DAY + seconds; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 192 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 193 | rtc_time64_to_tm(s1970, &alarm->time); |
| 194 | dev_dbg(dev, "%s: %lld\n", __func__, (long long)s1970); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 195 | |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
| 200 | { |
| 201 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 202 | time64_t s1970; |
| 203 | u32 seconds, days; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 204 | int ret; |
| 205 | |
| 206 | mc13xxx_lock(priv->mc13xxx); |
| 207 | |
| 208 | /* disable alarm to prevent false triggering */ |
| 209 | ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCTODA, 0x1ffff); |
| 210 | if (unlikely(ret)) |
| 211 | goto out; |
| 212 | |
| 213 | ret = mc13xxx_irq_ack(priv->mc13xxx, MC13XXX_IRQ_TODA); |
| 214 | if (unlikely(ret)) |
| 215 | goto out; |
| 216 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 217 | s1970 = rtc_tm_to_time64(&alarm->time); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 218 | |
Rasmus Villemoes | 99c14e4 | 2015-02-20 14:47:30 +0100 | [diff] [blame] | 219 | dev_dbg(dev, "%s: %s %lld\n", __func__, alarm->enabled ? "on" : "off", |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 220 | (long long)s1970); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 221 | |
| 222 | ret = mc13xxx_rtc_irq_enable_unlocked(dev, alarm->enabled, |
| 223 | MC13XXX_IRQ_TODA); |
| 224 | if (unlikely(ret)) |
| 225 | goto out; |
| 226 | |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 227 | days = div_s64_rem(s1970, SEC_PER_DAY, &seconds); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 228 | |
| 229 | ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCDAYA, days); |
| 230 | if (unlikely(ret)) |
| 231 | goto out; |
| 232 | |
| 233 | ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCTODA, seconds); |
| 234 | |
| 235 | out: |
| 236 | mc13xxx_unlock(priv->mc13xxx); |
| 237 | |
| 238 | return ret; |
| 239 | } |
| 240 | |
| 241 | static irqreturn_t mc13xxx_rtc_alarm_handler(int irq, void *dev) |
| 242 | { |
| 243 | struct mc13xxx_rtc *priv = dev; |
| 244 | struct mc13xxx *mc13xxx = priv->mc13xxx; |
| 245 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 246 | rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_AF); |
| 247 | |
| 248 | mc13xxx_irq_ack(mc13xxx, irq); |
| 249 | |
| 250 | return IRQ_HANDLED; |
| 251 | } |
| 252 | |
| 253 | static irqreturn_t mc13xxx_rtc_update_handler(int irq, void *dev) |
| 254 | { |
| 255 | struct mc13xxx_rtc *priv = dev; |
| 256 | struct mc13xxx *mc13xxx = priv->mc13xxx; |
| 257 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 258 | rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_UF); |
| 259 | |
| 260 | mc13xxx_irq_ack(mc13xxx, irq); |
| 261 | |
| 262 | return IRQ_HANDLED; |
| 263 | } |
| 264 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 265 | static const struct rtc_class_ops mc13xxx_rtc_ops = { |
| 266 | .read_time = mc13xxx_rtc_read_time, |
Xunlei Pang | 0307b0d | 2015-04-01 20:34:30 -0700 | [diff] [blame] | 267 | .set_mmss64 = mc13xxx_rtc_set_mmss, |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 268 | .read_alarm = mc13xxx_rtc_read_alarm, |
| 269 | .set_alarm = mc13xxx_rtc_set_alarm, |
| 270 | .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev) |
| 274 | { |
| 275 | struct mc13xxx_rtc *priv = dev; |
| 276 | struct mc13xxx *mc13xxx = priv->mc13xxx; |
| 277 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 278 | priv->valid = 0; |
| 279 | |
| 280 | mc13xxx_irq_mask(mc13xxx, irq); |
| 281 | |
| 282 | return IRQ_HANDLED; |
| 283 | } |
| 284 | |
Uwe Kleine-König | db5cf8d | 2011-11-02 13:37:56 -0700 | [diff] [blame] | 285 | static int __init mc13xxx_rtc_probe(struct platform_device *pdev) |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 286 | { |
| 287 | int ret; |
| 288 | struct mc13xxx_rtc *priv; |
| 289 | struct mc13xxx *mc13xxx; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 290 | |
Jingoo Han | a379fd2 | 2013-04-29 16:20:44 -0700 | [diff] [blame] | 291 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 292 | if (!priv) |
| 293 | return -ENOMEM; |
| 294 | |
| 295 | mc13xxx = dev_get_drvdata(pdev->dev.parent); |
| 296 | priv->mc13xxx = mc13xxx; |
Alexander Shiyan | 12de362 | 2014-04-03 14:50:00 -0700 | [diff] [blame] | 297 | priv->valid = 1; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 298 | |
| 299 | platform_set_drvdata(pdev, priv); |
| 300 | |
| 301 | mc13xxx_lock(mc13xxx); |
| 302 | |
Alexander Shiyan | 12de362 | 2014-04-03 14:50:00 -0700 | [diff] [blame] | 303 | mc13xxx_irq_ack(mc13xxx, MC13XXX_IRQ_RTCRST); |
| 304 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 305 | ret = mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_RTCRST, |
| 306 | mc13xxx_rtc_reset_handler, DRIVER_NAME, priv); |
| 307 | if (ret) |
Alexander Shiyan | 5ab9a52 | 2014-04-03 14:50:15 -0700 | [diff] [blame] | 308 | goto err_irq_request; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 309 | |
Alexander Shiyan | fb1bd9a | 2014-04-03 14:49:59 -0700 | [diff] [blame] | 310 | ret = mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_1HZ, |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 311 | mc13xxx_rtc_update_handler, DRIVER_NAME, priv); |
| 312 | if (ret) |
Alexander Shiyan | 5ab9a52 | 2014-04-03 14:50:15 -0700 | [diff] [blame] | 313 | goto err_irq_request; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 314 | |
| 315 | ret = mc13xxx_irq_request_nounmask(mc13xxx, MC13XXX_IRQ_TODA, |
| 316 | mc13xxx_rtc_alarm_handler, DRIVER_NAME, priv); |
Alexander Shiyan | 5ab9a52 | 2014-04-03 14:50:15 -0700 | [diff] [blame] | 317 | if (ret) |
| 318 | goto err_irq_request; |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 319 | |
Alexander Shiyan | 5ab9a52 | 2014-04-03 14:50:15 -0700 | [diff] [blame] | 320 | mc13xxx_unlock(mc13xxx); |
| 321 | |
| 322 | priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
| 323 | &mc13xxx_rtc_ops, THIS_MODULE); |
| 324 | |
| 325 | return 0; |
| 326 | |
| 327 | err_irq_request: |
| 328 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_TODA, priv); |
Alexander Shiyan | 589e501 | 2014-04-03 14:49:57 -0700 | [diff] [blame] | 329 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_1HZ, priv); |
Alexander Shiyan | 589e501 | 2014-04-03 14:49:57 -0700 | [diff] [blame] | 330 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_RTCRST, priv); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 331 | |
Alexander Shiyan | 589e501 | 2014-04-03 14:49:57 -0700 | [diff] [blame] | 332 | mc13xxx_unlock(mc13xxx); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 333 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 334 | return ret; |
| 335 | } |
| 336 | |
Alexander Shiyan | 77bf2ea | 2014-04-03 14:49:56 -0700 | [diff] [blame] | 337 | static int mc13xxx_rtc_remove(struct platform_device *pdev) |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 338 | { |
| 339 | struct mc13xxx_rtc *priv = platform_get_drvdata(pdev); |
| 340 | |
| 341 | mc13xxx_lock(priv->mc13xxx); |
| 342 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 343 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TODA, priv); |
| 344 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_1HZ, priv); |
| 345 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_RTCRST, priv); |
| 346 | |
| 347 | mc13xxx_unlock(priv->mc13xxx); |
| 348 | |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | |
Axel Lin | a46481d | 2012-01-10 15:10:52 -0800 | [diff] [blame] | 352 | static const struct platform_device_id mc13xxx_rtc_idtable[] = { |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 353 | { |
| 354 | .name = "mc13783-rtc", |
| 355 | }, { |
| 356 | .name = "mc13892-rtc", |
Uwe Kleine-König | 19a1ac5 | 2012-07-30 14:41:52 -0700 | [diff] [blame] | 357 | }, { |
| 358 | .name = "mc34708-rtc", |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 359 | }, |
Uwe Kleine-König | 0f636fc | 2012-07-30 14:41:50 -0700 | [diff] [blame] | 360 | { /* sentinel */ } |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 361 | }; |
Uwe Kleine-König | 0f636fc | 2012-07-30 14:41:50 -0700 | [diff] [blame] | 362 | MODULE_DEVICE_TABLE(platform, mc13xxx_rtc_idtable); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 363 | |
| 364 | static struct platform_driver mc13xxx_rtc_driver = { |
| 365 | .id_table = mc13xxx_rtc_idtable, |
Alexander Shiyan | 77bf2ea | 2014-04-03 14:49:56 -0700 | [diff] [blame] | 366 | .remove = mc13xxx_rtc_remove, |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 367 | .driver = { |
| 368 | .name = DRIVER_NAME, |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 369 | }, |
| 370 | }; |
| 371 | |
Jingoo Han | 09fb7ad | 2013-04-29 16:18:43 -0700 | [diff] [blame] | 372 | module_platform_driver_probe(mc13xxx_rtc_driver, &mc13xxx_rtc_probe); |
Uwe Kleine-König | 1c97872 | 2010-10-28 12:30:53 +0200 | [diff] [blame] | 373 | |
| 374 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
| 375 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); |
| 376 | MODULE_LICENSE("GPL v2"); |