aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-08-08 16:10:12 -0400
committerBen Dooks <ben-linux@fluff.org>2008-08-08 16:10:12 -0400
commitaf7a535688a758d15f06a98833e6a143b29af9de (patch)
treebac5ab210bbbbe276f0e44ed84194d7c8bb16aae /drivers/serial
parent0c17e4ceedd35c78b1c7413dbd16279a350be6bc (diff)
parentc41107c2d4fd31924533f4dbc4c3428acc2b5894 (diff)
Merge http://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/linux-2.6-arm into for-rmk
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/21285.c14
-rw-r--r--drivers/serial/68328serial.c30
-rw-r--r--drivers/serial/68360serial.c52
-rw-r--r--drivers/serial/8250.c29
-rw-r--r--drivers/serial/8250.h2
-rw-r--r--drivers/serial/8250_gsc.c2
-rw-r--r--drivers/serial/8250_pci.c19
-rw-r--r--drivers/serial/8250_pnp.c26
-rw-r--r--drivers/serial/Kconfig18
-rw-r--r--drivers/serial/Makefile3
-rw-r--r--drivers/serial/amba-pl010.c8
-rw-r--r--drivers/serial/amba-pl011.c4
-rw-r--r--drivers/serial/atmel_serial.c27
-rw-r--r--drivers/serial/bfin_5xx.c10
-rw-r--r--drivers/serial/bfin_sport_uart.c4
-rw-r--r--drivers/serial/clps711x.c11
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h22
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c577
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c170
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.h12
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c283
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.h12
-rw-r--r--drivers/serial/crisv10.c158
-rw-r--r--drivers/serial/crisv10.h3
-rw-r--r--drivers/serial/dz.c28
-rw-r--r--drivers/serial/icom.c2
-rw-r--r--drivers/serial/imx.c6
-rw-r--r--drivers/serial/ioc3_serial.c14
-rw-r--r--drivers/serial/ioc4_serial.c21
-rw-r--r--drivers/serial/ip22zilog.c4
-rw-r--r--drivers/serial/jsm/jsm_neo.c2
-rw-r--r--drivers/serial/jsm/jsm_tty.c8
-rw-r--r--drivers/serial/m32r_sio.c6
-rw-r--r--drivers/serial/mcf.c2
-rw-r--r--drivers/serial/mcfserial.c32
-rw-r--r--drivers/serial/mpc52xx_uart.c2
-rw-r--r--drivers/serial/mpsc.c154
-rw-r--r--drivers/serial/mux.c2
-rw-r--r--drivers/serial/netx-serial.c6
-rw-r--r--drivers/serial/of_serial.c2
-rw-r--r--drivers/serial/pmac_zilog.c4
-rw-r--r--drivers/serial/pnx8xxx_uart.c4
-rw-r--r--drivers/serial/pxa.c6
-rw-r--r--drivers/serial/s3c2400.c4
-rw-r--r--drivers/serial/s3c2410.c4
-rw-r--r--drivers/serial/s3c2412.c4
-rw-r--r--drivers/serial/s3c2440.c4
-rw-r--r--drivers/serial/sa1100.c11
-rw-r--r--drivers/serial/samsung.c6
-rw-r--r--drivers/serial/sb1250-duart.c2
-rw-r--r--drivers/serial/sc26xx.c2
-rw-r--r--drivers/serial/serial_core.c85
-rw-r--r--drivers/serial/serial_ks8695.c6
-rw-r--r--drivers/serial/serial_lh7a40x.c2
-rw-r--r--drivers/serial/serial_txx9.c2
-rw-r--r--drivers/serial/sh-sci.c25
-rw-r--r--drivers/serial/sh-sci.h40
-rw-r--r--drivers/serial/sn_console.c2
-rw-r--r--drivers/serial/sunhv.c2
-rw-r--r--drivers/serial/sunsab.c2
-rw-r--r--drivers/serial/sunsu.c4
-rw-r--r--drivers/serial/sunzilog.c4
-rw-r--r--drivers/serial/uartlite.c4
-rw-r--r--drivers/serial/ucc_uart.c2
-rw-r--r--drivers/serial/v850e_uart.c548
-rw-r--r--drivers/serial/vr41xx_siu.c2
-rw-r--r--drivers/serial/zs.c23
67 files changed, 807 insertions, 1784 deletions
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 0276471cb25e..f31c6698419c 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -4,8 +4,6 @@
4 * Driver for the serial port on the 21285 StrongArm-110 core logic chip. 4 * Driver for the serial port on the 21285 StrongArm-110 core logic chip.
5 * 5 *
6 * Based on drivers/char/serial.c 6 * Based on drivers/char/serial.c
7 *
8 * $Id: 21285.c,v 1.37 2002/07/28 10:03:27 rmk Exp $
9 */ 7 */
10#include <linux/module.h> 8#include <linux/module.h>
11#include <linux/tty.h> 9#include <linux/tty.h>
@@ -21,7 +19,7 @@
21#include <asm/irq.h> 19#include <asm/irq.h>
22#include <asm/mach-types.h> 20#include <asm/mach-types.h>
23#include <asm/hardware/dec21285.h> 21#include <asm/hardware/dec21285.h>
24#include <asm/hardware.h> 22#include <mach/hardware.h>
25 23
26#define BAUD_BASE (mem_fclk_21285/64) 24#define BAUD_BASE (mem_fclk_21285/64)
27 25
@@ -88,7 +86,7 @@ static void serial21285_enable_ms(struct uart_port *port)
88static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) 86static irqreturn_t serial21285_rx_chars(int irq, void *dev_id)
89{ 87{
90 struct uart_port *port = dev_id; 88 struct uart_port *port = dev_id;
91 struct tty_struct *tty = port->info->tty; 89 struct tty_struct *tty = port->info->port.tty;
92 unsigned int status, ch, flag, rxs, max_count = 256; 90 unsigned int status, ch, flag, rxs, max_count = 256;
93 91
94 status = *CSR_UARTFLG; 92 status = *CSR_UARTFLG;
@@ -237,8 +235,8 @@ serial21285_set_termios(struct uart_port *port, struct ktermios *termios,
237 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 235 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
238 quot = uart_get_divisor(port, baud); 236 quot = uart_get_divisor(port, baud);
239 237
240 if (port->info && port->info->tty) { 238 if (port->info && port->info->port.tty) {
241 struct tty_struct *tty = port->info->tty; 239 struct tty_struct *tty = port->info->port.tty;
242 unsigned int b = port->uartclk / (16 * quot); 240 unsigned int b = port->uartclk / (16 * quot);
243 tty_encode_baud_rate(tty, b, b); 241 tty_encode_baud_rate(tty, b, b);
244 } 242 }
@@ -494,7 +492,7 @@ static int __init serial21285_init(void)
494{ 492{
495 int ret; 493 int ret;
496 494
497 printk(KERN_INFO "Serial: 21285 driver $Revision: 1.37 $\n"); 495 printk(KERN_INFO "Serial: 21285 driver\n");
498 496
499 serial21285_setup_ports(); 497 serial21285_setup_ports();
500 498
@@ -515,5 +513,5 @@ module_init(serial21285_init);
515module_exit(serial21285_exit); 513module_exit(serial21285_exit);
516 514
517MODULE_LICENSE("GPL"); 515MODULE_LICENSE("GPL");
518MODULE_DESCRIPTION("Intel Footbridge (21285) serial driver $Revision: 1.37 $"); 516MODULE_DESCRIPTION("Intel Footbridge (21285) serial driver");
519MODULE_ALIAS_CHARDEV(SERIAL_21285_MAJOR, SERIAL_21285_MINOR); 517MODULE_ALIAS_CHARDEV(SERIAL_21285_MAJOR, SERIAL_21285_MINOR);
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index bbf5bc5892c7..381b12ac20e0 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -249,7 +249,7 @@ static void status_handle(struct m68k_serial *info, unsigned short status)
249{ 249{
250#if 0 250#if 0
251 if(status & DCD) { 251 if(status & DCD) {
252 if((info->tty->termios->c_cflag & CRTSCTS) && 252 if((info->port.tty->termios->c_cflag & CRTSCTS) &&
253 ((info->curregs[3] & AUTO_ENAB)==0)) { 253 ((info->curregs[3] & AUTO_ENAB)==0)) {
254 info->curregs[3] |= AUTO_ENAB; 254 info->curregs[3] |= AUTO_ENAB;
255 info->pendregs[3] |= AUTO_ENAB; 255 info->pendregs[3] |= AUTO_ENAB;
@@ -274,7 +274,7 @@ static void status_handle(struct m68k_serial *info, unsigned short status)
274 274
275static void receive_chars(struct m68k_serial *info, unsigned short rx) 275static void receive_chars(struct m68k_serial *info, unsigned short rx)
276{ 276{
277 struct tty_struct *tty = info->tty; 277 struct tty_struct *tty = info->port.tty;
278 m68328_uart *uart = &uart_addr[info->line]; 278 m68328_uart *uart = &uart_addr[info->line];
279 unsigned char ch, flag; 279 unsigned char ch, flag;
280 280
@@ -345,7 +345,7 @@ static void transmit_chars(struct m68k_serial *info)
345 goto clear_and_return; 345 goto clear_and_return;
346 } 346 }
347 347
348 if((info->xmit_cnt <= 0) || info->tty->stopped) { 348 if((info->xmit_cnt <= 0) || info->port.tty->stopped) {
349 /* That's peculiar... TX ints off */ 349 /* That's peculiar... TX ints off */
350 uart->ustcnt &= ~USTCNT_TX_INTR_MASK; 350 uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
351 goto clear_and_return; 351 goto clear_and_return;
@@ -403,7 +403,7 @@ static void do_softint(struct work_struct *work)
403 struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue); 403 struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue);
404 struct tty_struct *tty; 404 struct tty_struct *tty;
405 405
406 tty = info->tty; 406 tty = info->port.tty;
407 if (!tty) 407 if (!tty)
408 return; 408 return;
409#if 0 409#if 0
@@ -427,7 +427,7 @@ static void do_serial_hangup(struct work_struct *work)
427 struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue_hangup); 427 struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue_hangup);
428 struct tty_struct *tty; 428 struct tty_struct *tty;
429 429
430 tty = info->tty; 430 tty = info->port.tty;
431 if (!tty) 431 if (!tty)
432 return; 432 return;
433 433
@@ -471,8 +471,8 @@ static int startup(struct m68k_serial * info)
471 uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK; 471 uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
472#endif 472#endif
473 473
474 if (info->tty) 474 if (info->port.tty)
475 clear_bit(TTY_IO_ERROR, &info->tty->flags); 475 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
476 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 476 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
477 477
478 /* 478 /*
@@ -506,8 +506,8 @@ static void shutdown(struct m68k_serial * info)
506 info->xmit_buf = 0; 506 info->xmit_buf = 0;
507 } 507 }
508 508
509 if (info->tty) 509 if (info->port.tty)
510 set_bit(TTY_IO_ERROR, &info->tty->flags); 510 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
511 511
512 info->flags &= ~S_INITIALIZED; 512 info->flags &= ~S_INITIALIZED;
513 local_irq_restore(flags); 513 local_irq_restore(flags);
@@ -573,9 +573,9 @@ static void change_speed(struct m68k_serial *info)
573 unsigned cflag; 573 unsigned cflag;
574 int i; 574 int i;
575 575
576 if (!info->tty || !info->tty->termios) 576 if (!info->port.tty || !info->port.tty->termios)
577 return; 577 return;
578 cflag = info->tty->termios->c_cflag; 578 cflag = info->port.tty->termios->c_cflag;
579 if (!(port = info->port)) 579 if (!(port = info->port))
580 return; 580 return;
581 581
@@ -1131,7 +1131,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1131 tty_ldisc_flush(tty); 1131 tty_ldisc_flush(tty);
1132 tty->closing = 0; 1132 tty->closing = 0;
1133 info->event = 0; 1133 info->event = 0;
1134 info->tty = 0; 1134 info->port.tty = NULL;
1135#warning "This is not and has never been valid so fix it" 1135#warning "This is not and has never been valid so fix it"
1136#if 0 1136#if 0
1137 if (tty->ldisc.num != ldiscs[N_TTY].num) { 1137 if (tty->ldisc.num != ldiscs[N_TTY].num) {
@@ -1169,7 +1169,7 @@ void rs_hangup(struct tty_struct *tty)
1169 info->event = 0; 1169 info->event = 0;
1170 info->count = 0; 1170 info->count = 0;
1171 info->flags &= ~S_NORMAL_ACTIVE; 1171 info->flags &= ~S_NORMAL_ACTIVE;
1172 info->tty = 0; 1172 info->port.tty = NULL;
1173 wake_up_interruptible(&info->open_wait); 1173 wake_up_interruptible(&info->open_wait);
1174} 1174}
1175 1175
@@ -1286,7 +1286,7 @@ int rs_open(struct tty_struct *tty, struct file * filp)
1286 1286
1287 info->count++; 1287 info->count++;
1288 tty->driver_data = info; 1288 tty->driver_data = info;
1289 info->tty = tty; 1289 info->port.tty = tty;
1290 1290
1291 /* 1291 /*
1292 * Start up serial port 1292 * Start up serial port
@@ -1363,7 +1363,7 @@ rs68328_init(void)
1363 info = &m68k_soft[i]; 1363 info = &m68k_soft[i];
1364 info->magic = SERIAL_MAGIC; 1364 info->magic = SERIAL_MAGIC;
1365 info->port = (int) &uart_addr[i]; 1365 info->port = (int) &uart_addr[i];
1366 info->tty = 0; 1366 info->port.tty = NULL;
1367 info->irq = uart_irqs[i]; 1367 info->irq = uart_irqs[i];
1368 info->custom_divisor = 16; 1368 info->custom_divisor = 16;
1369 info->close_delay = 50; 1369 info->close_delay = 50;
diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c
index d9d4e9552a4d..24661cd5e4fb 100644
--- a/drivers/serial/68360serial.c
+++ b/drivers/serial/68360serial.c
@@ -393,7 +393,7 @@ static void rs_360_start(struct tty_struct *tty)
393 393
394static _INLINE_ void receive_chars(ser_info_t *info) 394static _INLINE_ void receive_chars(ser_info_t *info)
395{ 395{
396 struct tty_struct *tty = info->tty; 396 struct tty_struct *tty = info->port.tty;
397 unsigned char ch, flag, *cp; 397 unsigned char ch, flag, *cp;
398 /*int ignored = 0;*/ 398 /*int ignored = 0;*/
399 int i; 399 int i;
@@ -514,7 +514,7 @@ static _INLINE_ void receive_chars(ser_info_t *info)
514 514
515static _INLINE_ void receive_break(ser_info_t *info) 515static _INLINE_ void receive_break(ser_info_t *info)
516{ 516{
517 struct tty_struct *tty = info->tty; 517 struct tty_struct *tty = info->port.tty;
518 518
519 info->state->icount.brk++; 519 info->state->icount.brk++;
520 /* Check to see if there is room in the tty buffer for 520 /* Check to see if there is room in the tty buffer for
@@ -528,7 +528,7 @@ static _INLINE_ void transmit_chars(ser_info_t *info)
528{ 528{
529 529
530 if ((info->flags & TX_WAKEUP) || 530 if ((info->flags & TX_WAKEUP) ||
531 (info->tty->flags & (1 << TTY_DO_WRITE_WAKEUP))) { 531 (info->port.tty->flags & (1 << TTY_DO_WRITE_WAKEUP))) {
532 schedule_work(&info->tqueue); 532 schedule_work(&info->tqueue);
533 } 533 }
534 534
@@ -584,12 +584,12 @@ static _INLINE_ void check_modem_status(struct async_struct *info)
584 } 584 }
585 } 585 }
586 if (info->flags & ASYNC_CTS_FLOW) { 586 if (info->flags & ASYNC_CTS_FLOW) {
587 if (info->tty->hw_stopped) { 587 if (info->port.tty->hw_stopped) {
588 if (status & UART_MSR_CTS) { 588 if (status & UART_MSR_CTS) {
589#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 589#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
590 printk("CTS tx start..."); 590 printk("CTS tx start...");
591#endif 591#endif
592 info->tty->hw_stopped = 0; 592 info->port.tty->hw_stopped = 0;
593 info->IER |= UART_IER_THRI; 593 info->IER |= UART_IER_THRI;
594 serial_out(info, UART_IER, info->IER); 594 serial_out(info, UART_IER, info->IER);
595 rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); 595 rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
@@ -600,7 +600,7 @@ static _INLINE_ void check_modem_status(struct async_struct *info)
600#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 600#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
601 printk("CTS tx stop..."); 601 printk("CTS tx stop...");
602#endif 602#endif
603 info->tty->hw_stopped = 1; 603 info->port.tty->hw_stopped = 1;
604 info->IER &= ~UART_IER_THRI; 604 info->IER &= ~UART_IER_THRI;
605 serial_out(info, UART_IER, info->IER); 605 serial_out(info, UART_IER, info->IER);
606 } 606 }
@@ -670,7 +670,7 @@ static void do_softint(void *private_)
670 ser_info_t *info = (ser_info_t *) private_; 670 ser_info_t *info = (ser_info_t *) private_;
671 struct tty_struct *tty; 671 struct tty_struct *tty;
672 672
673 tty = info->tty; 673 tty = info->port.tty;
674 if (!tty) 674 if (!tty)
675 return; 675 return;
676 676
@@ -693,7 +693,7 @@ static void do_serial_hangup(void *private_)
693 struct async_struct *info = (struct async_struct *) private_; 693 struct async_struct *info = (struct async_struct *) private_;
694 struct tty_struct *tty; 694 struct tty_struct *tty;
695 695
696 tty = info->tty; 696 tty = info->port.tty;
697 if (!tty) 697 if (!tty)
698 return; 698 return;
699 699
@@ -721,8 +721,8 @@ static int startup(ser_info_t *info)
721 721
722#ifdef maybe 722#ifdef maybe
723 if (!state->port || !state->type) { 723 if (!state->port || !state->type) {
724 if (info->tty) 724 if (info->port.tty)
725 set_bit(TTY_IO_ERROR, &info->tty->flags); 725 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
726 goto errout; 726 goto errout;
727 } 727 }
728#endif 728#endif
@@ -734,12 +734,12 @@ static int startup(ser_info_t *info)
734 734
735#ifdef modem_control 735#ifdef modem_control
736 info->MCR = 0; 736 info->MCR = 0;
737 if (info->tty->termios->c_cflag & CBAUD) 737 if (info->port.tty->termios->c_cflag & CBAUD)
738 info->MCR = UART_MCR_DTR | UART_MCR_RTS; 738 info->MCR = UART_MCR_DTR | UART_MCR_RTS;
739#endif 739#endif
740 740
741 if (info->tty) 741 if (info->port.tty)
742 clear_bit(TTY_IO_ERROR, &info->tty->flags); 742 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
743 743
744 /* 744 /*
745 * and set the speed of the serial port 745 * and set the speed of the serial port
@@ -842,8 +842,8 @@ static void shutdown(ser_info_t *info)
842 smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); 842 smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
843 } 843 }
844 844
845 if (info->tty) 845 if (info->port.tty)
846 set_bit(TTY_IO_ERROR, &info->tty->flags); 846 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
847 847
848 info->flags &= ~ASYNC_INITIALIZED; 848 info->flags &= ~ASYNC_INITIALIZED;
849 local_irq_restore(flags); 849 local_irq_restore(flags);
@@ -863,9 +863,9 @@ static void change_speed(ser_info_t *info)
863 volatile struct smc_regs *smcp; 863 volatile struct smc_regs *smcp;
864 volatile struct scc_regs *sccp; 864 volatile struct scc_regs *sccp;
865 865
866 if (!info->tty || !info->tty->termios) 866 if (!info->port.tty || !info->port.tty->termios)
867 return; 867 return;
868 cflag = info->tty->termios->c_cflag; 868 cflag = info->port.tty->termios->c_cflag;
869 869
870 state = info->state; 870 state = info->state;
871 871
@@ -936,24 +936,24 @@ static void change_speed(ser_info_t *info)
936 * Set up parity check flag 936 * Set up parity check flag
937 */ 937 */
938 info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV); 938 info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
939 if (I_INPCK(info->tty)) 939 if (I_INPCK(info->port.tty))
940 info->read_status_mask |= BD_SC_FR | BD_SC_PR; 940 info->read_status_mask |= BD_SC_FR | BD_SC_PR;
941 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 941 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
942 info->read_status_mask |= BD_SC_BR; 942 info->read_status_mask |= BD_SC_BR;
943 943
944 /* 944 /*
945 * Characters to ignore 945 * Characters to ignore
946 */ 946 */
947 info->ignore_status_mask = 0; 947 info->ignore_status_mask = 0;
948 if (I_IGNPAR(info->tty)) 948 if (I_IGNPAR(info->port.tty))
949 info->ignore_status_mask |= BD_SC_PR | BD_SC_FR; 949 info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
950 if (I_IGNBRK(info->tty)) { 950 if (I_IGNBRK(info->port.tty)) {
951 info->ignore_status_mask |= BD_SC_BR; 951 info->ignore_status_mask |= BD_SC_BR;
952 /* 952 /*
953 * If we're ignore parity and break indicators, ignore 953 * If we're ignore parity and break indicators, ignore
954 * overruns too. (For real raw support). 954 * overruns too. (For real raw support).
955 */ 955 */
956 if (I_IGNPAR(info->tty)) 956 if (I_IGNPAR(info->port.tty))
957 info->ignore_status_mask |= BD_SC_OV; 957 info->ignore_status_mask |= BD_SC_OV;
958 } 958 }
959 /* 959 /*
@@ -1658,7 +1658,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp)
1658 tty_ldisc_flush(tty); 1658 tty_ldisc_flush(tty);
1659 tty->closing = 0; 1659 tty->closing = 0;
1660 info->event = 0; 1660 info->event = 0;
1661 info->tty = 0; 1661 info->port.tty = NULL;
1662 if (info->blocked_open) { 1662 if (info->blocked_open) {
1663 if (info->close_delay) { 1663 if (info->close_delay) {
1664 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1664 msleep_interruptible(jiffies_to_msecs(info->close_delay));
@@ -1758,7 +1758,7 @@ static void rs_360_hangup(struct tty_struct *tty)
1758 info->event = 0; 1758 info->event = 0;
1759 state->count = 0; 1759 state->count = 0;
1760 info->flags &= ~ASYNC_NORMAL_ACTIVE; 1760 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1761 info->tty = 0; 1761 info->port.tty = NULL;
1762 wake_up_interruptible(&info->open_wait); 1762 wake_up_interruptible(&info->open_wait);
1763} 1763}
1764 1764
@@ -1919,7 +1919,7 @@ static int rs_360_open(struct tty_struct *tty, struct file * filp)
1919 printk("rs_open %s, count = %d\n", tty->name, info->state->count); 1919 printk("rs_open %s, count = %d\n", tty->name, info->state->count);
1920#endif 1920#endif
1921 tty->driver_data = info; 1921 tty->driver_data = info;
1922 info->tty = tty; 1922 info->port.tty = tty;
1923 1923
1924 /* 1924 /*
1925 * Start up serial port 1925 * Start up serial port
@@ -1976,7 +1976,7 @@ static inline int line_info(char *buf, struct serial_state *state)
1976 info->port = state->port; 1976 info->port = state->port;
1977 info->flags = state->flags; 1977 info->flags = state->flags;
1978 info->quot = 0; 1978 info->quot = 0;
1979 info->tty = 0; 1979 info->port.tty = NULL;
1980 } 1980 }
1981 local_irq_disable(); 1981 local_irq_disable();
1982 status = serial_in(info, UART_MSR); 1982 status = serial_in(info, UART_MSR);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index be95e55b228b..342e12fb1c25 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -12,8 +12,6 @@
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * $Id: 8250.c,v 1.90 2002/07/28 10:03:27 rmk Exp $
16 *
17 * A note about mapbase / membase 15 * A note about mapbase / membase
18 * 16 *
19 * mapbase is the physical address of the IO port. 17 * mapbase is the physical address of the IO port.
@@ -1289,13 +1287,24 @@ static void serial8250_enable_ms(struct uart_port *port)
1289static void 1287static void
1290receive_chars(struct uart_8250_port *up, unsigned int *status) 1288receive_chars(struct uart_8250_port *up, unsigned int *status)
1291{ 1289{
1292 struct tty_struct *tty = up->port.info->tty; 1290 struct tty_struct *tty = up->port.info->port.tty;
1293 unsigned char ch, lsr = *status; 1291 unsigned char ch, lsr = *status;
1294 int max_count = 256; 1292 int max_count = 256;
1295 char flag; 1293 char flag;
1296 1294
1297 do { 1295 do {
1298 ch = serial_inp(up, UART_RX); 1296 if (likely(lsr & UART_LSR_DR))
1297 ch = serial_inp(up, UART_RX);
1298 else
1299 /*
1300 * Intel 82571 has a Serial Over Lan device that will
1301 * set UART_LSR_BI without setting UART_LSR_DR when
1302 * it receives a break. To avoid reading from the
1303 * receive buffer without UART_LSR_DR bit set, we
1304 * just force the read character to be 0
1305 */
1306 ch = 0;
1307
1299 flag = TTY_NORMAL; 1308 flag = TTY_NORMAL;
1300 up->port.icount.rx++; 1309 up->port.icount.rx++;
1301 1310
@@ -1344,7 +1353,7 @@ receive_chars(struct uart_8250_port *up, unsigned int *status)
1344 1353
1345ignore_char: 1354ignore_char:
1346 lsr = serial_inp(up, UART_LSR); 1355 lsr = serial_inp(up, UART_LSR);
1347 } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); 1356 } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0));
1348 spin_unlock(&up->port.lock); 1357 spin_unlock(&up->port.lock);
1349 tty_flip_buffer_push(tty); 1358 tty_flip_buffer_push(tty);
1350 spin_lock(&up->port.lock); 1359 spin_lock(&up->port.lock);
@@ -1427,7 +1436,7 @@ serial8250_handle_port(struct uart_8250_port *up)
1427 1436
1428 DEBUG_INTR("status = %x...", status); 1437 DEBUG_INTR("status = %x...", status);
1429 1438
1430 if (status & UART_LSR_DR) 1439 if (status & (UART_LSR_DR | UART_LSR_BI))
1431 receive_chars(up, &status); 1440 receive_chars(up, &status);
1432 check_modem_status(up); 1441 check_modem_status(up);
1433 if (status & UART_LSR_THRE) 1442 if (status & UART_LSR_THRE)
@@ -1877,6 +1886,8 @@ static int serial8250_startup(struct uart_port *port)
1877 * allow register changes to become visible. 1886 * allow register changes to become visible.
1878 */ 1887 */
1879 spin_lock_irqsave(&up->port.lock, flags); 1888 spin_lock_irqsave(&up->port.lock, flags);
1889 if (up->port.flags & UPF_SHARE_IRQ)
1890 disable_irq_nosync(up->port.irq);
1880 1891
1881 wait_for_xmitr(up, UART_LSR_THRE); 1892 wait_for_xmitr(up, UART_LSR_THRE);
1882 serial_out_sync(up, UART_IER, UART_IER_THRI); 1893 serial_out_sync(up, UART_IER, UART_IER_THRI);
@@ -1888,6 +1899,8 @@ static int serial8250_startup(struct uart_port *port)
1888 iir = serial_in(up, UART_IIR); 1899 iir = serial_in(up, UART_IIR);
1889 serial_out(up, UART_IER, 0); 1900 serial_out(up, UART_IER, 0);
1890 1901
1902 if (up->port.flags & UPF_SHARE_IRQ)
1903 enable_irq(up->port.irq);
1891 spin_unlock_irqrestore(&up->port.lock, flags); 1904 spin_unlock_irqrestore(&up->port.lock, flags);
1892 1905
1893 /* 1906 /*
@@ -2934,7 +2947,7 @@ static int __init serial8250_init(void)
2934 if (nr_uarts > UART_NR) 2947 if (nr_uarts > UART_NR)
2935 nr_uarts = UART_NR; 2948 nr_uarts = UART_NR;
2936 2949
2937 printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " 2950 printk(KERN_INFO "Serial: 8250/16550 driver"
2938 "%d ports, IRQ sharing %sabled\n", nr_uarts, 2951 "%d ports, IRQ sharing %sabled\n", nr_uarts,
2939 share_irqs ? "en" : "dis"); 2952 share_irqs ? "en" : "dis");
2940 2953
@@ -2995,7 +3008,7 @@ EXPORT_SYMBOL(serial8250_suspend_port);
2995EXPORT_SYMBOL(serial8250_resume_port); 3008EXPORT_SYMBOL(serial8250_resume_port);
2996 3009
2997MODULE_LICENSE("GPL"); 3010MODULE_LICENSE("GPL");
2998MODULE_DESCRIPTION("Generic 8250/16x50 serial driver $Revision: 1.90 $"); 3011MODULE_DESCRIPTION("Generic 8250/16x50 serial driver");
2999 3012
3000module_param(share_irqs, uint, 0644); 3013module_param(share_irqs, uint, 0644);
3001MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" 3014MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices"
diff --git a/drivers/serial/8250.h b/drivers/serial/8250.h
index 91bd28f2bb47..78c00162b04e 100644
--- a/drivers/serial/8250.h
+++ b/drivers/serial/8250.h
@@ -11,8 +11,6 @@
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 *
15 * $Id: 8250.h,v 1.8 2002/07/21 21:32:30 rmk Exp $
16 */ 14 */
17 15
18#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
diff --git a/drivers/serial/8250_gsc.c b/drivers/serial/8250_gsc.c
index 4eb7437a404a..0416ad3bc127 100644
--- a/drivers/serial/8250_gsc.c
+++ b/drivers/serial/8250_gsc.c
@@ -119,3 +119,5 @@ int __init probe_serial_gsc(void)
119} 119}
120 120
121module_init(probe_serial_gsc); 121module_init(probe_serial_gsc);
122
123MODULE_LICENSE("GPL");
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 788c3559522d..c2f23933155b 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -10,8 +10,6 @@
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License. 12 * the Free Software Foundation; either version 2 of the License.
13 *
14 * $Id: 8250_pci.c,v 1.28 2002/11/02 11:14:18 rmk Exp $
15 */ 13 */
16#include <linux/module.h> 14#include <linux/module.h>
17#include <linux/init.h> 15#include <linux/init.h>
@@ -769,6 +767,9 @@ pci_default_setup(struct serial_private *priv, struct pciserial_board *board,
769#define PCI_SUBDEVICE_ID_POCTAL232 0x0308 767#define PCI_SUBDEVICE_ID_POCTAL232 0x0308
770#define PCI_SUBDEVICE_ID_POCTAL422 0x0408 768#define PCI_SUBDEVICE_ID_POCTAL422 0x0408
771 769
770/* Unknown vendors/cards - this should not be in linux/pci_ids.h */
771#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
772
772/* 773/*
773 * Master list of serial port init/setup/exit quirks. 774 * Master list of serial port init/setup/exit quirks.
774 * This does not describe the general nature of the port. 775 * This does not describe the general nature of the port.
@@ -884,6 +885,15 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
884 }, 885 },
885 { 886 {
886 .vendor = PCI_VENDOR_ID_PLX, 887 .vendor = PCI_VENDOR_ID_PLX,
888 .device = PCI_DEVICE_ID_PLX_9050,
889 .subvendor = PCI_VENDOR_ID_PLX,
890 .subdevice = PCI_SUBDEVICE_ID_UNKNOWN_0x1584,
891 .init = pci_plx9050_init,
892 .setup = pci_default_setup,
893 .exit = __devexit_p(pci_plx9050_exit),
894 },
895 {
896 .vendor = PCI_VENDOR_ID_PLX,
887 .device = PCI_DEVICE_ID_PLX_ROMULUS, 897 .device = PCI_DEVICE_ID_PLX_ROMULUS,
888 .subvendor = PCI_VENDOR_ID_PLX, 898 .subvendor = PCI_VENDOR_ID_PLX,
889 .subdevice = PCI_DEVICE_ID_PLX_ROMULUS, 899 .subdevice = PCI_DEVICE_ID_PLX_ROMULUS,
@@ -2199,6 +2209,11 @@ static struct pci_device_id serial_pci_tbl[] = {
2199 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_1077, 2209 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_1077,
2200 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2210 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2201 pbn_b2_4_921600 }, 2211 pbn_b2_4_921600 },
2212 /* Unknown card - subdevice 0x1584 */
2213 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
2214 PCI_VENDOR_ID_PLX,
2215 PCI_SUBDEVICE_ID_UNKNOWN_0x1584, 0, 0,
2216 pbn_b0_4_115200 },
2202 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, 2217 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
2203 PCI_SUBVENDOR_ID_KEYSPAN, 2218 PCI_SUBVENDOR_ID_KEYSPAN,
2204 PCI_SUBDEVICE_ID_KEYSPAN_SX2, 0, 0, 2219 PCI_SUBDEVICE_ID_KEYSPAN_SX2, 0, 0,
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 97c68d021d28..fde7f9ccf57e 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -12,8 +12,6 @@
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License. 14 * the Free Software Foundation; either version 2 of the License.
15 *
16 * $Id: 8250_pnp.c,v 1.10 2002/07/21 21:32:30 rmk Exp $
17 */ 15 */
18#include <linux/module.h> 16#include <linux/module.h>
19#include <linux/init.h> 17#include <linux/init.h>
@@ -383,21 +381,14 @@ static int __devinit check_name(char *name)
383 return 0; 381 return 0;
384} 382}
385 383
386static int __devinit check_resources(struct pnp_option *option) 384static int __devinit check_resources(struct pnp_dev *dev)
387{ 385{
388 struct pnp_option *tmp; 386 resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
389 if (!option) 387 int i;
390 return 0;
391 388
392 for (tmp = option; tmp; tmp = tmp->next) { 389 for (i = 0; i < ARRAY_SIZE(base); i++) {
393 struct pnp_port *port; 390 if (pnp_possible_config(dev, IORESOURCE_IO, base[i], 8))
394 for (port = tmp->port; port; port = port->next) 391 return 1;
395 if ((port->size == 8) &&
396 ((port->min == 0x2f8) ||
397 (port->min == 0x3f8) ||
398 (port->min == 0x2e8) ||
399 (port->min == 0x3e8)))
400 return 1;
401 } 392 }
402 393
403 return 0; 394 return 0;
@@ -420,10 +411,7 @@ static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
420 (dev->card && check_name(dev->card->name)))) 411 (dev->card && check_name(dev->card->name))))
421 return -ENODEV; 412 return -ENODEV;
422 413
423 if (check_resources(dev->independent)) 414 if (check_resources(dev))
424 return 0;
425
426 if (check_resources(dev->dependent))
427 return 0; 415 return 0;
428 416
429 return -ENODEV; 417 return -ENODEV;
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 09f6346d38a8..77cb34270fc1 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1,8 +1,6 @@
1# 1#
2# Serial device configuration 2# Serial device configuration
3# 3#
4# $Id: Kconfig,v 1.11 2004/03/11 18:08:04 lethal Exp $
5#
6 4
7menu "Serial drivers" 5menu "Serial drivers"
8 depends on HAS_IOMEM 6 depends on HAS_IOMEM
@@ -945,22 +943,6 @@ config SERIAL_IP22_ZILOG_CONSOLE
945 depends on SERIAL_IP22_ZILOG=y 943 depends on SERIAL_IP22_ZILOG=y
946 select SERIAL_CORE_CONSOLE 944 select SERIAL_CORE_CONSOLE
947 945
948config V850E_UART
949 bool "NEC V850E on-chip UART support"
950 depends on V850E_MA1 || V850E_ME2 || V850E_TEG || V850E2_ANNA || V850E_AS85EP1
951 select SERIAL_CORE
952 default y
953
954config V850E_UARTB
955 bool
956 depends on V850E_UART && V850E_ME2
957 default y
958
959config V850E_UART_CONSOLE
960 bool "Use NEC V850E on-chip UART for console"
961 depends on V850E_UART
962 select SERIAL_CORE_CONSOLE
963
964config SERIAL_SH_SCI 946config SERIAL_SH_SCI
965 tristate "SuperH SCI(F) serial port support" 947 tristate "SuperH SCI(F) serial port support"
966 depends on SUPERH || H8300 948 depends on SUPERH || H8300
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 7d85c1fbe7e0..7e7383e890d8 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -1,8 +1,6 @@
1# 1#
2# Makefile for the kernel serial device drivers. 2# Makefile for the kernel serial device drivers.
3# 3#
4# $Id: Makefile,v 1.8 2002/07/21 21:32:30 rmk Exp $
5#
6 4
7obj-$(CONFIG_SERIAL_CORE) += serial_core.o 5obj-$(CONFIG_SERIAL_CORE) += serial_core.o
8obj-$(CONFIG_SERIAL_21285) += 21285.o 6obj-$(CONFIG_SERIAL_21285) += 21285.o
@@ -44,7 +42,6 @@ obj-$(CONFIG_SERIAL_68328) += 68328serial.o
44obj-$(CONFIG_SERIAL_68360) += 68360serial.o 42obj-$(CONFIG_SERIAL_68360) += 68360serial.o
45obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o 43obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o
46obj-$(CONFIG_SERIAL_MCF) += mcf.o 44obj-$(CONFIG_SERIAL_MCF) += mcf.o
47obj-$(CONFIG_V850E_UART) += v850e_uart.o
48obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o 45obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
49obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o 46obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o
50obj-$(CONFIG_SERIAL_DZ) += dz.o 47obj-$(CONFIG_SERIAL_DZ) += dz.o
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index e88da72f8304..90b56c2c31e2 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -22,8 +22,6 @@
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 24 *
25 * $Id: amba.c,v 1.41 2002/07/28 10:03:27 rmk Exp $
26 *
27 * This is a generic driver for ARM AMBA-type serial ports. They 25 * This is a generic driver for ARM AMBA-type serial ports. They
28 * have a lot of 16550-like features, but are not register compatible. 26 * have a lot of 16550-like features, but are not register compatible.
29 * Note that although they do have CTS, DCD and DSR inputs, they do 27 * Note that although they do have CTS, DCD and DSR inputs, they do
@@ -119,7 +117,7 @@ static void pl010_enable_ms(struct uart_port *port)
119 117
120static void pl010_rx_chars(struct uart_amba_port *uap) 118static void pl010_rx_chars(struct uart_amba_port *uap)
121{ 119{
122 struct tty_struct *tty = uap->port.info->tty; 120 struct tty_struct *tty = uap->port.info->port.tty;
123 unsigned int status, ch, flag, rsr, max_count = 256; 121 unsigned int status, ch, flag, rsr, max_count = 256;
124 122
125 status = readb(uap->port.membase + UART01x_FR); 123 status = readb(uap->port.membase + UART01x_FR);
@@ -791,7 +789,7 @@ static int __init pl010_init(void)
791{ 789{
792 int ret; 790 int ret;
793 791
794 printk(KERN_INFO "Serial: AMBA driver $Revision: 1.41 $\n"); 792 printk(KERN_INFO "Serial: AMBA driver\n");
795 793
796 ret = uart_register_driver(&amba_reg); 794 ret = uart_register_driver(&amba_reg);
797 if (ret == 0) { 795 if (ret == 0) {
@@ -812,5 +810,5 @@ module_init(pl010_init);
812module_exit(pl010_exit); 810module_exit(pl010_exit);
813 811
814MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd"); 812MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd");
815MODULE_DESCRIPTION("ARM AMBA serial port driver $Revision: 1.41 $"); 813MODULE_DESCRIPTION("ARM AMBA serial port driver");
816MODULE_LICENSE("GPL"); 814MODULE_LICENSE("GPL");
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 08adc1de4a79..9d08f27208a1 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -22,8 +22,6 @@
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 24 *
25 * $Id: amba.c,v 1.41 2002/07/28 10:03:27 rmk Exp $
26 *
27 * This is a generic driver for ARM AMBA-type serial ports. They 25 * This is a generic driver for ARM AMBA-type serial ports. They
28 * have a lot of 16550-like features, but are not register compatible. 26 * have a lot of 16550-like features, but are not register compatible.
29 * Note that although they do have CTS, DCD and DSR inputs, they do 27 * Note that although they do have CTS, DCD and DSR inputs, they do
@@ -109,7 +107,7 @@ static void pl011_enable_ms(struct uart_port *port)
109 107
110static void pl011_rx_chars(struct uart_amba_port *uap) 108static void pl011_rx_chars(struct uart_amba_port *uap)
111{ 109{
112 struct tty_struct *tty = uap->port.info->tty; 110 struct tty_struct *tty = uap->port.info->port.tty;
113 unsigned int status, ch, flag, max_count = 256; 111 unsigned int status, ch, flag, max_count = 256;
114 112
115 status = readw(uap->port.membase + UART01x_FR); 113 status = readw(uap->port.membase + UART01x_FR);
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 6aeef22bd203..3a6da80b081c 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -42,11 +42,11 @@
42#include <asm/io.h> 42#include <asm/io.h>
43 43
44#include <asm/mach/serial_at91.h> 44#include <asm/mach/serial_at91.h>
45#include <asm/arch/board.h> 45#include <mach/board.h>
46 46
47#ifdef CONFIG_ARM 47#ifdef CONFIG_ARM
48#include <asm/arch/cpu.h> 48#include <mach/cpu.h>
49#include <asm/arch/gpio.h> 49#include <mach/gpio.h>
50#endif 50#endif
51 51
52#define PDC_BUFFER_SIZE 512 52#define PDC_BUFFER_SIZE 512
@@ -662,14 +662,14 @@ static void atmel_rx_from_ring(struct uart_port *port)
662 * uart_start(), which takes the lock. 662 * uart_start(), which takes the lock.
663 */ 663 */
664 spin_unlock(&port->lock); 664 spin_unlock(&port->lock);
665 tty_flip_buffer_push(port->info->tty); 665 tty_flip_buffer_push(port->info->port.tty);
666 spin_lock(&port->lock); 666 spin_lock(&port->lock);
667} 667}
668 668
669static void atmel_rx_from_dma(struct uart_port *port) 669static void atmel_rx_from_dma(struct uart_port *port)
670{ 670{
671 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 671 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
672 struct tty_struct *tty = port->info->tty; 672 struct tty_struct *tty = port->info->port.tty;
673 struct atmel_dma_buffer *pdc; 673 struct atmel_dma_buffer *pdc;
674 int rx_idx = atmel_port->pdc_rx_idx; 674 int rx_idx = atmel_port->pdc_rx_idx;
675 unsigned int head; 675 unsigned int head;
@@ -794,7 +794,7 @@ static void atmel_tasklet_func(unsigned long data)
794static int atmel_startup(struct uart_port *port) 794static int atmel_startup(struct uart_port *port)
795{ 795{
796 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 796 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
797 struct tty_struct *tty = port->info->tty; 797 struct tty_struct *tty = port->info->port.tty;
798 int retval; 798 int retval;
799 799
800 /* 800 /*
@@ -956,6 +956,20 @@ static void atmel_shutdown(struct uart_port *port)
956} 956}
957 957
958/* 958/*
959 * Flush any TX data submitted for DMA. Called when the TX circular
960 * buffer is reset.
961 */
962static void atmel_flush_buffer(struct uart_port *port)
963{
964 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
965
966 if (atmel_use_dma_tx(port)) {
967 UART_PUT_TCR(port, 0);
968 atmel_port->pdc_tx.ofs = 0;
969 }
970}
971
972/*
959 * Power / Clock management. 973 * Power / Clock management.
960 */ 974 */
961static void atmel_serial_pm(struct uart_port *port, unsigned int state, 975static void atmel_serial_pm(struct uart_port *port, unsigned int state,
@@ -1189,6 +1203,7 @@ static struct uart_ops atmel_pops = {
1189 .break_ctl = atmel_break_ctl, 1203 .break_ctl = atmel_break_ctl,
1190 .startup = atmel_startup, 1204 .startup = atmel_startup,
1191 .shutdown = atmel_shutdown, 1205 .shutdown = atmel_shutdown,
1206 .flush_buffer = atmel_flush_buffer,
1192 .set_termios = atmel_set_termios, 1207 .set_termios = atmel_set_termios,
1193 .type = atmel_type, 1208 .type = atmel_type,
1194 .release_port = atmel_release_port, 1209 .release_port = atmel_release_port,
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index fd9bb777df28..efcd44344fb1 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -175,7 +175,7 @@ int kgdb_get_debug_char(void)
175#ifdef CONFIG_SERIAL_BFIN_PIO 175#ifdef CONFIG_SERIAL_BFIN_PIO
176static void bfin_serial_rx_chars(struct bfin_serial_port *uart) 176static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
177{ 177{
178 struct tty_struct *tty = uart->port.info->tty; 178 struct tty_struct *tty = uart->port.info->port.tty;
179 unsigned int status, ch, flg; 179 unsigned int status, ch, flg;
180 static struct timeval anomaly_start = { .tv_sec = 0 }; 180 static struct timeval anomaly_start = { .tv_sec = 0 };
181 181
@@ -393,7 +393,7 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
393 393
394static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) 394static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
395{ 395{
396 struct tty_struct *tty = uart->port.info->tty; 396 struct tty_struct *tty = uart->port.info->port.tty;
397 int i, flg, status; 397 int i, flg, status;
398 398
399 status = UART_GET_LSR(uart); 399 status = UART_GET_LSR(uart);
@@ -552,7 +552,7 @@ static void bfin_serial_mctrl_check(struct bfin_serial_port *uart)
552#ifdef CONFIG_SERIAL_BFIN_CTSRTS 552#ifdef CONFIG_SERIAL_BFIN_CTSRTS
553 unsigned int status; 553 unsigned int status;
554 struct uart_info *info = uart->port.info; 554 struct uart_info *info = uart->port.info;
555 struct tty_struct *tty = info->tty; 555 struct tty_struct *tty = info->port.tty;
556 556
557 status = bfin_serial_get_mctrl(&uart->port); 557 status = bfin_serial_get_mctrl(&uart->port);
558 uart_handle_cts_change(&uart->port, status & TIOCM_CTS); 558 uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
@@ -814,10 +814,10 @@ static void bfin_serial_set_ldisc(struct uart_port *port)
814 int line = port->line; 814 int line = port->line;
815 unsigned short val; 815 unsigned short val;
816 816
817 if (line >= port->info->tty->driver->num) 817 if (line >= port->info->port.tty->driver->num)
818 return; 818 return;
819 819
820 switch (port->info->tty->ldisc.num) { 820 switch (port->info->port.tty->termios->c_line) {
821 case N_IRDA: 821 case N_IRDA:
822 val = UART_GET_GCTL(&bfin_serial_ports[line]); 822 val = UART_GET_GCTL(&bfin_serial_ports[line]);
823 val |= (IREN | RPOLC); 823 val |= (IREN | RPOLC);
diff --git a/drivers/serial/bfin_sport_uart.c b/drivers/serial/bfin_sport_uart.c
index aca1240ad808..dd8564d25051 100644
--- a/drivers/serial/bfin_sport_uart.c
+++ b/drivers/serial/bfin_sport_uart.c
@@ -174,7 +174,7 @@ static int sport_uart_setup(struct sport_uart_port *up, int sclk, int baud_rate)
174static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) 174static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id)
175{ 175{
176 struct sport_uart_port *up = dev_id; 176 struct sport_uart_port *up = dev_id;
177 struct tty_struct *tty = up->port.info->tty; 177 struct tty_struct *tty = up->port.info->port.tty;
178 unsigned int ch; 178 unsigned int ch;
179 179
180 do { 180 do {
@@ -201,7 +201,7 @@ static irqreturn_t sport_uart_tx_irq(int irq, void *dev_id)
201static irqreturn_t sport_uart_err_irq(int irq, void *dev_id) 201static irqreturn_t sport_uart_err_irq(int irq, void *dev_id)
202{ 202{
203 struct sport_uart_port *up = dev_id; 203 struct sport_uart_port *up = dev_id;
204 struct tty_struct *tty = up->port.info->tty; 204 struct tty_struct *tty = up->port.info->port.tty;
205 unsigned int stat = SPORT_GET_STAT(up); 205 unsigned int stat = SPORT_GET_STAT(up);
206 206
207 /* Overflow in RX FIFO */ 207 /* Overflow in RX FIFO */
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 23827189ec0e..459f3420a429 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -21,9 +21,6 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * $Id: clps711x.c,v 1.42 2002/07/28 10:03:28 rmk Exp $
26 *
27 */ 24 */
28 25
29#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 26#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -42,7 +39,7 @@
42#include <linux/serial_core.h> 39#include <linux/serial_core.h>
43#include <linux/serial.h> 40#include <linux/serial.h>
44 41
45#include <asm/hardware.h> 42#include <mach/hardware.h>
46#include <asm/io.h> 43#include <asm/io.h>
47#include <asm/irq.h> 44#include <asm/irq.h>
48#include <asm/hardware/clps7111.h> 45#include <asm/hardware/clps7111.h>
@@ -96,7 +93,7 @@ static void clps711xuart_enable_ms(struct uart_port *port)
96static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id) 93static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id)
97{ 94{
98 struct uart_port *port = dev_id; 95 struct uart_port *port = dev_id;
99 struct tty_struct *tty = port->info->tty; 96 struct tty_struct *tty = port->info->port.tty;
100 unsigned int status, ch, flg; 97 unsigned int status, ch, flg;
101 98
102 status = clps_readl(SYSFLG(port)); 99 status = clps_readl(SYSFLG(port));
@@ -551,7 +548,7 @@ static int __init clps711xuart_init(void)
551{ 548{
552 int ret, i; 549 int ret, i;
553 550
554 printk(KERN_INFO "Serial: CLPS711x driver $Revision: 1.42 $\n"); 551 printk(KERN_INFO "Serial: CLPS711x driver\n");
555 552
556 ret = uart_register_driver(&clps711x_reg); 553 ret = uart_register_driver(&clps711x_reg);
557 if (ret) 554 if (ret)
@@ -577,6 +574,6 @@ module_init(clps711xuart_init);
577module_exit(clps711xuart_exit); 574module_exit(clps711xuart_exit);
578 575
579MODULE_AUTHOR("Deep Blue Solutions Ltd"); 576MODULE_AUTHOR("Deep Blue Solutions Ltd");
580MODULE_DESCRIPTION("CLPS-711x generic serial driver $Revision: 1.42 $"); 577MODULE_DESCRIPTION("CLPS-711x generic serial driver");
581MODULE_LICENSE("GPL"); 578MODULE_LICENSE("GPL");
582MODULE_ALIAS_CHARDEV(SERIAL_CLPS711X_MAJOR, SERIAL_CLPS711X_MINOR); 579MODULE_ALIAS_CHARDEV(SERIAL_CLPS711X_MAJOR, SERIAL_CLPS711X_MINOR);
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index 0cc39f82d7c5..7274b527a3c1 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -6,7 +6,7 @@
6 * Copyright (C) 2004 Freescale Semiconductor, Inc. 6 * Copyright (C) 2004 Freescale Semiconductor, Inc.
7 * 7 *
8 * 2006 (c) MontaVista Software, Inc. 8 * 2006 (c) MontaVista Software, Inc.
9 * Vitaly Bordug <vbordug@ru.mvista.com> 9 * Vitaly Bordug <vbordug@ru.mvista.com>
10 * 10 *
11 * This file is licensed under the terms of the GNU General Public License 11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any 12 * version 2. This program is licensed "as is" without any warranty of any
@@ -28,7 +28,7 @@
28#define SERIAL_CPM_MAJOR 204 28#define SERIAL_CPM_MAJOR 204
29#define SERIAL_CPM_MINOR 46 29#define SERIAL_CPM_MINOR 46
30 30
31#define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC) 31#define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
32#define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING) 32#define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING)
33#define FLAG_DISCARDING 0x00000004 /* when set, don't discard */ 33#define FLAG_DISCARDING 0x00000004 /* when set, don't discard */
34#define FLAG_SMC 0x00000002 34#define FLAG_SMC 0x00000002
@@ -50,6 +50,15 @@
50 50
51#define SCC_WAIT_CLOSING 100 51#define SCC_WAIT_CLOSING 100
52 52
53#define GPIO_CTS 0
54#define GPIO_RTS 1
55#define GPIO_DCD 2
56#define GPIO_DSR 3
57#define GPIO_DTR 4
58#define GPIO_RI 5
59
60#define NUM_GPIOS (GPIO_RI+1)
61
53struct uart_cpm_port { 62struct uart_cpm_port {
54 struct uart_port port; 63 struct uart_port port;
55 u16 rx_nrfifos; 64 u16 rx_nrfifos;
@@ -68,9 +77,10 @@ struct uart_cpm_port {
68 unsigned char *rx_buf; 77 unsigned char *rx_buf;
69 u32 flags; 78 u32 flags;
70 void (*set_lineif)(struct uart_cpm_port *); 79 void (*set_lineif)(struct uart_cpm_port *);
80 struct clk *clk;
71 u8 brg; 81 u8 brg;
72 uint dp_addr; 82 uint dp_addr;
73 void *mem_addr; 83 void *mem_addr;
74 dma_addr_t dma_addr; 84 dma_addr_t dma_addr;
75 u32 mem_size; 85 u32 mem_size;
76 /* helpers */ 86 /* helpers */
@@ -79,14 +89,12 @@ struct uart_cpm_port {
79 /* Keep track of 'odd' SMC2 wirings */ 89 /* Keep track of 'odd' SMC2 wirings */
80 int is_portb; 90 int is_portb;
81 /* wait on close if needed */ 91 /* wait on close if needed */
82 int wait_closing; 92 int wait_closing;
83 /* value to combine with opcode to form cpm command */ 93 /* value to combine with opcode to form cpm command */
84 u32 command; 94 u32 command;
95 int gpios[NUM_GPIOS];
85}; 96};
86 97
87#ifndef CONFIG_PPC_CPM_NEW_BINDING
88extern int cpm_uart_port_map[UART_NR];
89#endif
90extern int cpm_uart_nr; 98extern int cpm_uart_nr;
91extern struct uart_cpm_port cpm_uart_ports[UART_NR]; 99extern struct uart_cpm_port cpm_uart_ports[UART_NR];
92 100
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index a19dc7ef8861..25efca5a7a1f 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -13,7 +13,7 @@
13 * Copyright (C) 2004, 2007 Freescale Semiconductor, Inc. 13 * Copyright (C) 2004, 2007 Freescale Semiconductor, Inc.
14 * (C) 2004 Intracom, S.A. 14 * (C) 2004 Intracom, S.A.
15 * (C) 2005-2006 MontaVista Software, Inc. 15 * (C) 2005-2006 MontaVista Software, Inc.
16 * Vitaly Bordug <vbordug@ru.mvista.com> 16 * Vitaly Bordug <vbordug@ru.mvista.com>
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by 19 * it under the terms of the GNU General Public License as published by
@@ -42,6 +42,10 @@
42#include <linux/bootmem.h> 42#include <linux/bootmem.h>
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/fs_uart_pd.h> 44#include <linux/fs_uart_pd.h>
45#include <linux/of_platform.h>
46#include <linux/gpio.h>
47#include <linux/of_gpio.h>
48#include <linux/clk.h>
45 49
46#include <asm/io.h> 50#include <asm/io.h>
47#include <asm/irq.h> 51#include <asm/irq.h>
@@ -49,10 +53,6 @@
49#include <asm/fs_pd.h> 53#include <asm/fs_pd.h>
50#include <asm/udbg.h> 54#include <asm/udbg.h>
51 55
52#ifdef CONFIG_PPC_CPM_NEW_BINDING
53#include <linux/of_platform.h>
54#endif
55
56#if defined(CONFIG_SERIAL_CPM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 56#if defined(CONFIG_SERIAL_CPM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
57#define SUPPORT_SYSRQ 57#define SUPPORT_SYSRQ
58#endif 58#endif
@@ -72,59 +72,6 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
72 72
73/**************************************************************/ 73/**************************************************************/
74 74
75#ifndef CONFIG_PPC_CPM_NEW_BINDING
76/* Track which ports are configured as uarts */
77int cpm_uart_port_map[UART_NR];
78/* How many ports did we config as uarts */
79int cpm_uart_nr;
80
81/* Place-holder for board-specific stuff */
82struct platform_device* __attribute__ ((weak)) __init
83early_uart_get_pdev(int index)
84{
85 return NULL;
86}
87
88
89static void cpm_uart_count(void)
90{
91 cpm_uart_nr = 0;
92#ifdef CONFIG_SERIAL_CPM_SMC1
93 cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1;
94#endif
95#ifdef CONFIG_SERIAL_CPM_SMC2
96 cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2;
97#endif
98#ifdef CONFIG_SERIAL_CPM_SCC1
99 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1;
100#endif
101#ifdef CONFIG_SERIAL_CPM_SCC2
102 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2;
103#endif
104#ifdef CONFIG_SERIAL_CPM_SCC3
105 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3;
106#endif
107#ifdef CONFIG_SERIAL_CPM_SCC4
108 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4;
109#endif
110}
111
112/* Get UART number by its id */
113static int cpm_uart_id2nr(int id)
114{
115 int i;
116 if (id < UART_NR) {
117 for (i=0; i<UART_NR; i++) {
118 if (cpm_uart_port_map[i] == id)
119 return i;
120 }
121 }
122
123 /* not found or invalid argument */
124 return -1;
125}
126#endif
127
128/* 75/*
129 * Check, if transmit buffers are processed 76 * Check, if transmit buffers are processed
130*/ 77*/
@@ -152,13 +99,41 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)
152 99
153static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 100static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
154{ 101{
155 /* Whee. Do nothing. */ 102 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
103
104 if (pinfo->gpios[GPIO_RTS] >= 0)
105 gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS));
106
107 if (pinfo->gpios[GPIO_DTR] >= 0)
108 gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR));
156} 109}
157 110
158static unsigned int cpm_uart_get_mctrl(struct uart_port *port) 111static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
159{ 112{
160 /* Whee. Do nothing. */ 113 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
161 return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; 114 unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
115
116 if (pinfo->gpios[GPIO_CTS] >= 0) {
117 if (gpio_get_value(pinfo->gpios[GPIO_CTS]))
118 mctrl &= ~TIOCM_CTS;
119 }
120
121 if (pinfo->gpios[GPIO_DSR] >= 0) {
122 if (gpio_get_value(pinfo->gpios[GPIO_DSR]))
123 mctrl &= ~TIOCM_DSR;
124 }
125
126 if (pinfo->gpios[GPIO_DCD] >= 0) {
127 if (gpio_get_value(pinfo->gpios[GPIO_DCD]))
128 mctrl &= ~TIOCM_CAR;
129 }
130
131 if (pinfo->gpios[GPIO_RI] >= 0) {
132 if (!gpio_get_value(pinfo->gpios[GPIO_RI]))
133 mctrl |= TIOCM_RNG;
134 }
135
136 return mctrl;
162} 137}
163 138
164/* 139/*
@@ -257,6 +232,10 @@ static void cpm_uart_int_tx(struct uart_port *port)
257 cpm_uart_tx_pump(port); 232 cpm_uart_tx_pump(port);
258} 233}
259 234
235#ifdef CONFIG_CONSOLE_POLL
236static int serial_polled;
237#endif
238
260/* 239/*
261 * Receive characters 240 * Receive characters
262 */ 241 */
@@ -265,7 +244,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
265 int i; 244 int i;
266 unsigned char ch; 245 unsigned char ch;
267 u8 *cp; 246 u8 *cp;
268 struct tty_struct *tty = port->info->tty; 247 struct tty_struct *tty = port->info->port.tty;
269 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 248 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
270 cbd_t __iomem *bdp; 249 cbd_t __iomem *bdp;
271 u16 status; 250 u16 status;
@@ -278,6 +257,12 @@ static void cpm_uart_int_rx(struct uart_port *port)
278 */ 257 */
279 bdp = pinfo->rx_cur; 258 bdp = pinfo->rx_cur;
280 for (;;) { 259 for (;;) {
260#ifdef CONFIG_CONSOLE_POLL
261 if (unlikely(serial_polled)) {
262 serial_polled = 0;
263 return;
264 }
265#endif
281 /* get status */ 266 /* get status */
282 status = in_be16(&bdp->cbd_sc); 267 status = in_be16(&bdp->cbd_sc);
283 /* If this one is empty, return happy */ 268 /* If this one is empty, return happy */
@@ -309,7 +294,12 @@ static void cpm_uart_int_rx(struct uart_port *port)
309 goto handle_error; 294 goto handle_error;
310 if (uart_handle_sysrq_char(port, ch)) 295 if (uart_handle_sysrq_char(port, ch))
311 continue; 296 continue;
312 297#ifdef CONFIG_CONSOLE_POLL
298 if (unlikely(serial_polled)) {
299 serial_polled = 0;
300 return;
301 }
302#endif
313 error_return: 303 error_return:
314 tty_insert_flip_char(tty, ch, flg); 304 tty_insert_flip_char(tty, ch, flg);
315 305
@@ -476,10 +466,13 @@ static void cpm_uart_shutdown(struct uart_port *port)
476 } 466 }
477 467
478 /* Shut them really down and reinit buffer descriptors */ 468 /* Shut them really down and reinit buffer descriptors */
479 if (IS_SMC(pinfo)) 469 if (IS_SMC(pinfo)) {
470 out_be16(&pinfo->smcup->smc_brkcr, 0);
480 cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX); 471 cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX);
481 else 472 } else {
473 out_be16(&pinfo->sccup->scc_brkcr, 0);
482 cpm_line_cr_cmd(pinfo, CPM_CR_GRA_STOP_TX); 474 cpm_line_cr_cmd(pinfo, CPM_CR_GRA_STOP_TX);
475 }
483 476
484 cpm_uart_initbd(pinfo); 477 cpm_uart_initbd(pinfo);
485 } 478 }
@@ -547,6 +540,11 @@ static void cpm_uart_set_termios(struct uart_port *port,
547 } 540 }
548 541
549 /* 542 /*
543 * Update the timeout
544 */
545 uart_update_timeout(port, termios->c_cflag, baud);
546
547 /*
550 * Set up parity check flag 548 * Set up parity check flag
551 */ 549 */
552#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 550#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
@@ -590,14 +588,19 @@ static void cpm_uart_set_termios(struct uart_port *port,
590 * enables, because we want to put them back if they were 588 * enables, because we want to put them back if they were
591 * present. 589 * present.
592 */ 590 */
593 prev_mode = in_be16(&smcp->smc_smcmr); 591 prev_mode = in_be16(&smcp->smc_smcmr) & (SMCMR_REN | SMCMR_TEN);
594 out_be16(&smcp->smc_smcmr, smcr_mk_clen(bits) | cval | SMCMR_SM_UART); 592 /* Output in *one* operation, so we don't interrupt RX/TX if they
595 setbits16(&smcp->smc_smcmr, (prev_mode & (SMCMR_REN | SMCMR_TEN))); 593 * were already enabled. */
594 out_be16(&smcp->smc_smcmr, smcr_mk_clen(bits) | cval |
595 SMCMR_SM_UART | prev_mode);
596 } else { 596 } else {
597 out_be16(&sccp->scc_psmr, (sbits << 12) | scval); 597 out_be16(&sccp->scc_psmr, (sbits << 12) | scval);
598 } 598 }
599 599
600 cpm_set_brg(pinfo->brg - 1, baud); 600 if (pinfo->clk)
601 clk_set_rate(pinfo->clk, baud);
602 else
603 cpm_set_brg(pinfo->brg - 1, baud);
601 spin_unlock_irqrestore(&port->lock, flags); 604 spin_unlock_irqrestore(&port->lock, flags);
602} 605}
603 606
@@ -916,6 +919,80 @@ static void cpm_uart_config_port(struct uart_port *port, int flags)
916 cpm_uart_request_port(port); 919 cpm_uart_request_port(port);
917 } 920 }
918} 921}
922
923#ifdef CONFIG_CONSOLE_POLL
924/* Serial polling routines for writing and reading from the uart while
925 * in an interrupt or debug context.
926 */
927
928#define GDB_BUF_SIZE 512 /* power of 2, please */
929
930static char poll_buf[GDB_BUF_SIZE];
931static char *pollp;
932static int poll_chars;
933
934static int poll_wait_key(char *obuf, struct uart_cpm_port *pinfo)
935{
936 u_char c, *cp;
937 volatile cbd_t *bdp;
938 int i;
939
940 /* Get the address of the host memory buffer.
941 */
942 bdp = pinfo->rx_cur;
943 while (bdp->cbd_sc & BD_SC_EMPTY)
944 ;
945
946 /* If the buffer address is in the CPM DPRAM, don't
947 * convert it.
948 */
949 cp = cpm2cpu_addr(bdp->cbd_bufaddr, pinfo);
950
951 if (obuf) {
952 i = c = bdp->cbd_datlen;
953 while (i-- > 0)
954 *obuf++ = *cp++;
955 } else
956 c = *cp;
957 bdp->cbd_sc &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV | BD_SC_ID);
958 bdp->cbd_sc |= BD_SC_EMPTY;
959
960 if (bdp->cbd_sc & BD_SC_WRAP)
961 bdp = pinfo->rx_bd_base;
962 else
963 bdp++;
964 pinfo->rx_cur = (cbd_t *)bdp;
965
966 return (int)c;
967}
968
969static int cpm_get_poll_char(struct uart_port *port)
970{
971 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
972
973 if (!serial_polled) {
974 serial_polled = 1;
975 poll_chars = 0;
976 }
977 if (poll_chars <= 0) {
978 poll_chars = poll_wait_key(poll_buf, pinfo);
979 pollp = poll_buf;
980 }
981 poll_chars--;
982 return *pollp++;
983}
984
985static void cpm_put_poll_char(struct uart_port *port,
986 unsigned char c)
987{
988 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
989 static char ch[2];
990
991 ch[0] = (char)c;
992 cpm_uart_early_write(pinfo->port.line, ch, 1);
993}
994#endif /* CONFIG_CONSOLE_POLL */
995
919static struct uart_ops cpm_uart_pops = { 996static struct uart_ops cpm_uart_pops = {
920 .tx_empty = cpm_uart_tx_empty, 997 .tx_empty = cpm_uart_tx_empty,
921 .set_mctrl = cpm_uart_set_mctrl, 998 .set_mctrl = cpm_uart_set_mctrl,
@@ -933,9 +1010,12 @@ static struct uart_ops cpm_uart_pops = {
933 .request_port = cpm_uart_request_port, 1010 .request_port = cpm_uart_request_port,
934 .config_port = cpm_uart_config_port, 1011 .config_port = cpm_uart_config_port,
935 .verify_port = cpm_uart_verify_port, 1012 .verify_port = cpm_uart_verify_port,
1013#ifdef CONFIG_CONSOLE_POLL
1014 .poll_get_char = cpm_get_poll_char,
1015 .poll_put_char = cpm_put_poll_char,
1016#endif
936}; 1017};
937 1018
938#ifdef CONFIG_PPC_CPM_NEW_BINDING
939struct uart_cpm_port cpm_uart_ports[UART_NR]; 1019struct uart_cpm_port cpm_uart_ports[UART_NR];
940 1020
941static int cpm_uart_init_port(struct device_node *np, 1021static int cpm_uart_init_port(struct device_node *np,
@@ -945,14 +1025,23 @@ static int cpm_uart_init_port(struct device_node *np,
945 void __iomem *mem, *pram; 1025 void __iomem *mem, *pram;
946 int len; 1026 int len;
947 int ret; 1027 int ret;
1028 int i;
948 1029
949 data = of_get_property(np, "fsl,cpm-brg", &len); 1030 data = of_get_property(np, "clock", NULL);
950 if (!data || len != 4) { 1031 if (data) {
951 printk(KERN_ERR "CPM UART %s has no/invalid " 1032 struct clk *clk = clk_get(NULL, (const char*)data);
952 "fsl,cpm-brg property.\n", np->name); 1033 if (!IS_ERR(clk))
953 return -EINVAL; 1034 pinfo->clk = clk;
1035 }
1036 if (!pinfo->clk) {
1037 data = of_get_property(np, "fsl,cpm-brg", &len);
1038 if (!data || len != 4) {
1039 printk(KERN_ERR "CPM UART %s has no/invalid "
1040 "fsl,cpm-brg property.\n", np->name);
1041 return -EINVAL;
1042 }
1043 pinfo->brg = *data;
954 } 1044 }
955 pinfo->brg = *data;
956 1045
957 data = of_get_property(np, "fsl,cpm-command", &len); 1046 data = of_get_property(np, "fsl,cpm-command", &len);
958 if (!data || len != 4) { 1047 if (!data || len != 4) {
@@ -995,6 +1084,7 @@ static int cpm_uart_init_port(struct device_node *np,
995 pinfo->port.type = PORT_CPM; 1084 pinfo->port.type = PORT_CPM;
996 pinfo->port.ops = &cpm_uart_pops, 1085 pinfo->port.ops = &cpm_uart_pops,
997 pinfo->port.iotype = UPIO_MEM; 1086 pinfo->port.iotype = UPIO_MEM;
1087 pinfo->port.fifosize = pinfo->tx_nrfifos * pinfo->tx_fifosize;
998 spin_lock_init(&pinfo->port.lock); 1088 spin_lock_init(&pinfo->port.lock);
999 1089
1000 pinfo->port.irq = of_irq_to_resource(np, 0, NULL); 1090 pinfo->port.irq = of_irq_to_resource(np, 0, NULL);
@@ -1003,6 +1093,9 @@ static int cpm_uart_init_port(struct device_node *np,
1003 goto out_pram; 1093 goto out_pram;
1004 } 1094 }
1005 1095
1096 for (i = 0; i < NUM_GPIOS; i++)
1097 pinfo->gpios[i] = of_get_gpio(np, i);
1098
1006 return cpm_uart_request_port(&pinfo->port); 1099 return cpm_uart_request_port(&pinfo->port);
1007 1100
1008out_pram: 1101out_pram:
@@ -1012,153 +1105,6 @@ out_mem:
1012 return ret; 1105 return ret;
1013} 1106}
1014 1107
1015#else
1016
1017struct uart_cpm_port cpm_uart_ports[UART_NR] = {
1018 [UART_SMC1] = {
1019 .port = {
1020 .irq = SMC1_IRQ,
1021 .ops = &cpm_uart_pops,
1022 .iotype = UPIO_MEM,
1023 .lock = __SPIN_LOCK_UNLOCKED(cpm_uart_ports[UART_SMC1].port.lock),
1024 },
1025 .flags = FLAG_SMC,
1026 .tx_nrfifos = TX_NUM_FIFO,
1027 .tx_fifosize = TX_BUF_SIZE,
1028 .rx_nrfifos = RX_NUM_FIFO,
1029 .rx_fifosize = RX_BUF_SIZE,
1030 .set_lineif = smc1_lineif,
1031 },
1032 [UART_SMC2] = {
1033 .port = {
1034 .irq = SMC2_IRQ,
1035 .ops = &cpm_uart_pops,
1036 .iotype = UPIO_MEM,
1037 .lock = __SPIN_LOCK_UNLOCKED(cpm_uart_ports[UART_SMC2].port.lock),
1038 },
1039 .flags = FLAG_SMC,
1040 .tx_nrfifos = TX_NUM_FIFO,
1041 .tx_fifosize = TX_BUF_SIZE,
1042 .rx_nrfifos = RX_NUM_FIFO,
1043 .rx_fifosize = RX_BUF_SIZE,
1044 .set_lineif = smc2_lineif,
1045#ifdef CONFIG_SERIAL_CPM_ALT_SMC2
1046 .is_portb = 1,
1047#endif
1048 },
1049 [UART_SCC1] = {
1050 .port = {
1051 .irq = SCC1_IRQ,
1052 .ops = &cpm_uart_pops,
1053 .iotype = UPIO_MEM,
1054 .lock = __SPIN_LOCK_UNLOCKED(cpm_uart_ports[UART_SCC1].port.lock),
1055 },
1056 .tx_nrfifos = TX_NUM_FIFO,
1057 .tx_fifosize = TX_BUF_SIZE,
1058 .rx_nrfifos = RX_NUM_FIFO,
1059 .rx_fifosize = RX_BUF_SIZE,
1060 .set_lineif = scc1_lineif,
1061 .wait_closing = SCC_WAIT_CLOSING,
1062 },
1063 [UART_SCC2] = {
1064 .port = {
1065 .irq = SCC2_IRQ,
1066 .ops = &cpm_uart_pops,
1067 .iotype = UPIO_MEM,
1068 .lock = __SPIN_LOCK_UNLOCKED(cpm_uart_ports[UART_SCC2].port.lock),
1069 },
1070 .tx_nrfifos = TX_NUM_FIFO,
1071 .tx_fifosize = TX_BUF_SIZE,
1072 .rx_nrfifos = RX_NUM_FIFO,
1073 .rx_fifosize = RX_BUF_SIZE,
1074 .set_lineif = scc2_lineif,
1075 .wait_closing = SCC_WAIT_CLOSING,
1076 },
1077 [UART_SCC3] = {
1078 .port = {
1079 .irq = SCC3_IRQ,
1080 .ops = &cpm_uart_pops,
1081 .iotype = UPIO_MEM,
1082 .lock = __SPIN_LOCK_UNLOCKED(cpm_uart_ports[UART_SCC3].port.lock),
1083 },
1084 .tx_nrfifos = TX_NUM_FIFO,
1085 .tx_fifosize = TX_BUF_SIZE,
1086 .rx_nrfifos = RX_NUM_FIFO,
1087 .rx_fifosize = RX_BUF_SIZE,
1088 .set_lineif = scc3_lineif,
1089 .wait_closing = SCC_WAIT_CLOSING,
1090 },
1091 [UART_SCC4] = {
1092 .port = {
1093 .irq = SCC4_IRQ,
1094 .ops = &cpm_uart_pops,
1095 .iotype = UPIO_MEM,
1096 .lock = __SPIN_LOCK_UNLOCKED(cpm_uart_ports[UART_SCC4].port.lock),
1097 },
1098 .tx_nrfifos = TX_NUM_FIFO,
1099 .tx_fifosize = TX_BUF_SIZE,
1100 .rx_nrfifos = RX_NUM_FIFO,
1101 .rx_fifosize = RX_BUF_SIZE,
1102 .set_lineif = scc4_lineif,
1103 .wait_closing = SCC_WAIT_CLOSING,
1104 },
1105};
1106
1107int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con)
1108{
1109 struct resource *r;
1110 struct fs_uart_platform_info *pdata = pdev->dev.platform_data;
1111 int idx; /* It is UART_SMCx or UART_SCCx index */
1112 struct uart_cpm_port *pinfo;
1113 int line;
1114 u32 mem, pram;
1115
1116 idx = pdata->fs_no = fs_uart_get_id(pdata);
1117
1118 line = cpm_uart_id2nr(idx);
1119 if(line < 0) {
1120 printk(KERN_ERR"%s(): port %d is not registered", __func__, idx);
1121 return -EINVAL;
1122 }
1123
1124 pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx];
1125
1126 pinfo->brg = pdata->brg;
1127
1128 if (!is_con) {
1129 pinfo->port.line = line;
1130 pinfo->port.flags = UPF_BOOT_AUTOCONF;
1131 }
1132
1133 if (!(r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs")))
1134 return -EINVAL;
1135 mem = (u32)ioremap(r->start, r->end - r->start + 1);
1136
1137 if (!(r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pram")))
1138 return -EINVAL;
1139 pram = (u32)ioremap(r->start, r->end - r->start + 1);
1140
1141 if(idx > fsid_smc2_uart) {
1142 pinfo->sccp = (scc_t *)mem;
1143 pinfo->sccup = (scc_uart_t *)pram;
1144 } else {
1145 pinfo->smcp = (smc_t *)mem;
1146 pinfo->smcup = (smc_uart_t *)pram;
1147 }
1148 pinfo->tx_nrfifos = pdata->tx_num_fifo;
1149 pinfo->tx_fifosize = pdata->tx_buf_size;
1150
1151 pinfo->rx_nrfifos = pdata->rx_num_fifo;
1152 pinfo->rx_fifosize = pdata->rx_buf_size;
1153
1154 pinfo->port.uartclk = pdata->uart_clk;
1155 pinfo->port.mapbase = (unsigned long)mem;
1156 pinfo->port.irq = platform_get_irq(pdev, 0);
1157
1158 return 0;
1159}
1160#endif
1161
1162#ifdef CONFIG_SERIAL_CPM_CONSOLE 1108#ifdef CONFIG_SERIAL_CPM_CONSOLE
1163/* 1109/*
1164 * Print a string to the serial port trying not to disturb 1110 * Print a string to the serial port trying not to disturb
@@ -1169,15 +1115,18 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con)
1169static void cpm_uart_console_write(struct console *co, const char *s, 1115static void cpm_uart_console_write(struct console *co, const char *s,
1170 u_int count) 1116 u_int count)
1171{ 1117{
1172#ifdef CONFIG_PPC_CPM_NEW_BINDING
1173 struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index]; 1118 struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index];
1174#else
1175 struct uart_cpm_port *pinfo =
1176 &cpm_uart_ports[cpm_uart_port_map[co->index]];
1177#endif
1178 unsigned int i; 1119 unsigned int i;
1179 cbd_t __iomem *bdp, *bdbase; 1120 cbd_t __iomem *bdp, *bdbase;
1180 unsigned char *cp; 1121 unsigned char *cp;
1122 unsigned long flags;
1123 int nolock = oops_in_progress;
1124
1125 if (unlikely(nolock)) {
1126 local_irq_save(flags);
1127 } else {
1128 spin_lock_irqsave(&pinfo->port.lock, flags);
1129 }
1181 1130
1182 /* Get the address of the host memory buffer. 1131 /* Get the address of the host memory buffer.
1183 */ 1132 */
@@ -1239,6 +1188,12 @@ static void cpm_uart_console_write(struct console *co, const char *s,
1239 ; 1188 ;
1240 1189
1241 pinfo->tx_cur = bdp; 1190 pinfo->tx_cur = bdp;
1191
1192 if (unlikely(nolock)) {
1193 local_irq_restore(flags);
1194 } else {
1195 spin_unlock_irqrestore(&pinfo->port.lock, flags);
1196 }
1242} 1197}
1243 1198
1244 1199
@@ -1252,7 +1207,6 @@ static int __init cpm_uart_console_setup(struct console *co, char *options)
1252 struct uart_cpm_port *pinfo; 1207 struct uart_cpm_port *pinfo;
1253 struct uart_port *port; 1208 struct uart_port *port;
1254 1209
1255#ifdef CONFIG_PPC_CPM_NEW_BINDING
1256 struct device_node *np = NULL; 1210 struct device_node *np = NULL;
1257 int i = 0; 1211 int i = 0;
1258 1212
@@ -1284,35 +1238,6 @@ static int __init cpm_uart_console_setup(struct console *co, char *options)
1284 if (ret) 1238 if (ret)
1285 return ret; 1239 return ret;
1286 1240
1287#else
1288
1289 struct fs_uart_platform_info *pdata;
1290 struct platform_device* pdev = early_uart_get_pdev(co->index);
1291
1292 if (!pdev) {
1293 pr_info("cpm_uart: console: compat mode\n");
1294 /* compatibility - will be cleaned up */
1295 cpm_uart_init_portdesc();
1296 }
1297
1298 port =
1299 (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
1300 pinfo = (struct uart_cpm_port *)port;
1301 if (!pdev) {
1302 if (pinfo->set_lineif)
1303 pinfo->set_lineif(pinfo);
1304 } else {
1305 pdata = pdev->dev.platform_data;
1306 if (pdata)
1307 if (pdata->init_ioports)
1308 pdata->init_ioports(pdata);
1309
1310 cpm_uart_drv_get_platform_data(pdev, 1);
1311 }
1312
1313 pinfo->flags |= FLAG_CONSOLE;
1314#endif
1315
1316 if (options) { 1241 if (options) {
1317 uart_parse_options(options, &baud, &parity, &bits, &flow); 1242 uart_parse_options(options, &baud, &parity, &bits, &flow);
1318 } else { 1243 } else {
@@ -1324,12 +1249,14 @@ static int __init cpm_uart_console_setup(struct console *co, char *options)
1324 udbg_putc = NULL; 1249 udbg_putc = NULL;
1325#endif 1250#endif
1326 1251
1327 cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX);
1328
1329 if (IS_SMC(pinfo)) { 1252 if (IS_SMC(pinfo)) {
1253 out_be16(&pinfo->smcup->smc_brkcr, 0);
1254 cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX);
1330 clrbits8(&pinfo->smcp->smc_smcm, SMCM_RX | SMCM_TX); 1255 clrbits8(&pinfo->smcp->smc_smcm, SMCM_RX | SMCM_TX);
1331 clrbits16(&pinfo->smcp->smc_smcmr, SMCMR_REN | SMCMR_TEN); 1256 clrbits16(&pinfo->smcp->smc_smcmr, SMCMR_REN | SMCMR_TEN);
1332 } else { 1257 } else {
1258 out_be16(&pinfo->sccup->scc_brkcr, 0);
1259 cpm_line_cr_cmd(pinfo, CPM_CR_GRA_STOP_TX);
1333 clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_TX | UART_SCCM_RX); 1260 clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_TX | UART_SCCM_RX);
1334 clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); 1261 clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT);
1335 } 1262 }
@@ -1386,7 +1313,6 @@ static struct uart_driver cpm_reg = {
1386 .nr = UART_NR, 1313 .nr = UART_NR,
1387}; 1314};
1388 1315
1389#ifdef CONFIG_PPC_CPM_NEW_BINDING
1390static int probe_index; 1316static int probe_index;
1391 1317
1392static int __devinit cpm_uart_probe(struct of_device *ofdev, 1318static int __devinit cpm_uart_probe(struct of_device *ofdev,
@@ -1457,135 +1383,6 @@ static void __exit cpm_uart_exit(void)
1457 of_unregister_platform_driver(&cpm_uart_driver); 1383 of_unregister_platform_driver(&cpm_uart_driver);
1458 uart_unregister_driver(&cpm_reg); 1384 uart_unregister_driver(&cpm_reg);
1459} 1385}
1460#else
1461static int cpm_uart_drv_probe(struct device *dev)
1462{
1463 struct platform_device *pdev = to_platform_device(dev);
1464 struct fs_uart_platform_info *pdata;
1465 int ret = -ENODEV;
1466
1467 if(!pdev) {
1468 printk(KERN_ERR"CPM UART: platform data missing!\n");
1469 return ret;
1470 }
1471
1472 pdata = pdev->dev.platform_data;
1473
1474 if ((ret = cpm_uart_drv_get_platform_data(pdev, 0)))
1475 return ret;
1476
1477 pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", cpm_uart_id2nr(pdata->fs_no));
1478
1479 if (pdata->init_ioports)
1480 pdata->init_ioports(pdata);
1481
1482 ret = uart_add_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port);
1483
1484 return ret;
1485}
1486
1487static int cpm_uart_drv_remove(struct device *dev)
1488{
1489 struct platform_device *pdev = to_platform_device(dev);
1490 struct fs_uart_platform_info *pdata = pdev->dev.platform_data;
1491
1492 pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n",
1493 cpm_uart_id2nr(pdata->fs_no));
1494
1495 uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port);
1496 return 0;
1497}
1498
1499static struct device_driver cpm_smc_uart_driver = {
1500 .name = "fsl-cpm-smc:uart",
1501 .bus = &platform_bus_type,
1502 .probe = cpm_uart_drv_probe,
1503 .remove = cpm_uart_drv_remove,
1504};
1505
1506static struct device_driver cpm_scc_uart_driver = {
1507 .name = "fsl-cpm-scc:uart",
1508 .bus = &platform_bus_type,
1509 .probe = cpm_uart_drv_probe,
1510 .remove = cpm_uart_drv_remove,
1511};
1512
1513/*
1514 This is supposed to match uart devices on platform bus,
1515 */
1516static int match_is_uart (struct device* dev, void* data)
1517{
1518 struct platform_device* pdev = container_of(dev, struct platform_device, dev);
1519 int ret = 0;
1520 /* this was setfunc as uart */
1521 if(strstr(pdev->name,":uart")) {
1522 ret = 1;
1523 }
1524 return ret;
1525}
1526
1527
1528static int cpm_uart_init(void) {
1529
1530 int ret;
1531 int i;
1532 struct device *dev;
1533 printk(KERN_INFO "Serial: CPM driver $Revision: 0.02 $\n");
1534
1535 /* lookup the bus for uart devices */
1536 dev = bus_find_device(&platform_bus_type, NULL, 0, match_is_uart);
1537
1538 /* There are devices on the bus - all should be OK */
1539 if (dev) {
1540 cpm_uart_count();
1541 cpm_reg.nr = cpm_uart_nr;
1542
1543 if (!(ret = uart_register_driver(&cpm_reg))) {
1544 if ((ret = driver_register(&cpm_smc_uart_driver))) {
1545 uart_unregister_driver(&cpm_reg);
1546 return ret;
1547 }
1548 if ((ret = driver_register(&cpm_scc_uart_driver))) {
1549 driver_unregister(&cpm_scc_uart_driver);
1550 uart_unregister_driver(&cpm_reg);
1551 }
1552 }
1553 } else {
1554 /* No capable platform devices found - falling back to legacy mode */
1555 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n");
1556 pr_info(
1557 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n");
1558
1559 /* Don't run this again, if the console driver did it already */
1560 if (cpm_uart_nr == 0)
1561 cpm_uart_init_portdesc();
1562
1563 cpm_reg.nr = cpm_uart_nr;
1564 ret = uart_register_driver(&cpm_reg);
1565
1566 if (ret)
1567 return ret;
1568
1569 for (i = 0; i < cpm_uart_nr; i++) {
1570 int con = cpm_uart_port_map[i];
1571 cpm_uart_ports[con].port.line = i;
1572 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
1573 if (cpm_uart_ports[con].set_lineif)
1574 cpm_uart_ports[con].set_lineif(&cpm_uart_ports[con]);
1575 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
1576 }
1577
1578 }
1579 return ret;
1580}
1581
1582static void __exit cpm_uart_exit(void)
1583{
1584 driver_unregister(&cpm_scc_uart_driver);
1585 driver_unregister(&cpm_smc_uart_driver);
1586 uart_unregister_driver(&cpm_reg);
1587}
1588#endif
1589 1386
1590module_init(cpm_uart_init); 1387module_init(cpm_uart_init);
1591module_exit(cpm_uart_exit); 1388module_exit(cpm_uart_exit);
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 74f1432bb248..0f0aff06c596 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -9,7 +9,7 @@
9 * Copyright (C) 2004 Freescale Semiconductor, Inc. 9 * Copyright (C) 2004 Freescale Semiconductor, Inc.
10 * (C) 2004 Intracom, S.A. 10 * (C) 2004 Intracom, S.A.
11 * (C) 2006 MontaVista Software, Inc. 11 * (C) 2006 MontaVista Software, Inc.
12 * Vitaly Bordug <vbordug@ru.mvista.com> 12 * Vitaly Bordug <vbordug@ru.mvista.com>
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
@@ -51,7 +51,6 @@
51 51
52/**************************************************************/ 52/**************************************************************/
53 53
54#ifdef CONFIG_PPC_CPM_NEW_BINDING
55void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 54void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
56{ 55{
57 cpm_command(port->command, cmd); 56 cpm_command(port->command, cmd);
@@ -68,75 +67,6 @@ void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
68 iounmap(pram); 67 iounmap(pram);
69} 68}
70 69
71#else
72void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
73{
74 ushort val;
75 int line = port - cpm_uart_ports;
76 volatile cpm8xx_t *cp = cpmp;
77
78 switch (line) {
79 case UART_SMC1:
80 val = mk_cr_cmd(CPM_CR_CH_SMC1, cmd) | CPM_CR_FLG;
81 break;
82 case UART_SMC2:
83 val = mk_cr_cmd(CPM_CR_CH_SMC2, cmd) | CPM_CR_FLG;
84 break;
85 case UART_SCC1:
86 val = mk_cr_cmd(CPM_CR_CH_SCC1, cmd) | CPM_CR_FLG;
87 break;
88 case UART_SCC2:
89 val = mk_cr_cmd(CPM_CR_CH_SCC2, cmd) | CPM_CR_FLG;
90 break;
91 case UART_SCC3:
92 val = mk_cr_cmd(CPM_CR_CH_SCC3, cmd) | CPM_CR_FLG;
93 break;
94 case UART_SCC4:
95 val = mk_cr_cmd(CPM_CR_CH_SCC4, cmd) | CPM_CR_FLG;
96 break;
97 default:
98 return;
99
100 }
101 cp->cp_cpcr = val;
102 while (cp->cp_cpcr & CPM_CR_FLG) ;
103}
104
105void smc1_lineif(struct uart_cpm_port *pinfo)
106{
107 pinfo->brg = 1;
108}
109
110void smc2_lineif(struct uart_cpm_port *pinfo)
111{
112 pinfo->brg = 2;
113}
114
115void scc1_lineif(struct uart_cpm_port *pinfo)
116{
117 /* XXX SCC1: insert port configuration here */
118 pinfo->brg = 1;
119}
120
121void scc2_lineif(struct uart_cpm_port *pinfo)
122{
123 /* XXX SCC2: insert port configuration here */
124 pinfo->brg = 2;
125}
126
127void scc3_lineif(struct uart_cpm_port *pinfo)
128{
129 /* XXX SCC3: insert port configuration here */
130 pinfo->brg = 3;
131}
132
133void scc4_lineif(struct uart_cpm_port *pinfo)
134{
135 /* XXX SCC4: insert port configuration here */
136 pinfo->brg = 4;
137}
138#endif
139
140/* 70/*
141 * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 71 * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
142 * receive buffer descriptors from dual port ram, and a character 72 * receive buffer descriptors from dual port ram, and a character
@@ -205,101 +135,3 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
205 135
206 cpm_dpfree(pinfo->dp_addr); 136 cpm_dpfree(pinfo->dp_addr);
207} 137}
208
209#ifndef CONFIG_PPC_CPM_NEW_BINDING
210/* Setup any dynamic params in the uart desc */
211int cpm_uart_init_portdesc(void)
212{
213 pr_debug("CPM uart[-]:init portdesc\n");
214
215 cpm_uart_nr = 0;
216#ifdef CONFIG_SERIAL_CPM_SMC1
217 cpm_uart_ports[UART_SMC1].smcp = &cpmp->cp_smc[0];
218/*
219 * Is SMC1 being relocated?
220 */
221# ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
222 cpm_uart_ports[UART_SMC1].smcup =
223 (smc_uart_t *) & cpmp->cp_dparam[0x3C0];
224# else
225 cpm_uart_ports[UART_SMC1].smcup =
226 (smc_uart_t *) & cpmp->cp_dparam[PROFF_SMC1];
227# endif
228 cpm_uart_ports[UART_SMC1].port.mapbase =
229 (unsigned long)&cpmp->cp_smc[0];
230 cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
231 cpm_uart_ports[UART_SMC1].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
232 cpm_uart_ports[UART_SMC1].port.uartclk = uart_clock();
233 cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1;
234#endif
235
236#ifdef CONFIG_SERIAL_CPM_SMC2
237 cpm_uart_ports[UART_SMC2].smcp = &cpmp->cp_smc[1];
238 cpm_uart_ports[UART_SMC2].smcup =
239 (smc_uart_t *) & cpmp->cp_dparam[PROFF_SMC2];
240 cpm_uart_ports[UART_SMC2].port.mapbase =
241 (unsigned long)&cpmp->cp_smc[1];
242 cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
243 cpm_uart_ports[UART_SMC2].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
244 cpm_uart_ports[UART_SMC2].port.uartclk = uart_clock();
245 cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2;
246#endif
247
248#ifdef CONFIG_SERIAL_CPM_SCC1
249 cpm_uart_ports[UART_SCC1].sccp = &cpmp->cp_scc[0];
250 cpm_uart_ports[UART_SCC1].sccup =
251 (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC1];
252 cpm_uart_ports[UART_SCC1].port.mapbase =
253 (unsigned long)&cpmp->cp_scc[0];
254 cpm_uart_ports[UART_SCC1].sccp->scc_sccm &=
255 ~(UART_SCCM_TX | UART_SCCM_RX);
256 cpm_uart_ports[UART_SCC1].sccp->scc_gsmrl &=
257 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
258 cpm_uart_ports[UART_SCC1].port.uartclk = uart_clock();
259 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1;
260#endif
261
262#ifdef CONFIG_SERIAL_CPM_SCC2
263 cpm_uart_ports[UART_SCC2].sccp = &cpmp->cp_scc[1];
264 cpm_uart_ports[UART_SCC2].sccup =
265 (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC2];
266 cpm_uart_ports[UART_SCC2].port.mapbase =
267 (unsigned long)&cpmp->cp_scc[1];
268 cpm_uart_ports[UART_SCC2].sccp->scc_sccm &=
269 ~(UART_SCCM_TX | UART_SCCM_RX);
270 cpm_uart_ports[UART_SCC2].sccp->scc_gsmrl &=
271 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
272 cpm_uart_ports[UART_SCC2].port.uartclk = uart_clock();
273 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2;
274#endif
275
276#ifdef CONFIG_SERIAL_CPM_SCC3
277 cpm_uart_ports[UART_SCC3].sccp = &cpmp->cp_scc[2];
278 cpm_uart_ports[UART_SCC3].sccup =
279 (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC3];
280 cpm_uart_ports[UART_SCC3].port.mapbase =
281 (unsigned long)&cpmp->cp_scc[2];
282 cpm_uart_ports[UART_SCC3].sccp->scc_sccm &=
283 ~(UART_SCCM_TX | UART_SCCM_RX);
284 cpm_uart_ports[UART_SCC3].sccp->scc_gsmrl &=
285 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
286 cpm_uart_ports[UART_SCC3].port.uartclk = uart_clock();
287 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3;
288#endif
289
290#ifdef CONFIG_SERIAL_CPM_SCC4
291 cpm_uart_ports[UART_SCC4].sccp = &cpmp->cp_scc[3];
292 cpm_uart_ports[UART_SCC4].sccup =
293 (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC4];
294 cpm_uart_ports[UART_SCC4].port.mapbase =
295 (unsigned long)&cpmp->cp_scc[3];
296 cpm_uart_ports[UART_SCC4].sccp->scc_sccm &=
297 ~(UART_SCCM_TX | UART_SCCM_RX);
298 cpm_uart_ports[UART_SCC4].sccp->scc_gsmrl &=
299 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
300 cpm_uart_ports[UART_SCC4].port.uartclk = uart_clock();
301 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4;
302#endif
303 return 0;
304}
305#endif
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.h b/drivers/serial/cpm_uart/cpm_uart_cpm1.h
index ddf46d3c964b..10eecd6af6d4 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.h
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.h
@@ -2,7 +2,7 @@
2 * linux/drivers/serial/cpm_uart/cpm_uart_cpm1.h 2 * linux/drivers/serial/cpm_uart/cpm_uart_cpm1.h
3 * 3 *
4 * Driver for CPM (SCC/SMC) serial ports 4 * Driver for CPM (SCC/SMC) serial ports
5 * 5 *
6 * definitions for cpm1 6 * definitions for cpm1
7 * 7 *
8 */ 8 */
@@ -12,16 +12,6 @@
12 12
13#include <asm/cpm1.h> 13#include <asm/cpm1.h>
14 14
15/* defines for IRQs */
16#ifndef CONFIG_PPC_CPM_NEW_BINDING
17#define SMC1_IRQ (CPM_IRQ_OFFSET + CPMVEC_SMC1)
18#define SMC2_IRQ (CPM_IRQ_OFFSET + CPMVEC_SMC2)
19#define SCC1_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC1)
20#define SCC2_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC2)
21#define SCC3_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC3)
22#define SCC4_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC4)
23#endif
24
25static inline void cpm_set_brg(int brg, int baud) 15static inline void cpm_set_brg(int brg, int baud)
26{ 16{
27 cpm_setbrg(brg, baud); 17 cpm_setbrg(brg, baud);
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index bb862e2f54cf..b8db4d3eed36 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -5,11 +5,11 @@
5 * 5 *
6 * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2) 6 * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
7 * Pantelis Antoniou (panto@intracom.gr) (CPM1) 7 * Pantelis Antoniou (panto@intracom.gr) (CPM1)
8 * 8 *
9 * Copyright (C) 2004 Freescale Semiconductor, Inc. 9 * Copyright (C) 2004 Freescale Semiconductor, Inc.
10 * (C) 2004 Intracom, S.A. 10 * (C) 2004 Intracom, S.A.
11 * (C) 2006 MontaVista Software, Inc. 11 * (C) 2006 MontaVista Software, Inc.
12 * Vitaly Bordug <vbordug@ru.mvista.com> 12 * Vitaly Bordug <vbordug@ru.mvista.com>
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
@@ -41,9 +41,7 @@
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/irq.h> 42#include <asm/irq.h>
43#include <asm/fs_pd.h> 43#include <asm/fs_pd.h>
44#ifdef CONFIG_PPC_CPM_NEW_BINDING
45#include <asm/prom.h> 44#include <asm/prom.h>
46#endif
47 45
48#include <linux/serial_core.h> 46#include <linux/serial_core.h>
49#include <linux/kernel.h> 47#include <linux/kernel.h>
@@ -52,7 +50,6 @@
52 50
53/**************************************************************/ 51/**************************************************************/
54 52
55#ifdef CONFIG_PPC_CPM_NEW_BINDING
56void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 53void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
57{ 54{
58 cpm_command(port->command, cmd); 55 cpm_command(port->command, cmd);
@@ -106,174 +103,8 @@ void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
106 iounmap(pram); 103 iounmap(pram);
107} 104}
108 105
109#else
110void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
111{
112 ulong val;
113 int line = port - cpm_uart_ports;
114 volatile cpm_cpm2_t *cp = cpm2_map(im_cpm);
115
116
117 switch (line) {
118 case UART_SMC1:
119 val = mk_cr_cmd(CPM_CR_SMC1_PAGE, CPM_CR_SMC1_SBLOCK, 0,
120 cmd) | CPM_CR_FLG;
121 break;
122 case UART_SMC2:
123 val = mk_cr_cmd(CPM_CR_SMC2_PAGE, CPM_CR_SMC2_SBLOCK, 0,
124 cmd) | CPM_CR_FLG;
125 break;
126 case UART_SCC1:
127 val = mk_cr_cmd(CPM_CR_SCC1_PAGE, CPM_CR_SCC1_SBLOCK, 0,
128 cmd) | CPM_CR_FLG;
129 break;
130 case UART_SCC2:
131 val = mk_cr_cmd(CPM_CR_SCC2_PAGE, CPM_CR_SCC2_SBLOCK, 0,
132 cmd) | CPM_CR_FLG;
133 break;
134 case UART_SCC3:
135 val = mk_cr_cmd(CPM_CR_SCC3_PAGE, CPM_CR_SCC3_SBLOCK, 0,
136 cmd) | CPM_CR_FLG;
137 break;
138 case UART_SCC4:
139 val = mk_cr_cmd(CPM_CR_SCC4_PAGE, CPM_CR_SCC4_SBLOCK, 0,
140 cmd) | CPM_CR_FLG;
141 break;
142 default:
143 return;
144
145 }
146 cp->cp_cpcr = val;
147 while (cp->cp_cpcr & CPM_CR_FLG) ;
148
149 cpm2_unmap(cp);
150}
151
152void smc1_lineif(struct uart_cpm_port *pinfo)
153{
154 volatile iop_cpm2_t *io = cpm2_map(im_ioport);
155 volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
156
157 /* SMC1 is only on port D */
158 io->iop_ppard |= 0x00c00000;
159 io->iop_pdird |= 0x00400000;
160 io->iop_pdird &= ~0x00800000;
161 io->iop_psord &= ~0x00c00000;
162
163 /* Wire BRG1 to SMC1 */
164 cpmux->cmx_smr &= 0x0f;
165 pinfo->brg = 1;
166
167 cpm2_unmap(cpmux);
168 cpm2_unmap(io);
169}
170
171void smc2_lineif(struct uart_cpm_port *pinfo)
172{
173 volatile iop_cpm2_t *io = cpm2_map(im_ioport);
174 volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
175
176 /* SMC2 is only on port A */
177 io->iop_ppara |= 0x00c00000;
178 io->iop_pdira |= 0x00400000;
179 io->iop_pdira &= ~0x00800000;
180 io->iop_psora &= ~0x00c00000;
181
182 /* Wire BRG2 to SMC2 */
183 cpmux->cmx_smr &= 0xf0;
184 pinfo->brg = 2;
185
186 cpm2_unmap(cpmux);
187 cpm2_unmap(io);
188}
189
190void scc1_lineif(struct uart_cpm_port *pinfo)
191{
192 volatile iop_cpm2_t *io = cpm2_map(im_ioport);
193 volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
194
195 /* Use Port D for SCC1 instead of other functions. */
196 io->iop_ppard |= 0x00000003;
197 io->iop_psord &= ~0x00000001; /* Rx */
198 io->iop_psord |= 0x00000002; /* Tx */
199 io->iop_pdird &= ~0x00000001; /* Rx */
200 io->iop_pdird |= 0x00000002; /* Tx */
201
202 /* Wire BRG1 to SCC1 */
203 cpmux->cmx_scr &= 0x00ffffff;
204 cpmux->cmx_scr |= 0x00000000;
205 pinfo->brg = 1;
206
207 cpm2_unmap(cpmux);
208 cpm2_unmap(io);
209}
210
211void scc2_lineif(struct uart_cpm_port *pinfo)
212{
213 /*
214 * STx GP3 uses the SCC2 secondary option pin assignment
215 * which this driver doesn't account for in the static
216 * pin assignments. This kind of board specific info
217 * really has to get out of the driver so boards can
218 * be supported in a sane fashion.
219 */
220 volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
221#ifndef CONFIG_STX_GP3
222 volatile iop_cpm2_t *io = cpm2_map(im_ioport);
223
224 io->iop_pparb |= 0x008b0000;
225 io->iop_pdirb |= 0x00880000;
226 io->iop_psorb |= 0x00880000;
227 io->iop_pdirb &= ~0x00030000;
228 io->iop_psorb &= ~0x00030000;
229#endif
230 cpmux->cmx_scr &= 0xff00ffff;
231 cpmux->cmx_scr |= 0x00090000;
232 pinfo->brg = 2;
233
234 cpm2_unmap(cpmux);
235 cpm2_unmap(io);
236}
237
238void scc3_lineif(struct uart_cpm_port *pinfo)
239{
240 volatile iop_cpm2_t *io = cpm2_map(im_ioport);
241 volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
242
243 io->iop_pparb |= 0x008b0000;
244 io->iop_pdirb |= 0x00880000;
245 io->iop_psorb |= 0x00880000;
246 io->iop_pdirb &= ~0x00030000;
247 io->iop_psorb &= ~0x00030000;
248 cpmux->cmx_scr &= 0xffff00ff;
249 cpmux->cmx_scr |= 0x00001200;
250 pinfo->brg = 3;
251
252 cpm2_unmap(cpmux);
253 cpm2_unmap(io);
254}
255
256void scc4_lineif(struct uart_cpm_port *pinfo)
257{
258 volatile iop_cpm2_t *io = cpm2_map(im_ioport);
259 volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
260
261 io->iop_ppard |= 0x00000600;
262 io->iop_psord &= ~0x00000600; /* Tx/Rx */
263 io->iop_pdird &= ~0x00000200; /* Rx */
264 io->iop_pdird |= 0x00000400; /* Tx */
265
266 cpmux->cmx_scr &= 0xffffff00;
267 cpmux->cmx_scr |= 0x0000001b;
268 pinfo->brg = 4;
269
270 cpm2_unmap(cpmux);
271 cpm2_unmap(io);
272}
273#endif
274
275/* 106/*
276 * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 107 * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
277 * receive buffer descriptors from dual port ram, and a character 108 * receive buffer descriptors from dual port ram, and a character
278 * buffer area from host mem. If we are allocating for the console we need 109 * buffer area from host mem. If we are allocating for the console we need
279 * to do it from bootmem 110 * to do it from bootmem
@@ -340,111 +171,3 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
340 171
341 cpm_dpfree(pinfo->dp_addr); 172 cpm_dpfree(pinfo->dp_addr);
342} 173}
343
344#ifndef CONFIG_PPC_CPM_NEW_BINDING
345/* Setup any dynamic params in the uart desc */
346int cpm_uart_init_portdesc(void)
347{
348#if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2)
349 u16 *addr;
350#endif
351 pr_debug("CPM uart[-]:init portdesc\n");
352
353 cpm_uart_nr = 0;
354#ifdef CONFIG_SERIAL_CPM_SMC1
355 cpm_uart_ports[UART_SMC1].smcp = (smc_t *) cpm2_map(im_smc[0]);
356 cpm_uart_ports[UART_SMC1].port.mapbase =
357 (unsigned long)cpm_uart_ports[UART_SMC1].smcp;
358
359 cpm_uart_ports[UART_SMC1].smcup =
360 (smc_uart_t *) cpm2_map_size(im_dprambase[PROFF_SMC1], PROFF_SMC_SIZE);
361 addr = (u16 *)cpm2_map_size(im_dprambase[PROFF_SMC1_BASE], 2);
362 *addr = PROFF_SMC1;
363 cpm2_unmap(addr);
364
365 cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
366 cpm_uart_ports[UART_SMC1].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
367 cpm_uart_ports[UART_SMC1].port.uartclk = uart_clock();
368 cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1;
369#endif
370
371#ifdef CONFIG_SERIAL_CPM_SMC2
372 cpm_uart_ports[UART_SMC2].smcp = (smc_t *) cpm2_map(im_smc[1]);
373 cpm_uart_ports[UART_SMC2].port.mapbase =
374 (unsigned long)cpm_uart_ports[UART_SMC2].smcp;
375
376 cpm_uart_ports[UART_SMC2].smcup =
377 (smc_uart_t *) cpm2_map_size(im_dprambase[PROFF_SMC2], PROFF_SMC_SIZE);
378 addr = (u16 *)cpm2_map_size(im_dprambase[PROFF_SMC2_BASE], 2);
379 *addr = PROFF_SMC2;
380 cpm2_unmap(addr);
381
382 cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
383 cpm_uart_ports[UART_SMC2].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
384 cpm_uart_ports[UART_SMC2].port.uartclk = uart_clock();
385 cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2;
386#endif
387
388#ifdef CONFIG_SERIAL_CPM_SCC1
389 cpm_uart_ports[UART_SCC1].sccp = (scc_t *) cpm2_map(im_scc[0]);
390 cpm_uart_ports[UART_SCC1].port.mapbase =
391 (unsigned long)cpm_uart_ports[UART_SCC1].sccp;
392 cpm_uart_ports[UART_SCC1].sccup =
393 (scc_uart_t *) cpm2_map_size(im_dprambase[PROFF_SCC1], PROFF_SCC_SIZE);
394
395 cpm_uart_ports[UART_SCC1].sccp->scc_sccm &=
396 ~(UART_SCCM_TX | UART_SCCM_RX);
397 cpm_uart_ports[UART_SCC1].sccp->scc_gsmrl &=
398 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
399 cpm_uart_ports[UART_SCC1].port.uartclk = uart_clock();
400 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1;
401#endif
402
403#ifdef CONFIG_SERIAL_CPM_SCC2
404 cpm_uart_ports[UART_SCC2].sccp = (scc_t *) cpm2_map(im_scc[1]);
405 cpm_uart_ports[UART_SCC2].port.mapbase =
406 (unsigned long)cpm_uart_ports[UART_SCC2].sccp;
407 cpm_uart_ports[UART_SCC2].sccup =
408 (scc_uart_t *) cpm2_map_size(im_dprambase[PROFF_SCC2], PROFF_SCC_SIZE);
409
410 cpm_uart_ports[UART_SCC2].sccp->scc_sccm &=
411 ~(UART_SCCM_TX | UART_SCCM_RX);
412 cpm_uart_ports[UART_SCC2].sccp->scc_gsmrl &=
413 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
414 cpm_uart_ports[UART_SCC2].port.uartclk = uart_clock();
415 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2;
416#endif
417
418#ifdef CONFIG_SERIAL_CPM_SCC3
419 cpm_uart_ports[UART_SCC3].sccp = (scc_t *) cpm2_map(im_scc[2]);
420 cpm_uart_ports[UART_SCC3].port.mapbase =
421 (unsigned long)cpm_uart_ports[UART_SCC3].sccp;
422 cpm_uart_ports[UART_SCC3].sccup =
423 (scc_uart_t *) cpm2_map_size(im_dprambase[PROFF_SCC3], PROFF_SCC_SIZE);
424
425 cpm_uart_ports[UART_SCC3].sccp->scc_sccm &=
426 ~(UART_SCCM_TX | UART_SCCM_RX);
427 cpm_uart_ports[UART_SCC3].sccp->scc_gsmrl &=
428 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
429 cpm_uart_ports[UART_SCC3].port.uartclk = uart_clock();
430 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3;
431#endif
432
433#ifdef CONFIG_SERIAL_CPM_SCC4
434 cpm_uart_ports[UART_SCC4].sccp = (scc_t *) cpm2_map(im_scc[3]);
435 cpm_uart_ports[UART_SCC4].port.mapbase =
436 (unsigned long)cpm_uart_ports[UART_SCC4].sccp;
437 cpm_uart_ports[UART_SCC4].sccup =
438 (scc_uart_t *) cpm2_map_size(im_dprambase[PROFF_SCC4], PROFF_SCC_SIZE);
439
440 cpm_uart_ports[UART_SCC4].sccp->scc_sccm &=
441 ~(UART_SCCM_TX | UART_SCCM_RX);
442 cpm_uart_ports[UART_SCC4].sccp->scc_gsmrl &=
443 ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
444 cpm_uart_ports[UART_SCC4].port.uartclk = uart_clock();
445 cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4;
446#endif
447
448 return 0;
449}
450#endif
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.h b/drivers/serial/cpm_uart/cpm_uart_cpm2.h
index 40006a7dce46..7194c63dcf5f 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.h
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.h
@@ -2,7 +2,7 @@
2 * linux/drivers/serial/cpm_uart/cpm_uart_cpm2.h 2 * linux/drivers/serial/cpm_uart/cpm_uart_cpm2.h
3 * 3 *
4 * Driver for CPM (SCC/SMC) serial ports 4 * Driver for CPM (SCC/SMC) serial ports
5 * 5 *
6 * definitions for cpm2 6 * definitions for cpm2
7 * 7 *
8 */ 8 */
@@ -12,16 +12,6 @@
12 12
13#include <asm/cpm2.h> 13#include <asm/cpm2.h>
14 14
15/* defines for IRQs */
16#ifndef CONFIG_PPC_CPM_NEW_BINDING
17#define SMC1_IRQ SIU_INT_SMC1
18#define SMC2_IRQ SIU_INT_SMC2
19#define SCC1_IRQ SIU_INT_SCC1
20#define SCC2_IRQ SIU_INT_SCC2
21#define SCC3_IRQ SIU_INT_SCC3
22#define SCC4_IRQ SIU_INT_SCC4
23#endif
24
25static inline void cpm_set_brg(int brg, int baud) 15static inline void cpm_set_brg(int brg, int baud)
26{ 16{
27 cpm_setbrg(brg, baud); 17 cpm_setbrg(brg, baud);
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 3e0366eab412..bf94a770bb44 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -234,7 +234,7 @@ unsigned long r_alt_ser_baudrate_shadow = 0;
234 234
235static struct e100_serial rs_table[] = { 235static struct e100_serial rs_table[] = {
236 { .baud = DEF_BAUD, 236 { .baud = DEF_BAUD,
237 .port = (unsigned char *)R_SERIAL0_CTRL, 237 .ioport = (unsigned char *)R_SERIAL0_CTRL,
238 .irq = 1U << 12, /* uses DMA 6 and 7 */ 238 .irq = 1U << 12, /* uses DMA 6 and 7 */
239 .oclrintradr = R_DMA_CH6_CLR_INTR, 239 .oclrintradr = R_DMA_CH6_CLR_INTR,
240 .ofirstadr = R_DMA_CH6_FIRST, 240 .ofirstadr = R_DMA_CH6_FIRST,
@@ -288,7 +288,7 @@ static struct e100_serial rs_table[] = {
288}, /* ttyS0 */ 288}, /* ttyS0 */
289#ifndef CONFIG_SVINTO_SIM 289#ifndef CONFIG_SVINTO_SIM
290 { .baud = DEF_BAUD, 290 { .baud = DEF_BAUD,
291 .port = (unsigned char *)R_SERIAL1_CTRL, 291 .ioport = (unsigned char *)R_SERIAL1_CTRL,
292 .irq = 1U << 16, /* uses DMA 8 and 9 */ 292 .irq = 1U << 16, /* uses DMA 8 and 9 */
293 .oclrintradr = R_DMA_CH8_CLR_INTR, 293 .oclrintradr = R_DMA_CH8_CLR_INTR,
294 .ofirstadr = R_DMA_CH8_FIRST, 294 .ofirstadr = R_DMA_CH8_FIRST,
@@ -344,7 +344,7 @@ static struct e100_serial rs_table[] = {
344}, /* ttyS1 */ 344}, /* ttyS1 */
345 345
346 { .baud = DEF_BAUD, 346 { .baud = DEF_BAUD,
347 .port = (unsigned char *)R_SERIAL2_CTRL, 347 .ioport = (unsigned char *)R_SERIAL2_CTRL,
348 .irq = 1U << 4, /* uses DMA 2 and 3 */ 348 .irq = 1U << 4, /* uses DMA 2 and 3 */
349 .oclrintradr = R_DMA_CH2_CLR_INTR, 349 .oclrintradr = R_DMA_CH2_CLR_INTR,
350 .ofirstadr = R_DMA_CH2_FIRST, 350 .ofirstadr = R_DMA_CH2_FIRST,
@@ -398,7 +398,7 @@ static struct e100_serial rs_table[] = {
398 }, /* ttyS2 */ 398 }, /* ttyS2 */
399 399
400 { .baud = DEF_BAUD, 400 { .baud = DEF_BAUD,
401 .port = (unsigned char *)R_SERIAL3_CTRL, 401 .ioport = (unsigned char *)R_SERIAL3_CTRL,
402 .irq = 1U << 8, /* uses DMA 4 and 5 */ 402 .irq = 1U << 8, /* uses DMA 4 and 5 */
403 .oclrintradr = R_DMA_CH4_CLR_INTR, 403 .oclrintradr = R_DMA_CH4_CLR_INTR,
404 .ofirstadr = R_DMA_CH4_FIRST, 404 .ofirstadr = R_DMA_CH4_FIRST,
@@ -939,7 +939,7 @@ static const struct control_pins e100_modem_pins[NR_PORTS] =
939/* Output */ 939/* Output */
940#define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK) 940#define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK)
941/* Input */ 941/* Input */
942#define E100_CTS_GET(info) ((info)->port[REG_STATUS] & E100_CTS_MASK) 942#define E100_CTS_GET(info) ((info)->ioport[REG_STATUS] & E100_CTS_MASK)
943 943
944/* These are typically PA or PB and 0 means 0V, 1 means 3.3V */ 944/* These are typically PA or PB and 0 means 0V, 1 means 3.3V */
945/* Is an output */ 945/* Is an output */
@@ -968,7 +968,7 @@ static DEFINE_MUTEX(tmp_buf_mutex);
968/* Calculate the chartime depending on baudrate, numbor of bits etc. */ 968/* Calculate the chartime depending on baudrate, numbor of bits etc. */
969static void update_char_time(struct e100_serial * info) 969static void update_char_time(struct e100_serial * info)
970{ 970{
971 tcflag_t cflags = info->tty->termios->c_cflag; 971 tcflag_t cflags = info->port.tty->termios->c_cflag;
972 int bits; 972 int bits;
973 973
974 /* calc. number of bits / data byte */ 974 /* calc. number of bits / data byte */
@@ -1092,7 +1092,7 @@ e100_rts(struct e100_serial *info, int set)
1092 local_irq_save(flags); 1092 local_irq_save(flags);
1093 info->rx_ctrl &= ~E100_RTS_MASK; 1093 info->rx_ctrl &= ~E100_RTS_MASK;
1094 info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */ 1094 info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */
1095 info->port[REG_REC_CTRL] = info->rx_ctrl; 1095 info->ioport[REG_REC_CTRL] = info->rx_ctrl;
1096 local_irq_restore(flags); 1096 local_irq_restore(flags);
1097#ifdef SERIAL_DEBUG_IO 1097#ifdef SERIAL_DEBUG_IO
1098 printk("ser%i rts %i\n", info->line, set); 1098 printk("ser%i rts %i\n", info->line, set);
@@ -1142,7 +1142,7 @@ e100_disable_rx(struct e100_serial *info)
1142{ 1142{
1143#ifndef CONFIG_SVINTO_SIM 1143#ifndef CONFIG_SVINTO_SIM
1144 /* disable the receiver */ 1144 /* disable the receiver */
1145 info->port[REG_REC_CTRL] = 1145 info->ioport[REG_REC_CTRL] =
1146 (info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); 1146 (info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
1147#endif 1147#endif
1148} 1148}
@@ -1152,7 +1152,7 @@ e100_enable_rx(struct e100_serial *info)
1152{ 1152{
1153#ifndef CONFIG_SVINTO_SIM 1153#ifndef CONFIG_SVINTO_SIM
1154 /* enable the receiver */ 1154 /* enable the receiver */
1155 info->port[REG_REC_CTRL] = 1155 info->ioport[REG_REC_CTRL] =
1156 (info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); 1156 (info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
1157#endif 1157#endif
1158} 1158}
@@ -1483,13 +1483,14 @@ rs_stop(struct tty_struct *tty)
1483 CIRC_CNT(info->xmit.head, 1483 CIRC_CNT(info->xmit.head,
1484 info->xmit.tail,SERIAL_XMIT_SIZE))); 1484 info->xmit.tail,SERIAL_XMIT_SIZE)));
1485 1485
1486 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->tty)); 1486 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char,
1487 STOP_CHAR(info->port.tty));
1487 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, stop); 1488 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, stop);
1488 if (tty->termios->c_iflag & IXON ) { 1489 if (tty->termios->c_iflag & IXON ) {
1489 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 1490 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
1490 } 1491 }
1491 1492
1492 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1493 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
1493 local_irq_restore(flags); 1494 local_irq_restore(flags);
1494 } 1495 }
1495} 1496}
@@ -1512,7 +1513,7 @@ rs_start(struct tty_struct *tty)
1512 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 1513 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
1513 } 1514 }
1514 1515
1515 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1516 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
1516 if (!info->uses_dma_out && 1517 if (!info->uses_dma_out &&
1517 info->xmit.head != info->xmit.tail && info->xmit.buf) 1518 info->xmit.head != info->xmit.tail && info->xmit.buf)
1518 e100_enable_serial_tx_ready_irq(info); 1519 e100_enable_serial_tx_ready_irq(info);
@@ -1772,7 +1773,7 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl
1772 1773
1773 info->icount.rx++; 1774 info->icount.rx++;
1774 } else { 1775 } else {
1775 struct tty_struct *tty = info->tty; 1776 struct tty_struct *tty = info->port.tty;
1776 tty_insert_flip_char(tty, data, flag); 1777 tty_insert_flip_char(tty, data, flag);
1777 info->icount.rx++; 1778 info->icount.rx++;
1778 } 1779 }
@@ -1838,7 +1839,7 @@ static unsigned int handle_all_descr_data(struct e100_serial *info)
1838 descr->status = 0; 1839 descr->status = 0;
1839 1840
1840 DFLOW( DEBUG_LOG(info->line, "RX %lu\n", recvl); 1841 DFLOW( DEBUG_LOG(info->line, "RX %lu\n", recvl);
1841 if (info->tty->stopped) { 1842 if (info->port.tty->stopped) {
1842 unsigned char *buf = phys_to_virt(descr->buf); 1843 unsigned char *buf = phys_to_virt(descr->buf);
1843 DEBUG_LOG(info->line, "rx 0x%02X\n", buf[0]); 1844 DEBUG_LOG(info->line, "rx 0x%02X\n", buf[0]);
1844 DEBUG_LOG(info->line, "rx 0x%02X\n", buf[1]); 1845 DEBUG_LOG(info->line, "rx 0x%02X\n", buf[1]);
@@ -1872,7 +1873,7 @@ static void receive_chars_dma(struct e100_serial *info)
1872 IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) | 1873 IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
1873 IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do); 1874 IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
1874 1875
1875 tty = info->tty; 1876 tty = info->port.tty;
1876 if (!tty) /* Something wrong... */ 1877 if (!tty) /* Something wrong... */
1877 return; 1878 return;
1878 1879
@@ -1887,7 +1888,7 @@ static void receive_chars_dma(struct e100_serial *info)
1887 handle_all_descr_data(info); 1888 handle_all_descr_data(info);
1888 1889
1889 /* Read the status register to detect errors */ 1890 /* Read the status register to detect errors */
1890 rstat = info->port[REG_STATUS]; 1891 rstat = info->ioport[REG_STATUS];
1891 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { 1892 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
1892 DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat)); 1893 DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat));
1893 } 1894 }
@@ -1896,7 +1897,7 @@ static void receive_chars_dma(struct e100_serial *info)
1896 /* If we got an error, we must reset it by reading the 1897 /* If we got an error, we must reset it by reading the
1897 * data_in field 1898 * data_in field
1898 */ 1899 */
1899 unsigned char data = info->port[REG_DATA]; 1900 unsigned char data = info->ioport[REG_DATA];
1900 1901
1901 PROCSTAT(ser_stat[info->line].errors_cnt++); 1902 PROCSTAT(ser_stat[info->line].errors_cnt++);
1902 DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n", 1903 DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n",
@@ -2076,7 +2077,7 @@ static int force_eop_if_needed(struct e100_serial *info)
2076 /* We check data_avail bit to determine if data has 2077 /* We check data_avail bit to determine if data has
2077 * arrived since last time 2078 * arrived since last time
2078 */ 2079 */
2079 unsigned char rstat = info->port[REG_STATUS]; 2080 unsigned char rstat = info->ioport[REG_STATUS];
2080 2081
2081 /* error or datavail? */ 2082 /* error or datavail? */
2082 if (rstat & SER_ERROR_MASK) { 2083 if (rstat & SER_ERROR_MASK) {
@@ -2095,7 +2096,7 @@ static int force_eop_if_needed(struct e100_serial *info)
2095 TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n", 2096 TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n",
2096 rstat | (info->line << 8))); 2097 rstat | (info->line << 8)));
2097 /* Read data to clear status flags */ 2098 /* Read data to clear status flags */
2098 (void)info->port[REG_DATA]; 2099 (void)info->ioport[REG_DATA];
2099 2100
2100 info->forced_eop = 0; 2101 info->forced_eop = 0;
2101 START_FLUSH_FAST_TIMER(info, "magic"); 2102 START_FLUSH_FAST_TIMER(info, "magic");
@@ -2122,7 +2123,7 @@ static void flush_to_flip_buffer(struct e100_serial *info)
2122 unsigned long flags; 2123 unsigned long flags;
2123 2124
2124 local_irq_save(flags); 2125 local_irq_save(flags);
2125 tty = info->tty; 2126 tty = info->port.tty;
2126 2127
2127 if (!tty) { 2128 if (!tty) {
2128 local_irq_restore(flags); 2129 local_irq_restore(flags);
@@ -2287,7 +2288,7 @@ static
2287struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) 2288struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2288{ 2289{
2289 unsigned long data_read; 2290 unsigned long data_read;
2290 struct tty_struct *tty = info->tty; 2291 struct tty_struct *tty = info->port.tty;
2291 2292
2292 if (!tty) { 2293 if (!tty) {
2293 printk("!NO TTY!\n"); 2294 printk("!NO TTY!\n");
@@ -2295,7 +2296,7 @@ struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2295 } 2296 }
2296 2297
2297 /* Read data and status at the same time */ 2298 /* Read data and status at the same time */
2298 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2299 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]);
2299more_data: 2300more_data:
2300 if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) { 2301 if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) {
2301 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); 2302 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
@@ -2350,7 +2351,7 @@ more_data:
2350 data_in, data_read); 2351 data_in, data_read);
2351 char flag = TTY_NORMAL; 2352 char flag = TTY_NORMAL;
2352 if (info->errorcode == ERRCODE_INSERT_BREAK) { 2353 if (info->errorcode == ERRCODE_INSERT_BREAK) {
2353 struct tty_struct *tty = info->tty; 2354 struct tty_struct *tty = info->port.tty;
2354 tty_insert_flip_char(tty, 0, flag); 2355 tty_insert_flip_char(tty, 0, flag);
2355 info->icount.rx++; 2356 info->icount.rx++;
2356 } 2357 }
@@ -2390,13 +2391,13 @@ more_data:
2390 2391
2391 2392
2392 info->icount.rx++; 2393 info->icount.rx++;
2393 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2394 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]);
2394 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) { 2395 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
2395 DEBUG_LOG(info->line, "ser_rx %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read)); 2396 DEBUG_LOG(info->line, "ser_rx %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read));
2396 goto more_data; 2397 goto more_data;
2397 } 2398 }
2398 2399
2399 tty_flip_buffer_push(info->tty); 2400 tty_flip_buffer_push(info->port.tty);
2400 return info; 2401 return info;
2401} 2402}
2402 2403
@@ -2412,7 +2413,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2412 return handle_ser_rx_interrupt_no_dma(info); 2413 return handle_ser_rx_interrupt_no_dma(info);
2413 } 2414 }
2414 /* DMA is used */ 2415 /* DMA is used */
2415 rstat = info->port[REG_STATUS]; 2416 rstat = info->ioport[REG_STATUS];
2416 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { 2417 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
2417 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); 2418 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
2418 } 2419 }
@@ -2425,7 +2426,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2425 /* If we got an error, we must reset it by reading the 2426 /* If we got an error, we must reset it by reading the
2426 * data_in field 2427 * data_in field
2427 */ 2428 */
2428 data = info->port[REG_DATA]; 2429 data = info->ioport[REG_DATA];
2429 DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data)); 2430 DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data));
2430 DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat)); 2431 DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat));
2431 if (!data && (rstat & SER_FRAMING_ERR_MASK)) { 2432 if (!data && (rstat & SER_FRAMING_ERR_MASK)) {
@@ -2527,10 +2528,10 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2527 unsigned char rstat; 2528 unsigned char rstat;
2528 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char)); 2529 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char));
2529 local_irq_save(flags); 2530 local_irq_save(flags);
2530 rstat = info->port[REG_STATUS]; 2531 rstat = info->ioport[REG_STATUS];
2531 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2532 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2532 2533
2533 info->port[REG_TR_DATA] = info->x_char; 2534 info->ioport[REG_TR_DATA] = info->x_char;
2534 info->icount.tx++; 2535 info->icount.tx++;
2535 info->x_char = 0; 2536 info->x_char = 0;
2536 /* We must enable since it is disabled in ser_interrupt */ 2537 /* We must enable since it is disabled in ser_interrupt */
@@ -2544,11 +2545,11 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2544 /* We only use normal tx interrupt when sending x_char */ 2545 /* We only use normal tx interrupt when sending x_char */
2545 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0)); 2546 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0));
2546 local_irq_save(flags); 2547 local_irq_save(flags);
2547 rstat = info->port[REG_STATUS]; 2548 rstat = info->ioport[REG_STATUS];
2548 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2549 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2549 e100_disable_serial_tx_ready_irq(info); 2550 e100_disable_serial_tx_ready_irq(info);
2550 if (info->tty->stopped) 2551 if (info->port.tty->stopped)
2551 rs_stop(info->tty); 2552 rs_stop(info->port.tty);
2552 /* Enable the DMA channel and tell it to continue */ 2553 /* Enable the DMA channel and tell it to continue */
2553 e100_enable_txdma_channel(info); 2554 e100_enable_txdma_channel(info);
2554 /* Wait 12 cycles before doing the DMA command */ 2555 /* Wait 12 cycles before doing the DMA command */
@@ -2561,9 +2562,10 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2561 } 2562 }
2562 /* Normal char-by-char interrupt */ 2563 /* Normal char-by-char interrupt */
2563 if (info->xmit.head == info->xmit.tail 2564 if (info->xmit.head == info->xmit.tail
2564 || info->tty->stopped 2565 || info->port.tty->stopped
2565 || info->tty->hw_stopped) { 2566 || info->port.tty->hw_stopped) {
2566 DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", info->tty->stopped)); 2567 DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n",
2568 info->port.tty->stopped));
2567 e100_disable_serial_tx_ready_irq(info); 2569 e100_disable_serial_tx_ready_irq(info);
2568 info->tr_running = 0; 2570 info->tr_running = 0;
2569 return; 2571 return;
@@ -2571,7 +2573,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2571 DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail])); 2573 DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail]));
2572 /* Send a byte, rs485 timing is critical so turn of ints */ 2574 /* Send a byte, rs485 timing is critical so turn of ints */
2573 local_irq_save(flags); 2575 local_irq_save(flags);
2574 info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail]; 2576 info->ioport[REG_TR_DATA] = info->xmit.buf[info->xmit.tail];
2575 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1); 2577 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
2576 info->icount.tx++; 2578 info->icount.tx++;
2577 if (info->xmit.head == info->xmit.tail) { 2579 if (info->xmit.head == info->xmit.tail) {
@@ -2725,7 +2727,7 @@ do_softint(struct work_struct *work)
2725 2727
2726 info = container_of(work, struct e100_serial, work); 2728 info = container_of(work, struct e100_serial, work);
2727 2729
2728 tty = info->tty; 2730 tty = info->port.tty;
2729 if (!tty) 2731 if (!tty)
2730 return; 2732 return;
2731 2733
@@ -2767,8 +2769,8 @@ startup(struct e100_serial * info)
2767 /* Bits and pieces collected from below. Better to have them 2769 /* Bits and pieces collected from below. Better to have them
2768 in one ifdef:ed clause than to mix in a lot of ifdefs, 2770 in one ifdef:ed clause than to mix in a lot of ifdefs,
2769 right? */ 2771 right? */
2770 if (info->tty) 2772 if (info->port.tty)
2771 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2773 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
2772 2774
2773 info->xmit.head = info->xmit.tail = 0; 2775 info->xmit.head = info->xmit.tail = 0;
2774 info->first_recv_buffer = info->last_recv_buffer = NULL; 2776 info->first_recv_buffer = info->last_recv_buffer = NULL;
@@ -2825,8 +2827,8 @@ startup(struct e100_serial * info)
2825 e100_disable_txdma_channel(info); 2827 e100_disable_txdma_channel(info);
2826 } 2828 }
2827 2829
2828 if (info->tty) 2830 if (info->port.tty)
2829 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2831 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
2830 2832
2831 info->xmit.head = info->xmit.tail = 0; 2833 info->xmit.head = info->xmit.tail = 0;
2832 info->first_recv_buffer = info->last_recv_buffer = NULL; 2834 info->first_recv_buffer = info->last_recv_buffer = NULL;
@@ -2846,7 +2848,7 @@ startup(struct e100_serial * info)
2846 2848
2847 /* dummy read to reset any serial errors */ 2849 /* dummy read to reset any serial errors */
2848 2850
2849 (void)info->port[REG_DATA]; 2851 (void)info->ioport[REG_DATA];
2850 2852
2851 /* enable the interrupts */ 2853 /* enable the interrupts */
2852 if (info->uses_dma_out) 2854 if (info->uses_dma_out)
@@ -2895,7 +2897,7 @@ shutdown(struct e100_serial * info)
2895 /* shut down the transmitter and receiver */ 2897 /* shut down the transmitter and receiver */
2896 DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line)); 2898 DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line));
2897 e100_disable_rx(info); 2899 e100_disable_rx(info);
2898 info->port[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40); 2900 info->ioport[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40);
2899 2901
2900 /* disable interrupts, reset dma channels */ 2902 /* disable interrupts, reset dma channels */
2901 if (info->uses_dma_in) { 2903 if (info->uses_dma_in) {
@@ -2940,14 +2942,14 @@ shutdown(struct e100_serial * info)
2940 descr[i].buf = 0; 2942 descr[i].buf = 0;
2941 } 2943 }
2942 2944
2943 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { 2945 if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) {
2944 /* hang up DTR and RTS if HUPCL is enabled */ 2946 /* hang up DTR and RTS if HUPCL is enabled */
2945 e100_dtr(info, 0); 2947 e100_dtr(info, 0);
2946 e100_rts(info, 0); /* could check CRTSCTS before doing this */ 2948 e100_rts(info, 0); /* could check CRTSCTS before doing this */
2947 } 2949 }
2948 2950
2949 if (info->tty) 2951 if (info->port.tty)
2950 set_bit(TTY_IO_ERROR, &info->tty->flags); 2952 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2951 2953
2952 info->flags &= ~ASYNC_INITIALIZED; 2954 info->flags &= ~ASYNC_INITIALIZED;
2953 local_irq_restore(flags); 2955 local_irq_restore(flags);
@@ -2964,12 +2966,12 @@ change_speed(struct e100_serial *info)
2964 unsigned long flags; 2966 unsigned long flags;
2965 /* first some safety checks */ 2967 /* first some safety checks */
2966 2968
2967 if (!info->tty || !info->tty->termios) 2969 if (!info->port.tty || !info->port.tty->termios)
2968 return; 2970 return;
2969 if (!info->port) 2971 if (!info->ioport)
2970 return; 2972 return;
2971 2973
2972 cflag = info->tty->termios->c_cflag; 2974 cflag = info->port.tty->termios->c_cflag;
2973 2975
2974 /* possibly, the tx/rx should be disabled first to do this safely */ 2976 /* possibly, the tx/rx should be disabled first to do this safely */
2975 2977
@@ -3035,7 +3037,7 @@ change_speed(struct e100_serial *info)
3035 3037
3036 info->baud = cflag_to_baud(cflag); 3038 info->baud = cflag_to_baud(cflag);
3037#ifndef CONFIG_SVINTO_SIM 3039#ifndef CONFIG_SVINTO_SIM
3038 info->port[REG_BAUD] = cflag_to_etrax_baud(cflag); 3040 info->ioport[REG_BAUD] = cflag_to_etrax_baud(cflag);
3039#endif /* CONFIG_SVINTO_SIM */ 3041#endif /* CONFIG_SVINTO_SIM */
3040 } 3042 }
3041 3043
@@ -3095,16 +3097,17 @@ change_speed(struct e100_serial *info)
3095 3097
3096 /* actually write the control regs to the hardware */ 3098 /* actually write the control regs to the hardware */
3097 3099
3098 info->port[REG_TR_CTRL] = info->tx_ctrl; 3100 info->ioport[REG_TR_CTRL] = info->tx_ctrl;
3099 info->port[REG_REC_CTRL] = info->rx_ctrl; 3101 info->ioport[REG_REC_CTRL] = info->rx_ctrl;
3100 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->tty)); 3102 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty));
3101 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable); 3103 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
3102 if (info->tty->termios->c_iflag & IXON ) { 3104 if (info->port.tty->termios->c_iflag & IXON ) {
3103 DFLOW(DEBUG_LOG(info->line, "FLOW XOFF enabled 0x%02X\n", STOP_CHAR(info->tty))); 3105 DFLOW(DEBUG_LOG(info->line, "FLOW XOFF enabled 0x%02X\n",
3106 STOP_CHAR(info->port.tty)));
3104 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 3107 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
3105 } 3108 }
3106 3109
3107 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 3110 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
3108 local_irq_restore(flags); 3111 local_irq_restore(flags);
3109#endif /* !CONFIG_SVINTO_SIM */ 3112#endif /* !CONFIG_SVINTO_SIM */
3110 3113
@@ -3153,7 +3156,7 @@ static int rs_raw_write(struct tty_struct *tty,
3153#ifdef SERIAL_DEBUG_DATA 3156#ifdef SERIAL_DEBUG_DATA
3154 if (info->line == SERIAL_DEBUG_LINE) 3157 if (info->line == SERIAL_DEBUG_LINE)
3155 printk("rs_raw_write (%d), status %d\n", 3158 printk("rs_raw_write (%d), status %d\n",
3156 count, info->port[REG_STATUS]); 3159 count, info->ioport[REG_STATUS]);
3157#endif 3160#endif
3158 3161
3159#ifdef CONFIG_SVINTO_SIM 3162#ifdef CONFIG_SVINTO_SIM
@@ -3424,7 +3427,7 @@ get_serial_info(struct e100_serial * info,
3424 memset(&tmp, 0, sizeof(tmp)); 3427 memset(&tmp, 0, sizeof(tmp));
3425 tmp.type = info->type; 3428 tmp.type = info->type;
3426 tmp.line = info->line; 3429 tmp.line = info->line;
3427 tmp.port = (int)info->port; 3430 tmp.port = (int)info->ioport;
3428 tmp.irq = info->irq; 3431 tmp.irq = info->irq;
3429 tmp.flags = info->flags; 3432 tmp.flags = info->flags;
3430 tmp.baud_base = info->baud_base; 3433 tmp.baud_base = info->baud_base;
@@ -3475,7 +3478,7 @@ set_serial_info(struct e100_serial *info,
3475 info->type = new_serial.type; 3478 info->type = new_serial.type;
3476 info->close_delay = new_serial.close_delay; 3479 info->close_delay = new_serial.close_delay;
3477 info->closing_wait = new_serial.closing_wait; 3480 info->closing_wait = new_serial.closing_wait;
3478 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3481 info->port.tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
3479 3482
3480 check_and_exit: 3483 check_and_exit:
3481 if (info->flags & ASYNC_INITIALIZED) { 3484 if (info->flags & ASYNC_INITIALIZED) {
@@ -3554,14 +3557,14 @@ char *get_control_state_str(int MLines, char *s)
3554} 3557}
3555#endif 3558#endif
3556 3559
3557static void 3560static int
3558rs_break(struct tty_struct *tty, int break_state) 3561rs_break(struct tty_struct *tty, int break_state)
3559{ 3562{
3560 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3563 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3561 unsigned long flags; 3564 unsigned long flags;
3562 3565
3563 if (!info->port) 3566 if (!info->ioport)
3564 return; 3567 return -EIO;
3565 3568
3566 local_irq_save(flags); 3569 local_irq_save(flags);
3567 if (break_state == -1) { 3570 if (break_state == -1) {
@@ -3572,8 +3575,9 @@ rs_break(struct tty_struct *tty, int break_state)
3572 /* Set bit 7 (txd) and 6 (tr_enable) */ 3575 /* Set bit 7 (txd) and 6 (tr_enable) */
3573 info->tx_ctrl |= (0x80 | 0x40); 3576 info->tx_ctrl |= (0x80 | 0x40);
3574 } 3577 }
3575 info->port[REG_TR_CTRL] = info->tx_ctrl; 3578 info->ioport[REG_TR_CTRL] = info->tx_ctrl;
3576 local_irq_restore(flags); 3579 local_irq_restore(flags);
3580 return 0;
3577} 3581}
3578 3582
3579static int 3583static int
@@ -3811,7 +3815,7 @@ rs_close(struct tty_struct *tty, struct file * filp)
3811 tty_ldisc_flush(tty); 3815 tty_ldisc_flush(tty);
3812 tty->closing = 0; 3816 tty->closing = 0;
3813 info->event = 0; 3817 info->event = 0;
3814 info->tty = 0; 3818 info->port.tty = NULL;
3815 if (info->blocked_open) { 3819 if (info->blocked_open) {
3816 if (info->close_delay) 3820 if (info->close_delay)
3817 schedule_timeout_interruptible(info->close_delay); 3821 schedule_timeout_interruptible(info->close_delay);
@@ -3915,7 +3919,7 @@ rs_hangup(struct tty_struct *tty)
3915 info->event = 0; 3919 info->event = 0;
3916 info->count = 0; 3920 info->count = 0;
3917 info->flags &= ~ASYNC_NORMAL_ACTIVE; 3921 info->flags &= ~ASYNC_NORMAL_ACTIVE;
3918 info->tty = 0; 3922 info->port.tty = NULL;
3919 wake_up_interruptible(&info->open_wait); 3923 wake_up_interruptible(&info->open_wait);
3920} 3924}
3921 3925
@@ -4077,9 +4081,9 @@ rs_open(struct tty_struct *tty, struct file * filp)
4077 4081
4078 info->count++; 4082 info->count++;
4079 tty->driver_data = info; 4083 tty->driver_data = info;
4080 info->tty = tty; 4084 info->port.tty = tty;
4081 4085
4082 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 4086 info->port.tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
4083 4087
4084 if (!tmp_buf) { 4088 if (!tmp_buf) {
4085 page = get_zeroed_page(GFP_KERNEL); 4089 page = get_zeroed_page(GFP_KERNEL);
@@ -4228,9 +4232,9 @@ static int line_info(char *buf, struct e100_serial *info)
4228 unsigned long tmp; 4232 unsigned long tmp;
4229 4233
4230 ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d", 4234 ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
4231 info->line, (unsigned long)info->port, info->irq); 4235 info->line, (unsigned long)info->ioport, info->irq);
4232 4236
4233 if (!info->port || (info->type == PORT_UNKNOWN)) { 4237 if (!info->ioport || (info->type == PORT_UNKNOWN)) {
4234 ret += sprintf(buf+ret, "\n"); 4238 ret += sprintf(buf+ret, "\n");
4235 return ret; 4239 return ret;
4236 } 4240 }
@@ -4267,18 +4271,18 @@ static int line_info(char *buf, struct e100_serial *info)
4267 (unsigned long)info->max_recv_cnt); 4271 (unsigned long)info->max_recv_cnt);
4268 4272
4269#if 1 4273#if 1
4270 if (info->tty) { 4274 if (info->port.tty) {
4271 4275
4272 if (info->tty->stopped) 4276 if (info->port.tty->stopped)
4273 ret += sprintf(buf+ret, " stopped:%i", 4277 ret += sprintf(buf+ret, " stopped:%i",
4274 (int)info->tty->stopped); 4278 (int)info->port.tty->stopped);
4275 if (info->tty->hw_stopped) 4279 if (info->port.tty->hw_stopped)
4276 ret += sprintf(buf+ret, " hw_stopped:%i", 4280 ret += sprintf(buf+ret, " hw_stopped:%i",
4277 (int)info->tty->hw_stopped); 4281 (int)info->port.tty->hw_stopped);
4278 } 4282 }
4279 4283
4280 { 4284 {
4281 unsigned char rstat = info->port[REG_STATUS]; 4285 unsigned char rstat = info->ioport[REG_STATUS];
4282 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) 4286 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
4283 ret += sprintf(buf+ret, " xoff_detect:1"); 4287 ret += sprintf(buf+ret, " xoff_detect:1");
4284 } 4288 }
@@ -4465,7 +4469,7 @@ rs_init(void)
4465 info->uses_dma_in = 0; 4469 info->uses_dma_in = 0;
4466 info->uses_dma_out = 0; 4470 info->uses_dma_out = 0;
4467 info->line = i; 4471 info->line = i;
4468 info->tty = 0; 4472 info->port.tty = NULL;
4469 info->type = PORT_ETRAX; 4473 info->type = PORT_ETRAX;
4470 info->tr_running = 0; 4474 info->tr_running = 0;
4471 info->forced_eop = 0; 4475 info->forced_eop = 0;
@@ -4499,7 +4503,7 @@ rs_init(void)
4499 4503
4500 if (info->enabled) { 4504 if (info->enabled) {
4501 printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n", 4505 printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n",
4502 serial_driver->name, info->line, (unsigned int)info->port); 4506 serial_driver->name, info->line, (unsigned int)info->ioport);
4503 } 4507 }
4504 } 4508 }
4505#ifdef CONFIG_ETRAX_FAST_TIMER 4509#ifdef CONFIG_ETRAX_FAST_TIMER
diff --git a/drivers/serial/crisv10.h b/drivers/serial/crisv10.h
index ccd0f32b7372..e3c5c8c3c09b 100644
--- a/drivers/serial/crisv10.h
+++ b/drivers/serial/crisv10.h
@@ -36,8 +36,9 @@ struct etrax_recv_buffer {
36}; 36};
37 37
38struct e100_serial { 38struct e100_serial {
39 struct tty_port port;
39 int baud; 40 int baud;
40 volatile u8 *port; /* R_SERIALx_CTRL */ 41 volatile u8 *ioport; /* R_SERIALx_CTRL */
41 u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */ 42 u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */
42 43
43 /* Output registers */ 44 /* Output registers */
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index 0dddd68b20d2..6042b87797a1 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -197,7 +197,7 @@ static inline void dz_receive_chars(struct dz_mux *mux)
197 while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) { 197 while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) {
198 dport = &mux->dport[LINE(status)]; 198 dport = &mux->dport[LINE(status)];
199 uport = &dport->port; 199 uport = &dport->port;
200 tty = uport->info->tty; /* point to the proper dev */ 200 tty = uport->info->port.tty; /* point to the proper dev */
201 201
202 ch = UCHAR(status); /* grab the char */ 202 ch = UCHAR(status); /* grab the char */
203 flag = TTY_NORMAL; 203 flag = TTY_NORMAL;
@@ -249,7 +249,7 @@ static inline void dz_receive_chars(struct dz_mux *mux)
249 } 249 }
250 for (i = 0; i < DZ_NB_PORT; i++) 250 for (i = 0; i < DZ_NB_PORT; i++)
251 if (lines_rx[i]) 251 if (lines_rx[i])
252 tty_flip_buffer_push(mux->dport[i].port.info->tty); 252 tty_flip_buffer_push(mux->dport[i].port.info->port.tty);
253} 253}
254 254
255/* 255/*
@@ -642,6 +642,26 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
642 spin_unlock_irqrestore(&dport->port.lock, flags); 642 spin_unlock_irqrestore(&dport->port.lock, flags);
643} 643}
644 644
645/*
646 * Hack alert!
647 * Required solely so that the initial PROM-based console
648 * works undisturbed in parallel with this one.
649 */
650static void dz_pm(struct uart_port *uport, unsigned int state,
651 unsigned int oldstate)
652{
653 struct dz_port *dport = to_dport(uport);
654 unsigned long flags;
655
656 spin_lock_irqsave(&dport->port.lock, flags);
657 if (state < 3)
658 dz_start_tx(&dport->port);
659 else
660 dz_stop_tx(&dport->port);
661 spin_unlock_irqrestore(&dport->port.lock, flags);
662}
663
664
645static const char *dz_type(struct uart_port *uport) 665static const char *dz_type(struct uart_port *uport)
646{ 666{
647 return "DZ"; 667 return "DZ";
@@ -738,6 +758,7 @@ static struct uart_ops dz_ops = {
738 .startup = dz_startup, 758 .startup = dz_startup,
739 .shutdown = dz_shutdown, 759 .shutdown = dz_shutdown,
740 .set_termios = dz_set_termios, 760 .set_termios = dz_set_termios,
761 .pm = dz_pm,
741 .type = dz_type, 762 .type = dz_type,
742 .release_port = dz_release_port, 763 .release_port = dz_release_port,
743 .request_port = dz_request_port, 764 .request_port = dz_request_port,
@@ -861,7 +882,10 @@ static int __init dz_console_setup(struct console *co, char *options)
861 if (ret) 882 if (ret)
862 return ret; 883 return ret;
863 884
885 spin_lock_init(&dport->port.lock); /* For dz_pm(). */
886
864 dz_reset(dport); 887 dz_reset(dport);
888 dz_pm(uport, 0, -1);
865 889
866 if (options) 890 if (options)
867 uart_parse_options(options, &baud, &parity, &bits, &flow); 891 uart_parse_options(options, &baud, &parity, &bits, &flow);
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c
index 9c2df5c857cf..2b7531d9f6ab 100644
--- a/drivers/serial/icom.c
+++ b/drivers/serial/icom.c
@@ -730,7 +730,7 @@ static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port)
730static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) 730static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
731{ 731{
732 short int count, rcv_buff; 732 short int count, rcv_buff;
733 struct tty_struct *tty = icom_port->uart_port.info->tty; 733 struct tty_struct *tty = icom_port->uart_port.info->port.tty;
734 unsigned short int status; 734 unsigned short int status;
735 struct uart_icount *icount; 735 struct uart_icount *icount;
736 unsigned long offset; 736 unsigned long offset;
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 64acb39a51ba..6a29f9330a73 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -44,8 +44,8 @@
44 44
45#include <asm/io.h> 45#include <asm/io.h>
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/hardware.h> 47#include <mach/hardware.h>
48#include <asm/arch/imx-uart.h> 48#include <mach/imx-uart.h>
49 49
50/* Register definitions */ 50/* Register definitions */
51#define URXD0 0x0 /* Receiver Register */ 51#define URXD0 0x0 /* Receiver Register */
@@ -372,7 +372,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
372{ 372{
373 struct imx_port *sport = dev_id; 373 struct imx_port *sport = dev_id;
374 unsigned int rx,flg,ignored = 0; 374 unsigned int rx,flg,ignored = 0;
375 struct tty_struct *tty = sport->port.info->tty; 375 struct tty_struct *tty = sport->port.info->port.tty;
376 unsigned long flags, temp; 376 unsigned long flags, temp;
377 377
378 spin_lock_irqsave(&sport->port.lock,flags); 378 spin_lock_irqsave(&sport->port.lock,flags);
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
index 4f1af71e9a1b..6dd98f9fb89c 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/serial/ioc3_serial.c
@@ -905,7 +905,7 @@ static void transmit_chars(struct uart_port *the_port)
905 return; 905 return;
906 906
907 info = the_port->info; 907 info = the_port->info;
908 tty = info->tty; 908 tty = info->port.tty;
909 909
910 if (uart_circ_empty(&info->xmit) || uart_tx_stopped(the_port)) { 910 if (uart_circ_empty(&info->xmit) || uart_tx_stopped(the_port)) {
911 /* Nothing to do or hw stopped */ 911 /* Nothing to do or hw stopped */
@@ -997,14 +997,14 @@ ioc3_change_speed(struct uart_port *the_port,
997 997
998 the_port->ignore_status_mask = N_ALL_INPUT; 998 the_port->ignore_status_mask = N_ALL_INPUT;
999 999
1000 info->tty->low_latency = 1; 1000 info->port.tty->low_latency = 1;
1001 1001
1002 if (I_IGNPAR(info->tty)) 1002 if (I_IGNPAR(info->port.tty))
1003 the_port->ignore_status_mask &= ~(N_PARITY_ERROR 1003 the_port->ignore_status_mask &= ~(N_PARITY_ERROR
1004 | N_FRAMING_ERROR); 1004 | N_FRAMING_ERROR);
1005 if (I_IGNBRK(info->tty)) { 1005 if (I_IGNBRK(info->port.tty)) {
1006 the_port->ignore_status_mask &= ~N_BREAK; 1006 the_port->ignore_status_mask &= ~N_BREAK;
1007 if (I_IGNPAR(info->tty)) 1007 if (I_IGNPAR(info->port.tty))
1008 the_port->ignore_status_mask &= ~N_OVERRUN_ERROR; 1008 the_port->ignore_status_mask &= ~N_OVERRUN_ERROR;
1009 } 1009 }
1010 if (!(cflag & CREAD)) { 1010 if (!(cflag & CREAD)) {
@@ -1399,14 +1399,14 @@ static int receive_chars(struct uart_port *the_port)
1399 /* Make sure all the pointers are "good" ones */ 1399 /* Make sure all the pointers are "good" ones */
1400 if (!info) 1400 if (!info)
1401 return 0; 1401 return 0;
1402 if (!info->tty) 1402 if (!info->port.tty)
1403 return 0; 1403 return 0;
1404 1404
1405 if (!(port->ip_flags & INPUT_ENABLE)) 1405 if (!(port->ip_flags & INPUT_ENABLE))
1406 return 0; 1406 return 0;
1407 1407
1408 spin_lock_irqsave(&the_port->lock, pflags); 1408 spin_lock_irqsave(&the_port->lock, pflags);
1409 tty = info->tty; 1409 tty = info->port.tty;
1410 1410
1411 read_count = do_read(the_port, ch, MAX_CHARS); 1411 read_count = do_read(the_port, ch, MAX_CHARS);
1412 if (read_count > 0) { 1412 if (read_count > 0) {
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 49b8a82b7b9f..6bab63cd5b29 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -1635,7 +1635,7 @@ static void transmit_chars(struct uart_port *the_port)
1635 return; 1635 return;
1636 1636
1637 info = the_port->info; 1637 info = the_port->info;
1638 tty = info->tty; 1638 tty = info->port.tty;
1639 1639
1640 if (uart_circ_empty(&info->xmit) || uart_tx_stopped(the_port)) { 1640 if (uart_circ_empty(&info->xmit) || uart_tx_stopped(the_port)) {
1641 /* Nothing to do or hw stopped */ 1641 /* Nothing to do or hw stopped */
@@ -1738,14 +1738,14 @@ ioc4_change_speed(struct uart_port *the_port,
1738 1738
1739 the_port->ignore_status_mask = N_ALL_INPUT; 1739 the_port->ignore_status_mask = N_ALL_INPUT;
1740 1740
1741 info->tty->low_latency = 1; 1741 info->port.tty->low_latency = 1;
1742 1742
1743 if (I_IGNPAR(info->tty)) 1743 if (I_IGNPAR(info->port.tty))
1744 the_port->ignore_status_mask &= ~(N_PARITY_ERROR 1744 the_port->ignore_status_mask &= ~(N_PARITY_ERROR
1745 | N_FRAMING_ERROR); 1745 | N_FRAMING_ERROR);
1746 if (I_IGNBRK(info->tty)) { 1746 if (I_IGNBRK(info->port.tty)) {
1747 the_port->ignore_status_mask &= ~N_BREAK; 1747 the_port->ignore_status_mask &= ~N_BREAK;
1748 if (I_IGNPAR(info->tty)) 1748 if (I_IGNPAR(info->port.tty))
1749 the_port->ignore_status_mask &= ~N_OVERRUN_ERROR; 1749 the_port->ignore_status_mask &= ~N_OVERRUN_ERROR;
1750 } 1750 }
1751 if (!(cflag & CREAD)) { 1751 if (!(cflag & CREAD)) {
@@ -1801,7 +1801,8 @@ static inline int ic4_startup_local(struct uart_port *the_port)
1801 ioc4_set_proto(port, the_port->mapbase); 1801 ioc4_set_proto(port, the_port->mapbase);
1802 1802
1803 /* set the speed of the serial port */ 1803 /* set the speed of the serial port */
1804 ioc4_change_speed(the_port, info->tty->termios, (struct ktermios *)0); 1804 ioc4_change_speed(the_port, info->port.tty->termios,
1805 (struct ktermios *)0);
1805 1806
1806 return 0; 1807 return 0;
1807} 1808}
@@ -2346,11 +2347,11 @@ static void receive_chars(struct uart_port *the_port)
2346 /* Make sure all the pointers are "good" ones */ 2347 /* Make sure all the pointers are "good" ones */
2347 if (!info) 2348 if (!info)
2348 return; 2349 return;
2349 if (!info->tty) 2350 if (!info->port.tty)
2350 return; 2351 return;
2351 2352
2352 spin_lock_irqsave(&the_port->lock, pflags); 2353 spin_lock_irqsave(&the_port->lock, pflags);
2353 tty = info->tty; 2354 tty = info->port.tty;
2354 2355
2355 request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS); 2356 request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS);
2356 2357
@@ -2440,8 +2441,8 @@ static void ic4_shutdown(struct uart_port *the_port)
2440 2441
2441 wake_up_interruptible(&info->delta_msr_wait); 2442 wake_up_interruptible(&info->delta_msr_wait);
2442 2443
2443 if (info->tty) 2444 if (info->port.tty)
2444 set_bit(TTY_IO_ERROR, &info->tty->flags); 2445 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2445 2446
2446 spin_lock_irqsave(&the_port->lock, port_flags); 2447 spin_lock_irqsave(&the_port->lock, port_flags);
2447 set_notification(port, N_ALL, 0); 2448 set_notification(port, N_ALL, 0);
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 9c95bc0398ad..0d9acbd0bb70 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -257,8 +257,8 @@ static struct tty_struct *ip22zilog_receive_chars(struct uart_ip22zilog_port *up
257 257
258 tty = NULL; 258 tty = NULL;
259 if (up->port.info != NULL && 259 if (up->port.info != NULL &&
260 up->port.info->tty != NULL) 260 up->port.info->port.tty != NULL)
261 tty = up->port.info->tty; 261 tty = up->port.info->port.tty;
262 262
263 for (;;) { 263 for (;;) {
264 ch = readb(&channel->control); 264 ch = readb(&channel->control);
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index b2d6f5b1a7c2..b7584ca55ade 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -998,7 +998,7 @@ static void neo_param(struct jsm_channel *ch)
998 { 50, B50 }, 998 { 50, B50 },
999 }; 999 };
1000 1000
1001 cflag = C_BAUD(ch->uart_port.info->tty); 1001 cflag = C_BAUD(ch->uart_port.info->port.tty);
1002 baud = 9600; 1002 baud = 9600;
1003 for (i = 0; i < ARRAY_SIZE(baud_rates); i++) { 1003 for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
1004 if (baud_rates[i].cflag == cflag) { 1004 if (baud_rates[i].cflag == cflag) {
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 94ec66372508..a697914ae3d0 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -145,7 +145,7 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)
145 struct ktermios *termios; 145 struct ktermios *termios;
146 146
147 spin_lock_irqsave(&port->lock, lock_flags); 147 spin_lock_irqsave(&port->lock, lock_flags);
148 termios = port->info->tty->termios; 148 termios = port->info->port.tty->termios;
149 if (ch == termios->c_cc[VSTART]) 149 if (ch == termios->c_cc[VSTART])
150 channel->ch_bd->bd_ops->send_start_character(channel); 150 channel->ch_bd->bd_ops->send_start_character(channel);
151 151
@@ -239,7 +239,7 @@ static int jsm_tty_open(struct uart_port *port)
239 channel->ch_cached_lsr = 0; 239 channel->ch_cached_lsr = 0;
240 channel->ch_stops_sent = 0; 240 channel->ch_stops_sent = 0;
241 241
242 termios = port->info->tty->termios; 242 termios = port->info->port.tty->termios;
243 channel->ch_c_cflag = termios->c_cflag; 243 channel->ch_c_cflag = termios->c_cflag;
244 channel->ch_c_iflag = termios->c_iflag; 244 channel->ch_c_iflag = termios->c_iflag;
245 channel->ch_c_oflag = termios->c_oflag; 245 channel->ch_c_oflag = termios->c_oflag;
@@ -272,7 +272,7 @@ static void jsm_tty_close(struct uart_port *port)
272 jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n"); 272 jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n");
273 273
274 bd = channel->ch_bd; 274 bd = channel->ch_bd;
275 ts = channel->uart_port.info->tty->termios; 275 ts = channel->uart_port.info->port.tty->termios;
276 276
277 channel->ch_flags &= ~(CH_STOPI); 277 channel->ch_flags &= ~(CH_STOPI);
278 278
@@ -515,7 +515,7 @@ void jsm_input(struct jsm_channel *ch)
515 if (!ch) 515 if (!ch)
516 return; 516 return;
517 517
518 tp = ch->uart_port.info->tty; 518 tp = ch->uart_port.info->port.tty;
519 519
520 bd = ch->ch_bd; 520 bd = ch->ch_bd;
521 if(!bd) 521 if(!bd)
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c
index c2bb11c02bde..23d030511019 100644
--- a/drivers/serial/m32r_sio.c
+++ b/drivers/serial/m32r_sio.c
@@ -325,7 +325,7 @@ static void m32r_sio_enable_ms(struct uart_port *port)
325 325
326static void receive_chars(struct uart_sio_port *up, int *status) 326static void receive_chars(struct uart_sio_port *up, int *status)
327{ 327{
328 struct tty_struct *tty = up->port.info->tty; 328 struct tty_struct *tty = up->port.info->port.tty;
329 unsigned char ch; 329 unsigned char ch;
330 unsigned char flag; 330 unsigned char flag;
331 int max_count = 256; 331 int max_count = 256;
@@ -1160,7 +1160,7 @@ static int __init m32r_sio_init(void)
1160{ 1160{
1161 int ret, i; 1161 int ret, i;
1162 1162
1163 printk(KERN_INFO "Serial: M32R SIO driver $Revision: 1.11 $ "); 1163 printk(KERN_INFO "Serial: M32R SIO driver\n");
1164 1164
1165 for (i = 0; i < NR_IRQS; i++) 1165 for (i = 0; i < NR_IRQS; i++)
1166 spin_lock_init(&irq_lists[i].lock); 1166 spin_lock_init(&irq_lists[i].lock);
@@ -1189,4 +1189,4 @@ EXPORT_SYMBOL(m32r_sio_suspend_port);
1189EXPORT_SYMBOL(m32r_sio_resume_port); 1189EXPORT_SYMBOL(m32r_sio_resume_port);
1190 1190
1191MODULE_LICENSE("GPL"); 1191MODULE_LICENSE("GPL");
1192MODULE_DESCRIPTION("Generic M32R SIO serial driver $Revision: 1.11 $"); 1192MODULE_DESCRIPTION("Generic M32R SIO serial driver");
diff --git a/drivers/serial/mcf.c b/drivers/serial/mcf.c
index 7e164e0cd211..b2001c5b145c 100644
--- a/drivers/serial/mcf.c
+++ b/drivers/serial/mcf.c
@@ -312,7 +312,7 @@ static void mcf_rx_chars(struct mcf_uart *pp)
312 uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); 312 uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag);
313 } 313 }
314 314
315 tty_flip_buffer_push(port->info->tty); 315 tty_flip_buffer_push(port->info->port.tty);
316} 316}
317 317
318/****************************************************************************/ 318/****************************************************************************/
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 56007cc8a9b3..fbe3835f6b77 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -327,7 +327,7 @@ static void mcfrs_start(struct tty_struct *tty)
327static inline void receive_chars(struct mcf_serial *info) 327static inline void receive_chars(struct mcf_serial *info)
328{ 328{
329 volatile unsigned char *uartp; 329 volatile unsigned char *uartp;
330 struct tty_struct *tty = info->tty; 330 struct tty_struct *tty = info->port.tty;
331 unsigned char status, ch, flag; 331 unsigned char status, ch, flag;
332 332
333 if (!tty) 333 if (!tty)
@@ -382,7 +382,7 @@ static inline void transmit_chars(struct mcf_serial *info)
382 info->stats.tx++; 382 info->stats.tx++;
383 } 383 }
384 384
385 if ((info->xmit_cnt <= 0) || info->tty->stopped) { 385 if ((info->xmit_cnt <= 0) || info->port.tty->stopped) {
386 info->imr &= ~MCFUART_UIR_TXREADY; 386 info->imr &= ~MCFUART_UIR_TXREADY;
387 uartp[MCFUART_UIMR] = info->imr; 387 uartp[MCFUART_UIMR] = info->imr;
388 return; 388 return;
@@ -428,7 +428,7 @@ irqreturn_t mcfrs_interrupt(int irq, void *dev_id)
428static void mcfrs_offintr(struct work_struct *work) 428static void mcfrs_offintr(struct work_struct *work)
429{ 429{
430 struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue); 430 struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue);
431 struct tty_struct *tty = info->tty; 431 struct tty_struct *tty = info->port.tty;
432 432
433 if (tty) 433 if (tty)
434 tty_wakeup(tty); 434 tty_wakeup(tty);
@@ -498,7 +498,7 @@ static void mcfrs_timer(void)
498static void do_serial_hangup(struct work_struct *work) 498static void do_serial_hangup(struct work_struct *work)
499{ 499{
500 struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue_hangup); 500 struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue_hangup);
501 struct tty_struct *tty = info->tty; 501 struct tty_struct *tty = info->port.tty;
502 502
503 if (tty) 503 if (tty)
504 tty_hangup(tty); 504 tty_hangup(tty);
@@ -532,8 +532,8 @@ static int startup(struct mcf_serial * info)
532 uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */ 532 uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */
533 mcfrs_setsignals(info, 1, 1); 533 mcfrs_setsignals(info, 1, 1);
534 534
535 if (info->tty) 535 if (info->port.tty)
536 clear_bit(TTY_IO_ERROR, &info->tty->flags); 536 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
537 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 537 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
538 538
539 /* 539 /*
@@ -578,7 +578,7 @@ static void shutdown(struct mcf_serial * info)
578 uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */ 578 uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */
579 uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */ 579 uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */
580 580
581 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) 581 if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL))
582 mcfrs_setsignals(info, 0, 0); 582 mcfrs_setsignals(info, 0, 0);
583 583
584 if (info->xmit_buf) { 584 if (info->xmit_buf) {
@@ -586,8 +586,8 @@ static void shutdown(struct mcf_serial * info)
586 info->xmit_buf = 0; 586 info->xmit_buf = 0;
587 } 587 }
588 588
589 if (info->tty) 589 if (info->port.tty)
590 set_bit(TTY_IO_ERROR, &info->tty->flags); 590 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
591 591
592 info->flags &= ~ASYNC_INITIALIZED; 592 info->flags &= ~ASYNC_INITIALIZED;
593 local_irq_restore(flags); 593 local_irq_restore(flags);
@@ -609,9 +609,9 @@ static void mcfrs_change_speed(struct mcf_serial *info)
609 unsigned int fraction; 609 unsigned int fraction;
610#endif 610#endif
611 611
612 if (!info->tty || !info->tty->termios) 612 if (!info->port.tty || !info->port.tty->termios)
613 return; 613 return;
614 cflag = info->tty->termios->c_cflag; 614 cflag = info->port.tty->termios->c_cflag;
615 if (info->addr == 0) 615 if (info->addr == 0)
616 return; 616 return;
617 617
@@ -623,7 +623,7 @@ static void mcfrs_change_speed(struct mcf_serial *info)
623 if (i & CBAUDEX) { 623 if (i & CBAUDEX) {
624 i &= ~CBAUDEX; 624 i &= ~CBAUDEX;
625 if (i < 1 || i > 4) 625 if (i < 1 || i > 4)
626 info->tty->termios->c_cflag &= ~CBAUDEX; 626 info->port.tty->termios->c_cflag &= ~CBAUDEX;
627 else 627 else
628 i += 15; 628 i += 15;
629 } 629 }
@@ -1216,7 +1216,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp)
1216 1216
1217 tty->closing = 0; 1217 tty->closing = 0;
1218 info->event = 0; 1218 info->event = 0;
1219 info->tty = 0; 1219 info->port.tty = NULL;
1220#if 0 1220#if 0
1221 if (tty->ldisc.num != ldiscs[N_TTY].num) { 1221 if (tty->ldisc.num != ldiscs[N_TTY].num) {
1222 if (tty->ldisc.close) 1222 if (tty->ldisc.close)
@@ -1325,7 +1325,7 @@ void mcfrs_hangup(struct tty_struct *tty)
1325 info->event = 0; 1325 info->event = 0;
1326 info->count = 0; 1326 info->count = 0;
1327 info->flags &= ~ASYNC_NORMAL_ACTIVE; 1327 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1328 info->tty = 0; 1328 info->port.tty = NULL;
1329 wake_up_interruptible(&info->open_wait); 1329 wake_up_interruptible(&info->open_wait);
1330} 1330}
1331 1331
@@ -1452,7 +1452,7 @@ int mcfrs_open(struct tty_struct *tty, struct file * filp)
1452#endif 1452#endif
1453 info->count++; 1453 info->count++;
1454 tty->driver_data = info; 1454 tty->driver_data = info;
1455 info->tty = tty; 1455 info->port.tty = tty;
1456 1456
1457 /* 1457 /*
1458 * Start up serial port 1458 * Start up serial port
@@ -1767,7 +1767,7 @@ mcfrs_init(void)
1767 for (i = 0, info = mcfrs_table; (i < NR_PORTS); i++, info++) { 1767 for (i = 0, info = mcfrs_table; (i < NR_PORTS); i++, info++) {
1768 info->magic = SERIAL_MAGIC; 1768 info->magic = SERIAL_MAGIC;
1769 info->line = i; 1769 info->line = i;
1770 info->tty = 0; 1770 info->port.tty = NULL;
1771 info->custom_divisor = 16; 1771 info->custom_divisor = 16;
1772 info->close_delay = 50; 1772 info->close_delay = 50;
1773 info->closing_wait = 3000; 1773 info->closing_wait = 3000;
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index efc971d9647b..36126070d9af 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -732,7 +732,7 @@ static struct uart_ops mpc52xx_uart_ops = {
732static inline int 732static inline int
733mpc52xx_uart_int_rx_chars(struct uart_port *port) 733mpc52xx_uart_int_rx_chars(struct uart_port *port)
734{ 734{
735 struct tty_struct *tty = port->info->tty; 735 struct tty_struct *tty = port->info->port.tty;
736 unsigned char ch, flag; 736 unsigned char ch, flag;
737 unsigned short status; 737 unsigned short status;
738 738
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index e8819c43f57d..61d3ade5286c 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -921,6 +921,10 @@ static int mpsc_make_ready(struct mpsc_port_info *pi)
921 return 0; 921 return 0;
922} 922}
923 923
924#ifdef CONFIG_CONSOLE_POLL
925static int serial_polled;
926#endif
927
924/* 928/*
925 ****************************************************************************** 929 ******************************************************************************
926 * 930 *
@@ -932,7 +936,7 @@ static int mpsc_make_ready(struct mpsc_port_info *pi)
932static int mpsc_rx_intr(struct mpsc_port_info *pi) 936static int mpsc_rx_intr(struct mpsc_port_info *pi)
933{ 937{
934 struct mpsc_rx_desc *rxre; 938 struct mpsc_rx_desc *rxre;
935 struct tty_struct *tty = pi->port.info->tty; 939 struct tty_struct *tty = pi->port.info->port.tty;
936 u32 cmdstat, bytes_in, i; 940 u32 cmdstat, bytes_in, i;
937 int rc = 0; 941 int rc = 0;
938 u8 *bp; 942 u8 *bp;
@@ -956,7 +960,12 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi)
956 while (!((cmdstat = be32_to_cpu(rxre->cmdstat)) 960 while (!((cmdstat = be32_to_cpu(rxre->cmdstat))
957 & SDMA_DESC_CMDSTAT_O)) { 961 & SDMA_DESC_CMDSTAT_O)) {
958 bytes_in = be16_to_cpu(rxre->bytecnt); 962 bytes_in = be16_to_cpu(rxre->bytecnt);
959 963#ifdef CONFIG_CONSOLE_POLL
964 if (unlikely(serial_polled)) {
965 serial_polled = 0;
966 return 0;
967 }
968#endif
960 /* Following use of tty struct directly is deprecated */ 969 /* Following use of tty struct directly is deprecated */
961 if (unlikely(tty_buffer_request_room(tty, bytes_in) 970 if (unlikely(tty_buffer_request_room(tty, bytes_in)
962 < bytes_in)) { 971 < bytes_in)) {
@@ -1017,6 +1026,12 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi)
1017 if (uart_handle_sysrq_char(&pi->port, *bp)) { 1026 if (uart_handle_sysrq_char(&pi->port, *bp)) {
1018 bp++; 1027 bp++;
1019 bytes_in--; 1028 bytes_in--;
1029#ifdef CONFIG_CONSOLE_POLL
1030 if (unlikely(serial_polled)) {
1031 serial_polled = 0;
1032 return 0;
1033 }
1034#endif
1020 goto next_frame; 1035 goto next_frame;
1021 } 1036 }
1022 1037
@@ -1519,6 +1534,133 @@ static int mpsc_verify_port(struct uart_port *port, struct serial_struct *ser)
1519 1534
1520 return rc; 1535 return rc;
1521} 1536}
1537#ifdef CONFIG_CONSOLE_POLL
1538/* Serial polling routines for writing and reading from the uart while
1539 * in an interrupt or debug context.
1540 */
1541
1542static char poll_buf[2048];
1543static int poll_ptr;
1544static int poll_cnt;
1545static void mpsc_put_poll_char(struct uart_port *port,
1546 unsigned char c);
1547
1548static int mpsc_get_poll_char(struct uart_port *port)
1549{
1550 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1551 struct mpsc_rx_desc *rxre;
1552 u32 cmdstat, bytes_in, i;
1553 u8 *bp;
1554
1555 if (!serial_polled)
1556 serial_polled = 1;
1557
1558 pr_debug("mpsc_rx_intr[%d]: Handling Rx intr\n", pi->port.line);
1559
1560 if (poll_cnt) {
1561 poll_cnt--;
1562 return poll_buf[poll_ptr++];
1563 }
1564 poll_ptr = 0;
1565 poll_cnt = 0;
1566
1567 while (poll_cnt == 0) {
1568 rxre = (struct mpsc_rx_desc *)(pi->rxr +
1569 (pi->rxr_posn*MPSC_RXRE_SIZE));
1570 dma_cache_sync(pi->port.dev, (void *)rxre,
1571 MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1572#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1573 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1574 invalidate_dcache_range((ulong)rxre,
1575 (ulong)rxre + MPSC_RXRE_SIZE);
1576#endif
1577 /*
1578 * Loop through Rx descriptors handling ones that have
1579 * been completed.
1580 */
1581 while (poll_cnt == 0 &&
1582 !((cmdstat = be32_to_cpu(rxre->cmdstat)) &
1583 SDMA_DESC_CMDSTAT_O)){
1584 bytes_in = be16_to_cpu(rxre->bytecnt);
1585 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE);
1586 dma_cache_sync(pi->port.dev, (void *) bp,
1587 MPSC_RXBE_SIZE, DMA_FROM_DEVICE);
1588#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1589 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1590 invalidate_dcache_range((ulong)bp,
1591 (ulong)bp + MPSC_RXBE_SIZE);
1592#endif
1593 if ((unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR |
1594 SDMA_DESC_CMDSTAT_FR | SDMA_DESC_CMDSTAT_OR))) &&
1595 !(cmdstat & pi->port.ignore_status_mask)) {
1596 poll_buf[poll_cnt] = *bp;
1597 poll_cnt++;
1598 } else {
1599 for (i = 0; i < bytes_in; i++) {
1600 poll_buf[poll_cnt] = *bp++;
1601 poll_cnt++;
1602 }
1603 pi->port.icount.rx += bytes_in;
1604 }
1605 rxre->bytecnt = cpu_to_be16(0);
1606 wmb();
1607 rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O |
1608 SDMA_DESC_CMDSTAT_EI |
1609 SDMA_DESC_CMDSTAT_F |
1610 SDMA_DESC_CMDSTAT_L);
1611 wmb();
1612 dma_cache_sync(pi->port.dev, (void *)rxre,
1613 MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL);
1614#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1615 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1616 flush_dcache_range((ulong)rxre,
1617 (ulong)rxre + MPSC_RXRE_SIZE);
1618#endif
1619
1620 /* Advance to next descriptor */
1621 pi->rxr_posn = (pi->rxr_posn + 1) &
1622 (MPSC_RXR_ENTRIES - 1);
1623 rxre = (struct mpsc_rx_desc *)(pi->rxr +
1624 (pi->rxr_posn * MPSC_RXRE_SIZE));
1625 dma_cache_sync(pi->port.dev, (void *)rxre,
1626 MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1627#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1628 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1629 invalidate_dcache_range((ulong)rxre,
1630 (ulong)rxre + MPSC_RXRE_SIZE);
1631#endif
1632 }
1633
1634 /* Restart rx engine, if its stopped */
1635 if ((readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_ERD) == 0)
1636 mpsc_start_rx(pi);
1637 }
1638 if (poll_cnt) {
1639 poll_cnt--;
1640 return poll_buf[poll_ptr++];
1641 }
1642
1643 return 0;
1644}
1645
1646
1647static void mpsc_put_poll_char(struct uart_port *port,
1648 unsigned char c)
1649{
1650 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1651 u32 data;
1652
1653 data = readl(pi->mpsc_base + MPSC_MPCR);
1654 writeb(c, pi->mpsc_base + MPSC_CHR_1);
1655 mb();
1656 data = readl(pi->mpsc_base + MPSC_CHR_2);
1657 data |= MPSC_CHR_2_TTCS;
1658 writel(data, pi->mpsc_base + MPSC_CHR_2);
1659 mb();
1660
1661 while (readl(pi->mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_TTCS);
1662}
1663#endif
1522 1664
1523static struct uart_ops mpsc_pops = { 1665static struct uart_ops mpsc_pops = {
1524 .tx_empty = mpsc_tx_empty, 1666 .tx_empty = mpsc_tx_empty,
@@ -1537,6 +1679,10 @@ static struct uart_ops mpsc_pops = {
1537 .request_port = mpsc_request_port, 1679 .request_port = mpsc_request_port,
1538 .config_port = mpsc_config_port, 1680 .config_port = mpsc_config_port,
1539 .verify_port = mpsc_verify_port, 1681 .verify_port = mpsc_verify_port,
1682#ifdef CONFIG_CONSOLE_POLL
1683 .poll_get_char = mpsc_get_poll_char,
1684 .poll_put_char = mpsc_put_poll_char,
1685#endif
1540}; 1686};
1541 1687
1542/* 1688/*
@@ -1972,7 +2118,7 @@ static int __init mpsc_drv_init(void)
1972{ 2118{
1973 int rc; 2119 int rc;
1974 2120
1975 printk(KERN_INFO "Serial: MPSC driver $Revision: 1.00 $\n"); 2121 printk(KERN_INFO "Serial: MPSC driver\n");
1976 2122
1977 memset(mpsc_ports, 0, sizeof(mpsc_ports)); 2123 memset(mpsc_ports, 0, sizeof(mpsc_ports));
1978 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs)); 2124 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs));
@@ -2004,7 +2150,7 @@ module_init(mpsc_drv_init);
2004module_exit(mpsc_drv_exit); 2150module_exit(mpsc_drv_exit);
2005 2151
2006MODULE_AUTHOR("Mark A. Greer <mgreer@mvista.com>"); 2152MODULE_AUTHOR("Mark A. Greer <mgreer@mvista.com>");
2007MODULE_DESCRIPTION("Generic Marvell MPSC serial/UART driver $Revision: 1.00 $"); 2153MODULE_DESCRIPTION("Generic Marvell MPSC serial/UART driver");
2008MODULE_VERSION(MPSC_VERSION); 2154MODULE_VERSION(MPSC_VERSION);
2009MODULE_LICENSE("GPL"); 2155MODULE_LICENSE("GPL");
2010MODULE_ALIAS_CHARDEV_MAJOR(MPSC_MAJOR); 2156MODULE_ALIAS_CHARDEV_MAJOR(MPSC_MAJOR);
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c
index e94031731a47..953a5ffa9b44 100644
--- a/drivers/serial/mux.c
+++ b/drivers/serial/mux.c
@@ -243,7 +243,7 @@ static void mux_write(struct uart_port *port)
243static void mux_read(struct uart_port *port) 243static void mux_read(struct uart_port *port)
244{ 244{
245 int data; 245 int data;
246 struct tty_struct *tty = port->info->tty; 246 struct tty_struct *tty = port->info->port.tty;
247 __u32 start_count = port->icount.rx; 247 __u32 start_count = port->icount.rx;
248 248
249 while(1) { 249 while(1) {
diff --git a/drivers/serial/netx-serial.c b/drivers/serial/netx-serial.c
index 81ac9bb4f39b..3f489329e8d3 100644
--- a/drivers/serial/netx-serial.c
+++ b/drivers/serial/netx-serial.c
@@ -35,8 +35,8 @@
35 35
36#include <asm/io.h> 36#include <asm/io.h>
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/hardware.h> 38#include <mach/hardware.h>
39#include <asm/arch/netx-regs.h> 39#include <mach/netx-regs.h>
40 40
41/* We've been assigned a range on the "Low-density serial ports" major */ 41/* We've been assigned a range on the "Low-density serial ports" major */
42#define SERIAL_NX_MAJOR 204 42#define SERIAL_NX_MAJOR 204
@@ -203,7 +203,7 @@ static void netx_txint(struct uart_port *port)
203static void netx_rxint(struct uart_port *port) 203static void netx_rxint(struct uart_port *port)
204{ 204{
205 unsigned char rx, flg, status; 205 unsigned char rx, flg, status;
206 struct tty_struct *tty = port->info->tty; 206 struct tty_struct *tty = port->info->port.tty;
207 207
208 while (!(readl(port->membase + UART_FR) & FR_RXFE)) { 208 while (!(readl(port->membase + UART_FR) & FR_RXFE)) {
209 rx = readl(port->membase + UART_DR); 209 rx = readl(port->membase + UART_DR);
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index 25029c7570b6..8fa0ff561e9f 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -13,8 +13,8 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/serial_core.h> 14#include <linux/serial_core.h>
15#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
16#include <linux/of_platform.h>
16 17
17#include <asm/of_platform.h>
18#include <asm/prom.h> 18#include <asm/prom.h>
19 19
20struct of_serial_info { 20struct of_serial_info {
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 794bd0f50d73..317b061f7641 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -242,12 +242,12 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
242 } 242 }
243 243
244 /* Sanity check, make sure the old bug is no longer happening */ 244 /* Sanity check, make sure the old bug is no longer happening */
245 if (uap->port.info == NULL || uap->port.info->tty == NULL) { 245 if (uap->port.info == NULL || uap->port.info->port.tty == NULL) {
246 WARN_ON(1); 246 WARN_ON(1);
247 (void)read_zsdata(uap); 247 (void)read_zsdata(uap);
248 return NULL; 248 return NULL;
249 } 249 }
250 tty = uap->port.info->tty; 250 tty = uap->port.info->port.tty;
251 251
252 while (1) { 252 while (1) {
253 error = 0; 253 error = 0;
diff --git a/drivers/serial/pnx8xxx_uart.c b/drivers/serial/pnx8xxx_uart.c
index d0e5a79ea635..22e30d21225e 100644
--- a/drivers/serial/pnx8xxx_uart.c
+++ b/drivers/serial/pnx8xxx_uart.c
@@ -181,7 +181,7 @@ static void pnx8xxx_enable_ms(struct uart_port *port)
181 181
182static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) 182static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
183{ 183{
184 struct tty_struct *tty = sport->port.info->tty; 184 struct tty_struct *tty = sport->port.info->port.tty;
185 unsigned int status, ch, flg; 185 unsigned int status, ch, flg;
186 186
187 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | 187 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) |
@@ -824,7 +824,7 @@ static int __init pnx8xxx_serial_init(void)
824{ 824{
825 int ret; 825 int ret;
826 826
827 printk(KERN_INFO "Serial: PNX8XXX driver $Revision: 1.2 $\n"); 827 printk(KERN_INFO "Serial: PNX8XXX driver\n");
828 828
829 pnx8xxx_init_ports(); 829 pnx8xxx_init_ports();
830 830
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index b4f7ffb7688d..f7a0d37c4221 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -45,9 +45,9 @@
45#include <linux/clk.h> 45#include <linux/clk.h>
46 46
47#include <asm/io.h> 47#include <asm/io.h>
48#include <asm/hardware.h> 48#include <mach/hardware.h>
49#include <asm/irq.h> 49#include <asm/irq.h>
50#include <asm/arch/pxa-regs.h> 50#include <mach/pxa-regs.h>
51 51
52 52
53struct uart_pxa_port { 53struct uart_pxa_port {
@@ -101,7 +101,7 @@ static void serial_pxa_stop_rx(struct uart_port *port)
101 101
102static inline void receive_chars(struct uart_pxa_port *up, int *status) 102static inline void receive_chars(struct uart_pxa_port *up, int *status)
103{ 103{
104 struct tty_struct *tty = up->port.info->tty; 104 struct tty_struct *tty = up->port.info->port.tty;
105 unsigned int ch, flag; 105 unsigned int ch, flag;
106 int max_count = 256; 106 int max_count = 256;
107 107
diff --git a/drivers/serial/s3c2400.c b/drivers/serial/s3c2400.c
index a1102053e553..c8b4266ac35f 100644
--- a/drivers/serial/s3c2400.c
+++ b/drivers/serial/s3c2400.c
@@ -17,10 +17,10 @@
17 17
18#include <asm/irq.h> 18#include <asm/irq.h>
19 19
20#include <asm/hardware.h> 20#include <mach/hardware.h>
21 21
22#include <asm/plat-s3c/regs-serial.h> 22#include <asm/plat-s3c/regs-serial.h>
23#include <asm/arch/regs-gpio.h> 23#include <mach/regs-gpio.h>
24 24
25#include "samsung.h" 25#include "samsung.h"
26 26
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index c5f03f41686f..40a2531b5541 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -19,10 +19,10 @@
19#include <linux/serial.h> 19#include <linux/serial.h>
20 20
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/hardware.h> 22#include <mach/hardware.h>
23 23
24#include <asm/plat-s3c/regs-serial.h> 24#include <asm/plat-s3c/regs-serial.h>
25#include <asm/arch/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include "samsung.h" 27#include "samsung.h"
28 28
diff --git a/drivers/serial/s3c2412.c b/drivers/serial/s3c2412.c
index ce0c220e3e92..d0170319c729 100644
--- a/drivers/serial/s3c2412.c
+++ b/drivers/serial/s3c2412.c
@@ -19,10 +19,10 @@
19#include <linux/serial.h> 19#include <linux/serial.h>
20 20
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/hardware.h> 22#include <mach/hardware.h>
23 23
24#include <asm/plat-s3c/regs-serial.h> 24#include <asm/plat-s3c/regs-serial.h>
25#include <asm/arch/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include "samsung.h" 27#include "samsung.h"
28 28
diff --git a/drivers/serial/s3c2440.c b/drivers/serial/s3c2440.c
index 38f954bd39c6..d4a2b17b2498 100644
--- a/drivers/serial/s3c2440.c
+++ b/drivers/serial/s3c2440.c
@@ -19,10 +19,10 @@
19#include <linux/serial.h> 19#include <linux/serial.h>
20 20
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/hardware.h> 22#include <mach/hardware.h>
23 23
24#include <asm/plat-s3c/regs-serial.h> 24#include <asm/plat-s3c/regs-serial.h>
25#include <asm/arch/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include "samsung.h" 27#include "samsung.h"
28 28
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 62b38582f5e9..b24a25ea6bc5 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -20,9 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * $Id: sa1100.c,v 1.50 2002/07/29 14:41:04 rmk Exp $
25 *
26 */ 23 */
27 24
28#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 25#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -42,7 +39,7 @@
42 39
43#include <asm/io.h> 40#include <asm/io.h>
44#include <asm/irq.h> 41#include <asm/irq.h>
45#include <asm/hardware.h> 42#include <mach/hardware.h>
46#include <asm/mach/serial_sa1100.h> 43#include <asm/mach/serial_sa1100.h>
47 44
48/* We've been assigned a range on the "Low-density serial ports" major */ 45/* We've been assigned a range on the "Low-density serial ports" major */
@@ -192,7 +189,7 @@ static void sa1100_enable_ms(struct uart_port *port)
192static void 189static void
193sa1100_rx_chars(struct sa1100_port *sport) 190sa1100_rx_chars(struct sa1100_port *sport)
194{ 191{
195 struct tty_struct *tty = sport->port.info->tty; 192 struct tty_struct *tty = sport->port.info->port.tty;
196 unsigned int status, ch, flg; 193 unsigned int status, ch, flg;
197 194
198 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 195 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
@@ -892,7 +889,7 @@ static int __init sa1100_serial_init(void)
892{ 889{
893 int ret; 890 int ret;
894 891
895 printk(KERN_INFO "Serial: SA11x0 driver $Revision: 1.50 $\n"); 892 printk(KERN_INFO "Serial: SA11x0 driver\n");
896 893
897 sa1100_init_ports(); 894 sa1100_init_ports();
898 895
@@ -915,7 +912,7 @@ module_init(sa1100_serial_init);
915module_exit(sa1100_serial_exit); 912module_exit(sa1100_serial_exit);
916 913
917MODULE_AUTHOR("Deep Blue Solutions Ltd"); 914MODULE_AUTHOR("Deep Blue Solutions Ltd");
918MODULE_DESCRIPTION("SA1100 generic serial port driver $Revision: 1.50 $"); 915MODULE_DESCRIPTION("SA1100 generic serial port driver");
919MODULE_LICENSE("GPL"); 916MODULE_LICENSE("GPL");
920MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_SA1100_MAJOR); 917MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_SA1100_MAJOR);
921MODULE_ALIAS("platform:sa11x0-uart"); 918MODULE_ALIAS("platform:sa11x0-uart");
diff --git a/drivers/serial/samsung.c b/drivers/serial/samsung.c
index 4a3ecaa629e6..5a88b3f9fe9b 100644
--- a/drivers/serial/samsung.c
+++ b/drivers/serial/samsung.c
@@ -45,10 +45,10 @@
45 45
46#include <asm/irq.h> 46#include <asm/irq.h>
47 47
48#include <asm/hardware.h> 48#include <mach/hardware.h>
49 49
50#include <asm/plat-s3c/regs-serial.h> 50#include <asm/plat-s3c/regs-serial.h>
51#include <asm/arch/regs-gpio.h> 51#include <mach/regs-gpio.h>
52 52
53#include "samsung.h" 53#include "samsung.h"
54 54
@@ -202,7 +202,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id)
202{ 202{
203 struct s3c24xx_uart_port *ourport = dev_id; 203 struct s3c24xx_uart_port *ourport = dev_id;
204 struct uart_port *port = &ourport->port; 204 struct uart_port *port = &ourport->port;
205 struct tty_struct *tty = port->info->tty; 205 struct tty_struct *tty = port->info->port.tty;
206 unsigned int ufcon, ch, flag, ufstat, uerstat; 206 unsigned int ufcon, ch, flag, ufstat, uerstat;
207 int max_count = 64; 207 int max_count = 64;
208 208
diff --git a/drivers/serial/sb1250-duart.c b/drivers/serial/sb1250-duart.c
index f8e1447a022a..a4fb343a08da 100644
--- a/drivers/serial/sb1250-duart.c
+++ b/drivers/serial/sb1250-duart.c
@@ -384,7 +384,7 @@ static void sbd_receive_chars(struct sbd_port *sport)
384 uart_insert_char(uport, status, M_DUART_OVRUN_ERR, ch, flag); 384 uart_insert_char(uport, status, M_DUART_OVRUN_ERR, ch, flag);
385 } 385 }
386 386
387 tty_flip_buffer_push(uport->info->tty); 387 tty_flip_buffer_push(uport->info->port.tty);
388} 388}
389 389
390static void sbd_transmit_chars(struct sbd_port *sport) 390static void sbd_transmit_chars(struct sbd_port *sport)
diff --git a/drivers/serial/sc26xx.c b/drivers/serial/sc26xx.c
index ae2a9e2df777..e0be11ceaa25 100644
--- a/drivers/serial/sc26xx.c
+++ b/drivers/serial/sc26xx.c
@@ -141,7 +141,7 @@ static struct tty_struct *receive_chars(struct uart_port *port)
141 u8 status; 141 u8 status;
142 142
143 if (port->info != NULL) /* Unopened serial console */ 143 if (port->info != NULL) /* Unopened serial console */
144 tty = port->info->tty; 144 tty = port->info->port.tty;
145 145
146 while (limit-- > 0) { 146 while (limit-- > 0) {
147 status = READ_SC_PORT(port, SR); 147 status = READ_SC_PORT(port, SR);
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 42d2e108b679..f977c98cfa95 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -50,7 +50,7 @@ static struct lock_class_key port_lock_key;
50 50
51#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) 51#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
52 52
53#define uart_users(state) ((state)->count + ((state)->info ? (state)->info->blocked_open : 0)) 53#define uart_users(state) ((state)->count + ((state)->info ? (state)->info->port.blocked_open : 0))
54 54
55#ifdef CONFIG_SERIAL_CORE_CONSOLE 55#ifdef CONFIG_SERIAL_CORE_CONSOLE
56#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line) 56#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
@@ -113,7 +113,7 @@ static void uart_start(struct tty_struct *tty)
113static void uart_tasklet_action(unsigned long data) 113static void uart_tasklet_action(unsigned long data)
114{ 114{
115 struct uart_state *state = (struct uart_state *)data; 115 struct uart_state *state = (struct uart_state *)data;
116 tty_wakeup(state->info->tty); 116 tty_wakeup(state->info->port.tty);
117} 117}
118 118
119static inline void 119static inline void
@@ -135,7 +135,7 @@ uart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear)
135 135
136/* 136/*
137 * Startup the port. This will be called once per open. All calls 137 * Startup the port. This will be called once per open. All calls
138 * will be serialised by the per-port semaphore. 138 * will be serialised by the per-port mutex.
139 */ 139 */
140static int uart_startup(struct uart_state *state, int init_hw) 140static int uart_startup(struct uart_state *state, int init_hw)
141{ 141{
@@ -152,7 +152,7 @@ static int uart_startup(struct uart_state *state, int init_hw)
152 * once we have successfully opened the port. Also set 152 * once we have successfully opened the port. Also set
153 * up the tty->alt_speed kludge 153 * up the tty->alt_speed kludge
154 */ 154 */
155 set_bit(TTY_IO_ERROR, &info->tty->flags); 155 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
156 156
157 if (port->type == PORT_UNKNOWN) 157 if (port->type == PORT_UNKNOWN)
158 return 0; 158 return 0;
@@ -162,6 +162,7 @@ static int uart_startup(struct uart_state *state, int init_hw)
162 * buffer. 162 * buffer.
163 */ 163 */
164 if (!info->xmit.buf) { 164 if (!info->xmit.buf) {
165 /* This is protected by the per port mutex */
165 page = get_zeroed_page(GFP_KERNEL); 166 page = get_zeroed_page(GFP_KERNEL);
166 if (!page) 167 if (!page)
167 return -ENOMEM; 168 return -ENOMEM;
@@ -182,20 +183,20 @@ static int uart_startup(struct uart_state *state, int init_hw)
182 * Setup the RTS and DTR signals once the 183 * Setup the RTS and DTR signals once the
183 * port is open and ready to respond. 184 * port is open and ready to respond.
184 */ 185 */
185 if (info->tty->termios->c_cflag & CBAUD) 186 if (info->port.tty->termios->c_cflag & CBAUD)
186 uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR); 187 uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
187 } 188 }
188 189
189 if (info->flags & UIF_CTS_FLOW) { 190 if (info->flags & UIF_CTS_FLOW) {
190 spin_lock_irq(&port->lock); 191 spin_lock_irq(&port->lock);
191 if (!(port->ops->get_mctrl(port) & TIOCM_CTS)) 192 if (!(port->ops->get_mctrl(port) & TIOCM_CTS))
192 info->tty->hw_stopped = 1; 193 info->port.tty->hw_stopped = 1;
193 spin_unlock_irq(&port->lock); 194 spin_unlock_irq(&port->lock);
194 } 195 }
195 196
196 info->flags |= UIF_INITIALIZED; 197 info->flags |= UIF_INITIALIZED;
197 198
198 clear_bit(TTY_IO_ERROR, &info->tty->flags); 199 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
199 } 200 }
200 201
201 if (retval && capable(CAP_SYS_ADMIN)) 202 if (retval && capable(CAP_SYS_ADMIN))
@@ -217,8 +218,8 @@ static void uart_shutdown(struct uart_state *state)
217 /* 218 /*
218 * Set the TTY IO error marker 219 * Set the TTY IO error marker
219 */ 220 */
220 if (info->tty) 221 if (info->port.tty)
221 set_bit(TTY_IO_ERROR, &info->tty->flags); 222 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
222 223
223 if (info->flags & UIF_INITIALIZED) { 224 if (info->flags & UIF_INITIALIZED) {
224 info->flags &= ~UIF_INITIALIZED; 225 info->flags &= ~UIF_INITIALIZED;
@@ -226,7 +227,7 @@ static void uart_shutdown(struct uart_state *state)
226 /* 227 /*
227 * Turn off DTR and RTS early. 228 * Turn off DTR and RTS early.
228 */ 229 */
229 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) 230 if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL))
230 uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 231 uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
231 232
232 /* 233 /*
@@ -426,7 +427,7 @@ EXPORT_SYMBOL(uart_get_divisor);
426static void 427static void
427uart_change_speed(struct uart_state *state, struct ktermios *old_termios) 428uart_change_speed(struct uart_state *state, struct ktermios *old_termios)
428{ 429{
429 struct tty_struct *tty = state->info->tty; 430 struct tty_struct *tty = state->info->port.tty;
430 struct uart_port *port = state->port; 431 struct uart_port *port = state->port;
431 struct ktermios *termios; 432 struct ktermios *termios;
432 433
@@ -573,6 +574,8 @@ static void uart_flush_buffer(struct tty_struct *tty)
573 574
574 spin_lock_irqsave(&port->lock, flags); 575 spin_lock_irqsave(&port->lock, flags);
575 uart_circ_clear(&state->info->xmit); 576 uart_circ_clear(&state->info->xmit);
577 if (port->ops->flush_buffer)
578 port->ops->flush_buffer(port);
576 spin_unlock_irqrestore(&port->lock, flags); 579 spin_unlock_irqrestore(&port->lock, flags);
577 tty_wakeup(tty); 580 tty_wakeup(tty);
578} 581}
@@ -834,8 +837,8 @@ static int uart_set_info(struct uart_state *state,
834 state->closing_wait = closing_wait; 837 state->closing_wait = closing_wait;
835 if (new_serial.xmit_fifo_size) 838 if (new_serial.xmit_fifo_size)
836 port->fifosize = new_serial.xmit_fifo_size; 839 port->fifosize = new_serial.xmit_fifo_size;
837 if (state->info->tty) 840 if (state->info->port.tty)
838 state->info->tty->low_latency = 841 state->info->port.tty->low_latency =
839 (port->flags & UPF_LOW_LATENCY) ? 1 : 0; 842 (port->flags & UPF_LOW_LATENCY) ? 1 : 0;
840 843
841 check_and_exit: 844 check_and_exit:
@@ -855,7 +858,7 @@ static int uart_set_info(struct uart_state *state,
855 printk(KERN_NOTICE 858 printk(KERN_NOTICE
856 "%s sets custom speed on %s. This " 859 "%s sets custom speed on %s. This "
857 "is deprecated.\n", current->comm, 860 "is deprecated.\n", current->comm,
858 tty_name(state->info->tty, buf)); 861 tty_name(state->info->port.tty, buf));
859 } 862 }
860 uart_change_speed(state, NULL); 863 uart_change_speed(state, NULL);
861 } 864 }
@@ -887,7 +890,7 @@ static int uart_get_lsr_info(struct uart_state *state,
887 */ 890 */
888 if (port->x_char || 891 if (port->x_char ||
889 ((uart_circ_chars_pending(&state->info->xmit) > 0) && 892 ((uart_circ_chars_pending(&state->info->xmit) > 0) &&
890 !state->info->tty->stopped && !state->info->tty->hw_stopped)) 893 !state->info->port.tty->stopped && !state->info->port.tty->hw_stopped))
891 result &= ~TIOCSER_TEMT; 894 result &= ~TIOCSER_TEMT;
892 895
893 return put_user(result, value); 896 return put_user(result, value);
@@ -931,7 +934,7 @@ uart_tiocmset(struct tty_struct *tty, struct file *file,
931 return ret; 934 return ret;
932} 935}
933 936
934static void uart_break_ctl(struct tty_struct *tty, int break_state) 937static int uart_break_ctl(struct tty_struct *tty, int break_state)
935{ 938{
936 struct uart_state *state = tty->driver_data; 939 struct uart_state *state = tty->driver_data;
937 struct uart_port *port = state->port; 940 struct uart_port *port = state->port;
@@ -942,6 +945,7 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state)
942 port->ops->break_ctl(port, break_state); 945 port->ops->break_ctl(port, break_state);
943 946
944 mutex_unlock(&state->mutex); 947 mutex_unlock(&state->mutex);
948 return 0;
945} 949}
946 950
947static int uart_do_autoconfig(struct uart_state *state) 951static int uart_do_autoconfig(struct uart_state *state)
@@ -1237,7 +1241,7 @@ static void uart_set_termios(struct tty_struct *tty,
1237 */ 1241 */
1238 if (!(old_termios->c_cflag & CLOCAL) && 1242 if (!(old_termios->c_cflag & CLOCAL) &&
1239 (tty->termios->c_cflag & CLOCAL)) 1243 (tty->termios->c_cflag & CLOCAL))
1240 wake_up_interruptible(&state->info->open_wait); 1244 wake_up_interruptible(&state->info->port.open_wait);
1241#endif 1245#endif
1242} 1246}
1243 1247
@@ -1318,9 +1322,9 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
1318 tty_ldisc_flush(tty); 1322 tty_ldisc_flush(tty);
1319 1323
1320 tty->closing = 0; 1324 tty->closing = 0;
1321 state->info->tty = NULL; 1325 state->info->port.tty = NULL;
1322 1326
1323 if (state->info->blocked_open) { 1327 if (state->info->port.blocked_open) {
1324 if (state->close_delay) 1328 if (state->close_delay)
1325 msleep_interruptible(state->close_delay); 1329 msleep_interruptible(state->close_delay);
1326 } else if (!uart_console(port)) { 1330 } else if (!uart_console(port)) {
@@ -1331,7 +1335,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
1331 * Wake up anyone trying to open this port. 1335 * Wake up anyone trying to open this port.
1332 */ 1336 */
1333 state->info->flags &= ~UIF_NORMAL_ACTIVE; 1337 state->info->flags &= ~UIF_NORMAL_ACTIVE;
1334 wake_up_interruptible(&state->info->open_wait); 1338 wake_up_interruptible(&state->info->port.open_wait);
1335 1339
1336 done: 1340 done:
1337 mutex_unlock(&state->mutex); 1341 mutex_unlock(&state->mutex);
@@ -1415,8 +1419,8 @@ static void uart_hangup(struct tty_struct *tty)
1415 uart_shutdown(state); 1419 uart_shutdown(state);
1416 state->count = 0; 1420 state->count = 0;
1417 state->info->flags &= ~UIF_NORMAL_ACTIVE; 1421 state->info->flags &= ~UIF_NORMAL_ACTIVE;
1418 state->info->tty = NULL; 1422 state->info->port.tty = NULL;
1419 wake_up_interruptible(&state->info->open_wait); 1423 wake_up_interruptible(&state->info->port.open_wait);
1420 wake_up_interruptible(&state->info->delta_msr_wait); 1424 wake_up_interruptible(&state->info->delta_msr_wait);
1421 } 1425 }
1422 mutex_unlock(&state->mutex); 1426 mutex_unlock(&state->mutex);
@@ -1430,7 +1434,7 @@ static void uart_hangup(struct tty_struct *tty)
1430 */ 1434 */
1431static void uart_update_termios(struct uart_state *state) 1435static void uart_update_termios(struct uart_state *state)
1432{ 1436{
1433 struct tty_struct *tty = state->info->tty; 1437 struct tty_struct *tty = state->info->port.tty;
1434 struct uart_port *port = state->port; 1438 struct uart_port *port = state->port;
1435 1439
1436 if (uart_console(port) && port->cons->cflag) { 1440 if (uart_console(port) && port->cons->cflag) {
@@ -1469,17 +1473,17 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
1469 struct uart_port *port = state->port; 1473 struct uart_port *port = state->port;
1470 unsigned int mctrl; 1474 unsigned int mctrl;
1471 1475
1472 info->blocked_open++; 1476 info->port.blocked_open++;
1473 state->count--; 1477 state->count--;
1474 1478
1475 add_wait_queue(&info->open_wait, &wait); 1479 add_wait_queue(&info->port.open_wait, &wait);
1476 while (1) { 1480 while (1) {
1477 set_current_state(TASK_INTERRUPTIBLE); 1481 set_current_state(TASK_INTERRUPTIBLE);
1478 1482
1479 /* 1483 /*
1480 * If we have been hung up, tell userspace/restart open. 1484 * If we have been hung up, tell userspace/restart open.
1481 */ 1485 */
1482 if (tty_hung_up_p(filp) || info->tty == NULL) 1486 if (tty_hung_up_p(filp) || info->port.tty == NULL)
1483 break; 1487 break;
1484 1488
1485 /* 1489 /*
@@ -1498,8 +1502,8 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
1498 * have set TTY_IO_ERROR for a non-existant port. 1502 * have set TTY_IO_ERROR for a non-existant port.
1499 */ 1503 */
1500 if ((filp->f_flags & O_NONBLOCK) || 1504 if ((filp->f_flags & O_NONBLOCK) ||
1501 (info->tty->termios->c_cflag & CLOCAL) || 1505 (info->port.tty->termios->c_cflag & CLOCAL) ||
1502 (info->tty->flags & (1 << TTY_IO_ERROR))) 1506 (info->port.tty->flags & (1 << TTY_IO_ERROR)))
1503 break; 1507 break;
1504 1508
1505 /* 1509 /*
@@ -1507,7 +1511,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
1507 * not set RTS here - we want to make sure we catch 1511 * not set RTS here - we want to make sure we catch
1508 * the data from the modem. 1512 * the data from the modem.
1509 */ 1513 */
1510 if (info->tty->termios->c_cflag & CBAUD) 1514 if (info->port.tty->termios->c_cflag & CBAUD)
1511 uart_set_mctrl(port, TIOCM_DTR); 1515 uart_set_mctrl(port, TIOCM_DTR);
1512 1516
1513 /* 1517 /*
@@ -1529,15 +1533,15 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
1529 break; 1533 break;
1530 } 1534 }
1531 set_current_state(TASK_RUNNING); 1535 set_current_state(TASK_RUNNING);
1532 remove_wait_queue(&info->open_wait, &wait); 1536 remove_wait_queue(&info->port.open_wait, &wait);
1533 1537
1534 state->count++; 1538 state->count++;
1535 info->blocked_open--; 1539 info->port.blocked_open--;
1536 1540
1537 if (signal_pending(current)) 1541 if (signal_pending(current))
1538 return -ERESTARTSYS; 1542 return -ERESTARTSYS;
1539 1543
1540 if (!info->tty || tty_hung_up_p(filp)) 1544 if (!info->port.tty || tty_hung_up_p(filp))
1541 return -EAGAIN; 1545 return -EAGAIN;
1542 1546
1543 return 0; 1547 return 0;
@@ -1560,10 +1564,13 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
1560 goto err_unlock; 1564 goto err_unlock;
1561 } 1565 }
1562 1566
1567 /* BKL: RACE HERE - LEAK */
1568 /* We should move this into the uart_state structure and kill off
1569 this whole complexity */
1563 if (!state->info) { 1570 if (!state->info) {
1564 state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL); 1571 state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL);
1565 if (state->info) { 1572 if (state->info) {
1566 init_waitqueue_head(&state->info->open_wait); 1573 init_waitqueue_head(&state->info->port.open_wait);
1567 init_waitqueue_head(&state->info->delta_msr_wait); 1574 init_waitqueue_head(&state->info->delta_msr_wait);
1568 1575
1569 /* 1576 /*
@@ -1620,7 +1627,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
1620 * be re-entered while allocating the info structure, or while we 1627 * be re-entered while allocating the info structure, or while we
1621 * request any IRQs that the driver may need. This also has the nice 1628 * request any IRQs that the driver may need. This also has the nice
1622 * side-effect that it delays the action of uart_hangup, so we can 1629 * side-effect that it delays the action of uart_hangup, so we can
1623 * guarantee that info->tty will always contain something reasonable. 1630 * guarantee that info->port.tty will always contain something reasonable.
1624 */ 1631 */
1625 state = uart_get(drv, line); 1632 state = uart_get(drv, line);
1626 if (IS_ERR(state)) { 1633 if (IS_ERR(state)) {
@@ -1636,7 +1643,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
1636 tty->driver_data = state; 1643 tty->driver_data = state;
1637 tty->low_latency = (state->port->flags & UPF_LOW_LATENCY) ? 1 : 0; 1644 tty->low_latency = (state->port->flags & UPF_LOW_LATENCY) ? 1 : 0;
1638 tty->alt_speed = 0; 1645 tty->alt_speed = 0;
1639 state->info->tty = tty; 1646 state->info->port.tty = tty;
1640 1647
1641 /* 1648 /*
1642 * If the port is in the middle of closing, bail out now. 1649 * If the port is in the middle of closing, bail out now.
@@ -2099,8 +2106,8 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
2099 /* 2106 /*
2100 * If that's unset, use the tty termios setting. 2107 * If that's unset, use the tty termios setting.
2101 */ 2108 */
2102 if (state->info && state->info->tty && termios.c_cflag == 0) 2109 if (state->info && state->info->port.tty && termios.c_cflag == 0)
2103 termios = *state->info->tty->termios; 2110 termios = *state->info->port.tty->termios;
2104 2111
2105 uart_change_pm(state, 0); 2112 uart_change_pm(state, 0);
2106 port->ops->set_termios(port, &termios, NULL); 2113 port->ops->set_termios(port, &termios, NULL);
@@ -2519,8 +2526,8 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
2519 tty_unregister_device(drv->tty_driver, port->line); 2526 tty_unregister_device(drv->tty_driver, port->line);
2520 2527
2521 info = state->info; 2528 info = state->info;
2522 if (info && info->tty) 2529 if (info && info->port.tty)
2523 tty_vhangup(info->tty); 2530 tty_vhangup(info->port.tty);
2524 2531
2525 /* 2532 /*
2526 * All users of this port should now be disconnected from 2533 * All users of this port should now be disconnected from
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c
index 8721afe1ae4f..b9cbfc87f616 100644
--- a/drivers/serial/serial_ks8695.c
+++ b/drivers/serial/serial_ks8695.c
@@ -26,8 +26,8 @@
26#include <asm/irq.h> 26#include <asm/irq.h>
27#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
28 28
29#include <asm/arch/regs-uart.h> 29#include <mach/regs-uart.h>
30#include <asm/arch/regs-irq.h> 30#include <mach/regs-irq.h>
31 31
32#if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 32#if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
33#define SUPPORT_SYSRQ 33#define SUPPORT_SYSRQ
@@ -108,7 +108,7 @@ static void ks8695uart_disable_ms(struct uart_port *port)
108static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) 108static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id)
109{ 109{
110 struct uart_port *port = dev_id; 110 struct uart_port *port = dev_id;
111 struct tty_struct *tty = port->info->tty; 111 struct tty_struct *tty = port->info->port.tty;
112 unsigned int status, ch, lsr, flg, max_count = 256; 112 unsigned int status, ch, lsr, flg, max_count = 256;
113 113
114 status = UART_GET_LSR(port); /* clears pending LSR interrupts */ 114 status = UART_GET_LSR(port); /* clears pending LSR interrupts */
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index eb18d429752d..cb49a5ac022f 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -137,7 +137,7 @@ static void lh7a40xuart_enable_ms (struct uart_port* port)
137 137
138static void lh7a40xuart_rx_chars (struct uart_port* port) 138static void lh7a40xuart_rx_chars (struct uart_port* port)
139{ 139{
140 struct tty_struct* tty = port->info->tty; 140 struct tty_struct* tty = port->info->port.tty;
141 int cbRxMax = 256; /* (Gross) limit on receive */ 141 int cbRxMax = 256; /* (Gross) limit on receive */
142 unsigned int data; /* Received data and status */ 142 unsigned int data; /* Received data and status */
143 unsigned int flag; 143 unsigned int flag;
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 7ad21925869a..8fcb4c5b9a26 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -272,7 +272,7 @@ static void serial_txx9_initialize(struct uart_port *port)
272static inline void 272static inline void
273receive_chars(struct uart_txx9_port *up, unsigned int *status) 273receive_chars(struct uart_txx9_port *up, unsigned int *status)
274{ 274{
275 struct tty_struct *tty = up->port.info->tty; 275 struct tty_struct *tty = up->port.info->port.tty;
276 unsigned char ch; 276 unsigned char ch;
277 unsigned int disr = *status; 277 unsigned int disr = *status;
278 int max_count = 256; 278 int max_count = 256;
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index ce6ee92b3a1b..3df2aaec829f 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -410,7 +410,6 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
410#endif 410#endif
411 411
412#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ 412#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
413 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
414 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 413 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
415 defined(CONFIG_CPU_SUBTYPE_SH7785) 414 defined(CONFIG_CPU_SUBTYPE_SH7785)
416static inline int scif_txroom(struct uart_port *port) 415static inline int scif_txroom(struct uart_port *port)
@@ -422,6 +421,22 @@ static inline int scif_rxroom(struct uart_port *port)
422{ 421{
423 return sci_in(port, SCRFDR) & 0xff; 422 return sci_in(port, SCRFDR) & 0xff;
424} 423}
424#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
425static inline int scif_txroom(struct uart_port *port)
426{
427 if((port->mapbase == 0xffe00000) || (port->mapbase == 0xffe08000)) /* SCIF0/1*/
428 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
429 else /* SCIF2 */
430 return SCIF2_TXROOM_MAX - (sci_in(port, SCFDR) >> 8);
431}
432
433static inline int scif_rxroom(struct uart_port *port)
434{
435 if((port->mapbase == 0xffe00000) || (port->mapbase == 0xffe08000)) /* SCIF0/1*/
436 return sci_in(port, SCRFDR) & 0xff;
437 else /* SCIF2 */
438 return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
439}
425#else 440#else
426static inline int scif_txroom(struct uart_port *port) 441static inline int scif_txroom(struct uart_port *port)
427{ 442{
@@ -521,7 +536,7 @@ static void sci_transmit_chars(struct uart_port *port)
521static inline void sci_receive_chars(struct uart_port *port) 536static inline void sci_receive_chars(struct uart_port *port)
522{ 537{
523 struct sci_port *sci_port = (struct sci_port *)port; 538 struct sci_port *sci_port = (struct sci_port *)port;
524 struct tty_struct *tty = port->info->tty; 539 struct tty_struct *tty = port->info->port.tty;
525 int i, count, copied = 0; 540 int i, count, copied = 0;
526 unsigned short status; 541 unsigned short status;
527 unsigned char flag; 542 unsigned char flag;
@@ -642,7 +657,7 @@ static inline int sci_handle_errors(struct uart_port *port)
642{ 657{
643 int copied = 0; 658 int copied = 0;
644 unsigned short status = sci_in(port, SCxSR); 659 unsigned short status = sci_in(port, SCxSR);
645 struct tty_struct *tty = port->info->tty; 660 struct tty_struct *tty = port->info->port.tty;
646 661
647 if (status & SCxSR_ORER(port)) { 662 if (status & SCxSR_ORER(port)) {
648 /* overrun error */ 663 /* overrun error */
@@ -692,7 +707,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
692{ 707{
693 int copied = 0; 708 int copied = 0;
694 unsigned short status = sci_in(port, SCxSR); 709 unsigned short status = sci_in(port, SCxSR);
695 struct tty_struct *tty = port->info->tty; 710 struct tty_struct *tty = port->info->port.tty;
696 struct sci_port *s = &sci_ports[port->line]; 711 struct sci_port *s = &sci_ports[port->line];
697 712
698 if (uart_handle_break(port)) 713 if (uart_handle_break(port))
@@ -762,7 +777,7 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr)
762 } else { 777 } else {
763#if defined(SCIF_ORER) 778#if defined(SCIF_ORER)
764 if((sci_in(port, SCLSR) & SCIF_ORER) != 0) { 779 if((sci_in(port, SCLSR) & SCIF_ORER) != 0) {
765 struct tty_struct *tty = port->info->tty; 780 struct tty_struct *tty = port->info->port.tty;
766 781
767 sci_out(port, SCLSR, 0); 782 sci_out(port, SCLSR, 0);
768 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 783 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index eb84833233fd..8a0749e34ca3 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -123,8 +123,9 @@
123#elif defined(CONFIG_CPU_SUBTYPE_SH7763) 123#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
124# define SCSPTR0 0xffe00024 /* 16 bit SCIF */ 124# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
125# define SCSPTR1 0xffe08024 /* 16 bit SCIF */ 125# define SCSPTR1 0xffe08024 /* 16 bit SCIF */
126# define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */
126# define SCIF_ORER 0x0001 /* overrun error bit */ 127# define SCIF_ORER 0x0001 /* overrun error bit */
127# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 128# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
128# define SCIF_ONLY 129# define SCIF_ONLY
129#elif defined(CONFIG_CPU_SUBTYPE_SH7770) 130#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
130# define SCSPTR0 0xff923020 /* 16 bit SCIF */ 131# define SCSPTR0 0xff923020 /* 16 bit SCIF */
@@ -188,6 +189,7 @@
188 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ 189 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
189 defined(CONFIG_CPU_SUBTYPE_SH7751) || \ 190 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
190 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \ 191 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
192 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
191 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 193 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
192 defined(CONFIG_CPU_SUBTYPE_SH7785) || \ 194 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
193 defined(CONFIG_CPU_SUBTYPE_SHX3) 195 defined(CONFIG_CPU_SUBTYPE_SHX3)
@@ -225,14 +227,21 @@
225#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 227#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
226 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 228 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
227 defined(CONFIG_CPU_SUBTYPE_SH7721) 229 defined(CONFIG_CPU_SUBTYPE_SH7721)
228#define SCIF_ORER 0x0200 230# define SCIF_ORER 0x0200
229#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) 231# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
230#define SCIF_RFDC_MASK 0x007f 232# define SCIF_RFDC_MASK 0x007f
231#define SCIF_TXROOM_MAX 64 233# define SCIF_TXROOM_MAX 64
234#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
235# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK )
236# define SCIF_RFDC_MASK 0x007f
237# define SCIF_TXROOM_MAX 64
238/* SH7763 SCIF2 support */
239# define SCIF2_RFDC_MASK 0x001f
240# define SCIF2_TXROOM_MAX 16
232#else 241#else
233#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) 242# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
234#define SCIF_RFDC_MASK 0x001f 243# define SCIF_RFDC_MASK 0x001f
235#define SCIF_TXROOM_MAX 16 244# define SCIF_TXROOM_MAX 16
236#endif 245#endif
237 246
238#if defined(SCI_ONLY) 247#if defined(SCI_ONLY)
@@ -442,7 +451,6 @@ SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
442SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 451SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
443SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 452SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
444#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ 453#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
445 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
446 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 454 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
447 defined(CONFIG_CPU_SUBTYPE_SH7785) 455 defined(CONFIG_CPU_SUBTYPE_SH7785)
448SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 456SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
@@ -450,6 +458,14 @@ SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
450SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 458SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
451SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) 459SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
452SCIF_FNS(SCLSR, 0, 0, 0x28, 16) 460SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
461#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
462SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
463SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16)
464SCIF_FNS(SCLSR2, 0, 0, 0x24, 16)
465SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
466SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
467SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
468SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
453#else 469#else
454SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 470SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
455#if defined(CONFIG_CPU_SUBTYPE_SH7722) 471#if defined(CONFIG_CPU_SUBTYPE_SH7722)
@@ -652,6 +668,9 @@ static inline int sci_rxd_in(struct uart_port *port)
652 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ 668 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
653 if (port->mapbase == 0xffe08000) 669 if (port->mapbase == 0xffe08000)
654 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ 670 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
671 if (port->mapbase == 0xffe10000)
672 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF/IRDA */
673
655 return 1; 674 return 1;
656} 675}
657#elif defined(CONFIG_CPU_SUBTYPE_SH7770) 676#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
@@ -764,8 +783,7 @@ static inline int sci_rxd_in(struct uart_port *port)
764 * -- Mitch Davis - 15 Jul 2000 783 * -- Mitch Davis - 15 Jul 2000
765 */ 784 */
766 785
767#if defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 786#if defined(CONFIG_CPU_SUBTYPE_SH7780) || \
768 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
769 defined(CONFIG_CPU_SUBTYPE_SH7785) 787 defined(CONFIG_CPU_SUBTYPE_SH7785)
770#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) 788#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
771#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 789#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index 019da2e05f0b..b73e3c0056cd 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -471,7 +471,7 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags)
471 471
472 if (port->sc_port.info) { 472 if (port->sc_port.info) {
473 /* The serial_core stuffs are initilized, use them */ 473 /* The serial_core stuffs are initilized, use them */
474 tty = port->sc_port.info->tty; 474 tty = port->sc_port.info->port.tty;
475 } 475 }
476 else { 476 else {
477 /* Not registered yet - can't pass to tty layer. */ 477 /* Not registered yet - can't pass to tty layer. */
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c
index 2847336742d7..aeeec5588afd 100644
--- a/drivers/serial/sunhv.c
+++ b/drivers/serial/sunhv.c
@@ -185,7 +185,7 @@ static struct tty_struct *receive_chars(struct uart_port *port)
185 struct tty_struct *tty = NULL; 185 struct tty_struct *tty = NULL;
186 186
187 if (port->info != NULL) /* Unopened serial console */ 187 if (port->info != NULL) /* Unopened serial console */
188 tty = port->info->tty; 188 tty = port->info->port.tty;
189 189
190 if (sunhv_ops->receive_chars(port, tty)) 190 if (sunhv_ops->receive_chars(port, tty))
191 sun_do_break(); 191 sun_do_break();
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index 9ff5b38f3bee..15ee497e1c78 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -118,7 +118,7 @@ receive_chars(struct uart_sunsab_port *up,
118 int i; 118 int i;
119 119
120 if (up->port.info != NULL) /* Unopened serial console */ 120 if (up->port.info != NULL) /* Unopened serial console */
121 tty = up->port.info->tty; 121 tty = up->port.info->port.tty;
122 122
123 /* Read number of BYTES (Character + Status) available. */ 123 /* Read number of BYTES (Character + Status) available. */
124 if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { 124 if (stat->sreg.isr0 & SAB82532_ISR0_RPF) {
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 03806a935209..e24e68235088 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1,4 +1,4 @@
1/* $Id: su.c,v 1.55 2002/01/08 16:00:16 davem Exp $ 1/*
2 * su.c: Small serial driver for keyboard/mouse interface on sparc32/PCI 2 * su.c: Small serial driver for keyboard/mouse interface on sparc32/PCI
3 * 3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) 4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
@@ -311,7 +311,7 @@ static void sunsu_enable_ms(struct uart_port *port)
311static struct tty_struct * 311static struct tty_struct *
312receive_chars(struct uart_sunsu_port *up, unsigned char *status) 312receive_chars(struct uart_sunsu_port *up, unsigned char *status)
313{ 313{
314 struct tty_struct *tty = up->port.info->tty; 314 struct tty_struct *tty = up->port.info->port.tty;
315 unsigned char ch, flag; 315 unsigned char ch, flag;
316 int max_count = 256; 316 int max_count = 256;
317 int saw_console_brk = 0; 317 int saw_console_brk = 0;
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 7e9fa5ef0eb7..0f3d69b86d67 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -329,8 +329,8 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up,
329 329
330 tty = NULL; 330 tty = NULL;
331 if (up->port.info != NULL && /* Unopened serial console */ 331 if (up->port.info != NULL && /* Unopened serial console */
332 up->port.info->tty != NULL) /* Keyboard || mouse */ 332 up->port.info->port.tty != NULL) /* Keyboard || mouse */
333 tty = up->port.info->tty; 333 tty = up->port.info->port.tty;
334 334
335 for (;;) { 335 for (;;) {
336 336
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index b51c24245be4..6a3f8fb0c9dd 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -75,7 +75,7 @@ static struct uart_port ulite_ports[ULITE_NR_UARTS];
75 75
76static int ulite_receive(struct uart_port *port, int stat) 76static int ulite_receive(struct uart_port *port, int stat)
77{ 77{
78 struct tty_struct *tty = port->info->tty; 78 struct tty_struct *tty = port->info->port.tty;
79 unsigned char ch = 0; 79 unsigned char ch = 0;
80 char flag = TTY_NORMAL; 80 char flag = TTY_NORMAL;
81 81
@@ -162,7 +162,7 @@ static irqreturn_t ulite_isr(int irq, void *dev_id)
162 busy |= ulite_transmit(port, stat); 162 busy |= ulite_transmit(port, stat);
163 } while (busy); 163 } while (busy);
164 164
165 tty_flip_buffer_push(port->info->tty); 165 tty_flip_buffer_push(port->info->port.tty);
166 166
167 return IRQ_HANDLED; 167 return IRQ_HANDLED;
168} 168}
diff --git a/drivers/serial/ucc_uart.c b/drivers/serial/ucc_uart.c
index 566a8b42e05a..5c5d18dcb6ac 100644
--- a/drivers/serial/ucc_uart.c
+++ b/drivers/serial/ucc_uart.c
@@ -466,7 +466,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)
466 int i; 466 int i;
467 unsigned char ch, *cp; 467 unsigned char ch, *cp;
468 struct uart_port *port = &qe_port->port; 468 struct uart_port *port = &qe_port->port;
469 struct tty_struct *tty = port->info->tty; 469 struct tty_struct *tty = port->info->port.tty;
470 struct qe_bd *bdp; 470 struct qe_bd *bdp;
471 u16 status; 471 u16 status;
472 unsigned int flg; 472 unsigned int flg;
diff --git a/drivers/serial/v850e_uart.c b/drivers/serial/v850e_uart.c
deleted file mode 100644
index dd98aca6ed08..000000000000
--- a/drivers/serial/v850e_uart.c
+++ /dev/null
@@ -1,548 +0,0 @@
1/*
2 * drivers/serial/v850e_uart.c -- Serial I/O using V850E on-chip UART or UARTB
3 *
4 * Copyright (C) 2001,02,03 NEC Electronics Corporation
5 * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this
9 * archive for more details.
10 *
11 * Written by Miles Bader <miles@gnu.org>
12 */
13
14/* This driver supports both the original V850E UART interface (called
15 merely `UART' in the docs) and the newer `UARTB' interface, which is
16 roughly a superset of the first one. The selection is made at
17 configure time -- if CONFIG_V850E_UARTB is defined, then UARTB is
18 presumed, otherwise the old UART -- as these are on-CPU UARTS, a system
19 can never have both.
20
21 The UARTB interface also has a 16-entry FIFO mode, which is not
22 yet supported by this driver. */
23
24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <linux/module.h>
27#include <linux/console.h>
28#include <linux/tty.h>
29#include <linux/tty_flip.h>
30#include <linux/serial.h>
31#include <linux/serial_core.h>
32
33#include <asm/v850e_uart.h>
34
35/* Initial UART state. This may be overridden by machine-dependent headers. */
36#ifndef V850E_UART_INIT_BAUD
37#define V850E_UART_INIT_BAUD 115200
38#endif
39#ifndef V850E_UART_INIT_CFLAGS
40#define V850E_UART_INIT_CFLAGS (B115200 | CS8 | CREAD)
41#endif
42
43/* A string used for prefixing printed descriptions; since the same UART
44 macro is actually used on other chips than the V850E. This must be a
45 constant string. */
46#ifndef V850E_UART_CHIP_NAME
47#define V850E_UART_CHIP_NAME "V850E"
48#endif
49
50#define V850E_UART_MINOR_BASE 64 /* First tty minor number */
51
52
53/* Low-level UART functions. */
54
55/* Configure and turn on uart channel CHAN, using the termios `control
56 modes' bits in CFLAGS, and a baud-rate of BAUD. */
57void v850e_uart_configure (unsigned chan, unsigned cflags, unsigned baud)
58{
59 int flags;
60 v850e_uart_speed_t old_speed;
61 v850e_uart_config_t old_config;
62 v850e_uart_speed_t new_speed = v850e_uart_calc_speed (baud);
63 v850e_uart_config_t new_config = v850e_uart_calc_config (cflags);
64
65 /* Disable interrupts while we're twiddling the hardware. */
66 local_irq_save (flags);
67
68#ifdef V850E_UART_PRE_CONFIGURE
69 V850E_UART_PRE_CONFIGURE (chan, cflags, baud);
70#endif
71
72 old_config = V850E_UART_CONFIG (chan);
73 old_speed = v850e_uart_speed (chan);
74
75 if (! v850e_uart_speed_eq (old_speed, new_speed)) {
76 /* The baud rate has changed. First, disable the UART. */
77 V850E_UART_CONFIG (chan) = V850E_UART_CONFIG_FINI;
78 old_config = 0; /* Force the uart to be re-initialized. */
79
80 /* Reprogram the baud-rate generator. */
81 v850e_uart_set_speed (chan, new_speed);
82 }
83
84 if (! (old_config & V850E_UART_CONFIG_ENABLED)) {
85 /* If we are using the uart for the first time, start by
86 enabling it, which must be done before turning on any
87 other bits. */
88 V850E_UART_CONFIG (chan) = V850E_UART_CONFIG_INIT;
89 /* See the initial state. */
90 old_config = V850E_UART_CONFIG (chan);
91 }
92
93 if (new_config != old_config) {
94 /* Which of the TXE/RXE bits we'll temporarily turn off
95 before changing other control bits. */
96 unsigned temp_disable = 0;
97 /* Which of the TXE/RXE bits will be enabled. */
98 unsigned enable = 0;
99 unsigned changed_bits = new_config ^ old_config;
100
101 /* Which of RX/TX will be enabled in the new configuration. */
102 if (new_config & V850E_UART_CONFIG_RX_BITS)
103 enable |= (new_config & V850E_UART_CONFIG_RX_ENABLE);
104 if (new_config & V850E_UART_CONFIG_TX_BITS)
105 enable |= (new_config & V850E_UART_CONFIG_TX_ENABLE);
106
107 /* Figure out which of RX/TX needs to be disabled; note
108 that this will only happen if they're not already
109 disabled. */
110 if (changed_bits & V850E_UART_CONFIG_RX_BITS)
111 temp_disable
112 |= (old_config & V850E_UART_CONFIG_RX_ENABLE);
113 if (changed_bits & V850E_UART_CONFIG_TX_BITS)
114 temp_disable
115 |= (old_config & V850E_UART_CONFIG_TX_ENABLE);
116
117 /* We have to turn off RX and/or TX mode before changing
118 any associated control bits. */
119 if (temp_disable)
120 V850E_UART_CONFIG (chan) = old_config & ~temp_disable;
121
122 /* Write the new control bits, while RX/TX are disabled. */
123 if (changed_bits & ~enable)
124 V850E_UART_CONFIG (chan) = new_config & ~enable;
125
126 v850e_uart_config_delay (new_config, new_speed);
127
128 /* Write the final version, with enable bits turned on. */
129 V850E_UART_CONFIG (chan) = new_config;
130 }
131
132 local_irq_restore (flags);
133}
134
135
136/* Low-level console. */
137
138#ifdef CONFIG_V850E_UART_CONSOLE
139
140static void v850e_uart_cons_write (struct console *co,
141 const char *s, unsigned count)
142{
143 if (count > 0) {
144 unsigned chan = co->index;
145 unsigned irq = V850E_UART_TX_IRQ (chan);
146 int irq_was_enabled, irq_was_pending, flags;
147
148 /* We don't want to get `transmission completed'
149 interrupts, since we're busy-waiting, so we disable them
150 while sending (we don't disable interrupts entirely
151 because sending over a serial line is really slow). We
152 save the status of the tx interrupt and restore it when
153 we're done so that using printk doesn't interfere with
154 normal serial transmission (other than interleaving the
155 output, of course!). This should work correctly even if
156 this function is interrupted and the interrupt printks
157 something. */
158
159 /* Disable interrupts while fiddling with tx interrupt. */
160 local_irq_save (flags);
161 /* Get current tx interrupt status. */
162 irq_was_enabled = v850e_intc_irq_enabled (irq);
163 irq_was_pending = v850e_intc_irq_pending (irq);
164 /* Disable tx interrupt if necessary. */
165 if (irq_was_enabled)
166 v850e_intc_disable_irq (irq);
167 /* Turn interrupts back on. */
168 local_irq_restore (flags);
169
170 /* Send characters. */
171 while (count > 0) {
172 int ch = *s++;
173
174 if (ch == '\n') {
175 /* We don't have the benefit of a tty
176 driver, so translate NL into CR LF. */
177 v850e_uart_wait_for_xmit_ok (chan);
178 v850e_uart_putc (chan, '\r');
179 }
180
181 v850e_uart_wait_for_xmit_ok (chan);
182 v850e_uart_putc (chan, ch);
183
184 count--;
185 }
186
187 /* Restore saved tx interrupt status. */
188 if (irq_was_enabled) {
189 /* Wait for the last character we sent to be
190 completely transmitted (as we'll get an
191 interrupt interrupt at that point). */
192 v850e_uart_wait_for_xmit_done (chan);
193 /* Clear pending interrupts received due
194 to our transmission, unless there was already
195 one pending, in which case we want the
196 handler to be called. */
197 if (! irq_was_pending)
198 v850e_intc_clear_pending_irq (irq);
199 /* ... and then turn back on handling. */
200 v850e_intc_enable_irq (irq);
201 }
202 }
203}
204
205extern struct uart_driver v850e_uart_driver;
206static struct console v850e_uart_cons =
207{
208 .name = "ttyS",
209 .write = v850e_uart_cons_write,
210 .device = uart_console_device,
211 .flags = CON_PRINTBUFFER,
212 .cflag = V850E_UART_INIT_CFLAGS,
213 .index = -1,
214 .data = &v850e_uart_driver,
215};
216
217void v850e_uart_cons_init (unsigned chan)
218{
219 v850e_uart_configure (chan, V850E_UART_INIT_CFLAGS,
220 V850E_UART_INIT_BAUD);
221 v850e_uart_cons.index = chan;
222 register_console (&v850e_uart_cons);
223 printk ("Console: %s on-chip UART channel %d\n",
224 V850E_UART_CHIP_NAME, chan);
225}
226
227/* This is what the init code actually calls. */
228static int v850e_uart_console_init (void)
229{
230 v850e_uart_cons_init (V850E_UART_CONSOLE_CHANNEL);
231 return 0;
232}
233console_initcall(v850e_uart_console_init);
234
235#define V850E_UART_CONSOLE &v850e_uart_cons
236
237#else /* !CONFIG_V850E_UART_CONSOLE */
238#define V850E_UART_CONSOLE 0
239#endif /* CONFIG_V850E_UART_CONSOLE */
240
241/* TX/RX interrupt handlers. */
242
243static void v850e_uart_stop_tx (struct uart_port *port);
244
245void v850e_uart_tx (struct uart_port *port)
246{
247 struct circ_buf *xmit = &port->info->xmit;
248 int stopped = uart_tx_stopped (port);
249
250 if (v850e_uart_xmit_ok (port->line)) {
251 int tx_ch;
252
253 if (port->x_char) {
254 tx_ch = port->x_char;
255 port->x_char = 0;
256 } else if (!uart_circ_empty (xmit) && !stopped) {
257 tx_ch = xmit->buf[xmit->tail];
258 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
259 } else
260 goto no_xmit;
261
262 v850e_uart_putc (port->line, tx_ch);
263 port->icount.tx++;
264
265 if (uart_circ_chars_pending (xmit) < WAKEUP_CHARS)
266 uart_write_wakeup (port);
267 }
268
269 no_xmit:
270 if (uart_circ_empty (xmit) || stopped)
271 v850e_uart_stop_tx (port, stopped);
272}
273
274static irqreturn_t v850e_uart_tx_irq(int irq, void *data)
275{
276 struct uart_port *port = data;
277 v850e_uart_tx (port);
278 return IRQ_HANDLED;
279}
280
281static irqreturn_t v850e_uart_rx_irq(int irq, void *data)
282{
283 struct uart_port *port = data;
284 unsigned ch_stat = TTY_NORMAL;
285 unsigned ch = v850e_uart_getc (port->line);
286 unsigned err = v850e_uart_err (port->line);
287
288 if (err) {
289 if (err & V850E_UART_ERR_OVERRUN) {
290 ch_stat = TTY_OVERRUN;
291 port->icount.overrun++;
292 } else if (err & V850E_UART_ERR_FRAME) {
293 ch_stat = TTY_FRAME;
294 port->icount.frame++;
295 } else if (err & V850E_UART_ERR_PARITY) {
296 ch_stat = TTY_PARITY;
297 port->icount.parity++;
298 }
299 }
300
301 port->icount.rx++;
302
303 tty_insert_flip_char (port->info->tty, ch, ch_stat);
304 tty_schedule_flip (port->info->tty);
305
306 return IRQ_HANDLED;
307}
308
309
310/* Control functions for the serial framework. */
311
312static void v850e_uart_nop (struct uart_port *port) { }
313static int v850e_uart_success (struct uart_port *port) { return 0; }
314
315static unsigned v850e_uart_tx_empty (struct uart_port *port)
316{
317 return TIOCSER_TEMT; /* Can't detect. */
318}
319
320static void v850e_uart_set_mctrl (struct uart_port *port, unsigned mctrl)
321{
322#ifdef V850E_UART_SET_RTS
323 V850E_UART_SET_RTS (port->line, (mctrl & TIOCM_RTS));
324#endif
325}
326
327static unsigned v850e_uart_get_mctrl (struct uart_port *port)
328{
329 /* We don't support DCD or DSR, so consider them permanently active. */
330 int mctrl = TIOCM_CAR | TIOCM_DSR;
331
332 /* We may support CTS. */
333#ifdef V850E_UART_CTS
334 mctrl |= V850E_UART_CTS(port->line) ? TIOCM_CTS : 0;
335#else
336 mctrl |= TIOCM_CTS;
337#endif
338
339 return mctrl;
340}
341
342static void v850e_uart_start_tx (struct uart_port *port)
343{
344 v850e_intc_disable_irq (V850E_UART_TX_IRQ (port->line));
345 v850e_uart_tx (port);
346 v850e_intc_enable_irq (V850E_UART_TX_IRQ (port->line));
347}
348
349static void v850e_uart_stop_tx (struct uart_port *port)
350{
351 v850e_intc_disable_irq (V850E_UART_TX_IRQ (port->line));
352}
353
354static void v850e_uart_start_rx (struct uart_port *port)
355{
356 v850e_intc_enable_irq (V850E_UART_RX_IRQ (port->line));
357}
358
359static void v850e_uart_stop_rx (struct uart_port *port)
360{
361 v850e_intc_disable_irq (V850E_UART_RX_IRQ (port->line));
362}
363
364static void v850e_uart_break_ctl (struct uart_port *port, int break_ctl)
365{
366 /* Umm, do this later. */
367}
368
369static int v850e_uart_startup (struct uart_port *port)
370{
371 int err;
372
373 /* Alloc RX irq. */
374 err = request_irq (V850E_UART_RX_IRQ (port->line), v850e_uart_rx_irq,
375 IRQF_DISABLED, "v850e_uart", port);
376 if (err)
377 return err;
378
379 /* Alloc TX irq. */
380 err = request_irq (V850E_UART_TX_IRQ (port->line), v850e_uart_tx_irq,
381 IRQF_DISABLED, "v850e_uart", port);
382 if (err) {
383 free_irq (V850E_UART_RX_IRQ (port->line), port);
384 return err;
385 }
386
387 v850e_uart_start_rx (port);
388
389 return 0;
390}
391
392static void v850e_uart_shutdown (struct uart_port *port)
393{
394 /* Disable port interrupts. */
395 free_irq (V850E_UART_TX_IRQ (port->line), port);
396 free_irq (V850E_UART_RX_IRQ (port->line), port);
397
398 /* Turn off xmit/recv enable bits. */
399 V850E_UART_CONFIG (port->line)
400 &= ~(V850E_UART_CONFIG_TX_ENABLE
401 | V850E_UART_CONFIG_RX_ENABLE);
402 /* Then reset the channel. */
403 V850E_UART_CONFIG (port->line) = 0;
404}
405
406static void
407v850e_uart_set_termios (struct uart_port *port, struct ktermios *termios,
408 struct ktermios *old)
409{
410 unsigned cflags = termios->c_cflag;
411
412 /* Restrict flags to legal values. */
413 if ((cflags & CSIZE) != CS7 && (cflags & CSIZE) != CS8)
414 /* The new value of CSIZE is invalid, use the old value. */
415 cflags = (cflags & ~CSIZE)
416 | (old ? (old->c_cflag & CSIZE) : CS8);
417
418 termios->c_cflag = cflags;
419
420 v850e_uart_configure (port->line, cflags,
421 uart_get_baud_rate (port, termios, old,
422 v850e_uart_min_baud(),
423 v850e_uart_max_baud()));
424}
425
426static const char *v850e_uart_type (struct uart_port *port)
427{
428 return port->type == PORT_V850E_UART ? "v850e_uart" : 0;
429}
430
431static void v850e_uart_config_port (struct uart_port *port, int flags)
432{
433 if (flags & UART_CONFIG_TYPE)
434 port->type = PORT_V850E_UART;
435}
436
437static int
438v850e_uart_verify_port (struct uart_port *port, struct serial_struct *ser)
439{
440 if (ser->type != PORT_UNKNOWN && ser->type != PORT_V850E_UART)
441 return -EINVAL;
442 if (ser->irq != V850E_UART_TX_IRQ (port->line))
443 return -EINVAL;
444 return 0;
445}
446
447static struct uart_ops v850e_uart_ops = {
448 .tx_empty = v850e_uart_tx_empty,
449 .get_mctrl = v850e_uart_get_mctrl,
450 .set_mctrl = v850e_uart_set_mctrl,
451 .start_tx = v850e_uart_start_tx,
452 .stop_tx = v850e_uart_stop_tx,
453 .stop_rx = v850e_uart_stop_rx,
454 .enable_ms = v850e_uart_nop,
455 .break_ctl = v850e_uart_break_ctl,
456 .startup = v850e_uart_startup,
457 .shutdown = v850e_uart_shutdown,
458 .set_termios = v850e_uart_set_termios,
459 .type = v850e_uart_type,
460 .release_port = v850e_uart_nop,
461 .request_port = v850e_uart_success,
462 .config_port = v850e_uart_config_port,
463 .verify_port = v850e_uart_verify_port,
464};
465
466/* Initialization and cleanup. */
467
468static struct uart_driver v850e_uart_driver = {
469 .owner = THIS_MODULE,
470 .driver_name = "v850e_uart",
471 .dev_name = "ttyS",
472 .major = TTY_MAJOR,
473 .minor = V850E_UART_MINOR_BASE,
474 .nr = V850E_UART_NUM_CHANNELS,
475 .cons = V850E_UART_CONSOLE,
476};
477
478
479static struct uart_port v850e_uart_ports[V850E_UART_NUM_CHANNELS];
480
481static int __init v850e_uart_init (void)
482{
483 int rval;
484
485 printk (KERN_INFO "%s on-chip UART\n", V850E_UART_CHIP_NAME);
486
487 rval = uart_register_driver (&v850e_uart_driver);
488 if (rval == 0) {
489 unsigned chan;
490
491 for (chan = 0; chan < V850E_UART_NUM_CHANNELS; chan++) {
492 struct uart_port *port = &v850e_uart_ports[chan];
493
494 memset (port, 0, sizeof *port);
495
496 port->ops = &v850e_uart_ops;
497 port->line = chan;
498 port->iotype = UPIO_MEM;
499 port->flags = UPF_BOOT_AUTOCONF;
500
501 /* We actually use multiple IRQs, but the serial
502 framework seems to mainly use this for
503 informational purposes anyway. Here we use the TX
504 irq. */
505 port->irq = V850E_UART_TX_IRQ (chan);
506
507 /* The serial framework doesn't really use these
508 membase/mapbase fields for anything useful, but
509 it requires that they be something non-zero to
510 consider the port `valid', and also uses them
511 for informational purposes. */
512 port->membase = (void *)V850E_UART_BASE_ADDR (chan);
513 port->mapbase = V850E_UART_BASE_ADDR (chan);
514
515 /* The framework insists on knowing the uart's master
516 clock freq, though it doesn't seem to do anything
517 useful for us with it. We must make it at least
518 higher than (the maximum baud rate * 16), otherwise
519 the framework will puke during its internal
520 calculations, and force the baud rate to be 9600.
521 To be accurate though, just repeat the calculation
522 we use when actually setting the speed. */
523 port->uartclk = v850e_uart_max_clock() * 16;
524
525 uart_add_one_port (&v850e_uart_driver, port);
526 }
527 }
528
529 return rval;
530}
531
532static void __exit v850e_uart_exit (void)
533{
534 unsigned chan;
535
536 for (chan = 0; chan < V850E_UART_NUM_CHANNELS; chan++)
537 uart_remove_one_port (&v850e_uart_driver,
538 &v850e_uart_ports[chan]);
539
540 uart_unregister_driver (&v850e_uart_driver);
541}
542
543module_init (v850e_uart_init);
544module_exit (v850e_uart_exit);
545
546MODULE_AUTHOR ("Miles Bader");
547MODULE_DESCRIPTION ("NEC " V850E_UART_CHIP_NAME " on-chip UART");
548MODULE_LICENSE ("GPL");
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index bb6ce6bba32f..0573f3b5175e 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -318,7 +318,7 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status)
318 char flag; 318 char flag;
319 int max_count = RX_MAX_COUNT; 319 int max_count = RX_MAX_COUNT;
320 320
321 tty = port->info->tty; 321 tty = port->info->port.tty;
322 lsr = *status; 322 lsr = *status;
323 323
324 do { 324 do {
diff --git a/drivers/serial/zs.c b/drivers/serial/zs.c
index 65f1294fd27b..9e6a873f8203 100644
--- a/drivers/serial/zs.c
+++ b/drivers/serial/zs.c
@@ -602,7 +602,7 @@ static void zs_receive_chars(struct zs_port *zport)
602 uart_insert_char(uport, status, Rx_OVR, ch, flag); 602 uart_insert_char(uport, status, Rx_OVR, ch, flag);
603 } 603 }
604 604
605 tty_flip_buffer_push(uport->info->tty); 605 tty_flip_buffer_push(uport->info->port.tty);
606} 606}
607 607
608static void zs_raw_transmit_chars(struct zs_port *zport) 608static void zs_raw_transmit_chars(struct zs_port *zport)
@@ -787,7 +787,6 @@ static int zs_startup(struct uart_port *uport)
787 zport->regs[1] &= ~RxINT_MASK; 787 zport->regs[1] &= ~RxINT_MASK;
788 zport->regs[1] |= RxINT_ALL | TxINT_ENAB | EXT_INT_ENAB; 788 zport->regs[1] |= RxINT_ALL | TxINT_ENAB | EXT_INT_ENAB;
789 zport->regs[3] |= RxENABLE; 789 zport->regs[3] |= RxENABLE;
790 zport->regs[5] |= TxENAB;
791 zport->regs[15] |= BRKIE; 790 zport->regs[15] |= BRKIE;
792 write_zsreg(zport, R1, zport->regs[1]); 791 write_zsreg(zport, R1, zport->regs[1]);
793 write_zsreg(zport, R3, zport->regs[3]); 792 write_zsreg(zport, R3, zport->regs[3]);
@@ -814,7 +813,6 @@ static void zs_shutdown(struct uart_port *uport)
814 813
815 spin_lock_irqsave(&scc->zlock, flags); 814 spin_lock_irqsave(&scc->zlock, flags);
816 815
817 zport->regs[5] &= ~TxENAB;
818 zport->regs[3] &= ~RxENABLE; 816 zport->regs[3] &= ~RxENABLE;
819 write_zsreg(zport, R5, zport->regs[5]); 817 write_zsreg(zport, R5, zport->regs[5]);
820 write_zsreg(zport, R3, zport->regs[3]); 818 write_zsreg(zport, R3, zport->regs[3]);
@@ -959,6 +957,23 @@ static void zs_set_termios(struct uart_port *uport, struct ktermios *termios,
959 spin_unlock_irqrestore(&scc->zlock, flags); 957 spin_unlock_irqrestore(&scc->zlock, flags);
960} 958}
961 959
960/*
961 * Hack alert!
962 * Required solely so that the initial PROM-based console
963 * works undisturbed in parallel with this one.
964 */
965static void zs_pm(struct uart_port *uport, unsigned int state,
966 unsigned int oldstate)
967{
968 struct zs_port *zport = to_zport(uport);
969
970 if (state < 3)
971 zport->regs[5] |= TxENAB;
972 else
973 zport->regs[5] &= ~TxENAB;
974 write_zsreg(zport, R5, zport->regs[5]);
975}
976
962 977
963static const char *zs_type(struct uart_port *uport) 978static const char *zs_type(struct uart_port *uport)
964{ 979{
@@ -1041,6 +1056,7 @@ static struct uart_ops zs_ops = {
1041 .startup = zs_startup, 1056 .startup = zs_startup,
1042 .shutdown = zs_shutdown, 1057 .shutdown = zs_shutdown,
1043 .set_termios = zs_set_termios, 1058 .set_termios = zs_set_termios,
1059 .pm = zs_pm,
1044 .type = zs_type, 1060 .type = zs_type,
1045 .release_port = zs_release_port, 1061 .release_port = zs_release_port,
1046 .request_port = zs_request_port, 1062 .request_port = zs_request_port,
@@ -1190,6 +1206,7 @@ static int __init zs_console_setup(struct console *co, char *options)
1190 return ret; 1206 return ret;
1191 1207
1192 zs_reset(zport); 1208 zs_reset(zport);
1209 zs_pm(uport, 0, -1);
1193 1210
1194 if (options) 1211 if (options)
1195 uart_parse_options(options, &baud, &parity, &bits, &flow); 1212 uart_parse_options(options, &baud, &parity, &bits, &flow);