ARM9260内部中断和外部中断触发方式

1.内部中断(0~31) 
  内部中断可以有4中触发方式
 static struct irq_chip at91_aic_chip = {
         	.name           = "AIC",
         	.irq_ack        = at91_aic_mask_irq,
         	.irq_mask       = at91_aic_mask_irq,
         	.irq_unmask     = at91_aic_unmask_irq,
         	.irq_set_type   = at91_aic_set_type,
         	.irq_set_wake   = at91_aic_set_wake,
 };

 static int at91_aic_set_type(struct irq_data *d, unsigned type)
 {
        	unsigned int smr, srctype;
 
         	switch (type) {
        	case IRQ_TYPE_LEVEL_HIGH:
                 	 srctype = AT91_AIC_SRCTYPE_HIGH;
                 	 break;
         	case IRQ_TYPE_EDGE_RISING:
                 	 srctype = AT91_AIC_SRCTYPE_RISING;
                 	 break;
          case IRQ_TYPE_LEVEL_LOW:
                 	 if ((d->irq == AT91_ID_FIQ) || is_extern_irq(d->irq))           /* only supported on external interrupts */
                         	 srctype = AT91_AIC_SRCTYPE_LOW;
                 	 else
                         	 return -EINVAL;
                 	 break;
         	case IRQ_TYPE_EDGE_FALLING:
                 	 if ((d->irq == AT91_ID_FIQ) || is_extern_irq(d->irq))           /* only supported on external interrupts */
                         	 srctype = AT91_AIC_SRCTYPE_FALLING;
                 	 else
                         	 return -EINVAL;
                 	 break;
         	default:
                 	 return -EINVAL;
         	}
 
         	smr = at91_aic_read(AT91_AIC_SMR(d->irq)) & ~AT91_AIC_SRCTYPE;
         	at91_aic_write(AT91_AIC_SMR(d->irq), smr | srctype);
         	return 0;
 }
 
 
 
 
2.外部中断(32~224)
 外部中断有2种触发方式
 static struct irq_chip gpio_irqchip = {
         	.name           = "GPIO",
         	.irq_disable    = gpio_irq_mask,
        	.irq_mask       = gpio_irq_mask,
        	.irq_unmask     = gpio_irq_unmask,
         	.irq_set_type   = gpio_irq_type,
         	.irq_set_wake   = gpio_irq_set_wake,
 };
 static int gpio_irq_type(struct irq_data *d, unsigned type)
 {
         	switch (type) {
         	case IRQ_TYPE_NONE:
         	case IRQ_TYPE_EDGE_BOTH:
                	 return 0;
         	default:
                	 return -EINVAL;
         	}
 }
 


你可能感兴趣的:(struct)