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

Configure Feed

Select the types of activity you want to include in your feed.

rtc: pcf85063: add support for RV8063

Microcrystal RV8063 is a real-time clock with SPI interface. Its
functionality is very similar to the RV8263 rtc.

Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
Link: https://lore.kernel.org/r/20250413130755.159373-4-apokusinski01@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Antoni Pokusinski and committed by
Alexandre Belloni
a3c7f7e1 29ac4ced

+98 -10
+12 -9
drivers/rtc/Kconfig
··· 483 483 This driver can also be built as a module. If so, the module 484 484 will be called rtc-pcf8523. 485 485 486 - config RTC_DRV_PCF85063 487 - tristate "NXP PCF85063" 488 - select REGMAP_I2C 489 - help 490 - If you say yes here you get support for the PCF85063 RTC chip 491 - 492 - This driver can also be built as a module. If so, the module 493 - will be called rtc-pcf85063. 494 - 495 486 config RTC_DRV_PCF85363 496 487 tristate "NXP PCF85363" 497 488 select REGMAP_I2C ··· 961 970 962 971 This driver can also be built as a module. If so, the module 963 972 will be called rtc-pcf2127. 973 + 974 + config RTC_DRV_PCF85063 975 + tristate "NXP PCF85063" 976 + depends on RTC_I2C_AND_SPI 977 + select REGMAP_I2C if I2C 978 + select REGMAP_SPI if SPI_MASTER 979 + help 980 + If you say yes here you get support for the PCF85063 and RV8063 981 + RTC chips. 982 + 983 + This driver can also be built as a module. If so, the module 984 + will be called rtc-pcf85063. 964 985 965 986 config RTC_DRV_RV3029C2 966 987 tristate "Micro Crystal RV3029/3049"
+86 -1
drivers/rtc/rtc-pcf85063.c
··· 17 17 #include <linux/of.h> 18 18 #include <linux/pm_wakeirq.h> 19 19 #include <linux/regmap.h> 20 + #include <linux/spi/spi.h> 20 21 21 22 /* 22 23 * Information for this driver was pulled from the following datasheets. ··· 30 29 * 31 30 * https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-8263-C7_App-Manual.pdf 32 31 * RV8263 -- Rev. 1.0 — January 2019 32 + * 33 + * https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-8063-C7_App-Manual.pdf 34 + * RV8063 -- Rev. 1.1 - October 2018 33 35 */ 34 36 35 37 #define PCF85063_REG_CTRL1 0x00 /* status */ ··· 563 559 .force_cap_7000 = 1, 564 560 }; 565 561 562 + static const struct pcf85063_config config_rv8063 = { 563 + .regmap = { 564 + .reg_bits = 8, 565 + .val_bits = 8, 566 + .max_register = 0x11, 567 + .read_flag_mask = BIT(7) | BIT(5), 568 + .write_flag_mask = BIT(5), 569 + }, 570 + .has_alarms = 1, 571 + .force_cap_7000 = 1, 572 + }; 573 + 566 574 static int pcf85063_probe(struct device *dev, struct regmap *regmap, int irq, 567 575 const struct pcf85063_config *config) 568 576 { ··· 741 725 742 726 #endif /* IS_ENABLED(CONFIG_I2C) */ 743 727 728 + #if IS_ENABLED(CONFIG_SPI_MASTER) 729 + 730 + static const struct spi_device_id rv8063_id[] = { 731 + { "rv8063" }, 732 + {} 733 + }; 734 + MODULE_DEVICE_TABLE(spi, rv8063_id); 735 + 736 + static const struct of_device_id rv8063_of_match[] = { 737 + { .compatible = "microcrystal,rv8063" }, 738 + {} 739 + }; 740 + MODULE_DEVICE_TABLE(of, rv8063_of_match); 741 + 742 + static int rv8063_probe(struct spi_device *spi) 743 + { 744 + const struct pcf85063_config *config = &config_rv8063; 745 + struct regmap *regmap; 746 + 747 + regmap = devm_regmap_init_spi(spi, &config->regmap); 748 + if (IS_ERR(regmap)) 749 + return PTR_ERR(regmap); 750 + 751 + return pcf85063_probe(&spi->dev, regmap, spi->irq, config); 752 + } 753 + 754 + static struct spi_driver rv8063_driver = { 755 + .driver = { 756 + .name = "rv8063", 757 + .of_match_table = rv8063_of_match, 758 + }, 759 + .probe = rv8063_probe, 760 + .id_table = rv8063_id, 761 + }; 762 + 763 + static int __init rv8063_register_driver(void) 764 + { 765 + return spi_register_driver(&rv8063_driver); 766 + } 767 + 768 + static void __exit rv8063_unregister_driver(void) 769 + { 770 + spi_unregister_driver(&rv8063_driver); 771 + } 772 + 773 + #else 774 + 775 + static int __init rv8063_register_driver(void) 776 + { 777 + return 0; 778 + } 779 + 780 + static void __exit rv8063_unregister_driver(void) 781 + { 782 + } 783 + 784 + #endif /* IS_ENABLED(CONFIG_SPI_MASTER) */ 785 + 744 786 static int __init pcf85063_init(void) 745 787 { 746 - return pcf85063_register_driver(); 788 + int ret; 789 + 790 + ret = pcf85063_register_driver(); 791 + if (ret) 792 + return ret; 793 + 794 + ret = rv8063_register_driver(); 795 + if (ret) 796 + pcf85063_unregister_driver(); 797 + 798 + return ret; 747 799 } 748 800 module_init(pcf85063_init); 749 801 750 802 static void __exit pcf85063_exit(void) 751 803 { 804 + rv8063_unregister_driver(); 752 805 pcf85063_unregister_driver(); 753 806 } 754 807 module_exit(pcf85063_exit);