Merge branch 'master' into gfs2
[pandora-kernel.git] / arch / sh / boards / renesas / hs7751rvoip / irq.c
1 /*
2  * linux/arch/sh/boards/renesas/hs7751rvoip/irq.c
3  *
4  * Copyright (C) 2000  Kazumoto Kojima
5  *
6  * Renesas Technology Sales HS7751RVoIP Support.
7  *
8  * Modified for HS7751RVoIP by
9  * Atom Create Engineering Co., Ltd. 2002.
10  * Lineo uSolutions, Inc. 2003.
11  */
12
13 #include <linux/init.h>
14 #include <linux/irq.h>
15 #include <asm/io.h>
16 #include <asm/irq.h>
17 #include <asm/hs7751rvoip/hs7751rvoip.h>
18
19 static int mask_pos[] = {8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7};
20
21 static void enable_hs7751rvoip_irq(unsigned int irq);
22 static void disable_hs7751rvoip_irq(unsigned int irq);
23
24 /* shutdown is same as "disable" */
25 #define shutdown_hs7751rvoip_irq disable_hs7751rvoip_irq
26
27 static void ack_hs7751rvoip_irq(unsigned int irq);
28 static void end_hs7751rvoip_irq(unsigned int irq);
29
30 static unsigned int startup_hs7751rvoip_irq(unsigned int irq)
31 {
32         enable_hs7751rvoip_irq(irq);
33         return 0; /* never anything pending */
34 }
35
36 static void disable_hs7751rvoip_irq(unsigned int irq)
37 {
38         unsigned short val;
39         unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
40
41         /* Set the priority in IPR to 0 */
42         val = ctrl_inw(IRLCNTR3);
43         val &= mask;
44         ctrl_outw(val, IRLCNTR3);
45 }
46
47 static void enable_hs7751rvoip_irq(unsigned int irq)
48 {
49         unsigned short val;
50         unsigned short value = (0x0001 << mask_pos[irq]);
51
52         /* Set priority in IPR back to original value */
53         val = ctrl_inw(IRLCNTR3);
54         val |= value;
55         ctrl_outw(val, IRLCNTR3);
56 }
57
58 static void ack_hs7751rvoip_irq(unsigned int irq)
59 {
60         disable_hs7751rvoip_irq(irq);
61 }
62
63 static void end_hs7751rvoip_irq(unsigned int irq)
64 {
65         if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
66                 enable_hs7751rvoip_irq(irq);
67 }
68
69 static struct hw_interrupt_type hs7751rvoip_irq_type = {
70         .typename =  "HS7751RVoIP IRQ",
71         .startup = startup_hs7751rvoip_irq,
72         .shutdown = shutdown_hs7751rvoip_irq,
73         .enable = enable_hs7751rvoip_irq,
74         .disable = disable_hs7751rvoip_irq,
75         .ack = ack_hs7751rvoip_irq,
76         .end = end_hs7751rvoip_irq,
77 };
78
79 static void make_hs7751rvoip_irq(unsigned int irq)
80 {
81         disable_irq_nosync(irq);
82         irq_desc[irq].chip = &hs7751rvoip_irq_type;
83         disable_hs7751rvoip_irq(irq);
84 }
85
86 /*
87  * Initialize IRQ setting
88  */
89 void __init init_hs7751rvoip_IRQ(void)
90 {
91         int i;
92
93         /* IRL0=ON HOOK1
94          * IRL1=OFF HOOK1
95          * IRL2=ON HOOK2
96          * IRL3=OFF HOOK2
97          * IRL4=Ringing Detection
98          * IRL5=CODEC
99          * IRL6=Ethernet
100          * IRL7=Ethernet Hub
101          * IRL8=USB Communication
102          * IRL9=USB Connection
103          * IRL10=USB DMA
104          * IRL11=CF Card
105          * IRL12=PCMCIA
106          * IRL13=PCI Slot
107          */
108         ctrl_outw(0x9876, IRLCNTR1);
109         ctrl_outw(0xdcba, IRLCNTR2);
110         ctrl_outw(0x0050, IRLCNTR4);
111         ctrl_outw(0x4321, IRLCNTR5);
112
113         for (i=0; i<14; i++)
114                 make_hs7751rvoip_irq(i);
115 }