Signed-off-by: Thomas Gleixner --- arch/arm/mach-tcc8k/irq.c | 83 ++++++++-------------------------------------- 1 file changed, 16 insertions(+), 67 deletions(-) Index: linux-2.6/arch/arm/mach-tcc8k/irq.c =================================================================== --- linux-2.6.orig/arch/arm/mach-tcc8k/irq.c +++ linux-2.6/arch/arm/mach-tcc8k/irq.c @@ -17,72 +17,27 @@ #include "common.h" -/* Disable IRQ */ -static void tcc8000_mask_ack_irq0(struct irq_data *d) +static __init void tcc8k_alloc_irq(const char *name, unsigned int irq_base, + void __iomem *reg_base) { - PIC0_IEN &= ~(1 << d->irq); - PIC0_CREQ |= (1 << d->irq); -} + struct irq_chip_generic *gc; + struct irq_chip_type *ct; -static void tcc8000_mask_ack_irq1(struct irq_data *d) -{ - PIC1_IEN &= ~(1 << (d->irq - 32)); - PIC1_CREQ |= (1 << (d->irq - 32)); -} + gc = irq_alloc_generic_chip(name, 1, irq_base, reg_base, + handle_level_irq); + ct = gc->chip_types; + 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->regs.ack = PIC0_CREQ_OFFS; + ct->regs.mask = PIC0_IEN_OFFS; -static void tcc8000_mask_irq0(struct irq_data *d) -{ - PIC0_IEN &= ~(1 << d->irq); + irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_NOREQUEST | IRQ_NOPROBE, + IRQ_LEVEL); } -static void tcc8000_mask_irq1(struct irq_data *d) -{ - PIC1_IEN &= ~(1 << (d->irq - 32)); -} - -static void tcc8000_ack_irq0(struct irq_data *d) -{ - PIC0_CREQ |= (1 << d->irq); -} - -static void tcc8000_ack_irq1(struct irq_data *d) -{ - PIC1_CREQ |= (1 << (d->irq - 32)); -} - -/* Enable IRQ */ -static void tcc8000_unmask_irq0(struct irq_data *d) -{ - PIC0_IEN |= (1 << d->irq); - PIC0_INTOEN |= (1 << d->irq); -} - -static void tcc8000_unmask_irq1(struct irq_data *d) -{ - PIC1_IEN |= (1 << (d->irq - 32)); - PIC1_INTOEN |= (1 << (d->irq - 32)); -} - -static struct irq_chip tcc8000_irq_chip0 = { - .name = "tcc_irq0", - .irq_mask = tcc8000_mask_irq0, - .irq_ack = tcc8000_ack_irq0, - .irq_mask_ack = tcc8000_mask_ack_irq0, - .irq_unmask = tcc8000_unmask_irq0, -}; - -static struct irq_chip tcc8000_irq_chip1 = { - .name = "tcc_irq1", - .irq_mask = tcc8000_mask_irq1, - .irq_ack = tcc8000_ack_irq1, - .irq_mask_ack = tcc8000_mask_ack_irq1, - .irq_unmask = tcc8000_unmask_irq1, -}; - void __init tcc8k_init_irq(void) { - int irqno; - /* Mask and clear all interrupts */ PIC0_IEN = 0x00000000; PIC0_CREQ = 0xffffffff; @@ -100,12 +55,6 @@ void __init tcc8k_init_irq(void) PIC0_IRQSEL = 0xffffffff; PIC1_IRQSEL = 0xffffffff; - for (irqno = 0; irqno < NR_IRQS; irqno++) { - if (irqno < 32) - irq_set_chip(irqno, &tcc8000_irq_chip0); - else - irq_set_chip(irqno, &tcc8000_irq_chip1); - irq_set_handler(irqno, handle_level_irq); - set_irq_flags(irqno, IRQF_VALID); - } + tcc8k_alloc_irq("tcc_irq0", 0, PIC0_BASE); + tcc8k_alloc_irq("tcc_irq1", 32, PIC1_BASE); }