rtc: Add rtc driver for the Loongson family chips
Subsystems (4)
v4 cover rtc: Add rtc driver for the Loongson family chips
Hi all:
The initial DT-base ls2x rtc driver was written by Wang Xuerui, He has released five versions of patchset before, and all related mail records are shown below if you are interested:
https://lore.kernel.org/all/?q=ls2x-rtc
In this series of patches, based on the code above, I have added the following support:
1. Add ACPI-related support, as Loongson-3A5000 + LS7A is now ACPI-base by default under LoongArch architecture;
2. Add rtc alarm/walarm related functions;
3. Merge LS1X rtc and LS2X rtc into a unified rtc-loongson driver.
I have tested on Loongson-3A5000LA+LS7A1000/LS7A2000, Loongson-2K1000LA, Loongson-2K0500 and Loongson-2K2000(ACPI/DT).
Thanks to everyone for reviewing and testing the code.
-------
v4:
- Rebase on the top of rtc-next;
- Drop defconfig-related patches;
patch(1/5)
- New patch, Loongson RTC bindings have been rewritten and we have dropped the wildcard (ls2x) in compatible.
Thanks to Krzysztof for your comments;
patch(2/5)
- New patch, drop the ls1x rtc driver;
patch(3/5)
- Clear RTC_FEATURE_UPDATE_INTERRUPT bit, for the rtc does not support
UIE;
- Add LS2K2000 support(DT/ACPI);
- Merge ls1x support and name the driver rtc-loongson; Thanks to Jiaxun for his comments and Keguang for his assistance in
testing.
v3:
https://lore.kernel.org/linux-rtc/[email protected]/
patch(2/7):
- Check patchset with "checkpatch.pl --strict";
- Drop static inline functions which are used only once, such as ls2x_rtc_regs_to_time;
- Remove the suruct ls2x_rtc_regs and regmap_bulk_xxx() is used to read and write rtc registers;
- Clear the RTC wakeup interrupt manually;
- Enable the RTC in set_time() and check in read_time();
- device_get_match_data() is used to get ls2x_pm_offset, for LS2k1000 has the different value;
- Remove some inexact CONFIG_ACPI.
v2:
1. Rebased on top of latest loongarch-next;
2. Add interrupt descriptions to the ls2k and ls7a DTS files to avoid errors when the driver gets the IRQ number, Thanks to Qing Zhang for testing;
3. Remove some inexact CONFIG_ACPI.
Thanks.
Binbin Zhou (5):
dt-bindings: rtc: Remove the LS2X from the trivial RTCs
rtc: Remove the Loongson-1 RTC driver
rtc: Add rtc driver for the Loongson family chips
MIPS: Loongson64: DTS: Add RTC support to LS7A PCH
MIPS: Loongson64: DTS: Add RTC support to Loongson-2K1000
.../devicetree/bindings/rtc/loongson,rtc.yaml | 47 +++ .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - .../boot/dts/loongson/loongson64-2k1000.dtsi | 7 + arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 7 + drivers/rtc/Kconfig | 23 +- drivers/rtc/Makefile | 2 +- drivers/rtc/rtc-loongson.c | 390 ++++++++++++++++++ drivers/rtc/rtc-ls1x.c | 192 --------- 8 files changed, 465 insertions(+), 205 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/loongson,rtc.yaml create mode 100644 drivers/rtc/rtc-loongson.c delete mode 100644 drivers/rtc/rtc-ls1x.c
Signature · 1 line
2.39.1
PATCH v4 1/5 dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Move Loongson RTC bindings from trivial-rtc.yaml into loongson,rtc.yaml.
Also, we will discard the use of wildcards in compatible (ls2x-rtc), soc-based compatible is more accurate for hardware differences between chips.
--- .../devicetree/bindings/rtc/loongson,rtc.yaml | 47 +++++++++++++++++++ .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/loongson,rtc.yaml
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +49 -0
@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/loongson,rtc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson Real-Time Clock + +maintainers: + - Binbin Zhou <[email protected]> + +allOf: + - $ref: rtc.yaml# + +properties: + compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + rtc_dev: rtc@1fe27800 { + compatible = "loongson,ls2k0500-rtc"; + reg = <0x1fe27800 0x100>; + + interrupt-parent = <&liointc1>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + }; + +...
Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +0 -2
@@ -47,8 +47,6 @@ properties: - isil,isl1218 # Intersil ISL12022 Real-time Clock - isil,isl12022 - # Loongson-2K Socs/LS7A bridge Real-time Clock - - loongson,ls2x-rtc # Real Time Clock Module with I2C-Bus - microcrystal,rv3029 # Real Time Clock
Signature · 1 line
2.39.1
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Hey Binbin,
Quoted 32 lines · Binbin Zhou
Move Loongson RTC bindings from
trivial-rtc.yamlinto loongson,rtc.yaml.Also, we will discard the use of wildcards in compatible (ls2x-rtc), soc-based compatible is more accurate for hardware differences between chips.
Signed-off-by Binbin Zhou <[email protected]>--- .../devicetree/bindings/rtc/loongson,rtc.yaml | 47 +++++++++++++++++++ .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/loongson,rtc.yamlDocumentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +13
-0@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/loongson,rtc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson Real-Time Clock + +maintainers: + - Binbin Zhou <[email protected]> + +allOf: + - $ref: rtc.yaml#
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +10
-0+ +properties: + compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc
|+static const struct of_device_id loongson_rtc_of_match[] = {
|+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config },
|+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config },
|+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config },
|+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config },
|+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config },
|+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config },
|+ { /* sentinel */ }
|+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"
And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = {
|+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config },
|+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config },
|+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config },
|+ { /* sentinel */ }
|+};And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
To maintain compatibility with the existing devicetrees, should the old "loongson,ls2x-rtc" be kept in the driver?
Thanks,
Conor.
Quoted 42 lines
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +26
-0+ + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + rtc_dev: rtc@1fe27800 { + compatible = "loongson,ls2k0500-rtc"; + reg = <0x1fe27800 0x100>; + + interrupt-parent = <&liointc1>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + }; + +...Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +0
-2@@ -47,8 +47,6 @@ properties: - isil,isl1218 # Intersil ISL12022 Real-time Clock - isil,isl12022 - # Loongson-2K Socs/LS7A bridge Real-time Clock - - loongson,ls2x-rtc # Real Time Clock Module with I2C-Bus - microcrystal,rv3029 # Real Time ClockSignature · 1 line
2.39.1
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 77 lines · Conor Dooley
Hey Binbin,
Quoted 32 lines · Binbin Zhou
Move Loongson RTC bindings from
trivial-rtc.yamlinto loongson,rtc.yaml.Also, we will discard the use of wildcards in compatible (ls2x-rtc), soc-based compatible is more accurate for hardware differences between chips.
Signed-off-by Binbin Zhou <[email protected]>--- .../devicetree/bindings/rtc/loongson,rtc.yaml | 47 +++++++++++++++++++ .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/loongson,rtc.yamlDocumentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +13
-0@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/loongson,rtc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson Real-Time Clock + +maintainers: + - Binbin Zhou <[email protected]> + +allOf: + - $ref: rtc.yaml#Documentation/devicetree/bindings/rtc/loongson,rtc.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +10
-0+ +properties: + compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, |+ { /* sentinel */ } |+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { /* sentinel */ } |+};
Quoted 2 lines
And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
Hi Conor:
Thanks for your reply.
Yes, this is looking much cleaner. But it can't show every chip that supports that driver.
As we know, Loongson is a family of chips:
ls1b/ls1c represent the Loongson-1 family of CPU chips;
ls7a represents the Loongson LS7A bridge chip; ls2k0500/ls2k1000/ls2k2000 represent the Loongson-2 family of CPU chips.
Based on my previous conversations with Krzysztof, it seems that soc-based to order compatible is more popular, so I have listed all the chips that support that RTC driver.
Quoted 3 lines
To maintain compatibility with the existing devicetrees, should the old "loongson,ls2x-rtc" be kept in the driver?
No, It seems that wildcards in compatible are not allowed." loongson,ls2x-rtc" itself was part of this patch series at one time, but apparently it is not the right way to describe these chips.
Here is Krzysztof's previous reply:
https://lore.kernel.org/linux-rtc/[email protected]/
Thanks.
Binbin
Quoted 46 lines
Thanks,
Conor.Quoted 42 lines
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +26
-0+ + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + rtc_dev: rtc@1fe27800 { + compatible = "loongson,ls2k0500-rtc"; + reg = <0x1fe27800 0x100>; + + interrupt-parent = <&liointc1>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + }; + +...Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +0
-3@@ -47,8 +47,6 @@ properties: - isil,isl1218 # Intersil ISL12022 Real-time Clock - isil,isl12022 - # Loongson-2K Socs/LS7A bridge Real-time Clock - - loongson,ls2x-rtc # Real Time Clock Module with I2C-Bus - microcrystal,rv3029 # Real Time Clock --2.39.1
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 53 lines · Binbin Zhou
Quoted 42 lines · Conor Dooley
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml line 23
Quoted 9 lines · Binbin Zhou
Quoted 1 line
+properties:
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +8
-0+ compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, |+ { /* sentinel */ } |+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { /* sentinel */ } |+};Quoted 2 lines
And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
Hi Conor:
Thanks for your reply.
Yes, this is looking much cleaner. But it can't show every chip that supports that driver.
Quoted 8 lines
As we know, Loongson is a family of chips:
ls1b/ls1c represent the Loongson-1 family of CPU chips;
ls7a represents the Loongson LS7A bridge chip; ls2k0500/ls2k1000/ls2k2000 represent the Loongson-2 family of CPU chips.Based on my previous conversations with Krzysztof, it seems that soc-based to order compatible is more popular, so I have listed all the chips that support that RTC driver.
Right. You don't actually have to list them all *in the driver* though, just in the binding and in the devicetree. I think what you have missed is:
Quoted 7 lines
Quoted 7 lines
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"
This is what you would put in the compatible section of a devicetree node, using "fallback compatibles". So for a ls1c you put in compatible = "loongson,ls1c-rtc", "loongson,ls1b-rtc";
and the kernel first tries to find a driver that supports "loongson,ls1c-rtc" but if that fails it tries to find one that supports "loongson,ls1b-rtc". This gives you the best of both worlds - you can add support easily for new systems (when an ls1d comes out, you don't even need to change the driver for it to just work!) and you have a soc-specific compatible in case you need to add some workaround for hardware errata etc in the future.
Quoted 6 lines
Quoted 2 lines
To maintain compatibility with the existing devicetrees, should the old "loongson,ls2x-rtc" be kept in the driver?
No, It seems that wildcards in compatible are not allowed." loongson,ls2x-rtc" itself was part of this patch series at one time, but apparently it is not the right way to describe these chips.
Right, but it has been merged - you are deleting the driver that supports it after all - which means that any dtb with the old compatible will stop working.
I don't disagree with Krzysztof that having wildcard based compatibles is bad, but I do not think that regressing rtc support for systems with these old devicetrees is the right way to go either.
Thanks,
Conor.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 3 lines
2023年5月26日 13:06,Conor Dooley <[email protected]> 写道:
Hi all,
[...]
My two cents here as Loongson64 maintainer.
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
To maintain compatibility with the existing devicetrees, should the old "loongson,ls2x-rtc" be kept in the driver?
No, It seems that wildcards in compatible are not allowed." loongson,ls2x-rtc" itself was part of this patch series at one time, but apparently it is not the right way to describe these chips.
Right, but it has been merged - you are deleting the driver that supports it after all - which means that any dtb with the old compatible will stop working.
It is perfectly fine to break DTB compatibility for Loongson64 systems As they *only* use builtin dtb. Bootloader will only pass machine type information and kernel will choose one dtb from it’s dtbs pool.
Thanks
- Jiaxun
Quoted 6 lines
I don't disagree with Krzysztof that having wildcard based compatibles is bad, but I do not think that regressing rtc support for systems with these old devicetrees is the right way to go either.
Thanks,
Conor.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 16 lines · Jiaxun Yang
Quoted 3 lines
2023年5月26日 13:06,Conor Dooley <[email protected]> 写道:
Hi all,
[...]
My two cents here as Loongson64 maintainer.Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
To maintain compatibility with the existing devicetrees, should the old "loongson,ls2x-rtc" be kept in the driver?
No, It seems that wildcards in compatible are not allowed." loongson,ls2x-rtc" itself was part of this patch series at one time, but apparently it is not the right way to describe these chips.
Quoted 6 lines
Quoted 3 lines
Right, but it has been merged - you are deleting the driver that supports it after all - which means that any dtb with the old compatible will stop working.
It is perfectly fine to break DTB compatibility for Loongson64 systems As they *only* use builtin dtb. Bootloader will only pass machine type information and kernel will choose one dtb from it’s dtbs pool.
Ah, that is good to know thanks! I think that should be mentioned in the commit messages for the next revision.
Cheers,
Conor.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
In reply to Conor DooleyQuoted 75 lines · Conor Dooley
Quoted 53 lines · Binbin Zhou
Quoted 42 lines · Conor Dooley
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml line 23
Quoted 9 lines · Binbin Zhou
Quoted 1 line
+properties:
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +8
-0+ compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, |+ { /* sentinel */ } |+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { /* sentinel */ } |+};Quoted 2 lines
And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
Hi Conor:
Thanks for your reply.
Yes, this is looking much cleaner. But it can't show every chip that supports that driver.
Quoted 8 lines
As we know, Loongson is a family of chips:
ls1b/ls1c represent the Loongson-1 family of CPU chips;
ls7a represents the Loongson LS7A bridge chip; ls2k0500/ls2k1000/ls2k2000 represent the Loongson-2 family of CPU chips.Based on my previous conversations with Krzysztof, it seems that soc-based to order compatible is more popular, so I have listed all the chips that support that RTC driver.
Right. You don't actually have to list them all *in the driver* though, just in the binding and in the devicetree. I think what you have missed is:
Quoted 7 lines
Quoted 7 lines
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"
Quoted 10 lines
This is what you would put in the compatible section of a devicetree node, using "fallback compatibles". So for a ls1c you put in compatible = "loongson,ls1c-rtc", "loongson,ls1b-rtc";
and the kernel first tries to find a driver that supports "loongson,ls1c-rtc" but if that fails it tries to find one that supports "loongson,ls1b-rtc". This gives you the best of both worlds - you can add support easily for new systems (when an ls1d comes out, you don't even need to change the driver for it to just work!) and you have a soc-specific compatible in case you need to add some workaround for hardware errata etc in the future.
Hi Conor:
I seem to understand what you are talking about.
I hadn't delved into "fallback compatibles" before, so thanks for the detailed explanation.
In fact, I have thought before if there is a good way to do it other than adding comptable to the driver frequently, and "fallback compatibles" should be the most suitable.
So in the dt-bindings file, should we just write this:
compatible:
oneOf:
- items:
- enum:
- loongson,ls1c-rtc
- const: loongson,ls1b-rtc
- items:
- enum:
- loongson,ls2k0500-rtc
- loongson,ls2k2000-rtc
- const: loongson,ls7a-rtc
- items:
- const: loongson,ls2k1000-rtc
Thanks.
Binbin
Quoted 17 lines
Quoted 7 lines
Quoted 3 lines
To maintain compatibility with the existing devicetrees, should the old "loongson,ls2x-rtc" be kept in the driver?
No, It seems that wildcards in compatible are not allowed." loongson,ls2x-rtc" itself was part of this patch series at one time, but apparently it is not the right way to describe these chips.
Right, but it has been merged - you are deleting the driver that supports it after all - which means that any dtb with the old compatible will stop working.
I don't disagree with Krzysztof that having wildcard based compatibles is bad, but I do not think that regressing rtc support for systems with these old devicetrees is the right way to go either.Thanks,
Conor.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 103 lines
2023年5月27日 10:22,Binbin Zhou <[email protected]> 写道:
Quoted 75 lines · Conor Dooley
Quoted 53 lines · Binbin Zhou
Quoted 42 lines · Conor Dooley
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml line 23
Quoted 9 lines · Binbin Zhou
Quoted 1 line
+properties:
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +8
-0+ compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, |+ { /* sentinel */ } |+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { /* sentinel */ } |+};Quoted 2 lines
And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
Hi Conor:
Thanks for your reply.
Yes, this is looking much cleaner. But it can't show every chip that supports that driver.
Quoted 8 lines
As we know, Loongson is a family of chips:
ls1b/ls1c represent the Loongson-1 family of CPU chips;
ls7a represents the Loongson LS7A bridge chip; ls2k0500/ls2k1000/ls2k2000 represent the Loongson-2 family of CPU chips.Based on my previous conversations with Krzysztof, it seems that soc-based to order compatible is more popular, so I have listed all the chips that support that RTC driver.
Right. You don't actually have to list them all *in the driver* though, just in the binding and in the devicetree. I think what you have missed is:
Quoted 7 lines
Quoted 7 lines
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"Quoted 10 lines
This is what you would put in the compatible section of a devicetree node, using "fallback compatibles". So for a ls1c you put in compatible = "loongson,ls1c-rtc", "loongson,ls1b-rtc";
and the kernel first tries to find a driver that supports "loongson,ls1c-rtc" but if that fails it tries to find one that supports "loongson,ls1b-rtc". This gives you the best of both worlds - you can add support easily for new systems (when an ls1d comes out, you don't even need to change the driver for it to just work!) and you have a soc-specific compatible in case you need to add some workaround for hardware errata etc in the future.Hi Conor:
I seem to understand what you are talking about.
I hadn't delved into "fallback compatibles" before, so thanks for the detailed explanation.In fact, I have thought before if there is a good way to do it other than adding comptable to the driver frequently, and "fallback compatibles" should be the most suitable.
So in the dt-bindings file, should we just write this:
Quoted 13 lines
compatible:
oneOf:
- items:
- enum:
- loongson,ls1c-rtc
- const: loongson,ls1b-rtc
- items:
- enum:
- loongson,ls2k0500-rtc
- loongson,ls2k2000-rtc
- const: loongson,ls7a-rtc
- items:
- const: loongson,ls2k1000-rtc
My recommendation is leaving compatible string as is.
Thanks
- Jiaxun
Quoted 3 lines
Thanks.
Binbin
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 91 lines · Jiaxun Yang
Quoted 91 lines
2023年5月27日 10:22,Binbin Zhou <[email protected]> 写道:
Quoted 74 lines · Conor Dooley
Quoted 53 lines · Binbin Zhou
Quoted 42 lines · Conor Dooley
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml line 23
Quoted 9 lines · Binbin Zhou
Quoted 1 line
+properties:
Documentation/devicetree/bindings/rtc/loongson,rtc.yaml new file +8
-0+ compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, |+ { /* sentinel */ } |+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { /* sentinel */ } |+};Quoted 2 lines
And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
Hi Conor:
Thanks for your reply.
Yes, this is looking much cleaner. But it can't show every chip that supports that driver.
Quoted 8 lines
As we know, Loongson is a family of chips:
ls1b/ls1c represent the Loongson-1 family of CPU chips;
ls7a represents the Loongson LS7A bridge chip; ls2k0500/ls2k1000/ls2k2000 represent the Loongson-2 family of CPU chips.Based on my previous conversations with Krzysztof, it seems that soc-based to order compatible is more popular, so I have listed all the chips that support that RTC driver.
Right. You don't actually have to list them all *in the driver* though, just in the binding and in the devicetree. I think what you have missed is:
Quoted 7 lines
Quoted 7 lines
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"Quoted 10 lines
This is what you would put in the compatible section of a devicetree node, using "fallback compatibles". So for a ls1c you put in compatible = "loongson,ls1c-rtc", "loongson,ls1b-rtc";
and the kernel first tries to find a driver that supports "loongson,ls1c-rtc" but if that fails it tries to find one that supports "loongson,ls1b-rtc". This gives you the best of both worlds - you can add support easily for new systems (when an ls1d comes out, you don't even need to change the driver for it to just work!) and you have a soc-specific compatible in case you need to add some workaround for hardware errata etc in the future.I seem to understand what you are talking about.
I hadn't delved into "fallback compatibles" before, so thanks for the detailed explanation.
Quoted 5 lines
Quoted 5 lines
In fact, I have thought before if there is a good way to do it other than adding comptable to the driver frequently, and "fallback compatibles" should be the most suitable.
So in the dt-bindings file, should we just write this:
Not quite, because you still need to allow for ls1b-rtc and ls7a-rtc appearing on their own. That's just two more entries like the ls2k1000-rtc one.
Quoted 13 lines
Quoted 12 lines
compatible:
oneOf:
- items:
- enum:
- loongson,ls1c-rtc
- const: loongson,ls1b-rtc
- items:
- enum:
- loongson,ls2k0500-rtc
- loongson,ls2k2000-rtc
- const: loongson,ls7a-rtc
Quoted 2 lines
Quoted 2 lines
- items:
- const: loongson,ls2k1000-rtc
This one is just "const:", you don't need "items: const:". I didn't test this, but I figure it would be:
compatible:
oneOf:
- items:
- enum:
- loongson,ls1c-rtc
- const: loongson,ls1b-rtc
- items:
- enum:
- loongson,ls2k0500-rtc
- loongson,ls2k2000-rtc
- const: loongson,ls7a-rtc
- const: loongson,ls1b-rtc
- const: loongson,ls2k1000-rtc
- const: loongson,ls7a-rtc
Quoted 1 line
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Cheers,
Conor.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 139 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 91 lines · Jiaxun Yang
Quoted 91 lines
2023年5月27日 10:22,Binbin Zhou <[email protected]> 写道:
Quoted 74 lines · Conor Dooley
Quoted 53 lines · Binbin Zhou
Quoted 42 lines · Conor Dooley
Review
Quoted 9 lines · Binbin Zhou
Quoted 1 line
+properties:
(quoted diff) +8
-0+ compatible: + enum: + - loongson,ls1b-rtc + - loongson,ls1c-rtc + - loongson,ls7a-rtc + - loongson,ls2k0500-rtc + - loongson,ls2k1000-rtc + - loongson,ls2k2000-rtc|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, |+ { /* sentinel */ } |+};This is a sign to me that your compatibles here are could do with some fallbacks. Both of the ls1 ones are compatible with each other & there are three that are generic.
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"And then the driver only needs:
|+static const struct of_device_id loongson_rtc_of_match[] = { |+ { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }, |+ { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, |+ { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, |+ { /* sentinel */ } |+};Quoted 2 lines
And ~if~when you add support for more devices in the future that are compatible with the existing ones no code changes are required.
Hi Conor:
Thanks for your reply.
Yes, this is looking much cleaner. But it can't show every chip that supports that driver.
Quoted 8 lines
As we know, Loongson is a family of chips:
ls1b/ls1c represent the Loongson-1 family of CPU chips;
ls7a represents the Loongson LS7A bridge chip; ls2k0500/ls2k1000/ls2k2000 represent the Loongson-2 family of CPU chips.Based on my previous conversations with Krzysztof, it seems that soc-based to order compatible is more popular, so I have listed all the chips that support that RTC driver.
Right. You don't actually have to list them all *in the driver* though, just in the binding and in the devicetree. I think what you have missed is:
Quoted 7 lines
Quoted 7 lines
I would allow the following:
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"loongson,ls2k2000-rtc", "loongson,ls7a-rtc"
"loongson,ls2k1000-rtc"Quoted 10 lines
This is what you would put in the compatible section of a devicetree node, using "fallback compatibles". So for a ls1c you put in compatible = "loongson,ls1c-rtc", "loongson,ls1b-rtc";
and the kernel first tries to find a driver that supports "loongson,ls1c-rtc" but if that fails it tries to find one that supports "loongson,ls1b-rtc". This gives you the best of both worlds - you can add support easily for new systems (when an ls1d comes out, you don't even need to change the driver for it to just work!) and you have a soc-specific compatible in case you need to add some workaround for hardware errata etc in the future.I seem to understand what you are talking about.
I hadn't delved into "fallback compatibles" before, so thanks for the detailed explanation.Quoted 5 lines
Quoted 5 lines
In fact, I have thought before if there is a good way to do it other than adding comptable to the driver frequently, and "fallback compatibles" should be the most suitable.
So in the dt-bindings file, should we just write this:
Not quite, because you still need to allow for ls1b-rtc and ls7a-rtc appearing on their own. That's just two more entries like the ls2k1000-rtc one.
Quoted 13 lines
Quoted 12 lines
compatible:
oneOf:
- items:
- enum:
- loongson,ls1c-rtc
- const: loongson,ls1b-rtc
- items:
- enum:
- loongson,ls2k0500-rtc
- loongson,ls2k2000-rtc
- const: loongson,ls7a-rtcQuoted 2 lines
Quoted 2 lines
- items:
- const: loongson,ls2k1000-rtcThis one is just "const:", you don't need "items: const:". I didn't test this, but I figure it would be:
compatible:
oneOf:
- items:
- enum:
- loongson,ls1c-rtc
- const: loongson,ls1b-rtc
- items:
- enum:
- loongson,ls2k0500-rtc
- loongson,ls2k2000-rtc
- const: loongson,ls7a-rtc
- const: loongson,ls1b-rtc
- const: loongson,ls2k1000-rtc
- const: loongson,ls7a-rtc
Quoted 4 lines
Quoted 1 line
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Ah sorry I meant in this patch.
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
Thanks
- Jiaxun
Quoted 3 lines
Cheers,
Conor.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 8 lines · Jiaxun Yang
Quoted 7 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 1 line · Jiaxun Yang
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Quoted 6 lines
Ah sorry I meant in this patch.
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
I don't see why new bindings being written for old hardware should somehow be treated differently than new bindings for new hardware.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 12 lines · Conor Dooley
Quoted 10 lines · Jiaxun Yang
Quoted 7 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 1 line · Jiaxun Yang
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Ah sorry I meant in this patch.
Quoted 7 lines
Quoted 4 lines
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
I don't see why new bindings being written for old hardware should somehow be treated differently than new bindings for new hardware.
Let me add that ls1b RTC and ls1c RTC are not exactly the same. The former supports RTC interrupt, while the latter does not. So my suggestion is to leave the compatible string as it is in this patch.
Signature · 3 lines
Best regards, Keguang Zhang
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 18 lines · Keguang Zhang
Quoted 17 lines · Conor Dooley
Quoted 14 lines · Jiaxun Yang
Quoted 7 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 1 line · Jiaxun Yang
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Ah sorry I meant in this patch.
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
Quoted 6 lines
Quoted 2 lines
I don't see why new bindings being written for old hardware should somehow be treated differently than new bindings for new hardware.
Let me add that ls1b RTC and ls1c RTC are not exactly the same. The former supports RTC interrupt, while the latter does not. So my suggestion is to leave the compatible string as it is in this patch.
Just as a reminder, there are more than ls1b & c in the patch, lest we forget. Also, fallback compatibles mean a compatible subset, not only that two devices are identical. The interrupt is passed by the interrupts property.
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.
Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data = &ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config }, //ls7a bridge chip
{ .compatible = "loongson,ls2k0500-rtc", .data =
&generic_rtc_config }, // ls2k0500 soc
{ .compatible = "loongson,ls2k2000-rtc", .data =
&generic_rtc_config }, // ls2k2000 soc
{ .compatible = "loongson,ls2k1000-rtc", .data =&ls2k1000_rtc_config }, // ls2k1000 soc
And Conor thought it should be rendered using a fallback compatible form based on ".data".
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"longson,ls2k2000-rtc", "longson,ls7a-rtc"
"loonson,ls2k1000-rtc"
{ .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }
{ .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }
{ .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }In this form, I think it might not be possible to show very graphically which chips are using the driver.
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Which one do you think is more suitable for us?
Here is the link to our discussion:
https://lore.kernel.org/linux-rtc/[email protected]/T/#m6c1ae9b74fceafc4042f7598b1bc594e68e5ec76
Thanks.
Binbin
Quoted 33 lines · Conor Dooley
Quoted 18 lines · Keguang Zhang
Quoted 17 lines · Conor Dooley
Quoted 14 lines · Jiaxun Yang
Quoted 7 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 1 line · Jiaxun Yang
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Ah sorry I meant in this patch.
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
Quoted 6 lines
Quoted 2 lines
I don't see why new bindings being written for old hardware should somehow be treated differently than new bindings for new hardware.
Let me add that ls1b RTC and ls1c RTC are not exactly the same. The former supports RTC interrupt, while the latter does not. So my suggestion is to leave the compatible string as it is in this patch.
Just as a reminder, there are more than ls1b & c in the patch, lest we forget. Also, fallback compatibles mean a compatible subset, not only that two devices are identical. The interrupt is passed by the interrupts property.
Alexandre Belloni
maintainerRe: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Hello,
Honestly, the list of compatibles is fine for me. I wouldn't go for fallback. The improvement would be to drop "loongson,ls1c-rtc", and probably "loongson,ls2k0500-rtc" and "loongson,ls2k2000-rtc".
loongson,ls1c-rtc is definitively not needed, the alarm may not be wired but the registers are there.
For 2k0500 and 2k2000, I don't mind either way.
Quoted 86 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
This should be clearer and more straightforward:{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chip{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socAnd Conor thought it should be rendered using a fallback compatible form based on ".data".
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }In this form, I think it might not be possible to show very graphically which chips are using the driver.
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.Which one do you think is more suitable for us?
Here is the link to our discussion:
https://lore.kernel.org/linux-rtc/[email protected]/T/#m6c1ae9b74fceafc4042f7598b1bc594e68e5ec76
Thanks.
BinbinQuoted 33 lines · Conor Dooley
Quoted 18 lines · Keguang Zhang
Quoted 17 lines · Conor Dooley
Quoted 14 lines · Jiaxun Yang
Quoted 7 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 1 line · Jiaxun Yang
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Ah sorry I meant in this patch.
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
Quoted 6 lines
Quoted 2 lines
I don't see why new bindings being written for old hardware should somehow be treated differently than new bindings for new hardware.
Let me add that ls1b RTC and ls1c RTC are not exactly the same. The former supports RTC interrupt, while the latter does not. So my suggestion is to leave the compatible string as it is in this patch.
Just as a reminder, there are more than ls1b & c in the patch, lest we forget. Also, fallback compatibles mean a compatible subset, not only that two devices are identical. The interrupt is passed by the interrupts property.
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 9 lines · Alexandre Belloni
Hello,
Honestly, the list of compatibles is fine for me. I wouldn't go for fallback. The improvement would be to drop "loongson,ls1c-rtc", and probably "loongson,ls2k0500-rtc" and "loongson,ls2k2000-rtc".
loongson,ls1c-rtc is definitively not needed, the alarm may not be wired but the registers are there.
Hi Alexandre:
I am glad to receive your reply.
Yes, we tested and found that ls1c indeed can't trigger alarm interrupts, but can read and write RTC time normally. Also, in the latest rtc driver (V4), we measure the alarm function by the interrupts property.
Therefore, whether the ls1c compatible can be retained?
Thanks.
Binbin
Quoted 95 lines
For 2k0500 and 2k2000, I don't mind either way.
Quoted 46 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
This should be clearer and more straightforward:{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chip{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socAnd Conor thought it should be rendered using a fallback compatible form based on ".data".
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }In this form, I think it might not be possible to show very graphically which chips are using the driver.
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.Which one do you think is more suitable for us?
Here is the link to our discussion:
Quoted 40 lines
https://lore.kernel.org/linux-rtc/[email protected]/T/#m6c1ae9b74fceafc4042f7598b1bc594e68e5ec76
Thanks.
BinbinQuoted 33 lines · Conor Dooley
Quoted 18 lines · Keguang Zhang
Quoted 17 lines · Conor Dooley
Quoted 14 lines · Jiaxun Yang
Quoted 7 lines
2023年5月27日 17:23,Conor Dooley <[email protected]> 写道:
Quoted 1 line · Jiaxun Yang
My recommendation is leaving compatible string as is.
"as is" meaning "as it is right now in Linus' tree", or "as it is in this patch"?
Ah sorry I meant in this patch.
Since there won’t be any new ls1x chip that will boot Linux any time soon (due to Loongson move away from MIPS but LoongArch32 is undefined for now), and rest compatible strings are wide enough to cover their family, I think the present compatible strings in this patch describes hardware best.
Quoted 6 lines
Quoted 2 lines
I don't see why new bindings being written for old hardware should somehow be treated differently than new bindings for new hardware.
Let me add that ls1b RTC and ls1c RTC are not exactly the same. The former supports RTC interrupt, while the latter does not. So my suggestion is to leave the compatible string as it is in this patch.
Just as a reminder, there are more than ls1b & c in the patch, lest we forget. Also, fallback compatibles mean a compatible subset, not only that two devices are identical. The interrupt is passed by the interrupts property.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
In reply to Binbin ZhouQuoted 7 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
Suggestion was about the bindings. Not in the driver. I never said to list all compatibles in the driver...
Quoted 8 lines
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chip
Quoted 6 lines
{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 soc
I would suggest to use fallbacks as suggested by Conor at least for some of them. You referred to my previous comments about wildcards. Wildcard != fallback.
Quoted 3 lines
And Conor thought it should be rendered using a fallback compatible form based on ".data".
Based on common (compatible) programming model unless you already have clear hardware differences making them incompatible.
Quoted 12 lines
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc", "loongson,ls7a-rtc"
"longson,ls2k2000-rtc", "longson,ls7a-rtc"
"loonson,ls2k1000-rtc"
{ .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config }
{ .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }
{ .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }Quoted 2 lines
In this form, I think it might not be possible to show very graphically which chips are using the driver.
??? How is it impossible? For all other SoCs and architectures it is possible, so what is special for Loongson?
Quoted 3 lines
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Why it is inappropriate? I don't see the issue here... what is a "bridge" chip? Isn't this also an SoC?
Quoted 2 lines
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
ls2k500 and ls2k2000 seem compatible with each other so should use fallback.
Best regards,
Krzysztof
Alexandre Belloni
maintainerRe: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 65 lines · Krzysztof Kozlowski
Quoted 7 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
Suggestion was about the bindings. Not in the driver. I never said to list all compatibles in the driver...
Quoted 8 lines
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chipQuoted 6 lines
{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socI would suggest to use fallbacks as suggested by Conor at least for some of them. You referred to my previous comments about wildcards. Wildcard != fallback.
Quoted 3 lines
And Conor thought it should be rendered using a fallback compatible form based on ".data".
Based on common (compatible) programming model unless you already have clear hardware differences making them incompatible.
Quoted 12 lines
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }Quoted 2 lines
In this form, I think it might not be possible to show very graphically which chips are using the driver.
??? How is it impossible? For all other SoCs and architectures it is possible, so what is special for Loongson?
Quoted 3 lines
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Why it is inappropriate? I don't see the issue here... what is a "bridge" chip? Isn't this also an SoC?
Quoted 1 line
Quoted 4 lines
Quoted 1 line
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
From what I seen the IP and register set is the same, it is just the integration on the SoC that differs.
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 67 lines · Alexandre Belloni
Quoted 65 lines · Krzysztof Kozlowski
Quoted 7 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
Suggestion was about the bindings. Not in the driver. I never said to list all compatibles in the driver...
Quoted 8 lines
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chipQuoted 6 lines
{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socI would suggest to use fallbacks as suggested by Conor at least for some of them. You referred to my previous comments about wildcards. Wildcard != fallback.
Quoted 3 lines
And Conor thought it should be rendered using a fallback compatible form based on ".data".
Based on common (compatible) programming model unless you already have clear hardware differences making them incompatible.
Quoted 12 lines
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }Quoted 2 lines
In this form, I think it might not be possible to show very graphically which chips are using the driver.
??? How is it impossible? For all other SoCs and architectures it is possible, so what is special for Loongson?
Quoted 3 lines
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Why it is inappropriate? I don't see the issue here... what is a "bridge" chip? Isn't this also an SoC?
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
From what I seen the IP and register set is the same, it is just the integration on the SoC that differs.
Actually, ls1c RTC registers are not the same as ls1b. ls1c doesn't have the following resgisters.
+#define TOY_MATCH0_REG 0x34 /* TOY timing interrupt 0 */ +#define TOY_MATCH1_REG 0x38 /* TOY timing interrupt 1 */ +#define TOY_MATCH2_REG 0x3c /* TOY timing interrupt 2 */
+#define RTC_CTRL_REG 0x40 /* TOY and RTC control register */ +#define RTC_TRIM_REG 0x60 /* Must be initialized to 0 */ +#define RTC_WRITE0_REG 0x64 /* RTC counters value (write-only) */ +#define RTC_READ0_REG 0x68 /* RTC counters value (read-only) */ +#define RTC_MATCH0_REG 0x6c /* RTC timing interrupt 0 */ +#define RTC_MATCH1_REG 0x70 /* RTC timing interrupt 1 */ +#define RTC_MATCH2_REG 0x74 /* RTC timing interrupt 2 */
As you can see, it doesn't support match function, which is why ls1c doesn't support RTC interrupt.
Quoted 5 lines
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 3 lines
Best regards, Keguang Zhang
Alexandre Belloni
maintainerRe: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 91 lines · Keguang Zhang
Quoted 67 lines · Alexandre Belloni
Quoted 65 lines · Krzysztof Kozlowski
Quoted 7 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
Suggestion was about the bindings. Not in the driver. I never said to list all compatibles in the driver...
Quoted 8 lines
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chipQuoted 6 lines
{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socI would suggest to use fallbacks as suggested by Conor at least for some of them. You referred to my previous comments about wildcards. Wildcard != fallback.
Quoted 3 lines
And Conor thought it should be rendered using a fallback compatible form based on ".data".
Based on common (compatible) programming model unless you already have clear hardware differences making them incompatible.
Quoted 12 lines
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }Quoted 2 lines
In this form, I think it might not be possible to show very graphically which chips are using the driver.
??? How is it impossible? For all other SoCs and architectures it is possible, so what is special for Loongson?
Quoted 3 lines
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Why it is inappropriate? I don't see the issue here... what is a "bridge" chip? Isn't this also an SoC?
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
From what I seen the IP and register set is the same, it is just the integration on the SoC that differs.
Actually, ls1c RTC registers are not the same as ls1b. ls1c doesn't have the following resgisters.
(quoted diff) +10
-0+#define TOY_MATCH0_REG 0x34 /* TOY timing interrupt 0 */ +#define TOY_MATCH1_REG 0x38 /* TOY timing interrupt 1 */ +#define TOY_MATCH2_REG 0x3c /* TOY timing interrupt 2 */ +#define RTC_CTRL_REG 0x40 /* TOY and RTC control register */ +#define RTC_TRIM_REG 0x60 /* Must be initialized to 0 */ +#define RTC_WRITE0_REG 0x64 /* RTC counters value (write-only) */ +#define RTC_READ0_REG 0x68 /* RTC counters value (read-only) */ +#define RTC_MATCH0_REG 0x6c /* RTC timing interrupt 0 */ +#define RTC_MATCH1_REG 0x70 /* RTC timing interrupt 1 */ +#define RTC_MATCH2_REG 0x74 /* RTC timing interrupt 2 */
Quoted 2 lines
As you can see, it doesn't support match function, which is why ls1c doesn't support RTC interrupt.
They are in the Loongson1C Processor User Manual I have which states:
21.2.6 SYS_TOYMATCH0/1/2 (no register in 1C2)
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 93 lines · Alexandre Belloni
Quoted 91 lines · Keguang Zhang
Quoted 67 lines · Alexandre Belloni
Quoted 65 lines · Krzysztof Kozlowski
Quoted 7 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
Suggestion was about the bindings. Not in the driver. I never said to list all compatibles in the driver...
Quoted 8 lines
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chipQuoted 6 lines
{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socI would suggest to use fallbacks as suggested by Conor at least for some of them. You referred to my previous comments about wildcards. Wildcard != fallback.
Quoted 3 lines
And Conor thought it should be rendered using a fallback compatible form based on ".data".
Based on common (compatible) programming model unless you already have clear hardware differences making them incompatible.
Quoted 12 lines
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }Quoted 2 lines
In this form, I think it might not be possible to show very graphically which chips are using the driver.
??? How is it impossible? For all other SoCs and architectures it is possible, so what is special for Loongson?
Quoted 3 lines
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Why it is inappropriate? I don't see the issue here... what is a "bridge" chip? Isn't this also an SoC?
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
From what I seen the IP and register set is the same, it is just the integration on the SoC that differs.
Actually, ls1c RTC registers are not the same as ls1b. ls1c doesn't have the following resgisters.
(quoted diff) +10
-0+#define TOY_MATCH0_REG 0x34 /* TOY timing interrupt 0 */ +#define TOY_MATCH1_REG 0x38 /* TOY timing interrupt 1 */ +#define TOY_MATCH2_REG 0x3c /* TOY timing interrupt 2 */ +#define RTC_CTRL_REG 0x40 /* TOY and RTC control register */ +#define RTC_TRIM_REG 0x60 /* Must be initialized to 0 */ +#define RTC_WRITE0_REG 0x64 /* RTC counters value (write-only) */ +#define RTC_READ0_REG 0x68 /* RTC counters value (read-only) */ +#define RTC_MATCH0_REG 0x6c /* RTC timing interrupt 0 */ +#define RTC_MATCH1_REG 0x70 /* RTC timing interrupt 1 */ +#define RTC_MATCH2_REG 0x74 /* RTC timing interrupt 2 */
Quoted 7 lines
Quoted 2 lines
As you can see, it doesn't support match function, which is why ls1c doesn't support RTC interrupt.
They are in the Loongson1C Processor User Manual I have which states:
21.2.6 SYS_TOYMATCH0/1/2 (no register in 1C2)
I'm afraid that your user manual is outdated.
The latest 1C300 user manual (v1.5) doesn't have section 21.2.6 at all. Sorry, I can't find English version.
Here is the Chinese version:
https://www.loongson.cn/uploads/images/2022051616223977135.%E9%BE%99%E8%8A%AF1C300%E5%A4%84%E7%90%86%E5%99%A8%E7%94%A8%E6%88%B7%E6%89%8B%E5%86%8C.pdf
Quoted 4 lines
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 3 lines
Best regards, Keguang Zhang
Re: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
In reply to Krzysztof KozlowskiQuoted 57 lines · Krzysztof Kozlowski
Quoted 7 lines · Binbin Zhou
Hi Krzysztof:
Excuse me.
We have different opinions on how to better describe rtc-loongson compatible.Based on my previous communication with you, I think we should list all the Socs in the driver and drop the wildcards.
Suggestion was about the bindings. Not in the driver. I never said to list all compatibles in the driver...
Quoted 8 lines
This should be clearer and more straightforward:
{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config
}, //ls1b soc
{ .compatible = "loongson,ls1c-rtc", .data =&ls1x_rtc_config
}, //ls1c soc
{ .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config}, //ls7a bridge chipQuoted 6 lines
{ .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config }, // ls2k0500 soc { .compatible = "loongson,ls2k2000-rtc", .data = &generic_rtc_config }, // ls2k2000 soc { .compatible = "loongson,ls2k1000-rtc", .data =
&ls2k1000_rtc_config}, // ls2k1000 socI would suggest to use fallbacks as suggested by Conor at least for some of them. You referred to my previous comments about wildcards. Wildcard != fallback.
Quoted 3 lines
And Conor thought it should be rendered using a fallback compatible form based on ".data".
Based on common (compatible) programming model unless you already have clear hardware differences making them incompatible.
Quoted 12 lines
"loongson,ls1b-rtc" "loongson,ls1c-rtc", "loongson,ls1b-rtc" "loongson,ls7a-rtc" "loongson,ls2k0500-rtc", "loongson,ls7a-rtc" "longson,ls2k2000-rtc", "longson,ls7a-rtc" "loonson,ls2k1000-rtc" { .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }Quoted 2 lines
In this form, I think it might not be possible to show very graphically which chips are using the driver.
??? How is it impossible? For all other SoCs and architectures it is possible, so what is special for Loongson?
Quoted 7 lines
Quoted 3 lines
Also, for example, "ls7a" is a bridge chip, while "ls2k2000"/"ls2k0500" are soc chips, and it seems inappropriate to integrate them into one item.
Why it is inappropriate? I don't see the issue here... what is a "bridge" chip? Isn't this also an SoC?
Hi Krzysztof:
LS7A bridge chip can be considered as a combination of South and North bridge. Generally, it will be connected to the Loongson-3 series CPUs. LS2K500/LS2K1000/LS2K2000 refers to the LS2K series embedded CPU chip.
Therefore, from the understanding of the driver code, I don't think it is appropriate to fallback them together. Please pardon me if this view does not apply to dt-binding.
If fallback is necessary, can we have this:
Let ls7a remain a separate item.
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc"
"loongson,ls2k2000-rtc", "loongson,ls2k0500-rtc"
"loongson,ls2k1000-rtc"
{ .compatible = "loongson,ls1b-rtc", .data = &ls1x_rtc_config } { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k0500-rtc", .data = &generic_rtc_config } { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }
Thanks.
Binbin
Quoted 12 lines
Quoted 3 lines
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
ls2k500 and ls2k2000 seem compatible with each other so should use fallback.
Best regards,
Krzysztof
Alexandre Belloni
maintainerRe: [PATCH V4 1/5] dt-bindings: rtc: Remove the LS2X from the trivial RTCs
Quoted 10 lines · Binbin Zhou
Hi Krzysztof:
LS7A bridge chip can be considered as a combination of South and North bridge. Generally, it will be connected to the Loongson-3 series CPUs. LS2K500/LS2K1000/LS2K2000 refers to the LS2K series embedded CPU chip.
Therefore, from the understanding of the driver code, I don't think it is appropriate to fallback them together. Please pardon me if this view does not apply to dt-binding.
Quoted 6 lines
If fallback is necessary, can we have this:
Let ls7a remain a separate item.
"loongson,ls1b-rtc"
"loongson,ls1c-rtc", "loongson,ls1b-rtc"
Based on Keguang's feedback, "loongson,ls1b-rtc" is not a fallback for "loongson,ls1c-rtc" as it is missing registers, keep it standalone.
Quoted 25 lines
"loongson,ls7a-rtc"
"loongson,ls2k0500-rtc"
"loongson,ls2k2000-rtc", "loongson,ls2k0500-rtc"
"loongson,ls2k1000-rtc"{ .compatible = "loongson,ls1b-rtc", .data =
&ls1x_rtc_config} { .compatible = "loongson,ls7a-rtc", .data =&generic_rtc_config} { .compatible = "loongson,ls2k0500-rtc", .data =&generic_rtc_config} { .compatible = "loongson,ls2k1000-rtc", .data =&ls2k1000_rtc_config}Thanks.
BinbinQuoted 12 lines
Quoted 3 lines
Which one do you think is more suitable for us?
Use fallbacks for some. You pointed difference in alarm for ls1x, right? If so, then they can stay separate.
ls2k500 and ls2k2000 seem compatible with each other so should use fallback.
Best regards,
Krzysztof
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 2/5 rtc: Remove the Loongson-1 RTC driver
In reply to Binbin ZhouRemove the ls1x-rtc driver as it is obsolete. We will continue to support the ls1x RTC in the upcoming Loongson unified RTC driver rtc-loongson.
--- drivers/rtc/Kconfig | 10 --- drivers/rtc/Makefile | 1 - drivers/rtc/rtc-ls1x.c | 192 ----------------------------------------- 3 files changed, 203 deletions(-) delete mode 100644 drivers/rtc/rtc-ls1x.c
drivers/rtc/Kconfig +0 -10
@@ -1726,16 +1726,6 @@ config RTC_DRV_TEGRA This drive can also be built as a module. If so, the module will be called rtc-tegra. -config RTC_DRV_LOONGSON1 - tristate "loongson1 RTC support" - depends on MACH_LOONGSON32 - help - This is a driver for the loongson1 on-chip Counter0 (Time-Of-Year - counter) to be used as a RTC. - - This driver can also be built as a module. If so, the module - will be called rtc-ls1x. - config RTC_DRV_MXC tristate "Freescale MXC Real Time Clock" depends on ARCH_MXC || COMPILE_TEST
drivers/rtc/Makefile +0 -1
@@ -78,7 +78,6 @@ obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o -obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o
drivers/rtc/rtc-ls1x.c deleted +0 -192
192 lines not on this page · raw message
Signature · 1 line
2.39.1
Re: [PATCH V4 2/5] rtc: Remove the Loongson-1 RTC driver
Quoted 8 lines · Binbin Zhou
Remove the ls1x-rtc driver as it is obsolete. We will continue to support the ls1x RTC in the upcoming Loongson unified RTC driver rtc-loongson.
Cc Keguang Zhang <[email protected]>Cc zhao zhang <[email protected]>Cc Yang Ling <[email protected]>Signed-off-by Binbin Zhou <[email protected]>
Quoted 5 lines
--- drivers/rtc/Kconfig | 10 --- drivers/rtc/Makefile | 1 - drivers/rtc/rtc-ls1x.c | 192 ----------------------------------------- 3 files changed, 203 deletions(-)
Removal in one commit and adding a new driver in second is not what we usually do. We expect code to be developed and to evolve.
Best regards,
Krzysztof
Alexandre Belloni
maintainerRe: [PATCH V4 2/5] rtc: Remove the Loongson-1 RTC driver
Quoted 15 lines · Krzysztof Kozlowski
Quoted 8 lines · Binbin Zhou
Remove the ls1x-rtc driver as it is obsolete. We will continue to support the ls1x RTC in the upcoming Loongson unified RTC driver rtc-loongson.
Cc Keguang Zhang <[email protected]>Cc zhao zhang <[email protected]>Cc Yang Ling <[email protected]>Signed-off-by Binbin Zhou <[email protected]>Quoted 5 lines
--- drivers/rtc/Kconfig | 10 --- drivers/rtc/Makefile | 1 - drivers/rtc/rtc-ls1x.c | 192 ----------------------------------------- 3 files changed, 203 deletions(-)
Quoted 3 lines
Removal in one commit and adding a new driver in second is not what we usually do. We expect code to be developed and to evolve.
I'm fine with that, even if unusual.
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 3/5 rtc: Add rtc driver for the Loongson family chips
In reply to Binbin ZhouThe Loongson family chips use an on-chip counter 0 (Time Of Year counter) as the RTC. We will refer to them as rtc-loongson.
--- drivers/rtc/Kconfig | 13 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-loongson.c | 390 +++++++++++++++++++++++++++++++++++++ 3 files changed, 404 insertions(+) create mode 100644 drivers/rtc/rtc-loongson.c
drivers/rtc/Kconfig +13 -0
@@ -1685,6 +1685,19 @@ config RTC_DRV_JZ4740 This driver can also be built as a module. If so, the module will be called rtc-jz4740. +config RTC_DRV_LOONGSON + tristate "Loongson On-chip RTC" + depends on MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST + select REGMAP_MMIO + help + This is a driver for the Loongson on-chip Counter0 (Time-Of-Year + counter) to be used as a RTC. + It can be found on Loongson-1 series cpu, Loongson-2K series cpu + and Loongson LS7A bridge chips. + + This driver can also be built as a module. If so, the module + will be called rtc-loongson. + config RTC_DRV_LPC24XX tristate "NXP RTC for LPC178x/18xx/408x/43xx" depends on ARCH_LPC18XX || COMPILE_TEST
drivers/rtc/Makefile +1 -0
@@ -78,6 +78,7 @@ obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o +obj-$(CONFIG_RTC_DRV_LOONGSON) += rtc-loongson.o obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o
drivers/rtc/rtc-loongson.c new file +390 -0
390 lines not on this page · raw message
Signature · 1 line
2.39.1
PATCH v4 4/5 MIPS: Loongson64: DTS: Add RTC support to LS7A PCH
In reply to Binbin ZhouThe RTC module is now supported, enable it.
--- arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/mips/boot/dts/loongson/ls7a-pch.dtsi +7 -0
@@ -19,6 +19,13 @@ pic: interrupt-controller@10000000 { #interrupt-cells = <2>; }; + rtc0: rtc@100d0100 { + compatible = "loongson,ls7a-rtc"; + reg = <0 0x100d0100 0 0x78>; + interrupt-parent = <&pic>; + interrupts = <52 IRQ_TYPE_LEVEL_HIGH>; + }; + ls7a_uart0: serial@10080000 { compatible = "ns16550a"; reg = <0 0x10080000 0 0x100>;
Signature · 1 line
2.39.1
PATCH v4 5/5 MIPS: Loongson64: DTS: Add RTC support to Loongson-2K1000
In reply to Binbin ZhouThe module is now supported, enable it.
--- arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi +7 -0
@@ -97,6 +97,13 @@ liointc1: interrupt-controller@1fe11440 { <0x00000000>; /* int3 */ }; + rtc0: rtc@1fe07800 { + compatible = "loongson,ls2k1000-rtc"; + reg = <0 0x1fe07800 0 0x78>; + interrupt-parent = <&liointc0>; + interrupts = <60 IRQ_TYPE_LEVEL_LOW>; + }; + uart0: serial@1fe00000 { compatible = "ns16550a"; reg = <0 0x1fe00000 0 0x8>;
Signature · 1 line
2.39.1