From: Antoni Pokusinski <apokusinski01@gmail.com>
To: alexandre.belloni@bootlin.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org
Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org,
Antoni Pokusinski <apokusinski01@gmail.com>
Subject: [PATCH 6/6] rtc: abx80x: add support for ABX81X
Date: Wed, 22 Jul 2026 21:58:14 +0200 [thread overview]
Message-ID: <20260722195814.298552-7-apokusinski01@gmail.com> (raw)
In-Reply-To: <20260722195814.298552-1-apokusinski01@gmail.com>
Abracon ABX81X is a family of RTCs with SPI interface featuring
the same functionalities as the ABX80X I2C clocks.
Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
---
drivers/rtc/Kconfig | 26 +++++-----
drivers/rtc/rtc-abx80x.c | 106 +++++++++++++++++++++++++++++++++++++--
2 files changed, 115 insertions(+), 17 deletions(-)
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4d14bcba616e..d35221f81024 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -212,18 +212,6 @@ config RTC_DRV_ABEOZ9
This driver can also be built as a module. If so, the module
will be called rtc-ab-e0z9.
-config RTC_DRV_ABX80X
- tristate "Abracon ABx80x"
- select WATCHDOG_CORE if WATCHDOG
- select REGMAP_I2C
- help
- If you say yes here you get support for Abracon AB080X and AB180X
- families of ultra-low-power battery- and capacitor-backed real-time
- clock chips.
-
- This driver can also be built as a module. If so, the module
- will be called rtc-abx80x.
-
config RTC_DRV_AC100
tristate "X-Powers AC100"
depends on MFD_AC100
@@ -955,6 +943,20 @@ config RTC_I2C_AND_SPI
comment "SPI and I2C RTC drivers"
+config RTC_DRV_ABX80X
+ tristate "Abracon ABx80x"
+ depends on RTC_I2C_AND_SPI
+ select WATCHDOG_CORE if WATCHDOG
+ select REGMAP_I2C if I2C
+ select REGMAP_SPI if SPI_MASTER
+ help
+ If you say yes here you get support for Abracon AB080X, AB180X,
+ AB081X and AB181X families of ultra-low-power battery- and
+ capacitor-backed real-time clock chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-abx80x.
+
config RTC_DRV_DS3232
tristate "Dallas/Maxim DS3232/DS3234"
depends on RTC_I2C_AND_SPI
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 6e0c14695bdf..8481148ce3a2 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * A driver for the I2C members of the Abracon AB x8xx RTC family,
- * and compatible: AB 1805 and AB 0805
+ * A driver for the I2C and SPI members of the Abracon AB x8xx RTC family,
+ * and compatible: AB 1805, AB 0805, AB 1815 and AB 0815
*
* Copyright 2014-2015 Macq S.A.
*
@@ -18,6 +18,7 @@
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
+#include <linux/spi/spi.h>
#include <linux/watchdog.h>
#define ABX8XX_REG_HTH 0x00
@@ -102,8 +103,8 @@
static u8 trickle_resistors[] = {0, 3, 6, 11};
-enum abx80x_chip {AB0801, AB0803, AB0804, AB0805,
- AB1801, AB1803, AB1804, AB1805, RV1805, ABX80X};
+enum abx80x_chip {AB0801, AB0803, AB0804, AB0805, AB0815,
+ AB1801, AB1803, AB1804, AB1805, AB1815, RV1805, ABX80X};
struct abx80x_cap {
u16 pn;
@@ -116,10 +117,12 @@ static struct abx80x_cap abx80x_caps[] = {
[AB0803] = {.pn = 0x0803},
[AB0804] = {.pn = 0x0804, .has_tc = true, .has_wdog = true},
[AB0805] = {.pn = 0x0805, .has_tc = true, .has_wdog = true},
+ [AB0815] = {.pn = 0x0815, .has_tc = true, .has_wdog = true},
[AB1801] = {.pn = 0x1801},
[AB1803] = {.pn = 0x1803},
[AB1804] = {.pn = 0x1804, .has_tc = true, .has_wdog = true},
[AB1805] = {.pn = 0x1805, .has_tc = true, .has_wdog = true},
+ [AB1815] = {.pn = 0x1815, .has_tc = true, .has_wdog = true},
[RV1805] = {.pn = 0x1805, .has_tc = true, .has_wdog = true},
[ABX80X] = {.pn = 0}
};
@@ -1013,14 +1016,107 @@ static void abx80x_unregister_driver(void)
#endif /* IS_ENABLED(CONFIG_I2C) */
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+
+static const struct regmap_config abx80x_regmap_config_spi = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = ABX8XX_SRAM_BASE + ABX8XX_SRAM_WIN_SIZE - 1,
+
+ .rd_table = &abx80x_read_table,
+ .wr_table = &abx80x_write_table,
+
+ .write_flag_mask = BIT(7),
+};
+
+static const struct spi_device_id abx81x_id[] = {
+ { "ab0815", AB0815 },
+ { "ab1815", AB1815 },
+ { }
+};
+MODULE_DEVICE_TABLE(spi, abx81x_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id abx81x_of_match[] = {
+ {
+ .compatible = "abracon,ab0815",
+ .data = (void *)AB0815
+ },
+ {
+ .compatible = "abracon,ab1815",
+ .data = (void *)AB1815
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(of, abx81x_of_match);
+#endif
+
+static int abx81x_spi_probe(struct spi_device *spi)
+{
+ unsigned int part = (uintptr_t)spi_get_device_match_data(spi);
+ struct regmap *regmap;
+
+ regmap = devm_regmap_init_spi(spi, &abx80x_regmap_config_spi);
+ if (IS_ERR(regmap)) {
+ dev_err(&spi->dev, "Unable to allocate regmap\n");
+ return -EIO;
+ }
+
+ return abx80x_probe(&spi->dev, regmap, spi->irq,
+ spi->dev.of_node, part);
+}
+
+static struct spi_driver abx81x_driver = {
+ .driver = {
+ .name = "rtc-abx81x",
+ .of_match_table = of_match_ptr(abx81x_of_match),
+ },
+ .probe = abx81x_spi_probe,
+ .id_table = abx81x_id,
+};
+
+static int abx81x_register_driver(void)
+{
+ return spi_register_driver(&abx81x_driver);
+}
+
+static void abx81x_unregister_driver(void)
+{
+ spi_unregister_driver(&abx81x_driver);
+}
+
+#else
+
+static int abx81x_register_driver(void)
+{
+ return 0;
+}
+
+static void abx81x_unregister_driver(void)
+{
+}
+
+#endif /* IS_ENABLED(CONFIG_SPI_MASTER) */
+
static int __init abx80x_init(void)
{
- return abx80x_register_driver();
+ int ret;
+
+ ret = abx80x_register_driver();
+ if (ret)
+ return ret;
+
+ ret = abx81x_register_driver();
+ if (ret)
+ abx80x_unregister_driver();
+
+ return ret;
}
module_init(abx80x_init);
static void __exit abx80x_exit(void)
{
+ abx81x_unregister_driver();
abx80x_unregister_driver();
}
module_exit(abx80x_exit);
--
2.55.0
next prev parent reply other threads:[~2026-07-22 20:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 19:58 [PATCH 0/6] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-07-22 19:58 ` [PATCH 1/6] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-07-22 20:09 ` sashiko-bot
2026-07-22 19:58 ` [PATCH 2/6] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-07-22 20:13 ` sashiko-bot
2026-07-22 19:58 ` [PATCH 3/6] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-07-22 20:16 ` sashiko-bot
2026-07-22 19:58 ` [PATCH 4/6] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-07-22 20:11 ` sashiko-bot
2026-07-22 19:58 ` [PATCH 5/6] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-07-22 20:10 ` sashiko-bot
2026-07-22 19:58 ` Antoni Pokusinski [this message]
2026-07-22 20:09 ` [PATCH 6/6] rtc: abx80x: add support for ABX81X sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722195814.298552-7-apokusinski01@gmail.com \
--to=apokusinski01@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox