Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1390888

Re: [PATCH v2 6/9] pinctrl: Add IRQ support to STM32 gpios

From Linus Walleij <linus.walleij@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 6/9] pinctrl: Add IRQ support to STM32 gpios
Date 2016-04-29 11:00 +0200
Message-ID <rtcrg-2XJ-15@gated-at.bofh.it> (permalink)
References <riMoq-6WJ-11@gated-at.bofh.it> <riMy7-71p-31@gated-at.bofh.it> <rlBd8-1LF-9@gated-at.bofh.it> <rpzPs-4lP-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Apr 19, 2016 at 11:04 AM, Maxime Coquelin
<mcoquelin.stm32@gmail.com> wrote:
> 2016-04-08 11:43 GMT+02:00 Linus Walleij <linus.walleij@linaro.org>:
>> On Thu, Mar 31, 2016 at 5:09 PM, Maxime Coquelin
>> <mcoquelin.stm32@gmail.com> wrote:
>>
>>> +static int stm32_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
>>> +{
>>> +       struct stm32_pinctrl *pctl = dev_get_drvdata(chip->parent);
>>> +       struct stm32_gpio_bank *bank = gpiochip_get_data(chip);
>>> +       unsigned int irq;
>>> +
>>> +       regmap_field_write(pctl->irqmux[offset], bank->range.id);
>>
>> No. You must implement the irqchip and GPIO controllers to
>> be orthogonal, doing things like this creates a semantic that
>> assumes .to_irq() is always called before using the IRQ and
>> that is not guaranteed at all. A consumer may very well
>> use an interrupt right off the irqchip without this being called
>> first. All this function should do is translate a number. No
>> other semantics.
>>
>> This needs to be done from the irqchip (sorry).
>
> Actually, the register written here is not part of the irqchip.
> It is a system config register that is only used when using a GPIO as
> external interrupt.
> Its aim is to mux the GPIO bank on a line.

Then it should be done in .request() for the GPIO, not in
.to_irq().

It should *also* be done in the set-up path for the irqchip
side, if that line is used without any interaction with the
gpio side of things.

> For example on line 1, it can be muxed to select either gpioa1,
> gpiob1, gpioc1, ...
> How could I do it in the irqchip that has no gpio knowledge?

I don't understand this.

We are discussing an irqchip that is tightly coupled with
a gpiochip. Usually d->hwirq is the same as the GPIO offset
but that varies.

The point is that each IRQ that ever get used
has a 1-to-1 relationship to a certain GPIO line, and if that
relationship cannot be resolved from the irqchip side,
something is wrong. The irqchip needs to enable the
GPIO line it is backing to recieve interrupts without any
requirements that .to_irq() have been called first.

If to_irq() does something else than translate to an IRQ
something is wrong.

Yours,
Linus Walleij

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2 6/9] pinctrl: Add IRQ support to STM32 gpios Linus Walleij <linus.walleij@linaro.org> - 2016-04-29 11:00 +0200
  Re: [PATCH v2 6/9] pinctrl: Add IRQ support to STM32 gpios Maxime Coquelin <mcoquelin.stm32@gmail.com> - 2016-04-29 13:20 +0200
    Re: [PATCH v2 6/9] pinctrl: Add IRQ support to STM32 gpios Linus Walleij <linus.walleij@linaro.org> - 2016-04-30 13:40 +0200
      Re: [PATCH v2 6/9] pinctrl: Add IRQ support to STM32 gpios Maxime Coquelin <mcoquelin.stm32@gmail.com> - 2016-05-02 10:40 +0200

csiph-web