All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] show_interrupts: use irq_chip::name if available
@ 2009-12-01 20:48 Peter Korsgaard
  2009-12-01 20:48 ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
  2009-12-09  7:32 ` [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
  0 siblings, 2 replies; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-01 20:48 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt

struct irq_chip::typename is going away (replaced by name). Use name if
set instead of typename in show_interrupt to make ease transition.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/kernel/irq.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index e5d1211..33e1130 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -203,7 +203,8 @@ int show_interrupts(struct seq_file *p, void *v)
 		seq_printf(p, "%10u ", kstat_irqs(i));
 #endif /* CONFIG_SMP */
 		if (desc->chip)
-			seq_printf(p, " %s ", desc->chip->typename);
+			seq_printf(p, " %s ", desc->chip->name ?
+				   desc->chip->name : desc->chip->typename);
 		else
 			seq_puts(p, "  None      ");
 		seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
-- 
1.6.5

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

* [PATCH 2/3] asm/gpio.h: support gpio_to_irq()
  2009-12-01 20:48 [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
@ 2009-12-01 20:48 ` Peter Korsgaard
  2009-12-01 20:48   ` [PATCH 3/3] mpc8xxx_gpio: add interrupt support Peter Korsgaard
                     ` (2 more replies)
  2009-12-09  7:32 ` [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
  1 sibling, 3 replies; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-01 20:48 UTC (permalink / raw)
  To: linuxppc-dev, Anton Vorontsov

gpiolib returns -ENXIO if struct gpio_chip::to_irq isn't set, so it's
safe to always call.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/include/asm/gpio.h |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
index ea04632..38762ed 100644
--- a/arch/powerpc/include/asm/gpio.h
+++ b/arch/powerpc/include/asm/gpio.h
@@ -38,12 +38,9 @@ static inline int gpio_cansleep(unsigned int gpio)
 	return __gpio_cansleep(gpio);
 }
 
-/*
- * Not implemented, yet.
- */
 static inline int gpio_to_irq(unsigned int gpio)
 {
-	return -ENOSYS;
+	return __gpio_to_irq(gpio);
 }
 
 static inline int irq_to_gpio(unsigned int irq)
-- 
1.6.5

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

* [PATCH 3/3] mpc8xxx_gpio: add interrupt support
  2009-12-01 20:48 ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
@ 2009-12-01 20:48   ` Peter Korsgaard
  2009-12-09  7:33     ` Peter Korsgaard
  2009-12-09  7:32   ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
  2009-12-11  2:09   ` Kumar Gala
  2 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-01 20:48 UTC (permalink / raw)
  To: linuxppc-dev, Anton Vorontsov, Kumar Gala

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/sysdev/mpc8xxx_gpio.c |  147 ++++++++++++++++++++++++++++++++++++
 1 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c
index 103eace..b46f28b 100644
--- a/arch/powerpc/sysdev/mpc8xxx_gpio.c
+++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
+#include <linux/irq.h>
 
 #define MPC8XXX_GPIO_PINS	32
 
@@ -34,6 +35,7 @@ struct mpc8xxx_gpio_chip {
 	 * open drain mode safely
 	 */
 	u32 data;
+	struct irq_host *irq;
 };
 
 static inline u32 mpc8xxx_gpio2mask(unsigned int gpio)
@@ -111,12 +113,136 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val
 	return 0;
 }
 
