* [PATCH v3 1/2] rtc: rtc7301: Rewrite bindings in schema
2023-10-10 19:42 [PATCH v3 0/2] Support byte access in the RTC7301 driver Linus Walleij
@ 2023-10-10 19:42 ` Linus Walleij
2023-10-10 19:42 ` [PATCH v3 2/2] rtc: rtc7301: Support byte-addressed IO Linus Walleij
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2023-10-10 19:42 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Akinobu Mita, Howard Harte
Cc: linux-rtc, devicetree, Linus Walleij, Rob Herring
This rewrites the Epson RTC7301 bindings to use YAML schema,
and adds a property for "reg-io-width" as used in several
other bindings to account for different register strides.
The USRobotics USR8200 uses the byte IO width.
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
.../devicetree/bindings/rtc/epson,rtc7301.txt | 16 -------
.../devicetree/bindings/rtc/epson,rtc7301.yaml | 51 ++++++++++++++++++++++
2 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/Documentation/devicetree/bindings/rtc/epson,rtc7301.txt b/Documentation/devicetree/bindings/rtc/epson,rtc7301.txt
deleted file mode 100644
index 5f9df3f1467c..000000000000
--- a/Documentation/devicetree/bindings/rtc/epson,rtc7301.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-EPSON TOYOCOM RTC-7301SF/DG
-
-Required properties:
-
-- compatible: Should be "epson,rtc7301sf" or "epson,rtc7301dg"
-- reg: Specifies base physical address and size of the registers.
-- interrupts: A single interrupt specifier.
-
-Example:
-
-rtc: rtc@44a00000 {
- compatible = "epson,rtc7301dg";
- reg = <0x44a00000 0x10000>;
- interrupt-parent = <&axi_intc_0>;
- interrupts = <3 2>;
-};
diff --git a/Documentation/devicetree/bindings/rtc/epson,rtc7301.yaml b/Documentation/devicetree/bindings/rtc/epson,rtc7301.yaml
new file mode 100644
index 000000000000..bdb5cadb31cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/epson,rtc7301.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/rtc/epson,rtc7301.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Epson Toyocom RTC-7301SF/DG
+
+description:
+ The only difference between the two variants is the packaging.
+ The DG variant is a DIL package, and the SF variant is a flat
+ package.
+
+maintainers:
+ - Akinobu Mita <akinobu.mita@gmail.com>
+
+properties:
+ compatible:
+ enum:
+ - epson,rtc7301dg
+ - epson,rtc7301sf
+
+ reg:
+ maxItems: 1
+
+ reg-io-width:
+ description:
+ The size (in bytes) of the IO accesses that should be performed
+ on the device.
+ enum: [1, 4]
+ default: 4
+
+ interrupts:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ rtc: rtc@44a00000 {
+ compatible = "epson,rtc7301dg";
+ reg = <0x44a00000 0x10000>;
+ reg-io-width = <4>;
+ interrupt-parent = <&axi_intc_0>;
+ interrupts = <3 2>;
+ };
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v3 2/2] rtc: rtc7301: Support byte-addressed IO
2023-10-10 19:42 [PATCH v3 0/2] Support byte access in the RTC7301 driver Linus Walleij
2023-10-10 19:42 ` [PATCH v3 1/2] rtc: rtc7301: Rewrite bindings in schema Linus Walleij
@ 2023-10-10 19:42 ` Linus Walleij
2023-10-15 13:55 ` [PATCH v3 0/2] Support byte access in the RTC7301 driver Akinobu Mita
2023-10-15 21:03 ` Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2023-10-10 19:42 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Akinobu Mita, Howard Harte
Cc: linux-rtc, devicetree, Linus Walleij
The old RTC7301 driver in OpenWrt used byte access, but the
current mainline Linux driver uses 32bit word access.
Make this configurable using device properties using the
standard property "reg-io-width" in e.g. device tree.
This is needed for the USRobotics USR8200 which has the
chip connected using byte accesses.
Debugging and testing by Howard Harte.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/rtc/rtc-r7301.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-r7301.c b/drivers/rtc/rtc-r7301.c
index 5dbaeb7af648..ef913cf8593f 100644
--- a/drivers/rtc/rtc-r7301.c
+++ b/drivers/rtc/rtc-r7301.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/delay.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
@@ -55,12 +56,23 @@ struct rtc7301_priv {
u8 bank;
};
-static const struct regmap_config rtc7301_regmap_config = {
+/*
+ * When the device is memory-mapped, some platforms pack the registers into
+ * 32-bit access using the lower 8 bits at each 4-byte stride, while others
+ * expose them as simply consecutive bytes.
+ */
+static const struct regmap_config rtc7301_regmap_32_config = {
.reg_bits = 32,
.val_bits = 8,
.reg_stride = 4,
};
+static const struct regmap_config rtc7301_regmap_8_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .reg_stride = 1,
+};
+
static u8 rtc7301_read(struct rtc7301_priv *priv, unsigned int reg)
{
int reg_stride = regmap_get_reg_stride(priv->regmap);
@@ -356,7 +368,9 @@ static int __init rtc7301_rtc_probe(struct platform_device *dev)
void __iomem *regs;
struct rtc7301_priv *priv;
struct rtc_device *rtc;
+ static const struct regmap_config *mapconf;
int ret;
+ u32 val;
priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -366,8 +380,25 @@ static int __init rtc7301_rtc_probe(struct platform_device *dev)
if (IS_ERR(regs))
return PTR_ERR(regs);
+ ret = device_property_read_u32(&dev->dev, "reg-io-width", &val);
+ if (ret)
+ /* Default to 32bit accesses */
+ val = 4;
+
+ switch (val) {
+ case 1:
+ mapconf = &rtc7301_regmap_8_config;
+ break;
+ case 4:
+ mapconf = &rtc7301_regmap_32_config;
+ break;
+ default:
+ dev_err(&dev->dev, "invalid reg-io-width %d\n", val);
+ return -EINVAL;
+ }
+
priv->regmap = devm_regmap_init_mmio(&dev->dev, regs,
- &rtc7301_regmap_config);
+ mapconf);
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3 0/2] Support byte access in the RTC7301 driver
2023-10-10 19:42 [PATCH v3 0/2] Support byte access in the RTC7301 driver Linus Walleij
2023-10-10 19:42 ` [PATCH v3 1/2] rtc: rtc7301: Rewrite bindings in schema Linus Walleij
2023-10-10 19:42 ` [PATCH v3 2/2] rtc: rtc7301: Support byte-addressed IO Linus Walleij
@ 2023-10-15 13:55 ` Akinobu Mita
2023-10-15 21:03 ` Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2023-10-15 13:55 UTC (permalink / raw)
To: Linus Walleij
Cc: Alessandro Zummo, Alexandre Belloni, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Howard Harte, linux-rtc,
devicetree, Rob Herring
2023年10月11日(水) 4:42 Linus Walleij <linus.walleij@linaro.org>:
>
> This augments the Epson RTC7301 driver so that is supports
> both 8bit byte and 32bit word access.
I don't have access to that device anymore, but I think it's a good change.
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/2] Support byte access in the RTC7301 driver
2023-10-10 19:42 [PATCH v3 0/2] Support byte access in the RTC7301 driver Linus Walleij
` (2 preceding siblings ...)
2023-10-15 13:55 ` [PATCH v3 0/2] Support byte access in the RTC7301 driver Akinobu Mita
@ 2023-10-15 21:03 ` Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2023-10-15 21:03 UTC (permalink / raw)
To: Alessandro Zummo, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Akinobu Mita, Howard Harte, Linus Walleij
Cc: linux-rtc, devicetree, Rob Herring
On Tue, 10 Oct 2023 21:42:10 +0200, Linus Walleij wrote:
> This augments the Epson RTC7301 driver so that is supports
> both 8bit byte and 32bit word access.
>
>
Applied, thanks!
[1/2] rtc: rtc7301: Rewrite bindings in schema
commit: 5ded578a18c9515c2c0e1cd148ca42133bbcf055
[2/2] rtc: rtc7301: Support byte-addressed IO
commit: 8c767e9c1ef40c9fa73276df801251cef895b569
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