Message ID | 20230807074043.31288-2-zhuyinbo@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1284409vqr; Mon, 7 Aug 2023 00:42:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+2wb1YywDZAUVTxOmFGHB85mycame+Webq94HjWHuKl/mkp+uayk6tUXQLClVi5Jv2CtF X-Received: by 2002:aa7:dc12:0:b0:522:cb97:f198 with SMTP id b18-20020aa7dc12000000b00522cb97f198mr6679600edu.38.1691394138912; Mon, 07 Aug 2023 00:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691394138; cv=none; d=google.com; s=arc-20160816; b=xeJMf015jSR78jsIne1QHxZAKXHDSSId3XJYh6Uzn8ZPv319r1nsxj3nIBWyywXSnj uweiEzebjkpjsPnpJ6wDxuzgmx2DtId37e//PJg9jcX3wRHPRWulurk7uWHBkqxh5MwY FkymT5Tfbyxo93pwoKgiKoj2Xezz5lWUmkMf0KJWgAv0CQ1Z2GAZfs4ly1JirDumCmA7 NiFI+1qX3dO+Kr8y6Kt7dhmw7hefYjkzW4g3EgAD7KhIC39KujPA/dp9cThOOeqLMv63 LFq+zxcn/h0hZchCJsnSm9dFsIS4eaK4iyM3XhGqHFDrpbHvtFnXSzGL3bnhVEjz2MKD hgwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=C/Pd1K/SGMoK17JfA7aNkIGeNsDYE5rPa0yXkdDEJWg=; fh=03M9NuUp7mf+kiarWzGb9RQmG0WNybTkFW4IRsSZJPI=; b=zPfNJwg8e+EEOd4ay0cyyYWogbIWhvb2gvR/Mka1wJtXT20KvlL+S2t0lIRd5JkRBH czAnx362zBYVi8lriwe6ckxFpJIqnegcHComEnoW0SiHaODJgFpBbRt0z3Oolb9J+DpL b8BdD9ZzY0EhSaKl7/XrHfnkKN5Fnyf54tF2RfBmZTpnveR23kBxTZuCBsAkTk/XrtLc ACDre+3oL8BKwySzBmE9rQpmC3t0IZfbb6n1xJTebTRDtmKZtAWWk2ABpdZ/GT+CvCvS ZpKZBkfHMbF1IoIY0u9KqWEPPPF2Ln2/GkWY1j/WPhhfiNLpFn600R1sfruDEV3T+A7I mJLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a50ea88000000b00522d742bc4dsi5367269edo.334.2023.08.07.00.41.55; Mon, 07 Aug 2023 00:42:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjHGHlJ (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Mon, 7 Aug 2023 03:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbjHGHlE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Aug 2023 03:41:04 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22EA010FE; Mon, 7 Aug 2023 00:41:01 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.201]) by gateway (Coremail) with SMTP id _____8AxFvEJoNBkCOARAA--.40060S3; Mon, 07 Aug 2023 15:40:57 +0800 (CST) Received: from localhost.localdomain (unknown [10.20.42.201]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB838n9Bk+dBMAA--.56868S3; Mon, 07 Aug 2023 15:40:56 +0800 (CST) From: Yinbo Zhu <zhuyinbo@loongson.cn> To: Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <brgl@bgdev.pl>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jianmin Lv <lvjianmin@loongson.cn>, wanghongliang@loongson.cn, loongson-kernel@lists.loongnix.cn, Yinbo Zhu <zhuyinbo@loongson.cn> Subject: [PATCH v3 1/2] gpio: dt-bindings: add parsing of loongson gpio offset Date: Mon, 7 Aug 2023 15:40:42 +0800 Message-Id: <20230807074043.31288-2-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230807074043.31288-1-zhuyinbo@loongson.cn> References: <20230807074043.31288-1-zhuyinbo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8BxB838n9Bk+dBMAA--.56868S3 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773555300471141061 X-GMAIL-MSGID: 1773555300471141061 |
Series |
gpio: loongson: add firmware offset parse support
|
|
Commit Message
Yinbo Zhu
Aug. 7, 2023, 7:40 a.m. UTC
Loongson GPIO controllers come in multiple variants that are compatible
except for certain register offset values. Add support in yaml file for
device properties allowing to specify them in DT.
Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
.../bindings/gpio/loongson,ls-gpio.yaml | 40 ++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
Comments
Hey, On Mon, Aug 07, 2023 at 03:40:42PM +0800, Yinbo Zhu wrote: > Loongson GPIO controllers come in multiple variants that are compatible > except for certain register offset values. Add support in yaml file for > device properties allowing to specify them in DT. > > Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn> > --- > .../bindings/gpio/loongson,ls-gpio.yaml | 40 ++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml > index fb86e8ce6349..fc51cf40fccd 100644 > --- a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml > +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml > @@ -14,6 +14,7 @@ properties: > enum: > - loongson,ls2k-gpio > - loongson,ls7a-gpio > + - loongson,ls2k1000-gpio If you're adding new compatibles that depend on the new offset properties to function, they could be set up with the existing "ls2k-gpio" as a fallback, so that further driver changes are not required when you add ones for the 2k500 etc. > > reg: > maxItems: 1 > @@ -29,6 +30,33 @@ properties: > > gpio-ranges: true > > + loongson,gpio-conf-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO configuration register offset address. > + > + loongson,gpio-out-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO output register offset address. > + > + loongson,gpio-in-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO input register offset address. > + > + loongson,gpio-ctrl-mode: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO control mode, where '0' represents > + bit control mode and '1' represents byte control mode. How is one supposed to know which of these modes to use? > + loongson,gpio-inten-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO interrupt enable register offset > + address. > + tbh, I want to leave the final say on this stuff to Krzysztof or Rob. I'm not really sure what the best way to do to support your GPIO controllers is & I don't understand your hardware sufficiently to come up with an approach that I would use had I been in your shoes. Thanks, Conor. > interrupts: > minItems: 1 > maxItems: 64 > @@ -39,6 +67,11 @@ required: > - ngpios > - "#gpio-cells" > - gpio-controller > + - loongson,gpio-conf-offset > + - loongson,gpio-in-offset > + - loongson,gpio-out-offset > + - loongson,gpio-ctrl-mode > + - loongson,gpio-inten-offset > - gpio-ranges > - interrupts > > @@ -49,11 +82,16 @@ examples: > #include <dt-bindings/interrupt-controller/irq.h> > > gpio0: gpio@1fe00500 { > - compatible = "loongson,ls2k-gpio"; > + compatible = "loongson,ls2k1000-gpio"; > reg = <0x1fe00500 0x38>; > ngpios = <64>; > #gpio-cells = <2>; > gpio-controller; > + loongson,gpio-conf-offset = <0>; > + loongson,gpio-in-offset = <0x20>; > + loongson,gpio-out-offset = <0x10>; > + loongson,gpio-ctrl-mode = <0>; > + loongson,gpio-inten-offset = <0x30>; > gpio-ranges = <&pctrl 0 0 15>, > <&pctrl 16 16 15>, > <&pctrl 32 32 10>, > -- > 2.20.1 >
On 07/08/2023 09:40, Yinbo Zhu wrote: > Loongson GPIO controllers come in multiple variants that are compatible > except for certain register offset values. Add support in yaml file for > device properties allowing to specify them in DT. > > Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn> > --- > .../bindings/gpio/loongson,ls-gpio.yaml | 40 ++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml > index fb86e8ce6349..fc51cf40fccd 100644 > --- a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml > +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml > @@ -14,6 +14,7 @@ properties: > enum: > - loongson,ls2k-gpio > - loongson,ls7a-gpio > + - loongson,ls2k1000-gpio > > reg: > maxItems: 1 > @@ -29,6 +30,33 @@ properties: > > gpio-ranges: true > > + loongson,gpio-conf-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO configuration register offset address. > + > + loongson,gpio-out-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO output register offset address. > + > + loongson,gpio-in-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO input register offset address. > + > + loongson,gpio-ctrl-mode: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO control mode, where '0' represents > + bit control mode and '1' represents byte control mode. I have no clue what does it mean. Is it only 0 or 1? Then it should be enum or even bool. > + > + loongson,gpio-inten-offset: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + This option indicate this GPIO interrupt enable register offset > + address. > + > interrupts: > minItems: 1 > maxItems: 64 > @@ -39,6 +67,11 @@ required: > - ngpios > - "#gpio-cells" > - gpio-controller > + - loongson,gpio-conf-offset > + - loongson,gpio-in-offset > + - loongson,gpio-out-offset > + - loongson,gpio-ctrl-mode > + - loongson,gpio-inten-offset No, you cannot add them as required to every other device. First, there is no single need. Second, it breaks the ABI. > - gpio-ranges > - interrupts > > @@ -49,11 +82,16 @@ examples: > #include <dt-bindings/interrupt-controller/irq.h> > > gpio0: gpio@1fe00500 { > - compatible = "loongson,ls2k-gpio"; > + compatible = "loongson,ls2k1000-gpio"; > reg = <0x1fe00500 0x38>; > ngpios = <64>; > #gpio-cells = <2>; > gpio-controller; > + loongson,gpio-conf-offset = <0>; > + loongson,gpio-in-offset = <0x20>; > + loongson,gpio-out-offset = <0x10>; > + loongson,gpio-ctrl-mode = <0>; > + loongson,gpio-inten-offset = <0x30>; I still think that you just embed the programming model into properties, instead of using dedicated compatible for different blocks. It could be fine, although I would prefer to check it with your DTS. Where is your DTS? Best regards, Krzysztof
在 2023/8/8 下午11:05, Krzysztof Kozlowski 写道: > On 07/08/2023 09:40, Yinbo Zhu wrote: >> Loongson GPIO controllers come in multiple variants that are compatible >> except for certain register offset values. Add support in yaml file for >> device properties allowing to specify them in DT. >> >> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn> >> --- >> .../bindings/gpio/loongson,ls-gpio.yaml | 40 ++++++++++++++++++- >> 1 file changed, 39 insertions(+), 1 deletion(-) >> >> diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml >> index fb86e8ce6349..fc51cf40fccd 100644 >> --- a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml >> +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml >> @@ -14,6 +14,7 @@ properties: >> enum: >> - loongson,ls2k-gpio >> - loongson,ls7a-gpio >> + - loongson,ls2k1000-gpio >> >> reg: >> maxItems: 1 >> @@ -29,6 +30,33 @@ properties: >> >> gpio-ranges: true >> >> + loongson,gpio-conf-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO configuration register offset address. >> + >> + loongson,gpio-out-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO output register offset address. >> + >> + loongson,gpio-in-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO input register offset address. >> + >> + loongson,gpio-ctrl-mode: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO control mode, where '0' represents >> + bit control mode and '1' represents byte control mode. > > I have no clue what does it mean. Is it only 0 or 1? Then it should be > enum or even bool. Yes, it only 0 or 1, and I will use bool type. Byte mode is to access by byte, such as gpio3, the base address of the gpio controller is offset by 3 bytes as the access address of gpio3. The bit mode is the normal mode that like other platform gpio and it is to access by bit. > >> + >> + loongson,gpio-inten-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO interrupt enable register offset >> + address. >> + >> interrupts: >> minItems: 1 >> maxItems: 64 >> @@ -39,6 +67,11 @@ required: >> - ngpios >> - "#gpio-cells" >> - gpio-controller >> + - loongson,gpio-conf-offset >> + - loongson,gpio-in-offset >> + - loongson,gpio-out-offset >> + - loongson,gpio-ctrl-mode >> + - loongson,gpio-inten-offset > > No, you cannot add them as required to every other device. First, there > is no single need. Second, it breaks the ABI. Okay, I will remove it in required paragraph. > >> - gpio-ranges >> - interrupts >> >> @@ -49,11 +82,16 @@ examples: >> #include <dt-bindings/interrupt-controller/irq.h> >> >> gpio0: gpio@1fe00500 { >> - compatible = "loongson,ls2k-gpio"; >> + compatible = "loongson,ls2k1000-gpio"; >> reg = <0x1fe00500 0x38>; >> ngpios = <64>; >> #gpio-cells = <2>; >> gpio-controller; >> + loongson,gpio-conf-offset = <0>; >> + loongson,gpio-in-offset = <0x20>; >> + loongson,gpio-out-offset = <0x10>; >> + loongson,gpio-ctrl-mode = <0>; >> + loongson,gpio-inten-offset = <0x30>; > > I still think that you just embed the programming model into properties, > instead of using dedicated compatible for different blocks. It could be > fine, although I would prefer to check it with your DTS Okay, I got it, and if I understand correctly, you seem to agree with me adding attributes like this. And, if using this method that programming model into dts properites, then when adding a new platform's GPIO, there is no longer a need to modify the driver because gpio controller is compatible and different platform can use a same compatible. > > Where is your DTS? Sorry, the dts containing gpio nodes are only available in the product code and have not been sent to the community yet. 2k500, 2k2000, and 3a5000's gpio dts node have been listed in v2, which gpio dts node will be added in upstream dts. Thanks, Yinbo.
在 2023/8/8 下午8:05, Conor Dooley 写道: > Hey, > > On Mon, Aug 07, 2023 at 03:40:42PM +0800, Yinbo Zhu wrote: >> Loongson GPIO controllers come in multiple variants that are compatible >> except for certain register offset values. Add support in yaml file for >> device properties allowing to specify them in DT. >> >> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn> >> --- >> .../bindings/gpio/loongson,ls-gpio.yaml | 40 ++++++++++++++++++- >> 1 file changed, 39 insertions(+), 1 deletion(-) >> >> diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml >> index fb86e8ce6349..fc51cf40fccd 100644 >> --- a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml >> +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml >> @@ -14,6 +14,7 @@ properties: >> enum: >> - loongson,ls2k-gpio >> - loongson,ls7a-gpio >> + - loongson,ls2k1000-gpio > > If you're adding new compatibles that depend on the new offset > properties to function, they could be set up with the existing > "ls2k-gpio" as a fallback, so that further driver changes are not > required when you add ones for the 2k500 etc. okay, I got it. > >> >> reg: >> maxItems: 1 >> @@ -29,6 +30,33 @@ properties: >> >> gpio-ranges: true >> >> + loongson,gpio-conf-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO configuration register offset address. >> + >> + loongson,gpio-out-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO output register offset address. >> + >> + loongson,gpio-in-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO input register offset address. >> + >> + loongson,gpio-ctrl-mode: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO control mode, where '0' represents >> + bit control mode and '1' represents byte control mode. > > How is one supposed to know which of these modes to use? Byte mode is to access by byte, such as gpio3, the base address of the gpio controller is offset by 3 bytes as the access address of gpio3. The bit mode is the normal mode that like other platform gpio and it is to access by bit. If both modes are supported, it is recommended to prioritize using byte mode that according to spec. > >> + loongson,gpio-inten-offset: >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + description: >> + This option indicate this GPIO interrupt enable register offset >> + address. >> + > > tbh, I want to leave the final say on this stuff to Krzysztof or Rob. > I'm not really sure what the best way to do to support your GPIO > controllers is & I don't understand your hardware sufficiently to come > up with an approach that I would use had I been in your shoes. > okay, I got it. Thanks, Yinbo > >> interrupts: >> minItems: 1 >> maxItems: 64 >> @@ -39,6 +67,11 @@ required: >> - ngpios >> - "#gpio-cells" >> - gpio-controller >> + - loongson,gpio-conf-offset >> + - loongson,gpio-in-offset >> + - loongson,gpio-out-offset >> + - loongson,gpio-ctrl-mode >> + - loongson,gpio-inten-offset >> - gpio-ranges >> - interrupts >> >> @@ -49,11 +82,16 @@ examples: >> #include <dt-bindings/interrupt-controller/irq.h> >> >> gpio0: gpio@1fe00500 { >> - compatible = "loongson,ls2k-gpio"; >> + compatible = "loongson,ls2k1000-gpio"; >> reg = <0x1fe00500 0x38>; >> ngpios = <64>; >> #gpio-cells = <2>; >> gpio-controller; >> + loongson,gpio-conf-offset = <0>; >> + loongson,gpio-in-offset = <0x20>; >> + loongson,gpio-out-offset = <0x10>; >> + loongson,gpio-ctrl-mode = <0>; >> + loongson,gpio-inten-offset = <0x30>; >> gpio-ranges = <&pctrl 0 0 15>, >> <&pctrl 16 16 15>, >> <&pctrl 32 32 10>, >> -- >> 2.20.1 >>
On 09/08/2023 09:28, Yinbo Zhu wrote: >> >>> - gpio-ranges >>> - interrupts >>> >>> @@ -49,11 +82,16 @@ examples: >>> #include <dt-bindings/interrupt-controller/irq.h> >>> >>> gpio0: gpio@1fe00500 { >>> - compatible = "loongson,ls2k-gpio"; >>> + compatible = "loongson,ls2k1000-gpio"; >>> reg = <0x1fe00500 0x38>; >>> ngpios = <64>; >>> #gpio-cells = <2>; >>> gpio-controller; >>> + loongson,gpio-conf-offset = <0>; >>> + loongson,gpio-in-offset = <0x20>; >>> + loongson,gpio-out-offset = <0x10>; >>> + loongson,gpio-ctrl-mode = <0>; >>> + loongson,gpio-inten-offset = <0x30>; >> >> I still think that you just embed the programming model into properties, >> instead of using dedicated compatible for different blocks. It could be >> fine, although I would prefer to check it with your DTS > > Okay, I got it, and if I understand correctly, you seem to agree with > me adding attributes like this. > > And, if using this method that programming model into dts properites, > then when adding a new platform's GPIO, there is no longer a need to > modify the driver because gpio controller is compatible and different > platform can use a same compatible. Uhu, so there we are. You use this method now to avoid new compatibles. No, therefore I do not agree. > >> >> Where is your DTS? > > > Sorry, the dts containing gpio nodes are only available in the product > code and have not been sent to the community yet. Does not help to convince us, but it is your right. With this and above explanation, my answer is no - NAK. Best regards, Krzysztof
On Wed, Aug 09, 2023 at 03:47:55PM +0800, Yinbo Zhu wrote: > 在 2023/8/8 下午8:05, Conor Dooley 写道: > > On Mon, Aug 07, 2023 at 03:40:42PM +0800, Yinbo Zhu wrote: > > > + loongson,gpio-ctrl-mode: > > > + $ref: /schemas/types.yaml#/definitions/uint32 > > > + description: > > > + This option indicate this GPIO control mode, where '0' represents > > > + bit control mode and '1' represents byte control mode. > > > > How is one supposed to know which of these modes to use? > > > Byte mode is to access by byte, such as gpio3, the base address of the > gpio controller is offset by 3 bytes as the access address of gpio3. > > The bit mode is the normal mode that like other platform gpio and it is > to access by bit. > > If both modes are supported, it is recommended to prioritize using byte > mode that according to spec. So, sounds like this property should instead be a boolean that notes whether the hardware supports the mode or not, rather than the current enum used to determine software policy. However, from Krzysztof's comments & my own feeling, it really does seem like you should drop the do-everything compatible and introduce things that are soc-specific.
在 2023/8/9 下午9:00, Krzysztof Kozlowski 写道: > On 09/08/2023 09:28, Yinbo Zhu wrote: >>> >>>> - gpio-ranges >>>> - interrupts >>>> >>>> @@ -49,11 +82,16 @@ examples: >>>> #include <dt-bindings/interrupt-controller/irq.h> >>>> >>>> gpio0: gpio@1fe00500 { >>>> - compatible = "loongson,ls2k-gpio"; >>>> + compatible = "loongson,ls2k1000-gpio"; >>>> reg = <0x1fe00500 0x38>; >>>> ngpios = <64>; >>>> #gpio-cells = <2>; >>>> gpio-controller; >>>> + loongson,gpio-conf-offset = <0>; >>>> + loongson,gpio-in-offset = <0x20>; >>>> + loongson,gpio-out-offset = <0x10>; >>>> + loongson,gpio-ctrl-mode = <0>; >>>> + loongson,gpio-inten-offset = <0x30>; >>> >>> I still think that you just embed the programming model into properties, >>> instead of using dedicated compatible for different blocks. It could be >>> fine, although I would prefer to check it with your DTS >> >> Okay, I got it, and if I understand correctly, you seem to agree with >> me adding attributes like this. >> >> And, if using this method that programming model into dts properites, >> then when adding a new platform's GPIO, there is no longer a need to >> modify the driver because gpio controller is compatible and different >> platform can use a same compatible. > > Uhu, so there we are. You use this method now to avoid new compatibles. > No, therefore I do not agree. I don't seem to got it, if the GPIO controllers of two platforms are compatible, shouldn't they use the same compatible? > >> >>> >>> Where is your DTS? >> >> >> Sorry, the dts containing gpio nodes are only available in the product >> code and have not been sent to the community yet. > > Does not help to convince us, but it is your right. With this and above > explanation, my answer is no - NAK. The community work for DTS on the 2K platform is still ongoing. Do I need to add a GPIO DTS node based on the following DTS to request your review? so that you can more conveniently review whether my patch is suitable. 2k1000 https://lore.kernel.org/all/99bdbfc66604b4700e3e22e28c3d27ef7c9c9af7.1686882123.git.zhoubinbin@loongson.cn/ 2k500 https://lore.kernel.org/all/c7087046a725e7a2cfde788185112c150e216f1b.1686882123.git.zhoubinbin@loongson.cn/ 2k2000 https://lore.kernel.org/all/977009099c38177c384fca5a0ee77ebbe50e3ea2.1686882123.git.zhoubinbin@loongson.cn/ Thanks, Yinbo
On 10/08/2023 05:35, Yinbo Zhu wrote: > > > 在 2023/8/9 下午9:00, Krzysztof Kozlowski 写道: >> On 09/08/2023 09:28, Yinbo Zhu wrote: >>>> >>>>> - gpio-ranges >>>>> - interrupts >>>>> >>>>> @@ -49,11 +82,16 @@ examples: >>>>> #include <dt-bindings/interrupt-controller/irq.h> >>>>> >>>>> gpio0: gpio@1fe00500 { >>>>> - compatible = "loongson,ls2k-gpio"; >>>>> + compatible = "loongson,ls2k1000-gpio"; >>>>> reg = <0x1fe00500 0x38>; >>>>> ngpios = <64>; >>>>> #gpio-cells = <2>; >>>>> gpio-controller; >>>>> + loongson,gpio-conf-offset = <0>; >>>>> + loongson,gpio-in-offset = <0x20>; >>>>> + loongson,gpio-out-offset = <0x10>; >>>>> + loongson,gpio-ctrl-mode = <0>; >>>>> + loongson,gpio-inten-offset = <0x30>; >>>> >>>> I still think that you just embed the programming model into properties, >>>> instead of using dedicated compatible for different blocks. It could be >>>> fine, although I would prefer to check it with your DTS >>> >>> Okay, I got it, and if I understand correctly, you seem to agree with >>> me adding attributes like this. >>> >>> And, if using this method that programming model into dts properites, >>> then when adding a new platform's GPIO, there is no longer a need to >>> modify the driver because gpio controller is compatible and different >>> platform can use a same compatible. >> >> Uhu, so there we are. You use this method now to avoid new compatibles. >> No, therefore I do not agree. > > > I don't seem to got it, if the GPIO controllers of two platforms are > compatible, shouldn't they use the same compatible? They can use the same fallback compatible, but you should have specific compatible anyway. However they are not compatible, because programming model is different.- > >> >>> >>>> >>>> Where is your DTS? >>> >>> >>> Sorry, the dts containing gpio nodes are only available in the product >>> code and have not been sent to the community yet. >> >> Does not help to convince us, but it is your right. With this and above >> explanation, my answer is no - NAK. > > > The community work for DTS on the 2K platform is still ongoing. Do I > need to add a GPIO DTS node based on the following DTS to request your > review? so that you can more conveniently review whether my patch is > suitable. > > 2k1000 > https://lore.kernel.org/all/99bdbfc66604b4700e3e22e28c3d27ef7c9c9af7.1686882123.git.zhoubinbin@loongson.cn/ > > 2k500 > https://lore.kernel.org/all/c7087046a725e7a2cfde788185112c150e216f1b.1686882123.git.zhoubinbin@loongson.cn/ > > 2k2000 > https://lore.kernel.org/all/977009099c38177c384fca5a0ee77ebbe50e3ea2.1686882123.git.zhoubinbin@loongson.cn/ If you want to convince us that your properties makes sense, adding GPIO nodes there would be helpful. Best regards, Krzysztof
在 2023/8/9 下午11:39, Conor Dooley 写道: > On Wed, Aug 09, 2023 at 03:47:55PM +0800, Yinbo Zhu wrote: >> 在 2023/8/8 下午8:05, Conor Dooley 写道: >>> On Mon, Aug 07, 2023 at 03:40:42PM +0800, Yinbo Zhu wrote: > >>>> + loongson,gpio-ctrl-mode: >>>> + $ref: /schemas/types.yaml#/definitions/uint32 >>>> + description: >>>> + This option indicate this GPIO control mode, where '0' represents >>>> + bit control mode and '1' represents byte control mode. >>> >>> How is one supposed to know which of these modes to use? >> >> >> Byte mode is to access by byte, such as gpio3, the base address of the >> gpio controller is offset by 3 bytes as the access address of gpio3. >> >> The bit mode is the normal mode that like other platform gpio and it is >> to access by bit. >> >> If both modes are supported, it is recommended to prioritize using byte >> mode that according to spec. > > So, sounds like this property should instead be a boolean that notes > whether the hardware supports the mode or not, rather than the current > enum used to determine software policy. okay, I got it, I will use boolean, Thanks, Yinbo.
On Thu, Aug 10, 2023 at 8:19 AM Yinbo Zhu <zhuyinbo@loongson.cn> wrote: > > > > 在 2023/8/9 下午11:39, Conor Dooley 写道: > > On Wed, Aug 09, 2023 at 03:47:55PM +0800, Yinbo Zhu wrote: > >> 在 2023/8/8 下午8:05, Conor Dooley 写道: > >>> On Mon, Aug 07, 2023 at 03:40:42PM +0800, Yinbo Zhu wrote: > > > >>>> + loongson,gpio-ctrl-mode: > >>>> + $ref: /schemas/types.yaml#/definitions/uint32 > >>>> + description: > >>>> + This option indicate this GPIO control mode, where '0' represents > >>>> + bit control mode and '1' represents byte control mode. > >>> > >>> How is one supposed to know which of these modes to use? > >> > >> > >> Byte mode is to access by byte, such as gpio3, the base address of the > >> gpio controller is offset by 3 bytes as the access address of gpio3. > >> > >> The bit mode is the normal mode that like other platform gpio and it is > >> to access by bit. > >> > >> If both modes are supported, it is recommended to prioritize using byte > >> mode that according to spec. > > > > So, sounds like this property should instead be a boolean that notes > > whether the hardware supports the mode or not, rather than the current > > enum used to determine software policy. > > > okay, I got it, I will use boolean, > Why do you want to put it into device-tree so badly? This is not the first driver that would have of_match_data for different variants where you can have a structure that would keep offsets for different models. It's not like you will have hundreds of "compatible" chips anyway, most likely just a few? Bart
在 2023/8/11 下午10:25, Bartosz Golaszewski 写道: > On Thu, Aug 10, 2023 at 8:19 AM Yinbo Zhu <zhuyinbo@loongson.cn> wrote: >> >> >> >> 在 2023/8/9 下午11:39, Conor Dooley 写道: >>> On Wed, Aug 09, 2023 at 03:47:55PM +0800, Yinbo Zhu wrote: >>>> 在 2023/8/8 下午8:05, Conor Dooley 写道: >>>>> On Mon, Aug 07, 2023 at 03:40:42PM +0800, Yinbo Zhu wrote: >>> >>>>>> + loongson,gpio-ctrl-mode: >>>>>> + $ref: /schemas/types.yaml#/definitions/uint32 >>>>>> + description: >>>>>> + This option indicate this GPIO control mode, where '0' represents >>>>>> + bit control mode and '1' represents byte control mode. >>>>> >>>>> How is one supposed to know which of these modes to use? >>>> >>>> >>>> Byte mode is to access by byte, such as gpio3, the base address of the >>>> gpio controller is offset by 3 bytes as the access address of gpio3. >>>> >>>> The bit mode is the normal mode that like other platform gpio and it is >>>> to access by bit. >>>> >>>> If both modes are supported, it is recommended to prioritize using byte >>>> mode that according to spec. >>> >>> So, sounds like this property should instead be a boolean that notes >>> whether the hardware supports the mode or not, rather than the current >>> enum used to determine software policy. >> >> >> okay, I got it, I will use boolean, >> > > Why do you want to put it into device-tree so badly? This is not the > first driver that would have of_match_data for different variants > where you can have a structure that would keep offsets for different > models. It's not like you will have hundreds of "compatible" chips > anyway, most likely just a few? Using this ways that put offset property into device-tree that can be compatible with future GPIO chips without the need to modify drivers, such as more 2K chips in the future, but use of_match_data and data field of_device_id, which every time a new SoC is released, the GPIO driver needs to be modified once, which is not friendly to us. Thanks, Yinbo
在 2023/8/15 下午4:59, Linus Walleij 写道: > On Mon, Aug 14, 2023 at 5:39 AM Yinbo Zhu <zhuyinbo@loongson.cn> wrote: > >>> Why do you want to put it into device-tree so badly? This is not the >>> first driver that would have of_match_data for different variants >>> where you can have a structure that would keep offsets for different >>> models. It's not like you will have hundreds of "compatible" chips >>> anyway, most likely just a few? >> >> Using this ways that put offset property into device-tree that can be >> compatible with future GPIO chips without the need to modify drivers, >> such as more 2K chips in the future, but use of_match_data and data >> field of_device_id, which every time a new SoC is released, the GPIO >> driver needs to be modified once, which is not friendly to us. > > The purpose of device tree is to describe the hardware and > to configure it for a target system. > > The purpose of device tree is not to make driver writing easy > or convenient. It often does, but that is not the purpose. > > These offsets are not relevant to the people that need to > author and maintain device trees to support and tailor their > system. They are only relevant to driver authors and SoC > manufacturers. > > What about just writing these offsets into the driver and use > the compatible match to look them up. > okay, I got it, I had following your advice and send v4 to upstream, please you help review it. Thanks, Yinbo
diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml index fb86e8ce6349..fc51cf40fccd 100644 --- a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml @@ -14,6 +14,7 @@ properties: enum: - loongson,ls2k-gpio - loongson,ls7a-gpio + - loongson,ls2k1000-gpio reg: maxItems: 1 @@ -29,6 +30,33 @@ properties: gpio-ranges: true + loongson,gpio-conf-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This option indicate this GPIO configuration register offset address. + + loongson,gpio-out-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This option indicate this GPIO output register offset address. + + loongson,gpio-in-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This option indicate this GPIO input register offset address. + + loongson,gpio-ctrl-mode: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This option indicate this GPIO control mode, where '0' represents + bit control mode and '1' represents byte control mode. + + loongson,gpio-inten-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This option indicate this GPIO interrupt enable register offset + address. + interrupts: minItems: 1 maxItems: 64 @@ -39,6 +67,11 @@ required: - ngpios - "#gpio-cells" - gpio-controller + - loongson,gpio-conf-offset + - loongson,gpio-in-offset + - loongson,gpio-out-offset + - loongson,gpio-ctrl-mode + - loongson,gpio-inten-offset - gpio-ranges - interrupts @@ -49,11 +82,16 @@ examples: #include <dt-bindings/interrupt-controller/irq.h> gpio0: gpio@1fe00500 { - compatible = "loongson,ls2k-gpio"; + compatible = "loongson,ls2k1000-gpio"; reg = <0x1fe00500 0x38>; ngpios = <64>; #gpio-cells = <2>; gpio-controller; + loongson,gpio-conf-offset = <0>; + loongson,gpio-in-offset = <0x20>; + loongson,gpio-out-offset = <0x10>; + loongson,gpio-ctrl-mode = <0>; + loongson,gpio-inten-offset = <0x30>; gpio-ranges = <&pctrl 0 0 15>, <&pctrl 16 16 15>, <&pctrl 32 32 10>,