2 * linux/drivers/char/at91_serial.c
4 * Driver for Atmel AT91RM9200 Serial ports
6 * Copyright (C) 2003 Rick Bronson
8 * Based on drivers/char/serial_sa1100.c, by Deep Blue Solutions Ltd.
9 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/config.h>
27 #include <linux/module.h>
28 #include <linux/tty.h>
29 #include <linux/ioport.h>
30 #include <linux/slab.h>
31 #include <linux/init.h>
32 #include <linux/serial.h>
33 #include <linux/console.h>
34 #include <linux/sysrq.h>
35 #include <linux/tty_flip.h>
39 #include <asm/arch/at91rm9200_usart.h>
40 #include <asm/mach/serial_at91rm9200.h>
41 #include <asm/arch/board.h>
42 #include <asm/arch/pio.h>
45 #if defined(CONFIG_SERIAL_AT91_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
49 #include <linux/serial_core.h>
51 #ifdef CONFIG_SERIAL_AT91_TTYAT
53 /* Use device name ttyAT, major 204 and minor 154-169. This is necessary if we
54 * should coexist with the 8250 driver, such as if we have an external 16C550
56 #define SERIAL_AT91_MAJOR 204
57 #define MINOR_START 154
58 #define AT91_DEVICENAME "ttyAT"
62 /* Use device name ttyS, major 4, minor 64-68. This is the usual serial port
63 * name, but it is legally reserved for the 8250 driver. */
64 #define SERIAL_AT91_MAJOR TTY_MAJOR
65 #define MINOR_START 64
66 #define AT91_DEVICENAME "ttyS"
70 #define AT91_VA_BASE_DBGU ((unsigned long) AT91_VA_BASE_SYS + AT91_DBGU)
71 #define AT91_ISR_PASS_LIMIT 256
73 #define UART_PUT_CR(port,v) writel(v, (port)->membase + AT91_US_CR)
74 #define UART_GET_MR(port) readl((port)->membase + AT91_US_MR)
75 #define UART_PUT_MR(port,v) writel(v, (port)->membase + AT91_US_MR)
76 #define UART_PUT_IER(port,v) writel(v, (port)->membase + AT91_US_IER)
77 #define UART_PUT_IDR(port,v) writel(v, (port)->membase + AT91_US_IDR)
78 #define UART_GET_IMR(port) readl((port)->membase + AT91_US_IMR)
79 #define UART_GET_CSR(port) readl((port)->membase + AT91_US_CSR)
80 #define UART_GET_CHAR(port) readl((port)->membase + AT91_US_RHR)
81 #define UART_PUT_CHAR(port,v) writel(v, (port)->membase + AT91_US_THR)
82 #define UART_GET_BRGR(port) readl((port)->membase + AT91_US_BRGR)
83 #define UART_PUT_BRGR(port,v) writel(v, (port)->membase + AT91_US_BRGR)
84 #define UART_PUT_RTOR(port,v) writel(v, (port)->membase + AT91_US_RTOR)
86 // #define UART_GET_CR(port) readl((port)->membase + AT91_US_CR) // is write-only
89 #define UART_PUT_PTCR(port,v) writel(v, (port)->membase + AT91_PDC_PTCR)
90 #define UART_PUT_RPR(port,v) writel(v, (port)->membase + AT91_PDC_RPR)
91 #define UART_PUT_RCR(port,v) writel(v, (port)->membase + AT91_PDC_RCR)
92 #define UART_GET_RCR(port) readl((port)->membase + AT91_PDC_RCR)
93 #define UART_PUT_RNPR(port,v) writel(v, (port)->membase + AT91_PDC_RNPR)
94 #define UART_PUT_RNCR(port,v) writel(v, (port)->membase + AT91_PDC_RNCR)
97 static int (*at91_open)(struct uart_port *);
98 static void (*at91_close)(struct uart_port *);
101 static struct console at91_console;
105 * Return TIOCSER_TEMT when transmitter FIFO and Shift register is empty.
107 static u_int at91_tx_empty(struct uart_port *port)
109 return (UART_GET_CSR(port) & AT91_US_TXEMPTY) ? TIOCSER_TEMT : 0;
113 * Set state of the modem control output lines
115 static void at91_set_mctrl(struct uart_port *port, u_int mctrl)
117 unsigned int control = 0;
120 * Errata #39: RTS0 is not internally connected to PA21. We need to drive
123 if (port->mapbase == AT91_VA_BASE_US0) {
124 if (mctrl & TIOCM_RTS)
125 at91_sys_write(AT91_PIOA + PIO_CODR, AT91_PA21_RTS0);
127 at91_sys_write(AT91_PIOA + PIO_SODR, AT91_PA21_RTS0);
130 if (mctrl & TIOCM_RTS)
131 control |= AT91_US_RTSEN;
133 control |= AT91_US_RTSDIS;
135 if (mctrl & TIOCM_DTR)
136 control |= AT91_US_DTREN;
138 control |= AT91_US_DTRDIS;
140 UART_PUT_CR(port,control);
144 * Get state of the modem control input lines
146 static u_int at91_get_mctrl(struct uart_port *port)
148 unsigned int status, ret = 0;
150 status = UART_GET_CSR(port);
153 * The control signals are active low.
155 if (!(status & AT91_US_DCD))
157 if (!(status & AT91_US_CTS))
159 if (!(status & AT91_US_DSR))
161 if (!(status & AT91_US_RI))
170 static void at91_stop_tx(struct uart_port *port)
172 UART_PUT_IDR(port, AT91_US_TXRDY);
173 port->read_status_mask &= ~AT91_US_TXRDY;
177 * Start transmitting.
179 static void at91_start_tx(struct uart_port *port)
181 port->read_status_mask |= AT91_US_TXRDY;
182 UART_PUT_IER(port, AT91_US_TXRDY);
186 * Stop receiving - port is in process of being closed.
188 static void at91_stop_rx(struct uart_port *port)
190 UART_PUT_IDR(port, AT91_US_RXRDY);
194 * Enable modem status interrupts
196 static void at91_enable_ms(struct uart_port *port)
198 port->read_status_mask |= (AT91_US_RIIC | AT91_US_DSRIC | AT91_US_DCDIC | AT91_US_CTSIC);
199 UART_PUT_IER(port, AT91_US_RIIC | AT91_US_DSRIC | AT91_US_DCDIC | AT91_US_CTSIC);
203 * Control the transmission of a break signal
205 static void at91_break_ctl(struct uart_port *port, int break_state)
207 if (break_state != 0)
208 UART_PUT_CR(port, AT91_US_STTBRK); /* start break */
210 UART_PUT_CR(port, AT91_US_STPBRK); /* stop break */
214 * Characters received (called from interrupt handler)
216 static void at91_rx_chars(struct uart_port *port, struct pt_regs *regs)
218 struct tty_struct *tty = port->info->tty;
219 unsigned int status, ch, flg;
221 status = UART_GET_CSR(port) & port->read_status_mask;
222 while (status & (AT91_US_RXRDY)) {
223 ch = UART_GET_CHAR(port);
225 if (tty->flip.count >= TTY_FLIPBUF_SIZE)
232 * note that the error handling code is
233 * out of the main execution path
235 if (unlikely(status & (AT91_US_PARE | AT91_US_FRAME | AT91_US_OVRE))) {
236 UART_PUT_CR(port, AT91_US_RSTSTA); /* clear error */
237 if (status & (AT91_US_PARE))
238 port->icount.parity++;
239 if (status & (AT91_US_FRAME))
240 port->icount.frame++;
241 if (status & (AT91_US_OVRE))
242 port->icount.overrun++;
244 if (status & AT91_US_PARE)
246 else if (status & AT91_US_FRAME)
248 if (status & AT91_US_OVRE) {
250 * overrun does *not* affect the character
251 * we read from the FIFO
253 tty_insert_flip_char(tty, ch, flg);
262 if (uart_handle_sysrq_char(port, ch, regs))
265 tty_insert_flip_char(tty, ch, flg);
268 status = UART_GET_CSR(port) & port->read_status_mask;
271 tty_flip_buffer_push(tty);
275 * Transmit characters (called from interrupt handler)
277 static void at91_tx_chars(struct uart_port *port)
279 struct circ_buf *xmit = &port->info->xmit;
282 UART_PUT_CHAR(port, port->x_char);
287 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
292 while (UART_GET_CSR(port) & AT91_US_TXRDY) {
293 UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
294 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
296 if (uart_circ_empty(xmit))
300 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
301 uart_write_wakeup(port);
303 if (uart_circ_empty(xmit))
310 static irqreturn_t at91_interrupt(int irq, void *dev_id, struct pt_regs *regs)
312 struct uart_port *port = dev_id;
313 unsigned int status, pending, pass_counter = 0;
315 status = UART_GET_CSR(port);
316 pending = status & port->read_status_mask;
319 if (pending & AT91_US_RXRDY)
320 at91_rx_chars(port, regs);
322 /* Clear the relevent break bits */
323 if (pending & AT91_US_RXBRK) {
324 UART_PUT_CR(port, AT91_US_RSTSTA);
326 uart_handle_break(port);
329 // TODO: All reads to CSR will clear these interrupts!
330 if (pending & AT91_US_RIIC) port->icount.rng++;
331 if (pending & AT91_US_DSRIC) port->icount.dsr++;
332 if (pending & AT91_US_DCDIC)
333 uart_handle_dcd_change(port, !(status & AT91_US_DCD));
334 if (pending & AT91_US_CTSIC)
335 uart_handle_cts_change(port, !(status & AT91_US_CTS));
336 if (pending & (AT91_US_RIIC | AT91_US_DSRIC | AT91_US_DCDIC | AT91_US_CTSIC))
337 wake_up_interruptible(&port->info->delta_msr_wait);
339 if (pending & AT91_US_TXRDY)
341 if (pass_counter++ > AT91_ISR_PASS_LIMIT)
344 status = UART_GET_CSR(port);
345 pending = status & port->read_status_mask;
352 * Perform initialization and enable port for reception
354 static int at91_startup(struct uart_port *port)
359 * Ensure that no interrupts are enabled otherwise when
360 * request_irq() is called we could get stuck trying to
361 * handle an unexpected interrupt
363 UART_PUT_IDR(port, -1);
368 retval = request_irq(port->irq, at91_interrupt, SA_SHIRQ, "at91_serial", port);
370 printk("at91_serial: at91_startup - Can't get irq\n");
375 * If there is a specific "open" function (to register
376 * control line interrupts)
379 retval = at91_open(port);
381 free_irq(port->irq, port);
386 port->read_status_mask = AT91_US_RXRDY | AT91_US_TXRDY | AT91_US_OVRE
387 | AT91_US_FRAME | AT91_US_PARE | AT91_US_RXBRK;
389 * Finally, enable the serial port
391 UART_PUT_CR(port, AT91_US_RSTSTA | AT91_US_RSTRX);
392 UART_PUT_CR(port, AT91_US_TXEN | AT91_US_RXEN); /* enable xmit & rcvr */
393 UART_PUT_IER(port, AT91_US_RXRDY); /* do receive only */
400 static void at91_shutdown(struct uart_port *port)
403 * Disable all interrupts, port and break condition.
405 UART_PUT_CR(port, AT91_US_RSTSTA);
406 UART_PUT_IDR(port, -1);
411 free_irq(port->irq, port);
414 * If there is a specific "close" function (to unregister
415 * control line interrupts)
422 * Power / Clock management.
424 static void at91_serial_pm(struct uart_port *port, unsigned int state, unsigned int oldstate)
429 * Enable the peripheral clock for this serial port.
430 * This is called on uart_open() or a resume event.
432 at91_sys_write(AT91_PMC_PCER, 1 << port->irq);
436 * Disable the peripheral clock for this serial port.
437 * This is called on uart_close() or a suspend event.
439 if (port->irq != AT91_ID_SYS) /* is this a shared clock? */
440 at91_sys_write(AT91_PMC_PCDR, 1 << port->irq);
443 printk(KERN_ERR "at91_serial: unknown pm %d\n", state);
448 * Change the port parameters
450 static void at91_set_termios(struct uart_port *port, struct termios * termios, struct termios * old)
453 unsigned int mode, imr, quot, baud;
455 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
456 quot = uart_get_divisor(port, baud);
458 /* Get current mode register */
459 mode = UART_GET_MR(port) & ~(AT91_US_CHRL | AT91_US_NBSTOP | AT91_US_PAR);
462 switch (termios->c_cflag & CSIZE) {
464 mode |= AT91_US_CHRL_5;
467 mode |= AT91_US_CHRL_6;
470 mode |= AT91_US_CHRL_7;
473 mode |= AT91_US_CHRL_8;
478 if (termios->c_cflag & CSTOPB)
479 mode |= AT91_US_NBSTOP_2;
482 if (termios->c_cflag & PARENB) {
483 if (termios->c_cflag & CMSPAR) { /* Mark or Space parity */
484 if (termios->c_cflag & PARODD)
485 mode |= AT91_US_PAR_MARK;
487 mode |= AT91_US_PAR_SPACE;
489 else if (termios->c_cflag & PARODD)
490 mode |= AT91_US_PAR_ODD;
492 mode |= AT91_US_PAR_EVEN;
495 mode |= AT91_US_PAR_NONE;
497 spin_lock_irqsave(&port->lock, flags);
499 port->read_status_mask |= AT91_US_OVRE;
500 if (termios->c_iflag & INPCK)
501 port->read_status_mask |= AT91_US_FRAME | AT91_US_PARE;
502 if (termios->c_iflag & (BRKINT | PARMRK))
503 port->read_status_mask |= AT91_US_RXBRK;
506 * Characters to ignore
508 port->ignore_status_mask = 0;
509 if (termios->c_iflag & IGNPAR)
510 port->ignore_status_mask |= (AT91_US_FRAME | AT91_US_PARE);
511 if (termios->c_iflag & IGNBRK) {
512 port->ignore_status_mask |= AT91_US_RXBRK;
514 * If we're ignoring parity and break indicators,
515 * ignore overruns too (for real raw support).
517 if (termios->c_iflag & IGNPAR)
518 port->ignore_status_mask |= AT91_US_OVRE;
521 // TODO: Ignore all characters if CREAD is set.
523 /* update the per-port timeout */
524 uart_update_timeout(port, termios->c_cflag, baud);
526 /* disable interrupts and drain transmitter */
527 imr = UART_GET_IMR(port); /* get interrupt mask */
528 UART_PUT_IDR(port, -1); /* disable all interrupts */
529 while (!(UART_GET_CSR(port) & AT91_US_TXEMPTY)) { barrier(); }
531 /* disable receiver and transmitter */
532 UART_PUT_CR(port, AT91_US_TXDIS | AT91_US_RXDIS);
534 /* set the parity, stop bits and data size */
535 UART_PUT_MR(port, mode);
537 /* set the baud rate */
538 UART_PUT_BRGR(port, quot);
539 UART_PUT_CR(port, AT91_US_RSTSTA | AT91_US_RSTRX);
540 UART_PUT_CR(port, AT91_US_TXEN | AT91_US_RXEN);
542 /* restore interrupts */
543 UART_PUT_IER(port, imr);
545 /* CTS flow-control and modem-status interrupts */
546 if (UART_ENABLE_MS(port, termios->c_cflag))
547 port->ops->enable_ms(port);
549 spin_unlock_irqrestore(&port->lock, flags);
553 * Return string describing the specified port
555 static const char *at91_type(struct uart_port *port)
557 return (port->type == PORT_AT91RM9200) ? "AT91_SERIAL" : NULL;
561 * Release the memory region(s) being used by 'port'.
563 static void at91_release_port(struct uart_port *port)
565 release_mem_region(port->mapbase,
566 (port->mapbase == AT91_VA_BASE_DBGU) ? 512 : SZ_16K);
570 * Request the memory region(s) being used by 'port'.
572 static int at91_request_port(struct uart_port *port)
574 return request_mem_region(port->mapbase,
575 (port->mapbase == AT91_VA_BASE_DBGU) ? 512 : SZ_16K,
576 "at91_serial") != NULL ? 0 : -EBUSY;
581 * Configure/autoconfigure the port.
583 static void at91_config_port(struct uart_port *port, int flags)
585 if (flags & UART_CONFIG_TYPE) {
586 port->type = PORT_AT91RM9200;
587 at91_request_port(port);
592 * Verify the new serial_struct (for TIOCSSERIAL).
594 static int at91_verify_port(struct uart_port *port, struct serial_struct *ser)
597 if (ser->type != PORT_UNKNOWN && ser->type != PORT_AT91RM9200)
599 if (port->irq != ser->irq)
601 if (ser->io_type != SERIAL_IO_MEM)
603 if (port->uartclk / 16 != ser->baud_base)
605 if ((void *)port->mapbase != ser->iomem_base)
607 if (port->iobase != ser->port)
614 static struct uart_ops at91_pops = {
615 .tx_empty = at91_tx_empty,
616 .set_mctrl = at91_set_mctrl,
617 .get_mctrl = at91_get_mctrl,
618 .stop_tx = at91_stop_tx,
619 .start_tx = at91_start_tx,
620 .stop_rx = at91_stop_rx,
621 .enable_ms = at91_enable_ms,
622 .break_ctl = at91_break_ctl,
623 .startup = at91_startup,
624 .shutdown = at91_shutdown,
625 .set_termios = at91_set_termios,
627 .release_port = at91_release_port,
628 .request_port = at91_request_port,
629 .config_port = at91_config_port,
630 .verify_port = at91_verify_port,
631 .pm = at91_serial_pm,
634 static struct uart_port at91_ports[AT91_NR_UART];
636 void __init at91_init_ports(void)
638 static int first = 1;
645 for (i = 0; i < AT91_NR_UART; i++) {
646 at91_ports[i].iotype = UPIO_MEM;
647 at91_ports[i].flags = UPF_BOOT_AUTOCONF;
648 at91_ports[i].uartclk = at91_master_clock;
649 at91_ports[i].ops = &at91_pops;
650 at91_ports[i].fifosize = 1;
651 at91_ports[i].line = i;
655 void __init at91_register_uart_fns(struct at91rm9200_port_fns *fns)
658 at91_pops.enable_ms = fns->enable_ms;
660 at91_pops.get_mctrl = fns->get_mctrl;
662 at91_pops.set_mctrl = fns->set_mctrl;
663 at91_open = fns->open;
664 at91_close = fns->close;
665 at91_pops.pm = fns->pm;
666 at91_pops.set_wake = fns->set_wake;
672 void __init at91_register_uart(int idx, int port)
674 if ((idx < 0) || (idx >= AT91_NR_UART)) {
675 printk(KERN_ERR "%s: bad index number %d\n", __FUNCTION__, idx);
681 at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US0;
682 at91_ports[idx].mapbase = AT91_VA_BASE_US0;
683 at91_ports[idx].irq = AT91_ID_US0;
684 AT91_CfgPIO_USART0();
687 at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US1;
688 at91_ports[idx].mapbase = AT91_VA_BASE_US1;
689 at91_ports[idx].irq = AT91_ID_US1;
690 AT91_CfgPIO_USART1();
693 at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US2;
694 at91_ports[idx].mapbase = AT91_VA_BASE_US2;
695 at91_ports[idx].irq = AT91_ID_US2;
696 AT91_CfgPIO_USART2();
699 at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US3;
700 at91_ports[idx].mapbase = AT91_VA_BASE_US3;
701 at91_ports[idx].irq = AT91_ID_US3;
702 AT91_CfgPIO_USART3();
705 at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_DBGU;
706 at91_ports[idx].mapbase = AT91_VA_BASE_DBGU;
707 at91_ports[idx].irq = AT91_ID_SYS;
711 printk(KERN_ERR "%s : bad port number %d\n", __FUNCTION__, port);
715 #ifdef CONFIG_SERIAL_AT91_CONSOLE
718 * Interrupts are disabled on entering
720 static void at91_console_write(struct console *co, const char *s, u_int count)
722 struct uart_port *port = at91_ports + co->index;
723 unsigned int status, i, imr;
726 * First, save IMR and then disable interrupts
728 imr = UART_GET_IMR(port); /* get interrupt mask */
729 UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY);
732 * Now, do each character
734 for (i = 0; i < count; i++) {
736 status = UART_GET_CSR(port);
737 } while (!(status & AT91_US_TXRDY));
738 UART_PUT_CHAR(port, s[i]);
741 status = UART_GET_CSR(port);
742 } while (!(status & AT91_US_TXRDY));
743 UART_PUT_CHAR(port, '\r');
748 * Finally, wait for transmitter to become empty
752 status = UART_GET_CSR(port);
753 } while (!(status & AT91_US_TXRDY));
754 UART_PUT_IER(port, imr); /* set interrupts back the way they were */
758 * If the port was already initialised (eg, by a boot loader), try to determine
761 static void __init at91_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
763 unsigned int mr, quot;
765 // TODO: CR is a write-only register
768 // cr = UART_GET_CR(port) & (AT91_US_RXEN | AT91_US_TXEN);
769 // if (cr == (AT91_US_RXEN | AT91_US_TXEN)) {
770 // /* ok, the port was enabled */
773 mr = UART_GET_MR(port) & AT91_US_CHRL;
774 if (mr == AT91_US_CHRL_8)
779 mr = UART_GET_MR(port) & AT91_US_PAR;
780 if (mr == AT91_US_PAR_EVEN)
782 else if (mr == AT91_US_PAR_ODD)
785 quot = UART_GET_BRGR(port);
786 *baud = port->uartclk / (16 * (quot));
789 static int __init at91_console_setup(struct console *co, char *options)
791 struct uart_port *port;
798 * Check whether an invalid uart number has been specified, and
799 * if so, search for the first available port that does have
802 port = uart_get_console(at91_ports, AT91_NR_UART, co);
805 * Enable the serial console, in-case bootloader did not do it.
807 at91_sys_write(AT91_PMC_PCER, 1 << port->irq); /* enable clock */
808 UART_PUT_IDR(port, -1); /* disable interrupts */
809 UART_PUT_CR(port, AT91_US_RSTSTA | AT91_US_RSTRX);
810 UART_PUT_CR(port, AT91_US_TXEN | AT91_US_RXEN);
813 uart_parse_options(options, &baud, &parity, &bits, &flow);
815 at91_console_get_options(port, &baud, &parity, &bits);
817 return uart_set_options(port, co, baud, parity, bits, flow);
820 static struct uart_driver at91_uart;
822 static struct console at91_console = {
823 .name = AT91_DEVICENAME,
824 .write = at91_console_write,
825 .device = uart_console_device,
826 .setup = at91_console_setup,
827 .flags = CON_PRINTBUFFER,
832 #define AT91_CONSOLE_DEVICE &at91_console
834 static int __init at91_console_init(void)
838 at91_console.index = at91_console_port;
839 register_console(&at91_console);
842 console_initcall(at91_console_init);
845 #define AT91_CONSOLE_DEVICE NULL
848 static struct uart_driver at91_uart = {
849 .owner = THIS_MODULE,
850 .driver_name = AT91_DEVICENAME,
851 .dev_name = AT91_DEVICENAME,
852 .devfs_name = AT91_DEVICENAME,
853 .major = SERIAL_AT91_MAJOR,
854 .minor = MINOR_START,
856 .cons = AT91_CONSOLE_DEVICE,
859 static int __init at91_serial_init(void)
865 ret = uart_register_driver(&at91_uart);
869 for (i = 0; i < AT91_NR_UART; i++) {
870 if (at91_serial_map[i] >= 0)
871 uart_add_one_port(&at91_uart, &at91_ports[i]);
877 static void __exit at91_serial_exit(void)
881 for (i = 0; i < AT91_NR_UART; i++) {
882 if (at91_serial_map[i] >= 0)
883 uart_remove_one_port(&at91_uart, &at91_ports[i]);
886 uart_unregister_driver(&at91_uart);
889 module_init(at91_serial_init);
890 module_exit(at91_serial_exit);
892 MODULE_AUTHOR("Rick Bronson");
893 MODULE_DESCRIPTION("AT91 generic serial port driver");
894 MODULE_LICENSE("GPL");