blob: 1a259cee1a986854da0aa4de1563829261a41022 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/serial/serial_txx9.c
3 *
4 * Derived from many drivers using generic_serial interface,
5 * especially serial_tx3912.c by Steven J. Hill and r39xx_serial.c
6 * (was in Linux/VR tree) by Jim Pick.
7 *
8 * Copyright (C) 1999 Harald Koerfgen
9 * Copyright (C) 2000 Jim Pick <jim@jimpick.com>
10 * Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
11 * Copyright (C) 2000-2002 Toshiba Corporation
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 *
17 * Serial driver for TX3927/TX4927/TX4925/TX4938 internal SIO controller
18 *
19 * Revision History:
20 * 0.30 Initial revision. (Renamed from serial_txx927.c)
21 * 0.31 Use save_flags instead of local_irq_save.
22 * 0.32 Support SCLK.
23 * 0.33 Switch TXX9_TTY_NAME by CONFIG_SERIAL_TXX9_STDSERIAL.
24 * Support TIOCSERGETLSR.
25 * 0.34 Support slow baudrate.
26 * 0.40 Merge codes from mainstream kernel (2.4.22).
27 * 0.41 Fix console checking in rs_shutdown_port().
28 * Disable flow-control in serial_console_write().
29 * 0.42 Fix minor compiler warning.
30 * 1.00 Kernel 2.6. Converted to new serial core (based on 8250.c).
31 * 1.01 Set fifosize to make tx_empry called properly.
32 * Use standard uart_get_divisor.
33 * 1.02 Cleanup. (import 8250.c changes)
Ralf Baechlef5ee56c2005-09-09 13:01:32 -070034 * 1.03 Fix low-latency mode. (import 8250.c changes)
35 * 1.04 Remove usage of deprecated functions, cleanup.
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 */
37#include <linux/config.h>
38
39#if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
40#define SUPPORT_SYSRQ
41#endif
42
43#include <linux/module.h>
44#include <linux/ioport.h>
45#include <linux/init.h>
46#include <linux/console.h>
47#include <linux/sysrq.h>
48#include <linux/delay.h>
49#include <linux/device.h>
50#include <linux/pci.h>
51#include <linux/tty.h>
52#include <linux/tty_flip.h>
53#include <linux/serial_core.h>
54#include <linux/serial.h>
Arjan van de Venf392ecf2006-01-12 18:44:32 +000055#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57#include <asm/io.h>
58#include <asm/irq.h>
59
Ralf Baechlef5ee56c2005-09-09 13:01:32 -070060static char *serial_version = "1.04";
Linus Torvalds1da177e2005-04-16 15:20:36 -070061static char *serial_name = "TX39/49 Serial driver";
62
63#define PASS_LIMIT 256
64
65#if !defined(CONFIG_SERIAL_TXX9_STDSERIAL)
66/* "ttyS" is used for standard serial driver */
67#define TXX9_TTY_NAME "ttyTX"
68#define TXX9_TTY_DEVFS_NAME "tttx/"
69#define TXX9_TTY_MINOR_START (64 + 64) /* ttyTX0(128), ttyTX1(129) */
70#else
71/* acts like standard serial driver */
72#define TXX9_TTY_NAME "ttyS"
73#define TXX9_TTY_DEVFS_NAME "tts/"
74#define TXX9_TTY_MINOR_START 64
75#endif
76#define TXX9_TTY_MAJOR TTY_MAJOR
77
78/* flag aliases */
79#define UPF_TXX9_HAVE_CTS_LINE UPF_BUGGY_UART
80#define UPF_TXX9_USE_SCLK UPF_MAGIC_MULTIPLIER
81
82#ifdef CONFIG_PCI
83/* support for Toshiba TC86C001 SIO */
84#define ENABLE_SERIAL_TXX9_PCI
85#endif
86
87/*
88 * Number of serial ports
89 */
90#ifdef ENABLE_SERIAL_TXX9_PCI
91#define NR_PCI_BOARDS 4
Ralf Baechlef5ee56c2005-09-09 13:01:32 -070092#define UART_NR (4 + NR_PCI_BOARDS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#else
Ralf Baechlef5ee56c2005-09-09 13:01:32 -070094#define UART_NR 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#endif
96
97struct uart_txx9_port {
98 struct uart_port port;
99
100 /*
101 * We provide a per-port pm hook.
102 */
103 void (*pm)(struct uart_port *port,
104 unsigned int state, unsigned int old);
105};
106
107#define TXX9_REGION_SIZE 0x24
108
109/* TXX9 Serial Registers */
110#define TXX9_SILCR 0x00
111#define TXX9_SIDICR 0x04
112#define TXX9_SIDISR 0x08
113#define TXX9_SICISR 0x0c
114#define TXX9_SIFCR 0x10
115#define TXX9_SIFLCR 0x14
116#define TXX9_SIBGR 0x18
117#define TXX9_SITFIFO 0x1c
118#define TXX9_SIRFIFO 0x20
119
120/* SILCR : Line Control */
121#define TXX9_SILCR_SCS_MASK 0x00000060
122#define TXX9_SILCR_SCS_IMCLK 0x00000000
123#define TXX9_SILCR_SCS_IMCLK_BG 0x00000020
124#define TXX9_SILCR_SCS_SCLK 0x00000040
125#define TXX9_SILCR_SCS_SCLK_BG 0x00000060
126#define TXX9_SILCR_UEPS 0x00000010
127#define TXX9_SILCR_UPEN 0x00000008
128#define TXX9_SILCR_USBL_MASK 0x00000004
129#define TXX9_SILCR_USBL_1BIT 0x00000000
130#define TXX9_SILCR_USBL_2BIT 0x00000004
131#define TXX9_SILCR_UMODE_MASK 0x00000003
132#define TXX9_SILCR_UMODE_8BIT 0x00000000
133#define TXX9_SILCR_UMODE_7BIT 0x00000001
134
135/* SIDICR : DMA/Int. Control */
136#define TXX9_SIDICR_TDE 0x00008000
137#define TXX9_SIDICR_RDE 0x00004000
138#define TXX9_SIDICR_TIE 0x00002000
139#define TXX9_SIDICR_RIE 0x00001000
140#define TXX9_SIDICR_SPIE 0x00000800
141#define TXX9_SIDICR_CTSAC 0x00000600
142#define TXX9_SIDICR_STIE_MASK 0x0000003f
143#define TXX9_SIDICR_STIE_OERS 0x00000020
144#define TXX9_SIDICR_STIE_CTSS 0x00000010
145#define TXX9_SIDICR_STIE_RBRKD 0x00000008
146#define TXX9_SIDICR_STIE_TRDY 0x00000004
147#define TXX9_SIDICR_STIE_TXALS 0x00000002
148#define TXX9_SIDICR_STIE_UBRKD 0x00000001
149
150/* SIDISR : DMA/Int. Status */
151#define TXX9_SIDISR_UBRK 0x00008000
152#define TXX9_SIDISR_UVALID 0x00004000
153#define TXX9_SIDISR_UFER 0x00002000
154#define TXX9_SIDISR_UPER 0x00001000
155#define TXX9_SIDISR_UOER 0x00000800
156#define TXX9_SIDISR_ERI 0x00000400
157#define TXX9_SIDISR_TOUT 0x00000200
158#define TXX9_SIDISR_TDIS 0x00000100
159#define TXX9_SIDISR_RDIS 0x00000080
160#define TXX9_SIDISR_STIS 0x00000040
161#define TXX9_SIDISR_RFDN_MASK 0x0000001f
162
163/* SICISR : Change Int. Status */
164#define TXX9_SICISR_OERS 0x00000020
165#define TXX9_SICISR_CTSS 0x00000010
166#define TXX9_SICISR_RBRKD 0x00000008
167#define TXX9_SICISR_TRDY 0x00000004
168#define TXX9_SICISR_TXALS 0x00000002
169#define TXX9_SICISR_UBRKD 0x00000001
170
171/* SIFCR : FIFO Control */
172#define TXX9_SIFCR_SWRST 0x00008000
173#define TXX9_SIFCR_RDIL_MASK 0x00000180
174#define TXX9_SIFCR_RDIL_1 0x00000000
175#define TXX9_SIFCR_RDIL_4 0x00000080
176#define TXX9_SIFCR_RDIL_8 0x00000100
177#define TXX9_SIFCR_RDIL_12 0x00000180
178#define TXX9_SIFCR_RDIL_MAX 0x00000180
179#define TXX9_SIFCR_TDIL_MASK 0x00000018
180#define TXX9_SIFCR_TDIL_MASK 0x00000018
181#define TXX9_SIFCR_TDIL_1 0x00000000
182#define TXX9_SIFCR_TDIL_4 0x00000001
183#define TXX9_SIFCR_TDIL_8 0x00000010
184#define TXX9_SIFCR_TDIL_MAX 0x00000010
185#define TXX9_SIFCR_TFRST 0x00000004
186#define TXX9_SIFCR_RFRST 0x00000002
187#define TXX9_SIFCR_FRSTE 0x00000001
188#define TXX9_SIO_TX_FIFO 8
189#define TXX9_SIO_RX_FIFO 16
190
191/* SIFLCR : Flow Control */
192#define TXX9_SIFLCR_RCS 0x00001000
193#define TXX9_SIFLCR_TES 0x00000800
194#define TXX9_SIFLCR_RTSSC 0x00000200
195#define TXX9_SIFLCR_RSDE 0x00000100
196#define TXX9_SIFLCR_TSDE 0x00000080
197#define TXX9_SIFLCR_RTSTL_MASK 0x0000001e
198#define TXX9_SIFLCR_RTSTL_MAX 0x0000001e
199#define TXX9_SIFLCR_TBRK 0x00000001
200
201/* SIBGR : Baudrate Control */
202#define TXX9_SIBGR_BCLK_MASK 0x00000300
203#define TXX9_SIBGR_BCLK_T0 0x00000000
204#define TXX9_SIBGR_BCLK_T2 0x00000100
205#define TXX9_SIBGR_BCLK_T4 0x00000200
206#define TXX9_SIBGR_BCLK_T6 0x00000300
207#define TXX9_SIBGR_BRD_MASK 0x000000ff
208
209static inline unsigned int sio_in(struct uart_txx9_port *up, int offset)
210{
211 switch (up->port.iotype) {
212 default:
213 return *(volatile u32 *)(up->port.membase + offset);
214 case UPIO_PORT:
215 return inl(up->port.iobase + offset);
216 }
217}
218
219static inline void
220sio_out(struct uart_txx9_port *up, int offset, int value)
221{
222 switch (up->port.iotype) {
223 default:
224 *(volatile u32 *)(up->port.membase + offset) = value;
225 break;
226 case UPIO_PORT:
227 outl(value, up->port.iobase + offset);
228 break;
229 }
230}
231
232static inline void
233sio_mask(struct uart_txx9_port *up, int offset, unsigned int value)
234{
235 sio_out(up, offset, sio_in(up, offset) & ~value);
236}
237static inline void
238sio_set(struct uart_txx9_port *up, int offset, unsigned int value)
239{
240 sio_out(up, offset, sio_in(up, offset) | value);
241}
242
243static inline void
244sio_quot_set(struct uart_txx9_port *up, int quot)
245{
246 quot >>= 1;
247 if (quot < 256)
248 sio_out(up, TXX9_SIBGR, quot | TXX9_SIBGR_BCLK_T0);
249 else if (quot < (256 << 2))
250 sio_out(up, TXX9_SIBGR, (quot >> 2) | TXX9_SIBGR_BCLK_T2);
251 else if (quot < (256 << 4))
252 sio_out(up, TXX9_SIBGR, (quot >> 4) | TXX9_SIBGR_BCLK_T4);
253 else if (quot < (256 << 6))
254 sio_out(up, TXX9_SIBGR, (quot >> 6) | TXX9_SIBGR_BCLK_T6);
255 else
256 sio_out(up, TXX9_SIBGR, 0xff | TXX9_SIBGR_BCLK_T6);
257}
258
Russell Kingb129a8c2005-08-31 10:12:14 +0100259static void serial_txx9_stop_tx(struct uart_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260{
261 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
262 unsigned long flags;
263
264 spin_lock_irqsave(&up->port.lock, flags);
265 sio_mask(up, TXX9_SIDICR, TXX9_SIDICR_TIE);
266 spin_unlock_irqrestore(&up->port.lock, flags);
267}
268
Russell Kingb129a8c2005-08-31 10:12:14 +0100269static void serial_txx9_start_tx(struct uart_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270{
271 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
272 unsigned long flags;
273
274 spin_lock_irqsave(&up->port.lock, flags);
275 sio_set(up, TXX9_SIDICR, TXX9_SIDICR_TIE);
276 spin_unlock_irqrestore(&up->port.lock, flags);
277}
278
279static void serial_txx9_stop_rx(struct uart_port *port)
280{
281 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
282 unsigned long flags;
283
284 spin_lock_irqsave(&up->port.lock, flags);
285 up->port.read_status_mask &= ~TXX9_SIDISR_RDIS;
286#if 0
287 sio_mask(up, TXX9_SIDICR, TXX9_SIDICR_RIE);
288#endif
289 spin_unlock_irqrestore(&up->port.lock, flags);
290}
291
292static void serial_txx9_enable_ms(struct uart_port *port)
293{
294 /* TXX9-SIO can not control DTR... */
295}
296
297static inline void
298receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *regs)
299{
300 struct tty_struct *tty = up->port.info->tty;
301 unsigned char ch;
302 unsigned int disr = *status;
303 int max_count = 256;
304 char flag;
305
306 do {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 ch = sio_in(up, TXX9_SIRFIFO);
308 flag = TTY_NORMAL;
309 up->port.icount.rx++;
310
311 if (unlikely(disr & (TXX9_SIDISR_UBRK | TXX9_SIDISR_UPER |
312 TXX9_SIDISR_UFER | TXX9_SIDISR_UOER))) {
313 /*
314 * For statistics only
315 */
316 if (disr & TXX9_SIDISR_UBRK) {
317 disr &= ~(TXX9_SIDISR_UFER | TXX9_SIDISR_UPER);
318 up->port.icount.brk++;
319 /*
320 * We do the SysRQ and SAK checking
321 * here because otherwise the break
322 * may get masked by ignore_status_mask
323 * or read_status_mask.
324 */
325 if (uart_handle_break(&up->port))
326 goto ignore_char;
327 } else if (disr & TXX9_SIDISR_UPER)
328 up->port.icount.parity++;
329 else if (disr & TXX9_SIDISR_UFER)
330 up->port.icount.frame++;
331 if (disr & TXX9_SIDISR_UOER)
332 up->port.icount.overrun++;
333
334 /*
335 * Mask off conditions which should be ingored.
336 */
337 disr &= up->port.read_status_mask;
338
339 if (disr & TXX9_SIDISR_UBRK) {
340 flag = TTY_BREAK;
341 } else if (disr & TXX9_SIDISR_UPER)
342 flag = TTY_PARITY;
343 else if (disr & TXX9_SIDISR_UFER)
344 flag = TTY_FRAME;
345 }
346 if (uart_handle_sysrq_char(&up->port, ch, regs))
347 goto ignore_char;
Russell King05ab3012005-05-09 23:21:59 +0100348
349 uart_insert_char(&up->port, disr, TXX9_SIDISR_UOER, ch, flag);
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 ignore_char:
352 disr = sio_in(up, TXX9_SIDISR);
353 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0));
Ralf Baechlef5ee56c2005-09-09 13:01:32 -0700354 spin_unlock(&up->port.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 tty_flip_buffer_push(tty);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -0700356 spin_lock(&up->port.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 *status = disr;
358}
359
360static inline void transmit_chars(struct uart_txx9_port *up)
361{
362 struct circ_buf *xmit = &up->port.info->xmit;
363 int count;
364
365 if (up->port.x_char) {
366 sio_out(up, TXX9_SITFIFO, up->port.x_char);
367 up->port.icount.tx++;
368 up->port.x_char = 0;
369 return;
370 }
371 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
Russell Kingb129a8c2005-08-31 10:12:14 +0100372 serial_txx9_stop_tx(&up->port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 return;
374 }
375
376 count = TXX9_SIO_TX_FIFO;
377 do {
378 sio_out(up, TXX9_SITFIFO, xmit->buf[xmit->tail]);
379 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
380 up->port.icount.tx++;
381 if (uart_circ_empty(xmit))
382 break;
383 } while (--count > 0);
384
385 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
386 uart_write_wakeup(&up->port);
387
388 if (uart_circ_empty(xmit))
Russell Kingb129a8c2005-08-31 10:12:14 +0100389 serial_txx9_stop_tx(&up->port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
392static irqreturn_t serial_txx9_interrupt(int irq, void *dev_id, struct pt_regs *regs)
393{
394 int pass_counter = 0;
395 struct uart_txx9_port *up = dev_id;
396 unsigned int status;
397
398 while (1) {
399 spin_lock(&up->port.lock);
400 status = sio_in(up, TXX9_SIDISR);
401 if (!(sio_in(up, TXX9_SIDICR) & TXX9_SIDICR_TIE))
402 status &= ~TXX9_SIDISR_TDIS;
403 if (!(status & (TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS |
404 TXX9_SIDISR_TOUT))) {
405 spin_unlock(&up->port.lock);
406 break;
407 }
408
409 if (status & TXX9_SIDISR_RDIS)
410 receive_chars(up, &status, regs);
411 if (status & TXX9_SIDISR_TDIS)
412 transmit_chars(up);
413 /* Clear TX/RX Int. Status */
414 sio_mask(up, TXX9_SIDISR,
415 TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS |
416 TXX9_SIDISR_TOUT);
417 spin_unlock(&up->port.lock);
418
419 if (pass_counter++ > PASS_LIMIT)
420 break;
421 }
422
423 return pass_counter ? IRQ_HANDLED : IRQ_NONE;
424}
425
426static unsigned int serial_txx9_tx_empty(struct uart_port *port)
427{
428 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
429 unsigned long flags;
430 unsigned int ret;
431
432 spin_lock_irqsave(&up->port.lock, flags);
433 ret = (sio_in(up, TXX9_SICISR) & TXX9_SICISR_TXALS) ? TIOCSER_TEMT : 0;
434 spin_unlock_irqrestore(&up->port.lock, flags);
435
436 return ret;
437}
438
439static unsigned int serial_txx9_get_mctrl(struct uart_port *port)
440{
441 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 unsigned int ret;
443
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 ret = ((sio_in(up, TXX9_SIFLCR) & TXX9_SIFLCR_RTSSC) ? 0 : TIOCM_RTS)
445 | ((sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS) ? 0 : TIOCM_CTS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
447 return ret;
448}
449
450static void serial_txx9_set_mctrl(struct uart_port *port, unsigned int mctrl)
451{
452 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
453 unsigned long flags;
454
455 spin_lock_irqsave(&up->port.lock, flags);
456 if (mctrl & TIOCM_RTS)
457 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSSC);
458 else
459 sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSSC);
460 spin_unlock_irqrestore(&up->port.lock, flags);
461}
462
463static void serial_txx9_break_ctl(struct uart_port *port, int break_state)
464{
465 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
466 unsigned long flags;
467
468 spin_lock_irqsave(&up->port.lock, flags);
469 if (break_state == -1)
470 sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK);
471 else
472 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK);
473 spin_unlock_irqrestore(&up->port.lock, flags);
474}
475
476static int serial_txx9_startup(struct uart_port *port)
477{
478 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
479 unsigned long flags;
480 int retval;
481
482 /*
483 * Clear the FIFO buffers and disable them.
484 * (they will be reeanbled in set_termios())
485 */
486 sio_set(up, TXX9_SIFCR,
487 TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
488 /* clear reset */
489 sio_mask(up, TXX9_SIFCR,
490 TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
491 sio_out(up, TXX9_SIDICR, 0);
492
493 /*
494 * Clear the interrupt registers.
495 */
496 sio_out(up, TXX9_SIDISR, 0);
497
498 retval = request_irq(up->port.irq, serial_txx9_interrupt,
499 SA_SHIRQ, "serial_txx9", up);
500 if (retval)
501 return retval;
502
503 /*
504 * Now, initialize the UART
505 */
506 spin_lock_irqsave(&up->port.lock, flags);
507 serial_txx9_set_mctrl(&up->port, up->port.mctrl);
508 spin_unlock_irqrestore(&up->port.lock, flags);
509
510 /* Enable RX/TX */
511 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_RSDE | TXX9_SIFLCR_TSDE);
512
513 /*
514 * Finally, enable interrupts.
515 */
516 sio_set(up, TXX9_SIDICR, TXX9_SIDICR_RIE);
517
518 return 0;
519}
520
521static void serial_txx9_shutdown(struct uart_port *port)
522{
523 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
524 unsigned long flags;
525
526 /*
527 * Disable interrupts from this port
528 */
529 sio_out(up, TXX9_SIDICR, 0); /* disable all intrs */
530
531 spin_lock_irqsave(&up->port.lock, flags);
532 serial_txx9_set_mctrl(&up->port, up->port.mctrl);
533 spin_unlock_irqrestore(&up->port.lock, flags);
534
535 /*
536 * Disable break condition
537 */
538 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK);
539
540#ifdef CONFIG_SERIAL_TXX9_CONSOLE
541 if (up->port.cons && up->port.line == up->port.cons->index) {
542 free_irq(up->port.irq, up);
543 return;
544 }
545#endif
546 /* reset FIFOs */
547 sio_set(up, TXX9_SIFCR,
548 TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
549 /* clear reset */
550 sio_mask(up, TXX9_SIFCR,
551 TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
552
553 /* Disable RX/TX */
554 sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_RSDE | TXX9_SIFLCR_TSDE);
555
556 free_irq(up->port.irq, up);
557}
558
559static void
560serial_txx9_set_termios(struct uart_port *port, struct termios *termios,
561 struct termios *old)
562{
563 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
564 unsigned int cval, fcr = 0;
565 unsigned long flags;
566 unsigned int baud, quot;
567
568 cval = sio_in(up, TXX9_SILCR);
569 /* byte size and parity */
570 cval &= ~TXX9_SILCR_UMODE_MASK;
571 switch (termios->c_cflag & CSIZE) {
572 case CS7:
573 cval |= TXX9_SILCR_UMODE_7BIT;
574 break;
575 default:
576 case CS5: /* not supported */
577 case CS6: /* not supported */
578 case CS8:
579 cval |= TXX9_SILCR_UMODE_8BIT;
580 break;
581 }
582
583 cval &= ~TXX9_SILCR_USBL_MASK;
584 if (termios->c_cflag & CSTOPB)
585 cval |= TXX9_SILCR_USBL_2BIT;
586 else
587 cval |= TXX9_SILCR_USBL_1BIT;
588 cval &= ~(TXX9_SILCR_UPEN | TXX9_SILCR_UEPS);
589 if (termios->c_cflag & PARENB)
590 cval |= TXX9_SILCR_UPEN;
591 if (!(termios->c_cflag & PARODD))
592 cval |= TXX9_SILCR_UEPS;
593
594 /*
595 * Ask the core to calculate the divisor for us.
596 */
597 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16/2);
598 quot = uart_get_divisor(port, baud);
599
600 /* Set up FIFOs */
601 /* TX Int by FIFO Empty, RX Int by Receiving 1 char. */
602 fcr = TXX9_SIFCR_TDIL_MAX | TXX9_SIFCR_RDIL_1;
603
604 /*
605 * Ok, we're now changing the port state. Do it with
606 * interrupts disabled.
607 */
608 spin_lock_irqsave(&up->port.lock, flags);
609
610 /*
611 * Update the per-port timeout.
612 */
613 uart_update_timeout(port, termios->c_cflag, baud);
614
615 up->port.read_status_mask = TXX9_SIDISR_UOER |
616 TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS;
617 if (termios->c_iflag & INPCK)
618 up->port.read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER;
619 if (termios->c_iflag & (BRKINT | PARMRK))
620 up->port.read_status_mask |= TXX9_SIDISR_UBRK;
621
622 /*
623 * Characteres to ignore
624 */
625 up->port.ignore_status_mask = 0;
626 if (termios->c_iflag & IGNPAR)
627 up->port.ignore_status_mask |= TXX9_SIDISR_UPER | TXX9_SIDISR_UFER;
628 if (termios->c_iflag & IGNBRK) {
629 up->port.ignore_status_mask |= TXX9_SIDISR_UBRK;
630 /*
631 * If we're ignoring parity and break indicators,
632 * ignore overruns too (for real raw support).
633 */
634 if (termios->c_iflag & IGNPAR)
635 up->port.ignore_status_mask |= TXX9_SIDISR_UOER;
636 }
637
638 /*
639 * ignore all characters if CREAD is not set
640 */
641 if ((termios->c_cflag & CREAD) == 0)
642 up->port.ignore_status_mask |= TXX9_SIDISR_RDIS;
643
644 /* CTS flow control flag */
645 if ((termios->c_cflag & CRTSCTS) &&
646 (up->port.flags & UPF_TXX9_HAVE_CTS_LINE)) {
647 sio_set(up, TXX9_SIFLCR,
648 TXX9_SIFLCR_RCS | TXX9_SIFLCR_TES);
649 } else {
650 sio_mask(up, TXX9_SIFLCR,
651 TXX9_SIFLCR_RCS | TXX9_SIFLCR_TES);
652 }
653
654 sio_out(up, TXX9_SILCR, cval);
655 sio_quot_set(up, quot);
656 sio_out(up, TXX9_SIFCR, fcr);
657
658 serial_txx9_set_mctrl(&up->port, up->port.mctrl);
659 spin_unlock_irqrestore(&up->port.lock, flags);
660}
661
662static void
663serial_txx9_pm(struct uart_port *port, unsigned int state,
664 unsigned int oldstate)
665{
666 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
Ralf Baechlef5ee56c2005-09-09 13:01:32 -0700667 if (up->pm)
668 up->pm(port, state, oldstate);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669}
670
671static int serial_txx9_request_resource(struct uart_txx9_port *up)
672{
673 unsigned int size = TXX9_REGION_SIZE;
674 int ret = 0;
675
676 switch (up->port.iotype) {
677 default:
678 if (!up->port.mapbase)
679 break;
680
681 if (!request_mem_region(up->port.mapbase, size, "serial_txx9")) {
682 ret = -EBUSY;
683 break;
684 }
685
686 if (up->port.flags & UPF_IOREMAP) {
687 up->port.membase = ioremap(up->port.mapbase, size);
688 if (!up->port.membase) {
689 release_mem_region(up->port.mapbase, size);
690 ret = -ENOMEM;
691 }
692 }
693 break;
694
695 case UPIO_PORT:
696 if (!request_region(up->port.iobase, size, "serial_txx9"))
697 ret = -EBUSY;
698 break;
699 }
700 return ret;
701}
702
703static void serial_txx9_release_resource(struct uart_txx9_port *up)
704{
705 unsigned int size = TXX9_REGION_SIZE;
706
707 switch (up->port.iotype) {
708 default:
709 if (!up->port.mapbase)
710 break;
711
712 if (up->port.flags & UPF_IOREMAP) {
713 iounmap(up->port.membase);
714 up->port.membase = NULL;
715 }
716
717 release_mem_region(up->port.mapbase, size);
718 break;
719
720 case UPIO_PORT:
721 release_region(up->port.iobase, size);
722 break;
723 }
724}
725
726static void serial_txx9_release_port(struct uart_port *port)
727{
728 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
729 serial_txx9_release_resource(up);
730}
731
732static int serial_txx9_request_port(struct uart_port *port)
733{
734 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
735 return serial_txx9_request_resource(up);
736}
737
738static void serial_txx9_config_port(struct uart_port *port, int uflags)
739{
740 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
741 unsigned long flags;
742 int ret;
743
744 /*
745 * Find the region that we can probe for. This in turn
746 * tells us whether we can probe for the type of port.
747 */
748 ret = serial_txx9_request_resource(up);
749 if (ret < 0)
750 return;
751 port->type = PORT_TXX9;
752 up->port.fifosize = TXX9_SIO_TX_FIFO;
753
754#ifdef CONFIG_SERIAL_TXX9_CONSOLE
755 if (up->port.line == up->port.cons->index)
756 return;
757#endif
758 spin_lock_irqsave(&up->port.lock, flags);
759 /*
760 * Reset the UART.
761 */
762 sio_out(up, TXX9_SIFCR, TXX9_SIFCR_SWRST);
763#ifdef CONFIG_CPU_TX49XX
764 /* TX4925 BUG WORKAROUND. Accessing SIOC register
765 * immediately after soft reset causes bus error. */
766 iob();
767 udelay(1);
768#endif
769 while (sio_in(up, TXX9_SIFCR) & TXX9_SIFCR_SWRST)
770 ;
771 /* TX Int by FIFO Empty, RX Int by Receiving 1 char. */
772 sio_set(up, TXX9_SIFCR,
773 TXX9_SIFCR_TDIL_MAX | TXX9_SIFCR_RDIL_1);
774 /* initial settings */
775 sio_out(up, TXX9_SILCR,
776 TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT |
777 ((up->port.flags & UPF_TXX9_USE_SCLK) ?
778 TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG));
779 sio_quot_set(up, uart_get_divisor(port, 9600));
780 sio_out(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSTL_MAX /* 15 */);
781 spin_unlock_irqrestore(&up->port.lock, flags);
782}
783
784static int
785serial_txx9_verify_port(struct uart_port *port, struct serial_struct *ser)
786{
787 if (ser->irq < 0 ||
788 ser->baud_base < 9600 || ser->type != PORT_TXX9)
789 return -EINVAL;
790 return 0;
791}
792
793static const char *
794serial_txx9_type(struct uart_port *port)
795{
796 return "txx9";
797}
798
799static struct uart_ops serial_txx9_pops = {
800 .tx_empty = serial_txx9_tx_empty,
801 .set_mctrl = serial_txx9_set_mctrl,
802 .get_mctrl = serial_txx9_get_mctrl,
803 .stop_tx = serial_txx9_stop_tx,
804 .start_tx = serial_txx9_start_tx,
805 .stop_rx = serial_txx9_stop_rx,
806 .enable_ms = serial_txx9_enable_ms,
807 .break_ctl = serial_txx9_break_ctl,
808 .startup = serial_txx9_startup,
809 .shutdown = serial_txx9_shutdown,
810 .set_termios = serial_txx9_set_termios,
811 .pm = serial_txx9_pm,
812 .type = serial_txx9_type,
813 .release_port = serial_txx9_release_port,
814 .request_port = serial_txx9_request_port,
815 .config_port = serial_txx9_config_port,
816 .verify_port = serial_txx9_verify_port,
817};
818
819static struct uart_txx9_port serial_txx9_ports[UART_NR];
820
821static void __init serial_txx9_register_ports(struct uart_driver *drv)
822{
823 int i;
824
825 for (i = 0; i < UART_NR; i++) {
826 struct uart_txx9_port *up = &serial_txx9_ports[i];
827
828 up->port.line = i;
829 up->port.ops = &serial_txx9_pops;
830 uart_add_one_port(drv, &up->port);
831 }
832}
833
834#ifdef CONFIG_SERIAL_TXX9_CONSOLE
835
836/*
837 * Wait for transmitter & holding register to empty
838 */
839static inline void wait_for_xmitr(struct uart_txx9_port *up)
840{
841 unsigned int tmout = 10000;
842
843 /* Wait up to 10ms for the character(s) to be sent. */
844 while (--tmout &&
845 !(sio_in(up, TXX9_SICISR) & TXX9_SICISR_TXALS))
846 udelay(1);
847
848 /* Wait up to 1s for flow control if necessary */
849 if (up->port.flags & UPF_CONS_FLOW) {
850 tmout = 1000000;
851 while (--tmout &&
852 (sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS))
853 udelay(1);
854 }
855}
856
Russell Kingd3587882006-03-20 20:00:09 +0000857static void serial_txx9_console_putchar(struct uart_port *port, int ch)
858{
859 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
860
861 wait_for_xmitr(up);
862 sio_out(up, TXX9_SITFIFO, ch);
863}
864
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865/*
866 * Print a string to the serial port trying not to disturb
867 * any possible real use of the port...
868 *
869 * The console_lock must be held when we get here.
870 */
871static void
872serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
873{
874 struct uart_txx9_port *up = &serial_txx9_ports[co->index];
875 unsigned int ier, flcr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876
877 /*
878 * First save the UER then disable the interrupts
879 */
880 ier = sio_in(up, TXX9_SIDICR);
881 sio_out(up, TXX9_SIDICR, 0);
882 /*
883 * Disable flow-control if enabled (and unnecessary)
884 */
885 flcr = sio_in(up, TXX9_SIFLCR);
886 if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES))
887 sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES);
888
Russell Kingd3587882006-03-20 20:00:09 +0000889 uart_console_write(&up->port, s, count, serial_txx9_console_putchar);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890
891 /*
892 * Finally, wait for transmitter to become empty
893 * and restore the IER
894 */
895 wait_for_xmitr(up);
896 sio_out(up, TXX9_SIFLCR, flcr);
897 sio_out(up, TXX9_SIDICR, ier);
898}
899
900static int serial_txx9_console_setup(struct console *co, char *options)
901{
902 struct uart_port *port;
903 struct uart_txx9_port *up;
904 int baud = 9600;
905 int bits = 8;
906 int parity = 'n';
907 int flow = 'n';
908
909 /*
910 * Check whether an invalid uart number has been specified, and
911 * if so, search for the first available port that does have
912 * console support.
913 */
914 if (co->index >= UART_NR)
915 co->index = 0;
916 up = &serial_txx9_ports[co->index];
917 port = &up->port;
918 if (!port->ops)
919 return -ENODEV;
920
921 /*
922 * Temporary fix.
923 */
924 spin_lock_init(&port->lock);
925
926 /*
927 * Disable UART interrupts, set DTR and RTS high
928 * and set speed.
929 */
930 sio_out(up, TXX9_SIDICR, 0);
931 /* initial settings */
932 sio_out(up, TXX9_SILCR,
933 TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT |
934 ((port->flags & UPF_TXX9_USE_SCLK) ?
935 TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG));
936 sio_out(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSTL_MAX /* 15 */);
937
938 if (options)
939 uart_parse_options(options, &baud, &parity, &bits, &flow);
940
941 return uart_set_options(port, co, baud, parity, bits, flow);
942}
943
944static struct uart_driver serial_txx9_reg;
945static struct console serial_txx9_console = {
946 .name = TXX9_TTY_NAME,
947 .write = serial_txx9_console_write,
948 .device = uart_console_device,
949 .setup = serial_txx9_console_setup,
950 .flags = CON_PRINTBUFFER,
951 .index = -1,
952 .data = &serial_txx9_reg,
953};
954
955static int __init serial_txx9_console_init(void)
956{
957 register_console(&serial_txx9_console);
958 return 0;
959}
960console_initcall(serial_txx9_console_init);
961
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962#define SERIAL_TXX9_CONSOLE &serial_txx9_console
963#else
964#define SERIAL_TXX9_CONSOLE NULL
965#endif
966
967static struct uart_driver serial_txx9_reg = {
968 .owner = THIS_MODULE,
969 .driver_name = "serial_txx9",
970 .devfs_name = TXX9_TTY_DEVFS_NAME,
971 .dev_name = TXX9_TTY_NAME,
972 .major = TXX9_TTY_MAJOR,
973 .minor = TXX9_TTY_MINOR_START,
974 .nr = UART_NR,
975 .cons = SERIAL_TXX9_CONSOLE,
976};
977
978int __init early_serial_txx9_setup(struct uart_port *port)
979{
980 if (port->line >= ARRAY_SIZE(serial_txx9_ports))
981 return -ENODEV;
982
983 serial_txx9_ports[port->line].port = *port;
984 serial_txx9_ports[port->line].port.ops = &serial_txx9_pops;
985 serial_txx9_ports[port->line].port.flags |= UPF_BOOT_AUTOCONF;
986 return 0;
987}
988
989#ifdef ENABLE_SERIAL_TXX9_PCI
990/**
991 * serial_txx9_suspend_port - suspend one serial port
992 * @line: serial line number
993 * @level: the level of port suspension, as per uart_suspend_port
994 *
995 * Suspend one serial port.
996 */
997static void serial_txx9_suspend_port(int line)
998{
999 uart_suspend_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
1000}
1001
1002/**
1003 * serial_txx9_resume_port - resume one serial port
1004 * @line: serial line number
1005 * @level: the level of port resumption, as per uart_resume_port
1006 *
1007 * Resume one serial port.
1008 */
1009static void serial_txx9_resume_port(int line)
1010{
1011 uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
1012}
1013
Arjan van de Venf392ecf2006-01-12 18:44:32 +00001014static DEFINE_MUTEX(serial_txx9_mutex);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001015
1016/**
1017 * serial_txx9_register_port - register a serial port
1018 * @port: serial port template
1019 *
1020 * Configure the serial port specified by the request.
1021 *
1022 * The port is then probed and if necessary the IRQ is autodetected
1023 * If this fails an error is returned.
1024 *
1025 * On success the port is ready to use and the line number is returned.
1026 */
1027static int __devinit serial_txx9_register_port(struct uart_port *port)
1028{
1029 int i;
1030 struct uart_txx9_port *uart;
1031 int ret = -ENOSPC;
1032
Arjan van de Venf392ecf2006-01-12 18:44:32 +00001033 mutex_lock(&serial_txx9_mutex);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001034 for (i = 0; i < UART_NR; i++) {
1035 uart = &serial_txx9_ports[i];
1036 if (uart->port.type == PORT_UNKNOWN)
1037 break;
1038 }
1039 if (i < UART_NR) {
1040 uart_remove_one_port(&serial_txx9_reg, &uart->port);
1041 uart->port.iobase = port->iobase;
1042 uart->port.membase = port->membase;
1043 uart->port.irq = port->irq;
1044 uart->port.uartclk = port->uartclk;
1045 uart->port.iotype = port->iotype;
1046 uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
1047 uart->port.mapbase = port->mapbase;
1048 if (port->dev)
1049 uart->port.dev = port->dev;
1050 ret = uart_add_one_port(&serial_txx9_reg, &uart->port);
1051 if (ret == 0)
1052 ret = uart->port.line;
1053 }
Arjan van de Venf392ecf2006-01-12 18:44:32 +00001054 mutex_unlock(&serial_txx9_mutex);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001055 return ret;
1056}
1057
1058/**
1059 * serial_txx9_unregister_port - remove a txx9 serial port at runtime
1060 * @line: serial line number
1061 *
1062 * Remove one serial port. This may not be called from interrupt
1063 * context. We hand the port back to the our control.
1064 */
1065static void __devexit serial_txx9_unregister_port(int line)
1066{
1067 struct uart_txx9_port *uart = &serial_txx9_ports[line];
1068
Arjan van de Venf392ecf2006-01-12 18:44:32 +00001069 mutex_lock(&serial_txx9_mutex);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001070 uart_remove_one_port(&serial_txx9_reg, &uart->port);
1071 uart->port.flags = 0;
1072 uart->port.type = PORT_UNKNOWN;
1073 uart->port.iobase = 0;
1074 uart->port.mapbase = 0;
1075 uart->port.membase = 0;
1076 uart->port.dev = NULL;
1077 uart_add_one_port(&serial_txx9_reg, &uart->port);
Arjan van de Venf392ecf2006-01-12 18:44:32 +00001078 mutex_unlock(&serial_txx9_mutex);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001079}
1080
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081/*
1082 * Probe one serial board. Unfortunately, there is no rhyme nor reason
1083 * to the arrangement of serial ports on a PCI card.
1084 */
1085static int __devinit
1086pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
1087{
1088 struct uart_port port;
1089 int line;
1090 int rc;
1091
1092 rc = pci_enable_device(dev);
1093 if (rc)
1094 return rc;
1095
1096 memset(&port, 0, sizeof(port));
1097 port.ops = &serial_txx9_pops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 port.flags |= UPF_TXX9_HAVE_CTS_LINE;
1099 port.uartclk = 66670000;
1100 port.irq = dev->irq;
1101 port.iotype = UPIO_PORT;
1102 port.iobase = pci_resource_start(dev, 1);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001103 port.dev = &dev->dev;
1104 line = serial_txx9_register_port(&port);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 if (line < 0) {
1106 printk(KERN_WARNING "Couldn't register serial port %s: %d\n", pci_name(dev), line);
1107 }
1108 pci_set_drvdata(dev, (void *)(long)line);
1109
1110 return 0;
1111}
1112
1113static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev)
1114{
1115 int line = (int)(long)pci_get_drvdata(dev);
1116
1117 pci_set_drvdata(dev, NULL);
1118
1119 if (line) {
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001120 serial_txx9_unregister_port(line);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 pci_disable_device(dev);
1122 }
1123}
1124
Pavel Machek0370aff2005-04-16 15:25:35 -07001125static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126{
1127 int line = (int)(long)pci_get_drvdata(dev);
1128
1129 if (line)
1130 serial_txx9_suspend_port(line);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001131 pci_save_state(dev);
1132 pci_set_power_state(dev, pci_choose_state(dev, state));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 return 0;
1134}
1135
1136static int pciserial_txx9_resume_one(struct pci_dev *dev)
1137{
1138 int line = (int)(long)pci_get_drvdata(dev);
1139
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001140 pci_set_power_state(dev, PCI_D0);
1141 pci_restore_state(dev);
1142
1143 if (line) {
1144 pci_enable_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 serial_txx9_resume_port(line);
Ralf Baechlef5ee56c2005-09-09 13:01:32 -07001146 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 return 0;
1148}
1149
1150static struct pci_device_id serial_txx9_pci_tbl[] = {
1151 { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC,
1152 PCI_ANY_ID, PCI_ANY_ID,
1153 0, 0, 0 },
1154 { 0, }
1155};
1156
1157static struct pci_driver serial_txx9_pci_driver = {
1158 .name = "serial_txx9",
1159 .probe = pciserial_txx9_init_one,
1160 .remove = __devexit_p(pciserial_txx9_remove_one),
1161 .suspend = pciserial_txx9_suspend_one,
1162 .resume = pciserial_txx9_resume_one,
1163 .id_table = serial_txx9_pci_tbl,
1164};
1165
1166MODULE_DEVICE_TABLE(pci, serial_txx9_pci_tbl);
1167#endif /* ENABLE_SERIAL_TXX9_PCI */
1168
1169static int __init serial_txx9_init(void)
1170{
1171 int ret;
1172
1173 printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
1174
1175 ret = uart_register_driver(&serial_txx9_reg);
1176 if (ret >= 0) {
1177 serial_txx9_register_ports(&serial_txx9_reg);
1178
1179#ifdef ENABLE_SERIAL_TXX9_PCI
Richard Knutsson93b47682005-11-30 01:00:35 +01001180 ret = pci_register_driver(&serial_txx9_pci_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181#endif
1182 }
1183 return ret;
1184}
1185
1186static void __exit serial_txx9_exit(void)
1187{
1188 int i;
1189
1190#ifdef ENABLE_SERIAL_TXX9_PCI
1191 pci_unregister_driver(&serial_txx9_pci_driver);
1192#endif
1193 for (i = 0; i < UART_NR; i++)
1194 uart_remove_one_port(&serial_txx9_reg, &serial_txx9_ports[i].port);
1195
1196 uart_unregister_driver(&serial_txx9_reg);
1197}
1198
1199module_init(serial_txx9_init);
1200module_exit(serial_txx9_exit);
1201
1202MODULE_LICENSE("GPL");
1203MODULE_DESCRIPTION("TX39/49 serial driver");
1204
1205MODULE_ALIAS_CHARDEV_MAJOR(TXX9_TTY_MAJOR);