All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ
@ 2014-01-22 12:39 Jean-Jacques Hiblot
  2014-01-22 12:39 ` [PATCH 2/2] at91: pinctrl: " Jean-Jacques Hiblot
  2014-01-22 12:47 ` [PATCH 1/2] at91: gpio: " Gregory CLEMENT
  0 siblings, 2 replies; 4+ messages in thread
From: Jean-Jacques Hiblot @ 2014-01-22 12:39 UTC (permalink / raw)
  To: linux-arm-kernel

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 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index a5afcf7..6176b4b 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -577,8 +577,32 @@ 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;
+	}
+	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_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,
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ
  2014-01-22 12:39 [PATCH 1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ Jean-Jacques Hiblot
@ 2014-01-22 12:39 ` Jean-Jacques Hiblot
  2014-01-22 12:49   ` Gregory CLEMENT
  2014-01-22 12:47 ` [PATCH 1/2] at91: gpio: " Gregory CLEMENT
  1 sibling, 1 reply; 4+ messages in thread
From: Jean-Jacques Hiblot @ 2014-01-22 12:39 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 drivers/pinctrl/pinctrl-at91.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index e8c8301..fbedde2 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1299,6 +1299,28 @@ 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;
+	}
+	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_unlock_as_irq(&at91_gpio->chip, pin);
+}
+
 #ifdef CONFIG_PM
 
 static u32 wakeups[MAX_GPIO_BANKS];
@@ -1377,6 +1399,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,
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ
  2014-01-22 12:39 [PATCH 1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ Jean-Jacques Hiblot
  2014-01-22 12:39 ` [PATCH 2/2] at91: pinctrl: " Jean-Jacques Hiblot
@ 2014-01-22 12:47 ` Gregory CLEMENT
  1 sibling, 0 replies; 4+ messages in thread
From: Gregory CLEMENT @ 2014-01-22 12:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jean-Jacques,

On 22/01/2014 13:39, Jean-Jacques Hiblot 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>
> ---
>  arch/arm/mach-at91/gpio.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
> index a5afcf7..6176b4b 100644
> --- a/arch/arm/mach-at91/gpio.c
> +++ b/arch/arm/mach-at91/gpio.c
> @@ -577,8 +577,32 @@ 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;
> +	}
> +	return 0;
> +}

Nitpick: a blank line should be nice here between the 2 functions

> +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_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,
> 

Thanks,

Gregory


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ
  2014-01-22 12:39 ` [PATCH 2/2] at91: pinctrl: " Jean-Jacques Hiblot
@ 2014-01-22 12:49   ` Gregory CLEMENT
  0 siblings, 0 replies; 4+ messages in thread
From: Gregory CLEMENT @ 2014-01-22 12:49 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jean-Jacques,

On 22/01/2014 13:39, Jean-Jacques Hiblot 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>
> ---
>  drivers/pinctrl/pinctrl-at91.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index e8c8301..fbedde2 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1299,6 +1299,28 @@ 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;
> +	}
> +	return 0;
> +}

As for the 1st patch, a blank line between the 2 functions should be nice

Thanks,

Gregory

> +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_unlock_as_irq(&at91_gpio->chip, pin);
> +}
> +
>  #ifdef CONFIG_PM
>  
>  static u32 wakeups[MAX_GPIO_BANKS];
> @@ -1377,6 +1399,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,
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-22 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 12:39 [PATCH 1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ Jean-Jacques Hiblot
2014-01-22 12:39 ` [PATCH 2/2] at91: pinctrl: " Jean-Jacques Hiblot
2014-01-22 12:49   ` Gregory CLEMENT
2014-01-22 12:47 ` [PATCH 1/2] at91: gpio: " Gregory CLEMENT

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.