From: Chuanhong Guo <gch981213@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <brgl@bgdev.pl>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Qingfang Deng <qingfang.deng@siflower.com.cn>
Subject: Re: [PATCH 2/2] gpio: add support for GPIO controller on Siflower SoCs
Date: Sun, 29 Dec 2024 11:09:00 +0800 [thread overview]
Message-ID: <CAJsYDVKoLwnpfWWdwAph88XSk7VwOr=c_DPwhLw+yeJANK8TOw@mail.gmail.com> (raw)
In-Reply-To: <CACRpkdb4bMFqV+hfAHuUvLezyCA8PTE+SQOpYzh_y1JXzDHLvw@mail.gmail.com>
Hi Linus!
On Sat, Dec 28, 2024 at 12:52 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> Hi Chuanhong,
>
> thanks for your patch!
>
> I think it is better to split the driver instances into 4, one for each
> physical block, as explained in the binding patch.
>
> On Wed, Dec 25, 2024 at 4:59 AM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> > From: Qingfang Deng <qingfang.deng@siflower.com.cn>
> >
> > Add a driver for the GPIO controller on Siflower SoCs.
> > This controller is found on all current Siflower MIPS and RISC-V
> > chips including SF19A2890, SF21A6826 and SF21H8898.
> >
> > Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
> > Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
>
>
>
> > +config GPIO_SIFLOWER
> > + tristate "SiFlower GPIO support"
> > + depends on OF_GPIO
> > + depends on MIPS || RISCV || COMPILE_TEST
> > + select GPIOLIB_IRQCHIP
>
> select GPIO_GENERIC
>
> As you have only a set of 32-bit registers to handle for each
> instance, then some IRQs on top, you can untilize the MMIO
> library.
>
> > +#define GPIO_IR(n) (0x40 * (n) + 0x00)
> > +#define GPIO_OR(n) (0x40 * (n) + 0x04)
> > +#define GPIO_OEN(n) (0x40 * (n) + 0x08)
> > +#define GPIO_IMR(n) (0x40 * (n) + 0x0c)
> > +#define GPIO_GPIMR(n) (0x40 * (n) + 0x10)
> > +#define GPIO_PIR(n) (0x40 * (n) + 0x14)
> > +#define GPIO_ITR(n) (0x40 * (n) + 0x18)
> > +#define GPIO_IFR(n) (0x40 * (n) + 0x1c)
> > +#define GPIO_ICR(n) (0x40 * (n) + 0x20)
This set of registers is for a single pin, not a multiple-pin block.
> > +#define GPIO_GPxIR(n) (0x4 * (n) + 0x4000)
>
> Just define GPIO_IR 0, GPIO_OR 4, etc.
>
> Look up the GPIO_GPIR register separately from the
> device tree and use it without offset.
>
> Always register 16 GPIO lines unless ngpios is set.
>
> Look at example drivers such as
> drivers/gpio/gpio-pl061.c
> drivers/gpio/gpio-ftgpio010.c
> on how to use the MMIO helper library to implement
> a simple driver for one instance reusing the common code.
In my case the MMIO library doesn't seem really helpful since that's
for the more common case where multiple GPIO pins share one set of
registers.
--
Regards,
Chuanhong Guo
next prev parent reply other threads:[~2024-12-29 3:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-25 3:58 [PATCH 0/2] gpio: add support for GPIO controller on Siflower SoCs Chuanhong Guo
2024-12-25 3:58 ` [PATCH 1/2] dt-bindings: gpio: add binding doc for siflower,sf19a2890-gpio Chuanhong Guo
2024-12-27 16:45 ` Linus Walleij
2024-12-29 3:06 ` Chuanhong Guo
2025-01-13 14:38 ` Linus Walleij
2024-12-25 3:58 ` [PATCH 2/2] gpio: add support for GPIO controller on Siflower SoCs Chuanhong Guo
2024-12-27 16:51 ` Linus Walleij
2024-12-29 3:09 ` Chuanhong Guo [this message]
2024-12-31 8:38 ` Krzysztof Kozlowski
2025-01-01 9:11 ` Chuanhong Guo
2025-01-01 10:49 ` Krzysztof Kozlowski
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='CAJsYDVKoLwnpfWWdwAph88XSk7VwOr=c_DPwhLw+yeJANK8TOw@mail.gmail.com' \
--to=gch981213@gmail.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=qingfang.deng@siflower.com.cn \
--cc=robh@kernel.org \
/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).