Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'rtc-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
"Not much this cycle - mostly non urgent driver fixes:

- ds1374: use watchdog core

- pcf2127: add alarm and pcf2129 support"

* tag 'rtc-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
rtc: pcf2127: fix alarm handling
rtc: pcf2127: add alarm support
rtc: pcf2127: add pca2129 device id
rtc: max77686: Fix wake-ups for max77620
rtc: ds1307: provide an indication that the watchdog has fired
rtc: ds1374: remove unused define
rtc: ds1374: fix RTC_DRV_DS1374_WDT dependencies
rtc: cleanup obsolete comment about struct rtc_class_ops
rtc: pl031: fix set_alarm by adding back call to alarm_irq_enable
rtc: ds1374: wdt: Use watchdog core for watchdog part
rtc: Replace HTTP links with HTTPS ones
rtc: goldfish: Enable interrupt in set_alarm() when necessary
rtc: max77686: Do not allow interrupt to fire before system resume
rtc: imxdi: fix trivial typos
rtc: cpcap: fix range

+244 -218
+2
Documentation/devicetree/bindings/rtc/trivial-rtc.yaml
··· 52 52 - nxp,pcf2127 53 53 # Real-time clock 54 54 - nxp,pcf2129 55 + # Real-time clock 56 + - nxp,pca2129 55 57 # Real-time Clock Module 56 58 - pericom,pt7c4338 57 59 # I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
+2 -1
drivers/rtc/Kconfig
··· 281 281 282 282 config RTC_DRV_DS1374_WDT 283 283 bool "Dallas/Maxim DS1374 watchdog timer" 284 - depends on RTC_DRV_DS1374 284 + depends on RTC_DRV_DS1374 && WATCHDOG 285 + select WATCHDOG_CORE 285 286 help 286 287 If you say Y here you will get support for the 287 288 watchdog timer in the Dallas Semiconductor DS1374
+1 -1
drivers/rtc/rtc-ab-b5ze-s3.c
··· 7 7 * 8 8 * Detailed datasheet of the chip is available here: 9 9 * 10 - * http://www.abracon.com/realtimeclock/AB-RTCMC-32.768kHz-B5ZE-S3-Application-Manual.pdf 10 + * https://www.abracon.com/realtimeclock/AB-RTCMC-32.768kHz-B5ZE-S3-Application-Manual.pdf 11 11 * 12 12 * This work is based on ISL12057 driver (drivers/rtc/rtc-isl12057.c). 13 13 *
+1 -1
drivers/rtc/rtc-bq32k.c
··· 6 6 * Copyright (C) 2014 Pavel Machek <pavel@denx.de> 7 7 * 8 8 * You can get hardware description at 9 - * http://www.ti.com/lit/ds/symlink/bq32000.pdf 9 + * https://www.ti.com/lit/ds/symlink/bq32000.pdf 10 10 */ 11 11 12 12 #include <linux/module.h>
+1 -1
drivers/rtc/rtc-cpcap.c
··· 261 261 return PTR_ERR(rtc->rtc_dev); 262 262 263 263 rtc->rtc_dev->ops = &cpcap_rtc_ops; 264 - rtc->rtc_dev->range_max = (1 << 14) * SECS_PER_DAY - 1; 264 + rtc->rtc_dev->range_max = (timeu64_t) (DAY_MASK + 1) * SECS_PER_DAY - 1; 265 265 266 266 err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor); 267 267 if (err)
+6
drivers/rtc/rtc-ds1307.c
··· 1668 1668 static void ds1307_wdt_register(struct ds1307 *ds1307) 1669 1669 { 1670 1670 struct watchdog_device *wdt; 1671 + int err; 1672 + int val; 1671 1673 1672 1674 if (ds1307->type != ds_1388) 1673 1675 return; ··· 1677 1675 wdt = devm_kzalloc(ds1307->dev, sizeof(*wdt), GFP_KERNEL); 1678 1676 if (!wdt) 1679 1677 return; 1678 + 1679 + err = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &val); 1680 + if (!err && val & DS1388_BIT_WF) 1681 + wdt->bootstatus = WDIOF_CARDRESET; 1680 1682 1681 1683 wdt->info = &ds1388_wdt_info; 1682 1684 wdt->ops = &ds1388_wdt_ops;
+62 -200
drivers/rtc/rtc-ds1374.c
··· 46 46 #define DS1374_REG_WDALM2 0x06 47 47 #define DS1374_REG_CR 0x07 /* Control */ 48 48 #define DS1374_REG_CR_AIE 0x01 /* Alarm Int. Enable */ 49 + #define DS1374_REG_CR_WDSTR 0x08 /* 1=INT, 0=RST */ 49 50 #define DS1374_REG_CR_WDALM 0x20 /* 1=Watchdog, 0=Alarm */ 50 51 #define DS1374_REG_CR_WACE 0x40 /* WD/Alarm counter enable */ 51 52 #define DS1374_REG_SR 0x08 /* Status */ ··· 72 71 struct i2c_client *client; 73 72 struct rtc_device *rtc; 74 73 struct work_struct work; 75 - 74 + #ifdef CONFIG_RTC_DRV_DS1374_WDT 75 + struct watchdog_device wdt; 76 + #endif 76 77 /* The mutex protects alarm operations, and prevents a race 77 78 * between the enable_irq() in the workqueue and the free_irq() 78 79 * in the remove function. ··· 372 369 * 373 370 ***************************************************************************** 374 371 */ 375 - static struct i2c_client *save_client; 376 372 /* Default margin */ 377 - #define WD_TIMO 131762 373 + #define TIMER_MARGIN_DEFAULT 32 374 + #define TIMER_MARGIN_MIN 1 375 + #define TIMER_MARGIN_MAX 4095 /* 24-bit value */ 378 376 379 - #define DRV_NAME "DS1374 Watchdog" 380 - 381 - static int wdt_margin = WD_TIMO; 382 - static unsigned long wdt_is_open; 377 + static int wdt_margin; 383 378 module_param(wdt_margin, int, 0); 384 379 MODULE_PARM_DESC(wdt_margin, "Watchdog timeout in seconds (default 32s)"); 385 380 381 + static bool nowayout = WATCHDOG_NOWAYOUT; 382 + module_param(nowayout, bool, 0); 383 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default =" 384 + __MODULE_STRING(WATCHDOG_NOWAYOUT)")"); 385 + 386 386 static const struct watchdog_info ds1374_wdt_info = { 387 - .identity = "DS1374 WTD", 387 + .identity = "DS1374 Watchdog", 388 388 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | 389 389 WDIOF_MAGICCLOSE, 390 390 }; 391 391 392 - static int ds1374_wdt_settimeout(unsigned int timeout) 392 + static int ds1374_wdt_settimeout(struct watchdog_device *wdt, unsigned int timeout) 393 393 { 394 - int ret = -ENOIOCTLCMD; 395 - int cr; 394 + struct ds1374 *ds1374 = watchdog_get_drvdata(wdt); 395 + struct i2c_client *client = ds1374->client; 396 + int ret, cr; 396 397 397 - ret = cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR); 398 - if (ret < 0) 399 - goto out; 398 + wdt->timeout = timeout; 399 + 400 + cr = i2c_smbus_read_byte_data(client, DS1374_REG_CR); 401 + if (cr < 0) 402 + return cr; 400 403 401 404 /* Disable any existing watchdog/alarm before setting the new one */ 402 405 cr &= ~DS1374_REG_CR_WACE; 403 406 404 - ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr); 407 + ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, cr); 405 408 if (ret < 0) 406 - goto out; 409 + return ret; 407 410 408 411 /* Set new watchdog time */ 409 - ret = ds1374_write_rtc(save_client, timeout, DS1374_REG_WDALM0, 3); 410 - if (ret) { 411 - pr_info("couldn't set new watchdog time\n"); 412 - goto out; 413 - } 412 + timeout = timeout * 4096; 413 + ret = ds1374_write_rtc(client, timeout, DS1374_REG_WDALM0, 3); 414 + if (ret) 415 + return ret; 414 416 415 417 /* Enable watchdog timer */ 416 418 cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM; 419 + cr &= ~DS1374_REG_CR_WDSTR;/* for RST PIN */ 417 420 cr &= ~DS1374_REG_CR_AIE; 418 421 419 - ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr); 422 + ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, cr); 420 423 if (ret < 0) 421 - goto out; 424 + return ret; 422 425 423 426 return 0; 424 - out: 425 - return ret; 426 427 } 427 - 428 428 429 429 /* 430 430 * Reload the watchdog timer. (ie, pat the watchdog) 431 431 */ 432 - static void ds1374_wdt_ping(void) 432 + static int ds1374_wdt_start(struct watchdog_device *wdt) 433 433 { 434 + struct ds1374 *ds1374 = watchdog_get_drvdata(wdt); 434 435 u32 val; 435 - int ret = 0; 436 436 437 - ret = ds1374_read_rtc(save_client, &val, DS1374_REG_WDALM0, 3); 438 - if (ret) 439 - pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret); 437 + return ds1374_read_rtc(ds1374->client, &val, DS1374_REG_WDALM0, 3); 440 438 } 441 439 442 - static void ds1374_wdt_disable(void) 440 + static int ds1374_wdt_stop(struct watchdog_device *wdt) 443 441 { 442 + struct ds1374 *ds1374 = watchdog_get_drvdata(wdt); 443 + struct i2c_client *client = ds1374->client; 444 444 int cr; 445 445 446 - cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR); 446 + cr = i2c_smbus_read_byte_data(client, DS1374_REG_CR); 447 + if (cr < 0) 448 + return cr; 449 + 447 450 /* Disable watchdog timer */ 448 451 cr &= ~DS1374_REG_CR_WACE; 449 452 450 - i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr); 453 + return i2c_smbus_write_byte_data(client, DS1374_REG_CR, cr); 451 454 } 452 455 453 - /* 454 - * Watchdog device is opened, and watchdog starts running. 455 - */ 456 - static int ds1374_wdt_open(struct inode *inode, struct file *file) 457 - { 458 - struct ds1374 *ds1374 = i2c_get_clientdata(save_client); 459 - 460 - if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { 461 - mutex_lock(&ds1374->mutex); 462 - if (test_and_set_bit(0, &wdt_is_open)) { 463 - mutex_unlock(&ds1374->mutex); 464 - return -EBUSY; 465 - } 466 - /* 467 - * Activate 468 - */ 469 - wdt_is_open = 1; 470 - mutex_unlock(&ds1374->mutex); 471 - return stream_open(inode, file); 472 - } 473 - return -ENODEV; 474 - } 475 - 476 - /* 477 - * Close the watchdog device. 478 - */ 479 - static int ds1374_wdt_release(struct inode *inode, struct file *file) 480 - { 481 - if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) 482 - clear_bit(0, &wdt_is_open); 483 - 484 - return 0; 485 - } 486 - 487 - /* 488 - * Pat the watchdog whenever device is written to. 489 - */ 490 - static ssize_t ds1374_wdt_write(struct file *file, const char __user *data, 491 - size_t len, loff_t *ppos) 492 - { 493 - if (len) { 494 - ds1374_wdt_ping(); 495 - return 1; 496 - } 497 - return 0; 498 - } 499 - 500 - static ssize_t ds1374_wdt_read(struct file *file, char __user *data, 501 - size_t len, loff_t *ppos) 502 - { 503 - return 0; 504 - } 505 - 506 - /* 507 - * Handle commands from user-space. 508 - */ 509 - static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd, 510 - unsigned long arg) 511 - { 512 - int new_margin, options; 513 - 514 - switch (cmd) { 515 - case WDIOC_GETSUPPORT: 516 - return copy_to_user((struct watchdog_info __user *)arg, 517 - &ds1374_wdt_info, sizeof(ds1374_wdt_info)) ? -EFAULT : 0; 518 - 519 - case WDIOC_GETSTATUS: 520 - case WDIOC_GETBOOTSTATUS: 521 - return put_user(0, (int __user *)arg); 522 - case WDIOC_KEEPALIVE: 523 - ds1374_wdt_ping(); 524 - return 0; 525 - case WDIOC_SETTIMEOUT: 526 - if (get_user(new_margin, (int __user *)arg)) 527 - return -EFAULT; 528 - 529 - /* the hardware's tick rate is 4096 Hz, so 530 - * the counter value needs to be scaled accordingly 531 - */ 532 - new_margin <<= 12; 533 - if (new_margin < 1 || new_margin > 16777216) 534 - return -EINVAL; 535 - 536 - wdt_margin = new_margin; 537 - ds1374_wdt_settimeout(new_margin); 538 - ds1374_wdt_ping(); 539 - /* fallthrough */ 540 - case WDIOC_GETTIMEOUT: 541 - /* when returning ... inverse is true */ 542 - return put_user((wdt_margin >> 12), (int __user *)arg); 543 - case WDIOC_SETOPTIONS: 544 - if (copy_from_user(&options, (int __user *)arg, sizeof(int))) 545 - return -EFAULT; 546 - 547 - if (options & WDIOS_DISABLECARD) { 548 - pr_info("disable watchdog\n"); 549 - ds1374_wdt_disable(); 550 - return 0; 551 - } 552 - 553 - if (options & WDIOS_ENABLECARD) { 554 - pr_info("enable watchdog\n"); 555 - ds1374_wdt_settimeout(wdt_margin); 556 - ds1374_wdt_ping(); 557 - return 0; 558 - } 559 - return -EINVAL; 560 - } 561 - return -ENOTTY; 562 - } 563 - 564 - static long ds1374_wdt_unlocked_ioctl(struct file *file, unsigned int cmd, 565 - unsigned long arg) 566 - { 567 - int ret; 568 - struct ds1374 *ds1374 = i2c_get_clientdata(save_client); 569 - 570 - mutex_lock(&ds1374->mutex); 571 - ret = ds1374_wdt_ioctl(file, cmd, arg); 572 - mutex_unlock(&ds1374->mutex); 573 - 574 - return ret; 575 - } 576 - 577 - static int ds1374_wdt_notify_sys(struct notifier_block *this, 578 - unsigned long code, void *unused) 579 - { 580 - if (code == SYS_DOWN || code == SYS_HALT) 581 - /* Disable Watchdog */ 582 - ds1374_wdt_disable(); 583 - return NOTIFY_DONE; 584 - } 585 - 586 - static const struct file_operations ds1374_wdt_fops = { 587 - .owner = THIS_MODULE, 588 - .read = ds1374_wdt_read, 589 - .unlocked_ioctl = ds1374_wdt_unlocked_ioctl, 590 - .compat_ioctl = compat_ptr_ioctl, 591 - .write = ds1374_wdt_write, 592 - .open = ds1374_wdt_open, 593 - .release = ds1374_wdt_release, 594 - .llseek = no_llseek, 456 + static const struct watchdog_ops ds1374_wdt_ops = { 457 + .owner = THIS_MODULE, 458 + .start = ds1374_wdt_start, 459 + .stop = ds1374_wdt_stop, 460 + .set_timeout = ds1374_wdt_settimeout, 595 461 }; 596 - 597 - static struct miscdevice ds1374_miscdev = { 598 - .minor = WATCHDOG_MINOR, 599 - .name = "watchdog", 600 - .fops = &ds1374_wdt_fops, 601 - }; 602 - 603 - static struct notifier_block ds1374_wdt_notifier = { 604 - .notifier_call = ds1374_wdt_notify_sys, 605 - }; 606 - 607 462 #endif /*CONFIG_RTC_DRV_DS1374_WDT*/ 608 463 /* 609 464 ***************************************************************************** ··· 513 652 return ret; 514 653 515 654 #ifdef CONFIG_RTC_DRV_DS1374_WDT 516 - save_client = client; 517 - ret = misc_register(&ds1374_miscdev); 655 + ds1374->wdt.info = &ds1374_wdt_info; 656 + ds1374->wdt.ops = &ds1374_wdt_ops; 657 + ds1374->wdt.timeout = TIMER_MARGIN_DEFAULT; 658 + ds1374->wdt.min_timeout = TIMER_MARGIN_MIN; 659 + ds1374->wdt.max_timeout = TIMER_MARGIN_MAX; 660 + 661 + watchdog_init_timeout(&ds1374->wdt, wdt_margin, &client->dev); 662 + watchdog_set_nowayout(&ds1374->wdt, nowayout); 663 + watchdog_stop_on_reboot(&ds1374->wdt); 664 + watchdog_stop_on_unregister(&ds1374->wdt); 665 + watchdog_set_drvdata(&ds1374->wdt, ds1374); 666 + ds1374_wdt_settimeout(&ds1374->wdt, ds1374->wdt.timeout); 667 + 668 + ret = devm_watchdog_register_device(&client->dev, &ds1374->wdt); 518 669 if (ret) 519 670 return ret; 520 - ret = register_reboot_notifier(&ds1374_wdt_notifier); 521 - if (ret) { 522 - misc_deregister(&ds1374_miscdev); 523 - return ret; 524 - } 525 - ds1374_wdt_settimeout(131072); 526 671 #endif 527 672 528 673 return 0; ··· 537 670 static int ds1374_remove(struct i2c_client *client) 538 671 { 539 672 struct ds1374 *ds1374 = i2c_get_clientdata(client); 540 - #ifdef CONFIG_RTC_DRV_DS1374_WDT 541 - misc_deregister(&ds1374_miscdev); 542 - ds1374_miscdev.parent = NULL; 543 - unregister_reboot_notifier(&ds1374_wdt_notifier); 544 - #endif 545 673 546 674 if (client->irq > 0) { 547 675 mutex_lock(&ds1374->mutex);
+1
drivers/rtc/rtc-goldfish.c
··· 73 73 rtc_alarm64 = rtc_tm_to_time64(&alrm->time) * NSEC_PER_SEC; 74 74 writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH); 75 75 writel(rtc_alarm64, base + TIMER_ALARM_LOW); 76 + writel(1, base + TIMER_IRQ_ENABLED); 76 77 } else { 77 78 /* 78 79 * if this function was called with enabled=0
+2 -2
drivers/rtc/rtc-imxdi.c
··· 95 95 96 96 /** 97 97 * struct imxdi_dev - private imxdi rtc data 98 - * @pdev: pionter to platform dev 98 + * @pdev: pointer to platform dev 99 99 * @rtc: pointer to rtc struct 100 100 * @ioaddr: IO registers pointer 101 101 * @clk: input reference clock ··· 350 350 * the tamper register is locked. We cannot disable the 351 351 * tamper detection. The TDCHL can only be reset by a 352 352 * DRYICE POR, but we cannot force a DRYICE POR in 353 - * softwere because we are still in "FAILURE STATE". 353 + * software because we are still in "FAILURE STATE". 354 354 * We need a DRYICE POR via battery power cycling.... 355 355 */ 356 356 /*
+21 -2
drivers/rtc/rtc-max77686.c
··· 805 805 #ifdef CONFIG_PM_SLEEP 806 806 static int max77686_rtc_suspend(struct device *dev) 807 807 { 808 + struct max77686_rtc_info *info = dev_get_drvdata(dev); 809 + int ret = 0; 810 + 808 811 if (device_may_wakeup(dev)) { 809 812 struct max77686_rtc_info *info = dev_get_drvdata(dev); 810 813 811 - return enable_irq_wake(info->virq); 814 + ret = enable_irq_wake(info->virq); 812 815 } 813 816 814 - return 0; 817 + /* 818 + * If the main IRQ (not virtual) is the parent IRQ, then it must be 819 + * disabled during suspend because if it happens while suspended it 820 + * will be handled before resuming I2C. 821 + * 822 + * Since Main IRQ is shared, all its users should disable it to be sure 823 + * it won't fire while one of them is still suspended. 824 + */ 825 + if (!info->drv_data->rtc_irq_from_platform) 826 + disable_irq(info->rtc_irq); 827 + 828 + return ret; 815 829 } 816 830 817 831 static int max77686_rtc_resume(struct device *dev) 818 832 { 833 + struct max77686_rtc_info *info = dev_get_drvdata(dev); 834 + 835 + if (!info->drv_data->rtc_irq_from_platform) 836 + enable_irq(info->rtc_irq); 837 + 819 838 if (device_may_wakeup(dev)) { 820 839 struct max77686_rtc_info *info = dev_get_drvdata(dev); 821 840
+1 -1
drivers/rtc/rtc-mcp795.c
··· 7 7 * based on other Linux RTC drivers 8 8 * 9 9 * Device datasheet: 10 - * http://ww1.microchip.com/downloads/en/DeviceDoc/22280A.pdf 10 + * https://ww1.microchip.com/downloads/en/DeviceDoc/22280A.pdf 11 11 */ 12 12 13 13 #include <linux/module.h>
+141 -3
drivers/rtc/rtc-pcf2127.c
··· 20 20 #include <linux/slab.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 + #include <linux/of_irq.h> 23 24 #include <linux/regmap.h> 24 25 #include <linux/watchdog.h> 25 26 ··· 29 28 #define PCF2127_BIT_CTRL1_TSF1 BIT(4) 30 29 /* Control register 2 */ 31 30 #define PCF2127_REG_CTRL2 0x01 31 + #define PCF2127_BIT_CTRL2_AIE BIT(1) 32 32 #define PCF2127_BIT_CTRL2_TSIE BIT(2) 33 + #define PCF2127_BIT_CTRL2_AF BIT(4) 33 34 #define PCF2127_BIT_CTRL2_TSF2 BIT(5) 35 + #define PCF2127_BIT_CTRL2_WDTF BIT(6) 34 36 /* Control register 3 */ 35 37 #define PCF2127_REG_CTRL3 0x02 36 38 #define PCF2127_BIT_CTRL3_BLIE BIT(0) ··· 50 46 #define PCF2127_REG_DW 0x07 51 47 #define PCF2127_REG_MO 0x08 52 48 #define PCF2127_REG_YR 0x09 49 + /* Alarm registers */ 50 + #define PCF2127_REG_ALARM_SC 0x0A 51 + #define PCF2127_REG_ALARM_MN 0x0B 52 + #define PCF2127_REG_ALARM_HR 0x0C 53 + #define PCF2127_REG_ALARM_DM 0x0D 54 + #define PCF2127_REG_ALARM_DW 0x0E 55 + #define PCF2127_BIT_ALARM_AE BIT(7) 53 56 /* Watchdog registers */ 54 57 #define PCF2127_REG_WD_CTL 0x10 55 58 #define PCF2127_BIT_WD_CTL_TF0 BIT(0) ··· 335 324 .set_timeout = pcf2127_wdt_set_timeout, 336 325 }; 337 326 327 + /* Alarm */ 328 + static int pcf2127_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 329 + { 330 + struct pcf2127 *pcf2127 = dev_get_drvdata(dev); 331 + unsigned int buf[5], ctrl2; 332 + int ret; 333 + 334 + ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL2, &ctrl2); 335 + if (ret) 336 + return ret; 337 + 338 + ret = pcf2127_wdt_active_ping(&pcf2127->wdd); 339 + if (ret) 340 + return ret; 341 + 342 + ret = regmap_bulk_read(pcf2127->regmap, PCF2127_REG_ALARM_SC, buf, 343 + sizeof(buf)); 344 + if (ret) 345 + return ret; 346 + 347 + alrm->enabled = ctrl2 & PCF2127_BIT_CTRL2_AIE; 348 + alrm->pending = ctrl2 & PCF2127_BIT_CTRL2_AF; 349 + 350 + alrm->time.tm_sec = bcd2bin(buf[0] & 0x7F); 351 + alrm->time.tm_min = bcd2bin(buf[1] & 0x7F); 352 + alrm->time.tm_hour = bcd2bin(buf[2] & 0x3F); 353 + alrm->time.tm_mday = bcd2bin(buf[3] & 0x3F); 354 + 355 + return 0; 356 + } 357 + 358 + static int pcf2127_rtc_alarm_irq_enable(struct device *dev, u32 enable) 359 + { 360 + struct pcf2127 *pcf2127 = dev_get_drvdata(dev); 361 + int ret; 362 + 363 + ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL2, 364 + PCF2127_BIT_CTRL2_AIE, 365 + enable ? PCF2127_BIT_CTRL2_AIE : 0); 366 + if (ret) 367 + return ret; 368 + 369 + return pcf2127_wdt_active_ping(&pcf2127->wdd); 370 + } 371 + 372 + static int pcf2127_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 373 + { 374 + struct pcf2127 *pcf2127 = dev_get_drvdata(dev); 375 + uint8_t buf[5]; 376 + int ret; 377 + 378 + ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL2, 379 + PCF2127_BIT_CTRL2_AF, 0); 380 + if (ret) 381 + return ret; 382 + 383 + ret = pcf2127_wdt_active_ping(&pcf2127->wdd); 384 + if (ret) 385 + return ret; 386 + 387 + buf[0] = bin2bcd(alrm->time.tm_sec); 388 + buf[1] = bin2bcd(alrm->time.tm_min); 389 + buf[2] = bin2bcd(alrm->time.tm_hour); 390 + buf[3] = bin2bcd(alrm->time.tm_mday); 391 + buf[4] = PCF2127_BIT_ALARM_AE; /* Do not match on week day */ 392 + 393 + ret = regmap_bulk_write(pcf2127->regmap, PCF2127_REG_ALARM_SC, buf, 394 + sizeof(buf)); 395 + if (ret) 396 + return ret; 397 + 398 + return pcf2127_rtc_alarm_irq_enable(dev, alrm->enabled); 399 + } 400 + 401 + static irqreturn_t pcf2127_rtc_irq(int irq, void *dev) 402 + { 403 + struct pcf2127 *pcf2127 = dev_get_drvdata(dev); 404 + unsigned int ctrl2 = 0; 405 + int ret = 0; 406 + 407 + ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL2, &ctrl2); 408 + if (ret) 409 + return IRQ_NONE; 410 + 411 + if (!(ctrl2 & PCF2127_BIT_CTRL2_AF)) 412 + return IRQ_NONE; 413 + 414 + regmap_write(pcf2127->regmap, PCF2127_REG_CTRL2, 415 + ctrl2 & ~(PCF2127_BIT_CTRL2_AF | PCF2127_BIT_CTRL2_WDTF)); 416 + 417 + rtc_update_irq(pcf2127->rtc, 1, RTC_IRQF | RTC_AF); 418 + 419 + pcf2127_wdt_active_ping(&pcf2127->wdd); 420 + 421 + return IRQ_HANDLED; 422 + } 423 + 424 + static const struct rtc_class_ops pcf2127_rtc_alrm_ops = { 425 + .ioctl = pcf2127_rtc_ioctl, 426 + .read_time = pcf2127_rtc_read_time, 427 + .set_time = pcf2127_rtc_set_time, 428 + .read_alarm = pcf2127_rtc_read_alarm, 429 + .set_alarm = pcf2127_rtc_set_alarm, 430 + .alarm_irq_enable = pcf2127_rtc_alarm_irq_enable, 431 + }; 432 + 338 433 /* sysfs interface */ 339 434 340 435 static ssize_t timestamp0_store(struct device *dev, ··· 533 416 }; 534 417 535 418 static int pcf2127_probe(struct device *dev, struct regmap *regmap, 536 - const char *name, bool has_nvmem) 419 + int alarm_irq, const char *name, bool has_nvmem) 537 420 { 538 421 struct pcf2127 *pcf2127; 539 422 u32 wdd_timeout; ··· 557 440 pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; 558 441 pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099; 559 442 pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */ 443 + pcf2127->rtc->uie_unsupported = 1; 444 + 445 + if (alarm_irq >= 0) { 446 + ret = devm_request_threaded_irq(dev, alarm_irq, NULL, 447 + pcf2127_rtc_irq, 448 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 449 + dev_name(dev), dev); 450 + if (ret) { 451 + dev_err(dev, "failed to request alarm irq\n"); 452 + return ret; 453 + } 454 + } 455 + 456 + if (alarm_irq >= 0 || device_property_read_bool(dev, "wakeup-source")) { 457 + device_init_wakeup(dev, true); 458 + pcf2127->rtc->ops = &pcf2127_rtc_alrm_ops; 459 + } 560 460 561 461 pcf2127->wdd.parent = dev; 562 462 pcf2127->wdd.info = &pcf2127_wdt_info; ··· 687 553 static const struct of_device_id pcf2127_of_match[] = { 688 554 { .compatible = "nxp,pcf2127" }, 689 555 { .compatible = "nxp,pcf2129" }, 556 + { .compatible = "nxp,pca2129" }, 690 557 {} 691 558 }; 692 559 MODULE_DEVICE_TABLE(of, pcf2127_of_match); ··· 792 657 return PTR_ERR(regmap); 793 658 } 794 659 795 - return pcf2127_probe(&client->dev, regmap, 660 + return pcf2127_probe(&client->dev, regmap, client->irq, 796 661 pcf2127_i2c_driver.driver.name, id->driver_data); 797 662 } 798 663 799 664 static const struct i2c_device_id pcf2127_i2c_id[] = { 800 665 { "pcf2127", 1 }, 801 666 { "pcf2129", 0 }, 667 + { "pca2129", 0 }, 802 668 { } 803 669 }; 804 670 MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id); ··· 858 722 return PTR_ERR(regmap); 859 723 } 860 724 861 - return pcf2127_probe(&spi->dev, regmap, pcf2127_spi_driver.driver.name, 725 + return pcf2127_probe(&spi->dev, regmap, spi->irq, 726 + pcf2127_spi_driver.driver.name, 862 727 spi_get_device_id(spi)->driver_data); 863 728 } 864 729 865 730 static const struct spi_device_id pcf2127_spi_id[] = { 866 731 { "pcf2127", 1 }, 867 732 { "pcf2129", 0 }, 733 + { "pca2129", 0 }, 868 734 { } 869 735 }; 870 736 MODULE_DEVICE_TABLE(spi, pcf2127_spi_id);
+2 -2
drivers/rtc/rtc-pcf85063.c
··· 21 21 /* 22 22 * Information for this driver was pulled from the following datasheets. 23 23 * 24 - * http://www.nxp.com/documents/data_sheet/PCF85063A.pdf 25 - * http://www.nxp.com/documents/data_sheet/PCF85063TP.pdf 24 + * https://www.nxp.com/documents/data_sheet/PCF85063A.pdf 25 + * https://www.nxp.com/documents/data_sheet/PCF85063TP.pdf 26 26 * 27 27 * PCF85063A -- Rev. 6 — 18 November 2015 28 28 * PCF85063TP -- Rev. 4 — 6 May 2015
+1
drivers/rtc/rtc-pl031.c
··· 275 275 struct pl031_local *ldata = dev_get_drvdata(dev); 276 276 277 277 writel(rtc_tm_to_time64(&alarm->time), ldata->base + RTC_MR); 278 + pl031_alarm_irq_enable(dev, alarm->enabled); 278 279 279 280 return 0; 280 281 }
-4
include/linux/rtc.h
··· 55 55 * 56 56 * The (current) exceptions are mostly filesystem hooks: 57 57 * - the proc() hook for procfs 58 - * - non-ioctl() chardev hooks: open(), release() 59 - * 60 - * REVISIT those periodic irq calls *do* have ops_lock when they're 61 - * issued through ioctl() ... 62 58 */ 63 59 struct rtc_class_ops { 64 60 int (*ioctl)(struct device *, unsigned int, unsigned long);