+static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
+{
+	struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
+
+	if (mpc8xxx_gc->irq && offset < MPC8XXX_GPIO_PINS)
+		return irq_create_mapping(mpc8xxx_gc->irq, offset);
+	else
+		return -ENXIO;
+}
+
+static void mpc8xxx_gpio_irq_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_desc_data(desc);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned int mask;
+
+	mask = in_be32(mm->regs + GPIO_IER) & in_be32(mm->regs + GPIO_IMR);
+	if (mask)
+		generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
+						     32 - ffs(mask)));
+}
+
+static void mpc8xxx_irq_unmask(unsigned int virq)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned long flags;
+
+	spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+
+	setbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(virq_to_hw(virq)));
+
+	spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+}
+
+static void mpc8xxx_irq_mask(unsigned int virq)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned long flags;
+
+	spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+
+	clrbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(virq_to_hw(virq)));
+
+	spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+}
+
+static void mpc8xxx_irq_ack(unsigned int virq)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+
+	out_be32(mm->regs + GPIO_IER, mpc8xxx_gpio2mask(virq_to_hw(virq)));
+}
+
+static int mpc8xxx_irq_set_type(unsigned int virq, unsigned int flow_type)
+{
+	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
+	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
+	unsigned long flags;
+
+	switch (flow_type) {
+	case IRQ_TYPE_EDGE_FALLING:
+		spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+		setbits32(mm->regs + GPIO_ICR,
+			  mpc8xxx_gpio2mask(virq_to_hw(virq)));
+		spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+		break;
+
+	case IRQ_TYPE_EDGE_BOTH:
+		spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+		clrbits32(mm->regs + GPIO_ICR,
+			  mpc8xxx_gpio2mask(virq_to_hw(virq)));
+		spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static struct irq_chip mpc8xxx_irq_chip = {
+	.name		= "mpc8xxx-gpio",
+	.unmask		= mpc8xxx_irq_unmask,
+	.mask		= mpc8xxx_irq_mask,
+	.ack		= mpc8xxx_irq_ack,
+	.set_type	= mpc8xxx_irq_set_type,
+};
+
+static int mpc8xxx_gpio_irq_map(struct irq_host *h, unsigned int virq,
+				irq_hw_number_t hw)
+{
+	set_irq_chip_data(virq, h->host_data);
+	set_irq_chip_and_handler(virq, &mpc8xxx_irq_chip, handle_level_irq);
+	set_irq_type(virq, IRQ_TYPE_NONE);
+
+	return 0;
+}
+
+static int mpc8xxx_gpio_irq_xlate(struct irq_host *h, struct device_node *ct,
+				  u32 *intspec, unsigned int intsize,
+				  irq_hw_number_t *out_hwirq,
+				  unsigned int *out_flags)
+
+{
+	/* interrupt sense values coming from the device tree equal either
+	 * EDGE_FALLING or EDGE_BOTH
+	 */
+	*out_hwirq = intspec[0];
+	*out_flags = intspec[1];
+
+	return 0;
+}
+
+static struct irq_host_ops mpc8xxx_gpio_irq_ops = {
+	.map	= mpc8xxx_gpio_irq_map,
+	.xlate	= mpc8xxx_gpio_irq_xlate,
+};
+
 static void __init mpc8xxx_add_controller(struct device_node *np)
 {
 	struct mpc8xxx_gpio_chip *mpc8xxx_gc;
 	struct of_mm_gpio_chip *mm_gc;
 	struct of_gpio_chip *of_gc;
 	struct gpio_chip *gc;
+	unsigned hwirq;
 	int ret;
 
 	mpc8xxx_gc = kzalloc(sizeof(*mpc8xxx_gc), GFP_KERNEL);
@@ -138,11 +264,32 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
 	gc->direction_output = mpc8xxx_gpio_dir_out;
 	gc->get = mpc8xxx_gpio_get;
 	gc->set = mpc8xxx_gpio_set;
+	gc->to_irq = mpc8xxx_gpio_to_irq;
 
 	ret = of_mm_gpiochip_add(np, mm_gc);
 	if (ret)
 		goto err;
 
+	hwirq = irq_of_parse_and_map(np, 0);
+	if (hwirq == NO_IRQ)
+		goto skip_irq;
+
+	mpc8xxx_gc->irq =
+		irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, MPC8XXX_GPIO_PINS,
+			       &mpc8xxx_gpio_irq_ops, MPC8XXX_GPIO_PINS);
+	if (!mpc8xxx_gc->irq)
+		goto skip_irq;
+
+	mpc8xxx_gc->irq->host_data = mpc8xxx_gc;
+
+	/* ack and mask all irqs */
+	out_be32(mm_gc->regs + GPIO_IER, 0xffffffff);
+	out_be32(mm_gc->regs + GPIO_IMR, 0);
+
+	set_irq_data(hwirq, mpc8xxx_gc);
+	set_irq_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade);
+
+skip_irq:
 	return;
 
 err:
-- 
1.6.5

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

* Re: [PATCH 1/3] show_interrupts: use irq_chip::name if available
  2009-12-01 20:48 [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
  2009-12-01 20:48 ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
@ 2009-12-09  7:32 ` Peter Korsgaard
  2009-12-09  8:59   ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-09  7:32 UTC (permalink / raw)
  To: linuxppc-dev

>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:

 Peter> struct irq_chip::typename is going away (replaced by name). Use name if
 Peter> set instead of typename in show_interrupt to make ease transition.

Comments?

 Peter> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
 Peter> ---
 Peter>  arch/powerpc/kernel/irq.c |    3 ++-
 Peter>  1 files changed, 2 insertions(+), 1 deletions(-)

 Peter> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
 Peter> index e5d1211..33e1130 100644
 Peter> --- a/arch/powerpc/kernel/irq.c
 Peter> +++ b/arch/powerpc/kernel/irq.c
 Peter> @@ -203,7 +203,8 @@ int show_interrupts(struct seq_file *p, void *v)
 Peter>  		seq_printf(p, "%10u ", kstat_irqs(i));
 Peter>  #endif /* CONFIG_SMP */
 Peter>  		if (desc->chip)
 Peter> -			seq_printf(p, " %s ", desc->chip->typename);
 Peter> +			seq_printf(p, " %s ", desc->chip->name ?
 Peter> +				   desc->chip->name : desc->chip->typename);
 Peter>  		else
 Peter>  			seq_puts(p, "  None      ");
 Peter>  		seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
 Peter> -- 
 Peter> 1.6.5


-- 
Bye, Peter Korsgaard

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

* Re: [PATCH 2/3] asm/gpio.h: support gpio_to_irq()
  2009-12-01 20:48 ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
  2009-12-01 20:48   ` [PATCH 3/3] mpc8xxx_gpio: add interrupt support Peter Korsgaard
@ 2009-12-09  7:32   ` Peter Korsgaard
  2009-12-11  2:09   ` Kumar Gala
  2 siblings, 0 replies; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-09  7:32 UTC (permalink / raw)
  To: linuxppc-dev

>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:

 Peter> gpiolib returns -ENXIO if struct gpio_chip::to_irq isn't set, so it's
 Peter> safe to always call.

Comments?

 Peter> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
 Peter> ---
 Peter>  arch/powerpc/include/asm/gpio.h |    5 +----
 Peter>  1 files changed, 1 insertions(+), 4 deletions(-)

 Peter> diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
 Peter> index ea04632..38762ed 100644
 Peter> --- a/arch/powerpc/include/asm/gpio.h
 Peter> +++ b/arch/powerpc/include/asm/gpio.h
 Peter> @@ -38,12 +38,9 @@ static inline int gpio_cansleep(unsigned int gpio)
 Peter>  	return __gpio_cansleep(gpio);
 Peter>  }
 
 Peter> -/*
 Peter> - * Not implemented, yet.
 Peter> - */
 Peter>  static inline int gpio_to_irq(unsigned int gpio)
 Peter>  {
 Peter> -	return -ENOSYS;
 Peter> +	return __gpio_to_irq(gpio);
 Peter>  }
 
 Peter>  static inline int irq_to_gpio(unsigned int irq)
 Peter> -- 
 Peter> 1.6.5


-- 
Bye, Peter Korsgaard

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

* Re: [PATCH 3/3] mpc8xxx_gpio: add interrupt support
  2009-12-01 20:48   ` [PATCH 3/3] mpc8xxx_gpio: add interrupt support Peter Korsgaard
@ 2009-12-09  7:33     ` Peter Korsgaard
  2009-12-11  2:13       ` Kumar Gala
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-09  7:33 UTC (permalink / raw)
  To: linuxppc-dev

>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:

Comments?

 Peter> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
 Peter> ---
 Peter>  arch/powerpc/sysdev/mpc8xxx_gpio.c |  147 ++++++++++++++++++++++++++++++++++++
 Peter>  1 files changed, 147 insertions(+), 0 deletions(-)

 Peter> diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c
 Peter> index 103eace..b46f28b 100644
 Peter> --- a/arch/powerpc/sysdev/mpc8xxx_gpio.c
 Peter> +++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c
 Peter> @@ -15,6 +15,7 @@
 Peter>  #include <linux/of.h>
 Peter>  #include <linux/of_gpio.h>
 Peter>  #include <linux/gpio.h>
 Peter> +#include <linux/irq.h>
 
 Peter>  #define MPC8XXX_GPIO_PINS	32
 
 Peter> @@ -34,6 +35,7 @@ struct mpc8xxx_gpio_chip {
 Peter>  	 * open drain mode safely
 Peter>  	 */
 Peter>  	u32 data;
 Peter> +	struct irq_host *irq;
 Peter>  };
 
 Peter>  static inline u32 mpc8xxx_gpio2mask(unsigned int gpio)
 Peter> @@ -111,12 +113,136 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val
 Peter>  	return 0;
 Peter>  }
 
 Peter> +static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
 Peter> +{
 Peter> +	struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
 Peter> +	struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
 Peter> +
 Peter> +	if (mpc8xxx_gc->irq && offset < MPC8XXX_GPIO_PINS)
 Peter> +		return irq_create_mapping(mpc8xxx_gc->irq, offset);
 Peter> +	else
 Peter> +		return -ENXIO;
 Peter> +}
 Peter> +
 Peter> +static void mpc8xxx_gpio_irq_cascade(unsigned int irq, struct irq_desc *desc)
 Peter> +{
 Peter> +	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_desc_data(desc);
 Peter> +	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
 Peter> +	unsigned int mask;
 Peter> +
 Peter> +	mask = in_be32(mm->regs + GPIO_IER) & in_be32(mm->regs + GPIO_IMR);
 Peter> +	if (mask)
 Peter> +		generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
 Peter> +						     32 - ffs(mask)));
 Peter> +}
 Peter> +
 Peter> +static void mpc8xxx_irq_unmask(unsigned int virq)
 Peter> +{
 Peter> +	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
 Peter> +	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
 Peter> +	unsigned long flags;
 Peter> +
 Peter> +	spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
 Peter> +
 Peter> +	setbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(virq_to_hw(virq)));
 Peter> +
 Peter> +	spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
 Peter> +}
 Peter> +
 Peter> +static void mpc8xxx_irq_mask(unsigned int virq)
 Peter> +{
 Peter> +	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
 Peter> +	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
 Peter> +	unsigned long flags;
 Peter> +
 Peter> +	spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
 Peter> +
 Peter> +	clrbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(virq_to_hw(virq)));
 Peter> +
 Peter> +	spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
 Peter> +}
 Peter> +
 Peter> +static void mpc8xxx_irq_ack(unsigned int virq)
 Peter> +{
 Peter> +	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
 Peter> +	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
 Peter> +
 Peter> +	out_be32(mm->regs + GPIO_IER, mpc8xxx_gpio2mask(virq_to_hw(virq)));
 Peter> +}
 Peter> +
 Peter> +static int mpc8xxx_irq_set_type(unsigned int virq, unsigned int flow_type)
 Peter> +{
 Peter> +	struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq);
 Peter> +	struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc;
 Peter> +	unsigned long flags;
 Peter> +
 Peter> +	switch (flow_type) {
 Peter> +	case IRQ_TYPE_EDGE_FALLING:
 Peter> +		spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
 Peter> +		setbits32(mm->regs + GPIO_ICR,
 Peter> +			  mpc8xxx_gpio2mask(virq_to_hw(virq)));
 Peter> +		spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
 Peter> +		break;
 Peter> +
 Peter> +	case IRQ_TYPE_EDGE_BOTH:
 Peter> +		spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
 Peter> +		clrbits32(mm->regs + GPIO_ICR,
 Peter> +			  mpc8xxx_gpio2mask(virq_to_hw(virq)));
 Peter> +		spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
 Peter> +		break;
 Peter> +
 Peter> +	default:
 Peter> +		return -EINVAL;
 Peter> +	}
 Peter> +
 Peter> +	return 0;
 Peter> +}
 Peter> +
 Peter> +static struct irq_chip mpc8xxx_irq_chip = {
 Peter> +	.name		= "mpc8xxx-gpio",
 Peter> +	.unmask		= mpc8xxx_irq_unmask,
 Peter> +	.mask		= mpc8xxx_irq_mask,
 Peter> +	.ack		= mpc8xxx_irq_ack,
 Peter> +	.set_type	= mpc8xxx_irq_set_type,
 Peter> +};
 Peter> +
 Peter> +static int mpc8xxx_gpio_irq_map(struct irq_host *h, unsigned int virq,
 Peter> +				irq_hw_number_t hw)
 Peter> +{
 Peter> +	set_irq_chip_data(virq, h->host_data);
 Peter> +	set_irq_chip_and_handler(virq, &mpc8xxx_irq_chip, handle_level_irq);
 Peter> +	set_irq_type(virq, IRQ_TYPE_NONE);
 Peter> +
 Peter> +	return 0;
 Peter> +}
 Peter> +
 Peter> +static int mpc8xxx_gpio_irq_xlate(struct irq_host *h, struct device_node *ct,
 Peter> +				  u32 *intspec, unsigned int intsize,
 Peter> +				  irq_hw_number_t *out_hwirq,
 Peter> +				  unsigned int *out_flags)
 Peter> +
 Peter> +{
 Peter> +	/* interrupt sense values coming from the device tree equal either
 Peter> +	 * EDGE_FALLING or EDGE_BOTH
 Peter> +	 */
 Peter> +	*out_hwirq = intspec[0];
 Peter> +	*out_flags = intspec[1];
 Peter> +
 Peter> +	return 0;
 Peter> +}
 Peter> +
 Peter> +static struct irq_host_ops mpc8xxx_gpio_irq_ops = {
 Peter> +	.map	= mpc8xxx_gpio_irq_map,
 Peter> +	.xlate	= mpc8xxx_gpio_irq_xlate,
 Peter> +};
 Peter> +
 Peter>  static void __init mpc8xxx_add_controller(struct device_node *np)
 Peter>  {
 Peter>  	struct mpc8xxx_gpio_chip *mpc8xxx_gc;
 Peter>  	struct of_mm_gpio_chip *mm_gc;
 Peter>  	struct of_gpio_chip *of_gc;
 Peter>  	struct gpio_chip *gc;
 Peter> +	unsigned hwirq;
 Peter>  	int ret;
 
 Peter>  	mpc8xxx_gc = kzalloc(sizeof(*mpc8xxx_gc), GFP_KERNEL);
 Peter> @@ -138,11 +264,32 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
 gc-> direction_output = mpc8xxx_gpio_dir_out;
 gc-> get = mpc8xxx_gpio_get;
 gc-> set = mpc8xxx_gpio_set;
 Peter> +	gc->to_irq = mpc8xxx_gpio_to_irq;
 
 Peter>  	ret = of_mm_gpiochip_add(np, mm_gc);
 Peter>  	if (ret)
 Peter>  		goto err;
 
 Peter> +	hwirq = irq_of_parse_and_map(np, 0);
 Peter> +	if (hwirq == NO_IRQ)
 Peter> +		goto skip_irq;
 Peter> +
 Peter> +	mpc8xxx_gc->irq =
 Peter> +		irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, MPC8XXX_GPIO_PINS,
 Peter> +			       &mpc8xxx_gpio_irq_ops, MPC8XXX_GPIO_PINS);
 Peter> +	if (!mpc8xxx_gc->irq)
 Peter> +		goto skip_irq;
 Peter> +
 Peter> +	mpc8xxx_gc->irq->host_data = mpc8xxx_gc;
 Peter> +
 Peter> +	/* ack and mask all irqs */
 Peter> +	out_be32(mm_gc->regs + GPIO_IER, 0xffffffff);
 Peter> +	out_be32(mm_gc->regs + GPIO_IMR, 0);
 Peter> +
 Peter> +	set_irq_data(hwirq, mpc8xxx_gc);
 Peter> +	set_irq_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade);
 Peter> +
 Peter> +skip_irq:
 Peter>  	return;
 
 Peter>  err:
 Peter> -- 
 Peter> 1.6.5


-- 
Bye, Peter Korsgaard

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

* Re: [PATCH 1/3] show_interrupts: use irq_chip::name if available
  2009-12-09  7:32 ` [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
@ 2009-12-09  8:59   ` Benjamin Herrenschmidt
  2009-12-09  9:09     ` Peter Korsgaard
  0 siblings, 1 reply; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2009-12-09  8:59 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linuxppc-dev

On Wed, 2009-12-09 at 08:32 +0100, Peter Korsgaard wrote:
> >>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:
> 
>  Peter> struct irq_chip::typename is going away (replaced by name). Use name if
>  Peter> set instead of typename in show_interrupt to make ease transition.
> 
> Comments?

Hi Peter !

There's already a patch in my -next tree from Thomas Gleixner that fixes
that up along with a few others in arch/powerpc.

Cheers,
Ben.

>  Peter> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
>  Peter> ---
>  Peter>  arch/powerpc/kernel/irq.c |    3 ++-
>  Peter>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
>  Peter> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
>  Peter> index e5d1211..33e1130 100644
>  Peter> --- a/arch/powerpc/kernel/irq.c
>  Peter> +++ b/arch/powerpc/kernel/irq.c
>  Peter> @@ -203,7 +203,8 @@ int show_interrupts(struct seq_file *p, void *v)
>  Peter>  		seq_printf(p, "%10u ", kstat_irqs(i));
>  Peter>  #endif /* CONFIG_SMP */
>  Peter>  		if (desc->chip)
>  Peter> -			seq_printf(p, " %s ", desc->chip->typename);
>  Peter> +			seq_printf(p, " %s ", desc->chip->name ?
>  Peter> +				   desc->chip->name : desc->chip->typename);
>  Peter>  		else
>  Peter>  			seq_puts(p, "  None      ");
>  Peter>  		seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
>  Peter> -- 
>  Peter> 1.6.5
> 
> 

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

* Re: [PATCH 1/3] show_interrupts: use irq_chip::name if available
  2009-12-09  8:59   ` Benjamin Herrenschmidt
@ 2009-12-09  9:09     ` Peter Korsgaard
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-09  9:09 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

>>>>> "Benjamin" == Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:

 Benjamin> On Wed, 2009-12-09 at 08:32 +0100, Peter Korsgaard wrote:
 >> >>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:
 >> 
 Peter> struct irq_chip::typename is going away (replaced by name). Use name if
 Peter> set instead of typename in show_interrupt to make ease transition.
 >> 
 >> Comments?

 Benjamin> Hi Peter !

 Benjamin> There's already a patch in my -next tree from Thomas Gleixner
 Benjamin> that fixes that up along with a few others in arch/powerpc.

Ahh, ok - Hadn't noticed - Sorry.

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH 2/3] asm/gpio.h: support gpio_to_irq()
  2009-12-01 20:48 ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
  2009-12-01 20:48   ` [PATCH 3/3] mpc8xxx_gpio: add interrupt support Peter Korsgaard
  2009-12-09  7:32   ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
@ 2009-12-11  2:09   ` Kumar Gala
  2 siblings, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2009-12-11  2:09 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: Anton Vorontsov, linuxppc-dev


On Dec 1, 2009, at 2:48 PM, Peter Korsgaard wrote:

> gpiolib returns -ENXIO if struct gpio_chip::to_irq isn't set, so it's
> safe to always call.
> 
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> ---
> arch/powerpc/include/asm/gpio.h |    5 +----
> 1 files changed, 1 insertions(+), 4 deletions(-)

applied to next

- k

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

* Re: [PATCH 3/3] mpc8xxx_gpio: add interrupt support
  2009-12-09  7:33     ` Peter Korsgaard
@ 2009-12-11  2:13       ` Kumar Gala
  2009-12-11 15:31         ` Peter Korsgaard
  0 siblings, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2009-12-11  2:13 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: Anton Vorontsov, linuxppc-dev


On Dec 9, 2009, at 1:33 AM, Peter Korsgaard wrote:

>>>>>> "Peter" =3D=3D Peter Korsgaard <jacmet@sunsite.dk> writes:
>=20
> Comments?
>=20
> Peter> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> Peter> ---
> Peter>  arch/powerpc/sysdev/mpc8xxx_gpio.c |  147 =
++++++++++++++++++++++++++++++++++++
> Peter>  1 files changed, 147 insertions(+), 0 deletions(-)

We need a binding document to go with this.

- k=

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

* Re: [PATCH 3/3] mpc8xxx_gpio: add interrupt support
  2009-12-11  2:13       ` Kumar Gala
@ 2009-12-11 15:31         ` Peter Korsgaard
  2009-12-17 20:31           ` Peter Korsgaard
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-11 15:31 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Anton Vorontsov, linuxppc-dev

>>>>> "Kumar" == Kumar Gala <galak@kernel.crashing.org> writes:

Hi,

 Kumar> We need a binding document to go with this.

Ok, but where should it go? In the existing
powerpc/dts-bindings/fsl/8xxx_gpio.txt or somewhere seperate? I don't
see any other interrupt controller documentation besides the stuff in
booting-without-of.txt

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH 3/3] mpc8xxx_gpio: add interrupt support
  2009-12-11 15:31         ` Peter Korsgaard
@ 2009-12-17 20:31           ` Peter Korsgaard
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Korsgaard @ 2009-12-17 20:31 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Anton Vorontsov, linuxppc-dev

