blob: f2f25107510980ca8625f8a5658fc79739a85219 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Driver for AMBA serial ports
3 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 *
6 * Copyright 1999 ARM Limited
7 * Copyright (C) 2000 Deep Blue Solutions Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 * This is a generic driver for ARM AMBA-type serial ports. They
24 * have a lot of 16550-like features, but are not register compatible.
25 * Note that although they do have CTS, DCD and DSR inputs, they do
26 * not have an RI input, nor do they have DTR or RTS outputs. If
27 * required, these have to be supplied via some other means (eg, GPIO)
28 * and hooked into this driver.
29 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#if defined(CONFIG_SERIAL_AMBA_PL010_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
32#define SUPPORT_SYSRQ
33#endif
34
35#include <linux/module.h>
36#include <linux/ioport.h>
37#include <linux/init.h>
38#include <linux/console.h>
39#include <linux/sysrq.h>
40#include <linux/device.h>
41#include <linux/tty.h>
42#include <linux/tty_flip.h>
43#include <linux/serial_core.h>
44#include <linux/serial.h>
Russell Kinga62c80e2006-01-07 13:52:45 +000045#include <linux/amba/bus.h>
46#include <linux/amba/serial.h>
Russell Kinged519de2007-04-22 12:30:41 +010047#include <linux/clk.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090048#include <linux/slab.h>
Tushar Behera44acd262014-06-26 15:35:36 +053049#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Lennert Buytenhek4faf4e02006-06-20 19:24:07 +010051#define UART_NR 8
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53#define SERIAL_AMBA_MAJOR 204
54#define SERIAL_AMBA_MINOR 16
55#define SERIAL_AMBA_NR UART_NR
56
57#define AMBA_ISR_PASS_LIMIT 256
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define UART_RX_DATA(s) (((s) & UART01x_FR_RXFE) == 0)
60#define UART_TX_READY(s) (((s) & UART01x_FR_TXFF) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Russell Kingfbb18a22006-03-26 23:13:39 +010062#define UART_DUMMY_RSR_RX 256
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define UART_PORT_SIZE 64
64
65/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 * We wrap our port structure around the generic uart_port.
67 */
68struct uart_amba_port {
69 struct uart_port port;
Russell Kinged519de2007-04-22 12:30:41 +010070 struct clk *clk;
Russell Kingfbb18a22006-03-26 23:13:39 +010071 struct amba_device *dev;
72 struct amba_pl010_data *data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 unsigned int old_status;
74};
75
Russell Kingb129a8c2005-08-31 10:12:14 +010076static void pl010_stop_tx(struct uart_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077{
Fabian Frederickb70e5e92014-10-05 19:19:46 +020078 struct uart_amba_port *uap =
79 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 unsigned int cr;
81
Russell King1b0646a2007-04-22 11:55:59 +010082 cr = readb(uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 cr &= ~UART010_CR_TIE;
Russell King1b0646a2007-04-22 11:55:59 +010084 writel(cr, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085}
86
Russell Kingb129a8c2005-08-31 10:12:14 +010087static void pl010_start_tx(struct uart_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
Fabian Frederickb70e5e92014-10-05 19:19:46 +020089 struct uart_amba_port *uap =
90 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 unsigned int cr;
92
Russell King1b0646a2007-04-22 11:55:59 +010093 cr = readb(uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 cr |= UART010_CR_TIE;
Russell King1b0646a2007-04-22 11:55:59 +010095 writel(cr, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096}
97
98static void pl010_stop_rx(struct uart_port *port)
99{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200100 struct uart_amba_port *uap =
101 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 unsigned int cr;
103
Russell King1b0646a2007-04-22 11:55:59 +0100104 cr = readb(uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 cr &= ~(UART010_CR_RIE | UART010_CR_RTIE);
Russell King1b0646a2007-04-22 11:55:59 +0100106 writel(cr, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107}
108
Peter Hurleycab68f82014-11-05 13:11:45 -0500109static void pl010_disable_ms(struct uart_port *port)
110{
111 struct uart_amba_port *uap = (struct uart_amba_port *)port;
112 unsigned int cr;
113
114 cr = readb(uap->port.membase + UART010_CR);
115 cr &= ~UART010_CR_MSIE;
116 writel(cr, uap->port.membase + UART010_CR);
117}
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119static void pl010_enable_ms(struct uart_port *port)
120{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200121 struct uart_amba_port *uap =
122 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 unsigned int cr;
124
Russell King1b0646a2007-04-22 11:55:59 +0100125 cr = readb(uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 cr |= UART010_CR_MSIE;
Russell King1b0646a2007-04-22 11:55:59 +0100127 writel(cr, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
Russell King1b0646a2007-04-22 11:55:59 +0100130static void pl010_rx_chars(struct uart_amba_port *uap)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 unsigned int status, ch, flag, rsr, max_count = 256;
133
Russell King1b0646a2007-04-22 11:55:59 +0100134 status = readb(uap->port.membase + UART01x_FR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 while (UART_RX_DATA(status) && max_count--) {
Russell King1b0646a2007-04-22 11:55:59 +0100136 ch = readb(uap->port.membase + UART01x_DR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 flag = TTY_NORMAL;
138
Russell King1b0646a2007-04-22 11:55:59 +0100139 uap->port.icount.rx++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141 /*
142 * Note that the error handling code is
143 * out of the main execution path
144 */
Russell King1b0646a2007-04-22 11:55:59 +0100145 rsr = readb(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
Russell King45849282005-04-26 15:29:44 +0100146 if (unlikely(rsr & UART01x_RSR_ANY)) {
Russell King1b0646a2007-04-22 11:55:59 +0100147 writel(0, uap->port.membase + UART01x_ECR);
Lennert Buytenheka4ed06a2006-12-06 20:39:57 -0800148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 if (rsr & UART01x_RSR_BE) {
150 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
Russell King1b0646a2007-04-22 11:55:59 +0100151 uap->port.icount.brk++;
152 if (uart_handle_break(&uap->port))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 goto ignore_char;
154 } else if (rsr & UART01x_RSR_PE)
Russell King1b0646a2007-04-22 11:55:59 +0100155 uap->port.icount.parity++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 else if (rsr & UART01x_RSR_FE)
Russell King1b0646a2007-04-22 11:55:59 +0100157 uap->port.icount.frame++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 if (rsr & UART01x_RSR_OE)
Russell King1b0646a2007-04-22 11:55:59 +0100159 uap->port.icount.overrun++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Russell King1b0646a2007-04-22 11:55:59 +0100161 rsr &= uap->port.read_status_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163 if (rsr & UART01x_RSR_BE)
164 flag = TTY_BREAK;
165 else if (rsr & UART01x_RSR_PE)
166 flag = TTY_PARITY;
167 else if (rsr & UART01x_RSR_FE)
168 flag = TTY_FRAME;
169 }
170
Russell King1b0646a2007-04-22 11:55:59 +0100171 if (uart_handle_sysrq_char(&uap->port, ch))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 goto ignore_char;
173
Russell King1b0646a2007-04-22 11:55:59 +0100174 uart_insert_char(&uap->port, rsr, UART01x_RSR_OE, ch, flag);
Russell King05ab3012005-05-09 23:21:59 +0100175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 ignore_char:
Russell King1b0646a2007-04-22 11:55:59 +0100177 status = readb(uap->port.membase + UART01x_FR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 }
Russell Kingdb002b82007-06-05 19:39:49 +0100179 spin_unlock(&uap->port.lock);
Jiri Slaby2e124b42013-01-03 15:53:06 +0100180 tty_flip_buffer_push(&uap->port.state->port);
Russell Kingdb002b82007-06-05 19:39:49 +0100181 spin_lock(&uap->port.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182}
183
Russell King1b0646a2007-04-22 11:55:59 +0100184static void pl010_tx_chars(struct uart_amba_port *uap)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
Alan Coxebd2c8f2009-09-19 13:13:28 -0700186 struct circ_buf *xmit = &uap->port.state->xmit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 int count;
188
Russell King1b0646a2007-04-22 11:55:59 +0100189 if (uap->port.x_char) {
190 writel(uap->port.x_char, uap->port.membase + UART01x_DR);
191 uap->port.icount.tx++;
192 uap->port.x_char = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 return;
194 }
Russell King1b0646a2007-04-22 11:55:59 +0100195 if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) {
196 pl010_stop_tx(&uap->port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 return;
198 }
199
Russell King1b0646a2007-04-22 11:55:59 +0100200 count = uap->port.fifosize >> 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 do {
Russell King1b0646a2007-04-22 11:55:59 +0100202 writel(xmit->buf[xmit->tail], uap->port.membase + UART01x_DR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
Russell King1b0646a2007-04-22 11:55:59 +0100204 uap->port.icount.tx++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 if (uart_circ_empty(xmit))
206 break;
207 } while (--count > 0);
208
209 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
Russell King1b0646a2007-04-22 11:55:59 +0100210 uart_write_wakeup(&uap->port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
212 if (uart_circ_empty(xmit))
Russell King1b0646a2007-04-22 11:55:59 +0100213 pl010_stop_tx(&uap->port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214}
215
Russell King1b0646a2007-04-22 11:55:59 +0100216static void pl010_modem_status(struct uart_amba_port *uap)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 unsigned int status, delta;
219
Russell King98639a62006-03-25 21:30:11 +0000220 writel(0, uap->port.membase + UART010_ICR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
Russell King98639a62006-03-25 21:30:11 +0000222 status = readb(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224 delta = status ^ uap->old_status;
225 uap->old_status = status;
226
227 if (!delta)
228 return;
229
230 if (delta & UART01x_FR_DCD)
231 uart_handle_dcd_change(&uap->port, status & UART01x_FR_DCD);
232
233 if (delta & UART01x_FR_DSR)
234 uap->port.icount.dsr++;
235
236 if (delta & UART01x_FR_CTS)
237 uart_handle_cts_change(&uap->port, status & UART01x_FR_CTS);
238
Alan Coxbdc04e32009-09-19 13:13:31 -0700239 wake_up_interruptible(&uap->port.state->port.delta_msr_wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240}
241
David Howells7d12e782006-10-05 14:55:46 +0100242static irqreturn_t pl010_int(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243{
Russell King1b0646a2007-04-22 11:55:59 +0100244 struct uart_amba_port *uap = dev_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
246 int handled = 0;
247
Russell King1b0646a2007-04-22 11:55:59 +0100248 spin_lock(&uap->port.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Russell King1b0646a2007-04-22 11:55:59 +0100250 status = readb(uap->port.membase + UART010_IIR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 if (status) {
252 do {
253 if (status & (UART010_IIR_RTIS | UART010_IIR_RIS))
Russell King1b0646a2007-04-22 11:55:59 +0100254 pl010_rx_chars(uap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 if (status & UART010_IIR_MIS)
Russell King1b0646a2007-04-22 11:55:59 +0100256 pl010_modem_status(uap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 if (status & UART010_IIR_TIS)
Russell King1b0646a2007-04-22 11:55:59 +0100258 pl010_tx_chars(uap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260 if (pass_counter-- == 0)
261 break;
262
Russell King1b0646a2007-04-22 11:55:59 +0100263 status = readb(uap->port.membase + UART010_IIR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 } while (status & (UART010_IIR_RTIS | UART010_IIR_RIS |
265 UART010_IIR_TIS));
266 handled = 1;
267 }
268
Russell King1b0646a2007-04-22 11:55:59 +0100269 spin_unlock(&uap->port.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271 return IRQ_RETVAL(handled);
272}
273
274static unsigned int pl010_tx_empty(struct uart_port *port)
275{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200276 struct uart_amba_port *uap =
277 container_of(port, struct uart_amba_port, port);
Russell King1b0646a2007-04-22 11:55:59 +0100278 unsigned int status = readb(uap->port.membase + UART01x_FR);
279 return status & UART01x_FR_BUSY ? 0 : TIOCSER_TEMT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280}
281
282static unsigned int pl010_get_mctrl(struct uart_port *port)
283{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200284 struct uart_amba_port *uap =
285 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 unsigned int result = 0;
287 unsigned int status;
288
Russell King1b0646a2007-04-22 11:55:59 +0100289 status = readb(uap->port.membase + UART01x_FR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 if (status & UART01x_FR_DCD)
291 result |= TIOCM_CAR;
292 if (status & UART01x_FR_DSR)
293 result |= TIOCM_DSR;
294 if (status & UART01x_FR_CTS)
295 result |= TIOCM_CTS;
296
297 return result;
298}
299
300static void pl010_set_mctrl(struct uart_port *port, unsigned int mctrl)
301{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200302 struct uart_amba_port *uap =
303 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Russell Kingfbb18a22006-03-26 23:13:39 +0100305 if (uap->data)
306 uap->data->set_mctrl(uap->dev, uap->port.membase, mctrl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307}
308
309static void pl010_break_ctl(struct uart_port *port, int break_state)
310{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200311 struct uart_amba_port *uap =
312 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 unsigned long flags;
314 unsigned int lcr_h;
315
Russell King1b0646a2007-04-22 11:55:59 +0100316 spin_lock_irqsave(&uap->port.lock, flags);
317 lcr_h = readb(uap->port.membase + UART010_LCRH);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 if (break_state == -1)
319 lcr_h |= UART01x_LCRH_BRK;
320 else
321 lcr_h &= ~UART01x_LCRH_BRK;
Russell King1b0646a2007-04-22 11:55:59 +0100322 writel(lcr_h, uap->port.membase + UART010_LCRH);
323 spin_unlock_irqrestore(&uap->port.lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324}
325
326static int pl010_startup(struct uart_port *port)
327{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200328 struct uart_amba_port *uap =
329 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 int retval;
331
332 /*
Russell Kinged519de2007-04-22 12:30:41 +0100333 * Try to enable the clock producer.
334 */
Julia Lawall1c4c4392012-08-26 18:01:01 +0200335 retval = clk_prepare_enable(uap->clk);
Russell Kinged519de2007-04-22 12:30:41 +0100336 if (retval)
Julia Lawall1c4c4392012-08-26 18:01:01 +0200337 goto out;
Russell Kinged519de2007-04-22 12:30:41 +0100338
339 uap->port.uartclk = clk_get_rate(uap->clk);
340
341 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 * Allocate the IRQ
343 */
Russell King1b0646a2007-04-22 11:55:59 +0100344 retval = request_irq(uap->port.irq, pl010_int, 0, "uart-pl010", uap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 if (retval)
Russell Kinged519de2007-04-22 12:30:41 +0100346 goto clk_dis;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
348 /*
349 * initialise the old status of the modem signals
350 */
Russell King1b0646a2007-04-22 11:55:59 +0100351 uap->old_status = readb(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /*
354 * Finally, enable interrupts
355 */
Russell King98639a62006-03-25 21:30:11 +0000356 writel(UART01x_CR_UARTEN | UART010_CR_RIE | UART010_CR_RTIE,
Russell King1b0646a2007-04-22 11:55:59 +0100357 uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359 return 0;
Russell Kinged519de2007-04-22 12:30:41 +0100360
361 clk_dis:
Julia Lawall1c4c4392012-08-26 18:01:01 +0200362 clk_disable_unprepare(uap->clk);
Russell Kinged519de2007-04-22 12:30:41 +0100363 out:
364 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365}
366
367static void pl010_shutdown(struct uart_port *port)
368{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200369 struct uart_amba_port *uap =
370 container_of(port, struct uart_amba_port, port);
Russell King1b0646a2007-04-22 11:55:59 +0100371
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 /*
373 * Free the interrupt
374 */
Russell King1b0646a2007-04-22 11:55:59 +0100375 free_irq(uap->port.irq, uap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376
377 /*
378 * disable all interrupts, disable the port
379 */
Russell King1b0646a2007-04-22 11:55:59 +0100380 writel(0, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
382 /* disable break condition and fifos */
Russell King1b0646a2007-04-22 11:55:59 +0100383 writel(readb(uap->port.membase + UART010_LCRH) &
Russell King98639a62006-03-25 21:30:11 +0000384 ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN),
Russell King1b0646a2007-04-22 11:55:59 +0100385 uap->port.membase + UART010_LCRH);
Russell Kinged519de2007-04-22 12:30:41 +0100386
387 /*
388 * Shut down the clock producer
389 */
Julia Lawall1c4c4392012-08-26 18:01:01 +0200390 clk_disable_unprepare(uap->clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391}
392
393static void
Alan Cox606d0992006-12-08 02:38:45 -0800394pl010_set_termios(struct uart_port *port, struct ktermios *termios,
395 struct ktermios *old)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200397 struct uart_amba_port *uap =
398 container_of(port, struct uart_amba_port, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 unsigned int lcr_h, old_cr;
400 unsigned long flags;
401 unsigned int baud, quot;
402
403 /*
404 * Ask the core to calculate the divisor for us.
405 */
Russell King1b0646a2007-04-22 11:55:59 +0100406 baud = uart_get_baud_rate(port, termios, old, 0, uap->port.uartclk/16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 quot = uart_get_divisor(port, baud);
408
409 switch (termios->c_cflag & CSIZE) {
410 case CS5:
411 lcr_h = UART01x_LCRH_WLEN_5;
412 break;
413 case CS6:
414 lcr_h = UART01x_LCRH_WLEN_6;
415 break;
416 case CS7:
417 lcr_h = UART01x_LCRH_WLEN_7;
418 break;
419 default: // CS8
420 lcr_h = UART01x_LCRH_WLEN_8;
421 break;
422 }
423 if (termios->c_cflag & CSTOPB)
424 lcr_h |= UART01x_LCRH_STP2;
425 if (termios->c_cflag & PARENB) {
426 lcr_h |= UART01x_LCRH_PEN;
427 if (!(termios->c_cflag & PARODD))
428 lcr_h |= UART01x_LCRH_EPS;
429 }
Russell King1b0646a2007-04-22 11:55:59 +0100430 if (uap->port.fifosize > 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 lcr_h |= UART01x_LCRH_FEN;
432
Russell King1b0646a2007-04-22 11:55:59 +0100433 spin_lock_irqsave(&uap->port.lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
435 /*
436 * Update the per-port timeout.
437 */
438 uart_update_timeout(port, termios->c_cflag, baud);
439
Russell King1b0646a2007-04-22 11:55:59 +0100440 uap->port.read_status_mask = UART01x_RSR_OE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 if (termios->c_iflag & INPCK)
Russell King1b0646a2007-04-22 11:55:59 +0100442 uap->port.read_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE;
Peter Hurleyef8b9dd2014-06-16 08:10:41 -0400443 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
Russell King1b0646a2007-04-22 11:55:59 +0100444 uap->port.read_status_mask |= UART01x_RSR_BE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446 /*
447 * Characters to ignore
448 */
Russell King1b0646a2007-04-22 11:55:59 +0100449 uap->port.ignore_status_mask = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 if (termios->c_iflag & IGNPAR)
Russell King1b0646a2007-04-22 11:55:59 +0100451 uap->port.ignore_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 if (termios->c_iflag & IGNBRK) {
Russell King1b0646a2007-04-22 11:55:59 +0100453 uap->port.ignore_status_mask |= UART01x_RSR_BE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 /*
455 * If we're ignoring parity and break indicators,
456 * ignore overruns too (for real raw support).
457 */
458 if (termios->c_iflag & IGNPAR)
Russell King1b0646a2007-04-22 11:55:59 +0100459 uap->port.ignore_status_mask |= UART01x_RSR_OE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 }
461
462 /*
463 * Ignore all characters if CREAD is not set.
464 */
465 if ((termios->c_cflag & CREAD) == 0)
Russell King1b0646a2007-04-22 11:55:59 +0100466 uap->port.ignore_status_mask |= UART_DUMMY_RSR_RX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
468 /* first, disable everything */
Russell King1b0646a2007-04-22 11:55:59 +0100469 old_cr = readb(uap->port.membase + UART010_CR) & ~UART010_CR_MSIE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471 if (UART_ENABLE_MS(port, termios->c_cflag))
472 old_cr |= UART010_CR_MSIE;
473
Russell King1b0646a2007-04-22 11:55:59 +0100474 writel(0, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
476 /* Set baud rate */
477 quot -= 1;
Russell King1b0646a2007-04-22 11:55:59 +0100478 writel((quot & 0xf00) >> 8, uap->port.membase + UART010_LCRM);
479 writel(quot & 0xff, uap->port.membase + UART010_LCRL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
481 /*
482 * ----------v----------v----------v----------v-----
483 * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
484 * ----------^----------^----------^----------^-----
485 */
Russell King1b0646a2007-04-22 11:55:59 +0100486 writel(lcr_h, uap->port.membase + UART010_LCRH);
487 writel(old_cr, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488
Russell King1b0646a2007-04-22 11:55:59 +0100489 spin_unlock_irqrestore(&uap->port.lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490}
491
Peter Hurley732a84a2014-11-05 13:11:43 -0500492static void pl010_set_ldisc(struct uart_port *port, struct ktermios *termios)
Rodolfo Giometti7ed63d52010-03-10 15:23:48 -0800493{
Peter Hurley732a84a2014-11-05 13:11:43 -0500494 if (termios->c_line == N_PPS) {
Rodolfo Giometti7ed63d52010-03-10 15:23:48 -0800495 port->flags |= UPF_HARDPPS_CD;
Peter Hurleyd41510c2014-11-05 13:11:44 -0500496 spin_lock_irq(&port->lock);
Rodolfo Giometti7ed63d52010-03-10 15:23:48 -0800497 pl010_enable_ms(port);
Peter Hurleyd41510c2014-11-05 13:11:44 -0500498 spin_unlock_irq(&port->lock);
Peter Hurleycab68f82014-11-05 13:11:45 -0500499 } else {
Rodolfo Giometti7ed63d52010-03-10 15:23:48 -0800500 port->flags &= ~UPF_HARDPPS_CD;
Peter Hurleycab68f82014-11-05 13:11:45 -0500501 if (!UART_ENABLE_MS(port, termios->c_cflag)) {
502 spin_lock_irq(&port->lock);
503 pl010_disable_ms(port);
504 spin_unlock_irq(&port->lock);
505 }
506 }
Rodolfo Giometti7ed63d52010-03-10 15:23:48 -0800507}
508
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509static const char *pl010_type(struct uart_port *port)
510{
511 return port->type == PORT_AMBA ? "AMBA" : NULL;
512}
513
514/*
515 * Release the memory region(s) being used by 'port'
516 */
517static void pl010_release_port(struct uart_port *port)
518{
519 release_mem_region(port->mapbase, UART_PORT_SIZE);
520}
521
522/*
523 * Request the memory region(s) being used by 'port'
524 */
525static int pl010_request_port(struct uart_port *port)
526{
527 return request_mem_region(port->mapbase, UART_PORT_SIZE, "uart-pl010")
528 != NULL ? 0 : -EBUSY;
529}
530
531/*
532 * Configure/autoconfigure the port.
533 */
534static void pl010_config_port(struct uart_port *port, int flags)
535{
536 if (flags & UART_CONFIG_TYPE) {
537 port->type = PORT_AMBA;
538 pl010_request_port(port);
539 }
540}
541
542/*
543 * verify the new serial_struct (for TIOCSSERIAL).
544 */
545static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
546{
547 int ret = 0;
548 if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
549 ret = -EINVAL;
Yinghai Lua62c4132008-08-19 20:49:55 -0700550 if (ser->irq < 0 || ser->irq >= nr_irqs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 ret = -EINVAL;
552 if (ser->baud_base < 9600)
553 ret = -EINVAL;
554 return ret;
555}
556
Bhumika Goyal2331e062017-01-25 23:18:52 +0530557static const struct uart_ops amba_pl010_pops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .tx_empty = pl010_tx_empty,
559 .set_mctrl = pl010_set_mctrl,
560 .get_mctrl = pl010_get_mctrl,
561 .stop_tx = pl010_stop_tx,
562 .start_tx = pl010_start_tx,
563 .stop_rx = pl010_stop_rx,
564 .enable_ms = pl010_enable_ms,
565 .break_ctl = pl010_break_ctl,
566 .startup = pl010_startup,
567 .shutdown = pl010_shutdown,
568 .set_termios = pl010_set_termios,
Rodolfo Giometti7ed63d52010-03-10 15:23:48 -0800569 .set_ldisc = pl010_set_ldisc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .type = pl010_type,
571 .release_port = pl010_release_port,
572 .request_port = pl010_request_port,
573 .config_port = pl010_config_port,
574 .verify_port = pl010_verify_port,
575};
576
Russell Kingfbb18a22006-03-26 23:13:39 +0100577static struct uart_amba_port *amba_ports[UART_NR];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578
579#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
580
Russell Kingd3587882006-03-20 20:00:09 +0000581static void pl010_console_putchar(struct uart_port *port, int ch)
582{
Fabian Frederickb70e5e92014-10-05 19:19:46 +0200583 struct uart_amba_port *uap =
584 container_of(port, struct uart_amba_port, port);
Russell King98639a62006-03-25 21:30:11 +0000585 unsigned int status;
586
587 do {
Russell King1b0646a2007-04-22 11:55:59 +0100588 status = readb(uap->port.membase + UART01x_FR);
Russell Kingd3587882006-03-20 20:00:09 +0000589 barrier();
Russell King98639a62006-03-25 21:30:11 +0000590 } while (!UART_TX_READY(status));
Russell King1b0646a2007-04-22 11:55:59 +0100591 writel(ch, uap->port.membase + UART01x_DR);
Russell Kingd3587882006-03-20 20:00:09 +0000592}
593
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594static void
595pl010_console_write(struct console *co, const char *s, unsigned int count)
596{
Russell King1b0646a2007-04-22 11:55:59 +0100597 struct uart_amba_port *uap = amba_ports[co->index];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 unsigned int status, old_cr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599
Russell Kinged519de2007-04-22 12:30:41 +0100600 clk_enable(uap->clk);
601
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 /*
603 * First save the CR then disable the interrupts
604 */
Russell King1b0646a2007-04-22 11:55:59 +0100605 old_cr = readb(uap->port.membase + UART010_CR);
606 writel(UART01x_CR_UARTEN, uap->port.membase + UART010_CR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607
Russell King1b0646a2007-04-22 11:55:59 +0100608 uart_console_write(&uap->port, s, count, pl010_console_putchar);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609
610 /*
611 * Finally, wait for transmitter to become empty
612 * and restore the TCR
613 */
614 do {
Russell King1b0646a2007-04-22 11:55:59 +0100615 status = readb(uap->port.membase + UART01x_FR);
Russell King98639a62006-03-25 21:30:11 +0000616 barrier();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 } while (status & UART01x_FR_BUSY);
Russell King1b0646a2007-04-22 11:55:59 +0100618 writel(old_cr, uap->port.membase + UART010_CR);
Russell Kinged519de2007-04-22 12:30:41 +0100619
620 clk_disable(uap->clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621}
622
623static void __init
Russell King1b0646a2007-04-22 11:55:59 +0100624pl010_console_get_options(struct uart_amba_port *uap, int *baud,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 int *parity, int *bits)
626{
Russell King1b0646a2007-04-22 11:55:59 +0100627 if (readb(uap->port.membase + UART010_CR) & UART01x_CR_UARTEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 unsigned int lcr_h, quot;
Russell King1b0646a2007-04-22 11:55:59 +0100629 lcr_h = readb(uap->port.membase + UART010_LCRH);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
631 *parity = 'n';
632 if (lcr_h & UART01x_LCRH_PEN) {
633 if (lcr_h & UART01x_LCRH_EPS)
634 *parity = 'e';
635 else
636 *parity = 'o';
637 }
638
639 if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7)
640 *bits = 7;
641 else
642 *bits = 8;
643
Russell King1b0646a2007-04-22 11:55:59 +0100644 quot = readb(uap->port.membase + UART010_LCRL) |
645 readb(uap->port.membase + UART010_LCRM) << 8;
646 *baud = uap->port.uartclk / (16 * (quot + 1));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 }
648}
649
650static int __init pl010_console_setup(struct console *co, char *options)
651{
Russell King1b0646a2007-04-22 11:55:59 +0100652 struct uart_amba_port *uap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 int baud = 38400;
654 int bits = 8;
655 int parity = 'n';
656 int flow = 'n';
Russell King36b8f1e2011-09-22 11:35:09 +0100657 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658
659 /*
660 * Check whether an invalid uart number has been specified, and
661 * if so, search for the first available port that does have
662 * console support.
663 */
664 if (co->index >= UART_NR)
665 co->index = 0;
Russell King1b0646a2007-04-22 11:55:59 +0100666 uap = amba_ports[co->index];
667 if (!uap)
Russell Kingd28122a2007-01-22 18:59:42 +0000668 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669
Russell King36b8f1e2011-09-22 11:35:09 +0100670 ret = clk_prepare(uap->clk);
671 if (ret)
672 return ret;
673
Russell Kinged519de2007-04-22 12:30:41 +0100674 uap->port.uartclk = clk_get_rate(uap->clk);
675
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 if (options)
677 uart_parse_options(options, &baud, &parity, &bits, &flow);
678 else
Russell King1b0646a2007-04-22 11:55:59 +0100679 pl010_console_get_options(uap, &baud, &parity, &bits);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680
Russell King1b0646a2007-04-22 11:55:59 +0100681 return uart_set_options(&uap->port, co, baud, parity, bits, flow);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682}
683
Vincent Sanders2d934862005-09-14 22:36:03 +0100684static struct uart_driver amba_reg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685static struct console amba_console = {
686 .name = "ttyAM",
687 .write = pl010_console_write,
688 .device = uart_console_device,
689 .setup = pl010_console_setup,
690 .flags = CON_PRINTBUFFER,
691 .index = -1,
692 .data = &amba_reg,
693};
694
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695#define AMBA_CONSOLE &amba_console
696#else
697#define AMBA_CONSOLE NULL
698#endif
699
700static struct uart_driver amba_reg = {
701 .owner = THIS_MODULE,
702 .driver_name = "ttyAM",
703 .dev_name = "ttyAM",
704 .major = SERIAL_AMBA_MAJOR,
705 .minor = SERIAL_AMBA_MINOR,
706 .nr = UART_NR,
707 .cons = AMBA_CONSOLE,
708};
709
Russell Kingaa25afa2011-02-19 15:55:00 +0000710static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711{
Russell King1b0646a2007-04-22 11:55:59 +0100712 struct uart_amba_port *uap;
Russell Kingfbb18a22006-03-26 23:13:39 +0100713 void __iomem *base;
714 int i, ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715
Russell Kingfbb18a22006-03-26 23:13:39 +0100716 for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
717 if (amba_ports[i] == NULL)
718 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719
Tushar Behera44acd262014-06-26 15:35:36 +0530720 if (i == ARRAY_SIZE(amba_ports))
721 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722
Tushar Behera44acd262014-06-26 15:35:36 +0530723 uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
724 GFP_KERNEL);
725 if (!uap)
726 return -ENOMEM;
Russell Kingfbb18a22006-03-26 23:13:39 +0100727
Tushar Behera44acd262014-06-26 15:35:36 +0530728 base = devm_ioremap(&dev->dev, dev->res.start,
729 resource_size(&dev->res));
730 if (!base)
731 return -ENOMEM;
Russell Kingfbb18a22006-03-26 23:13:39 +0100732
Tushar Behera44acd262014-06-26 15:35:36 +0530733 uap->clk = devm_clk_get(&dev->dev, NULL);
734 if (IS_ERR(uap->clk))
735 return PTR_ERR(uap->clk);
Russell Kinged519de2007-04-22 12:30:41 +0100736
Russell King1b0646a2007-04-22 11:55:59 +0100737 uap->port.dev = &dev->dev;
738 uap->port.mapbase = dev->res.start;
739 uap->port.membase = base;
740 uap->port.iotype = UPIO_MEM;
741 uap->port.irq = dev->irq[0];
Russell King1b0646a2007-04-22 11:55:59 +0100742 uap->port.fifosize = 16;
743 uap->port.ops = &amba_pl010_pops;
744 uap->port.flags = UPF_BOOT_AUTOCONF;
745 uap->port.line = i;
746 uap->dev = dev;
Jingoo Han574de552013-07-30 17:06:57 +0900747 uap->data = dev_get_platdata(&dev->dev);
Russell Kingfbb18a22006-03-26 23:13:39 +0100748
Russell King1b0646a2007-04-22 11:55:59 +0100749 amba_ports[i] = uap;
Russell Kingfbb18a22006-03-26 23:13:39 +0100750
Russell King1b0646a2007-04-22 11:55:59 +0100751 amba_set_drvdata(dev, uap);
752 ret = uart_add_one_port(&amba_reg, &uap->port);
Tushar Behera44acd262014-06-26 15:35:36 +0530753 if (ret)
Russell Kingfbb18a22006-03-26 23:13:39 +0100754 amba_ports[i] = NULL;
Tushar Behera44acd262014-06-26 15:35:36 +0530755
Russell Kingfbb18a22006-03-26 23:13:39 +0100756 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757}
758
759static int pl010_remove(struct amba_device *dev)
760{
Russell King1b0646a2007-04-22 11:55:59 +0100761 struct uart_amba_port *uap = amba_get_drvdata(dev);
Russell Kingfbb18a22006-03-26 23:13:39 +0100762 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763
Russell King1b0646a2007-04-22 11:55:59 +0100764 uart_remove_one_port(&amba_reg, &uap->port);
Russell Kingfbb18a22006-03-26 23:13:39 +0100765
766 for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
Russell King1b0646a2007-04-22 11:55:59 +0100767 if (amba_ports[i] == uap)
Russell Kingfbb18a22006-03-26 23:13:39 +0100768 amba_ports[i] = NULL;
769
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 return 0;
771}
772
Ulf Hansson95468242013-12-03 11:04:27 +0100773#ifdef CONFIG_PM_SLEEP
774static int pl010_suspend(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775{
Ulf Hansson95468242013-12-03 11:04:27 +0100776 struct uart_amba_port *uap = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777
778 if (uap)
779 uart_suspend_port(&amba_reg, &uap->port);
780
781 return 0;
782}
783
Ulf Hansson95468242013-12-03 11:04:27 +0100784static int pl010_resume(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785{
Ulf Hansson95468242013-12-03 11:04:27 +0100786 struct uart_amba_port *uap = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787
788 if (uap)
789 uart_resume_port(&amba_reg, &uap->port);
790
791 return 0;
792}
Ulf Hansson95468242013-12-03 11:04:27 +0100793#endif
794
795static SIMPLE_DEV_PM_OPS(pl010_dev_pm_ops, pl010_suspend, pl010_resume);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796
Russell King2c39c9e2010-07-27 08:50:16 +0100797static struct amba_id pl010_ids[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 {
799 .id = 0x00041010,
800 .mask = 0x000fffff,
801 },
802 { 0, 0 },
803};
804
Dave Martina664a112011-10-05 15:15:22 +0100805MODULE_DEVICE_TABLE(amba, pl010_ids);
806
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807static struct amba_driver pl010_driver = {
808 .drv = {
809 .name = "uart-pl010",
Ulf Hansson95468242013-12-03 11:04:27 +0100810 .pm = &pl010_dev_pm_ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 },
812 .id_table = pl010_ids,
813 .probe = pl010_probe,
814 .remove = pl010_remove,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815};
816
817static int __init pl010_init(void)
818{
819 int ret;
820
Adrian Bunkd87a6d92008-07-16 21:53:31 +0100821 printk(KERN_INFO "Serial: AMBA driver\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822
823 ret = uart_register_driver(&amba_reg);
824 if (ret == 0) {
825 ret = amba_driver_register(&pl010_driver);
826 if (ret)
827 uart_unregister_driver(&amba_reg);
828 }
829 return ret;
830}
831
832static void __exit pl010_exit(void)
833{
834 amba_driver_unregister(&pl010_driver);
835 uart_unregister_driver(&amba_reg);
836}
837
838module_init(pl010_init);
839module_exit(pl010_exit);
840
841MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd");
Adrian Bunkd87a6d92008-07-16 21:53:31 +0100842MODULE_DESCRIPTION("ARM AMBA serial port driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843MODULE_LICENSE("GPL");