2006-05-16 10:54:37 +00:00
|
|
|
/*
|
|
|
|
* arch/arm/mach-pnx4008/irq.c
|
|
|
|
*
|
|
|
|
* PNX4008 IRQ controller driver
|
|
|
|
*
|
|
|
|
* Author: Dmitry Chigirev <source@mvista.com>
|
|
|
|
*
|
|
|
|
* Based on reference code received from Philips:
|
|
|
|
* Copyright (C) 2003 Philips Semiconductors
|
|
|
|
*
|
|
|
|
* 2005 (c) MontaVista Software, Inc. This file is licensed under
|
|
|
|
* the terms of the GNU General Public License version 2. This program
|
|
|
|
* is licensed "as is" without any warranty of any kind, whether express
|
|
|
|
* or implied.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/device.h>
|
2006-07-05 13:47:20 +00:00
|
|
|
#include <linux/irq.h>
|
2008-09-06 11:10:45 +00:00
|
|
|
#include <linux/io.h>
|
2008-08-05 15:14:15 +00:00
|
|
|
#include <mach/hardware.h>
|
2006-05-16 10:54:37 +00:00
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
#include <asm/mach/map.h>
|
2008-08-05 15:14:15 +00:00
|
|
|
#include <mach/irq.h>
|
2006-05-16 10:54:37 +00:00
|
|
|
|
|
|
|
static u8 pnx4008_irq_type[NR_IRQS] = PNX4008_IRQ_TYPES;
|
|
|
|
|
2010-11-29 09:40:16 +00:00
|
|
|
static void pnx4008_mask_irq(struct irq_data *d)
|
2006-05-16 10:54:37 +00:00
|
|
|
{
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ER(d->irq)) & ~INTC_BIT(d->irq), INTC_ER(d->irq)); /* mask interrupt */
|
2006-05-16 10:54:37 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 09:40:16 +00:00
|
|
|
static void pnx4008_unmask_irq(struct irq_data *d)
|
2006-05-16 10:54:37 +00:00
|
|
|
{
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ER(d->irq)) | INTC_BIT(d->irq), INTC_ER(d->irq)); /* unmask interrupt */
|
2006-05-16 10:54:37 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 09:40:16 +00:00
|
|
|
static void pnx4008_mask_ack_irq(struct irq_data *d)
|
2006-05-16 10:54:37 +00:00
|
|
|
{
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ER(d->irq)) & ~INTC_BIT(d->irq), INTC_ER(d->irq)); /* mask interrupt */
|
|
|
|
__raw_writel(INTC_BIT(d->irq), INTC_SR(d->irq)); /* clear interrupt status */
|
2006-05-16 10:54:37 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 09:40:16 +00:00
|
|
|
static int pnx4008_set_irq_type(struct irq_data *d, unsigned int type)
|
2006-05-16 10:54:37 +00:00
|
|
|
{
|
|
|
|
switch (type) {
|
2008-07-27 03:23:31 +00:00
|
|
|
case IRQ_TYPE_EDGE_RISING:
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ATR(d->irq)) | INTC_BIT(d->irq), INTC_ATR(d->irq)); /*edge sensitive */
|
|
|
|
__raw_writel(__raw_readl(INTC_APR(d->irq)) | INTC_BIT(d->irq), INTC_APR(d->irq)); /*rising edge */
|
2011-03-24 12:25:22 +00:00
|
|
|
irq_set_handler(d->irq, handle_edge_irq);
|
2006-05-16 10:54:37 +00:00
|
|
|
break;
|
2008-07-27 03:23:31 +00:00
|
|
|
case IRQ_TYPE_EDGE_FALLING:
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ATR(d->irq)) | INTC_BIT(d->irq), INTC_ATR(d->irq)); /*edge sensitive */
|
|
|
|
__raw_writel(__raw_readl(INTC_APR(d->irq)) & ~INTC_BIT(d->irq), INTC_APR(d->irq)); /*falling edge */
|
2011-03-24 12:25:22 +00:00
|
|
|
irq_set_handler(d->irq, handle_edge_irq);
|
2006-05-16 10:54:37 +00:00
|
|
|
break;
|
2008-07-27 03:23:31 +00:00
|
|
|
case IRQ_TYPE_LEVEL_LOW:
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ATR(d->irq)) & ~INTC_BIT(d->irq), INTC_ATR(d->irq)); /*level sensitive */
|
|
|
|
__raw_writel(__raw_readl(INTC_APR(d->irq)) & ~INTC_BIT(d->irq), INTC_APR(d->irq)); /*low level */
|
2011-03-24 12:25:22 +00:00
|
|
|
irq_set_handler(d->irq, handle_level_irq);
|
2006-05-16 10:54:37 +00:00
|
|
|
break;
|
2008-07-27 03:23:31 +00:00
|
|
|
case IRQ_TYPE_LEVEL_HIGH:
|
2010-11-29 09:40:16 +00:00
|
|
|
__raw_writel(__raw_readl(INTC_ATR(d->irq)) & ~INTC_BIT(d->irq), INTC_ATR(d->irq)); /*level sensitive */
|
|
|
|
__raw_writel(__raw_readl(INTC_APR(d->irq)) | INTC_BIT(d->irq), INTC_APR(d->irq)); /* high level */
|
2011-03-24 12:25:22 +00:00
|
|
|
irq_set_handler(d->irq, handle_level_irq);
|
2006-05-16 10:54:37 +00:00
|
|
|
break;
|
|
|
|
|
2008-07-27 03:23:31 +00:00
|
|
|
/* IRQ_TYPE_EDGE_BOTH is not supported */
|
2006-05-16 10:54:37 +00:00
|
|
|
default:
|
|
|
|
printk(KERN_ERR "PNX4008 IRQ: Unsupported irq type %d\n", type);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-11-23 11:41:32 +00:00
|
|
|
static struct irq_chip pnx4008_irq_chip = {
|
2010-11-29 09:40:16 +00:00
|
|
|
.irq_ack = pnx4008_mask_ack_irq,
|
|
|
|
.irq_mask = pnx4008_mask_irq,
|
|
|
|
.irq_unmask = pnx4008_unmask_irq,
|
|
|
|
.irq_set_type = pnx4008_set_irq_type,
|
2006-05-16 10:54:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void __init pnx4008_init_irq(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2006-07-05 13:47:20 +00:00
|
|
|
/* configure IRQ's */
|
|
|
|
for (i = 0; i < NR_IRQS; i++) {
|
|
|
|
set_irq_flags(i, IRQF_VALID);
|
2011-03-24 12:25:22 +00:00
|
|
|
irq_set_chip(i, &pnx4008_irq_chip);
|
2010-11-29 09:40:16 +00:00
|
|
|
pnx4008_set_irq_type(irq_get_irq_data(i), pnx4008_irq_type[i]);
|
2006-07-05 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* configure and enable IRQ 0,1,30,31 (cascade interrupts) */
|
2010-11-29 09:40:16 +00:00
|
|
|
pnx4008_set_irq_type(irq_get_irq_data(SUB1_IRQ_N),
|
|
|
|
pnx4008_irq_type[SUB1_IRQ_N]);
|
|
|
|
pnx4008_set_irq_type(irq_get_irq_data(SUB2_IRQ_N),
|
|
|
|
pnx4008_irq_type[SUB2_IRQ_N]);
|
|
|
|
pnx4008_set_irq_type(irq_get_irq_data(SUB1_FIQ_N),
|
|
|
|
pnx4008_irq_type[SUB1_FIQ_N]);
|
|
|
|
pnx4008_set_irq_type(irq_get_irq_data(SUB2_FIQ_N),
|
|
|
|
pnx4008_irq_type[SUB2_FIQ_N]);
|
2006-05-16 10:54:37 +00:00
|
|
|
|
2006-07-05 13:47:20 +00:00
|
|
|
/* mask all others */
|
2006-05-16 10:54:37 +00:00
|
|
|
__raw_writel((1 << SUB2_FIQ_N) | (1 << SUB1_FIQ_N) |
|
|
|
|
(1 << SUB2_IRQ_N) | (1 << SUB1_IRQ_N),
|
|
|
|
INTC_ER(MAIN_BASE_INT));
|
|
|
|
__raw_writel(0, INTC_ER(SIC1_BASE_INT));
|
|
|
|
__raw_writel(0, INTC_ER(SIC2_BASE_INT));
|
|
|
|
}
|
|
|
|
|