Skip to contentSkip to conversation

at91: gpio: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

PATCH New Jean-Jacques Hiblot 4 participants 10 messages Jan 23, 2014 – Mar 14, 2014

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover at91: gpio: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

change since V1:
* fixed unmasking/masking issue (unmask the irq in startup, mask it in shutdown)

Jean-Jacques Hiblot (2):
at91: gpio: use gpiolib API to mark a GPIO used as an IRQ
at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

 arch/arm/mach-at91/gpio.c      | 27 +++++++++++++++++++++++++++
 drivers/pinctrl/pinctrl-at91.c | 27 +++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
Signature · 1 line
1.8.5.2
#1 lore raw

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

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.

---
 arch/arm/mach-at91/gpio.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
arch/arm/mach-at91/gpio.c +27 -0
index a5afcf7..a88ed12 100644
@@ -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,
Signature · 1 line
1.8.5.2
#2 lore raw

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

Quoted 4 lines · Jean-Jacques Hiblot

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.

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

#3 lore raw

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

On 31/01/2014 08:55, Linus Walleij :

Quoted 11 lines
Quoted 4 lines · Jean-Jacques Hiblot

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.

Nicolas, are you queueing this patch?

Yes, I will.

Quoted 3 lines

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,

Signature · 1 line
Nicolas Ferre
#4 lore raw

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

Quoted 13 lines · Nicolas Ferre

On 31/01/2014 08:55, Linus Walleij :

Quoted 11 lines
Quoted 4 lines · Jean-Jacques Hiblot

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.

Nicolas, are you queueing this patch?

Quoted 7 lines

Yes, I will.

Quoted 3 lines

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.

Quoted 4 lines

Thanks for your review. Bye,

Signature · 1 line
Nicolas Ferre
#5 lore raw

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

In reply to Nicolas Ferre

On 31/01/2014 09:57, Nicolas Ferre :

Quoted 7 lines

On 31/01/2014 08:55, Linus Walleij :

Quoted 6 lines
Quoted 3 lines · Jean-Jacques Hiblot

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.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Nicolas, are you queueing this patch?

Yes, I will.

stacked on at91-3.15-cleanup branch.

Best regards,

Quoted 8 lines
Quoted 3 lines

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,

Signature · 1 line
Nicolas Ferre
#6 lore raw

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

On 12/03/2014 15:38, Nicolas Ferre :

Quoted 10 lines

On 31/01/2014 09:57, Nicolas Ferre :

Quoted 9 lines

On 31/01/2014 08:55, Linus Walleij :

Quoted 8 lines
Quoted 4 lines · Jean-Jacques Hiblot

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.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

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,

Quoted 10 lines
Quoted 8 lines
Quoted 3 lines

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,

Signature · 1 line
Nicolas Ferre
#7 lore raw

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

Quoted 17 lines · Nicolas Ferre

On 12/03/2014 15:38, Nicolas Ferre :

Quoted 16 lines

On 31/01/2014 09:57, Nicolas Ferre :

Quoted 14 lines

On 31/01/2014 08:55, Linus Walleij :

Quoted 11 lines
Quoted 4 lines · Jean-Jacques Hiblot

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.

Nicolas, are you queueing this patch?

Yes, I will.

Quoted 7 lines
Quoted 1 line

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

#8 lore raw

PATCH v2 2/2 at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

In reply to Jean-Jacques Hiblot

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.

---
 drivers/pinctrl/pinctrl-at91.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/pinctrl/pinctrl-at91.c +27 -0
index e8c8301..e00a4bb 100644
@@ -1299,6 +1299,31 @@ 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);
+}
+
 #ifdef CONFIG_PM
 
 static u32 wakeups[MAX_GPIO_BANKS];
@@ -1377,6 +1402,8 @@ void at91_pinctrl_gpio_resume(void)
 
 static struct irq_chip gpio_irqchip = {
 	.name		= "GPIO",
+	.irq_startup	= gpio_irq_startup,
+	.irq_shutdown	= gpio_irq_shutdown,
 	.irq_disable	= gpio_irq_mask,
 	.irq_mask	= gpio_irq_mask,
 	.irq_unmask	= gpio_irq_unmask,
Signature · 1 line
1.8.5.2
#9 lore raw

PATCH v2 2/2 at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

Quoted 4 lines · Jean-Jacques Hiblot

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.

Thanks!

Patch applied.

Yours,
Linus Walleij