diff options
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/rtc/class.c | 14 | ||||
| -rw-r--r-- | drivers/rtc/interface.c | 3 | ||||
| -rw-r--r-- | drivers/rtc/rtc-at91rm9200.c | 19 | ||||
| -rw-r--r-- | drivers/rtc/rtc-cmos.c | 50 | ||||
| -rw-r--r-- | drivers/rtc/rtc-pcf8583.c | 29 | ||||
| -rw-r--r-- | drivers/rtc/rtc-sa1100.c | 12 | 
7 files changed, 86 insertions, 51 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4bbca500d3d2..95826b92ca4b 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig  | |||
| @@ -101,7 +101,7 @@ comment "RTC drivers" | |||
| 101 | 101 | ||
| 102 | config RTC_DRV_CMOS | 102 | config RTC_DRV_CMOS | 
| 103 | tristate "PC-style 'CMOS' real time clock" | 103 | tristate "PC-style 'CMOS' real time clock" | 
| 104 | depends on RTC_CLASS && (X86_PC || ALPHA || ARM26 || ARM \ | 104 | depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ | 
| 105 | || M32R || ATARI || POWERPC) | 105 | || M32R || ATARI || POWERPC) | 
| 106 | help | 106 | help | 
| 107 | Say "yes" here to get direct support for the real time clock | 107 | Say "yes" here to get direct support for the real time clock | 
| @@ -207,10 +207,12 @@ config RTC_DRV_PCF8563 | |||
| 207 | 207 | ||
| 208 | config RTC_DRV_PCF8583 | 208 | config RTC_DRV_PCF8583 | 
| 209 | tristate "Philips PCF8583" | 209 | tristate "Philips PCF8583" | 
| 210 | depends on RTC_CLASS && I2C | 210 | depends on RTC_CLASS && I2C && ARCH_RPC | 
| 211 | help | 211 | help | 
| 212 | If you say yes here you get support for the | 212 | If you say yes here you get support for the Philips PCF8583 | 
| 213 | Philips PCF8583 RTC chip. | 213 | RTC chip found on Acorn RiscPCs. This driver supports the | 
| 214 | platform specific method of retrieving the current year from | ||
| 215 | the RTC's SRAM. | ||
| 214 | 216 | ||
| 215 | This driver can also be built as a module. If so, the module | 217 | This driver can also be built as a module. If so, the module | 
| 216 | will be called rtc-pcf8583. | 218 | will be called rtc-pcf8583. | 
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 7a0d8ee2de9c..04aaa6347234 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c  | |||
| @@ -113,10 +113,16 @@ EXPORT_SYMBOL_GPL(rtc_device_register); | |||
| 113 | */ | 113 | */ | 
| 114 | void rtc_device_unregister(struct rtc_device *rtc) | 114 | void rtc_device_unregister(struct rtc_device *rtc) | 
| 115 | { | 115 | { | 
| 116 | mutex_lock(&rtc->ops_lock); | 116 | if (class_device_get(&rtc->class_dev) != NULL) { | 
| 117 | rtc->ops = NULL; | 117 | mutex_lock(&rtc->ops_lock); | 
| 118 | mutex_unlock(&rtc->ops_lock); | 118 | /* remove innards of this RTC, then disable it, before | 
| 119 | class_device_unregister(&rtc->class_dev); | 119 | * letting any rtc_class_open() users access it again | 
| 120 | */ | ||
| 121 | class_device_unregister(&rtc->class_dev); | ||
| 122 | rtc->ops = NULL; | ||
| 123 | mutex_unlock(&rtc->ops_lock); | ||
| 124 | class_device_put(&rtc->class_dev); | ||
| 125 | } | ||
| 120 | } | 126 | } | 
| 121 | EXPORT_SYMBOL_GPL(rtc_device_unregister); | 127 | EXPORT_SYMBOL_GPL(rtc_device_unregister); | 
| 122 | 128 | ||
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 6f11f6dfdd9d..ef40df0f169d 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c  | |||
| @@ -179,7 +179,7 @@ struct class_device *rtc_class_open(char *name) | |||
| 179 | down(&rtc_class->sem); | 179 | down(&rtc_class->sem); | 
| 180 | list_for_each_entry(class_dev_tmp, &rtc_class->children, node) { | 180 | list_for_each_entry(class_dev_tmp, &rtc_class->children, node) { | 
| 181 | if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) { | 181 | if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) { | 
| 182 | class_dev = class_dev_tmp; | 182 | class_dev = class_device_get(class_dev_tmp); | 
| 183 | break; | 183 | break; | 
| 184 | } | 184 | } | 
| 185 | } | 185 | } | 
| @@ -197,6 +197,7 @@ EXPORT_SYMBOL_GPL(rtc_class_open); | |||
| 197 | void rtc_class_close(struct class_device *class_dev) | 197 | void rtc_class_close(struct class_device *class_dev) | 
| 198 | { | 198 | { | 
| 199 | module_put(to_rtc_device(class_dev)->owner); | 199 | module_put(to_rtc_device(class_dev)->owner); | 
| 200 | class_device_put(class_dev); | ||
| 200 | } | 201 | } | 
| 201 | EXPORT_SYMBOL_GPL(rtc_class_close); | 202 | EXPORT_SYMBOL_GPL(rtc_class_close); | 
| 202 | 203 | ||
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index a724ab49a797..ac0e68e2f025 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c  | |||
| @@ -164,6 +164,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 164 | tm.tm_min = alrm->time.tm_min; | 164 | tm.tm_min = alrm->time.tm_min; | 
| 165 | tm.tm_sec = alrm->time.tm_sec; | 165 | tm.tm_sec = alrm->time.tm_sec; | 
| 166 | 166 | ||
| 167 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); | ||
| 167 | at91_sys_write(AT91_RTC_TIMALR, | 168 | at91_sys_write(AT91_RTC_TIMALR, | 
| 168 | BIN2BCD(tm.tm_sec) << 0 | 169 | BIN2BCD(tm.tm_sec) << 0 | 
| 169 | | BIN2BCD(tm.tm_min) << 8 | 170 | | BIN2BCD(tm.tm_min) << 8 | 
| @@ -174,6 +175,9 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 174 | | BIN2BCD(tm.tm_mday) << 24 | 175 | | BIN2BCD(tm.tm_mday) << 24 | 
| 175 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); | 176 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); | 
| 176 | 177 | ||
| 178 | if (alrm->enabled) | ||
| 179 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); | ||
| 180 | |||
| 177 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, | 181 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, | 
| 178 | at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, | 182 | at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, | 
| 179 | tm.tm_min, tm.tm_sec); | 183 | tm.tm_min, tm.tm_sec); | 
| @@ -303,6 +307,12 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
| 303 | return ret; | 307 | return ret; | 
| 304 | } | 308 | } | 
| 305 | 309 | ||
| 310 | /* cpu init code should really have flagged this device as | ||
| 311 | * being wake-capable; if it didn't, do that here. | ||
| 312 | */ | ||
| 313 | if (!device_can_wakeup(&pdev->dev)) | ||
| 314 | device_init_wakeup(&pdev->dev, 1); | ||
| 315 | |||
| 306 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 316 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 
| 307 | &at91_rtc_ops, THIS_MODULE); | 317 | &at91_rtc_ops, THIS_MODULE); | 
| 308 | if (IS_ERR(rtc)) { | 318 | if (IS_ERR(rtc)) { | 
| @@ -310,7 +320,6 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
| 310 | return PTR_ERR(rtc); | 320 | return PTR_ERR(rtc); | 
| 311 | } | 321 | } | 
| 312 | platform_set_drvdata(pdev, rtc); | 322 | platform_set_drvdata(pdev, rtc); | 
| 313 | device_init_wakeup(&pdev->dev, 1); | ||
| 314 | 323 | ||
| 315 | printk(KERN_INFO "AT91 Real Time Clock driver.\n"); | 324 | printk(KERN_INFO "AT91 Real Time Clock driver.\n"); | 
| 316 | return 0; | 325 | return 0; | 
| @@ -319,7 +328,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
| 319 | /* | 328 | /* | 
| 320 | * Disable and remove the RTC driver | 329 | * Disable and remove the RTC driver | 
| 321 | */ | 330 | */ | 
| 322 | static int __devexit at91_rtc_remove(struct platform_device *pdev) | 331 | static int __exit at91_rtc_remove(struct platform_device *pdev) | 
| 323 | { | 332 | { | 
| 324 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 333 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 
| 325 | 334 | ||
| @@ -331,7 +340,6 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev) | |||
| 331 | 340 | ||
| 332 | rtc_device_unregister(rtc); | 341 | rtc_device_unregister(rtc); | 
| 333 | platform_set_drvdata(pdev, NULL); | 342 | platform_set_drvdata(pdev, NULL); | 
| 334 | device_init_wakeup(&pdev->dev, 0); | ||
| 335 | 343 | ||
| 336 | return 0; | 344 | return 0; | 
| 337 | } | 345 | } | 
| @@ -404,8 +412,7 @@ static int at91_rtc_resume(struct platform_device *pdev) | |||
| 404 | #endif | 412 | #endif | 
| 405 | 413 | ||
| 406 | static struct platform_driver at91_rtc_driver = { | 414 | static struct platform_driver at91_rtc_driver = { | 
| 407 | .probe = at91_rtc_probe, | 415 | .remove = __exit_p(at91_rtc_remove), | 
| 408 | .remove = at91_rtc_remove, | ||
| 409 | .suspend = at91_rtc_suspend, | 416 | .suspend = at91_rtc_suspend, | 
| 410 | .resume = at91_rtc_resume, | 417 | .resume = at91_rtc_resume, | 
| 411 | .driver = { | 418 | .driver = { | 
| @@ -416,7 +423,7 @@ static struct platform_driver at91_rtc_driver = { | |||
| 416 | 423 | ||
| 417 | static int __init at91_rtc_init(void) | 424 | static int __init at91_rtc_init(void) | 
| 418 | { | 425 | { | 
| 419 | return platform_driver_register(&at91_rtc_driver); | 426 | return platform_driver_probe(&at91_rtc_driver, at91_rtc_probe); | 
| 420 | } | 427 | } | 
| 421 | 428 | ||
| 422 | static void __exit at91_rtc_exit(void) | 429 | static void __exit at91_rtc_exit(void) | 
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 85bf795abdcc..7c0d60910077 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c  | |||
| @@ -59,6 +59,19 @@ struct cmos_rtc { | |||
| 59 | 59 | ||
| 60 | static const char driver_name[] = "rtc_cmos"; | 60 | static const char driver_name[] = "rtc_cmos"; | 
| 61 | 61 | ||
| 62 | /* The RTC_INTR register may have e.g. RTC_PF set even if RTC_PIE is clear; | ||
| 63 | * always mask it against the irq enable bits in RTC_CONTROL. Bit values | ||
| 64 | * are the same: PF==PIE, AF=AIE, UF=UIE; so RTC_IRQMASK works with both. | ||
| 65 | */ | ||
| 66 | #define RTC_IRQMASK (RTC_PF | RTC_AF | RTC_UF) | ||
| 67 | |||
| 68 | static inline int is_intr(u8 rtc_intr) | ||
| 69 | { | ||
| 70 | if (!(rtc_intr & RTC_IRQF)) | ||
| 71 | return 0; | ||
| 72 | return rtc_intr & RTC_IRQMASK; | ||
| 73 | } | ||
| 74 | |||
| 62 | /*----------------------------------------------------------------*/ | 75 | /*----------------------------------------------------------------*/ | 
| 63 | 76 | ||
| 64 | static int cmos_read_time(struct device *dev, struct rtc_time *t) | 77 | static int cmos_read_time(struct device *dev, struct rtc_time *t) | 
| @@ -188,7 +201,8 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
| 188 | rtc_control &= ~RTC_AIE; | 201 | rtc_control &= ~RTC_AIE; | 
| 189 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 202 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 
| 190 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 203 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 
| 191 | if (rtc_intr) | 204 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | 
| 205 | if (is_intr(rtc_intr)) | ||
| 192 | rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); | 206 | rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); | 
| 193 | 207 | ||
| 194 | /* update alarm */ | 208 | /* update alarm */ | 
| @@ -207,7 +221,8 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
| 207 | rtc_control |= RTC_AIE; | 221 | rtc_control |= RTC_AIE; | 
| 208 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 222 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 
| 209 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 223 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 
| 210 | if (rtc_intr) | 224 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | 
| 225 | if (is_intr(rtc_intr)) | ||
| 211 | rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); | 226 | rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); | 
| 212 | } | 227 | } | 
| 213 | 228 | ||
| @@ -287,7 +302,8 @@ cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
| 287 | } | 302 | } | 
| 288 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 303 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 
| 289 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 304 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 
| 290 | if (rtc_intr) | 305 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | 
| 306 | if (is_intr(rtc_intr)) | ||
| 291 | rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); | 307 | rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); | 
| 292 | spin_unlock_irqrestore(&rtc_lock, flags); | 308 | spin_unlock_irqrestore(&rtc_lock, flags); | 
| 293 | return 0; | 309 | return 0; | 
| @@ -353,12 +369,10 @@ static irqreturn_t cmos_interrupt(int irq, void *p) | |||
| 353 | 369 | ||
| 354 | spin_lock(&rtc_lock); | 370 | spin_lock(&rtc_lock); | 
| 355 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | 371 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | 
| 372 | irqstat &= (CMOS_READ(RTC_CONTROL) & RTC_IRQMASK) | RTC_IRQF; | ||
| 356 | spin_unlock(&rtc_lock); | 373 | spin_unlock(&rtc_lock); | 
| 357 | 374 | ||
| 358 | if (irqstat) { | 375 | if (is_intr(irqstat)) { | 
| 359 | /* NOTE: irqstat may have e.g. RTC_PF set | ||
| 360 | * even when RTC_PIE is clear... | ||
| 361 | */ | ||
| 362 | rtc_update_irq(p, 1, irqstat); | 376 | rtc_update_irq(p, 1, irqstat); | 
| 363 | return IRQ_HANDLED; | 377 | return IRQ_HANDLED; | 
| 364 | } else | 378 | } else | 
| @@ -525,25 +539,26 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg) | |||
| 525 | { | 539 | { | 
| 526 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 540 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 
| 527 | int do_wake = device_may_wakeup(dev); | 541 | int do_wake = device_may_wakeup(dev); | 
| 528 | unsigned char tmp, irqstat; | 542 | unsigned char tmp; | 
| 529 | 543 | ||
| 530 | /* only the alarm might be a wakeup event source */ | 544 | /* only the alarm might be a wakeup event source */ | 
| 531 | spin_lock_irq(&rtc_lock); | 545 | spin_lock_irq(&rtc_lock); | 
| 532 | cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL); | 546 | cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL); | 
| 533 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { | 547 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { | 
| 548 | unsigned char irqstat; | ||
| 549 | |||
| 534 | if (do_wake) | 550 | if (do_wake) | 
| 535 | tmp &= ~(RTC_PIE|RTC_UIE); | 551 | tmp &= ~(RTC_PIE|RTC_UIE); | 
| 536 | else | 552 | else | 
| 537 | tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE); | 553 | tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE); | 
| 538 | CMOS_WRITE(tmp, RTC_CONTROL); | 554 | CMOS_WRITE(tmp, RTC_CONTROL); | 
| 539 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | 555 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | 
| 540 | } else | 556 | irqstat &= (tmp & RTC_IRQMASK) | RTC_IRQF; | 
| 541 | irqstat = 0; | 557 | if (is_intr(irqstat)) | 
| 558 | rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat); | ||
| 559 | } | ||
| 542 | spin_unlock_irq(&rtc_lock); | 560 | spin_unlock_irq(&rtc_lock); | 
| 543 | 561 | ||
| 544 | if (irqstat) | ||
| 545 | rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat); | ||
| 546 | |||
| 547 | /* ACPI HOOK: enable ACPI_EVENT_RTC when (tmp & RTC_AIE) | 562 | /* ACPI HOOK: enable ACPI_EVENT_RTC when (tmp & RTC_AIE) | 
| 548 | * ... it'd be best if we could do that under rtc_lock. | 563 | * ... it'd be best if we could do that under rtc_lock. | 
| 549 | */ | 564 | */ | 
| @@ -573,9 +588,10 @@ static int cmos_resume(struct device *dev) | |||
| 573 | spin_lock_irq(&rtc_lock); | 588 | spin_lock_irq(&rtc_lock); | 
| 574 | CMOS_WRITE(tmp, RTC_CONTROL); | 589 | CMOS_WRITE(tmp, RTC_CONTROL); | 
| 575 | tmp = CMOS_READ(RTC_INTR_FLAGS); | 590 | tmp = CMOS_READ(RTC_INTR_FLAGS); | 
| 576 | spin_unlock_irq(&rtc_lock); | 591 | tmp &= (cmos->suspend_ctrl & RTC_IRQMASK) | RTC_IRQF; | 
| 577 | if (tmp) | 592 | if (is_intr(tmp)) | 
| 578 | rtc_update_irq(&cmos->rtc->class_dev, 1, tmp); | 593 | rtc_update_irq(&cmos->rtc->class_dev, 1, tmp); | 
| 594 | spin_unlock_irq(&rtc_lock); | ||
| 579 | } | 595 | } | 
| 580 | 596 | ||
| 581 | pr_debug("%s: resume, ctrl %02x\n", | 597 | pr_debug("%s: resume, ctrl %02x\n", | 
| @@ -594,7 +610,7 @@ static int cmos_resume(struct device *dev) | |||
| 594 | /*----------------------------------------------------------------*/ | 610 | /*----------------------------------------------------------------*/ | 
| 595 | 611 | ||
| 596 | /* The "CMOS" RTC normally lives on the platform_bus. On ACPI systems, | 612 | /* The "CMOS" RTC normally lives on the platform_bus. On ACPI systems, | 
| 597 | * the device node may alternatively be created as a PNP device. | 613 | * the device node will always be created as a PNPACPI device. | 
| 598 | */ | 614 | */ | 
| 599 | 615 | ||
| 600 | #ifdef CONFIG_PNPACPI | 616 | #ifdef CONFIG_PNPACPI | 
| @@ -673,7 +689,7 @@ module_exit(cmos_exit); | |||
| 673 | /*----------------------------------------------------------------*/ | 689 | /*----------------------------------------------------------------*/ | 
| 674 | 690 | ||
| 675 | /* Platform setup should have set up an RTC device, when PNPACPI is | 691 | /* Platform setup should have set up an RTC device, when PNPACPI is | 
| 676 | * unavailable ... this is the normal case, common even on PCs. | 692 | * unavailable ... this could happen even on (older) PCs. | 
| 677 | */ | 693 | */ | 
| 678 | 694 | ||
| 679 | static int __init cmos_platform_probe(struct platform_device *pdev) | 695 | static int __init cmos_platform_probe(struct platform_device *pdev) | 
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 5875ebb8c79d..d48b03374586 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c  | |||
| @@ -40,7 +40,7 @@ struct pcf8583 { | |||
| 40 | #define CTRL_ALARM 0x02 | 40 | #define CTRL_ALARM 0x02 | 
| 41 | #define CTRL_TIMER 0x01 | 41 | #define CTRL_TIMER 0x01 | 
| 42 | 42 | ||
| 43 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | 43 | static unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; | 
| 44 | 44 | ||
| 45 | /* Module parameters */ | 45 | /* Module parameters */ | 
| 46 | I2C_CLIENT_INSMOD; | 46 | I2C_CLIENT_INSMOD; | 
| @@ -81,11 +81,11 @@ static int pcf8583_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
| 81 | buf[4] &= 0x3f; | 81 | buf[4] &= 0x3f; | 
| 82 | buf[5] &= 0x1f; | 82 | buf[5] &= 0x1f; | 
| 83 | 83 | ||
| 84 | dt->tm_sec = BCD_TO_BIN(buf[1]); | 84 | dt->tm_sec = BCD2BIN(buf[1]); | 
| 85 | dt->tm_min = BCD_TO_BIN(buf[2]); | 85 | dt->tm_min = BCD2BIN(buf[2]); | 
| 86 | dt->tm_hour = BCD_TO_BIN(buf[3]); | 86 | dt->tm_hour = BCD2BIN(buf[3]); | 
| 87 | dt->tm_mday = BCD_TO_BIN(buf[4]); | 87 | dt->tm_mday = BCD2BIN(buf[4]); | 
| 88 | dt->tm_mon = BCD_TO_BIN(buf[5]); | 88 | dt->tm_mon = BCD2BIN(buf[5]) - 1; | 
| 89 | } | 89 | } | 
| 90 | 90 | ||
| 91 | return ret == 2 ? 0 : -EIO; | 91 | return ret == 2 ? 0 : -EIO; | 
| @@ -99,14 +99,14 @@ static int pcf8583_set_datetime(struct i2c_client *client, struct rtc_time *dt, | |||
| 99 | buf[0] = 0; | 99 | buf[0] = 0; | 
| 100 | buf[1] = get_ctrl(client) | 0x80; | 100 | buf[1] = get_ctrl(client) | 0x80; | 
| 101 | buf[2] = 0; | 101 | buf[2] = 0; | 
| 102 | buf[3] = BIN_TO_BCD(dt->tm_sec); | 102 | buf[3] = BIN2BCD(dt->tm_sec); | 
| 103 | buf[4] = BIN_TO_BCD(dt->tm_min); | 103 | buf[4] = BIN2BCD(dt->tm_min); | 
| 104 | buf[5] = BIN_TO_BCD(dt->tm_hour); | 104 | buf[5] = BIN2BCD(dt->tm_hour); | 
| 105 | 105 | ||
| 106 | if (datetoo) { | 106 | if (datetoo) { | 
| 107 | len = 8; | 107 | len = 8; | 
| 108 | buf[6] = BIN_TO_BCD(dt->tm_mday) | (dt->tm_year << 6); | 108 | buf[6] = BIN2BCD(dt->tm_mday) | (dt->tm_year << 6); | 
| 109 | buf[7] = BIN_TO_BCD(dt->tm_mon) | (dt->tm_wday << 5); | 109 | buf[7] = BIN2BCD(dt->tm_mon + 1) | (dt->tm_wday << 5); | 
| 110 | } | 110 | } | 
| 111 | 111 | ||
| 112 | ret = i2c_master_send(client, (char *)buf, len); | 112 | ret = i2c_master_send(client, (char *)buf, len); | 
| @@ -226,7 +226,7 @@ static int pcf8583_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
| 226 | */ | 226 | */ | 
| 227 | year_offset += 4; | 227 | year_offset += 4; | 
| 228 | 228 | ||
| 229 | tm->tm_year = real_year + year_offset + year[1] * 100; | 229 | tm->tm_year = (real_year + year_offset + year[1] * 100) - 1900; | 
| 230 | 230 | ||
| 231 | return 0; | 231 | return 0; | 
| 232 | } | 232 | } | 
| @@ -237,6 +237,7 @@ static int pcf8583_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
| 237 | unsigned char year[2], chk; | 237 | unsigned char year[2], chk; | 
| 238 | struct rtc_mem cmos_year = { CMOS_YEAR, sizeof(year), year }; | 238 | struct rtc_mem cmos_year = { CMOS_YEAR, sizeof(year), year }; | 
| 239 | struct rtc_mem cmos_check = { CMOS_CHECKSUM, 1, &chk }; | 239 | struct rtc_mem cmos_check = { CMOS_CHECKSUM, 1, &chk }; | 
| 240 | unsigned int proper_year = tm->tm_year + 1900; | ||
| 240 | int ret; | 241 | int ret; | 
| 241 | 242 | ||
| 242 | /* | 243 | /* | 
| @@ -258,8 +259,8 @@ static int pcf8583_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
| 258 | 259 | ||
| 259 | chk -= year[1] + year[0]; | 260 | chk -= year[1] + year[0]; | 
| 260 | 261 | ||
| 261 | year[1] = tm->tm_year / 100; | 262 | year[1] = proper_year / 100; | 
| 262 | year[0] = tm->tm_year % 100; | 263 | year[0] = proper_year % 100; | 
| 263 | 264 | ||
| 264 | chk += year[1] + year[0]; | 265 | chk += year[1] + year[0]; | 
| 265 | 266 | ||
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 9c8ead43a59c..677bae820dc3 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c  | |||
| @@ -263,8 +263,12 @@ static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
| 263 | 263 | ||
| 264 | static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 264 | static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 
| 265 | { | 265 | { | 
| 266 | u32 rtsr; | ||
| 267 | |||
| 266 | memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time)); | 268 | memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time)); | 
| 267 | alrm->pending = RTSR & RTSR_AL ? 1 : 0; | 269 | rtsr = RTSR; | 
| 270 | alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; | ||
| 271 | alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; | ||
| 268 | return 0; | 272 | return 0; | 
| 269 | } | 273 | } | 
| 270 | 274 | ||
| @@ -275,12 +279,10 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 275 | spin_lock_irq(&sa1100_rtc_lock); | 279 | spin_lock_irq(&sa1100_rtc_lock); | 
| 276 | ret = rtc_update_alarm(&alrm->time); | 280 | ret = rtc_update_alarm(&alrm->time); | 
| 277 | if (ret == 0) { | 281 | if (ret == 0) { | 
| 278 | memcpy(&rtc_alarm, &alrm->time, sizeof(struct rtc_time)); | ||
| 279 | |||
| 280 | if (alrm->enabled) | 282 | if (alrm->enabled) | 
| 281 | enable_irq_wake(IRQ_RTCAlrm); | 283 | RTSR |= RTSR_ALE; | 
| 282 | else | 284 | else | 
| 283 | disable_irq_wake(IRQ_RTCAlrm); | 285 | RTSR &= ~RTSR_ALE; | 
| 284 | } | 286 | } | 
| 285 | spin_unlock_irq(&sa1100_rtc_lock); | 287 | spin_unlock_irq(&sa1100_rtc_lock); | 
| 286 | 288 | ||
