From: Linus Walleij <linus.walleij@linaro.org>
To: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
Marc Zyngier <maz@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>,
Punit Agrawal <punit1.agrawal@toshiba.co.jp>,
yuji2.ishikawa@toshiba.co.jp,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/4] gpio: visconti: Add Toshiba Visconti GPIO support
Date: Sat, 12 Dec 2020 00:20:47 +0100 [thread overview]
Message-ID: <CACRpkdZ-umK4troerSA6S2rvyU5XV+KsFdxuWE5Sy0PCgdfT6A@mail.gmail.com> (raw)
In-Reply-To: <20201211094138.2863677-3-nobuhiro1.iwamatsu@toshiba.co.jp>
On Fri, Dec 11, 2020 at 1:43 AM Nobuhiro Iwamatsu
<nobuhiro1.iwamatsu@toshiba.co.jp> wrote:
This iteration is looking really good, but we are not quite there yet,
because now that the driver looks so much better I can see that it
is a hierarchical interrupt controller.
> Add the GPIO driver for Toshiba Visconti ARM SoCs.
>
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
> Reviewed-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
(...)
> +config GPIO_VISCONTI
> + tristate "Toshiba Visconti GPIO support"
> + depends on ARCH_VISCONTI || COMPILE_TEST
> + depends on OF_GPIO
> + select GPIOLIB_IRQCHIP
> + select GPIO_GENERIC
> + help
> + Say yes here to support GPIO on Tohisba Visconti.
Add
select IRQ_DOMAIN_HIERARCHY
> +struct visconti_gpio {
> + void __iomem *base;
> + int *irq;
Don't keep these irqs around.
> + ret = platform_irq_count(pdev);
> + if (ret < 0)
> + return ret;
> +
> + num_irq = ret;
> +
> + priv->irq = devm_kcalloc(dev, num_irq, sizeof(priv->irq), GFP_KERNEL);
> + if (!priv->irq)
> + return -ENOMEM;
> +
> + for (i = 0; i < num_irq; i++) {
> + priv->irq[i] = platform_get_irq(pdev, i);
> + if (priv->irq[i] < 0) {
> + dev_err(dev, "invalid IRQ[%d]\n", i);
> + return priv->irq[i];
> + }
> + }
Instead of doing this, look in for example
drivers/gpio/gpio-ixp4xx.c
You need:
> + girq = &priv->gpio_chip.irq;
> + girq->chip = irq_chip;
girq->fwnode = fwnode;
girq->parent_domain = parent;
girq->child_to_parent_hwirq = visconti_gpio_child_to_parent_hwirq;
The mapping function will be something like this:
static int visconti_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
unsigned int child,
unsigned int child_type,
unsigned int *parent,
unsigned int *parent_type)
{
/* Interrupts 0..15 mapped to interrupts 24..39 on the GIC */
if (child < 16) {
/* All these interrupts are level high in the CPU */
*parent_type = IRQ_TYPE_LEVEL_HIGH;
*parent = child + 24;
return 0;
}
return -EINVAL;
}
> + priv->gpio_chip.irq.init_valid_mask = visconti_init_irq_valid_mask;
This will be set up by gpiolib when using hierarchical irqs.
> + /* This will let us handle the parent IRQ in the driver */
> + girq->parent_handler = NULL;
> + girq->num_parents = 0;
> + girq->parents = NULL;
You don't need this.
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_level_irq;
But this stays.
> + for (i = 0; i < num_irq; i++) {
> + desc = irq_to_desc(priv->irq[i]);
> + desc->status_use_accessors |= IRQ_NOAUTOEN;
> + if (devm_request_irq(dev, priv->irq[i],
> + visconti_gpio_irq_handler, 0, name, priv)) {
> + dev_err(dev, "failed to request IRQ[%d]\n", i);
> + return -ENOENT;
> + }
> + }
This should not be needed either when using hiearchical IRQs,
also the irqchip maintainers will beat us up for poking around in the
descs like this.
The rest looks solid!
Yours,
Linus Walleij
next prev parent reply other threads:[~2020-12-11 23:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 9:41 [PATCH v4 0/4] gpio: visconti: Add Toshiba Visconti GPIO support Nobuhiro Iwamatsu
2020-12-11 9:41 ` [PATCH v4 1/4] dt-bindings: gpio: Add bindings for Toshiba Visconti GPIO Controller Nobuhiro Iwamatsu
2020-12-11 23:05 ` Linus Walleij
2020-12-11 9:41 ` [PATCH v4 2/4] gpio: visconti: Add Toshiba Visconti GPIO support Nobuhiro Iwamatsu
2020-12-11 23:20 ` Linus Walleij [this message]
2020-12-16 9:11 ` Nobuhiro Iwamatsu
2020-12-16 9:36 ` Marc Zyngier
2020-12-17 5:10 ` Nobuhiro Iwamatsu
2020-12-11 9:41 ` [PATCH v4 3/4] MAINTAINERS: Add entries for Toshiba Visconti GPIO controller Nobuhiro Iwamatsu
2020-12-11 9:41 ` [PATCH v4 4/4] arm: dts: visconti: Add DT support for Toshiba Visconti5 GPIO driver Nobuhiro Iwamatsu
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=CACRpkdZ-umK4troerSA6S2rvyU5XV+KsFdxuWE5Sy0PCgdfT6A@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=nobuhiro1.iwamatsu@toshiba.co.jp \
--cc=punit1.agrawal@toshiba.co.jp \
--cc=robh+dt@kernel.org \
--cc=yuji2.ishikawa@toshiba.co.jp \
/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).