linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] ARM: at91/gpio: add .to_irq gpio_chip handler and rework irq_to_gpio
Date: Wed, 4 Jan 2012 12:47:21 -0700	[thread overview]
Message-ID: <20120104194721.GB15503@ponder.secretlab.ca> (raw)
In-Reply-To: <57a5d54dd158c909a3c854b5bfc873a5f43e60ea.1323975517.git.nicolas.ferre@atmel.com>

On Thu, Dec 15, 2011 at 08:16:06PM +0100, Nicolas Ferre wrote:
> Replace the gpio_to_irq() macro by a plain gpiolib .to_irq() handler.
> The irq_to_gpio() macro is removed. A local replacement is created
> to fill the need of the gpio driver, internally.
> 
> Those calls are using the irqdomain to translate hardware to Linux
> IRQ numbers.
> 
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  arch/arm/mach-at91/gpio.c              |   23 +++++++++++++++++++++++
>  arch/arm/mach-at91/include/mach/gpio.h |   12 ------------
>  2 files changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
> index edb453a..c390f71 100644
> --- a/arch/arm/mach-at91/gpio.c
> +++ b/arch/arm/mach-at91/gpio.c
> @@ -11,6 +11,7 @@
>  
>  #include <linux/clk.h>
>  #include <linux/errno.h>
> +#include <linux/device.h>
>  #include <linux/gpio.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> @@ -46,6 +47,7 @@ static int at91_gpiolib_direction_output(struct gpio_chip *chip,
>  					 unsigned offset, int val);
>  static int at91_gpiolib_direction_input(struct gpio_chip *chip,
>  					unsigned offset);
> +static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset);
>  
>  #define AT91_GPIO_CHIP(name, base_gpio, nr_gpio)			\
>  	{								\
> @@ -57,6 +59,7 @@ static int at91_gpiolib_direction_input(struct gpio_chip *chip,
>  			.set		  = at91_gpiolib_set,		\
>  			.dbg_show	  = at91_gpiolib_dbg_show,	\
>  			.base		  = base_gpio,			\
> +			.to_irq		  = at91_gpiolib_to_irq,	\
>  			.ngpio		  = nr_gpio,			\
>  		},							\
>  	}
> @@ -86,6 +89,16 @@ static inline unsigned pin_to_mask(unsigned pin)
>  }
>  
>  
> +/*
> + * As gpio IRQs are stacked without holes, we can determine
> + * the gpio form an irq number comparing it with the first IRQ of first
> + * GPIO/IRQ domain.
> + */
> +static inline unsigned irq_to_gpio(unsigned irq)
> +{
> +	return irq - irq_domain_to_irq(&gpio_chip[0].domain, 0);
> +}
> +
>  /*--------------------------------------------------------------------------*/
>  
>  /* Not all hardware capabilities are exposed through these calls; they
> @@ -625,6 +638,16 @@ static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
>  	}
>  }
>  
> +static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset)
> +{
> +	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
> +	int retirq = irq_domain_to_irq(&at91_gpio->domain, offset);
> +
> +	dev_dbg(chip->dev, "request IRQ for GPIO %d, return %d\n", offset,
> +		retirq);
> +	return retirq;
> +}
> +
>  #ifdef CONFIG_OF_GPIO
>  static void __init of_at91_gpio_init_one(struct device_node *np)
>  {
> diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
> index e3fd225..7cf009b 100644
> --- a/arch/arm/mach-at91/include/mach/gpio.h
> +++ b/arch/arm/mach-at91/include/mach/gpio.h
> @@ -204,18 +204,6 @@ extern int at91_get_gpio_value(unsigned pin);
>  extern void at91_gpio_suspend(void);
>  extern void at91_gpio_resume(void);
>  
> -/*-------------------------------------------------------------------------*/
> -
> -/* wrappers for "new style" GPIO calls. the old AT91-specific ones should
> - * eventually be removed (along with this errno.h inclusion), and the
> - * gpio request/free calls should probably be implemented.
> - */
> -
> -#include <asm/errno.h>
> -
> -#define gpio_to_irq(gpio) (gpio + NR_AIC_IRQS)
> -#define irq_to_gpio(irq)  (irq - NR_AIC_IRQS)
> -
>  #endif	/* __ASSEMBLY__ */
>  
>  #endif
> -- 
> 1.7.5.4
> 

  reply	other threads:[~2012-01-04 19:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15 19:16 [PATCH 0/6] ARM: at91: irqdomain and device tree for AIC and GPIO Nicolas Ferre
2011-12-15 19:16 ` [PATCH v4 1/6] ARM: at91/aic: add irq domain and device tree support Nicolas Ferre
2012-01-04 19:40   ` Grant Likely
2012-01-05 16:26     ` Nicolas Ferre
2012-01-05 18:02       ` Grant Likely
2011-12-15 19:16 ` [PATCH 2/6] ARM: at91/gpio: add irqdomain to gpio interrupts Nicolas Ferre
2012-01-04 19:42   ` Grant Likely
2011-12-15 19:16 ` [PATCH 3/6] ARM: at91/gpio: add DT support Nicolas Ferre
2011-12-16 10:11   ` Jamie Iles
2012-01-03 16:25     ` Nicolas Ferre
2012-01-03 18:34   ` [PATCH v2 " Nicolas Ferre
2012-01-04 19:45     ` Grant Likely
2012-01-04 22:04     ` Russell King - ARM Linux
2012-01-05 19:42     ` [PATCH v3 " Nicolas Ferre
2012-01-05 17:50       ` Nicolas Ferre
2012-01-05 20:03       ` [PATCH v4 " Nicolas Ferre
2011-12-15 19:16 ` [PATCH 4/6] ARM: at91/gpio: add .to_irq gpio_chip handler and rework irq_to_gpio Nicolas Ferre
2012-01-04 19:47   ` Grant Likely [this message]
2011-12-15 19:16 ` [PATCH 5/6] ARM: at91/gpio: remove the static specification of gpio_chip.base Nicolas Ferre
2012-01-04 19:47   ` Grant Likely
2011-12-15 19:16 ` [PATCH 6/6] ARM: at91/board-dt: remove AIC irq domain from board file Nicolas Ferre
2012-01-04 19:48   ` Grant Likely
2011-12-16  1:53 ` [PATCH 0/6] ARM: at91: irqdomain and device tree for AIC and GPIO Rob Herring
2011-12-16 16:29   ` Nicolas Ferre

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=20120104194721.GB15503@ponder.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).