Pull video into test branch
[linux-drm-fsl-dcu.git] / arch / sh / boards / se / 73180 / irq.c
1 /*
2  * arch/sh/boards/se/73180/irq.c
3  *
4  * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5  * Based on arch/sh/boards/se/7300/irq.c
6  *
7  * Modified for SH-Mobile SolutionEngine 73180 Support
8  *              by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
9  *
10  */
11
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <asm/irq.h>
15 #include <asm/io.h>
16 #include <asm/mach/se73180.h>
17
18 static int
19 irq2intreq(int irq)
20 {
21         if (irq == 10)
22                 return 5;
23         return 7 - (irq - 32);
24 }
25
26 static void
27 disable_intreq_irq(unsigned int irq)
28 {
29         ctrl_outb(1 << (7 - irq2intreq(irq)), INTMSK0);
30 }
31
32 static void
33 enable_intreq_irq(unsigned int irq)
34 {
35         ctrl_outb(1 << (7 - irq2intreq(irq)), INTMSKCLR0);
36 }
37
38 static void
39 mask_and_ack_intreq_irq(unsigned int irq)
40 {
41         disable_intreq_irq(irq);
42 }
43
44 static unsigned int
45 startup_intreq_irq(unsigned int irq)
46 {
47         enable_intreq_irq(irq);
48         return 0;
49 }
50
51 static void
52 shutdown_intreq_irq(unsigned int irq)
53 {
54         disable_intreq_irq(irq);
55 }
56
57 static void
58 end_intreq_irq(unsigned int irq)
59 {
60         if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
61                 enable_intreq_irq(irq);
62 }
63
64 static struct hw_interrupt_type intreq_irq_type = {
65         .typename = "intreq",
66         .startup = startup_intreq_irq,
67         .shutdown = shutdown_intreq_irq,
68         .enable = enable_intreq_irq,
69         .disable = disable_intreq_irq,
70         .ack = mask_and_ack_intreq_irq,
71         .end = end_intreq_irq
72 };
73
74 void
75 make_intreq_irq(unsigned int irq)
76 {
77         disable_irq_nosync(irq);
78         irq_desc[irq].chip = &intreq_irq_type;
79         disable_intreq_irq(irq);
80 }
81
82 int
83 shmse_irq_demux(int irq)
84 {
85         if (irq == IRQ5_IRQ)
86                 return 10;
87         return irq;
88 }
89
90 static struct ipr_data se73180_siof0_ipr_map[] = {
91         { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
92 };
93 static struct ipr_data se73180_vpu_ipr_map[] = {
94         { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
95 };
96 static struct ipr_data se73180_other_ipr_map[] = {
97         { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
98         { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
99         { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
100         { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
101         { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
102         { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
103         { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
104         { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
105         { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
106
107         /* VIO interrupt */
108         { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
109         { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
110         { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
111
112         { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
113 };
114
115 /*
116  * Initialize IRQ setting
117  */
118 void __init
119 init_73180se_IRQ(void)
120 {
121         make_ipr_irq(se73180_siof0_ipr_map, ARRAY_SIZE(se73180_siof0_ipr_map));
122
123         ctrl_outw(0x2000, 0xb03fffec);  /* mrshpc irq enable */
124         ctrl_outw(0x2000, 0xb07fffec);  /* mrshpc irq enable */
125         ctrl_outl(3 << ((7 - 5) * 4), INTC_INTPRI0);    /* irq5 pri=3 */
126         ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1);       /* low-level irq */
127         make_intreq_irq(10);
128
129         make_ipr_irq(se73180_vpu_ipr_map, ARRAY_SIZE(se73180_vpu_ipr_map));
130
131         ctrl_outb(0x0f, INTC_IMCR5);    /* enable SCIF IRQ */
132
133         make_ipr_irq(se73180_other_ipr_map, ARRAY_SIZE(se73180_other_ipr_map));
134
135         ctrl_outw(0x2000, PA_MRSHPC + 0x0c);    /* mrshpc irq enable */
136 }