diff mbox series

[v1,2/2] dt-bindings: gpio: add loongson series gpio

Message ID 20221108092107.28996-2-zhuyinbo@loongson.cn
State New
Headers show
Series [v1,1/2] gpio: loongson: add dts/acpi gpio support | expand

Commit Message

Yinbo Zhu Nov. 8, 2022, 9:21 a.m. UTC
Add the Loongson series gpio binding with DT schema format using
json-schema.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
 .../bindings/gpio/loongson,ls-gpio.yaml       | 154 ++++++++++++++++++
 MAINTAINERS                                   |  11 ++
 2 files changed, 165 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml

Comments

Linus Walleij Nov. 8, 2022, 12:11 p.m. UTC | #1
Hi Yinbo,

thanks for your patch!

On Tue, Nov 8, 2022 at 10:21 AM Yinbo Zhu <zhuyinbo@loongson.cn> wrote:

> Add the Loongson series gpio binding with DT schema format using
> json-schema.
>
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>

> +  gpio-ranges: true

So you are using GPIO ranges... and...

> +  loongson,gpio_base:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description:
> +      This option indicate the first GPIO number in this node.

Then you have added this to reimplement gpio ranges.

It also shows in the driver.

Drop gpio_base altogether (we do not encode linux-specific properties
into the device trees) and use gpio-ranges as they are intended to
map between the GPIO numberspace and the pin control pin number
space.

See
Documentation/devicetree/bindings/gpio/gpio.txt
for documentation on gpio-ranges, also look how other drivers are
using them.

Yours,
Linus Walleij
Yinbo Zhu Nov. 14, 2022, 9:50 a.m. UTC | #2
在 2022/11/8 下午11:28, Krzysztof Kozlowski 写道:
> On 08/11/2022 10:21, Yinbo Zhu wrote:
>> Add the Loongson series gpio binding with DT schema format using
>> json-schema.
>>
>> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
>> ---
>>   .../bindings/gpio/loongson,ls-gpio.yaml       | 154 ++++++++++++++++++
>>   MAINTAINERS                                   |  11 ++
>>   2 files changed, 165 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
>> new file mode 100644
>> index 000000000000..9d335262ddcc
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
>> @@ -0,0 +1,154 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/gpio/loongson,ls-gpio.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Loongson series GPIO controller.
>> +
>> +maintainers:
>> +  - Yinbo Zhu <zhuyinbo@loongson.cn>
>> +
>> +properties:
>> +  compatible:
>> +    enum:
>> +      - loongson,ls2k-gpio
>> +      - loongson,ls7a-gpio
>> +
>> +  reg:
>> +    maxItems: 1
>> +
>> +  ngpios: true
> 
> minimum? maximum?
okay, I got it.
> 
>> +
>> +  "#gpio-cells":
>> +    const: 2
>> +
>> +  gpio-controller: true
>> +
>> +  gpio-ranges: true
>> +
>> +  loongson,conf_offset:
> 
> No underscores in node names. Plus comments from Linus seem to apply
> here as well. Drop it entirely or explain why this is not part of
> compatible, why this is needed and why encoding programming model
> address in DT matches the DT...
Add it is to distinguish differnt address in different platform.
and I had drop them and initial them in kernel driver that depend
on diffent compatible.
> 
> 
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description:
>> +      This option indicate this GPIO configuration offset address.
>> +
>> +  loongson,out_offset:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description:
>> +      This option indicate this GPIO output value offset address.
> 
> Drop
> 
>> +
>> +  loongson,in_offset:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description:
>> +      This option indicate this GPIO input value offset address.
> 
> Drop
> 
> 
>> +
>> +  loongson,gpio_base:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description:
>> +      This option indicate the first GPIO number in this node.
> 
> Drop
> 
> 
>> +
>> +  loongson,support_irq:
>> +    $ref: /schemas/types.yaml#/definitions/flag
>> +    description:
>> +      This option indicate this GPIO whether support interrupt.
> 
> Drop
> 
>> +
>> +  interrupts:
>> +    minItems: 1
>> +    maxItems: 64
>> +
>> +required:
>> +  - compatible
>> +  - reg
>> +  - ngpios
>> +  - "#gpio-cells"
>> +  - gpio-controller
>> +  - gpio-ranges
>> +  - interrupts
>> +
>> +additionalProperties: false
>> +
>> +examples:
>> +  - |
>> +    #include <dt-bindings/interrupt-controller/irq.h>
>> +
>> +    gpio0: gpio@1fe00500 {
>> +      compatible = "loongson,ls2k-gpio";
>> +      reg = <0x1fe00500 0x38>;
>> +      ngpios = <64>;
>> +      #gpio-cells = <2>;
>> +      gpio-controller;
>> +      gpio-ranges = <&pctrl 0 0 15>,
>> +                    <&pctrl 16 16 15>,
>> +                    <&pctrl 32 32 10>,
>> +                    <&pctrl 44 44 20>;
>> +      loongson,conf_offset = <0>;
>> +      loongson,out_offset = <0x10>;
>> +      loongson,in_offset = <0x20>;
>> +      loongson,gpio_base = <0>;
>> +      loongson,support_irq;
>> +      interrupt-parent = <&liointc1>;
>> +      interrupts = <28 IRQ_TYPE_LEVEL_LOW>,
>> +                   <29 IRQ_TYPE_LEVEL_LOW>,
>> +                   <30 IRQ_TYPE_LEVEL_LOW>,
>> +                   <30 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <26 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <>,
> 
> What's this?
There was no interrupt function in this gpio.
> 
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <>,
>> +                   <>,
> 
> What's this?
> 
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>,
>> +                   <27 IRQ_TYPE_LEVEL_LOW>;
>> +    };
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 916b2d9cffc0..878b8320ac3b 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -12048,6 +12048,17 @@ S:	Maintained
>>   F:	Documentation/devicetree/bindings/hwinfo/loongson,ls2k-chipid.yaml
>>   F:	drivers/soc/loongson/loongson2_guts.c
>>   
>> +LOONGSON SERIES GPIO DRIVER
>> +M:	Richard Liu, STMicroelectronics <richard.liu@st.com>
>> +M:	Arnaud Patard <apatard@mandriva.com>
>> +M:	Hongbing Hu <huhb@lemote.com>
>> +M:	Huacai Chen <chenhuacai@kernel.org>
>> +M:	Yinbo Zhu <zhuyinbo@loongson.cn>
> 
> Are they all maintainers of this driver?
add huacai and myself as maintainer.
> 
>> +L:	linux-gpio@vger.kernel.org
>> +S:	Maintained
>> +F:	Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
>> +F:	drivers/gpio/gpio-loongson.c
>> +
>>   LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)
>>   M:	Sathya Prakash <sathya.prakash@broadcom.com>
>>   M:	Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> 
> Best regards,
> Krzysztof
>
Krzysztof Kozlowski Nov. 18, 2022, 12:38 p.m. UTC | #3
On 14/11/2022 10:50, Yinbo Zhu wrote:
>
>>> +
>>> +  "#gpio-cells":
>>> +    const: 2
>>> +
>>> +  gpio-controller: true
>>> +
>>> +  gpio-ranges: true
>>> +
>>> +  loongson,conf_offset:
>>
>> No underscores in node names. Plus comments from Linus seem to apply
>> here as well. Drop it entirely or explain why this is not part of
>> compatible, why this is needed and why encoding programming model
>> address in DT matches the DT...
> Add it is to distinguish differnt address in different platform.
> and I had drop them and initial them in kernel driver that depend
> on diffent compatible.
>>

