diff options
author | Mylène Josserand <mylene.josserand@free-electrons.com> | 2016-05-03 05:54:34 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2016-05-21 11:06:52 -0400 |
commit | c2a1c145401df063d1197ace5d3b5bd323e26f86 (patch) | |
tree | b2da82521e97d411b442c9871ed62fa3545e7e9c /drivers/rtc | |
parent | e6e380821236b628a1379db97d777da3e36b8240 (diff) |
rtc: rv3029: Add support of RV3049
Add support of Microcrystal RV3049 RTC (SPI) using regmap on the
RV3029 (I2C) driver.
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 37 | ||||
-rw-r--r-- | drivers/rtc/rtc-rv3029c2.c | 108 |
2 files changed, 124 insertions, 21 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index f1e1f502be5d..18639e0cb6e2 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -573,24 +573,6 @@ config RTC_DRV_EM3027 | |||
573 | This driver can also be built as a module. If so, the module | 573 | This driver can also be built as a module. If so, the module |
574 | will be called rtc-em3027. | 574 | will be called rtc-em3027. |
575 | 575 | ||
576 | config RTC_DRV_RV3029C2 | ||
577 | tristate "Micro Crystal RV3029" | ||
578 | help | ||
579 | If you say yes here you get support for the Micro Crystal | ||
580 | RV3029 RTC chips. | ||
581 | |||
582 | This driver can also be built as a module. If so, the module | ||
583 | will be called rtc-rv3029c2. | ||
584 | |||
585 | config RTC_DRV_RV3029_HWMON | ||
586 | bool "HWMON support for RV3029" | ||
587 | depends on RTC_DRV_RV3029C2 && HWMON | ||
588 | depends on !(RTC_DRV_RV3029C2=y && HWMON=m) | ||
589 | default y | ||
590 | help | ||
591 | Say Y here if you want to expose temperature sensor data on | ||
592 | rtc-rv3029. | ||
593 | |||
594 | config RTC_DRV_RV8803 | 576 | config RTC_DRV_RV8803 |
595 | tristate "Micro Crystal RV8803" | 577 | tristate "Micro Crystal RV8803" |
596 | help | 578 | help |
@@ -786,6 +768,25 @@ config RTC_DRV_PCF2127 | |||
786 | This driver can also be built as a module. If so, the module | 768 | This driver can also be built as a module. If so, the module |
787 | will be called rtc-pcf2127. | 769 | will be called rtc-pcf2127. |
788 | 770 | ||
771 | config RTC_DRV_RV3029C2 | ||
772 | tristate "Micro Crystal RV3029/3049" | ||
773 | depends on RTC_I2C_AND_SPI | ||
774 | help | ||
775 | If you say yes here you get support for the Micro Crystal | ||
776 | RV3029 and RV3049 RTC chips. | ||
777 | |||
778 | This driver can also be built as a module. If so, the module | ||
779 | will be called rtc-rv3029c2. | ||
780 | |||
781 | config RTC_DRV_RV3029_HWMON | ||
782 | bool "HWMON support for RV3029/3049" | ||
783 | depends on RTC_DRV_RV3029C2 && HWMON | ||
784 | depends on !(RTC_DRV_RV3029C2=y && HWMON=m) | ||
785 | default y | ||
786 | help | ||
787 | Say Y here if you want to expose temperature sensor data on | ||
788 | rtc-rv3029. | ||
789 | |||
789 | comment "Platform RTC drivers" | 790 | comment "Platform RTC drivers" |
790 | 791 | ||
791 | # this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h> | 792 | # this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h> |
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c index 96dd1665220c..1310646a4821 100644 --- a/drivers/rtc/rtc-rv3029c2.c +++ b/drivers/rtc/rtc-rv3029c2.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Micro Crystal RV-3029 rtc class driver | 2 | * Micro Crystal RV-3029 / RV-3049 rtc class driver |
3 | * | 3 | * |
4 | * Author: Gregory Hermant <gregory.hermant@calao-systems.com> | 4 | * Author: Gregory Hermant <gregory.hermant@calao-systems.com> |
5 | * Michael Buesch <m@bues.ch> | 5 | * Michael Buesch <m@bues.ch> |
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
17 | #include <linux/spi/spi.h> | ||
17 | #include <linux/bcd.h> | 18 | #include <linux/bcd.h> |
18 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
19 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
@@ -766,6 +767,8 @@ static int rv3029_probe(struct device *dev, struct regmap *regmap, int irq, | |||
766 | return PTR_ERR_OR_ZERO(rv3029->rtc); | 767 | return PTR_ERR_OR_ZERO(rv3029->rtc); |
767 | } | 768 | } |
768 | 769 | ||
770 | #if IS_ENABLED(CONFIG_I2C) | ||
771 | |||
769 | static int rv3029_i2c_probe(struct i2c_client *client, | 772 | static int rv3029_i2c_probe(struct i2c_client *client, |
770 | const struct i2c_device_id *id) | 773 | const struct i2c_device_id *id) |
771 | { | 774 | { |
@@ -799,9 +802,108 @@ static struct i2c_driver rv3029_driver = { | |||
799 | .id_table = rv3029_id, | 802 | .id_table = rv3029_id, |
800 | }; | 803 | }; |
801 | 804 | ||
802 | module_i2c_driver(rv3029_driver); | 805 | static int rv3029_register_driver(void) |
806 | { | ||
807 | return i2c_add_driver(&rv3029_driver); | ||
808 | } | ||
809 | |||
810 | static void rv3029_unregister_driver(void) | ||
811 | { | ||
812 | i2c_del_driver(&rv3029_driver); | ||
813 | } | ||
814 | |||
815 | #else | ||
816 | |||
817 | static int rv3029_register_driver(void) | ||
818 | { | ||
819 | return 0; | ||
820 | } | ||
821 | |||
822 | static void rv3029_unregister_driver(void) | ||
823 | { | ||
824 | } | ||
825 | |||
826 | #endif | ||
827 | |||
828 | #if IS_ENABLED(CONFIG_SPI_MASTER) | ||
829 | |||
830 | static int rv3049_probe(struct spi_device *spi) | ||
831 | { | ||
832 | static const struct regmap_config config = { | ||
833 | .reg_bits = 8, | ||
834 | .val_bits = 8, | ||
835 | }; | ||
836 | struct regmap *regmap; | ||
837 | |||
838 | regmap = devm_regmap_init_spi(spi, &config); | ||
839 | if (IS_ERR(regmap)) { | ||
840 | dev_err(&spi->dev, "%s: regmap allocation failed: %ld\n", | ||
841 | __func__, PTR_ERR(regmap)); | ||
842 | return PTR_ERR(regmap); | ||
843 | } | ||
844 | |||
845 | return rv3029_probe(&spi->dev, regmap, spi->irq, "rv3049"); | ||
846 | } | ||
847 | |||
848 | static struct spi_driver rv3049_driver = { | ||
849 | .driver = { | ||
850 | .name = "rv3049", | ||
851 | }, | ||
852 | .probe = rv3049_probe, | ||
853 | }; | ||
854 | |||
855 | static int rv3049_register_driver(void) | ||
856 | { | ||
857 | return spi_register_driver(&rv3049_driver); | ||
858 | } | ||
859 | |||
860 | static void rv3049_unregister_driver(void) | ||
861 | { | ||
862 | spi_unregister_driver(&rv3049_driver); | ||
863 | } | ||
864 | |||
865 | #else | ||
866 | |||
867 | static int rv3049_register_driver(void) | ||
868 | { | ||
869 | return 0; | ||
870 | } | ||
871 | |||
872 | static void rv3049_unregister_driver(void) | ||
873 | { | ||
874 | } | ||
875 | |||
876 | #endif | ||
877 | |||
878 | static int __init rv30x9_init(void) | ||
879 | { | ||
880 | int ret; | ||
881 | |||
882 | ret = rv3029_register_driver(); | ||
883 | if (ret) { | ||
884 | pr_err("Failed to register rv3029 driver: %d\n", ret); | ||
885 | return ret; | ||
886 | } | ||
887 | |||
888 | ret = rv3049_register_driver(); | ||
889 | if (ret) { | ||
890 | pr_err("Failed to register rv3049 driver: %d\n", ret); | ||
891 | rv3029_unregister_driver(); | ||
892 | } | ||
893 | |||
894 | return ret; | ||
895 | } | ||
896 | module_init(rv30x9_init) | ||
897 | |||
898 | static void __exit rv30x9_exit(void) | ||
899 | { | ||
900 | rv3049_unregister_driver(); | ||
901 | rv3029_unregister_driver(); | ||
902 | } | ||
903 | module_exit(rv30x9_exit) | ||
803 | 904 | ||
804 | MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>"); | 905 | MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>"); |
805 | MODULE_AUTHOR("Michael Buesch <m@bues.ch>"); | 906 | MODULE_AUTHOR("Michael Buesch <m@bues.ch>"); |
806 | MODULE_DESCRIPTION("Micro Crystal RV3029 RTC driver"); | 907 | MODULE_DESCRIPTION("Micro Crystal RV3029/RV3049 RTC driver"); |
807 | MODULE_LICENSE("GPL"); | 908 | MODULE_LICENSE("GPL"); |
909 | MODULE_ALIAS("spi:rv3049"); | ||