1 /* -------------------------------------------------------------------- */
2 /* setup_voyagergx.c: */
3 /* -------------------------------------------------------------------- */
4 /* This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 Copyright 2003 (c) Lineo uSolutions,Inc.
20 /* -------------------------------------------------------------------- */
24 #include <linux/sched.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/param.h>
28 #include <linux/ioport.h>
29 #include <linux/interrupt.h>
30 #include <linux/init.h>
31 #include <linux/irq.h>
35 #include <asm/rts7751r2d/rts7751r2d.h>
36 #include <asm/rts7751r2d/voyagergx_reg.h>
38 static void disable_voyagergx_irq(unsigned int irq)
40 unsigned long flags, val;
41 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
43 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask);
44 local_irq_save(flags);
45 val = inl(VOYAGER_INT_MASK);
47 outl(val, VOYAGER_INT_MASK);
48 local_irq_restore(flags);
52 static void enable_voyagergx_irq(unsigned int irq)
54 unsigned long flags, val;
55 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
57 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask);
58 local_irq_save(flags);
59 val = inl(VOYAGER_INT_MASK);
61 outl(val, VOYAGER_INT_MASK);
62 local_irq_restore(flags);
66 static void mask_and_ack_voyagergx(unsigned int irq)
68 disable_voyagergx_irq(irq);
71 static void end_voyagergx_irq(unsigned int irq)
73 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
74 enable_voyagergx_irq(irq);
77 static unsigned int startup_voyagergx_irq(unsigned int irq)
79 enable_voyagergx_irq(irq);
83 static void shutdown_voyagergx_irq(unsigned int irq)
85 disable_voyagergx_irq(irq);
88 static struct hw_interrupt_type voyagergx_irq_type = {
89 .typename = "VOYAGERGX-IRQ",
90 .startup = startup_voyagergx_irq,
91 .shutdown = shutdown_voyagergx_irq,
92 .enable = enable_voyagergx_irq,
93 .disable = disable_voyagergx_irq,
94 .ack = mask_and_ack_voyagergx,
95 .end = end_voyagergx_irq,
98 static irqreturn_t voyagergx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
101 "VoyagerGX: spurious interrupt, status: 0x%x\n",
107 /*====================================================*/
110 int (*func)(int, void *);
112 } voyagergx_demux[VOYAGER_IRQ_NUM];
114 void voyagergx_register_irq_demux(int irq,
115 int (*demux)(int irq, void *dev), void *dev)
117 voyagergx_demux[irq - VOYAGER_IRQ_BASE].func = demux;
118 voyagergx_demux[irq - VOYAGER_IRQ_BASE].dev = dev;
121 void voyagergx_unregister_irq_demux(int irq)
123 voyagergx_demux[irq - VOYAGER_IRQ_BASE].func = 0;
126 int voyagergx_irq_demux(int irq)
129 if (irq == IRQ_VOYAGER ) {
130 unsigned long i = 0, bit __attribute__ ((unused));
131 unsigned long val = inl(INT_STATUS);
133 if ( val & ( 1 << 1 )){
135 } else if ( val & ( 1 << 2 )){
137 } else if ( val & ( 1 << 6 )){
139 } else if( val & ( 1 << 10 )){
141 } else if( val & ( 1 << 11 )){
143 } else if( val & ( 1 << 12 )){
145 } else if( val & ( 1 << 17 )){
148 printk("Unexpected IRQ irq = %d status = 0x%08lx\n", irq, val);
150 pr_debug("voyagergx_irq_demux %d \n", i);
152 for (bit = 1, i = 0 ; i < VOYAGER_IRQ_NUM ; bit <<= 1, i++)
156 if (i < VOYAGER_IRQ_NUM) {
157 irq = VOYAGER_IRQ_BASE + i;
158 if (voyagergx_demux[i].func != 0)
159 irq = voyagergx_demux[i].func(irq, voyagergx_demux[i].dev);
165 static struct irqaction irq0 = {
167 .handler = voyagergx_interrupt,
168 .flags = IRQF_DISABLED,
169 .mask = CPU_MASK_NONE,
172 void __init setup_voyagergx_irq(void)
176 printk(KERN_INFO "VoyagerGX configured at 0x%x on irq %d(mapped into %d to %d)\n",
180 VOYAGER_IRQ_BASE + VOYAGER_IRQ_NUM - 1);
182 for (i=0; i<VOYAGER_IRQ_NUM; i++) {
184 switch (VOYAGER_IRQ_BASE + i) {
185 case VOYAGER_USBH_IRQ:
186 case VOYAGER_8051_IRQ:
187 case VOYAGER_UART0_IRQ:
188 case VOYAGER_UART1_IRQ:
189 case VOYAGER_AC97_IRQ:
193 irq_desc[VOYAGER_IRQ_BASE + i].chip = &voyagergx_irq_type;
196 setup_irq(IRQ_VOYAGER, &irq0);