linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yao Zi <ziyao@disroot.org>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Yinbo Zhu <zhuyinbo@loongson.cn>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
	Mingcong Bai <jeffbai@aosc.io>,
	Kexy Biscuit <kexybiscuit@aosc.io>
Subject: Re: [PATCH 1/3] dt-bindings: gpio: loongson: Document GPIO controller of 2K0300 SoC
Date: Sat, 16 Aug 2025 16:07:54 +0000	[thread overview]
Message-ID: <aKCs2jUcYxYHWIB2@pie> (raw)
In-Reply-To: <CAAhV-H5ZQQpHS_b9UL8UNgX9MH8-i4DV8bid00vEDzg76rgebw@mail.gmail.com>

On Sat, Aug 16, 2025 at 10:18:57PM +0800, Huacai Chen wrote:
> On Sat, Aug 16, 2025 at 11:51 AM Yao Zi <ziyao@disroot.org> wrote:
> >
> > Loongson 2K0300 ships a GPIO controller whose input/output control logic
> > is similar to previous generation of SoCs. Additionally, it acts as an
> > interrupt-controller supporting both level and edge interrupts and has a
> > distinct reset signal.
> >
> > Describe its compatible in devicetree. We enlarge the maximum value of
> > ngpios to 128, since the controller technically supports at most 128
> > pins, although only 106 are routed out of the package. Properties for
> > interrupt-controllers and resets are introduced and limited as 2K0300
> > only.
> >
> > Signed-off-by: Yao Zi <ziyao@disroot.org>
> > ---
> >  .../bindings/gpio/loongson,ls-gpio.yaml       | 28 ++++++++++++++++++-
> >  1 file changed, 27 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
> > index b68159600e2b..69852444df23 100644
> > --- a/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
> > +++ b/Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
> > @@ -14,6 +14,7 @@ properties:
> >      oneOf:
> >        - enum:
> >            - loongson,ls2k-gpio
> > +          - loongson,ls2k0300-gpio
> >            - loongson,ls2k0500-gpio0
> >            - loongson,ls2k0500-gpio1
> >            - loongson,ls2k2000-gpio0
> > @@ -36,7 +37,7 @@ properties:
> >
> >    ngpios:
> >      minimum: 1
> > -    maximum: 64
> > +    maximum: 128
> >
> >    "#gpio-cells":
> >      const: 2
> > @@ -49,6 +50,14 @@ properties:
> >      minItems: 1
> >      maxItems: 64
> >
> > +  "#interrupt-cells":
> > +    const: 2
> > +
> > +  interrupt-controller: true
> ls2k300 supports interrupt-controller while others don't?

For these SoCs' GPIO controllers (I didn't carefully check 3A{5,6}00 and
7A{1,2}00), there're three different cases,

1. Controller of 2K0500, 2K1000:

   These controllers have only interrupt enable bits for each GPIO.
   Interrupts are routed directly to the parent interrupt controller and
   there're multiple pins share the same interrupt in the parent, e.g.,
   GPIO 0-31 share interrupt 26 of the second liointc on 2K0500.

   Since we have neither an interrupt status register nor interrupt ack
   bits, it's hard to tell which GPIO line is triggering the interrupt.
   And we even cannot configure the polarity/edge for triggering
   interrupts, thus I don't think these GPIO controller should be
   described as interrupt controllers.

   For these controllers, gpio-loongson-64bit.c implements GPIO
   controller's .to_irq() method which translates GPIO descriptor to
   corresponding IRQ number. This should work as long as there's at most
   one interrupt consumer for each group of GPIOs that share the same
   parent interrupt line.

2. Node controller of 2K1500 and 2K2000:

   These SoCs have GPIO controllers directly attached to the "node" (I
   think it means the CPU core, but am not sure). These controllers are
   similar to the first class, but they have an additional feature that
   the polarity for triggering interrupts could be configured.

   Still we couldn't precisely tell which GPIO line is triggering the
   interrupt, thus it's hard to implement it as a fully-functional
   irqchip, either. But if we don't do so, I cannot come up with a way
   to describe the polarity settings. I'm unsure whether these
   controllers should be implemented as interrupt controllers.

3. South-bridge controller of 2K1500 and 2K2000, and 2K0300's
   controller:

   Reading through the public TRM, I'm sure these're all fully
   functional interrupt controllers, and should be implemented as
   interrupt controllers.

   However, this also means the current binding for 2K1500/2K2000's
   south-bridge controller is WRONG, and a fix it seems to bring in ABI
   breakages (interrupt-controller/interrupt-cells are a must). But
   since I don't have these devices on hand, and they are at least not
   related to the situation of 2K0300, I decided to keep them as-is.

So the answer to the original question is, no, at least 2K1500/2K2000's
south-bridge GPIO controllers are also interrupt controllers according
to their public documentation. But I cannot test my GPIO changes against
them since I don't have such boards, and fixing the binding up may break
the ABI, thus I leave them as-is in this "support for 2K0300" series.

> Huacai

Best regards,
Yao Zi

> > +
> > +  resets:
> > +    maxItems: 1
> > +
> >  required:
> >    - compatible
> >    - reg
> > @@ -58,6 +67,23 @@ required:
> >    - gpio-ranges
> >    - interrupts
> >
> > +allOf:
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: loongson,ls2k0300-gpio
> > +    then:
> > +      required:
> > +        - "#interrupt-cells"
> > +        - interrupt-controller
> > +        - resets
> > +    else:
> > +      properties:
> > +        "#interrupts-cells": false
> > +        interrupt-controller: false
> > +        resets: false
> > +
> >  additionalProperties: false
> >
> >  examples:
> > --
> > 2.50.1
> >

  reply	other threads:[~2025-08-16 16:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-16  3:50 [PATCH 0/3] Support GPIO controller of Loongson 2K0300 SoC Yao Zi
2025-08-16  3:50 ` [PATCH 1/3] dt-bindings: gpio: loongson: Document GPIO controller of " Yao Zi
2025-08-16  9:49   ` Krzysztof Kozlowski
2025-08-16 14:18   ` Huacai Chen
2025-08-16 16:07     ` Yao Zi [this message]
2025-08-24 14:41       ` Huacai Chen
2025-08-16  3:50 ` [PATCH 2/3] gpio: loongson-64bit: Add support for Loongson " Yao Zi
2025-08-16  3:50 ` [PATCH 3/3] LoongArch: dts: Add GPIO controller for Loongson 2K0300 Yao Zi
2025-08-30 19:49 ` [PATCH 0/3] Support GPIO controller of Loongson 2K0300 SoC Bartosz Golaszewski
2025-08-31 11:25   ` Yao Zi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aKCs2jUcYxYHWIB2@pie \
    --to=ziyao@disroot.org \
    --cc=brgl@bgdev.pl \
    --cc=chenhuacai@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jeffbai@aosc.io \
    --cc=kernel@xen0n.name \
    --cc=kexybiscuit@aosc.io \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=zhuyinbo@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).