diff mbox

[v2,1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ

Message ID 1390473478-5591-2-git-send-email-jjhiblot@traphandler.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Jacques Hiblot Jan. 23, 2014, 10:37 a.m. UTC
When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
the gpiolib so we can keep track of the usage centrally.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
---
 arch/arm/mach-at91/gpio.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Linus Walleij Jan. 31, 2014, 7:55 a.m. UTC | #1
On Thu, Jan 23, 2014 at 11:37 AM, Jean-Jacques Hiblot
<jjhiblot@traphandler.com> wrote:

> When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
> the gpiolib so we can keep track of the usage centrally.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Nicolas, are you queueing this patch?

I guess this custom GPIO implementation is going away with
the transition to pinctrl else I'd requested that it be moved to
drivers/gpio...

Yours,
Linus Walleij
Nicolas Ferre Jan. 31, 2014, 8:57 a.m. UTC | #2
On 31/01/2014 08:55, Linus Walleij :
> On Thu, Jan 23, 2014 at 11:37 AM, Jean-Jacques Hiblot
> <jjhiblot@traphandler.com> wrote:
> 
>> When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
>> the gpiolib so we can keep track of the usage centrally.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> 
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> 
> Nicolas, are you queueing this patch?

Yes, I will.

> I guess this custom GPIO implementation is going away with
> the transition to pinctrl else I'd requested that it be moved to
> drivers/gpio...

Absolutely. But I suspect it will still be around for some time...

Thanks for your review. Bye,
Jean-Christophe PLAGNIOL-VILLARD Feb. 7, 2014, 8:07 a.m. UTC | #3
On 09:57 Fri 31 Jan     , Nicolas Ferre wrote:
> On 31/01/2014 08:55, Linus Walleij :
> > On Thu, Jan 23, 2014 at 11:37 AM, Jean-Jacques Hiblot
> > <jjhiblot@traphandler.com> wrote:
> > 
> >> When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
> >> the gpiolib so we can keep track of the usage centrally.
> >>
> >> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> > 
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > 
> > Nicolas, are you queueing this patch?
> 
> Yes, I will.
> 
> > I guess this custom GPIO implementation is going away with
> > the transition to pinctrl else I'd requested that it be moved to
> > drivers/gpio...
> 
> Absolutely. But I suspect it will still be around for some time...
moved no

I'm not even sure we need to update it at all to simply for the switch to DT

nearly all the support for old SoC is here so I see no reason to do not switch
I even a big patch serie to switch old board to DT

So for me no do not touch the old stuff

Best Regards,
J.
> 
> Thanks for your review. Bye,
> -- 
> Nicolas Ferre
Nicolas Ferre March 12, 2014, 2:38 p.m. UTC | #4
On 31/01/2014 09:57, Nicolas Ferre :
> On 31/01/2014 08:55, Linus Walleij :
>> On Thu, Jan 23, 2014 at 11:37 AM, Jean-Jacques Hiblot
>> <jjhiblot@traphandler.com> wrote:
>>
>>> When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
>>> the gpiolib so we can keep track of the usage centrally.
>>>
>>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
>>
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>>
>> Nicolas, are you queueing this patch?
> 
> Yes, I will.

stacked on at91-3.15-cleanup branch.

Best regards,

>> I guess this custom GPIO implementation is going away with
>> the transition to pinctrl else I'd requested that it be moved to
>> drivers/gpio...
> 
> Absolutely. But I suspect it will still be around for some time...
> 
> Thanks for your review. Bye,
>
Nicolas Ferre March 12, 2014, 5:29 p.m. UTC | #5
On 12/03/2014 15:38, Nicolas Ferre :
> On 31/01/2014 09:57, Nicolas Ferre :
>> On 31/01/2014 08:55, Linus Walleij :
>>> On Thu, Jan 23, 2014 at 11:37 AM, Jean-Jacques Hiblot
>>> <jjhiblot@traphandler.com> wrote:
>>>
>>>> When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
>>>> the gpiolib so we can keep track of the usage centrally.
>>>>
>>>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
>>>
>>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>>>
>>> Nicolas, are you queueing this patch?
>>
>> Yes, I will.
> 
> stacked on at91-3.15-cleanup branch.

... And immediately removed thanks to Boris' advice: it seems that you
will move to a gpio_irq_request/release_resources() model.

So, we might wait for the solution to settle in 3.15-rc before building
on top of it.

Thanks, bye,

>>> I guess this custom GPIO implementation is going away with
>>> the transition to pinctrl else I'd requested that it be moved to
>>> drivers/gpio...
>>
>> Absolutely. But I suspect it will still be around for some time...
>>
>> Thanks for your review. Bye,
>>
> 
>
Linus Walleij March 14, 2014, 10:17 a.m. UTC | #6
On Wed, Mar 12, 2014 at 6:29 PM, Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> On 12/03/2014 15:38, Nicolas Ferre :
>> On 31/01/2014 09:57, Nicolas Ferre :
>>> On 31/01/2014 08:55, Linus Walleij :
>>>> On Thu, Jan 23, 2014 at 11:37 AM, Jean-Jacques Hiblot
>>>> <jjhiblot@traphandler.com> wrote:
>>>>
>>>>> When an IRQ is started on a GPIO line, mark this GPIO as IRQ in
>>>>> the gpiolib so we can keep track of the usage centrally.
>>>>>
>>>>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
>>>>
>>>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>>>>
>>>> Nicolas, are you queueing this patch?
>>>
>>> Yes, I will.
>>
>> stacked on at91-3.15-cleanup branch.
>
> ... And immediately removed thanks to Boris' advice: it seems that you
> will move to a gpio_irq_request/release_resources() model.
>
> So, we might wait for the solution to settle in 3.15-rc before building
> on top of it.

It's not such a big deal IMO, but sure I'm working to clean this up.

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index a5afcf7..a88ed12 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -577,8 +577,35 @@  static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
 	return 0;
 }
 
+static unsigned int gpio_irq_startup(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+	int ret;
+
+	ret = gpio_lock_as_irq(&at91_gpio->chip, pin);
+	if (ret) {
+		dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
+			d->hwirq);
+		return ret;
+	}
+	gpio_irq_unmask(d);
+	return 0;
+}
+
+static void gpio_irq_shutdown(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+
+	gpio_irq_mask(d);
+	gpio_unlock_as_irq(&at91_gpio->chip, pin);
+}
+
 static struct irq_chip gpio_irqchip = {
 	.name		= "GPIO",
+	.irq_shutdown	= gpio_irq_shutdown,
+	.irq_startup	= gpio_irq_startup,
 	.irq_disable	= gpio_irq_mask,
 	.irq_mask	= gpio_irq_mask,
 	.irq_unmask	= gpio_irq_unmask,