aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-08-07 04:55:03 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-08-07 04:55:03 -0400
commit4fb8af10d0fd09372d52966b76922b9e82bbc950 (patch)
treed240e4d40357583e3f3eb228dccf20122a5b31ed /drivers/serial
parentf44f82e8a20b98558486eb14497b2f71c78fa325 (diff)
parent64a99d2a8c3ed5c4e39f3ae1cc682aa8fd3977fc (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/8250.c4
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/bfin_5xx.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h11
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c66
-rw-r--r--drivers/serial/crisv10.c79
-rw-r--r--drivers/serial/crisv10.h3
-rw-r--r--drivers/serial/sh-sci.c17
-rw-r--r--drivers/serial/sh-sci.h40
-rw-r--r--drivers/serial/v850e_uart.c548
10 files changed, 157 insertions, 614 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index a97f1ae11f78..342e12fb1c25 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1885,7 +1885,7 @@ static int serial8250_startup(struct uart_port *port)
1885 * the interrupt is enabled. Delays are necessary to 1885 * the interrupt is enabled. Delays are necessary to
1886 * allow register changes to become visible. 1886 * allow register changes to become visible.
1887 */ 1887 */
1888 spin_lock(&up->port.lock); 1888 spin_lock_irqsave(&up->port.lock, flags);
1889 if (up->port.flags & UPF_SHARE_IRQ) 1889 if (up->port.flags & UPF_SHARE_IRQ)
1890 disable_irq_nosync(up->port.irq); 1890 disable_irq_nosync(up->port.irq);
1891 1891
@@ -1901,7 +1901,7 @@ static int serial8250_startup(struct uart_port *port)
1901 1901
1902 if (up->port.flags & UPF_SHARE_IRQ) 1902 if (up->port.flags & UPF_SHARE_IRQ)
1903 enable_irq(up->port.irq); 1903 enable_irq(up->port.irq);
1904 spin_unlock(&up->port.lock); 1904 spin_unlock_irqrestore(&up->port.lock, flags);
1905 1905
1906 /* 1906 /*
1907 * If the interrupt is not reasserted, setup a timer to 1907 * If the interrupt is not reasserted, setup a timer to
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 3a0bbbe17aa3..7e7383e890d8 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -42,7 +42,6 @@ obj-$(CONFIG_SERIAL_68328) += 68328serial.o
42obj-$(CONFIG_SERIAL_68360) += 68360serial.o 42obj-$(CONFIG_SERIAL_68360) += 68360serial.o
43obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o 43obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o
44obj-$(CONFIG_SERIAL_MCF) += mcf.o 44obj-$(CONFIG_SERIAL_MCF) += mcf.o
45obj-$(CONFIG_V850E_UART) += v850e_uart.o
46obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o 45obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
47obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o 46obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o
48obj-$(CONFIG_SERIAL_DZ) += dz.o 47obj-$(CONFIG_SERIAL_DZ) += dz.o
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 9d8543762a30..efcd44344fb1 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -817,7 +817,7 @@ static void bfin_serial_set_ldisc(struct uart_port *port)
817 if (line >= port->info->port.tty->driver->num) 817 if (line >= port->info->port.tty->driver->num)
818 return; 818 return;
819 819
820 switch (port->info->port.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/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index 5c76e0ae0582..7274b527a3c1 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -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,6 +77,7 @@ 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;
@@ -82,6 +92,7 @@ struct uart_cpm_port {
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
87extern int cpm_uart_nr; 98extern int cpm_uart_nr;
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index a4f86927a74b..25efca5a7a1f 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -43,6 +43,9 @@
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> 45#include <linux/of_platform.h>
46#include <linux/gpio.h>
47#include <linux/of_gpio.h>
48#include <linux/clk.h>
46 49
47#include <asm/io.h> 50#include <asm/io.h>
48#include <asm/irq.h> 51#include <asm/irq.h>
@@ -96,13 +99,41 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)
96 99
97static 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)
98{ 101{
99 /* 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));
100} 109}
101 110
102static unsigned int cpm_uart_get_mctrl(struct uart_port *port) 111static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
103{ 112{
104 /* Whee. Do nothing. */ 113 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
105 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;
106} 137}
107 138
108/* 139/*
@@ -566,7 +597,10 @@ static void cpm_uart_set_termios(struct uart_port *port,
566 out_be16(&sccp->scc_psmr, (sbits << 12) | scval); 597 out_be16(&sccp->scc_psmr, (sbits << 12) | scval);
567 } 598 }
568 599
569 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);
570 spin_unlock_irqrestore(&port->lock, flags); 604 spin_unlock_irqrestore(&port->lock, flags);
571} 605}
572 606
@@ -991,14 +1025,23 @@ static int cpm_uart_init_port(struct device_node *np,
991 void __iomem *mem, *pram; 1025 void __iomem *mem, *pram;
992 int len; 1026 int len;
993 int ret; 1027 int ret;
1028 int i;
994 1029
995 data = of_get_property(np, "fsl,cpm-brg", &len); 1030 data = of_get_property(np, "clock", NULL);
996 if (!data || len != 4) { 1031 if (data) {
997 printk(KERN_ERR "CPM UART %s has no/invalid " 1032 struct clk *clk = clk_get(NULL, (const char*)data);
998 "fsl,cpm-brg property.\n", np->name); 1033 if (!IS_ERR(clk))
999 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;
1000 } 1044 }
1001 pinfo->brg = *data;
1002 1045
1003 data = of_get_property(np, "fsl,cpm-command", &len); 1046 data = of_get_property(np, "fsl,cpm-command", &len);
1004 if (!data || len != 4) { 1047 if (!data || len != 4) {
@@ -1050,6 +1093,9 @@ static int cpm_uart_init_port(struct device_node *np,
1050 goto out_pram; 1093 goto out_pram;
1051 } 1094 }
1052 1095
1096 for (i = 0; i < NUM_GPIOS; i++)
1097 pinfo->gpios[i] = of_get_gpio(np, i);
1098
1053 return cpm_uart_request_port(&pinfo->port); 1099 return cpm_uart_request_port(&pinfo->port);
1054 1100
1055out_pram: 1101out_pram:
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 8249ac490559..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 */
@@ -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}
@@ -1490,7 +1490,7 @@ rs_stop(struct tty_struct *tty)
1490 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 1490 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
1491 } 1491 }
1492 1492
1493 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1493 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
1494 local_irq_restore(flags); 1494 local_irq_restore(flags);
1495 } 1495 }
1496} 1496}
@@ -1513,7 +1513,7 @@ rs_start(struct tty_struct *tty)
1513 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 1513 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
1514 } 1514 }
1515 1515
1516 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1516 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
1517 if (!info->uses_dma_out && 1517 if (!info->uses_dma_out &&
1518 info->xmit.head != info->xmit.tail && info->xmit.buf) 1518 info->xmit.head != info->xmit.tail && info->xmit.buf)
1519 e100_enable_serial_tx_ready_irq(info); 1519 e100_enable_serial_tx_ready_irq(info);
@@ -1888,7 +1888,7 @@ static void receive_chars_dma(struct e100_serial *info)
1888 handle_all_descr_data(info); 1888 handle_all_descr_data(info);
1889 1889
1890 /* Read the status register to detect errors */ 1890 /* Read the status register to detect errors */
1891 rstat = info->port[REG_STATUS]; 1891 rstat = info->ioport[REG_STATUS];
1892 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { 1892 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
1893 DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat)); 1893 DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat));
1894 } 1894 }
@@ -1897,7 +1897,7 @@ static void receive_chars_dma(struct e100_serial *info)
1897 /* 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
1898 * data_in field 1898 * data_in field
1899 */ 1899 */
1900 unsigned char data = info->port[REG_DATA]; 1900 unsigned char data = info->ioport[REG_DATA];
1901 1901
1902 PROCSTAT(ser_stat[info->line].errors_cnt++); 1902 PROCSTAT(ser_stat[info->line].errors_cnt++);
1903 DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n", 1903 DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n",
@@ -2077,7 +2077,7 @@ static int force_eop_if_needed(struct e100_serial *info)
2077 /* We check data_avail bit to determine if data has 2077 /* We check data_avail bit to determine if data has
2078 * arrived since last time 2078 * arrived since last time
2079 */ 2079 */
2080 unsigned char rstat = info->port[REG_STATUS]; 2080 unsigned char rstat = info->ioport[REG_STATUS];
2081 2081
2082 /* error or datavail? */ 2082 /* error or datavail? */
2083 if (rstat & SER_ERROR_MASK) { 2083 if (rstat & SER_ERROR_MASK) {
@@ -2096,7 +2096,7 @@ static int force_eop_if_needed(struct e100_serial *info)
2096 TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n", 2096 TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n",
2097 rstat | (info->line << 8))); 2097 rstat | (info->line << 8)));
2098 /* Read data to clear status flags */ 2098 /* Read data to clear status flags */
2099 (void)info->port[REG_DATA]; 2099 (void)info->ioport[REG_DATA];
2100 2100
2101 info->forced_eop = 0; 2101 info->forced_eop = 0;
2102 START_FLUSH_FAST_TIMER(info, "magic"); 2102 START_FLUSH_FAST_TIMER(info, "magic");
@@ -2296,7 +2296,7 @@ struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2296 } 2296 }
2297 2297
2298 /* Read data and status at the same time */ 2298 /* Read data and status at the same time */
2299 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2299 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]);
2300more_data: 2300more_data:
2301 if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) { 2301 if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) {
2302 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); 2302 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
@@ -2391,7 +2391,7 @@ more_data:
2391 2391
2392 2392
2393 info->icount.rx++; 2393 info->icount.rx++;
2394 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2394 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]);
2395 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) { 2395 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
2396 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));
2397 goto more_data; 2397 goto more_data;
@@ -2413,7 +2413,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2413 return handle_ser_rx_interrupt_no_dma(info); 2413 return handle_ser_rx_interrupt_no_dma(info);
2414 } 2414 }
2415 /* DMA is used */ 2415 /* DMA is used */
2416 rstat = info->port[REG_STATUS]; 2416 rstat = info->ioport[REG_STATUS];
2417 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { 2417 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
2418 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); 2418 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
2419 } 2419 }
@@ -2426,7 +2426,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2426 /* 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
2427 * data_in field 2427 * data_in field
2428 */ 2428 */
2429 data = info->port[REG_DATA]; 2429 data = info->ioport[REG_DATA];
2430 DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data)); 2430 DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data));
2431 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));
2432 if (!data && (rstat & SER_FRAMING_ERR_MASK)) { 2432 if (!data && (rstat & SER_FRAMING_ERR_MASK)) {
@@ -2528,10 +2528,10 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2528 unsigned char rstat; 2528 unsigned char rstat;
2529 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));
2530 local_irq_save(flags); 2530 local_irq_save(flags);
2531 rstat = info->port[REG_STATUS]; 2531 rstat = info->ioport[REG_STATUS];
2532 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2532 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2533 2533
2534 info->port[REG_TR_DATA] = info->x_char; 2534 info->ioport[REG_TR_DATA] = info->x_char;
2535 info->icount.tx++; 2535 info->icount.tx++;
2536 info->x_char = 0; 2536 info->x_char = 0;
2537 /* We must enable since it is disabled in ser_interrupt */ 2537 /* We must enable since it is disabled in ser_interrupt */
@@ -2545,7 +2545,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2545 /* We only use normal tx interrupt when sending x_char */ 2545 /* We only use normal tx interrupt when sending x_char */
2546 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0)); 2546 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0));
2547 local_irq_save(flags); 2547 local_irq_save(flags);
2548 rstat = info->port[REG_STATUS]; 2548 rstat = info->ioport[REG_STATUS];
2549 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2549 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2550 e100_disable_serial_tx_ready_irq(info); 2550 e100_disable_serial_tx_ready_irq(info);
2551 if (info->port.tty->stopped) 2551 if (info->port.tty->stopped)
@@ -2573,7 +2573,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2573 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]));
2574 /* Send a byte, rs485 timing is critical so turn of ints */ 2574 /* Send a byte, rs485 timing is critical so turn of ints */
2575 local_irq_save(flags); 2575 local_irq_save(flags);
2576 info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail]; 2576 info->ioport[REG_TR_DATA] = info->xmit.buf[info->xmit.tail];
2577 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1); 2577 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
2578 info->icount.tx++; 2578 info->icount.tx++;
2579 if (info->xmit.head == info->xmit.tail) { 2579 if (info->xmit.head == info->xmit.tail) {
@@ -2848,7 +2848,7 @@ startup(struct e100_serial * info)
2848 2848
2849 /* dummy read to reset any serial errors */ 2849 /* dummy read to reset any serial errors */
2850 2850
2851 (void)info->port[REG_DATA]; 2851 (void)info->ioport[REG_DATA];
2852 2852
2853 /* enable the interrupts */ 2853 /* enable the interrupts */
2854 if (info->uses_dma_out) 2854 if (info->uses_dma_out)
@@ -2897,7 +2897,7 @@ shutdown(struct e100_serial * info)
2897 /* shut down the transmitter and receiver */ 2897 /* shut down the transmitter and receiver */
2898 DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line)); 2898 DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line));
2899 e100_disable_rx(info); 2899 e100_disable_rx(info);
2900 info->port[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40); 2900 info->ioport[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40);
2901 2901
2902 /* disable interrupts, reset dma channels */ 2902 /* disable interrupts, reset dma channels */
2903 if (info->uses_dma_in) { 2903 if (info->uses_dma_in) {
@@ -2968,7 +2968,7 @@ change_speed(struct e100_serial *info)
2968 2968
2969 if (!info->port.tty || !info->port.tty->termios) 2969 if (!info->port.tty || !info->port.tty->termios)
2970 return; 2970 return;
2971 if (!info->port) 2971 if (!info->ioport)
2972 return; 2972 return;
2973 2973
2974 cflag = info->port.tty->termios->c_cflag; 2974 cflag = info->port.tty->termios->c_cflag;
@@ -3037,7 +3037,7 @@ change_speed(struct e100_serial *info)
3037 3037
3038 info->baud = cflag_to_baud(cflag); 3038 info->baud = cflag_to_baud(cflag);
3039#ifndef CONFIG_SVINTO_SIM 3039#ifndef CONFIG_SVINTO_SIM
3040 info->port[REG_BAUD] = cflag_to_etrax_baud(cflag); 3040 info->ioport[REG_BAUD] = cflag_to_etrax_baud(cflag);
3041#endif /* CONFIG_SVINTO_SIM */ 3041#endif /* CONFIG_SVINTO_SIM */
3042 } 3042 }
3043 3043
@@ -3097,8 +3097,8 @@ change_speed(struct e100_serial *info)
3097 3097
3098 /* actually write the control regs to the hardware */ 3098 /* actually write the control regs to the hardware */
3099 3099
3100 info->port[REG_TR_CTRL] = info->tx_ctrl; 3100 info->ioport[REG_TR_CTRL] = info->tx_ctrl;
3101 info->port[REG_REC_CTRL] = info->rx_ctrl; 3101 info->ioport[REG_REC_CTRL] = info->rx_ctrl;
3102 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty)); 3102 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty));
3103 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable); 3103 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
3104 if (info->port.tty->termios->c_iflag & IXON ) { 3104 if (info->port.tty->termios->c_iflag & IXON ) {
@@ -3107,7 +3107,7 @@ change_speed(struct e100_serial *info)
3107 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 3107 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
3108 } 3108 }
3109 3109
3110 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 3110 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
3111 local_irq_restore(flags); 3111 local_irq_restore(flags);
3112#endif /* !CONFIG_SVINTO_SIM */ 3112#endif /* !CONFIG_SVINTO_SIM */
3113 3113
@@ -3156,7 +3156,7 @@ static int rs_raw_write(struct tty_struct *tty,
3156#ifdef SERIAL_DEBUG_DATA 3156#ifdef SERIAL_DEBUG_DATA
3157 if (info->line == SERIAL_DEBUG_LINE) 3157 if (info->line == SERIAL_DEBUG_LINE)
3158 printk("rs_raw_write (%d), status %d\n", 3158 printk("rs_raw_write (%d), status %d\n",
3159 count, info->port[REG_STATUS]); 3159 count, info->ioport[REG_STATUS]);
3160#endif 3160#endif
3161 3161
3162#ifdef CONFIG_SVINTO_SIM 3162#ifdef CONFIG_SVINTO_SIM
@@ -3427,7 +3427,7 @@ get_serial_info(struct e100_serial * info,
3427 memset(&tmp, 0, sizeof(tmp)); 3427 memset(&tmp, 0, sizeof(tmp));
3428 tmp.type = info->type; 3428 tmp.type = info->type;
3429 tmp.line = info->line; 3429 tmp.line = info->line;
3430 tmp.port = (int)info->port; 3430 tmp.port = (int)info->ioport;
3431 tmp.irq = info->irq; 3431 tmp.irq = info->irq;
3432 tmp.flags = info->flags; 3432 tmp.flags = info->flags;
3433 tmp.baud_base = info->baud_base; 3433 tmp.baud_base = info->baud_base;
@@ -3557,14 +3557,14 @@ char *get_control_state_str(int MLines, char *s)
3557} 3557}
3558#endif 3558#endif
3559 3559
3560static void 3560static int
3561rs_break(struct tty_struct *tty, int break_state) 3561rs_break(struct tty_struct *tty, int break_state)
3562{ 3562{
3563 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3563 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3564 unsigned long flags; 3564 unsigned long flags;
3565 3565
3566 if (!info->port) 3566 if (!info->ioport)
3567 return; 3567 return -EIO;
3568 3568
3569 local_irq_save(flags); 3569 local_irq_save(flags);
3570 if (break_state == -1) { 3570 if (break_state == -1) {
@@ -3575,8 +3575,9 @@ rs_break(struct tty_struct *tty, int break_state)
3575 /* Set bit 7 (txd) and 6 (tr_enable) */ 3575 /* Set bit 7 (txd) and 6 (tr_enable) */
3576 info->tx_ctrl |= (0x80 | 0x40); 3576 info->tx_ctrl |= (0x80 | 0x40);
3577 } 3577 }
3578 info->port[REG_TR_CTRL] = info->tx_ctrl; 3578 info->ioport[REG_TR_CTRL] = info->tx_ctrl;
3579 local_irq_restore(flags); 3579 local_irq_restore(flags);
3580 return 0;
3580} 3581}
3581 3582
3582static int 3583static int
@@ -4231,9 +4232,9 @@ static int line_info(char *buf, struct e100_serial *info)
4231 unsigned long tmp; 4232 unsigned long tmp;
4232 4233
4233 ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d", 4234 ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
4234 info->line, (unsigned long)info->port, info->irq); 4235 info->line, (unsigned long)info->ioport, info->irq);
4235 4236
4236 if (!info->port || (info->type == PORT_UNKNOWN)) { 4237 if (!info->ioport || (info->type == PORT_UNKNOWN)) {
4237 ret += sprintf(buf+ret, "\n"); 4238 ret += sprintf(buf+ret, "\n");
4238 return ret; 4239 return ret;
4239 } 4240 }
@@ -4281,7 +4282,7 @@ static int line_info(char *buf, struct e100_serial *info)
4281 } 4282 }
4282 4283
4283 { 4284 {
4284 unsigned char rstat = info->port[REG_STATUS]; 4285 unsigned char rstat = info->ioport[REG_STATUS];
4285 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) 4286 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
4286 ret += sprintf(buf+ret, " xoff_detect:1"); 4287 ret += sprintf(buf+ret, " xoff_detect:1");
4287 } 4288 }
@@ -4502,7 +4503,7 @@ rs_init(void)
4502 4503
4503 if (info->enabled) { 4504 if (info->enabled) {
4504 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",
4505 serial_driver->name, info->line, (unsigned int)info->port); 4506 serial_driver->name, info->line, (unsigned int)info->ioport);
4506 } 4507 }
4507 } 4508 }
4508#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/sh-sci.c b/drivers/serial/sh-sci.c
index 208e42ba9455..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{
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/v850e_uart.c b/drivers/serial/v850e_uart.c
deleted file mode 100644
index 5acf061b6cd2..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->port.tty, ch, ch_stat);
304 tty_schedule_flip (port->info->port.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");