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 2/6] ARM: at91/gpio: add irqdomain to gpio interrupts
Date: Wed, 4 Jan 2012 12:42:40 -0700	[thread overview]
Message-ID: <20120104194240.GZ15503@ponder.secretlab.ca> (raw)
In-Reply-To: <56e135f94dc4d88ab6d586f13e406977c4f4bb35.1323975517.git.nicolas.ferre@atmel.com>

On Thu, Dec 15, 2011 at 08:16:04PM +0100, Nicolas Ferre wrote:
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

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

> ---
>  arch/arm/mach-at91/gpio.c |   34 +++++++++++++++++++++++++++++-----
>  1 files changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
> index 74d6783..7ffb893 100644
> --- a/arch/arm/mach-at91/gpio.c
> +++ b/arch/arm/mach-at91/gpio.c
> @@ -20,6 +20,7 @@
>  #include <linux/list.h>
>  #include <linux/module.h>
>  #include <linux/io.h>
> +#include <linux/irqdomain.h>
>  
>  #include <mach/hardware.h>
>  #include <mach/at91_pio.h>
> @@ -32,6 +33,7 @@ struct at91_gpio_chip {
>  	int			id;		/* ID of register bank */
>  	void __iomem		*regbase;	/* Base of register bank */
>  	struct clk		*clock;		/* associated clock */
> +	struct irq_domain	domain;		/* associated irq domain */
>  };
>  
>  #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
> @@ -483,6 +485,24 @@ postcore_initcall(at91_gpio_debugfs_init);
>  /*--------------------------------------------------------------------------*/
>  
>  /*
> + * irqdomain initialization: pile up irqdomains on top of AIC range
> + */
> +static void __init at91_gpio_irqdomain(struct at91_gpio_chip *at91_gpio)
> +{
> +	struct irq_domain	*gpio_irq_d = &at91_gpio->domain;
> +	int			ret;
> +
> +	ret = irq_alloc_descs(-1, 0, at91_gpio->chip.ngpio, 0);
> +	if (ret < 0)
> +		panic("at91_gpio.%d: error %d: couldn't allocate IRQ numbers.\n",
> +			at91_gpio->id, ret);
> +	gpio_irq_d->irq_base = ret;
> +	gpio_irq_d->nr_irq = at91_gpio->chip.ngpio;
> +	gpio_irq_d->ops = &irq_domain_simple_ops;
> +	irq_domain_add(gpio_irq_d);
> +}
> +
> +/*
>   * This lock class tells lockdep that GPIO irqs are in a different
>   * category than their parents, so it won't report false recursion.
>   */
> @@ -493,19 +513,22 @@ static struct lock_class_key gpio_lock_class;
>   */
>  void __init at91_gpio_irq_setup(void)
>  {
> -	unsigned		pioc, irq = gpio_to_irq(0);
> +	unsigned		pioc;
> +	int			irq = 0;
>  	struct at91_gpio_chip	*this, *prev;
>  
>  	for (pioc = 0, this = gpio_chip, prev = NULL;
>  			pioc++ < gpio_banks;
>  			prev = this, this++) {
>  		unsigned	id = this->id;
> -		unsigned	i;
> +		int		hwirq;
>  
>  		__raw_writel(~0, this->regbase + PIO_IDR);
>  
> -		for (i = 0, irq = gpio_to_irq(this->chip.base); i < 32;
> -		     i++, irq++) {
> +		/* setup irq domain for this GPIO controller */
> +		at91_gpio_irqdomain(this);
> +
> +		irq_domain_for_each_irq((&this->domain), hwirq, irq) {
>  			irq_set_lockdep_class(irq, &gpio_lock_class);
>  
>  			/*
> @@ -527,7 +550,8 @@ void __init at91_gpio_irq_setup(void)
>  		irq_set_chip_data(id, this);
>  		irq_set_chained_handler(id, gpio_irq_handler);
>  	}
> -	pr_info("AT91: %d gpio irqs in %d banks\n", irq - gpio_to_irq(0), gpio_banks);
> +	pr_info("AT91: %d gpio irqs in %d banks\n",
> +		irq - irq_domain_to_irq(&gpio_chip[0].domain, 0), gpio_banks);
>  }
>  
>  /* gpiolib support */
> -- 
> 1.7.5.4
> 

  reply	other threads:[~2012-01-04 19:42 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 [this message]
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
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=20120104194240.GZ15503@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).