1 /* arch/arm/plat-samsung/irq-uart.c
2 * originally part of arch/arm/plat-s3c64xx/irq.c
4 * Copyright 2008 Openmoko, Inc.
5 * Copyright 2008 Simtec Electronics
6 * Ben Dooks <ben@simtec.co.uk>
7 * http://armlinux.simtec.co.uk/
9 * Samsung- UART Interrupt handling
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/interrupt.h>
18 #include <linux/serial_core.h>
19 #include <linux/irq.h>
23 #include <plat/irq-uart.h>
24 #include <plat/regs-serial.h>
27 /* Note, we make use of the fact that the parent IRQs, IRQ_UART[0..3]
28 * are consecutive when looking up the interrupt in the demux routines.
31 static inline void __iomem *s3c_irq_uart_base(unsigned int irq)
33 struct s3c_uart_irq *uirq = get_irq_chip_data(irq);
37 static inline unsigned int s3c_irq_uart_bit(unsigned int irq)
42 static void s3c_irq_uart_mask(unsigned int irq)
44 void __iomem *regs = s3c_irq_uart_base(irq);
45 unsigned int bit = s3c_irq_uart_bit(irq);
48 reg = __raw_readl(regs + S3C64XX_UINTM);
50 __raw_writel(reg, regs + S3C64XX_UINTM);
53 static void s3c_irq_uart_maskack(unsigned int irq)
55 void __iomem *regs = s3c_irq_uart_base(irq);
56 unsigned int bit = s3c_irq_uart_bit(irq);
59 reg = __raw_readl(regs + S3C64XX_UINTM);
61 __raw_writel(reg, regs + S3C64XX_UINTM);
62 __raw_writel(1 << bit, regs + S3C64XX_UINTP);
65 static void s3c_irq_uart_unmask(unsigned int irq)
67 void __iomem *regs = s3c_irq_uart_base(irq);
68 unsigned int bit = s3c_irq_uart_bit(irq);
71 reg = __raw_readl(regs + S3C64XX_UINTM);
73 __raw_writel(reg, regs + S3C64XX_UINTM);
76 static void s3c_irq_uart_ack(unsigned int irq)
78 void __iomem *regs = s3c_irq_uart_base(irq);
79 unsigned int bit = s3c_irq_uart_bit(irq);
81 __raw_writel(1 << bit, regs + S3C64XX_UINTP);
84 static void s3c_irq_demux_uart(unsigned int irq, struct irq_desc *desc)
86 struct s3c_uart_irq *uirq = desc->handler_data;
87 u32 pend = __raw_readl(uirq->regs + S3C64XX_UINTP);
88 int base = uirq->base_irq;
91 generic_handle_irq(base);
93 generic_handle_irq(base + 1);
95 generic_handle_irq(base + 2);
97 generic_handle_irq(base + 3);
100 static struct irq_chip s3c_irq_uart = {
102 .mask = s3c_irq_uart_mask,
103 .unmask = s3c_irq_uart_unmask,
104 .mask_ack = s3c_irq_uart_maskack,
105 .ack = s3c_irq_uart_ack,
108 static void __init s3c_init_uart_irq(struct s3c_uart_irq *uirq)
110 struct irq_desc *desc = irq_to_desc(uirq->parent_irq);
111 void __iomem *reg_base = uirq->regs;
115 /* mask all interrupts at the start. */
116 __raw_writel(0xf, reg_base + S3C64XX_UINTM);
118 for (offs = 0; offs < 3; offs++) {
119 irq = uirq->base_irq + offs;
121 set_irq_chip(irq, &s3c_irq_uart);
122 set_irq_chip_data(irq, uirq);
123 set_irq_handler(irq, handle_level_irq);
124 set_irq_flags(irq, IRQF_VALID);
127 desc->handler_data = uirq;
128 set_irq_chained_handler(uirq->parent_irq, s3c_irq_demux_uart);
132 * s3c_init_uart_irqs() - initialise UART IRQs and the necessary demuxing
133 * @irq: The interrupt data for registering
134 * @nr_irqs: The number of interrupt descriptions in @irq.
136 * Register the UART interrupts specified by @irq including the demuxing
137 * routines. This supports the S3C6400 and newer style of devices.
139 void __init s3c_init_uart_irqs(struct s3c_uart_irq *irq, unsigned int nr_irqs)
141 for (; nr_irqs > 0; nr_irqs--, irq++)
142 s3c_init_uart_irq(irq);