* [PATCH v4 0/3] add support for RV8063 SPI rtc
@ 2025-04-13 13:07 Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 1/3] dt-bindings: rtc: pcf85063: add binding for RV8063 Antoni Pokusinski
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Antoni Pokusinski @ 2025-04-13 13:07 UTC (permalink / raw)
To: alexandre.belloni, krzk+dt, conor+dt, robh, alexander.stein
Cc: linux-rtc, linux-kernel, devicetree, Antoni Pokusinski
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(-)
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/3] dt-bindings: rtc: pcf85063: add binding for RV8063
2025-04-13 13:07 [PATCH v4 0/3] add support for RV8063 SPI rtc Antoni Pokusinski
@ 2025-04-13 13:07 ` Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 2/3] rtc: pcf85063: create pcf85063_i2c_probe Antoni Pokusinski
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Antoni Pokusinski @ 2025-04-13 13:07 UTC (permalink / raw)
To: alexandre.belloni, krzk+dt, conor+dt, robh, alexander.stein
Cc: linux-rtc, linux-kernel, devicetree, Antoni Pokusinski
Microcrystal RV8063 is a real-time clock module with SPI interface.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
---
.../devicetree/bindings/rtc/nxp,pcf85063.yaml | 33 ++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/rtc/nxp,pcf85063.yaml b/Documentation/devicetree/bindings/rtc/nxp,pcf85063.yaml
index 2f892f8640d1..1e6277e524c2 100644
--- a/Documentation/devicetree/bindings/rtc/nxp,pcf85063.yaml
+++ b/Documentation/devicetree/bindings/rtc/nxp,pcf85063.yaml
@@ -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;
+ };
+ };
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/3] rtc: pcf85063: create pcf85063_i2c_probe
2025-04-13 13:07 [PATCH v4 0/3] add support for RV8063 SPI rtc Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 1/3] dt-bindings: rtc: pcf85063: add binding for RV8063 Antoni Pokusinski
@ 2025-04-13 13:07 ` Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 3/3] rtc: pcf85063: add support for RV8063 Antoni Pokusinski
2025-07-23 16:54 ` [PATCH v4 0/3] add support for RV8063 SPI rtc Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Antoni Pokusinski @ 2025-04-13 13:07 UTC (permalink / raw)
To: alexandre.belloni, krzk+dt, conor+dt, robh, alexander.stein
Cc: linux-rtc, linux-kernel, devicetree, Antoni Pokusinski
Move 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.
Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
---
drivers/rtc/rtc-pcf85063.c | 97 +++++++++++++++++++++++++++-----------
1 file changed, 70 insertions(+), 27 deletions(-)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 4fa5c4ecdd5a..03dfc58f4cd7 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -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 <san@rosetechnology.dk>");
MODULE_DESCRIPTION("PCF85063 RTC driver");
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 3/3] rtc: pcf85063: add support for RV8063
2025-04-13 13:07 [PATCH v4 0/3] add support for RV8063 SPI rtc Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 1/3] dt-bindings: rtc: pcf85063: add binding for RV8063 Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 2/3] rtc: pcf85063: create pcf85063_i2c_probe Antoni Pokusinski
@ 2025-04-13 13:07 ` Antoni Pokusinski
2025-07-23 16:54 ` [PATCH v4 0/3] add support for RV8063 SPI rtc Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Antoni Pokusinski @ 2025-04-13 13:07 UTC (permalink / raw)
To: alexandre.belloni, krzk+dt, conor+dt, robh, alexander.stein
Cc: linux-rtc, linux-kernel, devicetree, 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 <apokusinski01@gmail.com>
---
drivers/rtc/Kconfig | 21 +++++----
drivers/rtc/rtc-pcf85063.c | 87 +++++++++++++++++++++++++++++++++++++-
2 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 838bdc138ffe..1b9be96faa13 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -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
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 03dfc58f4cd7..d9b67b959d18 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -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);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 0/3] add support for RV8063 SPI rtc
2025-04-13 13:07 [PATCH v4 0/3] add support for RV8063 SPI rtc Antoni Pokusinski
` (2 preceding siblings ...)
2025-04-13 13:07 ` [PATCH v4 3/3] rtc: pcf85063: add support for RV8063 Antoni Pokusinski
@ 2025-07-23 16:54 ` Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2025-07-23 16:54 UTC (permalink / raw)
To: krzk+dt, conor+dt, robh, alexander.stein, Antoni Pokusinski
Cc: linux-rtc, linux-kernel, devicetree
On Sun, 13 Apr 2025 15:07:52 +0200, Antoni Pokusinski wrote:
> 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
>
> [...]
Applied, thanks!
[1/3] dt-bindings: rtc: pcf85063: add binding for RV8063
https://git.kernel.org/abelloni/c/b265cb1d68a9
[2/3] rtc: pcf85063: create pcf85063_i2c_probe
https://git.kernel.org/abelloni/c/29ac4cedb00e
[3/3] rtc: pcf85063: add support for RV8063
https://git.kernel.org/abelloni/c/a3c7f7e16ea8
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-23 16:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-13 13:07 [PATCH v4 0/3] add support for RV8063 SPI rtc Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 1/3] dt-bindings: rtc: pcf85063: add binding for RV8063 Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 2/3] rtc: pcf85063: create pcf85063_i2c_probe Antoni Pokusinski
2025-04-13 13:07 ` [PATCH v4 3/3] rtc: pcf85063: add support for RV8063 Antoni Pokusinski
2025-07-23 16:54 ` [PATCH v4 0/3] add support for RV8063 SPI rtc Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).