diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-22 19:12:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-22 19:12:24 -0400 |
commit | 94b5aff4c6f72fee6b0f49d49e4fa8b204e8ded9 (patch) | |
tree | 39197121b6ef8cddaa0f4057fe24b4ced58e8982 /drivers/tty/serial | |
parent | 5d4e2d08e7fdf7339f84a1c670d296a77e02f881 (diff) | |
parent | 59bd234b72fc29887839d792b7d6c7e8d2a577a6 (diff) |
Merge tag 'tty-3.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull TTY updates from Greg Kroah-Hartman:
"Here's the big TTY/serial driver pull request for the 3.5-rc1 merge
window.
Nothing major in here, just lots of incremental changes from Alan and
Jiri reworking some tty core things to behave better and to get a more
solid grasp on some of the nasty tty locking issues.
There are a few tty and serial driver updates in here as well.
All of this has been in the linux-next releases for a while with no
problems.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
* tag 'tty-3.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (115 commits)
serial: bfin_uart: Make MMR access compatible with 32 bits bf609 style controller.
serial: bfin_uart: RTS and CTS MMRs can be either 16-bit width or 32-bit width.
serial: bfin_uart: narrow the reboot condition in DMA tx interrupt
serial: bfin_uart: Adapt bf5xx serial driver to bf60x serial4 controller.
Revert "serial_core: Update buffer overrun statistics."
tty: hvc_xen: NULL dereference on allocation failure
tty: Fix LED error return
tty: Allow uart_register/unregister/register
tty: move global ldisc idle waitqueue to the individual ldisc
serial8250-em: Add DT support
serial8250-em: clk_get() IS_ERR() error handling fix
serial_core: Update buffer overrun statistics.
tty: drop the pty lock during hangup
cris: fix missing tty arg in wait_event_interruptible_tty call
tty/amiserial: Add missing argument for tty_unlock()
tty_lock: Localise the lock
pty: Lock the devpts bits privately
tty_lock: undo the old tty_lock use on the ctty
serial8250-em: Emma Mobile UART driver V2
Add missing call to uart_update_timeout()
...
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/68328serial.c | 383 | ||||
-rw-r--r-- | drivers/tty/serial/68328serial.h | 186 | ||||
-rw-r--r-- | drivers/tty/serial/8250/8250.c | 312 | ||||
-rw-r--r-- | drivers/tty/serial/8250/8250.h | 16 | ||||
-rw-r--r-- | drivers/tty/serial/8250/8250_em.c | 186 | ||||
-rw-r--r-- | drivers/tty/serial/8250/8250_pci.c | 63 | ||||
-rw-r--r-- | drivers/tty/serial/8250/Kconfig | 8 | ||||
-rw-r--r-- | drivers/tty/serial/8250/Makefile | 1 | ||||
-rw-r--r-- | drivers/tty/serial/amba-pl011.c | 109 | ||||
-rw-r--r-- | drivers/tty/serial/bfin_uart.c | 74 | ||||
-rw-r--r-- | drivers/tty/serial/crisv10.c | 36 | ||||
-rw-r--r-- | drivers/tty/serial/mxs-auart.c | 2 | ||||
-rw-r--r-- | drivers/tty/serial/of_serial.c | 26 | ||||
-rw-r--r-- | drivers/tty/serial/omap-serial.c | 74 | ||||
-rw-r--r-- | drivers/tty/serial/pch_uart.c | 53 | ||||
-rw-r--r-- | drivers/tty/serial/serial_core.c | 1 |
16 files changed, 759 insertions, 771 deletions
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index 5ce782529d65..3ed20e435e59 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/dbg.h> | 17 | #include <asm/dbg.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/serial.h> | ||
20 | #include <linux/signal.h> | 21 | #include <linux/signal.h> |
21 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
22 | #include <linux/timer.h> | 23 | #include <linux/timer.h> |
@@ -56,8 +57,6 @@ | |||
56 | #endif /* CONFIG_M68VZ328 */ | 57 | #endif /* CONFIG_M68VZ328 */ |
57 | #endif /* CONFIG_M68EZ328 */ | 58 | #endif /* CONFIG_M68EZ328 */ |
58 | 59 | ||
59 | #include "68328serial.h" | ||
60 | |||
61 | /* Turn off usage of real serial interrupt code, to "support" Copilot */ | 60 | /* Turn off usage of real serial interrupt code, to "support" Copilot */ |
62 | #ifdef CONFIG_XCOPILOT_BUGS | 61 | #ifdef CONFIG_XCOPILOT_BUGS |
63 | #undef USE_INTS | 62 | #undef USE_INTS |
@@ -65,33 +64,82 @@ | |||
65 | #define USE_INTS | 64 | #define USE_INTS |
66 | #endif | 65 | #endif |
67 | 66 | ||
68 | static struct m68k_serial m68k_soft[NR_PORTS]; | 67 | /* |
68 | * I believe this is the optimal setting that reduces the number of interrupts. | ||
69 | * At high speeds the output might become a little "bursted" (use USTCNT_TXHE | ||
70 | * if that bothers you), but in most cases it will not, since we try to | ||
71 | * transmit characters every time rs_interrupt is called. Thus, quite often | ||
72 | * you'll see that a receive interrupt occures before the transmit one. | ||
73 | * -- Vladimir Gurevich | ||
74 | */ | ||
75 | #define USTCNT_TX_INTR_MASK (USTCNT_TXEE) | ||
69 | 76 | ||
70 | static unsigned int uart_irqs[NR_PORTS] = UART_IRQ_DEFNS; | 77 | /* |
78 | * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special | ||
79 | * "Old data interrupt" which occures whenever the data stay in the FIFO | ||
80 | * longer than 30 bits time. This allows us to use FIFO without compromising | ||
81 | * latency. '328 does not have this feature and without the real 328-based | ||
82 | * board I would assume that RXRE is the safest setting. | ||
83 | * | ||
84 | * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of | ||
85 | * interrupts. RXFE (receive queue full) causes the system to lose data | ||
86 | * at least at 115200 baud | ||
87 | * | ||
88 | * If your board is busy doing other stuff, you might consider to use | ||
89 | * RXRE (data ready intrrupt) instead. | ||
90 | * | ||
91 | * The other option is to make these INTR masks run-time configurable, so | ||
92 | * that people can dynamically adapt them according to the current usage. | ||
93 | * -- Vladimir Gurevich | ||
94 | */ | ||
71 | 95 | ||
72 | /* multiple ports are contiguous in memory */ | 96 | /* (es) */ |
73 | m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR; | 97 | #if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328) |
98 | #define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN) | ||
99 | #elif defined(CONFIG_M68328) | ||
100 | #define USTCNT_RX_INTR_MASK (USTCNT_RXRE) | ||
101 | #else | ||
102 | #error Please, define the Rx interrupt events for your CPU | ||
103 | #endif | ||
104 | /* (/es) */ | ||
74 | 105 | ||
75 | struct tty_struct m68k_ttys; | 106 | /* |
76 | struct m68k_serial *m68k_consinfo = 0; | 107 | * This is our internal structure for each serial port's state. |
108 | */ | ||
109 | struct m68k_serial { | ||
110 | struct tty_port tport; | ||
111 | char is_cons; /* Is this our console. */ | ||
112 | int magic; | ||
113 | int baud_base; | ||
114 | int port; | ||
115 | int irq; | ||
116 | int type; /* UART type */ | ||
117 | int custom_divisor; | ||
118 | int x_char; /* xon/xoff character */ | ||
119 | int line; | ||
120 | unsigned char *xmit_buf; | ||
121 | int xmit_head; | ||
122 | int xmit_tail; | ||
123 | int xmit_cnt; | ||
124 | }; | ||
77 | 125 | ||
78 | #define M68K_CLOCK (16667000) /* FIXME: 16MHz is likely wrong */ | 126 | #define SERIAL_MAGIC 0x5301 |
79 | 127 | ||
80 | struct tty_driver *serial_driver; | 128 | /* |
129 | * Define the number of ports supported and their irqs. | ||
130 | */ | ||
131 | #define NR_PORTS 1 | ||
81 | 132 | ||
82 | /* number of characters left in xmit buffer before we ask for more */ | 133 | static struct m68k_serial m68k_soft[NR_PORTS]; |
83 | #define WAKEUP_CHARS 256 | ||
84 | 134 | ||
85 | /* Debugging... DEBUG_INTR is bad to use when one of the zs | 135 | static unsigned int uart_irqs[NR_PORTS] = { UART_IRQ_NUM }; |
86 | * lines is your console ;( | ||
87 | */ | ||
88 | #undef SERIAL_DEBUG_INTR | ||
89 | #undef SERIAL_DEBUG_OPEN | ||
90 | #undef SERIAL_DEBUG_FLOW | ||
91 | 136 | ||
92 | #define RS_ISR_PASS_LIMIT 256 | 137 | /* multiple ports are contiguous in memory */ |
138 | m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR; | ||
139 | |||
140 | struct tty_driver *serial_driver; | ||
93 | 141 | ||
94 | static void change_speed(struct m68k_serial *info); | 142 | static void change_speed(struct m68k_serial *info, struct tty_struct *tty); |
95 | 143 | ||
96 | /* | 144 | /* |
97 | * Setup for console. Argument comes from the boot command line. | 145 | * Setup for console. Argument comes from the boot command line. |
@@ -143,17 +191,6 @@ static int baud_table[] = { | |||
143 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, | 191 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, |
144 | 9600, 19200, 38400, 57600, 115200, 0 }; | 192 | 9600, 19200, 38400, 57600, 115200, 0 }; |
145 | 193 | ||
146 | /* Sets or clears DTR/RTS on the requested line */ | ||
147 | static inline void m68k_rtsdtr(struct m68k_serial *ss, int set) | ||
148 | { | ||
149 | if (set) { | ||
150 | /* set the RTS/CTS line */ | ||
151 | } else { | ||
152 | /* clear it */ | ||
153 | } | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | /* Utility routines */ | 194 | /* Utility routines */ |
158 | static inline int get_baud(struct m68k_serial *ss) | 195 | static inline int get_baud(struct m68k_serial *ss) |
159 | { | 196 | { |
@@ -189,7 +226,8 @@ static void rs_stop(struct tty_struct *tty) | |||
189 | 226 | ||
190 | static int rs_put_char(char ch) | 227 | static int rs_put_char(char ch) |
191 | { | 228 | { |
192 | int flags, loops = 0; | 229 | unsigned long flags; |
230 | int loops = 0; | ||
193 | 231 | ||
194 | local_irq_save(flags); | 232 | local_irq_save(flags); |
195 | 233 | ||
@@ -224,28 +262,9 @@ static void rs_start(struct tty_struct *tty) | |||
224 | local_irq_restore(flags); | 262 | local_irq_restore(flags); |
225 | } | 263 | } |
226 | 264 | ||
227 | /* Drop into either the boot monitor or kadb upon receiving a break | 265 | static void receive_chars(struct m68k_serial *info, struct tty_struct *tty, |
228 | * from keyboard/console input. | 266 | unsigned short rx) |
229 | */ | ||
230 | static void batten_down_hatches(void) | ||
231 | { | ||
232 | /* Drop into the debugger */ | ||
233 | } | ||
234 | |||
235 | static void status_handle(struct m68k_serial *info, unsigned short status) | ||
236 | { | 267 | { |
237 | /* If this is console input and this is a | ||
238 | * 'break asserted' status change interrupt | ||
239 | * see if we can drop into the debugger | ||
240 | */ | ||
241 | if((status & URX_BREAK) && info->break_abort) | ||
242 | batten_down_hatches(); | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | static void receive_chars(struct m68k_serial *info, unsigned short rx) | ||
247 | { | ||
248 | struct tty_struct *tty = info->tty; | ||
249 | m68328_uart *uart = &uart_addr[info->line]; | 268 | m68328_uart *uart = &uart_addr[info->line]; |
250 | unsigned char ch, flag; | 269 | unsigned char ch, flag; |
251 | 270 | ||
@@ -259,7 +278,6 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx) | |||
259 | 278 | ||
260 | if(info->is_cons) { | 279 | if(info->is_cons) { |
261 | if(URX_BREAK & rx) { /* whee, break received */ | 280 | if(URX_BREAK & rx) { /* whee, break received */ |
262 | status_handle(info, rx); | ||
263 | return; | 281 | return; |
264 | #ifdef CONFIG_MAGIC_SYSRQ | 282 | #ifdef CONFIG_MAGIC_SYSRQ |
265 | } else if (ch == 0x10) { /* ^P */ | 283 | } else if (ch == 0x10) { /* ^P */ |
@@ -280,16 +298,13 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx) | |||
280 | 298 | ||
281 | flag = TTY_NORMAL; | 299 | flag = TTY_NORMAL; |
282 | 300 | ||
283 | if(rx & URX_PARITY_ERROR) { | 301 | if (rx & URX_PARITY_ERROR) |
284 | flag = TTY_PARITY; | 302 | flag = TTY_PARITY; |
285 | status_handle(info, rx); | 303 | else if (rx & URX_OVRUN) |
286 | } else if(rx & URX_OVRUN) { | ||
287 | flag = TTY_OVERRUN; | 304 | flag = TTY_OVERRUN; |
288 | status_handle(info, rx); | 305 | else if (rx & URX_FRAME_ERROR) |
289 | } else if(rx & URX_FRAME_ERROR) { | ||
290 | flag = TTY_FRAME; | 306 | flag = TTY_FRAME; |
291 | status_handle(info, rx); | 307 | |
292 | } | ||
293 | tty_insert_flip_char(tty, ch, flag); | 308 | tty_insert_flip_char(tty, ch, flag); |
294 | #ifndef CONFIG_XCOPILOT_BUGS | 309 | #ifndef CONFIG_XCOPILOT_BUGS |
295 | } while((rx = uart->urx.w) & URX_DATA_READY); | 310 | } while((rx = uart->urx.w) & URX_DATA_READY); |
@@ -301,7 +316,7 @@ clear_and_exit: | |||
301 | return; | 316 | return; |
302 | } | 317 | } |
303 | 318 | ||
304 | static void transmit_chars(struct m68k_serial *info) | 319 | static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty) |
305 | { | 320 | { |
306 | m68328_uart *uart = &uart_addr[info->line]; | 321 | m68328_uart *uart = &uart_addr[info->line]; |
307 | 322 | ||
@@ -312,7 +327,7 @@ static void transmit_chars(struct m68k_serial *info) | |||
312 | goto clear_and_return; | 327 | goto clear_and_return; |
313 | } | 328 | } |
314 | 329 | ||
315 | if((info->xmit_cnt <= 0) || info->tty->stopped) { | 330 | if ((info->xmit_cnt <= 0) || !tty || tty->stopped) { |
316 | /* That's peculiar... TX ints off */ | 331 | /* That's peculiar... TX ints off */ |
317 | uart->ustcnt &= ~USTCNT_TX_INTR_MASK; | 332 | uart->ustcnt &= ~USTCNT_TX_INTR_MASK; |
318 | goto clear_and_return; | 333 | goto clear_and_return; |
@@ -340,6 +355,7 @@ clear_and_return: | |||
340 | irqreturn_t rs_interrupt(int irq, void *dev_id) | 355 | irqreturn_t rs_interrupt(int irq, void *dev_id) |
341 | { | 356 | { |
342 | struct m68k_serial *info = dev_id; | 357 | struct m68k_serial *info = dev_id; |
358 | struct tty_struct *tty = tty_port_tty_get(&info->tport); | ||
343 | m68328_uart *uart; | 359 | m68328_uart *uart; |
344 | unsigned short rx; | 360 | unsigned short rx; |
345 | unsigned short tx; | 361 | unsigned short tx; |
@@ -350,20 +366,24 @@ irqreturn_t rs_interrupt(int irq, void *dev_id) | |||
350 | #ifdef USE_INTS | 366 | #ifdef USE_INTS |
351 | tx = uart->utx.w; | 367 | tx = uart->utx.w; |
352 | 368 | ||
353 | if (rx & URX_DATA_READY) receive_chars(info, rx); | 369 | if (rx & URX_DATA_READY) |
354 | if (tx & UTX_TX_AVAIL) transmit_chars(info); | 370 | receive_chars(info, tty, rx); |
371 | if (tx & UTX_TX_AVAIL) | ||
372 | transmit_chars(info, tty); | ||
355 | #else | 373 | #else |
356 | receive_chars(info, rx); | 374 | receive_chars(info, tty, rx); |
357 | #endif | 375 | #endif |
376 | tty_kref_put(tty); | ||
377 | |||
358 | return IRQ_HANDLED; | 378 | return IRQ_HANDLED; |
359 | } | 379 | } |
360 | 380 | ||
361 | static int startup(struct m68k_serial * info) | 381 | static int startup(struct m68k_serial *info, struct tty_struct *tty) |
362 | { | 382 | { |
363 | m68328_uart *uart = &uart_addr[info->line]; | 383 | m68328_uart *uart = &uart_addr[info->line]; |
364 | unsigned long flags; | 384 | unsigned long flags; |
365 | 385 | ||
366 | if (info->flags & S_INITIALIZED) | 386 | if (info->tport.flags & ASYNC_INITIALIZED) |
367 | return 0; | 387 | return 0; |
368 | 388 | ||
369 | if (!info->xmit_buf) { | 389 | if (!info->xmit_buf) { |
@@ -380,7 +400,6 @@ static int startup(struct m68k_serial * info) | |||
380 | */ | 400 | */ |
381 | 401 | ||
382 | uart->ustcnt = USTCNT_UEN; | 402 | uart->ustcnt = USTCNT_UEN; |
383 | info->xmit_fifo_size = 1; | ||
384 | uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN; | 403 | uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN; |
385 | (void)uart->urx.w; | 404 | (void)uart->urx.w; |
386 | 405 | ||
@@ -394,17 +413,17 @@ static int startup(struct m68k_serial * info) | |||
394 | uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK; | 413 | uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK; |
395 | #endif | 414 | #endif |
396 | 415 | ||
397 | if (info->tty) | 416 | if (tty) |
398 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 417 | clear_bit(TTY_IO_ERROR, &tty->flags); |
399 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | 418 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
400 | 419 | ||
401 | /* | 420 | /* |
402 | * and set the speed of the serial port | 421 | * and set the speed of the serial port |
403 | */ | 422 | */ |
404 | 423 | ||
405 | change_speed(info); | 424 | change_speed(info, tty); |
406 | 425 | ||
407 | info->flags |= S_INITIALIZED; | 426 | info->tport.flags |= ASYNC_INITIALIZED; |
408 | local_irq_restore(flags); | 427 | local_irq_restore(flags); |
409 | return 0; | 428 | return 0; |
410 | } | 429 | } |
@@ -413,13 +432,13 @@ static int startup(struct m68k_serial * info) | |||
413 | * This routine will shutdown a serial port; interrupts are disabled, and | 432 | * This routine will shutdown a serial port; interrupts are disabled, and |
414 | * DTR is dropped if the hangup on close termio flag is on. | 433 | * DTR is dropped if the hangup on close termio flag is on. |
415 | */ | 434 | */ |
416 | static void shutdown(struct m68k_serial * info) | 435 | static void shutdown(struct m68k_serial *info, struct tty_struct *tty) |
417 | { | 436 | { |
418 | m68328_uart *uart = &uart_addr[info->line]; | 437 | m68328_uart *uart = &uart_addr[info->line]; |
419 | unsigned long flags; | 438 | unsigned long flags; |
420 | 439 | ||
421 | uart->ustcnt = 0; /* All off! */ | 440 | uart->ustcnt = 0; /* All off! */ |
422 | if (!(info->flags & S_INITIALIZED)) | 441 | if (!(info->tport.flags & ASYNC_INITIALIZED)) |
423 | return; | 442 | return; |
424 | 443 | ||
425 | local_irq_save(flags); | 444 | local_irq_save(flags); |
@@ -429,10 +448,10 @@ static void shutdown(struct m68k_serial * info) | |||
429 | info->xmit_buf = 0; | 448 | info->xmit_buf = 0; |
430 | } | 449 | } |
431 | 450 | ||
432 | if (info->tty) | 451 | if (tty) |
433 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 452 | set_bit(TTY_IO_ERROR, &tty->flags); |
434 | 453 | ||
435 | info->flags &= ~S_INITIALIZED; | 454 | info->tport.flags &= ~ASYNC_INITIALIZED; |
436 | local_irq_restore(flags); | 455 | local_irq_restore(flags); |
437 | } | 456 | } |
438 | 457 | ||
@@ -488,7 +507,7 @@ struct { | |||
488 | * This routine is called to set the UART divisor registers to match | 507 | * This routine is called to set the UART divisor registers to match |
489 | * the specified baud rate for a serial port. | 508 | * the specified baud rate for a serial port. |
490 | */ | 509 | */ |
491 | static void change_speed(struct m68k_serial *info) | 510 | static void change_speed(struct m68k_serial *info, struct tty_struct *tty) |
492 | { | 511 | { |
493 | m68328_uart *uart = &uart_addr[info->line]; | 512 | m68328_uart *uart = &uart_addr[info->line]; |
494 | unsigned short port; | 513 | unsigned short port; |
@@ -496,9 +515,7 @@ static void change_speed(struct m68k_serial *info) | |||
496 | unsigned cflag; | 515 | unsigned cflag; |
497 | int i; | 516 | int i; |
498 | 517 | ||
499 | if (!info->tty || !info->tty->termios) | 518 | cflag = tty->termios->c_cflag; |
500 | return; | ||
501 | cflag = info->tty->termios->c_cflag; | ||
502 | if (!(port = info->port)) | 519 | if (!(port = info->port)) |
503 | return; | 520 | return; |
504 | 521 | ||
@@ -510,7 +527,6 @@ static void change_speed(struct m68k_serial *info) | |||
510 | i = (i & ~CBAUDEX) + B38400; | 527 | i = (i & ~CBAUDEX) + B38400; |
511 | } | 528 | } |
512 | 529 | ||
513 | info->baud = baud_table[i]; | ||
514 | uart->ubaud = PUT_FIELD(UBAUD_DIVIDE, hw_baud_table[i].divisor) | | 530 | uart->ubaud = PUT_FIELD(UBAUD_DIVIDE, hw_baud_table[i].divisor) | |
515 | PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale); | 531 | PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale); |
516 | 532 | ||
@@ -807,10 +823,10 @@ static int get_serial_info(struct m68k_serial * info, | |||
807 | tmp.line = info->line; | 823 | tmp.line = info->line; |
808 | tmp.port = info->port; | 824 | tmp.port = info->port; |
809 | tmp.irq = info->irq; | 825 | tmp.irq = info->irq; |
810 | tmp.flags = info->flags; | 826 | tmp.flags = info->tport.flags; |
811 | tmp.baud_base = info->baud_base; | 827 | tmp.baud_base = info->baud_base; |
812 | tmp.close_delay = info->close_delay; | 828 | tmp.close_delay = info->tport.close_delay; |
813 | tmp.closing_wait = info->closing_wait; | 829 | tmp.closing_wait = info->tport.closing_wait; |
814 | tmp.custom_divisor = info->custom_divisor; | 830 | tmp.custom_divisor = info->custom_divisor; |
815 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | 831 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) |
816 | return -EFAULT; | 832 | return -EFAULT; |
@@ -818,9 +834,10 @@ static int get_serial_info(struct m68k_serial * info, | |||
818 | return 0; | 834 | return 0; |
819 | } | 835 | } |
820 | 836 | ||
821 | static int set_serial_info(struct m68k_serial * info, | 837 | static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty, |
822 | struct serial_struct * new_info) | 838 | struct serial_struct * new_info) |
823 | { | 839 | { |
840 | struct tty_port *port = &info->tport; | ||
824 | struct serial_struct new_serial; | 841 | struct serial_struct new_serial; |
825 | struct m68k_serial old_info; | 842 | struct m68k_serial old_info; |
826 | int retval = 0; | 843 | int retval = 0; |
@@ -834,17 +851,17 @@ static int set_serial_info(struct m68k_serial * info, | |||
834 | if (!capable(CAP_SYS_ADMIN)) { | 851 | if (!capable(CAP_SYS_ADMIN)) { |
835 | if ((new_serial.baud_base != info->baud_base) || | 852 | if ((new_serial.baud_base != info->baud_base) || |
836 | (new_serial.type != info->type) || | 853 | (new_serial.type != info->type) || |
837 | (new_serial.close_delay != info->close_delay) || | 854 | (new_serial.close_delay != port->close_delay) || |
838 | ((new_serial.flags & ~S_USR_MASK) != | 855 | ((new_serial.flags & ~ASYNC_USR_MASK) != |
839 | (info->flags & ~S_USR_MASK))) | 856 | (port->flags & ~ASYNC_USR_MASK))) |
840 | return -EPERM; | 857 | return -EPERM; |
841 | info->flags = ((info->flags & ~S_USR_MASK) | | 858 | port->flags = ((port->flags & ~ASYNC_USR_MASK) | |
842 | (new_serial.flags & S_USR_MASK)); | 859 | (new_serial.flags & ASYNC_USR_MASK)); |
843 | info->custom_divisor = new_serial.custom_divisor; | 860 | info->custom_divisor = new_serial.custom_divisor; |
844 | goto check_and_exit; | 861 | goto check_and_exit; |
845 | } | 862 | } |
846 | 863 | ||
847 | if (info->count > 1) | 864 | if (port->count > 1) |
848 | return -EBUSY; | 865 | return -EBUSY; |
849 | 866 | ||
850 | /* | 867 | /* |
@@ -853,14 +870,14 @@ static int set_serial_info(struct m68k_serial * info, | |||
853 | */ | 870 | */ |
854 | 871 | ||
855 | info->baud_base = new_serial.baud_base; | 872 | info->baud_base = new_serial.baud_base; |
856 | info->flags = ((info->flags & ~S_FLAGS) | | 873 | port->flags = ((port->flags & ~ASYNC_FLAGS) | |
857 | (new_serial.flags & S_FLAGS)); | 874 | (new_serial.flags & ASYNC_FLAGS)); |
858 | info->type = new_serial.type; | 875 | info->type = new_serial.type; |
859 | info->close_delay = new_serial.close_delay; | 876 | port->close_delay = new_serial.close_delay; |
860 | info->closing_wait = new_serial.closing_wait; | 877 | port->closing_wait = new_serial.closing_wait; |
861 | 878 | ||
862 | check_and_exit: | 879 | check_and_exit: |
863 | retval = startup(info); | 880 | retval = startup(info, tty); |
864 | return retval; | 881 | return retval; |
865 | } | 882 | } |
866 | 883 | ||
@@ -946,7 +963,7 @@ static int rs_ioctl(struct tty_struct *tty, | |||
946 | return get_serial_info(info, | 963 | return get_serial_info(info, |
947 | (struct serial_struct *) arg); | 964 | (struct serial_struct *) arg); |
948 | case TIOCSSERIAL: | 965 | case TIOCSSERIAL: |
949 | return set_serial_info(info, | 966 | return set_serial_info(info, tty, |
950 | (struct serial_struct *) arg); | 967 | (struct serial_struct *) arg); |
951 | case TIOCSERGETLSR: /* Get line status register */ | 968 | case TIOCSERGETLSR: /* Get line status register */ |
952 | return get_lsr_info(info, (unsigned int *) arg); | 969 | return get_lsr_info(info, (unsigned int *) arg); |
@@ -965,7 +982,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
965 | { | 982 | { |
966 | struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; | 983 | struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; |
967 | 984 | ||
968 | change_speed(info); | 985 | change_speed(info, tty); |
969 | 986 | ||
970 | if ((old_termios->c_cflag & CRTSCTS) && | 987 | if ((old_termios->c_cflag & CRTSCTS) && |
971 | !(tty->termios->c_cflag & CRTSCTS)) { | 988 | !(tty->termios->c_cflag & CRTSCTS)) { |
@@ -988,6 +1005,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
988 | static void rs_close(struct tty_struct *tty, struct file * filp) | 1005 | static void rs_close(struct tty_struct *tty, struct file * filp) |
989 | { | 1006 | { |
990 | struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; | 1007 | struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; |
1008 | struct tty_port *port = &info->tport; | ||
991 | m68328_uart *uart = &uart_addr[info->line]; | 1009 | m68328_uart *uart = &uart_addr[info->line]; |
992 | unsigned long flags; | 1010 | unsigned long flags; |
993 | 1011 | ||
@@ -1001,7 +1019,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1001 | return; | 1019 | return; |
1002 | } | 1020 | } |
1003 | 1021 | ||
1004 | if ((tty->count == 1) && (info->count != 1)) { | 1022 | if ((tty->count == 1) && (port->count != 1)) { |
1005 | /* | 1023 | /* |
1006 | * Uh, oh. tty->count is 1, which means that the tty | 1024 | * Uh, oh. tty->count is 1, which means that the tty |
1007 | * structure will be freed. Info->count should always | 1025 | * structure will be freed. Info->count should always |
@@ -1010,26 +1028,26 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1010 | * serial port won't be shutdown. | 1028 | * serial port won't be shutdown. |
1011 | */ | 1029 | */ |
1012 | printk("rs_close: bad serial port count; tty->count is 1, " | 1030 | printk("rs_close: bad serial port count; tty->count is 1, " |
1013 | "info->count is %d\n", info->count); | 1031 | "port->count is %d\n", port->count); |
1014 | info->count = 1; | 1032 | port->count = 1; |
1015 | } | 1033 | } |
1016 | if (--info->count < 0) { | 1034 | if (--port->count < 0) { |
1017 | printk("rs_close: bad serial port count for ttyS%d: %d\n", | 1035 | printk("rs_close: bad serial port count for ttyS%d: %d\n", |
1018 | info->line, info->count); | 1036 | info->line, port->count); |
1019 | info->count = 0; | 1037 | port->count = 0; |
1020 | } | 1038 | } |
1021 | if (info->count) { | 1039 | if (port->count) { |
1022 | local_irq_restore(flags); | 1040 | local_irq_restore(flags); |
1023 | return; | 1041 | return; |
1024 | } | 1042 | } |
1025 | info->flags |= S_CLOSING; | 1043 | port->flags |= ASYNC_CLOSING; |
1026 | /* | 1044 | /* |
1027 | * Now we wait for the transmit buffer to clear; and we notify | 1045 | * Now we wait for the transmit buffer to clear; and we notify |
1028 | * the line discipline to only process XON/XOFF characters. | 1046 | * the line discipline to only process XON/XOFF characters. |
1029 | */ | 1047 | */ |
1030 | tty->closing = 1; | 1048 | tty->closing = 1; |
1031 | if (info->closing_wait != S_CLOSING_WAIT_NONE) | 1049 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
1032 | tty_wait_until_sent(tty, info->closing_wait); | 1050 | tty_wait_until_sent(tty, port->closing_wait); |
1033 | /* | 1051 | /* |
1034 | * At this point we stop accepting input. To do this, we | 1052 | * At this point we stop accepting input. To do this, we |
1035 | * disable the receive line status interrupts, and tell the | 1053 | * disable the receive line status interrupts, and tell the |
@@ -1040,13 +1058,12 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1040 | uart->ustcnt &= ~USTCNT_RXEN; | 1058 | uart->ustcnt &= ~USTCNT_RXEN; |
1041 | uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); | 1059 | uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); |
1042 | 1060 | ||
1043 | shutdown(info); | 1061 | shutdown(info, tty); |
1044 | rs_flush_buffer(tty); | 1062 | rs_flush_buffer(tty); |
1045 | 1063 | ||
1046 | tty_ldisc_flush(tty); | 1064 | tty_ldisc_flush(tty); |
1047 | tty->closing = 0; | 1065 | tty->closing = 0; |
1048 | info->event = 0; | 1066 | tty_port_tty_set(&info->tport, NULL); |
1049 | info->tty = NULL; | ||
1050 | #warning "This is not and has never been valid so fix it" | 1067 | #warning "This is not and has never been valid so fix it" |
1051 | #if 0 | 1068 | #if 0 |
1052 | if (tty->ldisc.num != ldiscs[N_TTY].num) { | 1069 | if (tty->ldisc.num != ldiscs[N_TTY].num) { |
@@ -1058,14 +1075,13 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1058 | (tty->ldisc.open)(tty); | 1075 | (tty->ldisc.open)(tty); |
1059 | } | 1076 | } |
1060 | #endif | 1077 | #endif |
1061 | if (info->blocked_open) { | 1078 | if (port->blocked_open) { |
1062 | if (info->close_delay) { | 1079 | if (port->close_delay) |
1063 | msleep_interruptible(jiffies_to_msecs(info->close_delay)); | 1080 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); |
1064 | } | 1081 | wake_up_interruptible(&port->open_wait); |
1065 | wake_up_interruptible(&info->open_wait); | ||
1066 | } | 1082 | } |
1067 | info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING); | 1083 | port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); |
1068 | wake_up_interruptible(&info->close_wait); | 1084 | wake_up_interruptible(&port->close_wait); |
1069 | local_irq_restore(flags); | 1085 | local_irq_restore(flags); |
1070 | } | 1086 | } |
1071 | 1087 | ||
@@ -1080,107 +1096,14 @@ void rs_hangup(struct tty_struct *tty) | |||
1080 | return; | 1096 | return; |
1081 | 1097 | ||
1082 | rs_flush_buffer(tty); | 1098 | rs_flush_buffer(tty); |
1083 | shutdown(info); | 1099 | shutdown(info, tty); |
1084 | info->event = 0; | 1100 | info->tport.count = 0; |
1085 | info->count = 0; | 1101 | info->tport.flags &= ~ASYNC_NORMAL_ACTIVE; |
1086 | info->flags &= ~S_NORMAL_ACTIVE; | 1102 | tty_port_tty_set(&info->tport, NULL); |
1087 | info->tty = NULL; | 1103 | wake_up_interruptible(&info->tport.open_wait); |
1088 | wake_up_interruptible(&info->open_wait); | ||
1089 | } | 1104 | } |
1090 | 1105 | ||
1091 | /* | 1106 | /* |
1092 | * ------------------------------------------------------------ | ||
1093 | * rs_open() and friends | ||
1094 | * ------------------------------------------------------------ | ||
1095 | */ | ||
1096 | static int block_til_ready(struct tty_struct *tty, struct file * filp, | ||
1097 | struct m68k_serial *info) | ||
1098 | { | ||
1099 | DECLARE_WAITQUEUE(wait, current); | ||
1100 | int retval; | ||
1101 | int do_clocal = 0; | ||
1102 | |||
1103 | /* | ||
1104 | * If the device is in the middle of being closed, then block | ||
1105 | * until it's done, and then try again. | ||
1106 | */ | ||
1107 | if (info->flags & S_CLOSING) { | ||
1108 | interruptible_sleep_on(&info->close_wait); | ||
1109 | #ifdef SERIAL_DO_RESTART | ||
1110 | if (info->flags & S_HUP_NOTIFY) | ||
1111 | return -EAGAIN; | ||
1112 | else | ||
1113 | return -ERESTARTSYS; | ||
1114 | #else | ||
1115 | return -EAGAIN; | ||
1116 | #endif | ||
1117 | } | ||
1118 | |||
1119 | /* | ||
1120 | * If non-blocking mode is set, or the port is not enabled, | ||
1121 | * then make the check up front and then exit. | ||
1122 | */ | ||
1123 | if ((filp->f_flags & O_NONBLOCK) || | ||
1124 | (tty->flags & (1 << TTY_IO_ERROR))) { | ||
1125 | info->flags |= S_NORMAL_ACTIVE; | ||
1126 | return 0; | ||
1127 | } | ||
1128 | |||
1129 | if (tty->termios->c_cflag & CLOCAL) | ||
1130 | do_clocal = 1; | ||
1131 | |||
1132 | /* | ||
1133 | * Block waiting for the carrier detect and the line to become | ||
1134 | * free (i.e., not in use by the callout). While we are in | ||
1135 | * this loop, info->count is dropped by one, so that | ||
1136 | * rs_close() knows when to free things. We restore it upon | ||
1137 | * exit, either normal or abnormal. | ||
1138 | */ | ||
1139 | retval = 0; | ||
1140 | add_wait_queue(&info->open_wait, &wait); | ||
1141 | |||
1142 | info->count--; | ||
1143 | info->blocked_open++; | ||
1144 | while (1) { | ||
1145 | local_irq_disable(); | ||
1146 | m68k_rtsdtr(info, 1); | ||
1147 | local_irq_enable(); | ||
1148 | current->state = TASK_INTERRUPTIBLE; | ||
1149 | if (tty_hung_up_p(filp) || | ||
1150 | !(info->flags & S_INITIALIZED)) { | ||
1151 | #ifdef SERIAL_DO_RESTART | ||
1152 | if (info->flags & S_HUP_NOTIFY) | ||
1153 | retval = -EAGAIN; | ||
1154 | else | ||
1155 | retval = -ERESTARTSYS; | ||
1156 | #else | ||
1157 | retval = -EAGAIN; | ||
1158 | #endif | ||
1159 | break; | ||
1160 | } | ||
1161 | if (!(info->flags & S_CLOSING) && do_clocal) | ||
1162 | break; | ||
1163 | if (signal_pending(current)) { | ||
1164 | retval = -ERESTARTSYS; | ||
1165 | break; | ||
1166 | } | ||
1167 | tty_unlock(); | ||
1168 | schedule(); | ||
1169 | tty_lock(); | ||
1170 | } | ||
1171 | current->state = TASK_RUNNING; | ||
1172 | remove_wait_queue(&info->open_wait, &wait); | ||
1173 | if (!tty_hung_up_p(filp)) | ||
1174 | info->count++; | ||
1175 | info->blocked_open--; | ||
1176 | |||
1177 | if (retval) | ||
1178 | return retval; | ||
1179 | info->flags |= S_NORMAL_ACTIVE; | ||
1180 | return 0; | ||
1181 | } | ||
1182 | |||
1183 | /* | ||
1184 | * This routine is called whenever a serial port is opened. It | 1107 | * This routine is called whenever a serial port is opened. It |
1185 | * enables interrupts for a serial port, linking in its S structure into | 1108 | * enables interrupts for a serial port, linking in its S structure into |
1186 | * the IRQ chain. It also performs the serial-specific | 1109 | * the IRQ chain. It also performs the serial-specific |
@@ -1196,18 +1119,18 @@ int rs_open(struct tty_struct *tty, struct file * filp) | |||
1196 | if (serial_paranoia_check(info, tty->name, "rs_open")) | 1119 | if (serial_paranoia_check(info, tty->name, "rs_open")) |
1197 | return -ENODEV; | 1120 | return -ENODEV; |
1198 | 1121 | ||
1199 | info->count++; | 1122 | info->tport.count++; |
1200 | tty->driver_data = info; | 1123 | tty->driver_data = info; |
1201 | info->tty = tty; | 1124 | tty_port_tty_set(&info->tport, tty); |
1202 | 1125 | ||
1203 | /* | 1126 | /* |
1204 | * Start up serial port | 1127 | * Start up serial port |
1205 | */ | 1128 | */ |
1206 | retval = startup(info); | 1129 | retval = startup(info, tty); |
1207 | if (retval) | 1130 | if (retval) |
1208 | return retval; | 1131 | return retval; |
1209 | 1132 | ||
1210 | return block_til_ready(tty, filp, info); | 1133 | return tty_port_block_til_ready(&info->tport, tty, filp); |
1211 | } | 1134 | } |
1212 | 1135 | ||
1213 | /* Finally, routines used to initialize the serial driver. */ | 1136 | /* Finally, routines used to initialize the serial driver. */ |
@@ -1235,11 +1158,15 @@ static const struct tty_operations rs_ops = { | |||
1235 | .set_ldisc = rs_set_ldisc, | 1158 | .set_ldisc = rs_set_ldisc, |
1236 | }; | 1159 | }; |
1237 | 1160 | ||
1161 | static const struct tty_port_operations rs_port_ops = { | ||
1162 | }; | ||
1163 | |||
1238 | /* rs_init inits the driver */ | 1164 | /* rs_init inits the driver */ |
1239 | static int __init | 1165 | static int __init |
1240 | rs68328_init(void) | 1166 | rs68328_init(void) |
1241 | { | 1167 | { |
1242 | int flags, i; | 1168 | unsigned long flags; |
1169 | int i; | ||
1243 | struct m68k_serial *info; | 1170 | struct m68k_serial *info; |
1244 | 1171 | ||
1245 | serial_driver = alloc_tty_driver(NR_PORTS); | 1172 | serial_driver = alloc_tty_driver(NR_PORTS); |
@@ -1273,19 +1200,13 @@ rs68328_init(void) | |||
1273 | for(i=0;i<NR_PORTS;i++) { | 1200 | for(i=0;i<NR_PORTS;i++) { |
1274 | 1201 | ||
1275 | info = &m68k_soft[i]; | 1202 | info = &m68k_soft[i]; |
1203 | tty_port_init(&info->tport); | ||
1204 | info->tport.ops = &rs_port_ops; | ||
1276 | info->magic = SERIAL_MAGIC; | 1205 | info->magic = SERIAL_MAGIC; |
1277 | info->port = (int) &uart_addr[i]; | 1206 | info->port = (int) &uart_addr[i]; |
1278 | info->tty = NULL; | ||
1279 | info->irq = uart_irqs[i]; | 1207 | info->irq = uart_irqs[i]; |
1280 | info->custom_divisor = 16; | 1208 | info->custom_divisor = 16; |
1281 | info->close_delay = 50; | ||
1282 | info->closing_wait = 3000; | ||
1283 | info->x_char = 0; | 1209 | info->x_char = 0; |
1284 | info->event = 0; | ||
1285 | info->count = 0; | ||
1286 | info->blocked_open = 0; | ||
1287 | init_waitqueue_head(&info->open_wait); | ||
1288 | init_waitqueue_head(&info->close_wait); | ||
1289 | info->line = i; | 1210 | info->line = i; |
1290 | info->is_cons = 1; /* Means shortcuts work */ | 1211 | info->is_cons = 1; /* Means shortcuts work */ |
1291 | 1212 | ||
diff --git a/drivers/tty/serial/68328serial.h b/drivers/tty/serial/68328serial.h deleted file mode 100644 index 3d2faabd766f..000000000000 --- a/drivers/tty/serial/68328serial.h +++ /dev/null | |||
@@ -1,186 +0,0 @@ | |||
1 | /* 68328serial.h: Definitions for the mc68328 serial driver. | ||
2 | * | ||
3 | * Copyright (C) 1995 David S. Miller <davem@caip.rutgers.edu> | ||
4 | * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com> | ||
5 | * Copyright (C) 1998, 1999 D. Jeff Dionne <jeff@uclinux.org> | ||
6 | * Copyright (C) 1999 Vladimir Gurevich <vgurevic@cisco.com> | ||
7 | * | ||
8 | * VZ Support/Fixes Evan Stawnyczy <e@lineo.ca> | ||
9 | */ | ||
10 | |||
11 | #ifndef _MC683XX_SERIAL_H | ||
12 | #define _MC683XX_SERIAL_H | ||
13 | |||
14 | |||
15 | struct serial_struct { | ||
16 | int type; | ||
17 | int line; | ||
18 | int port; | ||
19 | int irq; | ||
20 | int flags; | ||
21 | int xmit_fifo_size; | ||
22 | int custom_divisor; | ||
23 | int baud_base; | ||
24 | unsigned short close_delay; | ||
25 | char reserved_char[2]; | ||
26 | int hub6; /* FIXME: We don't have AT&T Hub6 boards! */ | ||
27 | unsigned short closing_wait; /* time to wait before closing */ | ||
28 | unsigned short closing_wait2; /* no longer used... */ | ||
29 | int reserved[4]; | ||
30 | }; | ||
31 | |||
32 | /* | ||
33 | * For the close wait times, 0 means wait forever for serial port to | ||
34 | * flush its output. 65535 means don't wait at all. | ||
35 | */ | ||
36 | #define S_CLOSING_WAIT_INF 0 | ||
37 | #define S_CLOSING_WAIT_NONE 65535 | ||
38 | |||
39 | /* | ||
40 | * Definitions for S_struct (and serial_struct) flags field | ||
41 | */ | ||
42 | #define S_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes | ||
43 | on the callout port */ | ||
44 | #define S_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ | ||
45 | #define S_SAK 0x0004 /* Secure Attention Key (Orange book) */ | ||
46 | #define S_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ | ||
47 | |||
48 | #define S_SPD_MASK 0x0030 | ||
49 | #define S_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ | ||
50 | |||
51 | #define S_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ | ||
52 | #define S_SPD_CUST 0x0030 /* Use user-specified divisor */ | ||
53 | |||
54 | #define S_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ | ||
55 | #define S_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ | ||
56 | #define S_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ | ||
57 | #define S_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ | ||
58 | #define S_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ | ||
59 | |||
60 | #define S_FLAGS 0x0FFF /* Possible legal S flags */ | ||
61 | #define S_USR_MASK 0x0430 /* Legal flags that non-privileged | ||
62 | * users can set or reset */ | ||
63 | |||
64 | /* Internal flags used only by kernel/chr_drv/serial.c */ | ||
65 | #define S_INITIALIZED 0x80000000 /* Serial port was initialized */ | ||
66 | #define S_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */ | ||
67 | #define S_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ | ||
68 | #define S_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ | ||
69 | #define S_CLOSING 0x08000000 /* Serial port is closing */ | ||
70 | #define S_CTS_FLOW 0x04000000 /* Do CTS flow control */ | ||
71 | #define S_CHECK_CD 0x02000000 /* i.e., CLOCAL */ | ||
72 | |||
73 | /* Software state per channel */ | ||
74 | |||
75 | #ifdef __KERNEL__ | ||
76 | |||
77 | /* | ||
78 | * I believe this is the optimal setting that reduces the number of interrupts. | ||
79 | * At high speeds the output might become a little "bursted" (use USTCNT_TXHE | ||
80 | * if that bothers you), but in most cases it will not, since we try to | ||
81 | * transmit characters every time rs_interrupt is called. Thus, quite often | ||
82 | * you'll see that a receive interrupt occures before the transmit one. | ||
83 | * -- Vladimir Gurevich | ||
84 | */ | ||
85 | #define USTCNT_TX_INTR_MASK (USTCNT_TXEE) | ||
86 | |||
87 | /* | ||
88 | * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special | ||
89 | * "Old data interrupt" which occures whenever the data stay in the FIFO | ||
90 | * longer than 30 bits time. This allows us to use FIFO without compromising | ||
91 | * latency. '328 does not have this feature and without the real 328-based | ||
92 | * board I would assume that RXRE is the safest setting. | ||
93 | * | ||
94 | * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of | ||
95 | * interrupts. RXFE (receive queue full) causes the system to lose data | ||
96 | * at least at 115200 baud | ||
97 | * | ||
98 | * If your board is busy doing other stuff, you might consider to use | ||
99 | * RXRE (data ready intrrupt) instead. | ||
100 | * | ||
101 | * The other option is to make these INTR masks run-time configurable, so | ||
102 | * that people can dynamically adapt them according to the current usage. | ||
103 | * -- Vladimir Gurevich | ||
104 | */ | ||
105 | |||
106 | /* (es) */ | ||
107 | #if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328) | ||
108 | #define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN) | ||
109 | #elif defined(CONFIG_M68328) | ||
110 | #define USTCNT_RX_INTR_MASK (USTCNT_RXRE) | ||
111 | #else | ||
112 | #error Please, define the Rx interrupt events for your CPU | ||
113 | #endif | ||
114 | /* (/es) */ | ||
115 | |||
116 | /* | ||
117 | * This is our internal structure for each serial port's state. | ||
118 | * | ||
119 | * Many fields are paralleled by the structure used by the serial_struct | ||
120 | * structure. | ||
121 | * | ||
122 | * For definitions of the flags field, see tty.h | ||
123 | */ | ||
124 | |||
125 | struct m68k_serial { | ||
126 | char soft_carrier; /* Use soft carrier on this channel */ | ||
127 | char break_abort; /* Is serial console in, so process brk/abrt */ | ||
128 | char is_cons; /* Is this our console. */ | ||
129 | |||
130 | /* We need to know the current clock divisor | ||
131 | * to read the bps rate the chip has currently | ||
132 | * loaded. | ||
133 | */ | ||
134 | unsigned char clk_divisor; /* May be 1, 16, 32, or 64 */ | ||
135 | int baud; | ||
136 | int magic; | ||
137 | int baud_base; | ||
138 | int port; | ||
139 | int irq; | ||
140 | int flags; /* defined in tty.h */ | ||
141 | int type; /* UART type */ | ||
142 | struct tty_struct *tty; | ||
143 | int read_status_mask; | ||
144 | int ignore_status_mask; | ||
145 | int timeout; | ||
146 | int xmit_fifo_size; | ||
147 | int custom_divisor; | ||
148 | int x_char; /* xon/xoff character */ | ||
149 | int close_delay; | ||
150 | unsigned short closing_wait; | ||
151 | unsigned short closing_wait2; | ||
152 | unsigned long event; | ||
153 | unsigned long last_active; | ||
154 | int line; | ||
155 | int count; /* # of fd on device */ | ||
156 | int blocked_open; /* # of blocked opens */ | ||
157 | unsigned char *xmit_buf; | ||
158 | int xmit_head; | ||
159 | int xmit_tail; | ||
160 | int xmit_cnt; | ||
161 | wait_queue_head_t open_wait; | ||
162 | wait_queue_head_t close_wait; | ||
163 | }; | ||
164 | |||
165 | |||
166 | #define SERIAL_MAGIC 0x5301 | ||
167 | |||
168 | /* | ||
169 | * The size of the serial xmit buffer is 1 page, or 4096 bytes | ||
170 | */ | ||
171 | #define SERIAL_XMIT_SIZE 4096 | ||
172 | |||
173 | /* | ||
174 | * Events are used to schedule things to happen at timer-interrupt | ||
175 | * time, instead of at rs interrupt time. | ||
176 | */ | ||
177 | #define RS_EVENT_WRITE_WAKEUP 0 | ||
178 | |||
179 | /* | ||
180 | * Define the number of ports supported and their irqs. | ||
181 | */ | ||
182 | #define NR_PORTS 1 | ||
183 | #define UART_IRQ_DEFNS {UART_IRQ_NUM} | ||
184 | |||
185 | #endif /* __KERNEL__ */ | ||
186 | #endif /* !(_MC683XX_SERIAL_H) */ | ||
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 5c27f7e6c9f1..47d061b9ad4d 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c | |||
@@ -284,7 +284,20 @@ static const struct serial8250_config uart_config[] = { | |||
284 | }, | 284 | }, |
285 | }; | 285 | }; |
286 | 286 | ||
287 | #if defined(CONFIG_MIPS_ALCHEMY) | 287 | /* Uart divisor latch read */ |
288 | static int default_serial_dl_read(struct uart_8250_port *up) | ||
289 | { | ||
290 | return serial_in(up, UART_DLL) | serial_in(up, UART_DLM) << 8; | ||
291 | } | ||
292 | |||
293 | /* Uart divisor latch write */ | ||
294 | static void default_serial_dl_write(struct uart_8250_port *up, int value) | ||
295 | { | ||
296 | serial_out(up, UART_DLL, value & 0xff); | ||
297 | serial_out(up, UART_DLM, value >> 8 & 0xff); | ||
298 | } | ||
299 | |||
300 | #ifdef CONFIG_MIPS_ALCHEMY | ||
288 | 301 | ||
289 | /* Au1x00 UART hardware has a weird register layout */ | 302 | /* Au1x00 UART hardware has a weird register layout */ |
290 | static const u8 au_io_in_map[] = { | 303 | static const u8 au_io_in_map[] = { |
@@ -305,22 +318,32 @@ static const u8 au_io_out_map[] = { | |||
305 | [UART_MCR] = 6, | 318 | [UART_MCR] = 6, |
306 | }; | 319 | }; |
307 | 320 | ||
308 | /* sane hardware needs no mapping */ | 321 | static unsigned int au_serial_in(struct uart_port *p, int offset) |
309 | static inline int map_8250_in_reg(struct uart_port *p, int offset) | 322 | { |
323 | offset = au_io_in_map[offset] << p->regshift; | ||
324 | return __raw_readl(p->membase + offset); | ||
325 | } | ||
326 | |||
327 | static void au_serial_out(struct uart_port *p, int offset, int value) | ||
328 | { | ||
329 | offset = au_io_out_map[offset] << p->regshift; | ||
330 | __raw_writel(value, p->membase + offset); | ||
331 | } | ||
332 | |||
333 | /* Au1x00 haven't got a standard divisor latch */ | ||
334 | static int au_serial_dl_read(struct uart_8250_port *up) | ||
310 | { | 335 | { |
311 | if (p->iotype != UPIO_AU) | 336 | return __raw_readl(up->port.membase + 0x28); |
312 | return offset; | ||
313 | return au_io_in_map[offset]; | ||
314 | } | 337 | } |
315 | 338 | ||
316 | static inline int map_8250_out_reg(struct uart_port *p, int offset) | 339 | static void au_serial_dl_write(struct uart_8250_port *up, int value) |
317 | { | 340 | { |
318 | if (p->iotype != UPIO_AU) | 341 | __raw_writel(value, up->port.membase + 0x28); |
319 | return offset; | ||
320 | return au_io_out_map[offset]; | ||
321 | } | 342 | } |
322 | 343 | ||
323 | #elif defined(CONFIG_SERIAL_8250_RM9K) | 344 | #endif |
345 | |||
346 | #ifdef CONFIG_SERIAL_8250_RM9K | ||
324 | 347 | ||
325 | static const u8 | 348 | static const u8 |
326 | regmap_in[8] = { | 349 | regmap_in[8] = { |
@@ -344,87 +367,79 @@ static const u8 | |||
344 | [UART_SCR] = 0x2c | 367 | [UART_SCR] = 0x2c |
345 | }; | 368 | }; |
346 | 369 | ||
347 | static inline int map_8250_in_reg(struct uart_port *p, int offset) | 370 | static unsigned int rm9k_serial_in(struct uart_port *p, int offset) |
348 | { | 371 | { |
349 | if (p->iotype != UPIO_RM9000) | 372 | offset = regmap_in[offset] << p->regshift; |
350 | return offset; | 373 | return readl(p->membase + offset); |
351 | return regmap_in[offset]; | ||
352 | } | 374 | } |
353 | 375 | ||
354 | static inline int map_8250_out_reg(struct uart_port *p, int offset) | 376 | static void rm9k_serial_out(struct uart_port *p, int offset, int value) |
355 | { | 377 | { |
356 | if (p->iotype != UPIO_RM9000) | 378 | offset = regmap_out[offset] << p->regshift; |
357 | return offset; | 379 | writel(value, p->membase + offset); |
358 | return regmap_out[offset]; | ||
359 | } | 380 | } |
360 | 381 | ||
361 | #else | 382 | static int rm9k_serial_dl_read(struct uart_8250_port *up) |
383 | { | ||
384 | return ((__raw_readl(up->port.membase + 0x10) << 8) | | ||
385 | (__raw_readl(up->port.membase + 0x08) & 0xff)) & 0xffff; | ||
386 | } | ||
362 | 387 | ||
363 | /* sane hardware needs no mapping */ | 388 | static void rm9k_serial_dl_write(struct uart_8250_port *up, int value) |
364 | #define map_8250_in_reg(up, offset) (offset) | 389 | { |
365 | #define map_8250_out_reg(up, offset) (offset) | 390 | __raw_writel(value, up->port.membase + 0x08); |
391 | __raw_writel(value >> 8, up->port.membase + 0x10); | ||
392 | } | ||
366 | 393 | ||
367 | #endif | 394 | #endif |
368 | 395 | ||
369 | static unsigned int hub6_serial_in(struct uart_port *p, int offset) | 396 | static unsigned int hub6_serial_in(struct uart_port *p, int offset) |
370 | { | 397 | { |
371 | offset = map_8250_in_reg(p, offset) << p->regshift; | 398 | offset = offset << p->regshift; |
372 | outb(p->hub6 - 1 + offset, p->iobase); | 399 | outb(p->hub6 - 1 + offset, p->iobase); |
373 | return inb(p->iobase + 1); | 400 | return inb(p->iobase + 1); |
374 | } | 401 | } |
375 | 402 | ||
376 | static void hub6_serial_out(struct uart_port *p, int offset, int value) | 403 | static void hub6_serial_out(struct uart_port *p, int offset, int value) |
377 | { | 404 | { |
378 | offset = map_8250_out_reg(p, offset) << p->regshift; | 405 | offset = offset << p->regshift; |
379 | outb(p->hub6 - 1 + offset, p->iobase); | 406 | outb(p->hub6 - 1 + offset, p->iobase); |
380 | outb(value, p->iobase + 1); | 407 | outb(value, p->iobase + 1); |
381 | } | 408 | } |
382 | 409 | ||
383 | static unsigned int mem_serial_in(struct uart_port *p, int offset) | 410 | static unsigned int mem_serial_in(struct uart_port *p, int offset) |
384 | { | 411 | { |
385 | offset = map_8250_in_reg(p, offset) << p->regshift; | 412 | offset = offset << p->regshift; |
386 | return readb(p->membase + offset); | 413 | return readb(p->membase + offset); |
387 | } | 414 | } |
388 | 415 | ||
389 | static void mem_serial_out(struct uart_port *p, int offset, int value) | 416 | static void mem_serial_out(struct uart_port *p, int offset, int value) |
390 | { | 417 | { |
391 | offset = map_8250_out_reg(p, offset) << p->regshift; | 418 | offset = offset << p->regshift; |
392 | writeb(value, p->membase + offset); | 419 | writeb(value, p->membase + offset); |
393 | } | 420 | } |
394 | 421 | ||
395 | static void mem32_serial_out(struct uart_port *p, int offset, int value) | 422 | static void mem32_serial_out(struct uart_port *p, int offset, int value) |
396 | { | 423 | { |
397 | offset = map_8250_out_reg(p, offset) << p->regshift; | 424 | offset = offset << p->regshift; |
398 | writel(value, p->membase + offset); | 425 | writel(value, p->membase + offset); |
399 | } | 426 | } |
400 | 427 | ||
401 | static unsigned int mem32_serial_in(struct uart_port *p, int offset) | 428 | static unsigned int mem32_serial_in(struct uart_port *p, int offset) |
402 | { | 429 | { |
403 | offset = map_8250_in_reg(p, offset) << p->regshift; | 430 | offset = offset << p->regshift; |
404 | return readl(p->membase + offset); | 431 | return readl(p->membase + offset); |
405 | } | 432 | } |
406 | 433 | ||
407 | static unsigned int au_serial_in(struct uart_port *p, int offset) | ||
408 | { | ||
409 | offset = map_8250_in_reg(p, offset) << p->regshift; | ||
410 | return __raw_readl(p->membase + offset); | ||
411 | } | ||
412 | |||
413 | static void au_serial_out(struct uart_port *p, int offset, int value) | ||
414 | { | ||
415 | offset = map_8250_out_reg(p, offset) << p->regshift; | ||
416 | __raw_writel(value, p->membase + offset); | ||
417 | } | ||
418 | |||
419 | static unsigned int io_serial_in(struct uart_port *p, int offset) | 434 | static unsigned int io_serial_in(struct uart_port *p, int offset) |
420 | { | 435 | { |
421 | offset = map_8250_in_reg(p, offset) << p->regshift; | 436 | offset = offset << p->regshift; |
422 | return inb(p->iobase + offset); | 437 | return inb(p->iobase + offset); |
423 | } | 438 | } |
424 | 439 | ||
425 | static void io_serial_out(struct uart_port *p, int offset, int value) | 440 | static void io_serial_out(struct uart_port *p, int offset, int value) |
426 | { | 441 | { |
427 | offset = map_8250_out_reg(p, offset) << p->regshift; | 442 | offset = offset << p->regshift; |
428 | outb(value, p->iobase + offset); | 443 | outb(value, p->iobase + offset); |
429 | } | 444 | } |
430 | 445 | ||
@@ -434,6 +449,10 @@ static void set_io_from_upio(struct uart_port *p) | |||
434 | { | 449 | { |
435 | struct uart_8250_port *up = | 450 | struct uart_8250_port *up = |
436 | container_of(p, struct uart_8250_port, port); | 451 | container_of(p, struct uart_8250_port, port); |
452 | |||
453 | up->dl_read = default_serial_dl_read; | ||
454 | up->dl_write = default_serial_dl_write; | ||
455 | |||
437 | switch (p->iotype) { | 456 | switch (p->iotype) { |
438 | case UPIO_HUB6: | 457 | case UPIO_HUB6: |
439 | p->serial_in = hub6_serial_in; | 458 | p->serial_in = hub6_serial_in; |
@@ -445,16 +464,28 @@ static void set_io_from_upio(struct uart_port *p) | |||
445 | p->serial_out = mem_serial_out; | 464 | p->serial_out = mem_serial_out; |
446 | break; | 465 | break; |
447 | 466 | ||
448 | case UPIO_RM9000: | ||
449 | case UPIO_MEM32: | 467 | case UPIO_MEM32: |
450 | p->serial_in = mem32_serial_in; | 468 | p->serial_in = mem32_serial_in; |
451 | p->serial_out = mem32_serial_out; | 469 | p->serial_out = mem32_serial_out; |
452 | break; | 470 | break; |
453 | 471 | ||
472 | #ifdef CONFIG_SERIAL_8250_RM9K | ||
473 | case UPIO_RM9000: | ||
474 | p->serial_in = rm9k_serial_in; | ||
475 | p->serial_out = rm9k_serial_out; | ||
476 | up->dl_read = rm9k_serial_dl_read; | ||
477 | up->dl_write = rm9k_serial_dl_write; | ||
478 | break; | ||
479 | #endif | ||
480 | |||
481 | #ifdef CONFIG_MIPS_ALCHEMY | ||
454 | case UPIO_AU: | 482 | case UPIO_AU: |
455 | p->serial_in = au_serial_in; | 483 | p->serial_in = au_serial_in; |
456 | p->serial_out = au_serial_out; | 484 | p->serial_out = au_serial_out; |
485 | up->dl_read = au_serial_dl_read; | ||
486 | up->dl_write = au_serial_dl_write; | ||
457 | break; | 487 | break; |
488 | #endif | ||
458 | 489 | ||
459 | default: | 490 | default: |
460 | p->serial_in = io_serial_in; | 491 | p->serial_in = io_serial_in; |
@@ -481,59 +512,6 @@ serial_port_out_sync(struct uart_port *p, int offset, int value) | |||
481 | } | 512 | } |
482 | } | 513 | } |
483 | 514 | ||
484 | /* Uart divisor latch read */ | ||
485 | static inline int _serial_dl_read(struct uart_8250_port *up) | ||
486 | { | ||
487 | return serial_in(up, UART_DLL) | serial_in(up, UART_DLM) << 8; | ||
488 | } | ||
489 | |||
490 | /* Uart divisor latch write */ | ||
491 | static inline void _serial_dl_write(struct uart_8250_port *up, int value) | ||
492 | { | ||
493 | serial_out(up, UART_DLL, value & 0xff); | ||
494 | serial_out(up, UART_DLM, value >> 8 & 0xff); | ||
495 | } | ||
496 | |||
497 | #if defined(CONFIG_MIPS_ALCHEMY) | ||
498 | /* Au1x00 haven't got a standard divisor latch */ | ||
499 | static int serial_dl_read(struct uart_8250_port *up) | ||
500 | { | ||
501 | if (up->port.iotype == UPIO_AU) | ||
502 | return __raw_readl(up->port.membase + 0x28); | ||
503 | else | ||
504 | return _serial_dl_read(up); | ||
505 | } | ||
506 | |||
507 | static void serial_dl_write(struct uart_8250_port *up, int value) | ||
508 | { | ||
509 | if (up->port.iotype == UPIO_AU) | ||
510 | __raw_writel(value, up->port.membase + 0x28); | ||
511 | else | ||
512 | _serial_dl_write(up, value); | ||
513 | } | ||
514 | #elif defined(CONFIG_SERIAL_8250_RM9K) | ||
515 | static int serial_dl_read(struct uart_8250_port *up) | ||
516 | { | ||
517 | return (up->port.iotype == UPIO_RM9000) ? | ||
518 | (((__raw_readl(up->port.membase + 0x10) << 8) | | ||
519 | (__raw_readl(up->port.membase + 0x08) & 0xff)) & 0xffff) : | ||
520 | _serial_dl_read(up); | ||
521 | } | ||
522 | |||
523 | static void serial_dl_write(struct uart_8250_port *up, int value) | ||
524 | { | ||
525 | if (up->port.iotype == UPIO_RM9000) { | ||
526 | __raw_writel(value, up->port.membase + 0x08); | ||
527 | __raw_writel(value >> 8, up->port.membase + 0x10); | ||
528 | } else { | ||
529 | _serial_dl_write(up, value); | ||
530 | } | ||
531 | } | ||
532 | #else | ||
533 | #define serial_dl_read(up) _serial_dl_read(up) | ||
534 | #define serial_dl_write(up, value) _serial_dl_write(up, value) | ||
535 | #endif | ||
536 | |||
537 | /* | 515 | /* |
538 | * For the 16C950 | 516 | * For the 16C950 |
539 | */ | 517 | */ |
@@ -568,6 +546,16 @@ static void serial8250_clear_fifos(struct uart_8250_port *p) | |||
568 | } | 546 | } |
569 | } | 547 | } |
570 | 548 | ||
549 | void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p) | ||
550 | { | ||
551 | unsigned char fcr; | ||
552 | |||
553 | serial8250_clear_fifos(p); | ||
554 | fcr = uart_config[p->port.type].fcr; | ||
555 | serial_out(p, UART_FCR, fcr); | ||
556 | } | ||
557 | EXPORT_SYMBOL_GPL(serial8250_clear_and_reinit_fifos); | ||
558 | |||
571 | /* | 559 | /* |
572 | * IER sleep support. UARTs which have EFRs need the "extended | 560 | * IER sleep support. UARTs which have EFRs need the "extended |
573 | * capability" bit enabled. Note that on XR16C850s, we need to | 561 | * capability" bit enabled. Note that on XR16C850s, we need to |
@@ -1332,27 +1320,6 @@ static void serial8250_enable_ms(struct uart_port *port) | |||
1332 | } | 1320 | } |
1333 | 1321 | ||
1334 | /* | 1322 | /* |
1335 | * Clear the Tegra rx fifo after a break | ||
1336 | * | ||
1337 | * FIXME: This needs to become a port specific callback once we have a | ||
1338 | * framework for this | ||
1339 | */ | ||
1340 | static void clear_rx_fifo(struct uart_8250_port *up) | ||
1341 | { | ||
1342 | unsigned int status, tmout = 10000; | ||
1343 | do { | ||
1344 | status = serial_in(up, UART_LSR); | ||
1345 | if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS)) | ||
1346 | status = serial_in(up, UART_RX); | ||
1347 | else | ||
1348 | break; | ||
1349 | if (--tmout == 0) | ||
1350 | break; | ||
1351 | udelay(1); | ||
1352 | } while (1); | ||
1353 | } | ||
1354 | |||
1355 | /* | ||
1356 | * serial8250_rx_chars: processes according to the passed in LSR | 1323 | * serial8250_rx_chars: processes according to the passed in LSR |
1357 | * value, and returns the remaining LSR bits not handled | 1324 | * value, and returns the remaining LSR bits not handled |
1358 | * by this Rx routine. | 1325 | * by this Rx routine. |
@@ -1386,20 +1353,10 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) | |||
1386 | up->lsr_saved_flags = 0; | 1353 | up->lsr_saved_flags = 0; |
1387 | 1354 | ||
1388 | if (unlikely(lsr & UART_LSR_BRK_ERROR_BITS)) { | 1355 | if (unlikely(lsr & UART_LSR_BRK_ERROR_BITS)) { |
1389 | /* | ||
1390 | * For statistics only | ||
1391 | */ | ||
1392 | if (lsr & UART_LSR_BI) { | 1356 | if (lsr & UART_LSR_BI) { |
1393 | lsr &= ~(UART_LSR_FE | UART_LSR_PE); | 1357 | lsr &= ~(UART_LSR_FE | UART_LSR_PE); |
1394 | port->icount.brk++; | 1358 | port->icount.brk++; |
1395 | /* | 1359 | /* |
1396 | * If tegra port then clear the rx fifo to | ||
1397 | * accept another break/character. | ||
1398 | */ | ||
1399 | if (port->type == PORT_TEGRA) | ||
1400 | clear_rx_fifo(up); | ||
1401 | |||
1402 | /* | ||
1403 | * We do the SysRQ and SAK checking | 1360 | * We do the SysRQ and SAK checking |
1404 | * here because otherwise the break | 1361 | * here because otherwise the break |
1405 | * may get masked by ignore_status_mask | 1362 | * may get masked by ignore_status_mask |
@@ -2280,10 +2237,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, | |||
2280 | quot++; | 2237 | quot++; |
2281 | 2238 | ||
2282 | if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { | 2239 | if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { |
2283 | if (baud < 2400) | 2240 | fcr = uart_config[port->type].fcr; |
2284 | fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1; | 2241 | if (baud < 2400) { |
2285 | else | 2242 | fcr &= ~UART_FCR_TRIGGER_MASK; |
2286 | fcr = uart_config[port->type].fcr; | 2243 | fcr |= UART_FCR_TRIGGER_1; |
2244 | } | ||
2287 | } | 2245 | } |
2288 | 2246 | ||
2289 | /* | 2247 | /* |
@@ -3037,6 +2995,7 @@ static int __devinit serial8250_probe(struct platform_device *dev) | |||
3037 | port.serial_in = p->serial_in; | 2995 | port.serial_in = p->serial_in; |
3038 | port.serial_out = p->serial_out; | 2996 | port.serial_out = p->serial_out; |
3039 | port.handle_irq = p->handle_irq; | 2997 | port.handle_irq = p->handle_irq; |
2998 | port.handle_break = p->handle_break; | ||
3040 | port.set_termios = p->set_termios; | 2999 | port.set_termios = p->set_termios; |
3041 | port.pm = p->pm; | 3000 | port.pm = p->pm; |
3042 | port.dev = &dev->dev; | 3001 | port.dev = &dev->dev; |
@@ -3153,7 +3112,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
3153 | } | 3112 | } |
3154 | 3113 | ||
3155 | /** | 3114 | /** |
3156 | * serial8250_register_port - register a serial port | 3115 | * serial8250_register_8250_port - register a serial port |
3157 | * @port: serial port template | 3116 | * @port: serial port template |
3158 | * | 3117 | * |
3159 | * Configure the serial port specified by the request. If the | 3118 | * Configure the serial port specified by the request. If the |
@@ -3165,50 +3124,56 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
3165 | * | 3124 | * |
3166 | * On success the port is ready to use and the line number is returned. | 3125 | * On success the port is ready to use and the line number is returned. |
3167 | */ | 3126 | */ |
3168 | int serial8250_register_port(struct uart_port *port) | 3127 | int serial8250_register_8250_port(struct uart_8250_port *up) |
3169 | { | 3128 | { |
3170 | struct uart_8250_port *uart; | 3129 | struct uart_8250_port *uart; |
3171 | int ret = -ENOSPC; | 3130 | int ret = -ENOSPC; |
3172 | 3131 | ||
3173 | if (port->uartclk == 0) | 3132 | if (up->port.uartclk == 0) |
3174 | return -EINVAL; | 3133 | return -EINVAL; |
3175 | 3134 | ||
3176 | mutex_lock(&serial_mutex); | 3135 | mutex_lock(&serial_mutex); |
3177 | 3136 | ||
3178 | uart = serial8250_find_match_or_unused(port); | 3137 | uart = serial8250_find_match_or_unused(&up->port); |
3179 | if (uart) { | 3138 | if (uart) { |
3180 | uart_remove_one_port(&serial8250_reg, &uart->port); | 3139 | uart_remove_one_port(&serial8250_reg, &uart->port); |
3181 | 3140 | ||
3182 | uart->port.iobase = port->iobase; | 3141 | uart->port.iobase = up->port.iobase; |
3183 | uart->port.membase = port->membase; | 3142 | uart->port.membase = up->port.membase; |
3184 | uart->port.irq = port->irq; | 3143 | uart->port.irq = up->port.irq; |
3185 | uart->port.irqflags = port->irqflags; | 3144 | uart->port.irqflags = up->port.irqflags; |
3186 | uart->port.uartclk = port->uartclk; | 3145 | uart->port.uartclk = up->port.uartclk; |
3187 | uart->port.fifosize = port->fifosize; | 3146 | uart->port.fifosize = up->port.fifosize; |
3188 | uart->port.regshift = port->regshift; | 3147 | uart->port.regshift = up->port.regshift; |
3189 | uart->port.iotype = port->iotype; | 3148 | uart->port.iotype = up->port.iotype; |
3190 | uart->port.flags = port->flags | UPF_BOOT_AUTOCONF; | 3149 | uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF; |
3191 | uart->port.mapbase = port->mapbase; | 3150 | uart->port.mapbase = up->port.mapbase; |
3192 | uart->port.private_data = port->private_data; | 3151 | uart->port.private_data = up->port.private_data; |
3193 | if (port->dev) | 3152 | if (up->port.dev) |
3194 | uart->port.dev = port->dev; | 3153 | uart->port.dev = up->port.dev; |
3195 | 3154 | ||
3196 | if (port->flags & UPF_FIXED_TYPE) | 3155 | if (up->port.flags & UPF_FIXED_TYPE) |
3197 | serial8250_init_fixed_type_port(uart, port->type); | 3156 | serial8250_init_fixed_type_port(uart, up->port.type); |
3198 | 3157 | ||
3199 | set_io_from_upio(&uart->port); | 3158 | set_io_from_upio(&uart->port); |
3200 | /* Possibly override default I/O functions. */ | 3159 | /* Possibly override default I/O functions. */ |
3201 | if (port->serial_in) | 3160 | if (up->port.serial_in) |
3202 | uart->port.serial_in = port->serial_in; | 3161 | uart->port.serial_in = up->port.serial_in; |
3203 | if (port->serial_out) | 3162 | if (up->port.serial_out) |
3204 | uart->port.serial_out = port->serial_out; | 3163 | uart->port.serial_out = up->port.serial_out; |
3205 | if (port->handle_irq) | 3164 | if (up->port.handle_irq) |
3206 | uart->port.handle_irq = port->handle_irq; | 3165 | uart->port.handle_irq = up->port.handle_irq; |
3207 | /* Possibly override set_termios call */ | 3166 | /* Possibly override set_termios call */ |
3208 | if (port->set_termios) | 3167 | if (up->port.set_termios) |
3209 | uart->port.set_termios = port->set_termios; | 3168 | uart->port.set_termios = up->port.set_termios; |
3210 | if (port->pm) | 3169 | if (up->port.pm) |
3211 | uart->port.pm = port->pm; | 3170 | uart->port.pm = up->port.pm; |
3171 | if (up->port.handle_break) | ||
3172 | uart->port.handle_break = up->port.handle_break; | ||
3173 | if (up->dl_read) | ||
3174 | uart->dl_read = up->dl_read; | ||
3175 | if (up->dl_write) | ||
3176 | uart->dl_write = up->dl_write; | ||
3212 | 3177 | ||
3213 | if (serial8250_isa_config != NULL) | 3178 | if (serial8250_isa_config != NULL) |
3214 | serial8250_isa_config(0, &uart->port, | 3179 | serial8250_isa_config(0, &uart->port, |
@@ -3222,6 +3187,29 @@ int serial8250_register_port(struct uart_port *port) | |||
3222 | 3187 | ||
3223 | return ret; | 3188 | return ret; |
3224 | } | 3189 | } |
3190 | EXPORT_SYMBOL(serial8250_register_8250_port); | ||
3191 | |||
3192 | /** | ||
3193 | * serial8250_register_port - register a serial port | ||
3194 | * @port: serial port template | ||
3195 | * | ||
3196 | * Configure the serial port specified by the request. If the | ||
3197 | * port exists and is in use, it is hung up and unregistered | ||
3198 | * first. | ||
3199 | * | ||
3200 | * The port is then probed and if necessary the IRQ is autodetected | ||
3201 | * If this fails an error is returned. | ||
3202 | * | ||
3203 | * On success the port is ready to use and the line number is returned. | ||
3204 | */ | ||
3205 | int serial8250_register_port(struct uart_port *port) | ||
3206 | { | ||
3207 | struct uart_8250_port up; | ||
3208 | |||
3209 | memset(&up, 0, sizeof(up)); | ||
3210 | memcpy(&up.port, port, sizeof(*port)); | ||
3211 | return serial8250_register_8250_port(&up); | ||
3212 | } | ||
3225 | EXPORT_SYMBOL(serial8250_register_port); | 3213 | EXPORT_SYMBOL(serial8250_register_port); |
3226 | 3214 | ||
3227 | /** | 3215 | /** |
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 2868a1da254d..f9719d167c8d 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h | |||
@@ -37,6 +37,10 @@ struct uart_8250_port { | |||
37 | unsigned char lsr_saved_flags; | 37 | unsigned char lsr_saved_flags; |
38 | #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA | 38 | #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA |
39 | unsigned char msr_saved_flags; | 39 | unsigned char msr_saved_flags; |
40 | |||
41 | /* 8250 specific callbacks */ | ||
42 | int (*dl_read)(struct uart_8250_port *); | ||
43 | void (*dl_write)(struct uart_8250_port *, int); | ||
40 | }; | 44 | }; |
41 | 45 | ||
42 | struct old_serial_port { | 46 | struct old_serial_port { |
@@ -96,6 +100,18 @@ static inline void serial_out(struct uart_8250_port *up, int offset, int value) | |||
96 | up->port.serial_out(&up->port, offset, value); | 100 | up->port.serial_out(&up->port, offset, value); |
97 | } | 101 | } |
98 | 102 | ||
103 | void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p); | ||
104 | |||
105 | static inline int serial_dl_read(struct uart_8250_port *up) | ||
106 | { | ||
107 | return up->dl_read(up); | ||
108 | } | ||
109 | |||
110 | static inline void serial_dl_write(struct uart_8250_port *up, int value) | ||
111 | { | ||
112 | up->dl_write(up, value); | ||
113 | } | ||
114 | |||
99 | #if defined(__alpha__) && !defined(CONFIG_PCI) | 115 | #if defined(__alpha__) && !defined(CONFIG_PCI) |
100 | /* | 116 | /* |
101 | * Digital did something really horribly wrong with the OUT1 and OUT2 | 117 | * Digital did something really horribly wrong with the OUT1 and OUT2 |
diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c new file mode 100644 index 000000000000..3a0363e7f3a7 --- /dev/null +++ b/drivers/tty/serial/8250/8250_em.c | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | * Renesas Emma Mobile 8250 driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Magnus Damm | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/device.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/io.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/serial_8250.h> | ||
25 | #include <linux/serial_core.h> | ||
26 | #include <linux/serial_reg.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/clk.h> | ||
29 | #include <linux/slab.h> | ||
30 | |||
31 | #include "8250.h" | ||
32 | |||
33 | #define UART_DLL_EM 9 | ||
34 | #define UART_DLM_EM 10 | ||
35 | |||
36 | struct serial8250_em_priv { | ||
37 | struct clk *sclk; | ||
38 | int line; | ||
39 | }; | ||
40 | |||
41 | static void serial8250_em_serial_out(struct uart_port *p, int offset, int value) | ||
42 | { | ||
43 | switch (offset) { | ||
44 | case UART_TX: /* TX @ 0x00 */ | ||
45 | writeb(value, p->membase); | ||
46 | break; | ||
47 | case UART_FCR: /* FCR @ 0x0c (+1) */ | ||
48 | case UART_LCR: /* LCR @ 0x10 (+1) */ | ||
49 | case UART_MCR: /* MCR @ 0x14 (+1) */ | ||
50 | case UART_SCR: /* SCR @ 0x20 (+1) */ | ||
51 | writel(value, p->membase + ((offset + 1) << 2)); | ||
52 | break; | ||
53 | case UART_IER: /* IER @ 0x04 */ | ||
54 | value &= 0x0f; /* only 4 valid bits - not Xscale */ | ||
55 | /* fall-through */ | ||
56 | case UART_DLL_EM: /* DLL @ 0x24 (+9) */ | ||
57 | case UART_DLM_EM: /* DLM @ 0x28 (+9) */ | ||
58 | writel(value, p->membase + (offset << 2)); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | static unsigned int serial8250_em_serial_in(struct uart_port *p, int offset) | ||
63 | { | ||
64 | switch (offset) { | ||
65 | case UART_RX: /* RX @ 0x00 */ | ||
66 | return readb(p->membase); | ||
67 | case UART_MCR: /* MCR @ 0x14 (+1) */ | ||
68 | case UART_LSR: /* LSR @ 0x18 (+1) */ | ||
69 | case UART_MSR: /* MSR @ 0x1c (+1) */ | ||
70 | case UART_SCR: /* SCR @ 0x20 (+1) */ | ||
71 | return readl(p->membase + ((offset + 1) << 2)); | ||
72 | case UART_IER: /* IER @ 0x04 */ | ||
73 | case UART_IIR: /* IIR @ 0x08 */ | ||
74 | case UART_DLL_EM: /* DLL @ 0x24 (+9) */ | ||
75 | case UART_DLM_EM: /* DLM @ 0x28 (+9) */ | ||
76 | return readl(p->membase + (offset << 2)); | ||
77 | } | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int serial8250_em_serial_dl_read(struct uart_8250_port *up) | ||
82 | { | ||
83 | return serial_in(up, UART_DLL_EM) | serial_in(up, UART_DLM_EM) << 8; | ||
84 | } | ||
85 | |||
86 | static void serial8250_em_serial_dl_write(struct uart_8250_port *up, int value) | ||
87 | { | ||
88 | serial_out(up, UART_DLL_EM, value & 0xff); | ||
89 | serial_out(up, UART_DLM_EM, value >> 8 & 0xff); | ||
90 | } | ||
91 | |||
92 | static int __devinit serial8250_em_probe(struct platform_device *pdev) | ||
93 | { | ||
94 | struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
95 | struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
96 | struct serial8250_em_priv *priv; | ||
97 | struct uart_8250_port up; | ||
98 | int ret = -EINVAL; | ||
99 | |||
100 | if (!regs || !irq) { | ||
101 | dev_err(&pdev->dev, "missing registers or irq\n"); | ||
102 | goto err0; | ||
103 | } | ||
104 | |||
105 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
106 | if (!priv) { | ||
107 | dev_err(&pdev->dev, "unable to allocate private data\n"); | ||
108 | ret = -ENOMEM; | ||
109 | goto err0; | ||
110 | } | ||
111 | |||
112 | priv->sclk = clk_get(&pdev->dev, "sclk"); | ||
113 | if (IS_ERR(priv->sclk)) { | ||
114 | dev_err(&pdev->dev, "unable to get clock\n"); | ||
115 | ret = PTR_ERR(priv->sclk); | ||
116 | goto err1; | ||
117 | } | ||
118 | |||
119 | memset(&up, 0, sizeof(up)); | ||
120 | up.port.mapbase = regs->start; | ||
121 | up.port.irq = irq->start; | ||
122 | up.port.type = PORT_UNKNOWN; | ||
123 | up.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP; | ||
124 | up.port.dev = &pdev->dev; | ||
125 | up.port.private_data = priv; | ||
126 | |||
127 | clk_enable(priv->sclk); | ||
128 | up.port.uartclk = clk_get_rate(priv->sclk); | ||
129 | |||
130 | up.port.iotype = UPIO_MEM32; | ||
131 | up.port.serial_in = serial8250_em_serial_in; | ||
132 | up.port.serial_out = serial8250_em_serial_out; | ||
133 | up.dl_read = serial8250_em_serial_dl_read; | ||
134 | up.dl_write = serial8250_em_serial_dl_write; | ||
135 | |||
136 | ret = serial8250_register_8250_port(&up); | ||
137 | if (ret < 0) { | ||
138 | dev_err(&pdev->dev, "unable to register 8250 port\n"); | ||
139 | goto err2; | ||
140 | } | ||
141 | |||
142 | priv->line = ret; | ||
143 | platform_set_drvdata(pdev, priv); | ||
144 | return 0; | ||
145 | |||
146 | err2: | ||
147 | clk_disable(priv->sclk); | ||
148 | clk_put(priv->sclk); | ||
149 | err1: | ||
150 | kfree(priv); | ||
151 | err0: | ||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | static int __devexit serial8250_em_remove(struct platform_device *pdev) | ||
156 | { | ||
157 | struct serial8250_em_priv *priv = platform_get_drvdata(pdev); | ||
158 | |||
159 | serial8250_unregister_port(priv->line); | ||
160 | clk_disable(priv->sclk); | ||
161 | clk_put(priv->sclk); | ||
162 | kfree(priv); | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static const struct of_device_id serial8250_em_dt_ids[] __devinitconst = { | ||
167 | { .compatible = "renesas,em-uart", }, | ||
168 | {}, | ||
169 | }; | ||
170 | MODULE_DEVICE_TABLE(of, serial8250_em_dt_ids); | ||
171 | |||
172 | static struct platform_driver serial8250_em_platform_driver = { | ||
173 | .driver = { | ||
174 | .name = "serial8250-em", | ||
175 | .of_match_table = serial8250_em_dt_ids, | ||
176 | .owner = THIS_MODULE, | ||
177 | }, | ||
178 | .probe = serial8250_em_probe, | ||
179 | .remove = __devexit_p(serial8250_em_remove), | ||
180 | }; | ||
181 | |||
182 | module_platform_driver(serial8250_em_platform_driver); | ||
183 | |||
184 | MODULE_AUTHOR("Magnus Damm"); | ||
185 | MODULE_DESCRIPTION("Renesas Emma Mobile 8250 Driver"); | ||
186 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 858dca865d6a..28e7c7cce893 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
20 | #include <linux/serial_reg.h> | ||
20 | #include <linux/serial_core.h> | 21 | #include <linux/serial_core.h> |
21 | #include <linux/8250_pci.h> | 22 | #include <linux/8250_pci.h> |
22 | #include <linux/bitops.h> | 23 | #include <linux/bitops.h> |
@@ -1092,11 +1093,49 @@ static int skip_tx_en_setup(struct serial_private *priv, | |||
1092 | return pci_default_setup(priv, board, port, idx); | 1093 | return pci_default_setup(priv, board, port, idx); |
1093 | } | 1094 | } |
1094 | 1095 | ||
1096 | static void kt_handle_break(struct uart_port *p) | ||
1097 | { | ||
1098 | struct uart_8250_port *up = | ||
1099 | container_of(p, struct uart_8250_port, port); | ||
1100 | /* | ||
1101 | * On receipt of a BI, serial device in Intel ME (Intel | ||
1102 | * management engine) needs to have its fifos cleared for sane | ||
1103 | * SOL (Serial Over Lan) output. | ||
1104 | */ | ||
1105 | serial8250_clear_and_reinit_fifos(up); | ||
1106 | } | ||
1107 | |||
1108 | static unsigned int kt_serial_in(struct uart_port *p, int offset) | ||
1109 | { | ||
1110 | struct uart_8250_port *up = | ||
1111 | container_of(p, struct uart_8250_port, port); | ||
1112 | unsigned int val; | ||
1113 | |||
1114 | /* | ||
1115 | * When the Intel ME (management engine) gets reset its serial | ||
1116 | * port registers could return 0 momentarily. Functions like | ||
1117 | * serial8250_console_write, read and save the IER, perform | ||
1118 | * some operation and then restore it. In order to avoid | ||
1119 | * setting IER register inadvertently to 0, if the value read | ||
1120 | * is 0, double check with ier value in uart_8250_port and use | ||
1121 | * that instead. up->ier should be the same value as what is | ||
1122 | * currently configured. | ||
1123 | */ | ||
1124 | val = inb(p->iobase + offset); | ||
1125 | if (offset == UART_IER) { | ||
1126 | if (val == 0) | ||
1127 | val = up->ier; | ||
1128 | } | ||
1129 | return val; | ||
1130 | } | ||
1131 | |||
1095 | static int kt_serial_setup(struct serial_private *priv, | 1132 | static int kt_serial_setup(struct serial_private *priv, |
1096 | const struct pciserial_board *board, | 1133 | const struct pciserial_board *board, |
1097 | struct uart_port *port, int idx) | 1134 | struct uart_port *port, int idx) |
1098 | { | 1135 | { |
1099 | port->flags |= UPF_BUG_THRE; | 1136 | port->flags |= UPF_BUG_THRE; |
1137 | port->serial_in = kt_serial_in; | ||
1138 | port->handle_break = kt_handle_break; | ||
1100 | return skip_tx_en_setup(priv, board, port, idx); | 1139 | return skip_tx_en_setup(priv, board, port, idx); |
1101 | } | 1140 | } |
1102 | 1141 | ||
@@ -1609,54 +1648,72 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { | |||
1609 | { | 1648 | { |
1610 | .vendor = PCI_VENDOR_ID_INTEL, | 1649 | .vendor = PCI_VENDOR_ID_INTEL, |
1611 | .device = 0x8811, | 1650 | .device = 0x8811, |
1651 | .subvendor = PCI_ANY_ID, | ||
1652 | .subdevice = PCI_ANY_ID, | ||
1612 | .init = pci_eg20t_init, | 1653 | .init = pci_eg20t_init, |
1613 | .setup = pci_default_setup, | 1654 | .setup = pci_default_setup, |
1614 | }, | 1655 | }, |
1615 | { | 1656 | { |
1616 | .vendor = PCI_VENDOR_ID_INTEL, | 1657 | .vendor = PCI_VENDOR_ID_INTEL, |
1617 | .device = 0x8812, | 1658 | .device = 0x8812, |
1659 | .subvendor = PCI_ANY_ID, | ||
1660 | .subdevice = PCI_ANY_ID, | ||
1618 | .init = pci_eg20t_init, | 1661 | .init = pci_eg20t_init, |
1619 | .setup = pci_default_setup, | 1662 | .setup = pci_default_setup, |
1620 | }, | 1663 | }, |
1621 | { | 1664 | { |
1622 | .vendor = PCI_VENDOR_ID_INTEL, | 1665 | .vendor = PCI_VENDOR_ID_INTEL, |
1623 | .device = 0x8813, | 1666 | .device = 0x8813, |
1667 | .subvendor = PCI_ANY_ID, | ||
1668 | .subdevice = PCI_ANY_ID, | ||
1624 | .init = pci_eg20t_init, | 1669 | .init = pci_eg20t_init, |
1625 | .setup = pci_default_setup, | 1670 | .setup = pci_default_setup, |
1626 | }, | 1671 | }, |
1627 | { | 1672 | { |
1628 | .vendor = PCI_VENDOR_ID_INTEL, | 1673 | .vendor = PCI_VENDOR_ID_INTEL, |
1629 | .device = 0x8814, | 1674 | .device = 0x8814, |
1675 | .subvendor = PCI_ANY_ID, | ||
1676 | .subdevice = PCI_ANY_ID, | ||
1630 | .init = pci_eg20t_init, | 1677 | .init = pci_eg20t_init, |
1631 | .setup = pci_default_setup, | 1678 | .setup = pci_default_setup, |
1632 | }, | 1679 | }, |
1633 | { | 1680 | { |
1634 | .vendor = 0x10DB, | 1681 | .vendor = 0x10DB, |
1635 | .device = 0x8027, | 1682 | .device = 0x8027, |
1683 | .subvendor = PCI_ANY_ID, | ||
1684 | .subdevice = PCI_ANY_ID, | ||
1636 | .init = pci_eg20t_init, | 1685 | .init = pci_eg20t_init, |
1637 | .setup = pci_default_setup, | 1686 | .setup = pci_default_setup, |
1638 | }, | 1687 | }, |
1639 | { | 1688 | { |
1640 | .vendor = 0x10DB, | 1689 | .vendor = 0x10DB, |
1641 | .device = 0x8028, | 1690 | .device = 0x8028, |
1691 | .subvendor = PCI_ANY_ID, | ||
1692 | .subdevice = PCI_ANY_ID, | ||
1642 | .init = pci_eg20t_init, | 1693 | .init = pci_eg20t_init, |
1643 | .setup = pci_default_setup, | 1694 | .setup = pci_default_setup, |
1644 | }, | 1695 | }, |
1645 | { | 1696 | { |
1646 | .vendor = 0x10DB, | 1697 | .vendor = 0x10DB, |
1647 | .device = 0x8029, | 1698 | .device = 0x8029, |
1699 | .subvendor = PCI_ANY_ID, | ||
1700 | .subdevice = PCI_ANY_ID, | ||
1648 | .init = pci_eg20t_init, | 1701 | .init = pci_eg20t_init, |
1649 | .setup = pci_default_setup, | 1702 | .setup = pci_default_setup, |
1650 | }, | 1703 | }, |
1651 | { | 1704 | { |
1652 | .vendor = 0x10DB, | 1705 | .vendor = 0x10DB, |
1653 | .device = 0x800C, | 1706 | .device = 0x800C, |
1707 | .subvendor = PCI_ANY_ID, | ||
1708 | .subdevice = PCI_ANY_ID, | ||
1654 | .init = pci_eg20t_init, | 1709 | .init = pci_eg20t_init, |
1655 | .setup = pci_default_setup, | 1710 | .setup = pci_default_setup, |
1656 | }, | 1711 | }, |
1657 | { | 1712 | { |
1658 | .vendor = 0x10DB, | 1713 | .vendor = 0x10DB, |
1659 | .device = 0x800D, | 1714 | .device = 0x800D, |
1715 | .subvendor = PCI_ANY_ID, | ||
1716 | .subdevice = PCI_ANY_ID, | ||
1660 | .init = pci_eg20t_init, | 1717 | .init = pci_eg20t_init, |
1661 | .setup = pci_default_setup, | 1718 | .setup = pci_default_setup, |
1662 | }, | 1719 | }, |
@@ -2775,6 +2832,12 @@ void pciserial_suspend_ports(struct serial_private *priv) | |||
2775 | for (i = 0; i < priv->nr; i++) | 2832 | for (i = 0; i < priv->nr; i++) |
2776 | if (priv->line[i] >= 0) | 2833 | if (priv->line[i] >= 0) |
2777 | serial8250_suspend_port(priv->line[i]); | 2834 | serial8250_suspend_port(priv->line[i]); |
2835 | |||
2836 | /* | ||
2837 | * Ensure that every init quirk is properly torn down | ||
2838 | */ | ||
2839 | if (priv->quirk->exit) | ||
2840 | priv->quirk->exit(priv->dev); | ||
2778 | } | 2841 | } |
2779 | EXPORT_SYMBOL_GPL(pciserial_suspend_ports); | 2842 | EXPORT_SYMBOL_GPL(pciserial_suspend_ports); |
2780 | 2843 | ||
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index 591f8018e7dd..8bc7ecbf6bea 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig | |||
@@ -278,3 +278,11 @@ config SERIAL_8250_DW | |||
278 | help | 278 | help |
279 | Selecting this option will enable handling of the extra features | 279 | Selecting this option will enable handling of the extra features |
280 | present in the Synopsys DesignWare APB UART. | 280 | present in the Synopsys DesignWare APB UART. |
281 | |||
282 | config SERIAL_8250_EM | ||
283 | tristate "Support for Emma Mobile intergrated serial port" | ||
284 | depends on SERIAL_8250 && ARM && HAVE_CLK | ||
285 | help | ||
286 | Selecting this option will add support for the integrated serial | ||
287 | port hardware found on the Emma Mobile line of processors. | ||
288 | If unsure, say N. | ||
diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index 867bba738908..3f35eacdf673 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile | |||
@@ -18,3 +18,4 @@ obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o | |||
18 | obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o | 18 | obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o |
19 | obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o | 19 | obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o |
20 | obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o | 20 | obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o |
21 | obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o | ||
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 062ef8c2b3cb..4ad721fb8405 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c | |||
@@ -68,30 +68,6 @@ | |||
68 | #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) | 68 | #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) |
69 | #define UART_DUMMY_DR_RX (1 << 16) | 69 | #define UART_DUMMY_DR_RX (1 << 16) |
70 | 70 | ||
71 | |||
72 | #define UART_WA_SAVE_NR 14 | ||
73 | |||
74 | static void pl011_lockup_wa(unsigned long data); | ||
75 | static const u32 uart_wa_reg[UART_WA_SAVE_NR] = { | ||
76 | ST_UART011_DMAWM, | ||
77 | ST_UART011_TIMEOUT, | ||
78 | ST_UART011_LCRH_RX, | ||
79 | UART011_IBRD, | ||
80 | UART011_FBRD, | ||
81 | ST_UART011_LCRH_TX, | ||
82 | UART011_IFLS, | ||
83 | ST_UART011_XFCR, | ||
84 | ST_UART011_XON1, | ||
85 | ST_UART011_XON2, | ||
86 | ST_UART011_XOFF1, | ||
87 | ST_UART011_XOFF2, | ||
88 | UART011_CR, | ||
89 | UART011_IMSC | ||
90 | }; | ||
91 | |||
92 | static u32 uart_wa_regdata[UART_WA_SAVE_NR]; | ||
93 | static DECLARE_TASKLET(pl011_lockup_tlet, pl011_lockup_wa, 0); | ||
94 | |||
95 | /* There is by now at least one vendor with differing details, so handle it */ | 71 | /* There is by now at least one vendor with differing details, so handle it */ |
96 | struct vendor_data { | 72 | struct vendor_data { |
97 | unsigned int ifls; | 73 | unsigned int ifls; |
@@ -101,6 +77,7 @@ struct vendor_data { | |||
101 | bool oversampling; | 77 | bool oversampling; |
102 | bool interrupt_may_hang; /* vendor-specific */ | 78 | bool interrupt_may_hang; /* vendor-specific */ |
103 | bool dma_threshold; | 79 | bool dma_threshold; |
80 | bool cts_event_workaround; | ||
104 | }; | 81 | }; |
105 | 82 | ||
106 | static struct vendor_data vendor_arm = { | 83 | static struct vendor_data vendor_arm = { |
@@ -110,6 +87,7 @@ static struct vendor_data vendor_arm = { | |||
110 | .lcrh_rx = UART011_LCRH, | 87 | .lcrh_rx = UART011_LCRH, |
111 | .oversampling = false, | 88 | .oversampling = false, |
112 | .dma_threshold = false, | 89 | .dma_threshold = false, |
90 | .cts_event_workaround = false, | ||
113 | }; | 91 | }; |
114 | 92 | ||
115 | static struct vendor_data vendor_st = { | 93 | static struct vendor_data vendor_st = { |
@@ -120,6 +98,7 @@ static struct vendor_data vendor_st = { | |||
120 | .oversampling = true, | 98 | .oversampling = true, |
121 | .interrupt_may_hang = true, | 99 | .interrupt_may_hang = true, |
122 | .dma_threshold = true, | 100 | .dma_threshold = true, |
101 | .cts_event_workaround = true, | ||
123 | }; | 102 | }; |
124 | 103 | ||
125 | static struct uart_amba_port *amba_ports[UART_NR]; | 104 | static struct uart_amba_port *amba_ports[UART_NR]; |
@@ -1055,69 +1034,6 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap) | |||
1055 | #define pl011_dma_flush_buffer NULL | 1034 | #define pl011_dma_flush_buffer NULL |
1056 | #endif | 1035 | #endif |
1057 | 1036 | ||
1058 | |||
1059 | /* | ||
1060 | * pl011_lockup_wa | ||
1061 | * This workaround aims to break the deadlock situation | ||
1062 | * when after long transfer over uart in hardware flow | ||
1063 | * control, uart interrupt registers cannot be cleared. | ||
1064 | * Hence uart transfer gets blocked. | ||
1065 | * | ||
1066 | * It is seen that during such deadlock condition ICR | ||
1067 | * don't get cleared even on multiple write. This leads | ||
1068 | * pass_counter to decrease and finally reach zero. This | ||
1069 | * can be taken as trigger point to run this UART_BT_WA. | ||
1070 | * | ||
1071 | */ | ||
1072 | static void pl011_lockup_wa(unsigned long data) | ||
1073 | { | ||
1074 | struct uart_amba_port *uap = amba_ports[0]; | ||
1075 | void __iomem *base = uap->port.membase; | ||
1076 | struct circ_buf *xmit = &uap->port.state->xmit; | ||
1077 | struct tty_struct *tty = uap->port.state->port.tty; | ||
1078 | int buf_empty_retries = 200; | ||
1079 | int loop; | ||
1080 | |||
1081 | /* Stop HCI layer from submitting data for tx */ | ||
1082 | tty->hw_stopped = 1; | ||
1083 | while (!uart_circ_empty(xmit)) { | ||
1084 | if (buf_empty_retries-- == 0) | ||
1085 | break; | ||
1086 | udelay(100); | ||
1087 | } | ||
1088 | |||
1089 | /* Backup registers */ | ||
1090 | for (loop = 0; loop < UART_WA_SAVE_NR; loop++) | ||
1091 | uart_wa_regdata[loop] = readl(base + uart_wa_reg[loop]); | ||
1092 | |||
1093 | /* Disable UART so that FIFO data is flushed out */ | ||
1094 | writew(0x00, uap->port.membase + UART011_CR); | ||
1095 | |||
1096 | /* Soft reset UART module */ | ||
1097 | if (uap->port.dev->platform_data) { | ||
1098 | struct amba_pl011_data *plat; | ||
1099 | |||
1100 | plat = uap->port.dev->platform_data; | ||
1101 | if (plat->reset) | ||
1102 | plat->reset(); | ||
1103 | } | ||
1104 | |||
1105 | /* Restore registers */ | ||
1106 | for (loop = 0; loop < UART_WA_SAVE_NR; loop++) | ||
1107 | writew(uart_wa_regdata[loop] , | ||
1108 | uap->port.membase + uart_wa_reg[loop]); | ||
1109 | |||
1110 | /* Initialise the old status of the modem signals */ | ||
1111 | uap->old_status = readw(uap->port.membase + UART01x_FR) & | ||
1112 | UART01x_FR_MODEM_ANY; | ||
1113 | |||
1114 | if (readl(base + UART011_MIS) & 0x2) | ||
1115 | printk(KERN_EMERG "UART_BT_WA: ***FAILED***\n"); | ||
1116 | |||
1117 | /* Start Tx/Rx */ | ||
1118 | tty->hw_stopped = 0; | ||
1119 | } | ||
1120 | |||
1121 | static void pl011_stop_tx(struct uart_port *port) | 1037 | static void pl011_stop_tx(struct uart_port *port) |
1122 | { | 1038 | { |
1123 | struct uart_amba_port *uap = (struct uart_amba_port *)port; | 1039 | struct uart_amba_port *uap = (struct uart_amba_port *)port; |
@@ -1246,12 +1162,26 @@ static irqreturn_t pl011_int(int irq, void *dev_id) | |||
1246 | unsigned long flags; | 1162 | unsigned long flags; |
1247 | unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT; | 1163 | unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT; |
1248 | int handled = 0; | 1164 | int handled = 0; |
1165 | unsigned int dummy_read; | ||
1249 | 1166 | ||
1250 | spin_lock_irqsave(&uap->port.lock, flags); | 1167 | spin_lock_irqsave(&uap->port.lock, flags); |
1251 | 1168 | ||
1252 | status = readw(uap->port.membase + UART011_MIS); | 1169 | status = readw(uap->port.membase + UART011_MIS); |
1253 | if (status) { | 1170 | if (status) { |
1254 | do { | 1171 | do { |
1172 | if (uap->vendor->cts_event_workaround) { | ||
1173 | /* workaround to make sure that all bits are unlocked.. */ | ||
1174 | writew(0x00, uap->port.membase + UART011_ICR); | ||
1175 | |||
1176 | /* | ||
1177 | * WA: introduce 26ns(1 uart clk) delay before W1C; | ||
1178 | * single apb access will incur 2 pclk(133.12Mhz) delay, | ||
1179 | * so add 2 dummy reads | ||
1180 | */ | ||
1181 | dummy_read = readw(uap->port.membase + UART011_ICR); | ||
1182 | dummy_read = readw(uap->port.membase + UART011_ICR); | ||
1183 | } | ||
1184 | |||
1255 | writew(status & ~(UART011_TXIS|UART011_RTIS| | 1185 | writew(status & ~(UART011_TXIS|UART011_RTIS| |
1256 | UART011_RXIS), | 1186 | UART011_RXIS), |
1257 | uap->port.membase + UART011_ICR); | 1187 | uap->port.membase + UART011_ICR); |
@@ -1268,11 +1198,8 @@ static irqreturn_t pl011_int(int irq, void *dev_id) | |||
1268 | if (status & UART011_TXIS) | 1198 | if (status & UART011_TXIS) |
1269 | pl011_tx_chars(uap); | 1199 | pl011_tx_chars(uap); |
1270 | 1200 | ||
1271 | if (pass_counter-- == 0) { | 1201 | if (pass_counter-- == 0) |
1272 | if (uap->interrupt_may_hang) | ||
1273 | tasklet_schedule(&pl011_lockup_tlet); | ||
1274 | break; | 1202 | break; |
1275 | } | ||
1276 | 1203 | ||
1277 | status = readw(uap->port.membase + UART011_MIS); | 1204 | status = readw(uap->port.membase + UART011_MIS); |
1278 | } while (status != 0); | 1205 | } while (status != 0); |
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c index 5832fdef11e9..bd97db23985b 100644 --- a/drivers/tty/serial/bfin_uart.c +++ b/drivers/tty/serial/bfin_uart.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Blackfin On-Chip Serial Driver | 2 | * Blackfin On-Chip Serial Driver |
3 | * | 3 | * |
4 | * Copyright 2006-2010 Analog Devices Inc. | 4 | * Copyright 2006-2011 Analog Devices Inc. |
5 | * | 5 | * |
6 | * Enter bugs at http://blackfin.uclinux.org/ | 6 | * Enter bugs at http://blackfin.uclinux.org/ |
7 | * | 7 | * |
@@ -35,10 +35,6 @@ | |||
35 | #include <asm/portmux.h> | 35 | #include <asm/portmux.h> |
36 | #include <asm/cacheflush.h> | 36 | #include <asm/cacheflush.h> |
37 | #include <asm/dma.h> | 37 | #include <asm/dma.h> |
38 | |||
39 | #define port_membase(uart) (((struct bfin_serial_port *)(uart))->port.membase) | ||
40 | #define get_lsr_cache(uart) (((struct bfin_serial_port *)(uart))->lsr) | ||
41 | #define put_lsr_cache(uart, v) (((struct bfin_serial_port *)(uart))->lsr = (v)) | ||
42 | #include <asm/bfin_serial.h> | 38 | #include <asm/bfin_serial.h> |
43 | 39 | ||
44 | #ifdef CONFIG_SERIAL_BFIN_MODULE | 40 | #ifdef CONFIG_SERIAL_BFIN_MODULE |
@@ -166,7 +162,7 @@ static void bfin_serial_stop_tx(struct uart_port *port) | |||
166 | uart->tx_count = 0; | 162 | uart->tx_count = 0; |
167 | uart->tx_done = 1; | 163 | uart->tx_done = 1; |
168 | #else | 164 | #else |
169 | #ifdef CONFIG_BF54x | 165 | #if defined(CONFIG_BF54x) || defined(CONFIG_BF60x) |
170 | /* Clear TFI bit */ | 166 | /* Clear TFI bit */ |
171 | UART_PUT_LSR(uart, TFI); | 167 | UART_PUT_LSR(uart, TFI); |
172 | #endif | 168 | #endif |
@@ -337,7 +333,7 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart) | |||
337 | struct circ_buf *xmit = &uart->port.state->xmit; | 333 | struct circ_buf *xmit = &uart->port.state->xmit; |
338 | 334 | ||
339 | if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { | 335 | if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { |
340 | #ifdef CONFIG_BF54x | 336 | #if defined(CONFIG_BF54x) || defined(CONFIG_BF60x) |
341 | /* Clear TFI bit */ | 337 | /* Clear TFI bit */ |
342 | UART_PUT_LSR(uart, TFI); | 338 | UART_PUT_LSR(uart, TFI); |
343 | #endif | 339 | #endif |
@@ -536,7 +532,7 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id) | |||
536 | */ | 532 | */ |
537 | UART_CLEAR_IER(uart, ETBEI); | 533 | UART_CLEAR_IER(uart, ETBEI); |
538 | uart->port.icount.tx += uart->tx_count; | 534 | uart->port.icount.tx += uart->tx_count; |
539 | if (!uart_circ_empty(xmit)) { | 535 | if (!(xmit->tail == 0 && xmit->head == 0)) { |
540 | xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1); | 536 | xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1); |
541 | 537 | ||
542 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 538 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
@@ -553,7 +549,7 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id) | |||
553 | static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id) | 549 | static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id) |
554 | { | 550 | { |
555 | struct bfin_serial_port *uart = dev_id; | 551 | struct bfin_serial_port *uart = dev_id; |
556 | unsigned short irqstat; | 552 | unsigned int irqstat; |
557 | int x_pos, pos; | 553 | int x_pos, pos; |
558 | 554 | ||
559 | spin_lock(&uart->rx_lock); | 555 | spin_lock(&uart->rx_lock); |
@@ -586,7 +582,7 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id) | |||
586 | static unsigned int bfin_serial_tx_empty(struct uart_port *port) | 582 | static unsigned int bfin_serial_tx_empty(struct uart_port *port) |
587 | { | 583 | { |
588 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; | 584 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
589 | unsigned short lsr; | 585 | unsigned int lsr; |
590 | 586 | ||
591 | lsr = UART_GET_LSR(uart); | 587 | lsr = UART_GET_LSR(uart); |
592 | if (lsr & TEMT) | 588 | if (lsr & TEMT) |
@@ -598,7 +594,7 @@ static unsigned int bfin_serial_tx_empty(struct uart_port *port) | |||
598 | static void bfin_serial_break_ctl(struct uart_port *port, int break_state) | 594 | static void bfin_serial_break_ctl(struct uart_port *port, int break_state) |
599 | { | 595 | { |
600 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; | 596 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
601 | u16 lcr = UART_GET_LCR(uart); | 597 | u32 lcr = UART_GET_LCR(uart); |
602 | if (break_state) | 598 | if (break_state) |
603 | lcr |= SB; | 599 | lcr |= SB; |
604 | else | 600 | else |
@@ -745,7 +741,7 @@ static int bfin_serial_startup(struct uart_port *port) | |||
745 | } | 741 | } |
746 | 742 | ||
747 | /* CTS RTS PINs are negative assertive. */ | 743 | /* CTS RTS PINs are negative assertive. */ |
748 | UART_PUT_MCR(uart, ACTS); | 744 | UART_PUT_MCR(uart, UART_GET_MCR(uart) | ACTS); |
749 | UART_SET_IER(uart, EDSSI); | 745 | UART_SET_IER(uart, EDSSI); |
750 | } | 746 | } |
751 | #endif | 747 | #endif |
@@ -803,7 +799,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, | |||
803 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; | 799 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
804 | unsigned long flags; | 800 | unsigned long flags; |
805 | unsigned int baud, quot; | 801 | unsigned int baud, quot; |
806 | unsigned short val, ier, lcr = 0; | 802 | unsigned int ier, lcr = 0; |
807 | 803 | ||
808 | switch (termios->c_cflag & CSIZE) { | 804 | switch (termios->c_cflag & CSIZE) { |
809 | case CS8: | 805 | case CS8: |
@@ -875,26 +871,23 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, | |||
875 | 871 | ||
876 | /* Disable UART */ | 872 | /* Disable UART */ |
877 | ier = UART_GET_IER(uart); | 873 | ier = UART_GET_IER(uart); |
874 | UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN); | ||
878 | UART_DISABLE_INTS(uart); | 875 | UART_DISABLE_INTS(uart); |
879 | 876 | ||
880 | /* Set DLAB in LCR to Access DLL and DLH */ | 877 | /* Set DLAB in LCR to Access CLK */ |
881 | UART_SET_DLAB(uart); | 878 | UART_SET_DLAB(uart); |
882 | 879 | ||
883 | UART_PUT_DLL(uart, quot & 0xFF); | 880 | UART_PUT_CLK(uart, quot); |
884 | UART_PUT_DLH(uart, (quot >> 8) & 0xFF); | ||
885 | SSYNC(); | 881 | SSYNC(); |
886 | 882 | ||
887 | /* Clear DLAB in LCR to Access THR RBR IER */ | 883 | /* Clear DLAB in LCR to Access THR RBR IER */ |
888 | UART_CLEAR_DLAB(uart); | 884 | UART_CLEAR_DLAB(uart); |
889 | 885 | ||
890 | UART_PUT_LCR(uart, lcr); | 886 | UART_PUT_LCR(uart, (UART_GET_LCR(uart) & ~LCR_MASK) | lcr); |
891 | 887 | ||
892 | /* Enable UART */ | 888 | /* Enable UART */ |
893 | UART_ENABLE_INTS(uart, ier); | 889 | UART_ENABLE_INTS(uart, ier); |
894 | 890 | UART_PUT_GCTL(uart, UART_GET_GCTL(uart) | UCEN); | |
895 | val = UART_GET_GCTL(uart); | ||
896 | val |= UCEN; | ||
897 | UART_PUT_GCTL(uart, val); | ||
898 | 891 | ||
899 | /* Port speed changed, update the per-port timeout. */ | 892 | /* Port speed changed, update the per-port timeout. */ |
900 | uart_update_timeout(port, termios->c_cflag, baud); | 893 | uart_update_timeout(port, termios->c_cflag, baud); |
@@ -954,17 +947,17 @@ bfin_serial_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
954 | static void bfin_serial_set_ldisc(struct uart_port *port, int ld) | 947 | static void bfin_serial_set_ldisc(struct uart_port *port, int ld) |
955 | { | 948 | { |
956 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; | 949 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
957 | unsigned short val; | 950 | unsigned int val; |
958 | 951 | ||
959 | switch (ld) { | 952 | switch (ld) { |
960 | case N_IRDA: | 953 | case N_IRDA: |
961 | val = UART_GET_GCTL(uart); | 954 | val = UART_GET_GCTL(uart); |
962 | val |= (IREN | RPOLC); | 955 | val |= (UMOD_IRDA | RPOLC); |
963 | UART_PUT_GCTL(uart, val); | 956 | UART_PUT_GCTL(uart, val); |
964 | break; | 957 | break; |
965 | default: | 958 | default: |
966 | val = UART_GET_GCTL(uart); | 959 | val = UART_GET_GCTL(uart); |
967 | val &= ~(IREN | RPOLC); | 960 | val &= ~(UMOD_MASK | RPOLC); |
968 | UART_PUT_GCTL(uart, val); | 961 | UART_PUT_GCTL(uart, val); |
969 | } | 962 | } |
970 | } | 963 | } |
@@ -972,13 +965,13 @@ static void bfin_serial_set_ldisc(struct uart_port *port, int ld) | |||
972 | static void bfin_serial_reset_irda(struct uart_port *port) | 965 | static void bfin_serial_reset_irda(struct uart_port *port) |
973 | { | 966 | { |
974 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; | 967 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
975 | unsigned short val; | 968 | unsigned int val; |
976 | 969 | ||
977 | val = UART_GET_GCTL(uart); | 970 | val = UART_GET_GCTL(uart); |
978 | val &= ~(IREN | RPOLC); | 971 | val &= ~(UMOD_MASK | RPOLC); |
979 | UART_PUT_GCTL(uart, val); | 972 | UART_PUT_GCTL(uart, val); |
980 | SSYNC(); | 973 | SSYNC(); |
981 | val |= (IREN | RPOLC); | 974 | val |= (UMOD_IRDA | RPOLC); |
982 | UART_PUT_GCTL(uart, val); | 975 | UART_PUT_GCTL(uart, val); |
983 | SSYNC(); | 976 | SSYNC(); |
984 | } | 977 | } |
@@ -1070,12 +1063,12 @@ static void __init | |||
1070 | bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud, | 1063 | bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud, |
1071 | int *parity, int *bits) | 1064 | int *parity, int *bits) |
1072 | { | 1065 | { |
1073 | unsigned short status; | 1066 | unsigned int status; |
1074 | 1067 | ||
1075 | status = UART_GET_IER(uart) & (ERBFI | ETBEI); | 1068 | status = UART_GET_IER(uart) & (ERBFI | ETBEI); |
1076 | if (status == (ERBFI | ETBEI)) { | 1069 | if (status == (ERBFI | ETBEI)) { |
1077 | /* ok, the port was enabled */ | 1070 | /* ok, the port was enabled */ |
1078 | u16 lcr, dlh, dll; | 1071 | u32 lcr, clk; |
1079 | 1072 | ||
1080 | lcr = UART_GET_LCR(uart); | 1073 | lcr = UART_GET_LCR(uart); |
1081 | 1074 | ||
@@ -1086,30 +1079,17 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud, | |||
1086 | else | 1079 | else |
1087 | *parity = 'o'; | 1080 | *parity = 'o'; |
1088 | } | 1081 | } |
1089 | switch (lcr & 0x03) { | 1082 | *bits = ((lcr & WLS_MASK) >> WLS_OFFSET) + 5; |
1090 | case 0: | 1083 | |
1091 | *bits = 5; | 1084 | /* Set DLAB in LCR to Access CLK */ |
1092 | break; | ||
1093 | case 1: | ||
1094 | *bits = 6; | ||
1095 | break; | ||
1096 | case 2: | ||
1097 | *bits = 7; | ||
1098 | break; | ||
1099 | case 3: | ||
1100 | *bits = 8; | ||
1101 | break; | ||
1102 | } | ||
1103 | /* Set DLAB in LCR to Access DLL and DLH */ | ||
1104 | UART_SET_DLAB(uart); | 1085 | UART_SET_DLAB(uart); |
1105 | 1086 | ||
1106 | dll = UART_GET_DLL(uart); | 1087 | clk = UART_GET_CLK(uart); |
1107 | dlh = UART_GET_DLH(uart); | ||
1108 | 1088 | ||
1109 | /* Clear DLAB in LCR to Access THR RBR IER */ | 1089 | /* Clear DLAB in LCR to Access THR RBR IER */ |
1110 | UART_CLEAR_DLAB(uart); | 1090 | UART_CLEAR_DLAB(uart); |
1111 | 1091 | ||
1112 | *baud = get_sclk() / (16*(dll | dlh << 8)); | 1092 | *baud = get_sclk() / (16*clk); |
1113 | } | 1093 | } |
1114 | pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits); | 1094 | pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits); |
1115 | } | 1095 | } |
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 5b07c0c3a10c..7264d4d26717 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -952,19 +952,6 @@ static const struct control_pins e100_modem_pins[NR_PORTS] = | |||
952 | /* Input */ | 952 | /* Input */ |
953 | #define E100_DSR_GET(info) ((*e100_modem_pins[(info)->line].dsr_port) & e100_modem_pins[(info)->line].dsr_mask) | 953 | #define E100_DSR_GET(info) ((*e100_modem_pins[(info)->line].dsr_port) & e100_modem_pins[(info)->line].dsr_mask) |
954 | 954 | ||
955 | |||
956 | /* | ||
957 | * tmp_buf is used as a temporary buffer by serial_write. We need to | ||
958 | * lock it in case the memcpy_fromfs blocks while swapping in a page, | ||
959 | * and some other program tries to do a serial write at the same time. | ||
960 | * Since the lock will only come under contention when the system is | ||
961 | * swapping and available memory is low, it makes sense to share one | ||
962 | * buffer across all the serial ports, since it significantly saves | ||
963 | * memory if large numbers of serial ports are open. | ||
964 | */ | ||
965 | static unsigned char *tmp_buf; | ||
966 | static DEFINE_MUTEX(tmp_buf_mutex); | ||
967 | |||
968 | /* Calculate the chartime depending on baudrate, numbor of bits etc. */ | 955 | /* Calculate the chartime depending on baudrate, numbor of bits etc. */ |
969 | static void update_char_time(struct e100_serial * info) | 956 | static void update_char_time(struct e100_serial * info) |
970 | { | 957 | { |
@@ -3150,7 +3137,7 @@ static int rs_raw_write(struct tty_struct *tty, | |||
3150 | 3137 | ||
3151 | /* first some sanity checks */ | 3138 | /* first some sanity checks */ |
3152 | 3139 | ||
3153 | if (!tty || !info->xmit.buf || !tmp_buf) | 3140 | if (!tty || !info->xmit.buf) |
3154 | return 0; | 3141 | return 0; |
3155 | 3142 | ||
3156 | #ifdef SERIAL_DEBUG_DATA | 3143 | #ifdef SERIAL_DEBUG_DATA |
@@ -3989,7 +3976,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3989 | */ | 3976 | */ |
3990 | if (tty_hung_up_p(filp) || | 3977 | if (tty_hung_up_p(filp) || |
3991 | (info->flags & ASYNC_CLOSING)) { | 3978 | (info->flags & ASYNC_CLOSING)) { |
3992 | wait_event_interruptible_tty(info->close_wait, | 3979 | wait_event_interruptible_tty(tty, info->close_wait, |
3993 | !(info->flags & ASYNC_CLOSING)); | 3980 | !(info->flags & ASYNC_CLOSING)); |
3994 | #ifdef SERIAL_DO_RESTART | 3981 | #ifdef SERIAL_DO_RESTART |
3995 | if (info->flags & ASYNC_HUP_NOTIFY) | 3982 | if (info->flags & ASYNC_HUP_NOTIFY) |
@@ -4065,9 +4052,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
4065 | printk("block_til_ready blocking: ttyS%d, count = %d\n", | 4052 | printk("block_til_ready blocking: ttyS%d, count = %d\n", |
4066 | info->line, info->count); | 4053 | info->line, info->count); |
4067 | #endif | 4054 | #endif |
4068 | tty_unlock(); | 4055 | tty_unlock(tty); |
4069 | schedule(); | 4056 | schedule(); |
4070 | tty_lock(); | 4057 | tty_lock(tty); |
4071 | } | 4058 | } |
4072 | set_current_state(TASK_RUNNING); | 4059 | set_current_state(TASK_RUNNING); |
4073 | remove_wait_queue(&info->open_wait, &wait); | 4060 | remove_wait_queue(&info->open_wait, &wait); |
@@ -4106,7 +4093,6 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4106 | { | 4093 | { |
4107 | struct e100_serial *info; | 4094 | struct e100_serial *info; |
4108 | int retval; | 4095 | int retval; |
4109 | unsigned long page; | ||
4110 | int allocated_resources = 0; | 4096 | int allocated_resources = 0; |
4111 | 4097 | ||
4112 | info = rs_table + tty->index; | 4098 | info = rs_table + tty->index; |
@@ -4124,23 +4110,12 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4124 | 4110 | ||
4125 | tty->low_latency = !!(info->flags & ASYNC_LOW_LATENCY); | 4111 | tty->low_latency = !!(info->flags & ASYNC_LOW_LATENCY); |
4126 | 4112 | ||
4127 | if (!tmp_buf) { | ||
4128 | page = get_zeroed_page(GFP_KERNEL); | ||
4129 | if (!page) { | ||
4130 | return -ENOMEM; | ||
4131 | } | ||
4132 | if (tmp_buf) | ||
4133 | free_page(page); | ||
4134 | else | ||
4135 | tmp_buf = (unsigned char *) page; | ||
4136 | } | ||
4137 | |||
4138 | /* | 4113 | /* |
4139 | * If the port is in the middle of closing, bail out now | 4114 | * If the port is in the middle of closing, bail out now |
4140 | */ | 4115 | */ |
4141 | if (tty_hung_up_p(filp) || | 4116 | if (tty_hung_up_p(filp) || |
4142 | (info->flags & ASYNC_CLOSING)) { | 4117 | (info->flags & ASYNC_CLOSING)) { |
4143 | wait_event_interruptible_tty(info->close_wait, | 4118 | wait_event_interruptible_tty(tty, info->close_wait, |
4144 | !(info->flags & ASYNC_CLOSING)); | 4119 | !(info->flags & ASYNC_CLOSING)); |
4145 | #ifdef SERIAL_DO_RESTART | 4120 | #ifdef SERIAL_DO_RESTART |
4146 | return ((info->flags & ASYNC_HUP_NOTIFY) ? | 4121 | return ((info->flags & ASYNC_HUP_NOTIFY) ? |
@@ -4487,6 +4462,7 @@ static int __init rs_init(void) | |||
4487 | info->enabled = 0; | 4462 | info->enabled = 0; |
4488 | } | 4463 | } |
4489 | } | 4464 | } |
4465 | tty_port_init(&info->port); | ||
4490 | info->uses_dma_in = 0; | 4466 | info->uses_dma_in = 0; |
4491 | info->uses_dma_out = 0; | 4467 | info->uses_dma_out = 0; |
4492 | info->line = i; | 4468 | info->line = i; |
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 7081600bede4..ec56d8397aae 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c | |||
@@ -370,6 +370,8 @@ static void mxs_auart_settermios(struct uart_port *u, | |||
370 | 370 | ||
371 | writel(ctrl, u->membase + AUART_LINECTRL); | 371 | writel(ctrl, u->membase + AUART_LINECTRL); |
372 | writel(ctrl2, u->membase + AUART_CTRL2); | 372 | writel(ctrl2, u->membase + AUART_CTRL2); |
373 | |||
374 | uart_update_timeout(u, termios->c_cflag, baud); | ||
373 | } | 375 | } |
374 | 376 | ||
375 | static irqreturn_t mxs_auart_irq_handle(int irq, void *context) | 377 | static irqreturn_t mxs_auart_irq_handle(int irq, void *context) |
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index e8c9cee07d00..5410c0637266 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c | |||
@@ -12,10 +12,13 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/delay.h> | ||
15 | #include <linux/serial_core.h> | 16 | #include <linux/serial_core.h> |
16 | #include <linux/serial_8250.h> | 17 | #include <linux/serial_8250.h> |
18 | #include <linux/serial_reg.h> | ||
17 | #include <linux/of_address.h> | 19 | #include <linux/of_address.h> |
18 | #include <linux/of_irq.h> | 20 | #include <linux/of_irq.h> |
21 | #include <linux/of_serial.h> | ||
19 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
20 | #include <linux/nwpserial.h> | 23 | #include <linux/nwpserial.h> |
21 | 24 | ||
@@ -24,6 +27,26 @@ struct of_serial_info { | |||
24 | int line; | 27 | int line; |
25 | }; | 28 | }; |
26 | 29 | ||
30 | #ifdef CONFIG_ARCH_TEGRA | ||
31 | void tegra_serial_handle_break(struct uart_port *p) | ||
32 | { | ||
33 | unsigned int status, tmout = 10000; | ||
34 | |||
35 | do { | ||
36 | status = p->serial_in(p, UART_LSR); | ||
37 | if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS)) | ||
38 | status = p->serial_in(p, UART_RX); | ||
39 | else | ||
40 | break; | ||
41 | if (--tmout == 0) | ||
42 | break; | ||
43 | udelay(1); | ||
44 | } while (1); | ||
45 | } | ||
46 | /* FIXME remove this export when tegra finishes conversion to open firmware */ | ||
47 | EXPORT_SYMBOL_GPL(tegra_serial_handle_break); | ||
48 | #endif | ||
49 | |||
27 | /* | 50 | /* |
28 | * Fill a struct uart_port for a given device node | 51 | * Fill a struct uart_port for a given device node |
29 | */ | 52 | */ |
@@ -84,6 +107,9 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, | |||
84 | | UPF_FIXED_PORT | UPF_FIXED_TYPE; | 107 | | UPF_FIXED_PORT | UPF_FIXED_TYPE; |
85 | port->dev = &ofdev->dev; | 108 | port->dev = &ofdev->dev; |
86 | 109 | ||
110 | if (type == PORT_TEGRA) | ||
111 | port->handle_break = tegra_serial_handle_break; | ||
112 | |||
87 | return 0; | 113 | return 0; |
88 | } | 114 | } |
89 | 115 | ||
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index d00b38eb268e..d3cda0cb2df0 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -44,6 +44,13 @@ | |||
44 | #include <plat/dmtimer.h> | 44 | #include <plat/dmtimer.h> |
45 | #include <plat/omap-serial.h> | 45 | #include <plat/omap-serial.h> |
46 | 46 | ||
47 | #define UART_BUILD_REVISION(x, y) (((x) << 8) | (y)) | ||
48 | |||
49 | #define OMAP_UART_REV_42 0x0402 | ||
50 | #define OMAP_UART_REV_46 0x0406 | ||
51 | #define OMAP_UART_REV_52 0x0502 | ||
52 | #define OMAP_UART_REV_63 0x0603 | ||
53 | |||
47 | #define DEFAULT_CLK_SPEED 48000000 /* 48Mhz*/ | 54 | #define DEFAULT_CLK_SPEED 48000000 /* 48Mhz*/ |
48 | 55 | ||
49 | /* SCR register bitmasks */ | 56 | /* SCR register bitmasks */ |
@@ -53,6 +60,17 @@ | |||
53 | #define OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT 6 | 60 | #define OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT 6 |
54 | #define OMAP_UART_FCR_RX_FIFO_TRIG_MASK (0x3 << 6) | 61 | #define OMAP_UART_FCR_RX_FIFO_TRIG_MASK (0x3 << 6) |
55 | 62 | ||
63 | /* MVR register bitmasks */ | ||
64 | #define OMAP_UART_MVR_SCHEME_SHIFT 30 | ||
65 | |||
66 | #define OMAP_UART_LEGACY_MVR_MAJ_MASK 0xf0 | ||
67 | #define OMAP_UART_LEGACY_MVR_MAJ_SHIFT 4 | ||
68 | #define OMAP_UART_LEGACY_MVR_MIN_MASK 0x0f | ||
69 | |||
70 | #define OMAP_UART_MVR_MAJ_MASK 0x700 | ||
71 | #define OMAP_UART_MVR_MAJ_SHIFT 8 | ||
72 | #define OMAP_UART_MVR_MIN_MASK 0x3f | ||
73 | |||
56 | static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS]; | 74 | static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS]; |
57 | 75 | ||
58 | /* Forward declaration of functions */ | 76 | /* Forward declaration of functions */ |
@@ -1346,6 +1364,59 @@ static void uart_tx_dma_callback(int lch, u16 ch_status, void *data) | |||
1346 | return; | 1364 | return; |
1347 | } | 1365 | } |
1348 | 1366 | ||
1367 | static void omap_serial_fill_features_erratas(struct uart_omap_port *up) | ||
1368 | { | ||
1369 | u32 mvr, scheme; | ||
1370 | u16 revision, major, minor; | ||
1371 | |||
1372 | mvr = serial_in(up, UART_OMAP_MVER); | ||
1373 | |||
1374 | /* Check revision register scheme */ | ||
1375 | scheme = mvr >> OMAP_UART_MVR_SCHEME_SHIFT; | ||
1376 | |||
1377 | switch (scheme) { | ||
1378 | case 0: /* Legacy Scheme: OMAP2/3 */ | ||
1379 | /* MINOR_REV[0:4], MAJOR_REV[4:7] */ | ||
1380 | major = (mvr & OMAP_UART_LEGACY_MVR_MAJ_MASK) >> | ||
1381 | OMAP_UART_LEGACY_MVR_MAJ_SHIFT; | ||
1382 | minor = (mvr & OMAP_UART_LEGACY_MVR_MIN_MASK); | ||
1383 | break; | ||
1384 | case 1: | ||
1385 | /* New Scheme: OMAP4+ */ | ||
1386 | /* MINOR_REV[0:5], MAJOR_REV[8:10] */ | ||
1387 | major = (mvr & OMAP_UART_MVR_MAJ_MASK) >> | ||
1388 | OMAP_UART_MVR_MAJ_SHIFT; | ||
1389 | minor = (mvr & OMAP_UART_MVR_MIN_MASK); | ||
1390 | break; | ||
1391 | default: | ||
1392 | dev_warn(&up->pdev->dev, | ||
1393 | "Unknown %s revision, defaulting to highest\n", | ||
1394 | up->name); | ||
1395 | /* highest possible revision */ | ||
1396 | major = 0xff; | ||
1397 | minor = 0xff; | ||
1398 | } | ||
1399 | |||
1400 | /* normalize revision for the driver */ | ||
1401 | revision = UART_BUILD_REVISION(major, minor); | ||
1402 | |||
1403 | switch (revision) { | ||
1404 | case OMAP_UART_REV_46: | ||
1405 | up->errata |= (UART_ERRATA_i202_MDR1_ACCESS | | ||
1406 | UART_ERRATA_i291_DMA_FORCEIDLE); | ||
1407 | break; | ||
1408 | case OMAP_UART_REV_52: | ||
1409 | up->errata |= (UART_ERRATA_i202_MDR1_ACCESS | | ||
1410 | UART_ERRATA_i291_DMA_FORCEIDLE); | ||
1411 | break; | ||
1412 | case OMAP_UART_REV_63: | ||
1413 | up->errata |= UART_ERRATA_i202_MDR1_ACCESS; | ||
1414 | break; | ||
1415 | default: | ||
1416 | break; | ||
1417 | } | ||
1418 | } | ||
1419 | |||
1349 | static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) | 1420 | static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) |
1350 | { | 1421 | { |
1351 | struct omap_uart_port_info *omap_up_info; | 1422 | struct omap_uart_port_info *omap_up_info; |
@@ -1439,7 +1510,6 @@ static int serial_omap_probe(struct platform_device *pdev) | |||
1439 | "%d\n", DEFAULT_CLK_SPEED); | 1510 | "%d\n", DEFAULT_CLK_SPEED); |
1440 | } | 1511 | } |
1441 | up->uart_dma.uart_base = mem->start; | 1512 | up->uart_dma.uart_base = mem->start; |
1442 | up->errata = omap_up_info->errata; | ||
1443 | 1513 | ||
1444 | if (omap_up_info->dma_enabled) { | 1514 | if (omap_up_info->dma_enabled) { |
1445 | up->uart_dma.uart_dma_tx = dma_tx->start; | 1515 | up->uart_dma.uart_dma_tx = dma_tx->start; |
@@ -1469,6 +1539,8 @@ static int serial_omap_probe(struct platform_device *pdev) | |||
1469 | pm_runtime_enable(&pdev->dev); | 1539 | pm_runtime_enable(&pdev->dev); |
1470 | pm_runtime_get_sync(&pdev->dev); | 1540 | pm_runtime_get_sync(&pdev->dev); |
1471 | 1541 | ||
1542 | omap_serial_fill_features_erratas(up); | ||
1543 | |||
1472 | ui[up->port.line] = up; | 1544 | ui[up->port.line] = up; |
1473 | serial_omap_add_console_port(up); | 1545 | serial_omap_add_console_port(up); |
1474 | 1546 | ||
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index c2816f494807..4fdec6a6b758 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c | |||
@@ -39,6 +39,7 @@ enum { | |||
39 | PCH_UART_HANDLED_RX_ERR_INT_SHIFT, | 39 | PCH_UART_HANDLED_RX_ERR_INT_SHIFT, |
40 | PCH_UART_HANDLED_RX_TRG_INT_SHIFT, | 40 | PCH_UART_HANDLED_RX_TRG_INT_SHIFT, |
41 | PCH_UART_HANDLED_MS_INT_SHIFT, | 41 | PCH_UART_HANDLED_MS_INT_SHIFT, |
42 | PCH_UART_HANDLED_LS_INT_SHIFT, | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | enum { | 45 | enum { |
@@ -63,6 +64,8 @@ enum { | |||
63 | PCH_UART_HANDLED_RX_TRG_INT_SHIFT)<<1)) | 64 | PCH_UART_HANDLED_RX_TRG_INT_SHIFT)<<1)) |
64 | #define PCH_UART_HANDLED_MS_INT (1<<((PCH_UART_HANDLED_MS_INT_SHIFT)<<1)) | 65 | #define PCH_UART_HANDLED_MS_INT (1<<((PCH_UART_HANDLED_MS_INT_SHIFT)<<1)) |
65 | 66 | ||
67 | #define PCH_UART_HANDLED_LS_INT (1<<((PCH_UART_HANDLED_LS_INT_SHIFT)<<1)) | ||
68 | |||
66 | #define PCH_UART_RBR 0x00 | 69 | #define PCH_UART_RBR 0x00 |
67 | #define PCH_UART_THR 0x00 | 70 | #define PCH_UART_THR 0x00 |
68 | 71 | ||
@@ -229,7 +232,6 @@ struct eg20t_port { | |||
229 | int start_tx; | 232 | int start_tx; |
230 | int start_rx; | 233 | int start_rx; |
231 | int tx_empty; | 234 | int tx_empty; |
232 | int int_dis_flag; | ||
233 | int trigger; | 235 | int trigger; |
234 | int trigger_level; | 236 | int trigger_level; |
235 | struct pch_uart_buffer rxbuf; | 237 | struct pch_uart_buffer rxbuf; |
@@ -237,7 +239,6 @@ struct eg20t_port { | |||
237 | unsigned int fcr; | 239 | unsigned int fcr; |
238 | unsigned int mcr; | 240 | unsigned int mcr; |
239 | unsigned int use_dma; | 241 | unsigned int use_dma; |
240 | unsigned int use_dma_flag; | ||
241 | struct dma_async_tx_descriptor *desc_tx; | 242 | struct dma_async_tx_descriptor *desc_tx; |
242 | struct dma_async_tx_descriptor *desc_rx; | 243 | struct dma_async_tx_descriptor *desc_rx; |
243 | struct pch_dma_slave param_tx; | 244 | struct pch_dma_slave param_tx; |
@@ -560,14 +561,10 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf, | |||
560 | return i; | 561 | return i; |
561 | } | 562 | } |
562 | 563 | ||
563 | static unsigned int pch_uart_hal_get_iid(struct eg20t_port *priv) | 564 | static unsigned char pch_uart_hal_get_iid(struct eg20t_port *priv) |
564 | { | 565 | { |
565 | unsigned int iir; | 566 | return ioread8(priv->membase + UART_IIR) &\ |
566 | int ret; | 567 | (PCH_UART_IIR_IID | PCH_UART_IIR_TOI | PCH_UART_IIR_IP); |
567 | |||
568 | iir = ioread8(priv->membase + UART_IIR); | ||
569 | ret = (iir & (PCH_UART_IIR_IID | PCH_UART_IIR_TOI | PCH_UART_IIR_IP)); | ||
570 | return ret; | ||
571 | } | 568 | } |
572 | 569 | ||
573 | static u8 pch_uart_hal_get_line_status(struct eg20t_port *priv) | 570 | static u8 pch_uart_hal_get_line_status(struct eg20t_port *priv) |
@@ -666,10 +663,13 @@ static void pch_free_dma(struct uart_port *port) | |||
666 | dma_release_channel(priv->chan_rx); | 663 | dma_release_channel(priv->chan_rx); |
667 | priv->chan_rx = NULL; | 664 | priv->chan_rx = NULL; |
668 | } | 665 | } |
669 | if (sg_dma_address(&priv->sg_rx)) | 666 | |
670 | dma_free_coherent(port->dev, port->fifosize, | 667 | if (priv->rx_buf_dma) { |
671 | sg_virt(&priv->sg_rx), | 668 | dma_free_coherent(port->dev, port->fifosize, priv->rx_buf_virt, |
672 | sg_dma_address(&priv->sg_rx)); | 669 | priv->rx_buf_dma); |
670 | priv->rx_buf_virt = NULL; | ||
671 | priv->rx_buf_dma = 0; | ||
672 | } | ||
673 | 673 | ||
674 | return; | 674 | return; |
675 | } | 675 | } |
@@ -1053,12 +1053,17 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id) | |||
1053 | unsigned int handled; | 1053 | unsigned int handled; |
1054 | u8 lsr; | 1054 | u8 lsr; |
1055 | int ret = 0; | 1055 | int ret = 0; |
1056 | unsigned int iid; | 1056 | unsigned char iid; |
1057 | unsigned long flags; | 1057 | unsigned long flags; |
1058 | int next = 1; | ||
1059 | u8 msr; | ||
1058 | 1060 | ||
1059 | spin_lock_irqsave(&priv->port.lock, flags); | 1061 | spin_lock_irqsave(&priv->port.lock, flags); |
1060 | handled = 0; | 1062 | handled = 0; |
1061 | while ((iid = pch_uart_hal_get_iid(priv)) > 1) { | 1063 | while (next) { |
1064 | iid = pch_uart_hal_get_iid(priv); | ||
1065 | if (iid & PCH_UART_IIR_IP) /* No Interrupt */ | ||
1066 | break; | ||
1062 | switch (iid) { | 1067 | switch (iid) { |
1063 | case PCH_UART_IID_RLS: /* Receiver Line Status */ | 1068 | case PCH_UART_IID_RLS: /* Receiver Line Status */ |
1064 | lsr = pch_uart_hal_get_line_status(priv); | 1069 | lsr = pch_uart_hal_get_line_status(priv); |
@@ -1066,6 +1071,8 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id) | |||
1066 | UART_LSR_PE | UART_LSR_OE)) { | 1071 | UART_LSR_PE | UART_LSR_OE)) { |
1067 | pch_uart_err_ir(priv, lsr); | 1072 | pch_uart_err_ir(priv, lsr); |
1068 | ret = PCH_UART_HANDLED_RX_ERR_INT; | 1073 | ret = PCH_UART_HANDLED_RX_ERR_INT; |
1074 | } else { | ||
1075 | ret = PCH_UART_HANDLED_LS_INT; | ||
1069 | } | 1076 | } |
1070 | break; | 1077 | break; |
1071 | case PCH_UART_IID_RDR: /* Received Data Ready */ | 1078 | case PCH_UART_IID_RDR: /* Received Data Ready */ |
@@ -1092,20 +1099,22 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id) | |||
1092 | ret = handle_tx(priv); | 1099 | ret = handle_tx(priv); |
1093 | break; | 1100 | break; |
1094 | case PCH_UART_IID_MS: /* Modem Status */ | 1101 | case PCH_UART_IID_MS: /* Modem Status */ |
1095 | ret = PCH_UART_HANDLED_MS_INT; | 1102 | msr = pch_uart_hal_get_modem(priv); |
1103 | next = 0; /* MS ir prioirty is the lowest. So, MS ir | ||
1104 | means final interrupt */ | ||
1105 | if ((msr & UART_MSR_ANY_DELTA) == 0) | ||
1106 | break; | ||
1107 | ret |= PCH_UART_HANDLED_MS_INT; | ||
1096 | break; | 1108 | break; |
1097 | default: /* Never junp to this label */ | 1109 | default: /* Never junp to this label */ |
1098 | dev_err(priv->port.dev, "%s:iid=%d (%lu)\n", __func__, | 1110 | dev_err(priv->port.dev, "%s:iid=%02x (%lu)\n", __func__, |
1099 | iid, jiffies); | 1111 | iid, jiffies); |
1100 | ret = -1; | 1112 | ret = -1; |
1113 | next = 0; | ||
1101 | break; | 1114 | break; |
1102 | } | 1115 | } |
1103 | handled |= (unsigned int)ret; | 1116 | handled |= (unsigned int)ret; |
1104 | } | 1117 | } |
1105 | if (handled == 0 && iid <= 1) { | ||
1106 | if (priv->int_dis_flag) | ||
1107 | priv->int_dis_flag = 0; | ||
1108 | } | ||
1109 | 1118 | ||
1110 | spin_unlock_irqrestore(&priv->port.lock, flags); | 1119 | spin_unlock_irqrestore(&priv->port.lock, flags); |
1111 | return IRQ_RETVAL(handled); | 1120 | return IRQ_RETVAL(handled); |
@@ -1200,7 +1209,6 @@ static void pch_uart_stop_rx(struct uart_port *port) | |||
1200 | priv = container_of(port, struct eg20t_port, port); | 1209 | priv = container_of(port, struct eg20t_port, port); |
1201 | priv->start_rx = 0; | 1210 | priv->start_rx = 0; |
1202 | pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_RX_INT); | 1211 | pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_RX_INT); |
1203 | priv->int_dis_flag = 1; | ||
1204 | } | 1212 | } |
1205 | 1213 | ||
1206 | /* Enable the modem status interrupts. */ | 1214 | /* Enable the modem status interrupts. */ |
@@ -1447,7 +1455,6 @@ static int pch_uart_verify_port(struct uart_port *port, | |||
1447 | __func__); | 1455 | __func__); |
1448 | return -EOPNOTSUPP; | 1456 | return -EOPNOTSUPP; |
1449 | #endif | 1457 | #endif |
1450 | priv->use_dma_flag = 1; | ||
1451 | dev_info(priv->port.dev, "PCH UART : Use DMA Mode\n"); | 1458 | dev_info(priv->port.dev, "PCH UART : Use DMA Mode\n"); |
1452 | if (!priv->use_dma) | 1459 | if (!priv->use_dma) |
1453 | pch_request_dma(port); | 1460 | pch_request_dma(port); |
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 9c4c05b2825b..246b823c1b27 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -2282,6 +2282,7 @@ void uart_unregister_driver(struct uart_driver *drv) | |||
2282 | tty_unregister_driver(p); | 2282 | tty_unregister_driver(p); |
2283 | put_tty_driver(p); | 2283 | put_tty_driver(p); |
2284 | kfree(drv->state); | 2284 | kfree(drv->state); |
2285 | drv->state = NULL; | ||
2285 | drv->tty_driver = NULL; | 2286 | drv->tty_driver = NULL; |
2286 | } | 2287 | } |
2287 | 2288 | ||