aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/68328serial.c9
-rw-r--r--drivers/tty/serial/8250/8250.h7
-rw-r--r--drivers/tty/serial/8250/8250_core.c18
-rw-r--r--drivers/tty/serial/8250/8250_dma.c52
-rw-r--r--drivers/tty/serial/8250/8250_dw.c194
-rw-r--r--drivers/tty/serial/amba-pl011.c181
-rw-r--r--drivers/tty/serial/arc_uart.c2
-rw-r--r--drivers/tty/serial/bfin_uart.c23
-rw-r--r--drivers/tty/serial/crisv10.c168
-rw-r--r--drivers/tty/serial/crisv10.h14
-rw-r--r--drivers/tty/serial/icom.c3
-rw-r--r--drivers/tty/serial/ifx6x60.c80
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c6
-rw-r--r--drivers/tty/serial/max3100.c24
-rw-r--r--drivers/tty/serial/max310x.c24
-rw-r--r--drivers/tty/serial/mrst_max3110.c19
-rw-r--r--drivers/tty/serial/msm_serial_hs.c2
-rw-r--r--drivers/tty/serial/msm_smd_tty.c14
-rw-r--r--drivers/tty/serial/mxs-auart.c6
-rw-r--r--drivers/tty/serial/of_serial.c17
-rw-r--r--drivers/tty/serial/pch_uart.c103
-rw-r--r--drivers/tty/serial/samsung.c63
-rw-r--r--drivers/tty/serial/samsung.h4
-rw-r--r--drivers/tty/serial/sccnxp.c23
-rw-r--r--drivers/tty/serial/serial-tegra.c9
-rw-r--r--drivers/tty/serial/serial_core.c4
-rw-r--r--drivers/tty/serial/sh-sci.h2
-rw-r--r--drivers/tty/serial/sirfsoc_uart.c2
-rw-r--r--drivers/tty/serial/sunsab.c2
-rw-r--r--drivers/tty/serial/sunzilog.c2
-rw-r--r--drivers/tty/serial/vt8500_serial.c7
-rw-r--r--drivers/tty/serial/xilinx_uartps.c3
32 files changed, 608 insertions, 479 deletions
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 49399470794d..ef2e08e9b590 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -630,8 +630,7 @@ static void rs_flush_chars(struct tty_struct *tty)
630 /* Enable transmitter */ 630 /* Enable transmitter */
631 local_irq_save(flags); 631 local_irq_save(flags);
632 632
633 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 633 if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) {
634 !info->xmit_buf) {
635 local_irq_restore(flags); 634 local_irq_restore(flags);
636 return; 635 return;
637 } 636 }
@@ -697,7 +696,7 @@ static int rs_write(struct tty_struct * tty,
697 total += c; 696 total += c;
698 } 697 }
699 698
700 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 699 if (info->xmit_cnt && !tty->stopped) {
701 /* Enable transmitter */ 700 /* Enable transmitter */
702 local_irq_disable(); 701 local_irq_disable();
703#ifndef USE_INTS 702#ifndef USE_INTS
@@ -978,10 +977,8 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
978 change_speed(info, tty); 977 change_speed(info, tty);
979 978
980 if ((old_termios->c_cflag & CRTSCTS) && 979 if ((old_termios->c_cflag & CRTSCTS) &&
981 !(tty->termios.c_cflag & CRTSCTS)) { 980 !(tty->termios.c_cflag & CRTSCTS))
982 tty->hw_stopped = 0;
983 rs_start(tty); 981 rs_start(tty);
984 }
985 982
986} 983}
987 984
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 34eb676916fe..1ebf8538b4fa 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -117,13 +117,6 @@ static inline void serial_dl_write(struct uart_8250_port *up, int value)
117 * is cleared, the machine locks up with endless interrupts. 117 * is cleared, the machine locks up with endless interrupts.
118 */ 118 */
119#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1) 119#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
120#elif defined(CONFIG_SBC8560)
121/*
122 * WindRiver did something similarly broken on their SBC8560 board. The
123 * UART tristates its IRQ output while OUT2 is clear, but they pulled
124 * the interrupt line _up_ instead of down, so if we register the IRQ
125 * while the UART is in that state, we die in an IRQ storm. */
126#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
127#else 120#else
128#define ALPHA_KLUDGE_MCR 0 121#define ALPHA_KLUDGE_MCR 0
129#endif 122#endif
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 35f9c96aada9..46528d57be72 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2755,7 +2755,7 @@ static void __init serial8250_isa_init_ports(void)
2755 if (nr_uarts > UART_NR) 2755 if (nr_uarts > UART_NR)
2756 nr_uarts = UART_NR; 2756 nr_uarts = UART_NR;
2757 2757
2758 for (i = 0; i < nr_uarts; i++) { 2758 for (i = 0; i < UART_NR; i++) {
2759 struct uart_8250_port *up = &serial8250_ports[i]; 2759 struct uart_8250_port *up = &serial8250_ports[i];
2760 struct uart_port *port = &up->port; 2760 struct uart_port *port = &up->port;
2761 2761
@@ -2916,7 +2916,7 @@ static int __init serial8250_console_setup(struct console *co, char *options)
2916 * if so, search for the first available port that does have 2916 * if so, search for the first available port that does have
2917 * console support. 2917 * console support.
2918 */ 2918 */
2919 if (co->index >= nr_uarts) 2919 if (co->index >= UART_NR)
2920 co->index = 0; 2920 co->index = 0;
2921 port = &serial8250_ports[co->index].port; 2921 port = &serial8250_ports[co->index].port;
2922 if (!port->iobase && !port->membase) 2922 if (!port->iobase && !port->membase)
@@ -2957,7 +2957,7 @@ int serial8250_find_port(struct uart_port *p)
2957 int line; 2957 int line;
2958 struct uart_port *port; 2958 struct uart_port *port;
2959 2959
2960 for (line = 0; line < nr_uarts; line++) { 2960 for (line = 0; line < UART_NR; line++) {
2961 port = &serial8250_ports[line].port; 2961 port = &serial8250_ports[line].port;
2962 if (uart_match_port(p, port)) 2962 if (uart_match_port(p, port))
2963 return line; 2963 return line;
@@ -3110,7 +3110,7 @@ static int serial8250_remove(struct platform_device *dev)
3110{ 3110{
3111 int i; 3111 int i;
3112 3112
3113 for (i = 0; i < nr_uarts; i++) { 3113 for (i = 0; i < UART_NR; i++) {
3114 struct uart_8250_port *up = &serial8250_ports[i]; 3114 struct uart_8250_port *up = &serial8250_ports[i];
3115 3115
3116 if (up->port.dev == &dev->dev) 3116 if (up->port.dev == &dev->dev)
@@ -3178,7 +3178,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
3178 /* 3178 /*
3179 * First, find a port entry which matches. 3179 * First, find a port entry which matches.
3180 */ 3180 */
3181 for (i = 0; i < nr_uarts; i++) 3181 for (i = 0; i < UART_NR; i++)
3182 if (uart_match_port(&serial8250_ports[i].port, port)) 3182 if (uart_match_port(&serial8250_ports[i].port, port))
3183 return &serial8250_ports[i]; 3183 return &serial8250_ports[i];
3184 3184
@@ -3187,7 +3187,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
3187 * free entry. We look for one which hasn't been previously 3187 * free entry. We look for one which hasn't been previously
3188 * used (indicated by zero iobase). 3188 * used (indicated by zero iobase).
3189 */ 3189 */
3190 for (i = 0; i < nr_uarts; i++) 3190 for (i = 0; i < UART_NR; i++)
3191 if (serial8250_ports[i].port.type == PORT_UNKNOWN && 3191 if (serial8250_ports[i].port.type == PORT_UNKNOWN &&
3192 serial8250_ports[i].port.iobase == 0) 3192 serial8250_ports[i].port.iobase == 0)
3193 return &serial8250_ports[i]; 3193 return &serial8250_ports[i];
@@ -3196,7 +3196,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
3196 * That also failed. Last resort is to find any entry which 3196 * That also failed. Last resort is to find any entry which
3197 * doesn't have a real port associated with it. 3197 * doesn't have a real port associated with it.
3198 */ 3198 */
3199 for (i = 0; i < nr_uarts; i++) 3199 for (i = 0; i < UART_NR; i++)
3200 if (serial8250_ports[i].port.type == PORT_UNKNOWN) 3200 if (serial8250_ports[i].port.type == PORT_UNKNOWN)
3201 return &serial8250_ports[i]; 3201 return &serial8250_ports[i];
3202 3202
@@ -3247,6 +3247,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
3247 uart->tx_loadsz = up->tx_loadsz; 3247 uart->tx_loadsz = up->tx_loadsz;
3248 uart->capabilities = up->capabilities; 3248 uart->capabilities = up->capabilities;
3249 3249
3250 /* Take tx_loadsz from fifosize if it wasn't set separately */
3251 if (uart->port.fifosize && !uart->tx_loadsz)
3252 uart->tx_loadsz = uart->port.fifosize;
3253
3250 if (up->port.dev) 3254 if (up->port.dev)
3251 uart->port.dev = up->port.dev; 3255 uart->port.dev = up->port.dev;
3252 3256
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index b9f7fd28112e..7046769608d4 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -33,10 +33,8 @@ static void __dma_tx_complete(void *param)
33 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 33 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
34 uart_write_wakeup(&p->port); 34 uart_write_wakeup(&p->port);
35 35
36 if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) { 36 if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port))
37 serial8250_tx_dma(p); 37 serial8250_tx_dma(p);
38 uart_write_wakeup(&p->port);
39 }
40} 38}
41 39
42static void __dma_rx_complete(void *param) 40static void __dma_rx_complete(void *param)
@@ -67,12 +65,11 @@ int serial8250_tx_dma(struct uart_8250_port *p)
67 struct circ_buf *xmit = &p->port.state->xmit; 65 struct circ_buf *xmit = &p->port.state->xmit;
68 struct dma_async_tx_descriptor *desc; 66 struct dma_async_tx_descriptor *desc;
69 67
70 if (dma->tx_running) 68 if (uart_tx_stopped(&p->port) || dma->tx_running ||
71 return -EBUSY; 69 uart_circ_empty(xmit))
70 return 0;
72 71
73 dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 72 dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
74 if (!dma->tx_size)
75 return -EINVAL;
76 73
77 desc = dmaengine_prep_slave_single(dma->txchan, 74 desc = dmaengine_prep_slave_single(dma->txchan,
78 dma->tx_addr + xmit->tail, 75 dma->tx_addr + xmit->tail,
@@ -104,20 +101,29 @@ int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
104 struct dma_tx_state state; 101 struct dma_tx_state state;
105 int dma_status; 102 int dma_status;
106 103
107 /* 104 dma_status = dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
108 * If RCVR FIFO trigger level was not reached, complete the transfer and 105
109 * let 8250.c copy the remaining data. 106 switch (iir & 0x3f) {
110 */ 107 case UART_IIR_RLSI:
111 if ((iir & 0x3f) == UART_IIR_RX_TIMEOUT) { 108 /* 8250_core handles errors and break interrupts */
112 dma_status = dmaengine_tx_status(dma->rxchan, dma->rx_cookie, 109 return -EIO;
113 &state); 110 case UART_IIR_RX_TIMEOUT:
111 /*
112 * If RCVR FIFO trigger level was not reached, complete the
113 * transfer and let 8250_core copy the remaining data.
114 */
114 if (dma_status == DMA_IN_PROGRESS) { 115 if (dma_status == DMA_IN_PROGRESS) {
115 dmaengine_pause(dma->rxchan); 116 dmaengine_pause(dma->rxchan);
116 __dma_rx_complete(p); 117 __dma_rx_complete(p);
117 } 118 }
118 return -ETIMEDOUT; 119 return -ETIMEDOUT;
120 default:
121 break;
119 } 122 }
120 123
124 if (dma_status)
125 return 0;
126
121 desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, 127 desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
122 dma->rx_size, DMA_DEV_TO_MEM, 128 dma->rx_size, DMA_DEV_TO_MEM,
123 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 129 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
@@ -143,21 +149,31 @@ int serial8250_request_dma(struct uart_8250_port *p)
143 struct uart_8250_dma *dma = p->dma; 149 struct uart_8250_dma *dma = p->dma;
144 dma_cap_mask_t mask; 150 dma_cap_mask_t mask;
145 151
146 dma->rxconf.src_addr = p->port.mapbase + UART_RX; 152 /* Default slave configuration parameters */
147 dma->txconf.dst_addr = p->port.mapbase + UART_TX; 153 dma->rxconf.direction = DMA_DEV_TO_MEM;
154 dma->rxconf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
155 dma->rxconf.src_addr = p->port.mapbase + UART_RX;
156
157 dma->txconf.direction = DMA_MEM_TO_DEV;
158 dma->txconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
159 dma->txconf.dst_addr = p->port.mapbase + UART_TX;
148 160
149 dma_cap_zero(mask); 161 dma_cap_zero(mask);
150 dma_cap_set(DMA_SLAVE, mask); 162 dma_cap_set(DMA_SLAVE, mask);
151 163
152 /* Get a channel for RX */ 164 /* Get a channel for RX */
153 dma->rxchan = dma_request_channel(mask, dma->fn, dma->rx_param); 165 dma->rxchan = dma_request_slave_channel_compat(mask,
166 dma->fn, dma->rx_param,
167 p->port.dev, "rx");
154 if (!dma->rxchan) 168 if (!dma->rxchan)
155 return -ENODEV; 169 return -ENODEV;
156 170
157 dmaengine_slave_config(dma->rxchan, &dma->rxconf); 171 dmaengine_slave_config(dma->rxchan, &dma->rxconf);
158 172
159 /* Get a channel for TX */ 173 /* Get a channel for TX */
160 dma->txchan = dma_request_channel(mask, dma->fn, dma->tx_param); 174 dma->txchan = dma_request_slave_channel_compat(mask,
175 dma->fn, dma->tx_param,
176 p->port.dev, "tx");
161 if (!dma->txchan) { 177 if (!dma->txchan) {
162 dma_release_channel(dma->rxchan); 178 dma_release_channel(dma->rxchan);
163 return -ENODEV; 179 return -ENODEV;
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index db0e66f6dd0e..beaa283f5cc6 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -26,6 +26,8 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/acpi.h> 28#include <linux/acpi.h>
29#include <linux/clk.h>
30#include <linux/pm_runtime.h>
29 31
30#include "8250.h" 32#include "8250.h"
31 33
@@ -34,9 +36,6 @@
34#define DW_UART_CPR 0xf4 /* Component Parameter Register */ 36#define DW_UART_CPR 0xf4 /* Component Parameter Register */
35#define DW_UART_UCV 0xf8 /* UART Component Version */ 37#define DW_UART_UCV 0xf8 /* UART Component Version */
36 38
37/* Intel Low Power Subsystem specific */
38#define LPSS_PRV_CLOCK_PARAMS 0x800
39
40/* Component Parameter Register bits */ 39/* Component Parameter Register bits */
41#define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) 40#define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0)
42#define DW_UART_CPR_AFCE_MODE (1 << 4) 41#define DW_UART_CPR_AFCE_MODE (1 << 4)
@@ -55,8 +54,9 @@
55 54
56 55
57struct dw8250_data { 56struct dw8250_data {
58 int last_lcr; 57 int last_lcr;
59 int line; 58 int line;
59 struct clk *clk;
60}; 60};
61 61
62static void dw8250_serial_out(struct uart_port *p, int offset, int value) 62static void dw8250_serial_out(struct uart_port *p, int offset, int value)
@@ -113,6 +113,18 @@ static int dw8250_handle_irq(struct uart_port *p)
113 return 0; 113 return 0;
114} 114}
115 115
116static void
117dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
118{
119 if (!state)
120 pm_runtime_get_sync(port->dev);
121
122 serial8250_do_pm(port, state, old);
123
124 if (state)
125 pm_runtime_put_sync_suspend(port->dev);
126}
127
116static int dw8250_probe_of(struct uart_port *p) 128static int dw8250_probe_of(struct uart_port *p)
117{ 129{
118 struct device_node *np = p->dev->of_node; 130 struct device_node *np = p->dev->of_node;
@@ -136,8 +148,13 @@ static int dw8250_probe_of(struct uart_port *p)
136 if (!of_property_read_u32(np, "reg-shift", &val)) 148 if (!of_property_read_u32(np, "reg-shift", &val))
137 p->regshift = val; 149 p->regshift = val;
138 150
151 /* clock got configured through clk api, all done */
152 if (p->uartclk)
153 return 0;
154
155 /* try to find out clock frequency from DT as fallback */
139 if (of_property_read_u32(np, "clock-frequency", &val)) { 156 if (of_property_read_u32(np, "clock-frequency", &val)) {
140 dev_err(p->dev, "no clock-frequency property set\n"); 157 dev_err(p->dev, "clk or clock-frequency not defined\n");
141 return -EINVAL; 158 return -EINVAL;
142 } 159 }
143 p->uartclk = val; 160 p->uartclk = val;
@@ -146,67 +163,10 @@ static int dw8250_probe_of(struct uart_port *p)
146} 163}
147 164
148#ifdef CONFIG_ACPI 165#ifdef CONFIG_ACPI
149static bool dw8250_acpi_dma_filter(struct dma_chan *chan, void *parm) 166static int dw8250_probe_acpi(struct uart_8250_port *up)
150{
151 return chan->chan_id == *(int *)parm;
152}
153
154static acpi_status
155dw8250_acpi_walk_resource(struct acpi_resource *res, void *data)
156{
157 struct uart_port *p = data;
158 struct uart_8250_port *port;
159 struct uart_8250_dma *dma;
160 struct acpi_resource_fixed_dma *fixed_dma;
161 struct dma_slave_config *slave;
162
163 port = container_of(p, struct uart_8250_port, port);
164
165 switch (res->type) {
166 case ACPI_RESOURCE_TYPE_FIXED_DMA:
167 fixed_dma = &res->data.fixed_dma;
168
169 /* TX comes first */
170 if (!port->dma) {
171 dma = devm_kzalloc(p->dev, sizeof(*dma), GFP_KERNEL);
172 if (!dma)
173 return AE_NO_MEMORY;
174
175 port->dma = dma;
176 slave = &dma->txconf;
177
178 slave->direction = DMA_MEM_TO_DEV;
179 slave->dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
180 slave->slave_id = fixed_dma->request_lines;
181 slave->dst_maxburst = port->tx_loadsz / 4;
182
183 dma->tx_chan_id = fixed_dma->channels;
184 dma->tx_param = &dma->tx_chan_id;
185 dma->fn = dw8250_acpi_dma_filter;
186 } else {
187 dma = port->dma;
188 slave = &dma->rxconf;
189
190 slave->direction = DMA_DEV_TO_MEM;
191 slave->src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
192 slave->slave_id = fixed_dma->request_lines;
193 slave->src_maxburst = p->fifosize / 4;
194
195 dma->rx_chan_id = fixed_dma->channels;
196 dma->rx_param = &dma->rx_chan_id;
197 }
198
199 break;
200 }
201
202 return AE_OK;
203}
204
205static int dw8250_probe_acpi(struct uart_port *p)
206{ 167{
207 const struct acpi_device_id *id; 168 const struct acpi_device_id *id;
208 acpi_status status; 169 struct uart_port *p = &up->port;
209 u32 reg;
210 170
211 id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); 171 id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev);
212 if (!id) 172 if (!id)
@@ -216,26 +176,21 @@ static int dw8250_probe_acpi(struct uart_port *p)
216 p->serial_in = dw8250_serial_in32; 176 p->serial_in = dw8250_serial_in32;
217 p->serial_out = dw8250_serial_out32; 177 p->serial_out = dw8250_serial_out32;
218 p->regshift = 2; 178 p->regshift = 2;
219 p->uartclk = (unsigned int)id->driver_data;
220 179
221 status = acpi_walk_resources(ACPI_HANDLE(p->dev), METHOD_NAME__CRS, 180 if (!p->uartclk)
222 dw8250_acpi_walk_resource, p); 181 p->uartclk = (unsigned int)id->driver_data;
223 if (ACPI_FAILURE(status)) {
224 dev_err_ratelimited(p->dev, "%s failed \"%s\"\n", __func__,
225 acpi_format_exception(status));
226 return -ENODEV;
227 }
228 182
229 /* Fix Haswell issue where the clocks do not get enabled */ 183 up->dma = devm_kzalloc(p->dev, sizeof(*up->dma), GFP_KERNEL);
230 if (!strcmp(id->id, "INT33C4") || !strcmp(id->id, "INT33C5")) { 184 if (!up->dma)
231 reg = readl(p->membase + LPSS_PRV_CLOCK_PARAMS); 185 return -ENOMEM;
232 writel(reg | 1, p->membase + LPSS_PRV_CLOCK_PARAMS); 186
233 } 187 up->dma->rxconf.src_maxburst = p->fifosize / 4;
188 up->dma->txconf.dst_maxburst = p->fifosize / 4;
234 189
235 return 0; 190 return 0;
236} 191}
237#else 192#else
238static inline int dw8250_probe_acpi(struct uart_port *p) 193static inline int dw8250_probe_acpi(struct uart_8250_port *up)
239{ 194{
240 return -ENODEV; 195 return -ENODEV;
241} 196}
@@ -266,7 +221,11 @@ static void dw8250_setup_port(struct uart_8250_port *up)
266 p->flags |= UPF_FIXED_TYPE; 221 p->flags |= UPF_FIXED_TYPE;
267 p->fifosize = DW_UART_CPR_FIFO_SIZE(reg); 222 p->fifosize = DW_UART_CPR_FIFO_SIZE(reg);
268 up->tx_loadsz = p->fifosize; 223 up->tx_loadsz = p->fifosize;
224 up->capabilities = UART_CAP_FIFO;
269 } 225 }
226
227 if (reg & DW_UART_CPR_AFCE_MODE)
228 up->capabilities |= UART_CAP_AFE;
270} 229}
271 230
272static int dw8250_probe(struct platform_device *pdev) 231static int dw8250_probe(struct platform_device *pdev)
@@ -286,17 +245,30 @@ static int dw8250_probe(struct platform_device *pdev)
286 uart.port.mapbase = regs->start; 245 uart.port.mapbase = regs->start;
287 uart.port.irq = irq->start; 246 uart.port.irq = irq->start;
288 uart.port.handle_irq = dw8250_handle_irq; 247 uart.port.handle_irq = dw8250_handle_irq;
248 uart.port.pm = dw8250_do_pm;
289 uart.port.type = PORT_8250; 249 uart.port.type = PORT_8250;
290 uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT; 250 uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT;
291 uart.port.dev = &pdev->dev; 251 uart.port.dev = &pdev->dev;
292 252
293 uart.port.membase = ioremap(regs->start, resource_size(regs)); 253 uart.port.membase = devm_ioremap(&pdev->dev, regs->start,
254 resource_size(regs));
294 if (!uart.port.membase) 255 if (!uart.port.membase)
295 return -ENOMEM; 256 return -ENOMEM;
296 257
258 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
259 if (!data)
260 return -ENOMEM;
261
262 data->clk = devm_clk_get(&pdev->dev, NULL);
263 if (!IS_ERR(data->clk)) {
264 clk_prepare_enable(data->clk);
265 uart.port.uartclk = clk_get_rate(data->clk);
266 }
267
297 uart.port.iotype = UPIO_MEM; 268 uart.port.iotype = UPIO_MEM;
298 uart.port.serial_in = dw8250_serial_in; 269 uart.port.serial_in = dw8250_serial_in;
299 uart.port.serial_out = dw8250_serial_out; 270 uart.port.serial_out = dw8250_serial_out;
271 uart.port.private_data = data;
300 272
301 dw8250_setup_port(&uart); 273 dw8250_setup_port(&uart);
302 274
@@ -305,25 +277,22 @@ static int dw8250_probe(struct platform_device *pdev)
305 if (err) 277 if (err)
306 return err; 278 return err;
307 } else if (ACPI_HANDLE(&pdev->dev)) { 279 } else if (ACPI_HANDLE(&pdev->dev)) {
308 err = dw8250_probe_acpi(&uart.port); 280 err = dw8250_probe_acpi(&uart);
309 if (err) 281 if (err)
310 return err; 282 return err;
311 } else { 283 } else {
312 return -ENODEV; 284 return -ENODEV;
313 } 285 }
314 286
315 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
316 if (!data)
317 return -ENOMEM;
318
319 uart.port.private_data = data;
320
321 data->line = serial8250_register_8250_port(&uart); 287 data->line = serial8250_register_8250_port(&uart);
322 if (data->line < 0) 288 if (data->line < 0)
323 return data->line; 289 return data->line;
324 290
325 platform_set_drvdata(pdev, data); 291 platform_set_drvdata(pdev, data);
326 292
293 pm_runtime_set_active(&pdev->dev);
294 pm_runtime_enable(&pdev->dev);
295
327 return 0; 296 return 0;
328} 297}
329 298
@@ -331,34 +300,64 @@ static int dw8250_remove(struct platform_device *pdev)
331{ 300{
332 struct dw8250_data *data = platform_get_drvdata(pdev); 301 struct dw8250_data *data = platform_get_drvdata(pdev);
333 302
303 pm_runtime_get_sync(&pdev->dev);
304
334 serial8250_unregister_port(data->line); 305 serial8250_unregister_port(data->line);
335 306
307 if (!IS_ERR(data->clk))
308 clk_disable_unprepare(data->clk);
309
310 pm_runtime_disable(&pdev->dev);
311 pm_runtime_put_noidle(&pdev->dev);
312
336 return 0; 313 return 0;
337} 314}
338 315
339#ifdef CONFIG_PM 316#ifdef CONFIG_PM
340static int dw8250_suspend(struct platform_device *pdev, pm_message_t state) 317static int dw8250_suspend(struct device *dev)
341{ 318{
342 struct dw8250_data *data = platform_get_drvdata(pdev); 319 struct dw8250_data *data = dev_get_drvdata(dev);
343 320
344 serial8250_suspend_port(data->line); 321 serial8250_suspend_port(data->line);
345 322
346 return 0; 323 return 0;
347} 324}
348 325
349static int dw8250_resume(struct platform_device *pdev) 326static int dw8250_resume(struct device *dev)
350{ 327{
351 struct dw8250_data *data = platform_get_drvdata(pdev); 328 struct dw8250_data *data = dev_get_drvdata(dev);
352 329
353 serial8250_resume_port(data->line); 330 serial8250_resume_port(data->line);
354 331
355 return 0; 332 return 0;
356} 333}
357#else
358#define dw8250_suspend NULL
359#define dw8250_resume NULL
360#endif /* CONFIG_PM */ 334#endif /* CONFIG_PM */
361 335
336#ifdef CONFIG_PM_RUNTIME
337static int dw8250_runtime_suspend(struct device *dev)
338{
339 struct dw8250_data *data = dev_get_drvdata(dev);
340
341 clk_disable_unprepare(data->clk);
342
343 return 0;
344}
345
346static int dw8250_runtime_resume(struct device *dev)
347{
348 struct dw8250_data *data = dev_get_drvdata(dev);
349
350 clk_prepare_enable(data->clk);
351
352 return 0;
353}
354#endif
355
356static const struct dev_pm_ops dw8250_pm_ops = {
357 SET_SYSTEM_SLEEP_PM_OPS(dw8250_suspend, dw8250_resume)
358 SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL)
359};
360
362static const struct of_device_id dw8250_of_match[] = { 361static const struct of_device_id dw8250_of_match[] = {
363 { .compatible = "snps,dw-apb-uart" }, 362 { .compatible = "snps,dw-apb-uart" },
364 { /* Sentinel */ } 363 { /* Sentinel */ }
@@ -366,8 +365,8 @@ static const struct of_device_id dw8250_of_match[] = {
366MODULE_DEVICE_TABLE(of, dw8250_of_match); 365MODULE_DEVICE_TABLE(of, dw8250_of_match);
367 366
368static const struct acpi_device_id dw8250_acpi_match[] = { 367static const struct acpi_device_id dw8250_acpi_match[] = {
369 { "INT33C4", 100000000 }, 368 { "INT33C4", 0 },
370 { "INT33C5", 100000000 }, 369 { "INT33C5", 0 },
371 { }, 370 { },
372}; 371};
373MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match); 372MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
@@ -376,13 +375,12 @@ static struct platform_driver dw8250_platform_driver = {
376 .driver = { 375 .driver = {
377 .name = "dw-apb-uart", 376 .name = "dw-apb-uart",
378 .owner = THIS_MODULE, 377 .owner = THIS_MODULE,
378 .pm = &dw8250_pm_ops,
379 .of_match_table = dw8250_of_match, 379 .of_match_table = dw8250_of_match,
380 .acpi_match_table = ACPI_PTR(dw8250_acpi_match), 380 .acpi_match_table = ACPI_PTR(dw8250_acpi_match),
381 }, 381 },
382 .probe = dw8250_probe, 382 .probe = dw8250_probe,
383 .remove = dw8250_remove, 383 .remove = dw8250_remove,
384 .suspend = dw8250_suspend,
385 .resume = dw8250_resume,
386}; 384};
387 385
388module_platform_driver(dw8250_platform_driver); 386module_platform_driver(dw8250_platform_driver);
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 3ea5408fcbeb..b2e9e177a354 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -29,6 +29,7 @@
29 * and hooked into this driver. 29 * and hooked into this driver.
30 */ 30 */
31 31
32
32#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 33#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
33#define SUPPORT_SYSRQ 34#define SUPPORT_SYSRQ
34#endif 35#endif
@@ -72,32 +73,44 @@
72/* There is by now at least one vendor with differing details, so handle it */ 73/* There is by now at least one vendor with differing details, so handle it */
73struct vendor_data { 74struct vendor_data {
74 unsigned int ifls; 75 unsigned int ifls;
75 unsigned int fifosize;
76 unsigned int lcrh_tx; 76 unsigned int lcrh_tx;
77 unsigned int lcrh_rx; 77 unsigned int lcrh_rx;
78 bool oversampling; 78 bool oversampling;
79 bool dma_threshold; 79 bool dma_threshold;
80 bool cts_event_workaround; 80 bool cts_event_workaround;
81
82 unsigned int (*get_fifosize)(unsigned int periphid);
81}; 83};
82 84
85static unsigned int get_fifosize_arm(unsigned int periphid)
86{
87 unsigned int rev = (periphid >> 20) & 0xf;
88 return rev < 3 ? 16 : 32;
89}
90
83static struct vendor_data vendor_arm = { 91static struct vendor_data vendor_arm = {
84 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, 92 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8,
85 .fifosize = 16,
86 .lcrh_tx = UART011_LCRH, 93 .lcrh_tx = UART011_LCRH,
87 .lcrh_rx = UART011_LCRH, 94 .lcrh_rx = UART011_LCRH,
88 .oversampling = false, 95 .oversampling = false,
89 .dma_threshold = false, 96 .dma_threshold = false,
90 .cts_event_workaround = false, 97 .cts_event_workaround = false,
98 .get_fifosize = get_fifosize_arm,
91}; 99};
92 100
101static unsigned int get_fifosize_st(unsigned int periphid)
102{
103 return 64;
104}
105
93static struct vendor_data vendor_st = { 106static struct vendor_data vendor_st = {
94 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF, 107 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF,
95 .fifosize = 64,
96 .lcrh_tx = ST_UART011_LCRH_TX, 108 .lcrh_tx = ST_UART011_LCRH_TX,
97 .lcrh_rx = ST_UART011_LCRH_RX, 109 .lcrh_rx = ST_UART011_LCRH_RX,
98 .oversampling = true, 110 .oversampling = true,
99 .dma_threshold = true, 111 .dma_threshold = true,
100 .cts_event_workaround = true, 112 .cts_event_workaround = true,
113 .get_fifosize = get_fifosize_st,
101}; 114};
102 115
103static struct uart_amba_port *amba_ports[UART_NR]; 116static struct uart_amba_port *amba_ports[UART_NR];
@@ -117,6 +130,12 @@ struct pl011_dmarx_data {
117 struct pl011_sgbuf sgbuf_b; 130 struct pl011_sgbuf sgbuf_b;
118 dma_cookie_t cookie; 131 dma_cookie_t cookie;
119 bool running; 132 bool running;
133 struct timer_list timer;
134 unsigned int last_residue;
135 unsigned long last_jiffies;
136 bool auto_poll_rate;
137 unsigned int poll_rate;
138 unsigned int poll_timeout;
120}; 139};
121 140
122struct pl011_dmatx_data { 141struct pl011_dmatx_data {
@@ -223,16 +242,18 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap)
223static int pl011_sgbuf_init(struct dma_chan *chan, struct pl011_sgbuf *sg, 242static int pl011_sgbuf_init(struct dma_chan *chan, struct pl011_sgbuf *sg,
224 enum dma_data_direction dir) 243 enum dma_data_direction dir)
225{ 244{
226 sg->buf = kmalloc(PL011_DMA_BUFFER_SIZE, GFP_KERNEL); 245 dma_addr_t dma_addr;
246
247 sg->buf = dma_alloc_coherent(chan->device->dev,
248 PL011_DMA_BUFFER_SIZE, &dma_addr, GFP_KERNEL);
227 if (!sg->buf) 249 if (!sg->buf)
228 return -ENOMEM; 250 return -ENOMEM;
229 251
230 sg_init_one(&sg->sg, sg->buf, PL011_DMA_BUFFER_SIZE); 252 sg_init_table(&sg->sg, 1);
253 sg_set_page(&sg->sg, phys_to_page(dma_addr),
254 PL011_DMA_BUFFER_SIZE, offset_in_page(dma_addr));
255 sg_dma_address(&sg->sg) = dma_addr;
231 256
232 if (dma_map_sg(chan->device->dev, &sg->sg, 1, dir) != 1) {
233 kfree(sg->buf);
234 return -EINVAL;
235 }
236 return 0; 257 return 0;
237} 258}
238 259
@@ -240,8 +261,9 @@ static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg,
240 enum dma_data_direction dir) 261 enum dma_data_direction dir)
241{ 262{
242 if (sg->buf) { 263 if (sg->buf) {
243 dma_unmap_sg(chan->device->dev, &sg->sg, 1, dir); 264 dma_free_coherent(chan->device->dev,
244 kfree(sg->buf); 265 PL011_DMA_BUFFER_SIZE, sg->buf,
266 sg_dma_address(&sg->sg));
245 } 267 }
246} 268}
247 269
@@ -300,6 +322,29 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
300 dmaengine_slave_config(chan, &rx_conf); 322 dmaengine_slave_config(chan, &rx_conf);
301 uap->dmarx.chan = chan; 323 uap->dmarx.chan = chan;
302 324
325 if (plat->dma_rx_poll_enable) {
326 /* Set poll rate if specified. */
327 if (plat->dma_rx_poll_rate) {
328 uap->dmarx.auto_poll_rate = false;
329 uap->dmarx.poll_rate = plat->dma_rx_poll_rate;
330 } else {
331 /*
332 * 100 ms defaults to poll rate if not
333 * specified. This will be adjusted with
334 * the baud rate at set_termios.
335 */
336 uap->dmarx.auto_poll_rate = true;
337 uap->dmarx.poll_rate = 100;
338 }
339 /* 3 secs defaults poll_timeout if not specified. */
340 if (plat->dma_rx_poll_timeout)
341 uap->dmarx.poll_timeout =
342 plat->dma_rx_poll_timeout;
343 else
344 uap->dmarx.poll_timeout = 3000;
345 } else
346 uap->dmarx.auto_poll_rate = false;
347
303 dev_info(uap->port.dev, "DMA channel RX %s\n", 348 dev_info(uap->port.dev, "DMA channel RX %s\n",
304 dma_chan_name(uap->dmarx.chan)); 349 dma_chan_name(uap->dmarx.chan));
305 } 350 }
@@ -701,24 +746,30 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap,
701 struct tty_port *port = &uap->port.state->port; 746 struct tty_port *port = &uap->port.state->port;
702 struct pl011_sgbuf *sgbuf = use_buf_b ? 747 struct pl011_sgbuf *sgbuf = use_buf_b ?
703 &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; 748 &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a;
704 struct device *dev = uap->dmarx.chan->device->dev;
705 int dma_count = 0; 749 int dma_count = 0;
706 u32 fifotaken = 0; /* only used for vdbg() */ 750 u32 fifotaken = 0; /* only used for vdbg() */
707 751
708 /* Pick everything from the DMA first */ 752 struct pl011_dmarx_data *dmarx = &uap->dmarx;
753 int dmataken = 0;
754
755 if (uap->dmarx.poll_rate) {
756 /* The data can be taken by polling */
757 dmataken = sgbuf->sg.length - dmarx->last_residue;
758 /* Recalculate the pending size */
759 if (pending >= dmataken)
760 pending -= dmataken;
761 }
762
763 /* Pick the remain data from the DMA */
709 if (pending) { 764 if (pending) {
710 /* Sync in buffer */
711 dma_sync_sg_for_cpu(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
712 765
713 /* 766 /*
714 * First take all chars in the DMA pipe, then look in the FIFO. 767 * First take all chars in the DMA pipe, then look in the FIFO.
715 * Note that tty_insert_flip_buf() tries to take as many chars 768 * Note that tty_insert_flip_buf() tries to take as many chars
716 * as it can. 769 * as it can.
717 */ 770 */
718 dma_count = tty_insert_flip_string(port, sgbuf->buf, pending); 771 dma_count = tty_insert_flip_string(port, sgbuf->buf + dmataken,
719 772 pending);
720 /* Return buffer to device */
721 dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
722 773
723 uap->port.icount.rx += dma_count; 774 uap->port.icount.rx += dma_count;
724 if (dma_count < pending) 775 if (dma_count < pending)
@@ -726,6 +777,10 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap,
726 "couldn't insert all characters (TTY is full?)\n"); 777 "couldn't insert all characters (TTY is full?)\n");
727 } 778 }
728 779
780 /* Reset the last_residue for Rx DMA poll */
781 if (uap->dmarx.poll_rate)
782 dmarx->last_residue = sgbuf->sg.length;
783
729 /* 784 /*
730 * Only continue with trying to read the FIFO if all DMA chars have 785 * Only continue with trying to read the FIFO if all DMA chars have
731 * been taken first. 786 * been taken first.
@@ -865,6 +920,57 @@ static inline void pl011_dma_rx_stop(struct uart_amba_port *uap)
865 writew(uap->dmacr, uap->port.membase + UART011_DMACR); 920 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
866} 921}
867 922
923/*
924 * Timer handler for Rx DMA polling.
925 * Every polling, It checks the residue in the dma buffer and transfer
926 * data to the tty. Also, last_residue is updated for the next polling.
927 */
928static void pl011_dma_rx_poll(unsigned long args)
929{
930 struct uart_amba_port *uap = (struct uart_amba_port *)args;
931 struct tty_port *port = &uap->port.state->port;
932 struct pl011_dmarx_data *dmarx = &uap->dmarx;
933 struct dma_chan *rxchan = uap->dmarx.chan;
934 unsigned long flags = 0;
935 unsigned int dmataken = 0;
936 unsigned int size = 0;
937 struct pl011_sgbuf *sgbuf;
938 int dma_count;
939 struct dma_tx_state state;
940
941 sgbuf = dmarx->use_buf_b ? &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a;
942 rxchan->device->device_tx_status(rxchan, dmarx->cookie, &state);
943 if (likely(state.residue < dmarx->last_residue)) {
944 dmataken = sgbuf->sg.length - dmarx->last_residue;
945 size = dmarx->last_residue - state.residue;
946 dma_count = tty_insert_flip_string(port, sgbuf->buf + dmataken,
947 size);
948 if (dma_count == size)
949 dmarx->last_residue = state.residue;
950 dmarx->last_jiffies = jiffies;
951 }
952 tty_flip_buffer_push(port);
953
954 /*
955 * If no data is received in poll_timeout, the driver will fall back
956 * to interrupt mode. We will retrigger DMA at the first interrupt.
957 */
958 if (jiffies_to_msecs(jiffies - dmarx->last_jiffies)
959 > uap->dmarx.poll_timeout) {
960
961 spin_lock_irqsave(&uap->port.lock, flags);
962 pl011_dma_rx_stop(uap);
963 spin_unlock_irqrestore(&uap->port.lock, flags);
964
965 uap->dmarx.running = false;
966 dmaengine_terminate_all(rxchan);
967 del_timer(&uap->dmarx.timer);
968 } else {
969 mod_timer(&uap->dmarx.timer,
970 jiffies + msecs_to_jiffies(uap->dmarx.poll_rate));
971 }
972}
973
868static void pl011_dma_startup(struct uart_amba_port *uap) 974static void pl011_dma_startup(struct uart_amba_port *uap)
869{ 975{
870 int ret; 976 int ret;
@@ -927,6 +1033,16 @@ skip_rx:
927 if (pl011_dma_rx_trigger_dma(uap)) 1033 if (pl011_dma_rx_trigger_dma(uap))
928 dev_dbg(uap->port.dev, "could not trigger initial " 1034 dev_dbg(uap->port.dev, "could not trigger initial "
929 "RX DMA job, fall back to interrupt mode\n"); 1035 "RX DMA job, fall back to interrupt mode\n");
1036 if (uap->dmarx.poll_rate) {
1037 init_timer(&(uap->dmarx.timer));
1038 uap->dmarx.timer.function = pl011_dma_rx_poll;
1039 uap->dmarx.timer.data = (unsigned long)uap;
1040 mod_timer(&uap->dmarx.timer,
1041 jiffies +
1042 msecs_to_jiffies(uap->dmarx.poll_rate));
1043 uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE;
1044 uap->dmarx.last_jiffies = jiffies;
1045 }
930 } 1046 }
931} 1047}
932 1048
@@ -962,6 +1078,8 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap)
962 /* Clean up the RX DMA */ 1078 /* Clean up the RX DMA */
963 pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a, DMA_FROM_DEVICE); 1079 pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a, DMA_FROM_DEVICE);
964 pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_b, DMA_FROM_DEVICE); 1080 pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_b, DMA_FROM_DEVICE);
1081 if (uap->dmarx.poll_rate)
1082 del_timer_sync(&uap->dmarx.timer);
965 uap->using_rx_dma = false; 1083 uap->using_rx_dma = false;
966 } 1084 }
967} 1085}
@@ -976,7 +1094,6 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap)
976 return uap->using_rx_dma && uap->dmarx.running; 1094 return uap->using_rx_dma && uap->dmarx.running;
977} 1095}
978 1096
979
980#else 1097#else
981/* Blank functions if the DMA engine is not available */ 1098/* Blank functions if the DMA engine is not available */
982static inline void pl011_dma_probe(struct uart_amba_port *uap) 1099static inline void pl011_dma_probe(struct uart_amba_port *uap)
@@ -1088,8 +1205,20 @@ static void pl011_rx_chars(struct uart_amba_port *uap)
1088 dev_dbg(uap->port.dev, "could not trigger RX DMA job " 1205 dev_dbg(uap->port.dev, "could not trigger RX DMA job "
1089 "fall back to interrupt mode again\n"); 1206 "fall back to interrupt mode again\n");
1090 uap->im |= UART011_RXIM; 1207 uap->im |= UART011_RXIM;
1091 } else 1208 } else {
1092 uap->im &= ~UART011_RXIM; 1209 uap->im &= ~UART011_RXIM;
1210#ifdef CONFIG_DMA_ENGINE
1211 /* Start Rx DMA poll */
1212 if (uap->dmarx.poll_rate) {
1213 uap->dmarx.last_jiffies = jiffies;
1214 uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE;
1215 mod_timer(&uap->dmarx.timer,
1216 jiffies +
1217 msecs_to_jiffies(uap->dmarx.poll_rate));
1218 }
1219#endif
1220 }
1221
1093 writew(uap->im, uap->port.membase + UART011_IMSC); 1222 writew(uap->im, uap->port.membase + UART011_IMSC);
1094 } 1223 }
1095 spin_lock(&uap->port.lock); 1224 spin_lock(&uap->port.lock);
@@ -1164,7 +1293,6 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
1164 unsigned int dummy_read; 1293 unsigned int dummy_read;
1165 1294
1166 spin_lock_irqsave(&uap->port.lock, flags); 1295 spin_lock_irqsave(&uap->port.lock, flags);
1167
1168 status = readw(uap->port.membase + UART011_MIS); 1296 status = readw(uap->port.membase + UART011_MIS);
1169 if (status) { 1297 if (status) {
1170 do { 1298 do {
@@ -1551,6 +1679,13 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1551 */ 1679 */
1552 baud = uart_get_baud_rate(port, termios, old, 0, 1680 baud = uart_get_baud_rate(port, termios, old, 0,
1553 port->uartclk / clkdiv); 1681 port->uartclk / clkdiv);
1682#ifdef CONFIG_DMA_ENGINE
1683 /*
1684 * Adjust RX DMA polling rate with baud rate if not specified.
1685 */
1686 if (uap->dmarx.auto_poll_rate)
1687 uap->dmarx.poll_rate = DIV_ROUND_UP(10000000, baud);
1688#endif
1554 1689
1555 if (baud > port->uartclk/16) 1690 if (baud > port->uartclk/16)
1556 quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud); 1691 quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud);
@@ -2010,7 +2145,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2010 uap->lcrh_rx = vendor->lcrh_rx; 2145 uap->lcrh_rx = vendor->lcrh_rx;
2011 uap->lcrh_tx = vendor->lcrh_tx; 2146 uap->lcrh_tx = vendor->lcrh_tx;
2012 uap->old_cr = 0; 2147 uap->old_cr = 0;
2013 uap->fifosize = vendor->fifosize; 2148 uap->fifosize = vendor->get_fifosize(dev->periphid);
2014 uap->port.dev = &dev->dev; 2149 uap->port.dev = &dev->dev;
2015 uap->port.mapbase = dev->res.start; 2150 uap->port.mapbase = dev->res.start;
2016 uap->port.membase = base; 2151 uap->port.membase = base;
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index d97e194b6bc5..cbf1d155b7b2 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -162,7 +162,7 @@ static unsigned int arc_serial_tx_empty(struct uart_port *port)
162/* 162/*
163 * Driver internal routine, used by both tty(serial core) as well as tx-isr 163 * Driver internal routine, used by both tty(serial core) as well as tx-isr
164 * -Called under spinlock in either cases 164 * -Called under spinlock in either cases
165 * -also tty->stopped / tty->hw_stopped has already been checked 165 * -also tty->stopped has already been checked
166 * = by uart_start( ) before calling us 166 * = by uart_start( ) before calling us
167 * = tx_ist checks that too before calling 167 * = tx_ist checks that too before calling
168 */ 168 */
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 12dceda9db33..26a3be7ced7d 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -1011,24 +1011,6 @@ static int bfin_serial_poll_get_char(struct uart_port *port)
1011} 1011}
1012#endif 1012#endif
1013 1013
1014#if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
1015 defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE)
1016static void bfin_kgdboc_port_shutdown(struct uart_port *port)
1017{
1018 if (kgdboc_break_enabled) {
1019 kgdboc_break_enabled = 0;
1020 bfin_serial_shutdown(port);
1021 }
1022}
1023
1024static int bfin_kgdboc_port_startup(struct uart_port *port)
1025{
1026 kgdboc_port_line = port->line;
1027 kgdboc_break_enabled = !bfin_serial_startup(port);
1028 return 0;
1029}
1030#endif
1031
1032static struct uart_ops bfin_serial_pops = { 1014static struct uart_ops bfin_serial_pops = {
1033 .tx_empty = bfin_serial_tx_empty, 1015 .tx_empty = bfin_serial_tx_empty,
1034 .set_mctrl = bfin_serial_set_mctrl, 1016 .set_mctrl = bfin_serial_set_mctrl,
@@ -1047,11 +1029,6 @@ static struct uart_ops bfin_serial_pops = {
1047 .request_port = bfin_serial_request_port, 1029 .request_port = bfin_serial_request_port,
1048 .config_port = bfin_serial_config_port, 1030 .config_port = bfin_serial_config_port,
1049 .verify_port = bfin_serial_verify_port, 1031 .verify_port = bfin_serial_verify_port,
1050#if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
1051 defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE)
1052 .kgdboc_port_startup = bfin_kgdboc_port_startup,
1053 .kgdboc_port_shutdown = bfin_kgdboc_port_shutdown,
1054#endif
1055#ifdef CONFIG_CONSOLE_POLL 1032#ifdef CONFIG_CONSOLE_POLL
1056 .poll_put_char = bfin_serial_poll_put_char, 1033 .poll_put_char = bfin_serial_poll_put_char,
1057 .poll_get_char = bfin_serial_poll_get_char, 1034 .poll_get_char = bfin_serial_poll_get_char,
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index 5f37c31e32bc..477f22f773fc 100644
--- a/drivers/tty/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
@@ -169,7 +169,6 @@ static int get_lsr_info(struct e100_serial *info, unsigned int *value);
169 169
170 170
171#define DEF_BAUD 115200 /* 115.2 kbit/s */ 171#define DEF_BAUD 115200 /* 115.2 kbit/s */
172#define STD_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
173#define DEF_RX 0x20 /* or SERIAL_CTRL_W >> 8 */ 172#define DEF_RX 0x20 /* or SERIAL_CTRL_W >> 8 */
174/* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */ 173/* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */
175#define DEF_TX 0x80 /* or SERIAL_CTRL_B */ 174#define DEF_TX 0x80 /* or SERIAL_CTRL_B */
@@ -246,7 +245,6 @@ static struct e100_serial rs_table[] = {
246 .ifirstadr = R_DMA_CH7_FIRST, 245 .ifirstadr = R_DMA_CH7_FIRST,
247 .icmdadr = R_DMA_CH7_CMD, 246 .icmdadr = R_DMA_CH7_CMD,
248 .idescradr = R_DMA_CH7_DESCR, 247 .idescradr = R_DMA_CH7_DESCR,
249 .flags = STD_FLAGS,
250 .rx_ctrl = DEF_RX, 248 .rx_ctrl = DEF_RX,
251 .tx_ctrl = DEF_TX, 249 .tx_ctrl = DEF_TX,
252 .iseteop = 2, 250 .iseteop = 2,
@@ -300,7 +298,6 @@ static struct e100_serial rs_table[] = {
300 .ifirstadr = R_DMA_CH9_FIRST, 298 .ifirstadr = R_DMA_CH9_FIRST,
301 .icmdadr = R_DMA_CH9_CMD, 299 .icmdadr = R_DMA_CH9_CMD,
302 .idescradr = R_DMA_CH9_DESCR, 300 .idescradr = R_DMA_CH9_DESCR,
303 .flags = STD_FLAGS,
304 .rx_ctrl = DEF_RX, 301 .rx_ctrl = DEF_RX,
305 .tx_ctrl = DEF_TX, 302 .tx_ctrl = DEF_TX,
306 .iseteop = 3, 303 .iseteop = 3,
@@ -356,7 +353,6 @@ static struct e100_serial rs_table[] = {
356 .ifirstadr = R_DMA_CH3_FIRST, 353 .ifirstadr = R_DMA_CH3_FIRST,
357 .icmdadr = R_DMA_CH3_CMD, 354 .icmdadr = R_DMA_CH3_CMD,
358 .idescradr = R_DMA_CH3_DESCR, 355 .idescradr = R_DMA_CH3_DESCR,
359 .flags = STD_FLAGS,
360 .rx_ctrl = DEF_RX, 356 .rx_ctrl = DEF_RX,
361 .tx_ctrl = DEF_TX, 357 .tx_ctrl = DEF_TX,
362 .iseteop = 0, 358 .iseteop = 0,
@@ -410,7 +406,6 @@ static struct e100_serial rs_table[] = {
410 .ifirstadr = R_DMA_CH5_FIRST, 406 .ifirstadr = R_DMA_CH5_FIRST,
411 .icmdadr = R_DMA_CH5_CMD, 407 .icmdadr = R_DMA_CH5_CMD,
412 .idescradr = R_DMA_CH5_DESCR, 408 .idescradr = R_DMA_CH5_DESCR,
413 .flags = STD_FLAGS,
414 .rx_ctrl = DEF_RX, 409 .rx_ctrl = DEF_RX,
415 .tx_ctrl = DEF_TX, 410 .tx_ctrl = DEF_TX,
416 .iseteop = 1, 411 .iseteop = 1,
@@ -2263,8 +2258,7 @@ TODO: The break will be delayed until an F or V character is received.
2263 2258
2264*/ 2259*/
2265 2260
2266static 2261static void handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2267struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2268{ 2262{
2269 unsigned long data_read; 2263 unsigned long data_read;
2270 2264
@@ -2370,10 +2364,9 @@ more_data:
2370 } 2364 }
2371 2365
2372 tty_flip_buffer_push(&info->port); 2366 tty_flip_buffer_push(&info->port);
2373 return info;
2374} 2367}
2375 2368
2376static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) 2369static void handle_ser_rx_interrupt(struct e100_serial *info)
2377{ 2370{
2378 unsigned char rstat; 2371 unsigned char rstat;
2379 2372
@@ -2382,7 +2375,8 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2382#endif 2375#endif
2383/* DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */ 2376/* DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */
2384 if (!info->uses_dma_in) { 2377 if (!info->uses_dma_in) {
2385 return handle_ser_rx_interrupt_no_dma(info); 2378 handle_ser_rx_interrupt_no_dma(info);
2379 return;
2386 } 2380 }
2387 /* DMA is used */ 2381 /* DMA is used */
2388 rstat = info->ioport[REG_STATUS]; 2382 rstat = info->ioport[REG_STATUS];
@@ -2489,7 +2483,6 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2489 /* Restarting the DMA never hurts */ 2483 /* Restarting the DMA never hurts */
2490 *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); 2484 *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
2491 START_FLUSH_FAST_TIMER(info, "ser_int"); 2485 START_FLUSH_FAST_TIMER(info, "ser_int");
2492 return info;
2493} /* handle_ser_rx_interrupt */ 2486} /* handle_ser_rx_interrupt */
2494 2487
2495static void handle_ser_tx_interrupt(struct e100_serial *info) 2488static void handle_ser_tx_interrupt(struct e100_serial *info)
@@ -2534,8 +2527,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2534 } 2527 }
2535 /* Normal char-by-char interrupt */ 2528 /* Normal char-by-char interrupt */
2536 if (info->xmit.head == info->xmit.tail 2529 if (info->xmit.head == info->xmit.tail
2537 || info->port.tty->stopped 2530 || info->port.tty->stopped) {
2538 || info->port.tty->hw_stopped) {
2539 DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", 2531 DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n",
2540 info->port.tty->stopped)); 2532 info->port.tty->stopped));
2541 e100_disable_serial_tx_ready_irq(info); 2533 e100_disable_serial_tx_ready_irq(info);
@@ -2722,7 +2714,7 @@ startup(struct e100_serial * info)
2722 2714
2723 /* if it was already initialized, skip this */ 2715 /* if it was already initialized, skip this */
2724 2716
2725 if (info->flags & ASYNC_INITIALIZED) { 2717 if (info->port.flags & ASYNC_INITIALIZED) {
2726 local_irq_restore(flags); 2718 local_irq_restore(flags);
2727 free_page(xmit_page); 2719 free_page(xmit_page);
2728 return 0; 2720 return 0;
@@ -2847,7 +2839,7 @@ startup(struct e100_serial * info)
2847 2839
2848#endif /* CONFIG_SVINTO_SIM */ 2840#endif /* CONFIG_SVINTO_SIM */
2849 2841
2850 info->flags |= ASYNC_INITIALIZED; 2842 info->port.flags |= ASYNC_INITIALIZED;
2851 2843
2852 local_irq_restore(flags); 2844 local_irq_restore(flags);
2853 return 0; 2845 return 0;
@@ -2892,7 +2884,7 @@ shutdown(struct e100_serial * info)
2892 2884
2893#endif /* CONFIG_SVINTO_SIM */ 2885#endif /* CONFIG_SVINTO_SIM */
2894 2886
2895 if (!(info->flags & ASYNC_INITIALIZED)) 2887 if (!(info->port.flags & ASYNC_INITIALIZED))
2896 return; 2888 return;
2897 2889
2898#ifdef SERIAL_DEBUG_OPEN 2890#ifdef SERIAL_DEBUG_OPEN
@@ -2923,7 +2915,7 @@ shutdown(struct e100_serial * info)
2923 if (info->port.tty) 2915 if (info->port.tty)
2924 set_bit(TTY_IO_ERROR, &info->port.tty->flags); 2916 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2925 2917
2926 info->flags &= ~ASYNC_INITIALIZED; 2918 info->port.flags &= ~ASYNC_INITIALIZED;
2927 local_irq_restore(flags); 2919 local_irq_restore(flags);
2928} 2920}
2929 2921
@@ -2948,7 +2940,7 @@ change_speed(struct e100_serial *info)
2948 /* possibly, the tx/rx should be disabled first to do this safely */ 2940 /* possibly, the tx/rx should be disabled first to do this safely */
2949 2941
2950 /* change baud-rate and write it to the hardware */ 2942 /* change baud-rate and write it to the hardware */
2951 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) { 2943 if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) {
2952 /* Special baudrate */ 2944 /* Special baudrate */
2953 u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */ 2945 u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */
2954 unsigned long alt_source = 2946 unsigned long alt_source =
@@ -3098,7 +3090,6 @@ rs_flush_chars(struct tty_struct *tty)
3098 if (info->tr_running || 3090 if (info->tr_running ||
3099 info->xmit.head == info->xmit.tail || 3091 info->xmit.head == info->xmit.tail ||
3100 tty->stopped || 3092 tty->stopped ||
3101 tty->hw_stopped ||
3102 !info->xmit.buf) 3093 !info->xmit.buf)
3103 return; 3094 return;
3104 3095
@@ -3176,7 +3167,6 @@ static int rs_raw_write(struct tty_struct *tty,
3176 3167
3177 if (info->xmit.head != info->xmit.tail && 3168 if (info->xmit.head != info->xmit.tail &&
3178 !tty->stopped && 3169 !tty->stopped &&
3179 !tty->hw_stopped &&
3180 !info->tr_running) { 3170 !info->tr_running) {
3181 start_transmit(info); 3171 start_transmit(info);
3182 } 3172 }
@@ -3400,10 +3390,10 @@ get_serial_info(struct e100_serial * info,
3400 tmp.line = info->line; 3390 tmp.line = info->line;
3401 tmp.port = (int)info->ioport; 3391 tmp.port = (int)info->ioport;
3402 tmp.irq = info->irq; 3392 tmp.irq = info->irq;
3403 tmp.flags = info->flags; 3393 tmp.flags = info->port.flags;
3404 tmp.baud_base = info->baud_base; 3394 tmp.baud_base = info->baud_base;
3405 tmp.close_delay = info->close_delay; 3395 tmp.close_delay = info->port.close_delay;
3406 tmp.closing_wait = info->closing_wait; 3396 tmp.closing_wait = info->port.closing_wait;
3407 tmp.custom_divisor = info->custom_divisor; 3397 tmp.custom_divisor = info->custom_divisor;
3408 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 3398 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
3409 return -EFAULT; 3399 return -EFAULT;
@@ -3425,16 +3415,16 @@ set_serial_info(struct e100_serial *info,
3425 3415
3426 if (!capable(CAP_SYS_ADMIN)) { 3416 if (!capable(CAP_SYS_ADMIN)) {
3427 if ((new_serial.type != info->type) || 3417 if ((new_serial.type != info->type) ||
3428 (new_serial.close_delay != info->close_delay) || 3418 (new_serial.close_delay != info->port.close_delay) ||
3429 ((new_serial.flags & ~ASYNC_USR_MASK) != 3419 ((new_serial.flags & ~ASYNC_USR_MASK) !=
3430 (info->flags & ~ASYNC_USR_MASK))) 3420 (info->port.flags & ~ASYNC_USR_MASK)))
3431 return -EPERM; 3421 return -EPERM;
3432 info->flags = ((info->flags & ~ASYNC_USR_MASK) | 3422 info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
3433 (new_serial.flags & ASYNC_USR_MASK)); 3423 (new_serial.flags & ASYNC_USR_MASK));
3434 goto check_and_exit; 3424 goto check_and_exit;
3435 } 3425 }
3436 3426
3437 if (info->count > 1) 3427 if (info->port.count > 1)
3438 return -EBUSY; 3428 return -EBUSY;
3439 3429
3440 /* 3430 /*
@@ -3443,16 +3433,16 @@ set_serial_info(struct e100_serial *info,
3443 */ 3433 */
3444 3434
3445 info->baud_base = new_serial.baud_base; 3435 info->baud_base = new_serial.baud_base;
3446 info->flags = ((info->flags & ~ASYNC_FLAGS) | 3436 info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
3447 (new_serial.flags & ASYNC_FLAGS)); 3437 (new_serial.flags & ASYNC_FLAGS));
3448 info->custom_divisor = new_serial.custom_divisor; 3438 info->custom_divisor = new_serial.custom_divisor;
3449 info->type = new_serial.type; 3439 info->type = new_serial.type;
3450 info->close_delay = new_serial.close_delay; 3440 info->port.close_delay = new_serial.close_delay;
3451 info->closing_wait = new_serial.closing_wait; 3441 info->port.closing_wait = new_serial.closing_wait;
3452 info->port.low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3442 info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
3453 3443
3454 check_and_exit: 3444 check_and_exit:
3455 if (info->flags & ASYNC_INITIALIZED) { 3445 if (info->port.flags & ASYNC_INITIALIZED) {
3456 change_speed(info); 3446 change_speed(info);
3457 } else 3447 } else
3458 retval = startup(info); 3448 retval = startup(info);
@@ -3733,10 +3723,8 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
3733 3723
3734 /* Handle turning off CRTSCTS */ 3724 /* Handle turning off CRTSCTS */
3735 if ((old_termios->c_cflag & CRTSCTS) && 3725 if ((old_termios->c_cflag & CRTSCTS) &&
3736 !(tty->termios.c_cflag & CRTSCTS)) { 3726 !(tty->termios.c_cflag & CRTSCTS))
3737 tty->hw_stopped = 0;
3738 rs_start(tty); 3727 rs_start(tty);
3739 }
3740 3728
3741} 3729}
3742 3730
@@ -3772,7 +3760,7 @@ rs_close(struct tty_struct *tty, struct file * filp)
3772 printk("[%d] rs_close ttyS%d, count = %d\n", current->pid, 3760 printk("[%d] rs_close ttyS%d, count = %d\n", current->pid,
3773 info->line, info->count); 3761 info->line, info->count);
3774#endif 3762#endif
3775 if ((tty->count == 1) && (info->count != 1)) { 3763 if ((tty->count == 1) && (info->port.count != 1)) {
3776 /* 3764 /*
3777 * Uh, oh. tty->count is 1, which means that the tty 3765 * Uh, oh. tty->count is 1, which means that the tty
3778 * structure will be freed. Info->count should always 3766 * structure will be freed. Info->count should always
@@ -3782,32 +3770,32 @@ rs_close(struct tty_struct *tty, struct file * filp)
3782 */ 3770 */
3783 printk(KERN_ERR 3771 printk(KERN_ERR
3784 "rs_close: bad serial port count; tty->count is 1, " 3772 "rs_close: bad serial port count; tty->count is 1, "
3785 "info->count is %d\n", info->count); 3773 "info->count is %d\n", info->port.count);
3786 info->count = 1; 3774 info->port.count = 1;
3787 } 3775 }
3788 if (--info->count < 0) { 3776 if (--info->port.count < 0) {
3789 printk(KERN_ERR "rs_close: bad serial port count for ttyS%d: %d\n", 3777 printk(KERN_ERR "rs_close: bad serial port count for ttyS%d: %d\n",
3790 info->line, info->count); 3778 info->line, info->port.count);
3791 info->count = 0; 3779 info->port.count = 0;
3792 } 3780 }
3793 if (info->count) { 3781 if (info->port.count) {
3794 local_irq_restore(flags); 3782 local_irq_restore(flags);
3795 return; 3783 return;
3796 } 3784 }
3797 info->flags |= ASYNC_CLOSING; 3785 info->port.flags |= ASYNC_CLOSING;
3798 /* 3786 /*
3799 * Save the termios structure, since this port may have 3787 * Save the termios structure, since this port may have
3800 * separate termios for callout and dialin. 3788 * separate termios for callout and dialin.
3801 */ 3789 */
3802 if (info->flags & ASYNC_NORMAL_ACTIVE) 3790 if (info->port.flags & ASYNC_NORMAL_ACTIVE)
3803 info->normal_termios = tty->termios; 3791 info->normal_termios = tty->termios;
3804 /* 3792 /*
3805 * Now we wait for the transmit buffer to clear; and we notify 3793 * Now we wait for the transmit buffer to clear; and we notify
3806 * the line discipline to only process XON/XOFF characters. 3794 * the line discipline to only process XON/XOFF characters.
3807 */ 3795 */
3808 tty->closing = 1; 3796 tty->closing = 1;
3809 if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) 3797 if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
3810 tty_wait_until_sent(tty, info->closing_wait); 3798 tty_wait_until_sent(tty, info->port.closing_wait);
3811 /* 3799 /*
3812 * At this point we stop accepting input. To do this, we 3800 * At this point we stop accepting input. To do this, we
3813 * disable the serial receiver and the DMA receive interrupt. 3801 * disable the serial receiver and the DMA receive interrupt.
@@ -3820,7 +3808,7 @@ rs_close(struct tty_struct *tty, struct file * filp)
3820 e100_disable_rx(info); 3808 e100_disable_rx(info);
3821 e100_disable_rx_irq(info); 3809 e100_disable_rx_irq(info);
3822 3810
3823 if (info->flags & ASYNC_INITIALIZED) { 3811 if (info->port.flags & ASYNC_INITIALIZED) {
3824 /* 3812 /*
3825 * Before we drop DTR, make sure the UART transmitter 3813 * Before we drop DTR, make sure the UART transmitter
3826 * has completely drained; this is especially 3814 * has completely drained; this is especially
@@ -3836,13 +3824,13 @@ rs_close(struct tty_struct *tty, struct file * filp)
3836 tty->closing = 0; 3824 tty->closing = 0;
3837 info->event = 0; 3825 info->event = 0;
3838 info->port.tty = NULL; 3826 info->port.tty = NULL;
3839 if (info->blocked_open) { 3827 if (info->port.blocked_open) {
3840 if (info->close_delay) 3828 if (info->port.close_delay)
3841 schedule_timeout_interruptible(info->close_delay); 3829 schedule_timeout_interruptible(info->port.close_delay);
3842 wake_up_interruptible(&info->open_wait); 3830 wake_up_interruptible(&info->port.open_wait);
3843 } 3831 }
3844 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 3832 info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
3845 wake_up_interruptible(&info->close_wait); 3833 wake_up_interruptible(&info->port.close_wait);
3846 local_irq_restore(flags); 3834 local_irq_restore(flags);
3847 3835
3848 /* port closed */ 3836 /* port closed */
@@ -3935,10 +3923,10 @@ rs_hangup(struct tty_struct *tty)
3935 rs_flush_buffer(tty); 3923 rs_flush_buffer(tty);
3936 shutdown(info); 3924 shutdown(info);
3937 info->event = 0; 3925 info->event = 0;
3938 info->count = 0; 3926 info->port.count = 0;
3939 info->flags &= ~ASYNC_NORMAL_ACTIVE; 3927 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
3940 info->port.tty = NULL; 3928 info->port.tty = NULL;
3941 wake_up_interruptible(&info->open_wait); 3929 wake_up_interruptible(&info->port.open_wait);
3942} 3930}
3943 3931
3944/* 3932/*
@@ -3960,11 +3948,11 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
3960 * until it's done, and then try again. 3948 * until it's done, and then try again.
3961 */ 3949 */
3962 if (tty_hung_up_p(filp) || 3950 if (tty_hung_up_p(filp) ||
3963 (info->flags & ASYNC_CLOSING)) { 3951 (info->port.flags & ASYNC_CLOSING)) {
3964 wait_event_interruptible_tty(tty, info->close_wait, 3952 wait_event_interruptible_tty(tty, info->port.close_wait,
3965 !(info->flags & ASYNC_CLOSING)); 3953 !(info->port.flags & ASYNC_CLOSING));
3966#ifdef SERIAL_DO_RESTART 3954#ifdef SERIAL_DO_RESTART
3967 if (info->flags & ASYNC_HUP_NOTIFY) 3955 if (info->port.flags & ASYNC_HUP_NOTIFY)
3968 return -EAGAIN; 3956 return -EAGAIN;
3969 else 3957 else
3970 return -ERESTARTSYS; 3958 return -ERESTARTSYS;
@@ -3979,7 +3967,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
3979 */ 3967 */
3980 if ((filp->f_flags & O_NONBLOCK) || 3968 if ((filp->f_flags & O_NONBLOCK) ||
3981 (tty->flags & (1 << TTY_IO_ERROR))) { 3969 (tty->flags & (1 << TTY_IO_ERROR))) {
3982 info->flags |= ASYNC_NORMAL_ACTIVE; 3970 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3983 return 0; 3971 return 0;
3984 } 3972 }
3985 3973
@@ -3990,23 +3978,23 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
3990 /* 3978 /*
3991 * Block waiting for the carrier detect and the line to become 3979 * Block waiting for the carrier detect and the line to become
3992 * free (i.e., not in use by the callout). While we are in 3980 * free (i.e., not in use by the callout). While we are in
3993 * this loop, info->count is dropped by one, so that 3981 * this loop, info->port.count is dropped by one, so that
3994 * rs_close() knows when to free things. We restore it upon 3982 * rs_close() knows when to free things. We restore it upon
3995 * exit, either normal or abnormal. 3983 * exit, either normal or abnormal.
3996 */ 3984 */
3997 retval = 0; 3985 retval = 0;
3998 add_wait_queue(&info->open_wait, &wait); 3986 add_wait_queue(&info->port.open_wait, &wait);
3999#ifdef SERIAL_DEBUG_OPEN 3987#ifdef SERIAL_DEBUG_OPEN
4000 printk("block_til_ready before block: ttyS%d, count = %d\n", 3988 printk("block_til_ready before block: ttyS%d, count = %d\n",
4001 info->line, info->count); 3989 info->line, info->port.count);
4002#endif 3990#endif
4003 local_irq_save(flags); 3991 local_irq_save(flags);
4004 if (!tty_hung_up_p(filp)) { 3992 if (!tty_hung_up_p(filp)) {
4005 extra_count++; 3993 extra_count++;
4006 info->count--; 3994 info->port.count--;
4007 } 3995 }
4008 local_irq_restore(flags); 3996 local_irq_restore(flags);
4009 info->blocked_open++; 3997 info->port.blocked_open++;
4010 while (1) { 3998 while (1) {
4011 local_irq_save(flags); 3999 local_irq_save(flags);
4012 /* assert RTS and DTR */ 4000 /* assert RTS and DTR */
@@ -4015,9 +4003,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
4015 local_irq_restore(flags); 4003 local_irq_restore(flags);
4016 set_current_state(TASK_INTERRUPTIBLE); 4004 set_current_state(TASK_INTERRUPTIBLE);
4017 if (tty_hung_up_p(filp) || 4005 if (tty_hung_up_p(filp) ||
4018 !(info->flags & ASYNC_INITIALIZED)) { 4006 !(info->port.flags & ASYNC_INITIALIZED)) {
4019#ifdef SERIAL_DO_RESTART 4007#ifdef SERIAL_DO_RESTART
4020 if (info->flags & ASYNC_HUP_NOTIFY) 4008 if (info->port.flags & ASYNC_HUP_NOTIFY)
4021 retval = -EAGAIN; 4009 retval = -EAGAIN;
4022 else 4010 else
4023 retval = -ERESTARTSYS; 4011 retval = -ERESTARTSYS;
@@ -4026,7 +4014,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
4026#endif 4014#endif
4027 break; 4015 break;
4028 } 4016 }
4029 if (!(info->flags & ASYNC_CLOSING) && do_clocal) 4017 if (!(info->port.flags & ASYNC_CLOSING) && do_clocal)
4030 /* && (do_clocal || DCD_IS_ASSERTED) */ 4018 /* && (do_clocal || DCD_IS_ASSERTED) */
4031 break; 4019 break;
4032 if (signal_pending(current)) { 4020 if (signal_pending(current)) {
@@ -4035,24 +4023,24 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
4035 } 4023 }
4036#ifdef SERIAL_DEBUG_OPEN 4024#ifdef SERIAL_DEBUG_OPEN
4037 printk("block_til_ready blocking: ttyS%d, count = %d\n", 4025 printk("block_til_ready blocking: ttyS%d, count = %d\n",
4038 info->line, info->count); 4026 info->line, info->port.count);
4039#endif 4027#endif
4040 tty_unlock(tty); 4028 tty_unlock(tty);
4041 schedule(); 4029 schedule();
4042 tty_lock(tty); 4030 tty_lock(tty);
4043 } 4031 }
4044 set_current_state(TASK_RUNNING); 4032 set_current_state(TASK_RUNNING);
4045 remove_wait_queue(&info->open_wait, &wait); 4033 remove_wait_queue(&info->port.open_wait, &wait);
4046 if (extra_count) 4034 if (extra_count)
4047 info->count++; 4035 info->port.count++;
4048 info->blocked_open--; 4036 info->port.blocked_open--;
4049#ifdef SERIAL_DEBUG_OPEN 4037#ifdef SERIAL_DEBUG_OPEN
4050 printk("block_til_ready after blocking: ttyS%d, count = %d\n", 4038 printk("block_til_ready after blocking: ttyS%d, count = %d\n",
4051 info->line, info->count); 4039 info->line, info->port.count);
4052#endif 4040#endif
4053 if (retval) 4041 if (retval)
4054 return retval; 4042 return retval;
4055 info->flags |= ASYNC_NORMAL_ACTIVE; 4043 info->port.flags |= ASYNC_NORMAL_ACTIVE;
4056 return 0; 4044 return 0;
4057} 4045}
4058 4046
@@ -4086,24 +4074,24 @@ rs_open(struct tty_struct *tty, struct file * filp)
4086 4074
4087#ifdef SERIAL_DEBUG_OPEN 4075#ifdef SERIAL_DEBUG_OPEN
4088 printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name, 4076 printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name,
4089 info->count); 4077 info->port.count);
4090#endif 4078#endif
4091 4079
4092 info->count++; 4080 info->port.count++;
4093 tty->driver_data = info; 4081 tty->driver_data = info;
4094 info->port.tty = tty; 4082 info->port.tty = tty;
4095 4083
4096 info->port.low_latency = !!(info->flags & ASYNC_LOW_LATENCY); 4084 info->port.low_latency = !!(info->port.flags & ASYNC_LOW_LATENCY);
4097 4085
4098 /* 4086 /*
4099 * If the port is in the middle of closing, bail out now 4087 * If the port is in the middle of closing, bail out now
4100 */ 4088 */
4101 if (tty_hung_up_p(filp) || 4089 if (tty_hung_up_p(filp) ||
4102 (info->flags & ASYNC_CLOSING)) { 4090 (info->port.flags & ASYNC_CLOSING)) {
4103 wait_event_interruptible_tty(tty, info->close_wait, 4091 wait_event_interruptible_tty(tty, info->port.close_wait,
4104 !(info->flags & ASYNC_CLOSING)); 4092 !(info->port.flags & ASYNC_CLOSING));
4105#ifdef SERIAL_DO_RESTART 4093#ifdef SERIAL_DO_RESTART
4106 return ((info->flags & ASYNC_HUP_NOTIFY) ? 4094 return ((info->port.flags & ASYNC_HUP_NOTIFY) ?
4107 -EAGAIN : -ERESTARTSYS); 4095 -EAGAIN : -ERESTARTSYS);
4108#else 4096#else
4109 return -EAGAIN; 4097 return -EAGAIN;
@@ -4113,7 +4101,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
4113 /* 4101 /*
4114 * If DMA is enabled try to allocate the irq's. 4102 * If DMA is enabled try to allocate the irq's.
4115 */ 4103 */
4116 if (info->count == 1) { 4104 if (info->port.count == 1) {
4117 allocated_resources = 1; 4105 allocated_resources = 1;
4118 if (info->dma_in_enabled) { 4106 if (info->dma_in_enabled) {
4119 if (request_irq(info->dma_in_irq_nbr, 4107 if (request_irq(info->dma_in_irq_nbr,
@@ -4186,7 +4174,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
4186 if (allocated_resources) 4174 if (allocated_resources)
4187 deinit_port(info); 4175 deinit_port(info);
4188 4176
4189 /* FIXME Decrease count info->count here too? */ 4177 /* FIXME Decrease count info->port.count here too? */
4190 return retval; 4178 return retval;
4191 } 4179 }
4192 4180
@@ -4203,7 +4191,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
4203 return retval; 4191 return retval;
4204 } 4192 }
4205 4193
4206 if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) { 4194 if ((info->port.count == 1) && (info->port.flags & ASYNC_SPLIT_TERMIOS)) {
4207 tty->termios = info->normal_termios; 4195 tty->termios = info->normal_termios;
4208 change_speed(info); 4196 change_speed(info);
4209 } 4197 }
@@ -4256,9 +4244,6 @@ static void seq_line_info(struct seq_file *m, struct e100_serial *info)
4256 if (info->port.tty->stopped) 4244 if (info->port.tty->stopped)
4257 seq_printf(m, " stopped:%i", 4245 seq_printf(m, " stopped:%i",
4258 (int)info->port.tty->stopped); 4246 (int)info->port.tty->stopped);
4259 if (info->port.tty->hw_stopped)
4260 seq_printf(m, " hw_stopped:%i",
4261 (int)info->port.tty->hw_stopped);
4262 } 4247 }
4263 4248
4264 { 4249 {
@@ -4455,16 +4440,9 @@ static int __init rs_init(void)
4455 info->forced_eop = 0; 4440 info->forced_eop = 0;
4456 info->baud_base = DEF_BAUD_BASE; 4441 info->baud_base = DEF_BAUD_BASE;
4457 info->custom_divisor = 0; 4442 info->custom_divisor = 0;
4458 info->flags = 0;
4459 info->close_delay = 5*HZ/10;
4460 info->closing_wait = 30*HZ;
4461 info->x_char = 0; 4443 info->x_char = 0;
4462 info->event = 0; 4444 info->event = 0;
4463 info->count = 0;
4464 info->blocked_open = 0;
4465 info->normal_termios = driver->init_termios; 4445 info->normal_termios = driver->init_termios;
4466 init_waitqueue_head(&info->open_wait);
4467 init_waitqueue_head(&info->close_wait);
4468 info->xmit.buf = NULL; 4446 info->xmit.buf = NULL;
4469 info->xmit.tail = info->xmit.head = 0; 4447 info->xmit.tail = info->xmit.head = 0;
4470 info->first_recv_buffer = info->last_recv_buffer = NULL; 4448 info->first_recv_buffer = info->last_recv_buffer = NULL;
diff --git a/drivers/tty/serial/crisv10.h b/drivers/tty/serial/crisv10.h
index ea0beb46a10d..7599014ae03f 100644
--- a/drivers/tty/serial/crisv10.h
+++ b/drivers/tty/serial/crisv10.h
@@ -53,8 +53,6 @@ struct e100_serial {
53 volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */ 53 volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */
54 volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */ 54 volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */
55 55
56 int flags; /* defined in tty.h */
57
58 u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */ 56 u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */
59 u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */ 57 u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */
60 u8 iseteop; /* bit number for R_SET_EOP for the input dma */ 58 u8 iseteop; /* bit number for R_SET_EOP for the input dma */
@@ -88,19 +86,10 @@ struct e100_serial {
88 86
89 volatile int tr_running; /* 1 if output is running */ 87 volatile int tr_running; /* 1 if output is running */
90 88
91 struct tty_struct *tty;
92 int read_status_mask;
93 int ignore_status_mask;
94 int x_char; /* xon/xoff character */ 89 int x_char; /* xon/xoff character */
95 int close_delay;
96 unsigned short closing_wait;
97 unsigned short closing_wait2;
98 unsigned long event; 90 unsigned long event;
99 unsigned long last_active;
100 int line; 91 int line;
101 int type; /* PORT_ETRAX */ 92 int type; /* PORT_ETRAX */
102 int count; /* # of fd on device */
103 int blocked_open; /* # of blocked opens */
104 struct circ_buf xmit; 93 struct circ_buf xmit;
105 struct etrax_recv_buffer *first_recv_buffer; 94 struct etrax_recv_buffer *first_recv_buffer;
106 struct etrax_recv_buffer *last_recv_buffer; 95 struct etrax_recv_buffer *last_recv_buffer;
@@ -110,9 +99,6 @@ struct e100_serial {
110 struct work_struct work; 99 struct work_struct work;
111 struct async_icount icount; /* error-statistics etc.*/ 100 struct async_icount icount; /* error-statistics etc.*/
112 struct ktermios normal_termios; 101 struct ktermios normal_termios;
113 struct ktermios callout_termios;
114 wait_queue_head_t open_wait;
115 wait_queue_head_t close_wait;
116 102
117 unsigned long char_time_usec; /* The time for 1 char, in usecs */ 103 unsigned long char_time_usec; /* The time for 1 char, in usecs */
118 unsigned long flush_time_usec; /* How often we should flush */ 104 unsigned long flush_time_usec; /* How often we should flush */
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index bc9e6b017b05..18ed5aebb166 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -1415,8 +1415,7 @@ static int icom_alloc_adapter(struct icom_adapter
1415 struct icom_adapter *cur_adapter_entry; 1415 struct icom_adapter *cur_adapter_entry;
1416 struct list_head *tmp; 1416 struct list_head *tmp;
1417 1417
1418 icom_adapter = (struct icom_adapter *) 1418 icom_adapter = kzalloc(sizeof(struct icom_adapter), GFP_KERNEL);
1419 kzalloc(sizeof(struct icom_adapter), GFP_KERNEL);
1420 1419
1421 if (!icom_adapter) { 1420 if (!icom_adapter) {
1422 return -ENOMEM; 1421 return -ENOMEM;
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 68d7ce997ede..8b1534c424af 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -270,23 +270,6 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev)
270} 270}
271 271
272/** 272/**
273 * ifx_spi_hangup - hang up an IFX device
274 * @ifx_dev: our SPI device
275 *
276 * Hang up the tty attached to the IFX device if one is currently
277 * open. If not take no action
278 */
279static void ifx_spi_ttyhangup(struct ifx_spi_device *ifx_dev)
280{
281 struct tty_port *pport = &ifx_dev->tty_port;
282 struct tty_struct *tty = tty_port_tty_get(pport);
283 if (tty) {
284 tty_hangup(tty);
285 tty_kref_put(tty);
286 }
287}
288
289/**
290 * ifx_spi_timeout - SPI timeout 273 * ifx_spi_timeout - SPI timeout
291 * @arg: our SPI device 274 * @arg: our SPI device
292 * 275 *
@@ -298,7 +281,7 @@ static void ifx_spi_timeout(unsigned long arg)
298 struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg; 281 struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg;
299 282
300 dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); 283 dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***");
301 ifx_spi_ttyhangup(ifx_dev); 284 tty_port_tty_hangup(&ifx_dev->tty_port, false);
302 mrdy_set_low(ifx_dev); 285 mrdy_set_low(ifx_dev);
303 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); 286 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
304} 287}
@@ -443,25 +426,6 @@ static void ifx_spi_setup_spi_header(unsigned char *txbuffer, int tx_count,
443} 426}
444 427
445/** 428/**
446 * ifx_spi_wakeup_serial - SPI space made
447 * @port_data: our SPI device
448 *
449 * We have emptied the FIFO enough that we want to get more data
450 * queued into it. Poke the line discipline via tty_wakeup so that
451 * it will feed us more bits
452 */
453static void ifx_spi_wakeup_serial(struct ifx_spi_device *ifx_dev)
454{
455 struct tty_struct *tty;
456
457 tty = tty_port_tty_get(&ifx_dev->tty_port);
458 if (!tty)
459 return;
460 tty_wakeup(tty);
461 tty_kref_put(tty);
462}
463
464/**
465 * ifx_spi_prepare_tx_buffer - prepare transmit frame 429 * ifx_spi_prepare_tx_buffer - prepare transmit frame
466 * @ifx_dev: our SPI device 430 * @ifx_dev: our SPI device
467 * 431 *
@@ -506,7 +470,7 @@ static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device *ifx_dev)
506 tx_count += temp_count; 470 tx_count += temp_count;
507 if (temp_count == queue_length) 471 if (temp_count == queue_length)
508 /* poke port to get more data */ 472 /* poke port to get more data */
509 ifx_spi_wakeup_serial(ifx_dev); 473 tty_port_tty_wakeup(&ifx_dev->tty_port);
510 else /* more data in port, use next SPI message */ 474 else /* more data in port, use next SPI message */
511 ifx_dev->spi_more = 1; 475 ifx_dev->spi_more = 1;
512 } 476 }
@@ -683,8 +647,6 @@ static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev,
683static void ifx_spi_complete(void *ctx) 647static void ifx_spi_complete(void *ctx)
684{ 648{
685 struct ifx_spi_device *ifx_dev = ctx; 649 struct ifx_spi_device *ifx_dev = ctx;
686 struct tty_struct *tty;
687 struct tty_ldisc *ldisc = NULL;
688 int length; 650 int length;
689 int actual_length; 651 int actual_length;
690 unsigned char more; 652 unsigned char more;
@@ -762,15 +724,7 @@ complete_exit:
762 */ 724 */
763 ifx_spi_power_state_clear(ifx_dev, 725 ifx_spi_power_state_clear(ifx_dev,
764 IFX_SPI_POWER_DATA_PENDING); 726 IFX_SPI_POWER_DATA_PENDING);
765 tty = tty_port_tty_get(&ifx_dev->tty_port); 727 tty_port_tty_wakeup(&ifx_dev->tty_port);
766 if (tty) {
767 ldisc = tty_ldisc_ref(tty);
768 if (ldisc) {
769 ldisc->ops->write_wakeup(tty);
770 tty_ldisc_deref(ldisc);
771 }
772 tty_kref_put(tty);
773 }
774 } 728 }
775 } 729 }
776} 730}
@@ -962,7 +916,7 @@ static irqreturn_t ifx_spi_reset_interrupt(int irq, void *dev)
962 set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); 916 set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state);
963 if (!solreset) { 917 if (!solreset) {
964 /* unsolicited reset */ 918 /* unsolicited reset */
965 ifx_spi_ttyhangup(ifx_dev); 919 tty_port_tty_hangup(&ifx_dev->tty_port, false);
966 } 920 }
967 } else { 921 } else {
968 /* exited reset */ 922 /* exited reset */
@@ -1325,30 +1279,6 @@ static void ifx_spi_spi_shutdown(struct spi_device *spi)
1325 */ 1279 */
1326 1280
1327/** 1281/**
1328 * ifx_spi_spi_suspend - suspend SPI on system suspend
1329 * @dev: device being suspended
1330 *
1331 * Suspend the SPI side. No action needed on Intel MID platforms, may
1332 * need extending for other systems.
1333 */
1334static int ifx_spi_spi_suspend(struct spi_device *spi, pm_message_t msg)
1335{
1336 return 0;
1337}
1338
1339/**
1340 * ifx_spi_spi_resume - resume SPI side on system resume
1341 * @dev: device being suspended
1342 *
1343 * Suspend the SPI side. No action needed on Intel MID platforms, may
1344 * need extending for other systems.
1345 */
1346static int ifx_spi_spi_resume(struct spi_device *spi)
1347{
1348 return 0;
1349}
1350
1351/**
1352 * ifx_spi_pm_suspend - suspend modem on system suspend 1282 * ifx_spi_pm_suspend - suspend modem on system suspend
1353 * @dev: device being suspended 1283 * @dev: device being suspended
1354 * 1284 *
@@ -1437,8 +1367,6 @@ static struct spi_driver ifx_spi_driver = {
1437 .probe = ifx_spi_spi_probe, 1367 .probe = ifx_spi_spi_probe,
1438 .shutdown = ifx_spi_spi_shutdown, 1368 .shutdown = ifx_spi_spi_shutdown,
1439 .remove = ifx_spi_spi_remove, 1369 .remove = ifx_spi_spi_remove,
1440 .suspend = ifx_spi_spi_suspend,
1441 .resume = ifx_spi_spi_resume,
1442 .id_table = ifx_id_table 1370 .id_table = ifx_id_table
1443}; 1371};
1444 1372
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 00f250ae14c5..27bb75070c96 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -596,12 +596,6 @@ void jsm_input(struct jsm_channel *ch)
596 596
597 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start 2\n"); 597 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start 2\n");
598 598
599 if (data_len <= 0) {
600 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
601 jsm_dbg(READ, &ch->ch_bd->pci_dev, "jsm_input 1\n");
602 return;
603 }
604
605 len = tty_buffer_request_room(port, data_len); 599 len = tty_buffer_request_room(port, data_len);
606 n = len; 600 n = len;
607 601
diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
index 32517d4bceab..35866d5872ad 100644
--- a/drivers/tty/serial/max3100.c
+++ b/drivers/tty/serial/max3100.c
@@ -778,7 +778,7 @@ static int max3100_probe(struct spi_device *spi)
778 max3100s[i]->spi = spi; 778 max3100s[i]->spi = spi;
779 max3100s[i]->irq = spi->irq; 779 max3100s[i]->irq = spi->irq;
780 spin_lock_init(&max3100s[i]->conf_lock); 780 spin_lock_init(&max3100s[i]->conf_lock);
781 dev_set_drvdata(&spi->dev, max3100s[i]); 781 spi_set_drvdata(spi, max3100s[i]);
782 pdata = spi->dev.platform_data; 782 pdata = spi->dev.platform_data;
783 max3100s[i]->crystal = pdata->crystal; 783 max3100s[i]->crystal = pdata->crystal;
784 max3100s[i]->loopback = pdata->loopback; 784 max3100s[i]->loopback = pdata->loopback;
@@ -819,7 +819,7 @@ static int max3100_probe(struct spi_device *spi)
819 819
820static int max3100_remove(struct spi_device *spi) 820static int max3100_remove(struct spi_device *spi)
821{ 821{
822 struct max3100_port *s = dev_get_drvdata(&spi->dev); 822 struct max3100_port *s = spi_get_drvdata(spi);
823 int i; 823 int i;
824 824
825 mutex_lock(&max3100s_lock); 825 mutex_lock(&max3100s_lock);
@@ -849,11 +849,11 @@ static int max3100_remove(struct spi_device *spi)
849 return 0; 849 return 0;
850} 850}
851 851
852#ifdef CONFIG_PM 852#ifdef CONFIG_PM_SLEEP
853 853
854static int max3100_suspend(struct spi_device *spi, pm_message_t state) 854static int max3100_suspend(struct device *dev)
855{ 855{
856 struct max3100_port *s = dev_get_drvdata(&spi->dev); 856 struct max3100_port *s = dev_get_drvdata(dev);
857 857
858 dev_dbg(&s->spi->dev, "%s\n", __func__); 858 dev_dbg(&s->spi->dev, "%s\n", __func__);
859 859
@@ -874,9 +874,9 @@ static int max3100_suspend(struct spi_device *spi, pm_message_t state)
874 return 0; 874 return 0;
875} 875}
876 876
877static int max3100_resume(struct spi_device *spi) 877static int max3100_resume(struct device *dev)
878{ 878{
879 struct max3100_port *s = dev_get_drvdata(&spi->dev); 879 struct max3100_port *s = dev_get_drvdata(dev);
880 880
881 dev_dbg(&s->spi->dev, "%s\n", __func__); 881 dev_dbg(&s->spi->dev, "%s\n", __func__);
882 882
@@ -894,21 +894,21 @@ static int max3100_resume(struct spi_device *spi)
894 return 0; 894 return 0;
895} 895}
896 896
897static SIMPLE_DEV_PM_OPS(max3100_pm_ops, max3100_suspend, max3100_resume);
898#define MAX3100_PM_OPS (&max3100_pm_ops)
899
897#else 900#else
898#define max3100_suspend NULL 901#define MAX3100_PM_OPS NULL
899#define max3100_resume NULL
900#endif 902#endif
901 903
902static struct spi_driver max3100_driver = { 904static struct spi_driver max3100_driver = {
903 .driver = { 905 .driver = {
904 .name = "max3100", 906 .name = "max3100",
905 .owner = THIS_MODULE, 907 .owner = THIS_MODULE,
908 .pm = MAX3100_PM_OPS,
906 }, 909 },
907
908 .probe = max3100_probe, 910 .probe = max3100_probe,
909 .remove = max3100_remove, 911 .remove = max3100_remove,
910 .suspend = max3100_suspend,
911 .resume = max3100_resume,
912}; 912};
913 913
914module_spi_driver(max3100_driver); 914module_spi_driver(max3100_driver);
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 0c2422cb04ea..8941e6418942 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -881,12 +881,14 @@ static struct uart_ops max310x_ops = {
881 .verify_port = max310x_verify_port, 881 .verify_port = max310x_verify_port,
882}; 882};
883 883
884static int max310x_suspend(struct spi_device *spi, pm_message_t state) 884#ifdef CONFIG_PM_SLEEP
885
886static int max310x_suspend(struct device *dev)
885{ 887{
886 int ret; 888 int ret;
887 struct max310x_port *s = dev_get_drvdata(&spi->dev); 889 struct max310x_port *s = dev_get_drvdata(dev);
888 890
889 dev_dbg(&spi->dev, "Suspend\n"); 891 dev_dbg(dev, "Suspend\n");
890 892
891 ret = uart_suspend_port(&s->uart, &s->port); 893 ret = uart_suspend_port(&s->uart, &s->port);
892 894
@@ -905,11 +907,11 @@ static int max310x_suspend(struct spi_device *spi, pm_message_t state)
905 return ret; 907 return ret;
906} 908}
907 909
908static int max310x_resume(struct spi_device *spi) 910static int max310x_resume(struct device *dev)
909{ 911{
910 struct max310x_port *s = dev_get_drvdata(&spi->dev); 912 struct max310x_port *s = dev_get_drvdata(dev);
911 913
912 dev_dbg(&spi->dev, "Resume\n"); 914 dev_dbg(dev, "Resume\n");
913 915
914 if (s->pdata->suspend) 916 if (s->pdata->suspend)
915 s->pdata->suspend(0); 917 s->pdata->suspend(0);
@@ -928,6 +930,13 @@ static int max310x_resume(struct spi_device *spi)
928 return uart_resume_port(&s->uart, &s->port); 930 return uart_resume_port(&s->uart, &s->port);
929} 931}
930 932
933static SIMPLE_DEV_PM_OPS(max310x_pm_ops, max310x_suspend, max310x_resume);
934#define MAX310X_PM_OPS (&max310x_pm_ops)
935
936#else
937#define MAX310X_PM_OPS NULL
938#endif
939
931#ifdef CONFIG_GPIOLIB 940#ifdef CONFIG_GPIOLIB
932static int max310x_gpio_get(struct gpio_chip *chip, unsigned offset) 941static int max310x_gpio_get(struct gpio_chip *chip, unsigned offset)
933{ 942{
@@ -1242,11 +1251,10 @@ static struct spi_driver max310x_driver = {
1242 .driver = { 1251 .driver = {
1243 .name = "max310x", 1252 .name = "max310x",
1244 .owner = THIS_MODULE, 1253 .owner = THIS_MODULE,
1254 .pm = MAX310X_PM_OPS,
1245 }, 1255 },
1246 .probe = max310x_probe, 1256 .probe = max310x_probe,
1247 .remove = max310x_remove, 1257 .remove = max310x_remove,
1248 .suspend = max310x_suspend,
1249 .resume = max310x_resume,
1250 .id_table = max310x_id_table, 1258 .id_table = max310x_id_table,
1251}; 1259};
1252module_spi_driver(max310x_driver); 1260module_spi_driver(max310x_driver);
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
index f641c232beca..9b6ef20420c0 100644
--- a/drivers/tty/serial/mrst_max3110.c
+++ b/drivers/tty/serial/mrst_max3110.c
@@ -743,9 +743,10 @@ static struct uart_driver serial_m3110_reg = {
743 .cons = &serial_m3110_console, 743 .cons = &serial_m3110_console,
744}; 744};
745 745
746#ifdef CONFIG_PM 746#ifdef CONFIG_PM_SLEEP
747static int serial_m3110_suspend(struct spi_device *spi, pm_message_t state) 747static int serial_m3110_suspend(struct device *dev)
748{ 748{
749 struct spi_device *spi = to_spi_device(dev);
749 struct uart_max3110 *max = spi_get_drvdata(spi); 750 struct uart_max3110 *max = spi_get_drvdata(spi);
750 751
751 disable_irq(max->irq); 752 disable_irq(max->irq);
@@ -754,8 +755,9 @@ static int serial_m3110_suspend(struct spi_device *spi, pm_message_t state)
754 return 0; 755 return 0;
755} 756}
756 757
757static int serial_m3110_resume(struct spi_device *spi) 758static int serial_m3110_resume(struct device *dev)
758{ 759{
760 struct spi_device *spi = to_spi_device(dev);
759 struct uart_max3110 *max = spi_get_drvdata(spi); 761 struct uart_max3110 *max = spi_get_drvdata(spi);
760 762
761 max3110_out(max, max->cur_conf); 763 max3110_out(max, max->cur_conf);
@@ -763,9 +765,13 @@ static int serial_m3110_resume(struct spi_device *spi)
763 enable_irq(max->irq); 765 enable_irq(max->irq);
764 return 0; 766 return 0;
765} 767}
768
769static SIMPLE_DEV_PM_OPS(serial_m3110_pm_ops, serial_m3110_suspend,
770 serial_m3110_resume);
771#define SERIAL_M3110_PM_OPS (&serial_m3110_pm_ops)
772
766#else 773#else
767#define serial_m3110_suspend NULL 774#define SERIAL_M3110_PM_OPS NULL
768#define serial_m3110_resume NULL
769#endif 775#endif
770 776
771static int serial_m3110_probe(struct spi_device *spi) 777static int serial_m3110_probe(struct spi_device *spi)
@@ -872,11 +878,10 @@ static struct spi_driver uart_max3110_driver = {
872 .driver = { 878 .driver = {
873 .name = "spi_max3111", 879 .name = "spi_max3111",
874 .owner = THIS_MODULE, 880 .owner = THIS_MODULE,
881 .pm = SERIAL_M3110_PM_OPS,
875 }, 882 },
876 .probe = serial_m3110_probe, 883 .probe = serial_m3110_probe,
877 .remove = serial_m3110_remove, 884 .remove = serial_m3110_remove,
878 .suspend = serial_m3110_suspend,
879 .resume = serial_m3110_resume,
880}; 885};
881 886
882static int __init serial_m3110_init(void) 887static int __init serial_m3110_init(void)
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c
index 4a942c78347e..4ca2f64861e6 100644
--- a/drivers/tty/serial/msm_serial_hs.c
+++ b/drivers/tty/serial/msm_serial_hs.c
@@ -907,7 +907,6 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr,
907 unsigned int error_f = 0; 907 unsigned int error_f = 0;
908 unsigned long flags; 908 unsigned long flags;
909 unsigned int flush; 909 unsigned int flush;
910 struct tty_struct *tty;
911 struct tty_port *port; 910 struct tty_port *port;
912 struct uart_port *uport; 911 struct uart_port *uport;
913 struct msm_hs_port *msm_uport; 912 struct msm_hs_port *msm_uport;
@@ -919,7 +918,6 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr,
919 clk_enable(msm_uport->clk); 918 clk_enable(msm_uport->clk);
920 919
921 port = &uport->state->port; 920 port = &uport->state->port;
922 tty = port->tty;
923 921
924 msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE); 922 msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE);
925 923
diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c
index e722ff163d91..1238ac370bff 100644
--- a/drivers/tty/serial/msm_smd_tty.c
+++ b/drivers/tty/serial/msm_smd_tty.c
@@ -90,13 +90,13 @@ static void smd_tty_notify(void *priv, unsigned event)
90 90
91static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty) 91static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty)
92{ 92{
93 struct smd_tty_info *info = container_of(tport, struct smd_tty_info,
94 port);
93 int i, res = 0; 95 int i, res = 0;
94 int n = tty->index;
95 const char *name = NULL; 96 const char *name = NULL;
96 struct smd_tty_info *info = smd_tty + n;
97 97
98 for (i = 0; i < smd_tty_channels_len; i++) { 98 for (i = 0; i < smd_tty_channels_len; i++) {
99 if (smd_tty_channels[i].id == n) { 99 if (smd_tty_channels[i].id == tty->index) {
100 name = smd_tty_channels[i].name; 100 name = smd_tty_channels[i].name;
101 break; 101 break;
102 } 102 }
@@ -117,17 +117,13 @@ static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty)
117 117
118static void smd_tty_port_shutdown(struct tty_port *tport) 118static void smd_tty_port_shutdown(struct tty_port *tport)
119{ 119{
120 struct smd_tty_info *info; 120 struct smd_tty_info *info = container_of(tport, struct smd_tty_info,
121 struct tty_struct *tty = tty_port_tty_get(tport); 121 port);
122 122
123 info = tty->driver_data;
124 if (info->ch) { 123 if (info->ch) {
125 smd_close(info->ch); 124 smd_close(info->ch);
126 info->ch = 0; 125 info->ch = 0;
127 } 126 }
128
129 tty->driver_data = 0;
130 tty_kref_put(tty);
131} 127}
132 128
133static int smd_tty_open(struct tty_struct *tty, struct file *f) 129static int smd_tty_open(struct tty_struct *tty, struct file *f)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index d549fe1fa42a..62e7d3b015a1 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -883,7 +883,7 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
883 unsigned int old_ctrl0, old_ctrl2; 883 unsigned int old_ctrl0, old_ctrl2;
884 unsigned int to = 1000; 884 unsigned int to = 1000;
885 885
886 if (co->index > MXS_AUART_PORTS || co->index < 0) 886 if (co->index >= MXS_AUART_PORTS || co->index < 0)
887 return; 887 return;
888 888
889 s = auart_port[co->index]; 889 s = auart_port[co->index];
@@ -1103,7 +1103,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
1103 s->port.fifosize = 16; 1103 s->port.fifosize = 16;
1104 s->port.uartclk = clk_get_rate(s->clk); 1104 s->port.uartclk = clk_get_rate(s->clk);
1105 s->port.type = PORT_IMX; 1105 s->port.type = PORT_IMX;
1106 s->port.dev = s->dev = get_device(&pdev->dev); 1106 s->port.dev = s->dev = &pdev->dev;
1107 1107
1108 s->ctrl = 0; 1108 s->ctrl = 0;
1109 1109
@@ -1134,7 +1134,6 @@ out_free_irq:
1134 auart_port[pdev->id] = NULL; 1134 auart_port[pdev->id] = NULL;
1135 free_irq(s->irq, s); 1135 free_irq(s->irq, s);
1136out_free_clk: 1136out_free_clk:
1137 put_device(s->dev);
1138 clk_put(s->clk); 1137 clk_put(s->clk);
1139out_free: 1138out_free:
1140 kfree(s); 1139 kfree(s);
@@ -1150,7 +1149,6 @@ static int mxs_auart_remove(struct platform_device *pdev)
1150 1149
1151 auart_port[pdev->id] = NULL; 1150 auart_port[pdev->id] = NULL;
1152 1151
1153 put_device(s->dev);
1154 clk_put(s->clk); 1152 clk_put(s->clk);
1155 free_irq(s->irq, s); 1153 free_irq(s->irq, s);
1156 kfree(s); 1154 kfree(s);
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index b025d5438275..39c7ea4cb14f 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -14,7 +14,6 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/serial_core.h> 16#include <linux/serial_core.h>
17#include <linux/serial_8250.h>
18#include <linux/serial_reg.h> 17#include <linux/serial_reg.h>
19#include <linux/of_address.h> 18#include <linux/of_address.h>
20#include <linux/of_irq.h> 19#include <linux/of_irq.h>
@@ -22,6 +21,8 @@
22#include <linux/nwpserial.h> 21#include <linux/nwpserial.h>
23#include <linux/clk.h> 22#include <linux/clk.h>
24 23
24#include "8250/8250.h"
25
25struct of_serial_info { 26struct of_serial_info {
26 struct clk *clk; 27 struct clk *clk;
27 int type; 28 int type;
@@ -97,6 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
97 if (of_property_read_u32(np, "reg-shift", &prop) == 0) 98 if (of_property_read_u32(np, "reg-shift", &prop) == 0)
98 port->regshift = prop; 99 port->regshift = prop;
99 100
101 /* Check for fifo size */
102 if (of_property_read_u32(np, "fifo-size", &prop) == 0)
103 port->fifosize = prop;
104
100 port->irq = irq_of_parse_and_map(np, 0); 105 port->irq = irq_of_parse_and_map(np, 0);
101 port->iotype = UPIO_MEM; 106 port->iotype = UPIO_MEM;
102 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { 107 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
@@ -167,11 +172,17 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
167#ifdef CONFIG_SERIAL_8250 172#ifdef CONFIG_SERIAL_8250
168 case PORT_8250 ... PORT_MAX_8250: 173 case PORT_8250 ... PORT_MAX_8250:
169 { 174 {
170 /* For now the of bindings don't support the extra
171 8250 specific bits */
172 struct uart_8250_port port8250; 175 struct uart_8250_port port8250;
173 memset(&port8250, 0, sizeof(port8250)); 176 memset(&port8250, 0, sizeof(port8250));
174 port8250.port = port; 177 port8250.port = port;
178
179 if (port.fifosize)
180 port8250.capabilities = UART_CAP_FIFO;
181
182 if (of_property_read_bool(ofdev->dev.of_node,
183 "auto-flow-control"))
184 port8250.capabilities |= UART_CAP_AFE;
185
175 ret = serial8250_register_8250_port(&port8250); 186 ret = serial8250_register_8250_port(&port8250);
176 break; 187 break;
177 } 188 }
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 7a6c989924b3..21a7e179edf3 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -1493,29 +1493,6 @@ static int pch_uart_verify_port(struct uart_port *port,
1493 return 0; 1493 return 0;
1494} 1494}
1495 1495
1496static struct uart_ops pch_uart_ops = {
1497 .tx_empty = pch_uart_tx_empty,
1498 .set_mctrl = pch_uart_set_mctrl,
1499 .get_mctrl = pch_uart_get_mctrl,
1500 .stop_tx = pch_uart_stop_tx,
1501 .start_tx = pch_uart_start_tx,
1502 .stop_rx = pch_uart_stop_rx,
1503 .enable_ms = pch_uart_enable_ms,
1504 .break_ctl = pch_uart_break_ctl,
1505 .startup = pch_uart_startup,
1506 .shutdown = pch_uart_shutdown,
1507 .set_termios = pch_uart_set_termios,
1508/* .pm = pch_uart_pm, Not supported yet */
1509/* .set_wake = pch_uart_set_wake, Not supported yet */
1510 .type = pch_uart_type,
1511 .release_port = pch_uart_release_port,
1512 .request_port = pch_uart_request_port,
1513 .config_port = pch_uart_config_port,
1514 .verify_port = pch_uart_verify_port
1515};
1516
1517#ifdef CONFIG_SERIAL_PCH_UART_CONSOLE
1518
1519/* 1496/*
1520 * Wait for transmitter & holding register to empty 1497 * Wait for transmitter & holding register to empty
1521 */ 1498 */
@@ -1547,6 +1524,84 @@ static void wait_for_xmitr(struct eg20t_port *up, int bits)
1547 } 1524 }
1548} 1525}
1549 1526
1527#ifdef CONFIG_CONSOLE_POLL
1528/*
1529 * Console polling routines for communicate via uart while
1530 * in an interrupt or debug context.
1531 */
1532static int pch_uart_get_poll_char(struct uart_port *port)
1533{
1534 struct eg20t_port *priv =
1535 container_of(port, struct eg20t_port, port);
1536 u8 lsr = ioread8(priv->membase + UART_LSR);
1537
1538 if (!(lsr & UART_LSR_DR))
1539 return NO_POLL_CHAR;
1540
1541 return ioread8(priv->membase + PCH_UART_RBR);
1542}
1543
1544
1545static void pch_uart_put_poll_char(struct uart_port *port,
1546 unsigned char c)
1547{
1548 unsigned int ier;
1549 struct eg20t_port *priv =
1550 container_of(port, struct eg20t_port, port);
1551
1552 /*
1553 * First save the IER then disable the interrupts
1554 */
1555 ier = ioread8(priv->membase + UART_IER);
1556 pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_ALL_INT);
1557
1558 wait_for_xmitr(priv, UART_LSR_THRE);
1559 /*
1560 * Send the character out.
1561 * If a LF, also do CR...
1562 */
1563 iowrite8(c, priv->membase + PCH_UART_THR);
1564 if (c == 10) {
1565 wait_for_xmitr(priv, UART_LSR_THRE);
1566 iowrite8(13, priv->membase + PCH_UART_THR);
1567 }
1568
1569 /*
1570 * Finally, wait for transmitter to become empty
1571 * and restore the IER
1572 */
1573 wait_for_xmitr(priv, BOTH_EMPTY);
1574 iowrite8(ier, priv->membase + UART_IER);
1575}
1576#endif /* CONFIG_CONSOLE_POLL */
1577
1578static struct uart_ops pch_uart_ops = {
1579 .tx_empty = pch_uart_tx_empty,
1580 .set_mctrl = pch_uart_set_mctrl,
1581 .get_mctrl = pch_uart_get_mctrl,
1582 .stop_tx = pch_uart_stop_tx,
1583 .start_tx = pch_uart_start_tx,
1584 .stop_rx = pch_uart_stop_rx,
1585 .enable_ms = pch_uart_enable_ms,
1586 .break_ctl = pch_uart_break_ctl,
1587 .startup = pch_uart_startup,
1588 .shutdown = pch_uart_shutdown,
1589 .set_termios = pch_uart_set_termios,
1590/* .pm = pch_uart_pm, Not supported yet */
1591/* .set_wake = pch_uart_set_wake, Not supported yet */
1592 .type = pch_uart_type,
1593 .release_port = pch_uart_release_port,
1594 .request_port = pch_uart_request_port,
1595 .config_port = pch_uart_config_port,
1596 .verify_port = pch_uart_verify_port,
1597#ifdef CONFIG_CONSOLE_POLL
1598 .poll_get_char = pch_uart_get_poll_char,
1599 .poll_put_char = pch_uart_put_poll_char,
1600#endif
1601};
1602
1603#ifdef CONFIG_SERIAL_PCH_UART_CONSOLE
1604
1550static void pch_console_putchar(struct uart_port *port, int ch) 1605static void pch_console_putchar(struct uart_port *port, int ch)
1551{ 1606{
1552 struct eg20t_port *priv = 1607 struct eg20t_port *priv =
@@ -1655,7 +1710,7 @@ static struct console pch_console = {
1655#define PCH_CONSOLE (&pch_console) 1710#define PCH_CONSOLE (&pch_console)
1656#else 1711#else
1657#define PCH_CONSOLE NULL 1712#define PCH_CONSOLE NULL
1658#endif 1713#endif /* CONFIG_SERIAL_PCH_UART_CONSOLE */
1659 1714
1660static struct uart_driver pch_uart_driver = { 1715static struct uart_driver pch_uart_driver = {
1661 .owner = THIS_MODULE, 1716 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 2769a38d15b6..074b9194144f 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -39,6 +39,7 @@
39#include <linux/tty_flip.h> 39#include <linux/tty_flip.h>
40#include <linux/serial_core.h> 40#include <linux/serial_core.h>
41#include <linux/serial.h> 41#include <linux/serial.h>
42#include <linux/serial_s3c.h>
42#include <linux/delay.h> 43#include <linux/delay.h>
43#include <linux/clk.h> 44#include <linux/clk.h>
44#include <linux/cpufreq.h> 45#include <linux/cpufreq.h>
@@ -46,10 +47,9 @@
46 47
47#include <asm/irq.h> 48#include <asm/irq.h>
48 49
49#include <mach/hardware.h> 50#ifdef CONFIG_SAMSUNG_CLOCK
50
51#include <plat/regs-serial.h>
52#include <plat/clock.h> 51#include <plat/clock.h>
52#endif
53 53
54#include "samsung.h" 54#include "samsung.h"
55 55
@@ -446,6 +446,8 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
446 446
447 /* Clear pending interrupts and mask all interrupts */ 447 /* Clear pending interrupts and mask all interrupts */
448 if (s3c24xx_serial_has_interrupt_mask(port)) { 448 if (s3c24xx_serial_has_interrupt_mask(port)) {
449 free_irq(port->irq, ourport);
450
449 wr_regl(port, S3C64XX_UINTP, 0xf); 451 wr_regl(port, S3C64XX_UINTP, 0xf);
450 wr_regl(port, S3C64XX_UINTM, 0xf); 452 wr_regl(port, S3C64XX_UINTM, 0xf);
451 } 453 }
@@ -505,6 +507,8 @@ static int s3c64xx_serial_startup(struct uart_port *port)
505 dbg("s3c64xx_serial_startup: port=%p (%08lx,%p)\n", 507 dbg("s3c64xx_serial_startup: port=%p (%08lx,%p)\n",
506 port->mapbase, port->membase); 508 port->mapbase, port->membase);
507 509
510 wr_regl(port, S3C64XX_UINTM, 0xf);
511
508 ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, 512 ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED,
509 s3c24xx_serial_portname(port), ourport); 513 s3c24xx_serial_portname(port), ourport);
510 if (ret) { 514 if (ret) {
@@ -894,7 +898,7 @@ console_initcall(s3c24xx_serial_console_init);
894#define S3C24XX_SERIAL_CONSOLE NULL 898#define S3C24XX_SERIAL_CONSOLE NULL
895#endif 899#endif
896 900
897#ifdef CONFIG_CONSOLE_POLL 901#if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_CONSOLE_POLL)
898static int s3c24xx_serial_get_poll_char(struct uart_port *port); 902static int s3c24xx_serial_get_poll_char(struct uart_port *port);
899static void s3c24xx_serial_put_poll_char(struct uart_port *port, 903static void s3c24xx_serial_put_poll_char(struct uart_port *port,
900 unsigned char c); 904 unsigned char c);
@@ -918,7 +922,7 @@ static struct uart_ops s3c24xx_serial_ops = {
918 .request_port = s3c24xx_serial_request_port, 922 .request_port = s3c24xx_serial_request_port,
919 .config_port = s3c24xx_serial_config_port, 923 .config_port = s3c24xx_serial_config_port,
920 .verify_port = s3c24xx_serial_verify_port, 924 .verify_port = s3c24xx_serial_verify_port,
921#ifdef CONFIG_CONSOLE_POLL 925#if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_CONSOLE_POLL)
922 .poll_get_char = s3c24xx_serial_get_poll_char, 926 .poll_get_char = s3c24xx_serial_get_poll_char,
923 .poll_put_char = s3c24xx_serial_put_poll_char, 927 .poll_put_char = s3c24xx_serial_put_poll_char,
924#endif 928#endif
@@ -1179,6 +1183,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1179 return 0; 1183 return 0;
1180} 1184}
1181 1185
1186#ifdef CONFIG_SAMSUNG_CLOCK
1182static ssize_t s3c24xx_serial_show_clksrc(struct device *dev, 1187static ssize_t s3c24xx_serial_show_clksrc(struct device *dev,
1183 struct device_attribute *attr, 1188 struct device_attribute *attr,
1184 char *buf) 1189 char *buf)
@@ -1194,7 +1199,7 @@ static ssize_t s3c24xx_serial_show_clksrc(struct device *dev,
1194} 1199}
1195 1200
1196static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL); 1201static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL);
1197 1202#endif
1198 1203
1199/* Device driver serial port probe */ 1204/* Device driver serial port probe */
1200 1205
@@ -1252,9 +1257,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
1252 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); 1257 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
1253 platform_set_drvdata(pdev, &ourport->port); 1258 platform_set_drvdata(pdev, &ourport->port);
1254 1259
1260#ifdef CONFIG_SAMSUNG_CLOCK
1255 ret = device_create_file(&pdev->dev, &dev_attr_clock_source); 1261 ret = device_create_file(&pdev->dev, &dev_attr_clock_source);
1256 if (ret < 0) 1262 if (ret < 0)
1257 dev_err(&pdev->dev, "failed to add clock source attr.\n"); 1263 dev_err(&pdev->dev, "failed to add clock source attr.\n");
1264#endif
1258 1265
1259 ret = s3c24xx_serial_cpufreq_register(ourport); 1266 ret = s3c24xx_serial_cpufreq_register(ourport);
1260 if (ret < 0) 1267 if (ret < 0)
@@ -1272,7 +1279,9 @@ static int s3c24xx_serial_remove(struct platform_device *dev)
1272 1279
1273 if (port) { 1280 if (port) {
1274 s3c24xx_serial_cpufreq_deregister(to_ourport(port)); 1281 s3c24xx_serial_cpufreq_deregister(to_ourport(port));
1282#ifdef CONFIG_SAMSUNG_CLOCK
1275 device_remove_file(&dev->dev, &dev_attr_clock_source); 1283 device_remove_file(&dev->dev, &dev_attr_clock_source);
1284#endif
1276 uart_remove_one_port(&s3c24xx_uart_drv, port); 1285 uart_remove_one_port(&s3c24xx_uart_drv, port);
1277 } 1286 }
1278 1287
@@ -1307,9 +1316,29 @@ static int s3c24xx_serial_resume(struct device *dev)
1307 return 0; 1316 return 0;
1308} 1317}
1309 1318
1319static int s3c24xx_serial_resume_noirq(struct device *dev)
1320{
1321 struct uart_port *port = s3c24xx_dev_to_port(dev);
1322
1323 if (port) {
1324 /* restore IRQ mask */
1325 if (s3c24xx_serial_has_interrupt_mask(port)) {
1326 unsigned int uintm = 0xf;
1327 if (tx_enabled(port))
1328 uintm &= ~S3C64XX_UINTM_TXD_MSK;
1329 if (rx_enabled(port))
1330 uintm &= ~S3C64XX_UINTM_RXD_MSK;
1331 wr_regl(port, S3C64XX_UINTM, uintm);
1332 }
1333 }
1334
1335 return 0;
1336}
1337
1310static const struct dev_pm_ops s3c24xx_serial_pm_ops = { 1338static const struct dev_pm_ops s3c24xx_serial_pm_ops = {
1311 .suspend = s3c24xx_serial_suspend, 1339 .suspend = s3c24xx_serial_suspend,
1312 .resume = s3c24xx_serial_resume, 1340 .resume = s3c24xx_serial_resume,
1341 .resume_noirq = s3c24xx_serial_resume_noirq,
1313}; 1342};
1314#define SERIAL_SAMSUNG_PM_OPS (&s3c24xx_serial_pm_ops) 1343#define SERIAL_SAMSUNG_PM_OPS (&s3c24xx_serial_pm_ops)
1315 1344
@@ -1343,6 +1372,13 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
1343 return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0; 1372 return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
1344} 1373}
1345 1374
1375static bool
1376s3c24xx_port_configured(unsigned int ucon)
1377{
1378 /* consider the serial port configured if the tx/rx mode set */
1379 return (ucon & 0xf) != 0;
1380}
1381
1346#ifdef CONFIG_CONSOLE_POLL 1382#ifdef CONFIG_CONSOLE_POLL
1347/* 1383/*
1348 * Console polling routines for writing and reading from the uart while 1384 * Console polling routines for writing and reading from the uart while
@@ -1365,6 +1401,11 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1365 unsigned char c) 1401 unsigned char c)
1366{ 1402{
1367 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1403 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
1404 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
1405
1406 /* not possible to xmit on unconfigured port */
1407 if (!s3c24xx_port_configured(ucon))
1408 return;
1368 1409
1369 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1410 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1370 cpu_relax(); 1411 cpu_relax();
@@ -1377,6 +1418,12 @@ static void
1377s3c24xx_serial_console_putchar(struct uart_port *port, int ch) 1418s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
1378{ 1419{
1379 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1420 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
1421 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
1422
1423 /* not possible to xmit on unconfigured port */
1424 if (!s3c24xx_port_configured(ucon))
1425 return;
1426
1380 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1427 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1381 barrier(); 1428 barrier();
1382 wr_regb(cons_uart, S3C2410_UTXH, ch); 1429 wr_regb(cons_uart, S3C2410_UTXH, ch);
@@ -1409,9 +1456,7 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud,
1409 "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n", 1456 "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n",
1410 port, ulcon, ucon, ubrdiv); 1457 port, ulcon, ucon, ubrdiv);
1411 1458
1412 if ((ucon & 0xf) != 0) { 1459 if (s3c24xx_port_configured(ucon)) {
1413 /* consider the serial port configured if the tx/rx mode set */
1414
1415 switch (ulcon & S3C2410_LCON_CSMASK) { 1460 switch (ulcon & S3C2410_LCON_CSMASK) {
1416 case S3C2410_LCON_CS5: 1461 case S3C2410_LCON_CS5:
1417 *bits = 5; 1462 *bits = 5;
diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h
index 1a4bca3e4179..00a499ecd385 100644
--- a/drivers/tty/serial/samsung.h
+++ b/drivers/tty/serial/samsung.h
@@ -76,7 +76,9 @@ struct s3c24xx_uart_port {
76#define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg)) 76#define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg))
77#define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg)) 77#define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg))
78 78
79#ifdef CONFIG_SERIAL_SAMSUNG_DEBUG 79#if defined(CONFIG_SERIAL_SAMSUNG_DEBUG) && \
80 defined(CONFIG_DEBUG_LL) && \
81 !defined(MODULE)
80 82
81extern void printascii(const char *); 83extern void printascii(const char *);
82 84
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index 08dbfb88d42c..c77304155410 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -27,6 +27,7 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/platform_data/serial-sccnxp.h> 29#include <linux/platform_data/serial-sccnxp.h>
30#include <linux/regulator/consumer.h>
30 31
31#define SCCNXP_NAME "uart-sccnxp" 32#define SCCNXP_NAME "uart-sccnxp"
32#define SCCNXP_MAJOR 204 33#define SCCNXP_MAJOR 204
@@ -131,6 +132,8 @@ struct sccnxp_port {
131 struct timer_list timer; 132 struct timer_list timer;
132 133
133 struct sccnxp_pdata pdata; 134 struct sccnxp_pdata pdata;
135
136 struct regulator *regulator;
134}; 137};
135 138
136static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift) 139static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift)
@@ -789,8 +792,6 @@ static int sccnxp_probe(struct platform_device *pdev)
789 return -EADDRNOTAVAIL; 792 return -EADDRNOTAVAIL;
790 } 793 }
791 794
792 dev_set_name(&pdev->dev, SCCNXP_NAME);
793
794 s = devm_kzalloc(&pdev->dev, sizeof(struct sccnxp_port), GFP_KERNEL); 795 s = devm_kzalloc(&pdev->dev, sizeof(struct sccnxp_port), GFP_KERNEL);
795 if (!s) { 796 if (!s) {
796 dev_err(&pdev->dev, "Error allocating port structure\n"); 797 dev_err(&pdev->dev, "Error allocating port structure\n");
@@ -918,6 +919,16 @@ static int sccnxp_probe(struct platform_device *pdev)
918 goto err_out; 919 goto err_out;
919 } 920 }
920 921
922 s->regulator = devm_regulator_get(&pdev->dev, "VCC");
923 if (!IS_ERR(s->regulator)) {
924 ret = regulator_enable(s->regulator);
925 if (ret) {
926 dev_err(&pdev->dev,
927 "Failed to enable regulator: %i\n", ret);
928 return ret;
929 }
930 }
931
921 membase = devm_ioremap_resource(&pdev->dev, res); 932 membase = devm_ioremap_resource(&pdev->dev, res);
922 if (IS_ERR(membase)) { 933 if (IS_ERR(membase)) {
923 ret = PTR_ERR(membase); 934 ret = PTR_ERR(membase);
@@ -967,10 +978,6 @@ static int sccnxp_probe(struct platform_device *pdev)
967 s->imr = 0; 978 s->imr = 0;
968 sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0); 979 sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0);
969 980
970 /* Board specific configure */
971 if (s->pdata.init)
972 s->pdata.init();
973
974 if (!s->poll) { 981 if (!s->poll) {
975 ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, 982 ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL,
976 sccnxp_ist, 983 sccnxp_ist,
@@ -1011,8 +1018,8 @@ static int sccnxp_remove(struct platform_device *pdev)
1011 uart_unregister_driver(&s->uart); 1018 uart_unregister_driver(&s->uart);
1012 platform_set_drvdata(pdev, NULL); 1019 platform_set_drvdata(pdev, NULL);
1013 1020
1014 if (s->pdata.exit) 1021 if (!IS_ERR(s->regulator))
1015 s->pdata.exit(); 1022 return regulator_disable(s->regulator);
1016 1023
1017 return 0; 1024 return 0;
1018} 1025}
diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index 372de8ade76a..9799d043a9bd 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -26,6 +26,7 @@
26#include <linux/dmaengine.h> 26#include <linux/dmaengine.h>
27#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/dmapool.h> 28#include <linux/dmapool.h>
29#include <linux/err.h>
29#include <linux/io.h> 30#include <linux/io.h>
30#include <linux/irq.h> 31#include <linux/irq.h>
31#include <linux/module.h> 32#include <linux/module.h>
@@ -1301,11 +1302,9 @@ static int tegra_uart_probe(struct platform_device *pdev)
1301 } 1302 }
1302 1303
1303 u->mapbase = resource->start; 1304 u->mapbase = resource->start;
1304 u->membase = devm_request_and_ioremap(&pdev->dev, resource); 1305 u->membase = devm_ioremap_resource(&pdev->dev, resource);
1305 if (!u->membase) { 1306 if (IS_ERR(u->membase))
1306 dev_err(&pdev->dev, "memregion/iomap address req failed\n"); 1307 return PTR_ERR(u->membase);
1307 return -EADDRNOTAVAIL;
1308 }
1309 1308
1310 tup->uart_clk = devm_clk_get(&pdev->dev, NULL); 1309 tup->uart_clk = devm_clk_get(&pdev->dev, NULL);
1311 if (IS_ERR(tup->uart_clk)) { 1310 if (IS_ERR(tup->uart_clk)) {
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index a400002dfa84..8fbb6d22cdc8 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1941,6 +1941,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
1941 mutex_unlock(&port->mutex); 1941 mutex_unlock(&port->mutex);
1942 return 0; 1942 return 0;
1943 } 1943 }
1944 put_device(tty_dev);
1945
1944 if (console_suspend_enabled || !uart_console(uport)) 1946 if (console_suspend_enabled || !uart_console(uport))
1945 uport->suspended = 1; 1947 uport->suspended = 1;
1946 1948
@@ -2006,9 +2008,11 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
2006 disable_irq_wake(uport->irq); 2008 disable_irq_wake(uport->irq);
2007 uport->irq_wake = 0; 2009 uport->irq_wake = 0;
2008 } 2010 }
2011 put_device(tty_dev);
2009 mutex_unlock(&port->mutex); 2012 mutex_unlock(&port->mutex);
2010 return 0; 2013 return 0;
2011 } 2014 }
2015 put_device(tty_dev);
2012 uport->suspended = 0; 2016 uport->suspended = 0;
2013 2017
2014 /* 2018 /*
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index 4c22a1529aac..5aca7364634c 100644
--- a/drivers/tty/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
@@ -15,8 +15,6 @@
15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
16 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 16 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
17 defined(CONFIG_ARCH_SH73A0) || \ 17 defined(CONFIG_ARCH_SH73A0) || \
18 defined(CONFIG_ARCH_SH7367) || \
19 defined(CONFIG_ARCH_SH7377) || \
20 defined(CONFIG_ARCH_SH7372) || \ 18 defined(CONFIG_ARCH_SH7372) || \
21 defined(CONFIG_ARCH_R8A7740) 19 defined(CONFIG_ARCH_R8A7740)
22 20
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c
index 6bbfe9934a4d..03465b673945 100644
--- a/drivers/tty/serial/sirfsoc_uart.c
+++ b/drivers/tty/serial/sirfsoc_uart.c
@@ -758,7 +758,7 @@ static struct of_device_id sirfsoc_uart_ids[] = {
758 { .compatible = "sirf,marco-uart", }, 758 { .compatible = "sirf,marco-uart", },
759 {} 759 {}
760}; 760};
761MODULE_DEVICE_TABLE(of, sirfsoc_serial_of_match); 761MODULE_DEVICE_TABLE(of, sirfsoc_uart_ids);
762 762
763static struct platform_driver sirfsoc_uart_driver = { 763static struct platform_driver sirfsoc_uart_driver = {
764 .probe = sirfsoc_uart_probe, 764 .probe = sirfsoc_uart_probe,
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 8de2213664e0..a422c8b55a47 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -203,7 +203,7 @@ receive_chars(struct uart_sunsab_port *up,
203 flag = TTY_FRAME; 203 flag = TTY_FRAME;
204 } 204 }
205 205
206 if (uart_handle_sysrq_char(&up->port, ch)) 206 if (uart_handle_sysrq_char(&up->port, ch) || !port)
207 continue; 207 continue;
208 208
209 if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && 209 if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 &&
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index 27669ff3d446..813ef8eb8eff 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -388,7 +388,7 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up,
388 else if (r1 & CRC_ERR) 388 else if (r1 & CRC_ERR)
389 flag = TTY_FRAME; 389 flag = TTY_FRAME;
390 } 390 }
391 if (uart_handle_sysrq_char(&up->port, ch)) 391 if (uart_handle_sysrq_char(&up->port, ch) || !port)
392 continue; 392 continue;
393 393
394 if (up->port.ignore_status_mask == 0xff || 394 if (up->port.ignore_status_mask == 0xff ||
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 705240e6c4ec..1a8bc2275ea4 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -35,6 +35,7 @@
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/of.h> 37#include <linux/of.h>
38#include <linux/err.h>
38 39
39/* 40/*
40 * UART Register offsets 41 * UART Register offsets
@@ -585,9 +586,9 @@ static int vt8500_serial_probe(struct platform_device *pdev)
585 if (!vt8500_port) 586 if (!vt8500_port)
586 return -ENOMEM; 587 return -ENOMEM;
587 588
588 vt8500_port->uart.membase = devm_request_and_ioremap(&pdev->dev, mmres); 589 vt8500_port->uart.membase = devm_ioremap_resource(&pdev->dev, mmres);
589 if (!vt8500_port->uart.membase) 590 if (IS_ERR(vt8500_port->uart.membase))
590 return -EADDRNOTAVAIL; 591 return PTR_ERR(vt8500_port->uart.membase);
591 592
592 vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); 593 vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0);
593 if (IS_ERR(vt8500_port->clk)) { 594 if (IS_ERR(vt8500_port->clk)) {
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index f36bbba1ac8b..4e5c77834c50 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -585,9 +585,6 @@ static int xuartps_startup(struct uart_port *port)
585 xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | 585 xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY |
586 XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | 586 XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN |
587 XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET); 587 XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET);
588 xuartps_writel(~(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY |
589 XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN |
590 XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT), XUARTPS_IDR_OFFSET);
591 588
592 return retval; 589 return retval;
593} 590}