blob: 7608c7a288cfbabf3f69ebc0ff7f43daaf41b017 [file] [log] [blame]
Vitaly Wool78818e42006-05-16 11:54:37 +01001/*
2 * arch/arm/mach-pnx4008/irq.c
3 *
4 * PNX4008 IRQ controller driver
5 *
6 * Author: Dmitry Chigirev <source@mvista.com>
7 *
8 * Based on reference code received from Philips:
9 * Copyright (C) 2003 Philips Semiconductors
10 *
11 * 2005 (c) MontaVista Software, Inc. This file is licensed under
12 * the terms of the GNU General Public License version 2. This program
13 * is licensed "as is" without any warranty of any kind, whether express
14 * or implied.
15 */
16
17#include <linux/kernel.h>
18#include <linux/types.h>
19#include <linux/mm.h>
20#include <linux/interrupt.h>
21#include <linux/list.h>
22#include <linux/init.h>
23#include <linux/ioport.h>
24#include <linux/device.h>
Vitaly Wool5904a7f2006-07-05 14:47:20 +010025#include <linux/irq.h>
Russell Kingfced80c2008-09-06 12:10:45 +010026#include <linux/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
Vitaly Wool78818e42006-05-16 11:54:37 +010028#include <asm/setup.h>
Vitaly Wool78818e42006-05-16 11:54:37 +010029#include <asm/pgtable.h>
30#include <asm/page.h>
31#include <asm/system.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/irq.h>
34#include <asm/mach/map.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/irq.h>
Vitaly Wool78818e42006-05-16 11:54:37 +010036
37static u8 pnx4008_irq_type[NR_IRQS] = PNX4008_IRQ_TYPES;
38
Lennert Buytenhek406b0052010-11-29 10:40:16 +010039static void pnx4008_mask_irq(struct irq_data *d)
Vitaly Wool78818e42006-05-16 11:54:37 +010040{
Lennert Buytenhek406b0052010-11-29 10:40:16 +010041 __raw_writel(__raw_readl(INTC_ER(d->irq)) & ~INTC_BIT(d->irq), INTC_ER(d->irq)); /* mask interrupt */
Vitaly Wool78818e42006-05-16 11:54:37 +010042}
43
Lennert Buytenhek406b0052010-11-29 10:40:16 +010044static void pnx4008_unmask_irq(struct irq_data *d)
Vitaly Wool78818e42006-05-16 11:54:37 +010045{
Lennert Buytenhek406b0052010-11-29 10:40:16 +010046 __raw_writel(__raw_readl(INTC_ER(d->irq)) | INTC_BIT(d->irq), INTC_ER(d->irq)); /* unmask interrupt */
Vitaly Wool78818e42006-05-16 11:54:37 +010047}
48
Lennert Buytenhek406b0052010-11-29 10:40:16 +010049static void pnx4008_mask_ack_irq(struct irq_data *d)
Vitaly Wool78818e42006-05-16 11:54:37 +010050{
Lennert Buytenhek406b0052010-11-29 10:40:16 +010051 __raw_writel(__raw_readl(INTC_ER(d->irq)) & ~INTC_BIT(d->irq), INTC_ER(d->irq)); /* mask interrupt */
52 __raw_writel(INTC_BIT(d->irq), INTC_SR(d->irq)); /* clear interrupt status */
Vitaly Wool78818e42006-05-16 11:54:37 +010053}
54
Lennert Buytenhek406b0052010-11-29 10:40:16 +010055static int pnx4008_set_irq_type(struct irq_data *d, unsigned int type)
Vitaly Wool78818e42006-05-16 11:54:37 +010056{
57 switch (type) {
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010058 case IRQ_TYPE_EDGE_RISING:
Lennert Buytenhek406b0052010-11-29 10:40:16 +010059 __raw_writel(__raw_readl(INTC_ATR(d->irq)) | INTC_BIT(d->irq), INTC_ATR(d->irq)); /*edge sensitive */
60 __raw_writel(__raw_readl(INTC_APR(d->irq)) | INTC_BIT(d->irq), INTC_APR(d->irq)); /*rising edge */
Thomas Gleixner6845664a2011-03-24 13:25:22 +010061 irq_set_handler(d->irq, handle_edge_irq);
Vitaly Wool78818e42006-05-16 11:54:37 +010062 break;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010063 case IRQ_TYPE_EDGE_FALLING:
Lennert Buytenhek406b0052010-11-29 10:40:16 +010064 __raw_writel(__raw_readl(INTC_ATR(d->irq)) | INTC_BIT(d->irq), INTC_ATR(d->irq)); /*edge sensitive */
65 __raw_writel(__raw_readl(INTC_APR(d->irq)) & ~INTC_BIT(d->irq), INTC_APR(d->irq)); /*falling edge */
Thomas Gleixner6845664a2011-03-24 13:25:22 +010066 irq_set_handler(d->irq, handle_edge_irq);
Vitaly Wool78818e42006-05-16 11:54:37 +010067 break;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010068 case IRQ_TYPE_LEVEL_LOW:
Lennert Buytenhek406b0052010-11-29 10:40:16 +010069 __raw_writel(__raw_readl(INTC_ATR(d->irq)) & ~INTC_BIT(d->irq), INTC_ATR(d->irq)); /*level sensitive */
70 __raw_writel(__raw_readl(INTC_APR(d->irq)) & ~INTC_BIT(d->irq), INTC_APR(d->irq)); /*low level */
Thomas Gleixner6845664a2011-03-24 13:25:22 +010071 irq_set_handler(d->irq, handle_level_irq);
Vitaly Wool78818e42006-05-16 11:54:37 +010072 break;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010073 case IRQ_TYPE_LEVEL_HIGH:
Lennert Buytenhek406b0052010-11-29 10:40:16 +010074 __raw_writel(__raw_readl(INTC_ATR(d->irq)) & ~INTC_BIT(d->irq), INTC_ATR(d->irq)); /*level sensitive */
75 __raw_writel(__raw_readl(INTC_APR(d->irq)) | INTC_BIT(d->irq), INTC_APR(d->irq)); /* high level */
Thomas Gleixner6845664a2011-03-24 13:25:22 +010076 irq_set_handler(d->irq, handle_level_irq);
Vitaly Wool78818e42006-05-16 11:54:37 +010077 break;
78
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010079 /* IRQ_TYPE_EDGE_BOTH is not supported */
Vitaly Wool78818e42006-05-16 11:54:37 +010080 default:
81 printk(KERN_ERR "PNX4008 IRQ: Unsupported irq type %d\n", type);
82 return -1;
83 }
84 return 0;
85}
86
Russell King10dd5ce2006-11-23 11:41:32 +000087static struct irq_chip pnx4008_irq_chip = {
Lennert Buytenhek406b0052010-11-29 10:40:16 +010088 .irq_ack = pnx4008_mask_ack_irq,
89 .irq_mask = pnx4008_mask_irq,
90 .irq_unmask = pnx4008_unmask_irq,
91 .irq_set_type = pnx4008_set_irq_type,
Vitaly Wool78818e42006-05-16 11:54:37 +010092};
93
94void __init pnx4008_init_irq(void)
95{
96 unsigned int i;
97
Vitaly Wool5904a7f2006-07-05 14:47:20 +010098 /* configure IRQ's */
99 for (i = 0; i < NR_IRQS; i++) {
100 set_irq_flags(i, IRQF_VALID);
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100101 irq_set_chip(i, &pnx4008_irq_chip);
Lennert Buytenhek406b0052010-11-29 10:40:16 +0100102 pnx4008_set_irq_type(irq_get_irq_data(i), pnx4008_irq_type[i]);
Vitaly Wool5904a7f2006-07-05 14:47:20 +0100103 }
104
105 /* configure and enable IRQ 0,1,30,31 (cascade interrupts) */
Lennert Buytenhek406b0052010-11-29 10:40:16 +0100106 pnx4008_set_irq_type(irq_get_irq_data(SUB1_IRQ_N),
107 pnx4008_irq_type[SUB1_IRQ_N]);
108 pnx4008_set_irq_type(irq_get_irq_data(SUB2_IRQ_N),
109 pnx4008_irq_type[SUB2_IRQ_N]);
110 pnx4008_set_irq_type(irq_get_irq_data(SUB1_FIQ_N),
111 pnx4008_irq_type[SUB1_FIQ_N]);
112 pnx4008_set_irq_type(irq_get_irq_data(SUB2_FIQ_N),
113 pnx4008_irq_type[SUB2_FIQ_N]);
Vitaly Wool78818e42006-05-16 11:54:37 +0100114
Vitaly Wool5904a7f2006-07-05 14:47:20 +0100115 /* mask all others */
Vitaly Wool78818e42006-05-16 11:54:37 +0100116 __raw_writel((1 << SUB2_FIQ_N) | (1 << SUB1_FIQ_N) |
117 (1 << SUB2_IRQ_N) | (1 << SUB1_IRQ_N),
118 INTC_ER(MAIN_BASE_INT));
119 __raw_writel(0, INTC_ER(SIC1_BASE_INT));
120 __raw_writel(0, INTC_ER(SIC2_BASE_INT));
Vitaly Wool78818e42006-05-16 11:54:37 +0100121}
122