>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:

>>>>> "Kumar" == Kumar Gala <galak@kernel.crashing.org> writes:
 Peter> Hi,

 Kumar> We need a binding document to go with this.

 Peter> Ok, but where should it go? In the existing
 Peter> powerpc/dts-bindings/fsl/8xxx_gpio.txt or somewhere seperate? I don't
 Peter> see any other interrupt controller documentation besides the stuff in
 Peter> booting-without-of.txt

Any comments?

-- 
Bye, Peter Korsgaard

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

end of thread, other threads:[~2009-12-17 20:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-01 20:48 [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
2009-12-01 20:48 ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
2009-12-01 20:48   ` [PATCH 3/3] mpc8xxx_gpio: add interrupt support Peter Korsgaard
2009-12-09  7:33     ` Peter Korsgaard
2009-12-11  2:13       ` Kumar Gala
2009-12-11 15:31         ` Peter Korsgaard
2009-12-17 20:31           ` Peter Korsgaard
2009-12-09  7:32   ` [PATCH 2/3] asm/gpio.h: support gpio_to_irq() Peter Korsgaard
2009-12-11  2:09   ` Kumar Gala
2009-12-09  7:32 ` [PATCH 1/3] show_interrupts: use irq_chip::name if available Peter Korsgaard
2009-12-09  8:59   ` Benjamin Herrenschmidt
2009-12-09  9:09     ` Peter Korsgaard

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.