linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: adharmap@codeaurora.org (Abhijeet Dharmapurikar)
To: linux-arm-kernel@lists.infradead.org
Subject: arm: orion: Use generic irq chip
Date: Wed, 20 Apr 2011 01:21:50 -0700	[thread overview]
Message-ID: <4DAE979E.6000907@codeaurora.org> (raw)
In-Reply-To: <20110416211307.498522459@linutronix.de>

On 04/16/2011 02:14 PM, Thomas Gleixner wrote:
> The core interrupt chip is a straight forward conversion. The gpio
> chip is implemented with two instances of the irq_chip_type which can
> be switched with the irq_set_type function. That allows us to use the
> generic callbacks and avoids the conditionals in them.
>
> Signed-off-by: Thomas Gleixner<tglx@linutronix.de>
> ---
>   arch/arm/plat-orion/gpio.c              |  110 ++++++++++----------------------
>   arch/arm/plat-orion/include/plat/gpio.h |    1
>   arch/arm/plat-orion/irq.c               |   49 ++------------
>   3 files changed, 44 insertions(+), 116 deletions(-)
>
> Index: linux-2.6/arch/arm/plat-orion/gpio.c
> ===================================================================
> --- linux-2.6.orig/arch/arm/plat-orion/gpio.c
> +++ linux-2.6/arch/arm/plat-orion/gpio.c
> @@ -321,59 +321,16 @@ EXPORT_SYMBOL(orion_gpio_set_blink);
>    *        polarity    LEVEL          mask
>    *
>    ****************************************************************************/
> -static void gpio_irq_ack(struct irq_data *d)
> -{
> -	struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d);
> -	int type = irqd_get_trigger_type(d);
> -
> -	if (type&  (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
> -		int pin = d->irq - ochip->secondary_irq_base;
> -
> -		writel(~(1<<  pin), GPIO_EDGE_CAUSE(ochip));
> -	}
> -}
> -
> -static void gpio_irq_mask(struct irq_data *d)
> -{
> -	struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d);
> -	int type = irqd_get_trigger_type(d);
> -	void __iomem *reg;
> -	int pin;
> -
> -	if (type&  (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
> -		reg = GPIO_EDGE_MASK(ochip);
> -	else
> -		reg = GPIO_LEVEL_MASK(ochip);
> -
> -	pin = d->irq - ochip->secondary_irq_base;
> -
> -	writel(readl(reg)&  ~(1<<  pin), reg);
> -}
> -
> -static void gpio_irq_unmask(struct irq_data *d)
> -{
> -	struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d);
> -	int type = irqd_get_trigger_type(d);
> -	void __iomem *reg;
> -	int pin;
> -
> -	if (type&  (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
> -		reg = GPIO_EDGE_MASK(ochip);
> -	else
> -		reg = GPIO_LEVEL_MASK(ochip);
> -
> -	pin = d->irq - ochip->secondary_irq_base;
> -
> -	writel(readl(reg) | (1<<  pin), reg);
> -}
>
>   static int gpio_irq_set_type(struct irq_data *d, u32 type)
>   {
> -	struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d);
> +	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
> +	struct irq_chip_type *ct = irq_data_get_chip_type(d);
> +	struct orion_gpio_chip *ochip = gc->private;
>   	int pin;
>   	u32 u;
>
> -	pin = d->irq - ochip->secondary_irq_base;
> +	pin = d->irq - gc->irq_base;
>
>   	u = readl(GPIO_IO_CONF(ochip))&  (1<<  pin);
>   	if (!u) {
> @@ -382,18 +339,14 @@ static int gpio_irq_set_type(struct irq_
>   		return -EINVAL;
>   	}
>
> -	/*
> -	 * Set edge/level type.
> -	 */
> -	if (type&  (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
> -		__irq_set_handler_locked(d->irq, handle_edge_irq);
> -	} else if (type&  (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
> -		__irq_set_handler_locked(d->irq, handle_level_irq);
> -	} else {
> -		printk(KERN_ERR "failed to set irq=%d (type=%d)\n",
> -		       d->irq, type);
> +	type&= IRQ_TYPE_SENSE_MASK;
> +	if (type == IRQ_TYPE_NONE)
>   		return -EINVAL;
> -	}
> +
> +	/* Check if we need to change chip and handler */
> +	if (!(ct->type&  type))
> +		if (irq_setup_alt_chip(d, type))
> +			return -EINVAL;
>
>   	/*
>   	 * Configure interrupt polarity.
> @@ -425,19 +378,12 @@ static int gpio_irq_set_type(struct irq_
>   	return 0;
>   }
>
> -struct irq_chip orion_gpio_irq_chip = {
> -	.name		= "orion_gpio_irq",
> -	.irq_ack	= gpio_irq_ack,
> -	.irq_mask	= gpio_irq_mask,
> -	.irq_unmask	= gpio_irq_unmask,
> -	.irq_set_type	= gpio_irq_set_type,
> -};
> -
>   void __init orion_gpio_init(int gpio_base, int ngpio,
>   			    u32 base, int mask_offset, int secondary_irq_base)
>   {
>   	struct orion_gpio_chip *ochip;
> -	int i;
> +	struct irq_chip_generic *gc;
> +	struct irq_chip_type *ct;
>
>   	if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips))
>   		return;
> @@ -471,15 +417,29 @@ void __init orion_gpio_init(int gpio_bas
>   	writel(0, GPIO_EDGE_MASK(ochip));
>   	writel(0, GPIO_LEVEL_MASK(ochip));
>
> -	for (i = 0; i<  ngpio; i++) {
> -		unsigned int irq = secondary_irq_base + i;
> +	gc = irq_alloc_generic_chip("orion_gpio_irq", 1, secondary_irq_base,
> +				    ochip->base, handle_level_irq);

should this be 2 instead of 1 ?
	gc = irq_alloc_generic_chip("orion_gpio_irq", 2,  ...


> +	gc->private = ochip;
> +
> +	ct = gc->chip_types;
> +	ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
> +	ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
> +	ct->chip.irq_mask = irq_gc_mask_clr_bit;
> +	ct->chip.irq_unmask = irq_gc_mask_set_bit;
> +	ct->chip.irq_set_type = gpio_irq_set_type;
> +
> +	ct++;
> +	ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF;
> +	ct->regs.ack = GPIO_EDGE_CAUSE_OFF;
> +	ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
> +	ct->chip.irq_ack = irq_gc_ack;
> +	ct->chip.irq_mask = irq_gc_mask_clr_bit;
> +	ct->chip.irq_unmask = irq_gc_mask_set_bit;
> +	ct->chip.irq_set_type = gpio_irq_set_type;
> +	ct->handler = handle_edge_irq;
>
> -		irq_set_chip_and_handler(irq,&orion_gpio_irq_chip,
> -					 handle_level_irq);
> -		irq_set_chip_data(irq, ochip);
> -		irq_set_status_flags(irq, IRQ_LEVEL);
> -		set_irq_flags(irq, IRQF_VALID);
> -	}
> +	irq_setup_generic_chip(gc, IRQ_MSK(ngpio), IRQ_NOREQUEST,
> +			       IRQ_LEVEL | IRQ_NOPROBE);
>   }

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  reply	other threads:[~2011-04-20  8:21 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16 21:14 [RFC patch 00/20] Interrupt chip consolidation Thomas Gleixner
2011-04-16 21:14 ` genirq: Implement a generic interrupt chip Thomas Gleixner
2011-04-18 17:20   ` H Hartley Sweeten
2011-04-18 19:32     ` Thomas Gleixner
2011-04-18 19:43       ` Thomas Gleixner
2011-04-18 20:32         ` H Hartley Sweeten
2011-04-19  7:57   ` Tony Lindgren
2011-04-19 10:01     ` Tony Lindgren
2011-04-20  8:20   ` Abhijeet Dharmapurikar
2011-04-20  9:34     ` Thomas Gleixner
2011-04-16 21:14 ` genirq: Add chip suspend and resume callbacks Thomas Gleixner
2011-04-16 21:14 ` arm: vic: Use generic interrupt chip Thomas Gleixner
2011-04-18 17:34   ` H Hartley Sweeten
2011-04-16 21:14 ` arm: vic: Implement irq_suspend/resume callbacks Thomas Gleixner
2011-04-16 21:14 ` arm: orion: Use generic irq chip Thomas Gleixner
2011-04-20  8:21   ` Abhijeet Dharmapurikar [this message]
2011-04-20  8:35     ` Thomas Gleixner
2011-04-16 21:14 ` arm: davinci: " Thomas Gleixner
2011-04-20  0:01   ` Kevin Hilman
2011-04-25  6:50   ` Nori, Sekhar
2011-04-16 21:14 ` arm: bcmring: Use generic irq chip implementation Thomas Gleixner
2011-04-16 21:14 ` arm: samsung: Convert irq-vic-timer to generic irq chip Thomas Gleixner
2011-04-17 21:52   ` Kukjin Kim
2011-04-19  9:59   ` [PATCH] arm: omap2/3: Use " Tony Lindgren
2011-04-16 21:14 ` arm: samsung: Convert irq_uart to " Thomas Gleixner
2011-04-17 21:53   ` Kukjin Kim
2011-04-16 21:14 ` arm: samsung: s5p: Convert irq-gpioint " Thomas Gleixner
2011-04-17 21:51   ` Kukjin Kim
2011-04-16 21:14 ` arm: tcc8k: Convert " Thomas Gleixner
2011-04-16 21:14 ` arm: msm: Convert sirc " Thomas Gleixner
2011-04-21 15:13   ` Abhijeet Dharmapurikar
2011-04-16 21:14 ` arm: sa1111: Convert " Thomas Gleixner
2011-04-16 21:14 ` arm: msm: Convert irq.c chip " Thomas Gleixner
2011-04-16 21:14 ` arm: msm: Convert irq-vic " Thomas Gleixner
2011-04-21 16:53   ` Abhijeet Dharmapurikar
2011-04-21 17:28     ` Thomas Gleixner
2011-04-25  6:11       ` Abhijeet Dharmapurikar
2011-04-25 10:13         ` Linus Walleij
2011-04-16 21:14 ` arm: msm: Cleanup the irq.c code some more Thomas Gleixner
2011-04-16 21:14 ` arm: msm: Use irq-vic for all vic instances Thomas Gleixner
2011-04-16 21:14 ` arm: msm: Consolidate more Thomas Gleixner
2011-04-16 21:14 ` arm: pxa: Convert SC and GPIO-l to generic irq chips Thomas Gleixner
2011-04-19  8:22 ` [RFC patch 00/20] Interrupt chip consolidation Lars-Peter Clausen
2011-04-19  9:41   ` Thomas Gleixner
2011-04-19 10:10     ` Lars-Peter Clausen
2011-04-19 10:26       ` Thomas Gleixner

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=4DAE979E.6000907@codeaurora.org \
    --to=adharmap@codeaurora.org \
    --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).