aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-10-21 09:07:05 -0400
committerBen Dooks <ben-linux@fluff.org>2008-12-15 18:02:58 -0500
commit3e694d4bc633a5e6192e63a644a628e7bbab3e64 (patch)
tree53b96aa832850b1e9227feb555d773c4ce116689 /arch
parentb73c289cc90138e9f78d487434df0f8eeb2daf9b (diff)
[ARM] S3C64XX: Demux UART interrupts
Add demux handling for the UART interrupts generated by the VIC into their seperate IRQs that the serial driver can register. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-s3c6400/include/mach/map.h8
-rw-r--r--arch/arm/plat-s3c64xx/irq.c140
2 files changed, 147 insertions, 1 deletions
diff --git a/arch/arm/mach-s3c6400/include/mach/map.h b/arch/arm/mach-s3c6400/include/mach/map.h
index de6cdd518cea..83ed3c158693 100644
--- a/arch/arm/mach-s3c6400/include/mach/map.h
+++ b/arch/arm/mach-s3c6400/include/mach/map.h
@@ -24,6 +24,14 @@
24#define S3C_PA_UART3 (S3C_PA_UART + 0xC00) 24#define S3C_PA_UART3 (S3C_PA_UART + 0xC00)
25#define S3C_UART_OFFSET (0x400) 25#define S3C_UART_OFFSET (0x400)
26 26
27/* See notes on UART VA mapping in debug-macro.S */
28#define S3C_VA_UARTx(x) (S3C_VA_UART + (S3C_PA_UART & 0xfffff) + ((x) * S3C_UART_OFFSET))
29
30#define S3C_VA_UART0 S3C_VA_UARTx(0)
31#define S3C_VA_UART1 S3C_VA_UARTx(1)
32#define S3C_VA_UART2 S3C_VA_UARTx(2)
33#define S3C_VA_UART3 S3C_VA_UARTx(3)
34
27#define S3C64XX_PA_SYSCON (0x7E00F000) 35#define S3C64XX_PA_SYSCON (0x7E00F000)
28#define S3C64XX_PA_TIMER (0x7F006000) 36#define S3C64XX_PA_TIMER (0x7F006000)
29 37
diff --git a/arch/arm/plat-s3c64xx/irq.c b/arch/arm/plat-s3c64xx/irq.c
index 1e6fa5c828c9..99df9dbefa69 100644
--- a/arch/arm/plat-s3c64xx/irq.c
+++ b/arch/arm/plat-s3c64xx/irq.c
@@ -91,9 +91,144 @@ static struct irq_chip s3c_irq_timer = {
91 .ack = s3c_irq_timer_ack, 91 .ack = s3c_irq_timer_ack,
92}; 92};
93 93
94struct uart_irq {
95 void __iomem *regs;
96 unsigned int base_irq;
97 unsigned int parent_irq;
98};
99
100/* Note, we make use of the fact that the parent IRQs, IRQ_UART[0..3]
101 * are consecutive when looking up the interrupt in the demux routines.
102 */
103static struct uart_irq uart_irqs[] = {
104 [0] = {
105 .regs = S3C_VA_UART0,
106 .base_irq = IRQ_S3CUART_BASE0,
107 .parent_irq = IRQ_UART0,
108 },
109 [1] = {
110 .regs = S3C_VA_UART1,
111 .base_irq = IRQ_S3CUART_BASE1,
112 .parent_irq = IRQ_UART1,
113 },
114 [2] = {
115 .regs = S3C_VA_UART2,
116 .base_irq = IRQ_S3CUART_BASE2,
117 .parent_irq = IRQ_UART2,
118 },
119 [3] = {
120 .regs = S3C_VA_UART3,
121 .base_irq = IRQ_S3CUART_BASE3,
122 .parent_irq = IRQ_UART3,
123 },
124};
125
126static inline void __iomem *s3c_irq_uart_base(unsigned int irq)
127{
128 struct uart_irq *uirq = get_irq_chip_data(irq);
129 return uirq->regs;
130}
131
132static inline unsigned int s3c_irq_uart_bit(unsigned int irq)
133{
134 return irq & 3;
135}
136
137/* UART interrupt registers, not worth adding to seperate include header */
138#define S3C64XX_UINTP 0x30
139#define S3C64XX_UINTSP 0x34
140#define S3C64XX_UINTM 0x38
141
142static void s3c_irq_uart_mask(unsigned int irq)
143{
144 void __iomem *regs = s3c_irq_uart_base(irq);
145 unsigned int bit = s3c_irq_uart_bit(irq);
146 u32 reg;
147
148 reg = __raw_readl(regs + S3C64XX_UINTM);
149 reg |= (1 << bit);
150 __raw_writel(reg, regs + S3C64XX_UINTM);
151}
152
153static void s3c_irq_uart_maskack(unsigned int irq)
154{
155 void __iomem *regs = s3c_irq_uart_base(irq);
156 unsigned int bit = s3c_irq_uart_bit(irq);
157 u32 reg;
158
159 reg = __raw_readl(regs + S3C64XX_UINTM);
160 reg |= (1 << bit);
161 __raw_writel(reg, regs + S3C64XX_UINTM);
162 __raw_writel(1 << bit, regs + S3C64XX_UINTP);
163}
164
165static void s3c_irq_uart_unmask(unsigned int irq)
166{
167 void __iomem *regs = s3c_irq_uart_base(irq);
168 unsigned int bit = s3c_irq_uart_bit(irq);
169 u32 reg;
170
171 reg = __raw_readl(regs + S3C64XX_UINTM);
172 reg &= ~(1 << bit);
173 __raw_writel(reg, regs + S3C64XX_UINTM);
174}
175
176static void s3c_irq_uart_ack(unsigned int irq)
177{
178 void __iomem *regs = s3c_irq_uart_base(irq);
179 unsigned int bit = s3c_irq_uart_bit(irq);
180
181 __raw_writel(1 << bit, regs + S3C64XX_UINTP);
182}
183
184static void s3c_irq_demux_uart(unsigned int irq, struct irq_desc *desc)
185{
186 struct uart_irq *uirq = &uart_irqs[irq - IRQ_UART0];
187 u32 pend = __raw_readl(uirq->regs + S3C64XX_UINTP);
188 int base = uirq->base_irq;
189
190 if (pend & (1 << 0))
191 generic_handle_irq(base);
192 if (pend & (1 << 1))
193 generic_handle_irq(base + 1);
194 if (pend & (1 << 2))
195 generic_handle_irq(base + 2);
196 if (pend & (1 << 3))
197 generic_handle_irq(base + 3);
198}
199
200static struct irq_chip s3c_irq_uart = {
201 .name = "s3c-uart",
202 .mask = s3c_irq_uart_mask,
203 .unmask = s3c_irq_uart_unmask,
204 .mask_ack = s3c_irq_uart_maskack,
205 .ack = s3c_irq_uart_ack,
206};
207
208static void __init s3c64xx_uart_irq(struct uart_irq *uirq)
209{
210 void *reg_base = uirq->regs;
211 unsigned int irq;
212 int offs;
213
214 /* mask all interrupts at the start. */
215 __raw_writel(0xf, reg_base + S3C64XX_UINTM);
216
217 for (offs = 0; offs < 3; offs++) {
218 irq = uirq->base_irq + offs;
219
220 set_irq_chip(irq, &s3c_irq_uart);
221 set_irq_chip_data(irq, uirq);
222 set_irq_handler(irq, handle_level_irq);
223 set_irq_flags(irq, IRQF_VALID);
224 }
225
226 set_irq_chained_handler(uirq->parent_irq, s3c_irq_demux_uart);
227}
228
94void __init s3c64xx_init_irq(u32 vic0_valid, u32 vic1_valid) 229void __init s3c64xx_init_irq(u32 vic0_valid, u32 vic1_valid)
95{ 230{
96 int irq; 231 int uart, irq;
97 232
98 printk(KERN_INFO "%s: initialising interrupts\n", __func__); 233 printk(KERN_INFO "%s: initialising interrupts\n", __func__);
99 234
@@ -114,6 +249,9 @@ void __init s3c64xx_init_irq(u32 vic0_valid, u32 vic1_valid)
114 set_irq_handler(irq, handle_level_irq); 249 set_irq_handler(irq, handle_level_irq);
115 set_irq_flags(irq, IRQF_VALID); 250 set_irq_flags(irq, IRQF_VALID);
116 } 251 }
252
253 for (uart = 0; uart < ARRAY_SIZE(uart_irqs); uart++)
254 s3c64xx_uart_irq(&uart_irqs[uart]);
117} 255}
118 256
119 257