add support for RV8063 SPI rtc
Subsystems (2)
v4 cover add support for RV8063 SPI rtc
This patch series adds support for the Microcrystal RV8063 real time clock module with SPI interface. This device is very similar to RV8263 (which however uses I2C), so I decided to extend the existing driver instead of creating a new one.
RV8063 datasheet: https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-8063-C7_App-Manual.pdf
---
Changes since v3:
* dt-binding: fix indentation in spi example
* pcf85063 driver: add of_match_table
Changes since v2:
* dt-binding: send as patch 1/3, not patch 3/3
* dt-binding: fix indentation in spi example
* dt-binding: fix order of enums: rv8063 before rv8263
Changes since v1:
* pcf85063 driver: drop MODULE_ALIAS, add id_table
* dt-binding: add "pcf85063" to the commit message
Antoni Pokusinski (3):
dt-bindings: rtc: pcf85063: add binding for RV8063
rtc: pcf85063: create pcf85063_i2c_probe
rtc: pcf85063: add support for RV8063
.../devicetree/bindings/rtc/nxp,pcf85063.yaml | 33 +++- drivers/rtc/Kconfig | 21 +- drivers/rtc/rtc-pcf85063.c | 182 +++++++++++++++--- 3 files changed, 199 insertions(+), 37 deletions(-)
Signature · 1 line
2.25.1
PATCH RESEND v4 1/3 dt-bindings: rtc: pcf85063: add binding for RV8063
Microcrystal RV8063 is a real-time clock module with SPI interface.
--- .../devicetree/bindings/rtc/nxp,pcf85063.yaml | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/rtc/nxp,pcf85063.yaml +32 -1
@@ -12,6 +12,7 @@ maintainers: properties: compatible: enum: + - microcrystal,rv8063 - microcrystal,rv8263 - nxp,pcf85063 - nxp,pcf85063a
@@ -44,13 +45,19 @@ properties: wakeup-source: true + spi-cs-high: true + + spi-3wire: true + allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# - $ref: rtc.yaml# - if: properties: compatible: contains: enum: + - microcrystal,rv8063 - microcrystal,rv8263 then: properties:
@@ -65,12 +72,23 @@ allOf: properties: quartz-load-femtofarads: const: 7000 + - if: + properties: + compatible: + not: + contains: + enum: + - microcrystal,rv8063 + then: + properties: + spi-cs-high: false + spi-3wire: false required: - compatible - reg -additionalProperties: false +unevaluatedProperties: false examples: - |
@@ -90,3 +108,16 @@ examples: }; }; }; + + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + rtc@0 { + compatible = "microcrystal,rv8063"; + reg = <0>; + spi-cs-high; + spi-3wire; + }; + };
Signature · 1 line
2.25.1
PATCH RESEND v4 2/3 rtc: pcf85063: create pcf85063_i2c_probe
In reply to Antoni PokusinskiMove the i2c-specific code from pcf85063_probe to the newly created function.
This is a preparation for introducing the support for RV8063 real-time clock with SPI interface.
--- drivers/rtc/rtc-pcf85063.c | 97 +++++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 27 deletions(-)
drivers/rtc/rtc-pcf85063.c +70 -27
@@ -559,12 +559,12 @@ static const struct pcf85063_config config_rv8263 = { .force_cap_7000 = 1, }; -static int pcf85063_probe (struct i2c_client *client) +static int pcf85063_probe (struct device *dev,struct regmap *regmap,int irq, +const struct pcf85063_config *config) {struct pcf85063 *pcf85063;unsigned int tmp;int err; -const struct pcf85063_config *config;struct nvmem_config nvmem_cfg = { .name ="pcf85063_nvram" , .reg_read = pcf85063_nvmem_read,
@@ -573,28 +573,22 @@ static int pcf85063_probe(struct i2c_client *client) .size = 1, }; -dev_dbg (&client->dev,"%s\n" , __func__); +dev_dbg (dev,"%s\n" , __func__); - pcf85063 =devm_kzalloc (&client->dev,sizeof (struct pcf85063 ), + pcf85063 =devm_kzalloc (dev,sizeof (struct pcf85063 ),GFP_KERNEL );if (!pcf85063)return -ENOMEM ; - config =i2c_get_match_data (client); -if (!config) -return -ENODEV ; - - pcf85063->regmap =devm_regmap_init_i2c (client, &config->regmap); -if (IS_ERR (pcf85063->regmap)) -return PTR_ERR (pcf85063->regmap); + pcf85063->regmap = regmap; -i2c_set_clientdata (client, pcf85063); +dev_set_drvdata (dev, pcf85063); err =regmap_read (pcf85063->regmap,PCF85063_REG_SC , &tmp);if (err) -return dev_err_probe (&client->dev, err,"RTC chip is not present\n" ); +return dev_err_probe (dev, err,"RTC chip is not present\n" ); - pcf85063->rtc =devm_rtc_allocate_device (&client->dev); + pcf85063->rtc =devm_rtc_allocate_device (dev);if (IS_ERR (pcf85063->rtc))return PTR_ERR (pcf85063->rtc);
@@ -605,19 +599,17 @@ static int pcf85063_probe(struct i2c_client *client)* of the registers after the automatic power-on reset... */ if (tmp &PCF85063_REG_SC_OS ) { -dev_warn (&client->dev, -"POR issue detected, sending a SW reset\n" ); +dev_warn (dev,"POR issue detected, sending a SW reset\n" ); err =regmap_write (pcf85063->regmap,PCF85063_REG_CTRL1 ,PCF85063_REG_CTRL1_SWR );if (err <0 ) -dev_warn (&client->dev, -"SW reset failed, trying to continue\n" ); +dev_warn (dev,"SW reset failed, trying to continue\n" ); } - err =pcf85063_load_capacitance (pcf85063, client->dev.of_node, + err =pcf85063_load_capacitance (pcf85063, dev->of_node, config->force_cap_7000 ?7000 :0 );if (err <0 ) -dev_warn (&client->dev,"failed to set xtal load capacitance: %d" , +dev_warn (dev,"failed to set xtal load capacitance: %d" , err); pcf85063->rtc->ops = &pcf85063_rtc_ops;
@@ -627,13 +619,13 @@ static int pcf85063_probe(struct i2c_client *client)clear_bit (RTC_FEATURE_UPDATE_INTERRUPT , pcf85063->rtc->features);clear_bit (RTC_FEATURE_ALARM , pcf85063->rtc->features); -if (config->has_alarms && client->irq >0 ) { +if (config->has_alarms && irq >0 ) {unsigned long irqflags =IRQF_TRIGGER_LOW ; -if (dev_fwnode (&client->dev)) +if (dev_fwnode (dev)) irqflags =0 ; - err =devm_request_threaded_irq (&client->dev, client->irq, + err =devm_request_threaded_irq (dev, irq,NULL , pcf85063_rtc_handle_irq, irqflags |IRQF_ONESHOT ,"pcf85063" , pcf85063);
@@ -642,8 +634,8 @@ static int pcf85063_probe(struct i2c_client *client) "unable to request IRQ, alarms disabled\n"); }else {set_bit (RTC_FEATURE_ALARM , pcf85063->rtc->features); -device_init_wakeup (&client->dev, true); - err =dev_pm_set_wake_irq (&client->dev, client->irq); +device_init_wakeup (dev, true); + err =dev_pm_set_wake_irq (dev, irq);if (err)dev_err (&pcf85063->rtc->dev,"failed to enable irq wake\n" );
@@ -661,6 +653,8 @@ static int pcf85063_probe(struct i2c_client *client)return devm_rtc_register_device (pcf85063->rtc); } +#if IS_ENABLED (CONFIG_I2C ) +static const struct i2c_device_id pcf85063_ids[] = { {"pca85073a" , .driver_data = (kernel_ulong_t)&config_pcf85063a }, { "pcf85063", .driver_data = (kernel_ulong_t)&config_pcf85063 },
@@ -683,16 +677,65 @@ static const struct of_device_id pcf85063_of_match[] = {MODULE_DEVICE_TABLE (of, pcf85063_of_match);#endif +static int pcf85063_i2c_probe (struct i2c_client *client) +{ +const struct pcf85063_config *config; +struct regmap *regmap; + + config =i2c_get_match_data (client); +if (!config) +return -ENODEV ; + + regmap =devm_regmap_init_i2c (client, &config->regmap); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +return pcf85063_probe (&client->dev, regmap, client->irq, config); +} +static struct i2c_driver pcf85063_driver = { .driver = { .name ="rtc-pcf85063" , .of_match_table =of_match_ptr (pcf85063_of_match), }, - .probe = pcf85063_probe, + .probe = pcf85063_i2c_probe, .id_table = pcf85063_ids, }; -module_i2c_driver (pcf85063_driver); +static int pcf85063_register_driver (void ) +{ +return i2c_add_driver (&pcf85063_driver); +} + +static void pcf85063_unregister_driver (void ) +{ +i2c_del_driver (&pcf85063_driver); +} + +#else + +static int pcf85063_register_driver (void ) +{ +return 0 ; +} + +static void pcf85063_unregister_driver (void ) +{ +} + +#endif /* IS_ENABLED(CONFIG_I2C) */ + +static int __init pcf85063_init (void ) +{ +return pcf85063_register_driver (); +} +module_init (pcf85063_init); + +static void __exit pcf85063_exit(void) +{ +pcf85063_unregister_driver (); +} +module_exit (pcf85063_exit);MODULE_AUTHOR ("Søren Andersen <[email protected]>" );MODULE_DESCRIPTION ("PCF85063 RTC driver" );
Signature · 1 line
2.25.1
PATCH RESEND v4 3/3 rtc: pcf85063: add support for RV8063
In reply to Antoni PokusinskiMicrocrystal RV8063 is a real-time clock with SPI interface. Its functionality is very similar to the RV8263 rtc.
--- drivers/rtc/Kconfig | 21 +++++---- drivers/rtc/rtc-pcf85063.c | 87 +++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 10 deletions(-)
drivers/rtc/Kconfig +12 -9
@@ -483,15 +483,6 @@ config RTC_DRV_PCF8523 This driver can also be built as a module. If so, the module will be called rtc-pcf8523. -config RTC_DRV_PCF85063 - tristate "NXP PCF85063" - select REGMAP_I2C - help - If you say yes here you get support for the PCF85063 RTC chip - - This driver can also be built as a module. If so, the module - will be called rtc-pcf85063. - config RTC_DRV_PCF85363 tristate "NXP PCF85363" select REGMAP_I2C
@@ -971,6 +962,18 @@ config RTC_DRV_PCF2127 This driver can also be built as a module. If so, the module will be called rtc-pcf2127. +config RTC_DRV_PCF85063 + tristate "NXP PCF85063" + depends on RTC_I2C_AND_SPI + select REGMAP_I2C if I2C + select REGMAP_SPI if SPI_MASTER + help + If you say yes here you get support for the PCF85063 and RV8063 + RTC chips. + + This driver can also be built as a module. If so, the module + will be called rtc-pcf85063. + config RTC_DRV_RV3029C2 tristate "Micro Crystal RV3029/3049" depends on RTC_I2C_AND_SPI
drivers/rtc/rtc-pcf85063.c +86 -1
118 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH RESEND v4 3/3] rtc: pcf85063: add support for RV8063
Hello,
Since there was no feedback for this patch I'd like to send a reminder here. Is there a chance that this patch series will get integrated into the mainline?
Kind regards,
Antoni Pokusinski
Quoted 177 lines · Antoni Pokusinski
Microcrystal RV8063 is a real-time clock with SPI interface. Its functionality is very similar to the RV8263 rtc.
Signed-off-by Antoni Pokusinski <[email protected]>--- drivers/rtc/Kconfig | 21 +++++---- drivers/rtc/rtc-pcf85063.c | 87 +++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 10 deletions(-)drivers/rtc/Kconfig +12
-9@@ -483,15 +483,6 @@ config RTC_DRV_PCF8523 This driver can also be built as a module. If so, the module will be called rtc-pcf8523. -config RTC_DRV_PCF85063 - tristate "NXP PCF85063" - select REGMAP_I2C - help - If you say yes here you get support for the PCF85063 RTC chip - - This driver can also be built as a module. If so, the module - will be called rtc-pcf85063. - config RTC_DRV_PCF85363 tristate "NXP PCF85363" select REGMAP_I2C@@ -971,6 +962,18 @@ config RTC_DRV_PCF2127 This driver can also be built as a module. If so, the module will be called rtc-pcf2127. +config RTC_DRV_PCF85063 + tristate "NXP PCF85063" + depends on RTC_I2C_AND_SPI + select REGMAP_I2C if I2C + select REGMAP_SPI if SPI_MASTER + help + If you say yes here you get support for the PCF85063 and RV8063 + RTC chips. + + This driver can also be built as a module. If so, the module + will be called rtc-pcf85063. + config RTC_DRV_RV3029C2 tristate "Micro Crystal RV3029/3049" depends on RTC_I2C_AND_SPIdrivers/rtc/rtc-pcf85063.c +86
-1@@ -17,6 +17,7 @@#include <linux/of.h> #include <linux/pm_wakeirq.h> #include <linux/regmap.h> +#include <linux/spi/spi.h> /* * Information for this driver was pulled from the following datasheets. @@ -29,6 +30,9 @@* * https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-8263-C7_App-Manual.pdf * RV8263 -- Rev. 1.0 — January 2019 +* +* https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-8063-C7_App-Manual.pdf +* RV8063 -- Rev. 1.1 - October 2018 */ #define PCF85063_REG_CTRL1 0x00/* status */ @@ -559,6 +563,18 @@ static const struct pcf85063_config config_rv8263 = { .force_cap_7000 = 1, }; +static const struct pcf85063_config config_rv8063 = { + .regmap = { + .reg_bits =8 , + .val_bits =8 , + .max_register =0x11 , + .read_flag_mask =BIT (7 ) |BIT (5 ), + .write_flag_mask =BIT (5 ), + }, + .has_alarms =1 , + .force_cap_7000 =1 , +}; +static int pcf85063_probe (struct device *dev,struct regmap *regmap,int irq,const struct pcf85063_config *config) {@@ -725,14 +741,83 @@ static void pcf85063_unregister_driver(void)#endif /* IS_ENABLED(CONFIG_I2C) */ +#if IS_ENABLED (CONFIG_SPI_MASTER ) + +static const struct spi_device_id rv8063_id[] = { + {"rv8063" }, + {} +}; +MODULE_DEVICE_TABLE (spi, rv8063_id); + +static const struct of_device_id rv8063_of_match[] = { + { .compatible ="microcrystal,rv8063" }, + {} +}; +MODULE_DEVICE_TABLE (of, rv8063_of_match); + +static int rv8063_probe (struct spi_device *spi) +{ +const struct pcf85063_config *config = &config_rv8063; +struct regmap *regmap; + + regmap =devm_regmap_init_spi (spi, &config->regmap); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +return pcf85063_probe (&spi->dev, regmap, spi->irq, config); +} + +static struct spi_driver rv8063_driver = { + .driver = { + .name ="rv8063" , + .of_match_table = rv8063_of_match, + }, + .probe = rv8063_probe, + .id_table = rv8063_id, +}; + +static int __init rv8063_register_driver (void ) +{ +return spi_register_driver (&rv8063_driver); +} + +static void __exit rv8063_unregister_driver(void) +{ +spi_unregister_driver (&rv8063_driver); +} + +#else + +static int __init rv8063_register_driver (void ) +{ +return 0 ; +} + +static void __exit rv8063_unregister_driver(void) +{ +} + +#endif /* IS_ENABLED(CONFIG_SPI_MASTER) */ +static int __init pcf85063_init (void ) { -return pcf85063_register_driver (); +int ret; + + ret =pcf85063_register_driver (); +if (ret) +return ret; + + ret =rv8063_register_driver (); +if (ret) +pcf85063_unregister_driver (); + +return ret; }module_init (pcf85063_init); static void __exit pcf85063_exit(void) { +rv8063_unregister_driver ();pcf85063_unregister_driver (); }module_exit (pcf85063_exit);Signature · 1 line
2.25.1