So if you had to drop these, please drop from the bindings.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
new file mode 100644
index 000000000000..9d335262ddcc
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
@@ -0,0 +1,154 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/loongson,ls-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson series GPIO controller.
+
+maintainers:
+  - Yinbo Zhu <zhuyinbo@loongson.cn>
+
+properties:
+  compatible:
+    enum:
+      - loongson,ls2k-gpio
+      - loongson,ls7a-gpio
+
+  reg:
+    maxItems: 1
+
+  ngpios: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-controller: true
+
+  gpio-ranges: true
+
+  loongson,conf_offset:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This option indicate this GPIO configuration offset address.
+
+  loongson,out_offset:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This option indicate this GPIO output value offset address.
+
+  loongson,in_offset:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This option indicate this GPIO input value offset address.
+
+  loongson,gpio_base:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This option indicate the first GPIO number in this node.
+
+  loongson,support_irq:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      This option indicate this GPIO whether support interrupt.
+
+  interrupts:
+    minItems: 1
+    maxItems: 64
+
+required:
+  - compatible
+  - reg
+  - ngpios
+  - "#gpio-cells"
+  - gpio-controller
+  - gpio-ranges
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    gpio0: gpio@1fe00500 {
+      compatible = "loongson,ls2k-gpio";
+      reg = <0x1fe00500 0x38>;
+      ngpios = <64>;
+      #gpio-cells = <2>;
+      gpio-controller;
+      gpio-ranges = <&pctrl 0 0 15>,
+                    <&pctrl 16 16 15>,
+                    <&pctrl 32 32 10>,
+                    <&pctrl 44 44 20>;
+      loongson,conf_offset = <0>;
+      loongson,out_offset = <0x10>;
+      loongson,in_offset = <0x20>;
+      loongson,gpio_base = <0>;
+      loongson,support_irq;
+      interrupt-parent = <&liointc1>;
+      interrupts = <28 IRQ_TYPE_LEVEL_LOW>,
+                   <29 IRQ_TYPE_LEVEL_LOW>,
+                   <30 IRQ_TYPE_LEVEL_LOW>,
+                   <30 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <26 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <>,
+                   <>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>,
+                   <27 IRQ_TYPE_LEVEL_LOW>;
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index 916b2d9cffc0..878b8320ac3b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12048,6 +12048,17 @@  S:	Maintained
 F:	Documentation/devicetree/bindings/hwinfo/loongson,ls2k-chipid.yaml
 F:	drivers/soc/loongson/loongson2_guts.c
 
+LOONGSON SERIES GPIO DRIVER
+M:	Richard Liu, STMicroelectronics <richard.liu@st.com>
+M:	Arnaud Patard <apatard@mandriva.com>
+M:	Hongbing Hu <huhb@lemote.com>
+M:	Huacai Chen <chenhuacai@kernel.org>
+M:	Yinbo Zhu <zhuyinbo@loongson.cn>
+L:	linux-gpio@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
+F:	drivers/gpio/gpio-loongson.c
+
 LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)
 M:	Sathya Prakash <sathya.prakash@broadcom.com>
 M:	Sreekanth Reddy <sreekanth.reddy@broadcom.com>