aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt6
-rw-r--r--arch/arm/boot/dts/armada-38x.dtsi4
-rw-r--r--drivers/tty/ipwireless/network.c2
-rw-r--r--drivers/tty/n_gsm.c2
-rw-r--r--drivers/tty/nozomi.c104
-rw-r--r--drivers/tty/pty.c3
-rw-r--r--drivers/tty/serial/8250/8250_aspeed_vuart.c125
-rw-r--r--drivers/tty/serial/8250/8250_dw.c35
-rw-r--r--drivers/tty/serial/8250/8250_early.c2
-rw-r--r--drivers/tty/serial/8250/8250_of.c63
-rw-r--r--drivers/tty/serial/8250/8250_omap.c27
-rw-r--r--drivers/tty/serial/8250/8250_port.c6
-rw-r--r--drivers/tty/serial/Kconfig8
-rw-r--r--drivers/tty/serial/amba-pl011.c16
-rw-r--r--drivers/tty/serial/atmel_serial.c5
-rw-r--r--drivers/tty/serial/earlycon.c5
-rw-r--r--drivers/tty/serial/imx.c43
-rw-r--r--drivers/tty/serial/msm_serial.c23
-rw-r--r--drivers/tty/serial/mvebu-uart.c64
-rw-r--r--drivers/tty/serial/qcom_geni_serial.c177
-rw-r--r--drivers/tty/serial/samsung.c40
-rw-r--r--drivers/tty/serial/sc16is7xx.c5
-rw-r--r--drivers/tty/serial/serial_core.c4
-rw-r--r--drivers/tty/serial/sh-sci.c81
-rw-r--r--drivers/tty/serial/sh-sci.h4
-rw-r--r--drivers/tty/serial/st-asc.c6
-rw-r--r--drivers/tty/serial/xilinx_uartps.c108
-rw-r--r--drivers/tty/vt/vt.c16
-rw-r--r--include/linux/serial_8250.h1
-rw-r--r--include/linux/serial_core.h4
-rw-r--r--include/uapi/linux/tty_flags.h2
31 files changed, 694 insertions, 297 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 9d699c85d8fe..1beb30d8d7fc 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1020,6 +1020,12 @@
1020 address. The serial port must already be setup 1020 address. The serial port must already be setup
1021 and configured. Options are not yet supported. 1021 and configured. Options are not yet supported.
1022 1022
1023 qcom_geni,<addr>
1024 Start an early, polled-mode console on a Qualcomm
1025 Generic Interface (GENI) based serial port at the
1026 specified address. The serial port must already be
1027 setup and configured. Options are not yet supported.
1028
1023 earlyprintk= [X86,SH,ARM,M68k,S390] 1029 earlyprintk= [X86,SH,ARM,M68k,S390]
1024 earlyprintk=vga 1030 earlyprintk=vga
1025 earlyprintk=efi 1031 earlyprintk=efi
diff --git a/arch/arm/boot/dts/armada-38x.dtsi b/arch/arm/boot/dts/armada-38x.dtsi
index 4cc09e43eea2..6916d7532ad2 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -163,7 +163,7 @@
163 }; 163 };
164 164
165 uart0: serial@12000 { 165 uart0: serial@12000 {
166 compatible = "snps,dw-apb-uart"; 166 compatible = "marvell,armada-38x-uart";
167 reg = <0x12000 0x100>; 167 reg = <0x12000 0x100>;
168 reg-shift = <2>; 168 reg-shift = <2>;
169 interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>; 169 interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
@@ -173,7 +173,7 @@
173 }; 173 };
174 174
175 uart1: serial@12100 { 175 uart1: serial@12100 {
176 compatible = "snps,dw-apb-uart"; 176 compatible = "marvell,armada-38x-uart";
177 reg = <0x12100 0x100>; 177 reg = <0x12100 0x100>;
178 reg-shift = <2>; 178 reg-shift = <2>;
179 interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>; 179 interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c
index 695439c03147..cf20616340a1 100644
--- a/drivers/tty/ipwireless/network.c
+++ b/drivers/tty/ipwireless/network.c
@@ -416,7 +416,7 @@ void ipwireless_network_packet_received(struct ipw_network *network,
416struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw) 416struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw)
417{ 417{
418 struct ipw_network *network = 418 struct ipw_network *network =
419 kzalloc(sizeof(struct ipw_network), GFP_ATOMIC); 419 kzalloc(sizeof(struct ipw_network), GFP_KERNEL);
420 420
421 if (!network) 421 if (!network)
422 return NULL; 422 return NULL;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 1dbe27c9946c..86b7e20ffd7f 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2675,7 +2675,7 @@ static inline void muxnet_put(struct gsm_mux_net *mux_net)
2675 kref_put(&mux_net->ref, net_free); 2675 kref_put(&mux_net->ref, net_free);
2676} 2676}
2677 2677
2678static int gsm_mux_net_start_xmit(struct sk_buff *skb, 2678static netdev_tx_t gsm_mux_net_start_xmit(struct sk_buff *skb,
2679 struct net_device *net) 2679 struct net_device *net)
2680{ 2680{
2681 struct gsm_mux_net *mux_net = netdev_priv(net); 2681 struct gsm_mux_net *mux_net = netdev_priv(net);
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index b57b35066ebe..fed820e9ab9d 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -72,19 +72,19 @@ do { \
72 72
73#define TMP_BUF_MAX 256 73#define TMP_BUF_MAX 256
74 74
75#define DUMP(buf__,len__) \ 75#define DUMP(buf__, len__) \
76 do { \ 76 do { \
77 char tbuf[TMP_BUF_MAX] = {0};\ 77 char tbuf[TMP_BUF_MAX] = {0}; \
78 if (len__ > 1) {\ 78 if (len__ > 1) { \
79 snprintf(tbuf, len__ > TMP_BUF_MAX ? TMP_BUF_MAX : len__, "%s", buf__);\ 79 u32 data_len = min_t(u32, len__, TMP_BUF_MAX); \
80 if (tbuf[len__-2] == '\r') {\ 80 strscpy(tbuf, buf__, data_len); \
81 tbuf[len__-2] = 'r';\ 81 if (tbuf[data_len - 2] == '\r') \
82 } \ 82 tbuf[data_len - 2] = 'r'; \
83 DBG1("SENDING: '%s' (%d+n)", tbuf, len__);\ 83 DBG1("SENDING: '%s' (%d+n)", tbuf, len__); \
84 } else {\ 84 } else { \
85 DBG1("SENDING: '%s' (%d)", tbuf, len__);\ 85 DBG1("SENDING: '%s' (%d)", tbuf, len__); \
86 } \ 86 } \
87} while (0) 87 } while (0)
88 88
89/* Defines */ 89/* Defines */
90#define NOZOMI_NAME "nozomi" 90#define NOZOMI_NAME "nozomi"
@@ -102,41 +102,41 @@ do { \
102#define RECEIVE_BUF_MAX 4 102#define RECEIVE_BUF_MAX 4
103 103
104 104
105#define R_IIR 0x0000 /* Interrupt Identity Register */ 105#define R_IIR 0x0000 /* Interrupt Identity Register */
106#define R_FCR 0x0000 /* Flow Control Register */ 106#define R_FCR 0x0000 /* Flow Control Register */
107#define R_IER 0x0004 /* Interrupt Enable Register */ 107#define R_IER 0x0004 /* Interrupt Enable Register */
108 108
109#define NOZOMI_CONFIG_MAGIC 0xEFEFFEFE 109#define NOZOMI_CONFIG_MAGIC 0xEFEFFEFE
110#define TOGGLE_VALID 0x0000 110#define TOGGLE_VALID 0x0000
111 111
112/* Definition of interrupt tokens */ 112/* Definition of interrupt tokens */
113#define MDM_DL1 0x0001 113#define MDM_DL1 0x0001
114#define MDM_UL1 0x0002 114#define MDM_UL1 0x0002
115#define MDM_DL2 0x0004 115#define MDM_DL2 0x0004
116#define MDM_UL2 0x0008 116#define MDM_UL2 0x0008
117#define DIAG_DL1 0x0010 117#define DIAG_DL1 0x0010
118#define DIAG_DL2 0x0020 118#define DIAG_DL2 0x0020
119#define DIAG_UL 0x0040 119#define DIAG_UL 0x0040
120#define APP1_DL 0x0080 120#define APP1_DL 0x0080
121#define APP1_UL 0x0100 121#define APP1_UL 0x0100
122#define APP2_DL 0x0200 122#define APP2_DL 0x0200
123#define APP2_UL 0x0400 123#define APP2_UL 0x0400
124#define CTRL_DL 0x0800 124#define CTRL_DL 0x0800
125#define CTRL_UL 0x1000 125#define CTRL_UL 0x1000
126#define RESET 0x8000 126#define RESET 0x8000
127 127
128#define MDM_DL (MDM_DL1 | MDM_DL2) 128#define MDM_DL (MDM_DL1 | MDM_DL2)
129#define MDM_UL (MDM_UL1 | MDM_UL2) 129#define MDM_UL (MDM_UL1 | MDM_UL2)
130#define DIAG_DL (DIAG_DL1 | DIAG_DL2) 130#define DIAG_DL (DIAG_DL1 | DIAG_DL2)
131 131
132/* modem signal definition */ 132/* modem signal definition */
133#define CTRL_DSR 0x0001 133#define CTRL_DSR 0x0001
134#define CTRL_DCD 0x0002 134#define CTRL_DCD 0x0002
135#define CTRL_RI 0x0004 135#define CTRL_RI 0x0004
136#define CTRL_CTS 0x0008 136#define CTRL_CTS 0x0008
137 137
138#define CTRL_DTR 0x0001 138#define CTRL_DTR 0x0001
139#define CTRL_RTS 0x0002 139#define CTRL_RTS 0x0002
140 140
141#define MAX_PORT 4 141#define MAX_PORT 4
142#define NOZOMI_MAX_PORTS 5 142#define NOZOMI_MAX_PORTS 5
@@ -155,7 +155,7 @@ enum card_type {
155 155
156/* Initialization states a card can be in */ 156/* Initialization states a card can be in */
157enum card_state { 157enum card_state {
158 NOZOMI_STATE_UKNOWN = 0, 158 NOZOMI_STATE_UNKNOWN = 0,
159 NOZOMI_STATE_ENABLED = 1, /* pci device enabled */ 159 NOZOMI_STATE_ENABLED = 1, /* pci device enabled */
160 NOZOMI_STATE_ALLOCATED = 2, /* config setup done */ 160 NOZOMI_STATE_ALLOCATED = 2, /* config setup done */
161 NOZOMI_STATE_READY = 3, /* flowcontrols received */ 161 NOZOMI_STATE_READY = 3, /* flowcontrols received */
@@ -365,7 +365,7 @@ struct buffer {
365 u8 *data; 365 u8 *data;
366} __attribute__ ((packed)); 366} __attribute__ ((packed));
367 367
368/* Global variables */ 368/* Global variables */
369static const struct pci_device_id nozomi_pci_tbl[] = { 369static const struct pci_device_id nozomi_pci_tbl[] = {
370 {PCI_DEVICE(0x1931, 0x000c)}, /* Nozomi HSDPA */ 370 {PCI_DEVICE(0x1931, 0x000c)}, /* Nozomi HSDPA */
371 {}, 371 {},
@@ -1686,12 +1686,12 @@ static int ntty_tiocmget(struct tty_struct *tty)
1686 1686
1687 /* Note: these could change under us but it is not clear this 1687 /* Note: these could change under us but it is not clear this
1688 matters if so */ 1688 matters if so */
1689 return (ctrl_ul->RTS ? TIOCM_RTS : 0) | 1689 return (ctrl_ul->RTS ? TIOCM_RTS : 0)
1690 (ctrl_ul->DTR ? TIOCM_DTR : 0) | 1690 | (ctrl_ul->DTR ? TIOCM_DTR : 0)
1691 (ctrl_dl->DCD ? TIOCM_CAR : 0) | 1691 | (ctrl_dl->DCD ? TIOCM_CAR : 0)
1692 (ctrl_dl->RI ? TIOCM_RNG : 0) | 1692 | (ctrl_dl->RI ? TIOCM_RNG : 0)
1693 (ctrl_dl->DSR ? TIOCM_DSR : 0) | 1693 | (ctrl_dl->DSR ? TIOCM_DSR : 0)
1694 (ctrl_dl->CTS ? TIOCM_CTS : 0); 1694 | (ctrl_dl->CTS ? TIOCM_CTS : 0);
1695} 1695}
1696 1696
1697/* Sets io controls parameters */ 1697/* Sets io controls parameters */
@@ -1722,10 +1722,10 @@ static int ntty_cflags_changed(struct port *port, unsigned long flags,
1722 const struct async_icount cnow = port->tty_icount; 1722 const struct async_icount cnow = port->tty_icount;
1723 int ret; 1723 int ret;
1724 1724
1725 ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) || 1725 ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng))
1726 ((flags & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) || 1726 || ((flags & TIOCM_DSR) && (cnow.dsr != cprev->dsr))
1727 ((flags & TIOCM_CD) && (cnow.dcd != cprev->dcd)) || 1727 || ((flags & TIOCM_CD) && (cnow.dcd != cprev->dcd))
1728 ((flags & TIOCM_CTS) && (cnow.cts != cprev->cts)); 1728 || ((flags & TIOCM_CTS) && (cnow.cts != cprev->cts));
1729 1729
1730 *cprev = cnow; 1730 *cprev = cnow;
1731 1731
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 6c7151edd715..b0e2c4847a5d 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -110,16 +110,19 @@ static void pty_unthrottle(struct tty_struct *tty)
110static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) 110static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
111{ 111{
112 struct tty_struct *to = tty->link; 112 struct tty_struct *to = tty->link;
113 unsigned long flags;
113 114
114 if (tty->stopped) 115 if (tty->stopped)
115 return 0; 116 return 0;
116 117
117 if (c > 0) { 118 if (c > 0) {
119 spin_lock_irqsave(&to->port->lock, flags);
118 /* Stuff the data into the input queue of the other end */ 120 /* Stuff the data into the input queue of the other end */
119 c = tty_insert_flip_string(to->port, buf, c); 121 c = tty_insert_flip_string(to->port, buf, c);
120 /* And shovel */ 122 /* And shovel */
121 if (c) 123 if (c)
122 tty_flip_buffer_push(to->port); 124 tty_flip_buffer_push(to->port);
125 spin_unlock_irqrestore(&to->port->lock, flags);
123 } 126 }
124 return c; 127 return c;
125} 128}
diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index 74a408d9db24..435bec40dee6 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -10,6 +10,8 @@
10#include <linux/of_address.h> 10#include <linux/of_address.h>
11#include <linux/of_irq.h> 11#include <linux/of_irq.h>
12#include <linux/of_platform.h> 12#include <linux/of_platform.h>
13#include <linux/tty.h>
14#include <linux/tty_flip.h>
13#include <linux/clk.h> 15#include <linux/clk.h>
14 16
15#include "8250.h" 17#include "8250.h"
@@ -28,9 +30,18 @@ struct aspeed_vuart {
28 void __iomem *regs; 30 void __iomem *regs;
29 struct clk *clk; 31 struct clk *clk;
30 int line; 32 int line;
33 struct timer_list unthrottle_timer;
34 struct uart_8250_port *port;
31}; 35};
32 36
33/* 37/*
38 * If we fill the tty flip buffers, we throttle the data ready interrupt
39 * to prevent dropped characters. This timeout defines how long we wait
40 * to (conditionally, depending on buffer state) unthrottle.
41 */
42static const int unthrottle_timeout = HZ/10;
43
44/*
34 * The VUART is basically two UART 'front ends' connected by their FIFO 45 * The VUART is basically two UART 'front ends' connected by their FIFO
35 * (no actual serial line in between). One is on the BMC side (management 46 * (no actual serial line in between). One is on the BMC side (management
36 * controller) and one is on the host CPU side. 47 * controller) and one is on the host CPU side.
@@ -179,6 +190,114 @@ static void aspeed_vuart_shutdown(struct uart_port *uart_port)
179 serial8250_do_shutdown(uart_port); 190 serial8250_do_shutdown(uart_port);
180} 191}
181 192
193static void __aspeed_vuart_set_throttle(struct uart_8250_port *up,
194 bool throttle)
195{
196 unsigned char irqs = UART_IER_RLSI | UART_IER_RDI;
197
198 up->ier &= ~irqs;
199 if (!throttle)
200 up->ier |= irqs;
201 serial_out(up, UART_IER, up->ier);
202}
203static void aspeed_vuart_set_throttle(struct uart_port *port, bool throttle)
204{
205 struct uart_8250_port *up = up_to_u8250p(port);
206 unsigned long flags;
207
208 spin_lock_irqsave(&port->lock, flags);
209 __aspeed_vuart_set_throttle(up, throttle);
210 spin_unlock_irqrestore(&port->lock, flags);
211}
212
213static void aspeed_vuart_throttle(struct uart_port *port)
214{
215 aspeed_vuart_set_throttle(port, true);
216}
217
218static void aspeed_vuart_unthrottle(struct uart_port *port)
219{
220 aspeed_vuart_set_throttle(port, false);
221}
222
223static void aspeed_vuart_unthrottle_exp(struct timer_list *timer)
224{
225 struct aspeed_vuart *vuart = from_timer(vuart, timer, unthrottle_timer);
226 struct uart_8250_port *up = vuart->port;
227
228 if (!tty_buffer_space_avail(&up->port.state->port)) {
229 mod_timer(&vuart->unthrottle_timer,
230 jiffies + unthrottle_timeout);
231 return;
232 }
233
234 aspeed_vuart_unthrottle(&up->port);
235}
236
237/*
238 * Custom interrupt handler to manage finer-grained flow control. Although we
239 * have throttle/unthrottle callbacks, we've seen that the VUART device can
240 * deliver characters faster than the ldisc has a chance to check buffer space
241 * against the throttle threshold. This results in dropped characters before
242 * the throttle.
243 *
244 * We do this by checking for flip buffer space before RX. If we have no space,
245 * throttle now and schedule an unthrottle for later, once the ldisc has had
246 * a chance to drain the buffers.
247 */
248static int aspeed_vuart_handle_irq(struct uart_port *port)
249{
250 struct uart_8250_port *up = up_to_u8250p(port);
251 unsigned int iir, lsr;
252 unsigned long flags;
253 int space, count;
254
255 iir = serial_port_in(port, UART_IIR);
256
257 if (iir & UART_IIR_NO_INT)
258 return 0;
259
260 spin_lock_irqsave(&port->lock, flags);
261
262 lsr = serial_port_in(port, UART_LSR);
263
264 if (lsr & (UART_LSR_DR | UART_LSR_BI)) {
265 space = tty_buffer_space_avail(&port->state->port);
266
267 if (!space) {
268 /* throttle and schedule an unthrottle later */
269 struct aspeed_vuart *vuart = port->private_data;
270 __aspeed_vuart_set_throttle(up, true);
271
272 if (!timer_pending(&vuart->unthrottle_timer)) {
273 vuart->port = up;
274 mod_timer(&vuart->unthrottle_timer,
275 jiffies + unthrottle_timeout);
276 }
277
278 } else {
279 count = min(space, 256);
280
281 do {
282 serial8250_read_char(up, lsr);
283 lsr = serial_in(up, UART_LSR);
284 if (--count == 0)
285 break;
286 } while (lsr & (UART_LSR_DR | UART_LSR_BI));
287
288 tty_flip_buffer_push(&port->state->port);
289 }
290 }
291
292 serial8250_modem_status(up);
293 if (lsr & UART_LSR_THRE)
294 serial8250_tx_chars(up);
295
296 spin_unlock_irqrestore(&port->lock, flags);
297
298 return 1;
299}
300
182static int aspeed_vuart_probe(struct platform_device *pdev) 301static int aspeed_vuart_probe(struct platform_device *pdev)
183{ 302{
184 struct uart_8250_port port; 303 struct uart_8250_port port;
@@ -195,6 +314,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
195 return -ENOMEM; 314 return -ENOMEM;
196 315
197 vuart->dev = &pdev->dev; 316 vuart->dev = &pdev->dev;
317 timer_setup(&vuart->unthrottle_timer, aspeed_vuart_unthrottle_exp, 0);
198 318
199 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 319 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
200 vuart->regs = devm_ioremap_resource(&pdev->dev, res); 320 vuart->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -208,6 +328,9 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
208 port.port.mapsize = resource_size(res); 328 port.port.mapsize = resource_size(res);
209 port.port.startup = aspeed_vuart_startup; 329 port.port.startup = aspeed_vuart_startup;
210 port.port.shutdown = aspeed_vuart_shutdown; 330 port.port.shutdown = aspeed_vuart_shutdown;
331 port.port.throttle = aspeed_vuart_throttle;
332 port.port.unthrottle = aspeed_vuart_unthrottle;
333 port.port.status = UPSTAT_SYNC_FIFO;
211 port.port.dev = &pdev->dev; 334 port.port.dev = &pdev->dev;
212 335
213 rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); 336 rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
@@ -253,6 +376,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
253 376
254 port.port.irq = irq_of_parse_and_map(np, 0); 377 port.port.irq = irq_of_parse_and_map(np, 0);
255 port.port.irqflags = IRQF_SHARED; 378 port.port.irqflags = IRQF_SHARED;
379 port.port.handle_irq = aspeed_vuart_handle_irq;
256 port.port.iotype = UPIO_MEM; 380 port.port.iotype = UPIO_MEM;
257 port.port.type = PORT_16550A; 381 port.port.type = PORT_16550A;
258 port.port.uartclk = clk; 382 port.port.uartclk = clk;
@@ -292,6 +416,7 @@ static int aspeed_vuart_remove(struct platform_device *pdev)
292{ 416{
293 struct aspeed_vuart *vuart = platform_get_drvdata(pdev); 417 struct aspeed_vuart *vuart = platform_get_drvdata(pdev);
294 418
419 del_timer_sync(&vuart->unthrottle_timer);
295 aspeed_vuart_set_enabled(vuart, false); 420 aspeed_vuart_set_enabled(vuart, false);
296 serial8250_unregister_port(vuart->line); 421 serial8250_unregister_port(vuart->line);
297 sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); 422 sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 6fcdb90f616a..aff04f1de3a5 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -121,25 +121,44 @@ static void dw8250_check_lcr(struct uart_port *p, int value)
121} 121}
122 122
123/* Returns once the transmitter is empty or we run out of retries */ 123/* Returns once the transmitter is empty or we run out of retries */
124static void dw8250_tx_wait_empty(struct uart_port *p, int tries) 124static void dw8250_tx_wait_empty(struct uart_port *p)
125{ 125{
126 unsigned int tries = 20000;
127 unsigned int delay_threshold = tries - 1000;
126 unsigned int lsr; 128 unsigned int lsr;
127 129
128 while (tries--) { 130 while (tries--) {
129 lsr = readb (p->membase + (UART_LSR << p->regshift)); 131 lsr = readb (p->membase + (UART_LSR << p->regshift));
130 if (lsr & UART_LSR_TEMT) 132 if (lsr & UART_LSR_TEMT)
131 break; 133 break;
132 udelay (10); 134
135 /* The device is first given a chance to empty without delay,
136 * to avoid slowdowns at high bitrates. If after 1000 tries
137 * the buffer has still not emptied, allow more time for low-
138 * speed links. */
139 if (tries < delay_threshold)
140 udelay (1);
133 } 141 }
134} 142}
135 143
136static void dw8250_serial_out(struct uart_port *p, int offset, int value) 144static void dw8250_serial_out38x(struct uart_port *p, int offset, int value)
137{ 145{
138 struct dw8250_data *d = p->private_data; 146 struct dw8250_data *d = p->private_data;
139 147
140 /* Allow the TX to drain before we reconfigure */ 148 /* Allow the TX to drain before we reconfigure */
141 if (offset == UART_LCR) 149 if (offset == UART_LCR)
142 dw8250_tx_wait_empty(p, 1000); 150 dw8250_tx_wait_empty(p);
151
152 writeb(value, p->membase + (offset << p->regshift));
153
154 if (offset == UART_LCR && !d->uart_16550_compatible)
155 dw8250_check_lcr(p, value);
156}
157
158
159static void dw8250_serial_out(struct uart_port *p, int offset, int value)
160{
161 struct dw8250_data *d = p->private_data;
143 162
144 writeb(value, p->membase + (offset << p->regshift)); 163 writeb(value, p->membase + (offset << p->regshift));
145 164
@@ -357,6 +376,9 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
357 p->serial_in = dw8250_serial_in32be; 376 p->serial_in = dw8250_serial_in32be;
358 p->serial_out = dw8250_serial_out32be; 377 p->serial_out = dw8250_serial_out32be;
359 } 378 }
379 if (of_device_is_compatible(np, "marvell,armada-38x-uart"))
380 p->serial_out = dw8250_serial_out38x;
381
360 } else if (acpi_dev_present("APMC0D08", NULL, -1)) { 382 } else if (acpi_dev_present("APMC0D08", NULL, -1)) {
361 p->iotype = UPIO_MEM32; 383 p->iotype = UPIO_MEM32;
362 p->regshift = 2; 384 p->regshift = 2;
@@ -554,6 +576,10 @@ static int dw8250_probe(struct platform_device *pdev)
554 if (!data->skip_autocfg) 576 if (!data->skip_autocfg)
555 dw8250_setup_port(p); 577 dw8250_setup_port(p);
556 578
579#ifdef CONFIG_PM
580 uart.capabilities |= UART_CAP_RPM;
581#endif
582
557 /* If we have a valid fifosize, try hooking up DMA */ 583 /* If we have a valid fifosize, try hooking up DMA */
558 if (p->fifosize) { 584 if (p->fifosize) {
559 data->dma.rxconf.src_maxburst = p->fifosize / 4; 585 data->dma.rxconf.src_maxburst = p->fifosize / 4;
@@ -666,6 +692,7 @@ static const struct dev_pm_ops dw8250_pm_ops = {
666static const struct of_device_id dw8250_of_match[] = { 692static const struct of_device_id dw8250_of_match[] = {
667 { .compatible = "snps,dw-apb-uart" }, 693 { .compatible = "snps,dw-apb-uart" },
668 { .compatible = "cavium,octeon-3860-uart" }, 694 { .compatible = "cavium,octeon-3860-uart" },
695 { .compatible = "marvell,armada-38x-uart" },
669 { /* Sentinel */ } 696 { /* Sentinel */ }
670}; 697};
671MODULE_DEVICE_TABLE(of, dw8250_of_match); 698MODULE_DEVICE_TABLE(of, dw8250_of_match);
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index ae6a256524d8..5cd8c36c8fcc 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -122,7 +122,7 @@ static void __init init_port(struct earlycon_device *device)
122 serial8250_early_out(port, UART_FCR, 0); /* no fifo */ 122 serial8250_early_out(port, UART_FCR, 0); /* no fifo */
123 serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */ 123 serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */
124 124
125 if (port->uartclk && device->baud) { 125 if (port->uartclk) {
126 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud); 126 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
127 c = serial8250_early_in(port, UART_LCR); 127 c = serial8250_early_in(port, UART_LCR);
128 serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB); 128 serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB);
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 9835b1c1cbe1..bfb37f0be22f 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -92,13 +92,43 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
92 goto err_unprepare; 92 goto err_unprepare;
93 } 93 }
94 94
95 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT |
96 UPF_FIXED_TYPE;
95 spin_lock_init(&port->lock); 97 spin_lock_init(&port->lock);
96 port->mapbase = resource.start;
97 port->mapsize = resource_size(&resource);
98 98
99 /* Check for shifted address mapping */ 99 if (resource_type(&resource) == IORESOURCE_IO) {
100 if (of_property_read_u32(np, "reg-offset", &prop) == 0) 100 port->iotype = UPIO_PORT;
101 port->mapbase += prop; 101 port->iobase = resource.start;
102 } else {
103 port->mapbase = resource.start;
104 port->mapsize = resource_size(&resource);
105
106 /* Check for shifted address mapping */
107 if (of_property_read_u32(np, "reg-offset", &prop) == 0)
108 port->mapbase += prop;
109
110 port->iotype = UPIO_MEM;
111 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
112 switch (prop) {
113 case 1:
114 port->iotype = UPIO_MEM;
115 break;
116 case 2:
117 port->iotype = UPIO_MEM16;
118 break;
119 case 4:
120 port->iotype = of_device_is_big_endian(np) ?
121 UPIO_MEM32BE : UPIO_MEM32;
122 break;
123 default:
124 dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
125 prop);
126 ret = -EINVAL;
127 goto err_dispose;
128 }
129 }
130 port->flags |= UPF_IOREMAP;
131 }
102 132
103 /* Check for registers offset within the devices address range */ 133 /* Check for registers offset within the devices address range */
104 if (of_property_read_u32(np, "reg-shift", &prop) == 0) 134 if (of_property_read_u32(np, "reg-shift", &prop) == 0)
@@ -114,26 +144,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
114 port->line = ret; 144 port->line = ret;
115 145
116 port->irq = irq_of_parse_and_map(np, 0); 146 port->irq = irq_of_parse_and_map(np, 0);
117 port->iotype = UPIO_MEM;
118 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
119 switch (prop) {
120 case 1:
121 port->iotype = UPIO_MEM;
122 break;
123 case 2:
124 port->iotype = UPIO_MEM16;
125 break;
126 case 4:
127 port->iotype = of_device_is_big_endian(np) ?
128 UPIO_MEM32BE : UPIO_MEM32;
129 break;
130 default:
131 dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
132 prop);
133 ret = -EINVAL;
134 goto err_dispose;
135 }
136 }
137 147
138 info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); 148 info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
139 if (IS_ERR(info->rst)) { 149 if (IS_ERR(info->rst)) {
@@ -147,8 +157,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
147 157
148 port->type = type; 158 port->type = type;
149 port->uartclk = clk; 159 port->uartclk = clk;
150 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 160 port->irqflags |= IRQF_SHARED;
151 | UPF_FIXED_PORT | UPF_FIXED_TYPE;
152 161
153 if (of_property_read_bool(np, "no-loopback-test")) 162 if (of_property_read_bool(np, "no-loopback-test"))
154 port->flags |= UPF_SKIP_TEST; 163 port->flags |= UPF_SKIP_TEST;
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 624b501fd253..1b337fee07ed 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1110,13 +1110,14 @@ static int omap8250_no_handle_irq(struct uart_port *port)
1110 return 0; 1110 return 0;
1111} 1111}
1112 1112
1113static const u8 omap4_habit = UART_ERRATA_CLOCK_DISABLE;
1113static const u8 am3352_habit = OMAP_DMA_TX_KICK | UART_ERRATA_CLOCK_DISABLE; 1114static const u8 am3352_habit = OMAP_DMA_TX_KICK | UART_ERRATA_CLOCK_DISABLE;
1114static const u8 dra742_habit = UART_ERRATA_CLOCK_DISABLE; 1115static const u8 dra742_habit = UART_ERRATA_CLOCK_DISABLE;
1115 1116
1116static const struct of_device_id omap8250_dt_ids[] = { 1117static const struct of_device_id omap8250_dt_ids[] = {
1117 { .compatible = "ti,omap2-uart" }, 1118 { .compatible = "ti,omap2-uart" },
1118 { .compatible = "ti,omap3-uart" }, 1119 { .compatible = "ti,omap3-uart" },
1119 { .compatible = "ti,omap4-uart" }, 1120 { .compatible = "ti,omap4-uart", .data = &omap4_habit, },
1120 { .compatible = "ti,am3352-uart", .data = &am3352_habit, }, 1121 { .compatible = "ti,am3352-uart", .data = &am3352_habit, },
1121 { .compatible = "ti,am4372-uart", .data = &am3352_habit, }, 1122 { .compatible = "ti,am4372-uart", .data = &am3352_habit, },
1122 { .compatible = "ti,dra742-uart", .data = &dra742_habit, }, 1123 { .compatible = "ti,dra742-uart", .data = &dra742_habit, },
@@ -1310,8 +1311,17 @@ static void omap8250_complete(struct device *dev)
1310static int omap8250_suspend(struct device *dev) 1311static int omap8250_suspend(struct device *dev)
1311{ 1312{
1312 struct omap8250_priv *priv = dev_get_drvdata(dev); 1313 struct omap8250_priv *priv = dev_get_drvdata(dev);
1314 struct uart_8250_port *up = serial8250_get_port(priv->line);
1313 1315
1314 serial8250_suspend_port(priv->line); 1316 serial8250_suspend_port(priv->line);
1317
1318 pm_runtime_get_sync(dev);
1319 if (!device_may_wakeup(dev))
1320 priv->wer = 0;
1321 serial_out(up, UART_OMAP_WER, priv->wer);
1322 pm_runtime_mark_last_busy(dev);
1323 pm_runtime_put_autosuspend(dev);
1324
1315 flush_work(&priv->qos_work); 1325 flush_work(&priv->qos_work);
1316 return 0; 1326 return 0;
1317} 1327}
@@ -1353,6 +1363,19 @@ static int omap8250_soft_reset(struct device *dev)
1353 int sysc; 1363 int sysc;
1354 int syss; 1364 int syss;
1355 1365
1366 /*
1367 * At least on omap4, unused uarts may not idle after reset without
1368 * a basic scr dma configuration even with no dma in use. The
1369 * module clkctrl status bits will be 1 instead of 3 blocking idle
1370 * for the whole clockdomain. The softreset below will clear scr,
1371 * and we restore it on resume so this is safe to do on all SoCs
1372 * needing omap8250_soft_reset() quirk. Do it in two writes as
1373 * recommended in the comment for omap8250_update_scr().
1374 */
1375 serial_out(up, UART_OMAP_SCR, OMAP_UART_SCR_DMAMODE_1);
1376 serial_out(up, UART_OMAP_SCR,
1377 OMAP_UART_SCR_DMAMODE_1 | OMAP_UART_SCR_DMAMODE_CTL);
1378
1356 sysc = serial_in(up, UART_OMAP_SYSC); 1379 sysc = serial_in(up, UART_OMAP_SYSC);
1357 1380
1358 /* softreset the UART */ 1381 /* softreset the UART */
@@ -1403,6 +1426,8 @@ static int omap8250_runtime_suspend(struct device *dev)
1403 1426
1404 /* Restore to UART mode after reset (for wakeup) */ 1427 /* Restore to UART mode after reset (for wakeup) */
1405 omap8250_update_mdr1(up, priv); 1428 omap8250_update_mdr1(up, priv);
1429 /* Restore wakeup enable register */
1430 serial_out(up, UART_OMAP_WER, priv->wer);
1406 } 1431 }
1407 1432
1408 if (up->dma && up->dma->rxchan) 1433 if (up->dma && up->dma->rxchan)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 95833cbc4338..cf541aab2bd0 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -243,6 +243,7 @@ static const struct serial8250_config uart_config[] = {
243 .fifo_size = 32, 243 .fifo_size = 32,
244 .tx_loadsz = 32, 244 .tx_loadsz = 32,
245 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 245 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
246 .rxtrig_bytes = {1, 8, 16, 30},
246 .flags = UART_CAP_FIFO | UART_CAP_AFE, 247 .flags = UART_CAP_FIFO | UART_CAP_AFE,
247 }, 248 },
248 [PORT_ALTR_16550_F64] = { 249 [PORT_ALTR_16550_F64] = {
@@ -250,6 +251,7 @@ static const struct serial8250_config uart_config[] = {
250 .fifo_size = 64, 251 .fifo_size = 64,
251 .tx_loadsz = 64, 252 .tx_loadsz = 64,
252 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 253 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
254 .rxtrig_bytes = {1, 16, 32, 62},
253 .flags = UART_CAP_FIFO | UART_CAP_AFE, 255 .flags = UART_CAP_FIFO | UART_CAP_AFE,
254 }, 256 },
255 [PORT_ALTR_16550_F128] = { 257 [PORT_ALTR_16550_F128] = {
@@ -257,6 +259,7 @@ static const struct serial8250_config uart_config[] = {
257 .fifo_size = 128, 259 .fifo_size = 128,
258 .tx_loadsz = 128, 260 .tx_loadsz = 128,
259 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 261 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
262 .rxtrig_bytes = {1, 32, 64, 126},
260 .flags = UART_CAP_FIFO | UART_CAP_AFE, 263 .flags = UART_CAP_FIFO | UART_CAP_AFE,
261 }, 264 },
262 /* 265 /*
@@ -1680,7 +1683,7 @@ static void serial8250_enable_ms(struct uart_port *port)
1680 serial8250_rpm_put(up); 1683 serial8250_rpm_put(up);
1681} 1684}
1682 1685
1683static void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr) 1686void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr)
1684{ 1687{
1685 struct uart_port *port = &up->port; 1688 struct uart_port *port = &up->port;
1686 unsigned char ch; 1689 unsigned char ch;
@@ -1740,6 +1743,7 @@ static void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr)
1740 1743
1741 uart_insert_char(port, lsr, UART_LSR_OE, ch, flag); 1744 uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
1742} 1745}
1746EXPORT_SYMBOL_GPL(serial8250_read_char);
1743 1747
1744/* 1748/*
1745 * serial8250_rx_chars: processes according to the passed in LSR 1749 * serial8250_rx_chars: processes according to the passed in LSR
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 0f058df0b070..df8bd0c7b97d 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -115,7 +115,6 @@ config SERIAL_SB1250_DUART_CONSOLE
115 115
116config SERIAL_ATMEL 116config SERIAL_ATMEL
117 bool "AT91 on-chip serial port support" 117 bool "AT91 on-chip serial port support"
118 depends on HAS_DMA
119 depends on ARCH_AT91 || COMPILE_TEST 118 depends on ARCH_AT91 || COMPILE_TEST
120 select SERIAL_CORE 119 select SERIAL_CORE
121 select SERIAL_MCTRL_GPIO if GPIOLIB 120 select SERIAL_MCTRL_GPIO if GPIOLIB
@@ -500,7 +499,6 @@ config SERIAL_SA1100_CONSOLE
500 499
501config SERIAL_IMX 500config SERIAL_IMX
502 tristate "IMX serial port support" 501 tristate "IMX serial port support"
503 depends on HAS_DMA
504 depends on ARCH_MXC || COMPILE_TEST 502 depends on ARCH_MXC || COMPILE_TEST
505 select SERIAL_CORE 503 select SERIAL_CORE
506 select RATIONAL 504 select RATIONAL
@@ -676,6 +674,8 @@ config SERIAL_SH_SCI
676 674
677config SERIAL_SH_SCI_NR_UARTS 675config SERIAL_SH_SCI_NR_UARTS
678 int "Maximum number of SCI(F) serial ports" if EXPERT 676 int "Maximum number of SCI(F) serial ports" if EXPERT
677 range 1 64 if 64BIT
678 range 1 32 if !64BIT
679 depends on SERIAL_SH_SCI 679 depends on SERIAL_SH_SCI
680 default "3" if H8300 680 default "3" if H8300
681 default "10" if SUPERH 681 default "10" if SUPERH
@@ -1262,7 +1262,6 @@ config SERIAL_PCH_UART_CONSOLE
1262 1262
1263config SERIAL_MXS_AUART 1263config SERIAL_MXS_AUART
1264 tristate "MXS AUART support" 1264 tristate "MXS AUART support"
1265 depends on HAS_DMA
1266 depends on ARCH_MXS || MACH_ASM9260 || COMPILE_TEST 1265 depends on ARCH_MXS || MACH_ASM9260 || COMPILE_TEST
1267 select SERIAL_CORE 1266 select SERIAL_CORE
1268 select SERIAL_MCTRL_GPIO if GPIOLIB 1267 select SERIAL_MCTRL_GPIO if GPIOLIB
@@ -1295,7 +1294,7 @@ config SERIAL_XILINX_PS_UART_CONSOLE
1295 1294
1296config SERIAL_AR933X 1295config SERIAL_AR933X
1297 tristate "AR933X serial port support" 1296 tristate "AR933X serial port support"
1298 depends on HAVE_CLK && SOC_AR933X 1297 depends on HAVE_CLK && ATH79
1299 select SERIAL_CORE 1298 select SERIAL_CORE
1300 help 1299 help
1301 If you have an Atheros AR933X SOC based board and want to use the 1300 If you have an Atheros AR933X SOC based board and want to use the
@@ -1473,7 +1472,6 @@ config SERIAL_SPRD_CONSOLE
1473config SERIAL_STM32 1472config SERIAL_STM32
1474 tristate "STMicroelectronics STM32 serial port support" 1473 tristate "STMicroelectronics STM32 serial port support"
1475 select SERIAL_CORE 1474 select SERIAL_CORE
1476 depends on HAS_DMA
1477 depends on ARCH_STM32 || COMPILE_TEST 1475 depends on ARCH_STM32 || COMPILE_TEST
1478 help 1476 help
1479 This driver is for the on-chip Serial Controller on 1477 This driver is for the on-chip Serial Controller on
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 4b40a5b449ee..ebd33c0232e6 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1727,10 +1727,26 @@ static int pl011_allocate_irq(struct uart_amba_port *uap)
1727 */ 1727 */
1728static void pl011_enable_interrupts(struct uart_amba_port *uap) 1728static void pl011_enable_interrupts(struct uart_amba_port *uap)
1729{ 1729{
1730 unsigned int i;
1731
1730 spin_lock_irq(&uap->port.lock); 1732 spin_lock_irq(&uap->port.lock);
1731 1733
1732 /* Clear out any spuriously appearing RX interrupts */ 1734 /* Clear out any spuriously appearing RX interrupts */
1733 pl011_write(UART011_RTIS | UART011_RXIS, uap, REG_ICR); 1735 pl011_write(UART011_RTIS | UART011_RXIS, uap, REG_ICR);
1736
1737 /*
1738 * RXIS is asserted only when the RX FIFO transitions from below
1739 * to above the trigger threshold. If the RX FIFO is already
1740 * full to the threshold this can't happen and RXIS will now be
1741 * stuck off. Drain the RX FIFO explicitly to fix this:
1742 */
1743 for (i = 0; i < uap->fifosize * 2; ++i) {
1744 if (pl011_read(uap, REG_FR) & UART01x_FR_RXFE)
1745 break;
1746
1747 pl011_read(uap, REG_DR);
1748 }
1749
1734 uap->im = UART011_RTIM; 1750 uap->im = UART011_RTIM;
1735 if (!pl011_dma_rx_running(uap)) 1751 if (!pl011_dma_rx_running(uap))
1736 uap->im |= UART011_RXIM; 1752 uap->im |= UART011_RXIM;
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index e287fe8f10fc..55b3eff148b1 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1757,7 +1757,6 @@ static int atmel_startup(struct uart_port *port)
1757{ 1757{
1758 struct platform_device *pdev = to_platform_device(port->dev); 1758 struct platform_device *pdev = to_platform_device(port->dev);
1759 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1759 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
1760 struct tty_struct *tty = port->state->port.tty;
1761 int retval; 1760 int retval;
1762 1761
1763 /* 1762 /*
@@ -1772,8 +1771,8 @@ static int atmel_startup(struct uart_port *port)
1772 * Allocate the IRQ 1771 * Allocate the IRQ
1773 */ 1772 */
1774 retval = request_irq(port->irq, atmel_interrupt, 1773 retval = request_irq(port->irq, atmel_interrupt,
1775 IRQF_SHARED | IRQF_COND_SUSPEND, 1774 IRQF_SHARED | IRQF_COND_SUSPEND,
1776 tty ? tty->name : "atmel_serial", port); 1775 dev_name(&pdev->dev), port);
1777 if (retval) { 1776 if (retval) {
1778 dev_err(port->dev, "atmel_startup - Can't get irq\n"); 1777 dev_err(port->dev, "atmel_startup - Can't get irq\n");
1779 return retval; 1778 return retval;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 22683393a0f2..c14873b67803 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -246,7 +246,6 @@ int __init of_setup_earlycon(const struct earlycon_id *match,
246 return -ENXIO; 246 return -ENXIO;
247 } 247 }
248 port->mapbase = addr; 248 port->mapbase = addr;
249 port->uartclk = BASE_BAUD * 16;
250 249
251 val = of_get_flat_dt_prop(node, "reg-offset", NULL); 250 val = of_get_flat_dt_prop(node, "reg-offset", NULL);
252 if (val) 251 if (val)
@@ -281,6 +280,10 @@ int __init of_setup_earlycon(const struct earlycon_id *match,
281 if (val) 280 if (val)
282 early_console_dev.baud = be32_to_cpu(*val); 281 early_console_dev.baud = be32_to_cpu(*val);
283 282
283 val = of_get_flat_dt_prop(node, "clock-frequency", NULL);
284 if (val)
285 port->uartclk = be32_to_cpu(*val);
286
284 if (options) { 287 if (options) {
285 early_console_dev.baud = simple_strtoul(options, NULL, 0); 288 early_console_dev.baud = simple_strtoul(options, NULL, 0);
286 strlcpy(early_console_dev.options, options, 289 strlcpy(early_console_dev.options, options,
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index c2fc6bef7a6f..4e853570ea80 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1291,18 +1291,13 @@ static void imx_uart_enable_dma(struct imx_port *sport)
1291 1291
1292static void imx_uart_disable_dma(struct imx_port *sport) 1292static void imx_uart_disable_dma(struct imx_port *sport)
1293{ 1293{
1294 u32 ucr1, ucr2; 1294 u32 ucr1;
1295 1295
1296 /* clear UCR1 */ 1296 /* clear UCR1 */
1297 ucr1 = imx_uart_readl(sport, UCR1); 1297 ucr1 = imx_uart_readl(sport, UCR1);
1298 ucr1 &= ~(UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN); 1298 ucr1 &= ~(UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN);
1299 imx_uart_writel(sport, ucr1, UCR1); 1299 imx_uart_writel(sport, ucr1, UCR1);
1300 1300
1301 /* clear UCR2 */
1302 ucr2 = imx_uart_readl(sport, UCR2);
1303 ucr2 &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
1304 imx_uart_writel(sport, ucr2, UCR2);
1305
1306 imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT); 1301 imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
1307 1302
1308 sport->dma_is_enabled = 0; 1303 sport->dma_is_enabled = 0;
@@ -1427,13 +1422,21 @@ static void imx_uart_shutdown(struct uart_port *port)
1427{ 1422{
1428 struct imx_port *sport = (struct imx_port *)port; 1423 struct imx_port *sport = (struct imx_port *)port;
1429 unsigned long flags; 1424 unsigned long flags;
1430 u32 ucr1, ucr2; 1425 u32 ucr1, ucr2, ucr4;
1431 1426
1432 if (sport->dma_is_enabled) { 1427 if (sport->dma_is_enabled) {
1433 sport->dma_is_rxing = 0;
1434 sport->dma_is_txing = 0;
1435 dmaengine_terminate_sync(sport->dma_chan_tx); 1428 dmaengine_terminate_sync(sport->dma_chan_tx);
1429 if (sport->dma_is_txing) {
1430 dma_unmap_sg(sport->port.dev, &sport->tx_sgl[0],
1431 sport->dma_tx_nents, DMA_TO_DEVICE);
1432 sport->dma_is_txing = 0;
1433 }
1436 dmaengine_terminate_sync(sport->dma_chan_rx); 1434 dmaengine_terminate_sync(sport->dma_chan_rx);
1435 if (sport->dma_is_rxing) {
1436 dma_unmap_sg(sport->port.dev, &sport->rx_sgl,
1437 1, DMA_FROM_DEVICE);
1438 sport->dma_is_rxing = 0;
1439 }
1437 1440
1438 spin_lock_irqsave(&sport->port.lock, flags); 1441 spin_lock_irqsave(&sport->port.lock, flags);
1439 imx_uart_stop_tx(port); 1442 imx_uart_stop_tx(port);
@@ -1449,6 +1452,10 @@ static void imx_uart_shutdown(struct uart_port *port)
1449 ucr2 = imx_uart_readl(sport, UCR2); 1452 ucr2 = imx_uart_readl(sport, UCR2);
1450 ucr2 &= ~(UCR2_TXEN | UCR2_ATEN); 1453 ucr2 &= ~(UCR2_TXEN | UCR2_ATEN);
1451 imx_uart_writel(sport, ucr2, UCR2); 1454 imx_uart_writel(sport, ucr2, UCR2);
1455
1456 ucr4 = imx_uart_readl(sport, UCR4);
1457 ucr4 &= ~UCR4_OREN;
1458 imx_uart_writel(sport, ucr4, UCR4);
1452 spin_unlock_irqrestore(&sport->port.lock, flags); 1459 spin_unlock_irqrestore(&sport->port.lock, flags);
1453 1460
1454 /* 1461 /*
@@ -2425,8 +2432,7 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
2425 2432
2426static int imx_uart_suspend_noirq(struct device *dev) 2433static int imx_uart_suspend_noirq(struct device *dev)
2427{ 2434{
2428 struct platform_device *pdev = to_platform_device(dev); 2435 struct imx_port *sport = dev_get_drvdata(dev);
2429 struct imx_port *sport = platform_get_drvdata(pdev);
2430 2436
2431 imx_uart_save_context(sport); 2437 imx_uart_save_context(sport);
2432 2438
@@ -2437,8 +2443,7 @@ static int imx_uart_suspend_noirq(struct device *dev)
2437 2443
2438static int imx_uart_resume_noirq(struct device *dev) 2444static int imx_uart_resume_noirq(struct device *dev)
2439{ 2445{
2440 struct platform_device *pdev = to_platform_device(dev); 2446 struct imx_port *sport = dev_get_drvdata(dev);
2441 struct imx_port *sport = platform_get_drvdata(pdev);
2442 int ret; 2447 int ret;
2443 2448
2444 ret = clk_enable(sport->clk_ipg); 2449 ret = clk_enable(sport->clk_ipg);
@@ -2452,8 +2457,7 @@ static int imx_uart_resume_noirq(struct device *dev)
2452 2457
2453static int imx_uart_suspend(struct device *dev) 2458static int imx_uart_suspend(struct device *dev)
2454{ 2459{
2455 struct platform_device *pdev = to_platform_device(dev); 2460 struct imx_port *sport = dev_get_drvdata(dev);
2456 struct imx_port *sport = platform_get_drvdata(pdev);
2457 int ret; 2461 int ret;
2458 2462
2459 uart_suspend_port(&imx_uart_uart_driver, &sport->port); 2463 uart_suspend_port(&imx_uart_uart_driver, &sport->port);
@@ -2471,8 +2475,7 @@ static int imx_uart_suspend(struct device *dev)
2471 2475
2472static int imx_uart_resume(struct device *dev) 2476static int imx_uart_resume(struct device *dev)
2473{ 2477{
2474 struct platform_device *pdev = to_platform_device(dev); 2478 struct imx_port *sport = dev_get_drvdata(dev);
2475 struct imx_port *sport = platform_get_drvdata(pdev);
2476 2479
2477 /* disable wakeup from i.MX UART */ 2480 /* disable wakeup from i.MX UART */
2478 imx_uart_enable_wakeup(sport, false); 2481 imx_uart_enable_wakeup(sport, false);
@@ -2487,8 +2490,7 @@ static int imx_uart_resume(struct device *dev)
2487 2490
2488static int imx_uart_freeze(struct device *dev) 2491static int imx_uart_freeze(struct device *dev)
2489{ 2492{
2490 struct platform_device *pdev = to_platform_device(dev); 2493 struct imx_port *sport = dev_get_drvdata(dev);
2491 struct imx_port *sport = platform_get_drvdata(pdev);
2492 2494
2493 uart_suspend_port(&imx_uart_uart_driver, &sport->port); 2495 uart_suspend_port(&imx_uart_uart_driver, &sport->port);
2494 2496
@@ -2497,8 +2499,7 @@ static int imx_uart_freeze(struct device *dev)
2497 2499
2498static int imx_uart_thaw(struct device *dev) 2500static int imx_uart_thaw(struct device *dev)
2499{ 2501{
2500 struct platform_device *pdev = to_platform_device(dev); 2502 struct imx_port *sport = dev_get_drvdata(dev);
2501 struct imx_port *sport = platform_get_drvdata(pdev);
2502 2503
2503 uart_resume_port(&imx_uart_uart_driver, &sport->port); 2504 uart_resume_port(&imx_uart_uart_driver, &sport->port);
2504 2505
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index ee96cf0d0057..736b74fd6623 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -1812,11 +1812,34 @@ static const struct of_device_id msm_match_table[] = {
1812}; 1812};
1813MODULE_DEVICE_TABLE(of, msm_match_table); 1813MODULE_DEVICE_TABLE(of, msm_match_table);
1814 1814
1815static int __maybe_unused msm_serial_suspend(struct device *dev)
1816{
1817 struct msm_port *port = dev_get_drvdata(dev);
1818
1819 uart_suspend_port(&msm_uart_driver, &port->uart);
1820
1821 return 0;
1822}
1823
1824static int __maybe_unused msm_serial_resume(struct device *dev)
1825{
1826 struct msm_port *port = dev_get_drvdata(dev);
1827
1828 uart_resume_port(&msm_uart_driver, &port->uart);
1829
1830 return 0;
1831}
1832
1833static const struct dev_pm_ops msm_serial_dev_pm_ops = {
1834 SET_SYSTEM_SLEEP_PM_OPS(msm_serial_suspend, msm_serial_resume)
1835};
1836
1815static struct platform_driver msm_platform_driver = { 1837static struct platform_driver msm_platform_driver = {
1816 .remove = msm_serial_remove, 1838 .remove = msm_serial_remove,
1817 .probe = msm_serial_probe, 1839 .probe = msm_serial_probe,
1818 .driver = { 1840 .driver = {
1819 .name = "msm_serial", 1841 .name = "msm_serial",
1842 .pm = &msm_serial_dev_pm_ops,
1820 .of_match_table = msm_match_table, 1843 .of_match_table = msm_match_table,
1821 }, 1844 },
1822}; 1845};
diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
index f503fab1e268..d04b5eeea3c6 100644
--- a/drivers/tty/serial/mvebu-uart.c
+++ b/drivers/tty/serial/mvebu-uart.c
@@ -71,6 +71,8 @@
71#define UART_BRDV 0x10 71#define UART_BRDV 0x10
72#define BRDV_BAUD_MASK 0x3FF 72#define BRDV_BAUD_MASK 0x3FF
73 73
74#define UART_OSAMP 0x14
75
74#define MVEBU_NR_UARTS 2 76#define MVEBU_NR_UARTS 2
75 77
76#define MVEBU_UART_TYPE "mvebu-uart" 78#define MVEBU_UART_TYPE "mvebu-uart"
@@ -108,6 +110,17 @@ struct mvebu_uart_driver_data {
108 struct uart_flags flags; 110 struct uart_flags flags;
109}; 111};
110 112
113/* Saved registers during suspend */
114struct mvebu_uart_pm_regs {
115 unsigned int rbr;
116 unsigned int tsh;
117 unsigned int ctrl;
118 unsigned int intr;
119 unsigned int stat;
120 unsigned int brdv;
121 unsigned int osamp;
122};
123
111/* MVEBU UART driver structure */ 124/* MVEBU UART driver structure */
112struct mvebu_uart { 125struct mvebu_uart {
113 struct uart_port *port; 126 struct uart_port *port;
@@ -115,6 +128,9 @@ struct mvebu_uart {
115 int irq[UART_IRQ_COUNT]; 128 int irq[UART_IRQ_COUNT];
116 unsigned char __iomem *nb; 129 unsigned char __iomem *nb;
117 struct mvebu_uart_driver_data *data; 130 struct mvebu_uart_driver_data *data;
131#if defined(CONFIG_PM)
132 struct mvebu_uart_pm_regs pm_regs;
133#endif /* CONFIG_PM */
118}; 134};
119 135
120static struct mvebu_uart *to_mvuart(struct uart_port *port) 136static struct mvebu_uart *to_mvuart(struct uart_port *port)
@@ -718,6 +734,51 @@ static struct uart_driver mvebu_uart_driver = {
718#endif 734#endif
719}; 735};
720 736
737#if defined(CONFIG_PM)
738static int mvebu_uart_suspend(struct device *dev)
739{
740 struct mvebu_uart *mvuart = dev_get_drvdata(dev);
741 struct uart_port *port = mvuart->port;
742
743 uart_suspend_port(&mvebu_uart_driver, port);
744
745 mvuart->pm_regs.rbr = readl(port->membase + UART_RBR(port));
746 mvuart->pm_regs.tsh = readl(port->membase + UART_TSH(port));
747 mvuart->pm_regs.ctrl = readl(port->membase + UART_CTRL(port));
748 mvuart->pm_regs.intr = readl(port->membase + UART_INTR(port));
749 mvuart->pm_regs.stat = readl(port->membase + UART_STAT);
750 mvuart->pm_regs.brdv = readl(port->membase + UART_BRDV);
751 mvuart->pm_regs.osamp = readl(port->membase + UART_OSAMP);
752
753 device_set_wakeup_enable(dev, true);
754
755 return 0;
756}
757
758static int mvebu_uart_resume(struct device *dev)
759{
760 struct mvebu_uart *mvuart = dev_get_drvdata(dev);
761 struct uart_port *port = mvuart->port;
762
763 writel(mvuart->pm_regs.rbr, port->membase + UART_RBR(port));
764 writel(mvuart->pm_regs.tsh, port->membase + UART_TSH(port));
765 writel(mvuart->pm_regs.ctrl, port->membase + UART_CTRL(port));
766 writel(mvuart->pm_regs.intr, port->membase + UART_INTR(port));
767 writel(mvuart->pm_regs.stat, port->membase + UART_STAT);
768 writel(mvuart->pm_regs.brdv, port->membase + UART_BRDV);
769 writel(mvuart->pm_regs.osamp, port->membase + UART_OSAMP);
770
771 uart_resume_port(&mvebu_uart_driver, port);
772
773 return 0;
774}
775
776static const struct dev_pm_ops mvebu_uart_pm_ops = {
777 .suspend = mvebu_uart_suspend,
778 .resume = mvebu_uart_resume,
779};
780#endif /* CONFIG_PM */
781
721static const struct of_device_id mvebu_uart_of_match[]; 782static const struct of_device_id mvebu_uart_of_match[];
722 783
723/* Counter to keep track of each UART port id when not using CONFIG_OF */ 784/* Counter to keep track of each UART port id when not using CONFIG_OF */
@@ -891,6 +952,9 @@ static struct platform_driver mvebu_uart_platform_driver = {
891 .name = "mvebu-uart", 952 .name = "mvebu-uart",
892 .of_match_table = of_match_ptr(mvebu_uart_of_match), 953 .of_match_table = of_match_ptr(mvebu_uart_of_match),
893 .suppress_bind_attrs = true, 954 .suppress_bind_attrs = true,
955#if defined(CONFIG_PM)
956 .pm = &mvebu_uart_pm_ops,
957#endif /* CONFIG_PM */
894 }, 958 },
895}; 959};
896 960
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index a1b3eb04cb32..c62e17c85f57 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -98,14 +98,13 @@ struct qcom_geni_serial_port {
98 enum geni_se_xfer_mode xfer_mode; 98 enum geni_se_xfer_mode xfer_mode;
99 bool setup; 99 bool setup;
100 int (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); 100 int (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop);
101 unsigned int xmit_size;
102 unsigned int baud; 101 unsigned int baud;
103 unsigned int tx_bytes_pw; 102 unsigned int tx_bytes_pw;
104 unsigned int rx_bytes_pw; 103 unsigned int rx_bytes_pw;
105 bool brk; 104 bool brk;
106}; 105};
107 106
108static const struct uart_ops qcom_geni_serial_pops; 107static const struct uart_ops qcom_geni_console_pops;
109static struct uart_driver qcom_geni_console_driver; 108static struct uart_driver qcom_geni_console_driver;
110static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop); 109static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop);
111static unsigned int qcom_geni_serial_tx_empty(struct uart_port *port); 110static unsigned int qcom_geni_serial_tx_empty(struct uart_port *port);
@@ -118,7 +117,14 @@ static const unsigned long root_freq[] = {7372800, 14745600, 19200000, 29491200,
118#define to_dev_port(ptr, member) \ 117#define to_dev_port(ptr, member) \
119 container_of(ptr, struct qcom_geni_serial_port, member) 118 container_of(ptr, struct qcom_geni_serial_port, member)
120 119
121static struct qcom_geni_serial_port qcom_geni_console_port; 120static struct qcom_geni_serial_port qcom_geni_console_port = {
121 .uport = {
122 .iotype = UPIO_MEM,
123 .ops = &qcom_geni_console_pops,
124 .flags = UPF_BOOT_AUTOCONF,
125 .line = 0,
126 },
127};
122 128
123static int qcom_geni_serial_request_port(struct uart_port *uport) 129static int qcom_geni_serial_request_port(struct uart_port *uport)
124{ 130{
@@ -189,8 +195,19 @@ static bool qcom_geni_serial_poll_bit(struct uart_port *uport,
189 timeout_us = ((fifo_bits * USEC_PER_SEC) / baud) + 500; 195 timeout_us = ((fifo_bits * USEC_PER_SEC) / baud) + 500;
190 } 196 }
191 197
192 return !readl_poll_timeout_atomic(uport->membase + offset, reg, 198 /*
193 (bool)(reg & field) == set, 10, timeout_us); 199 * Use custom implementation instead of readl_poll_atomic since ktimer
200 * is not ready at the time of early console.
201 */
202 timeout_us = DIV_ROUND_UP(timeout_us, 10) * 10;
203 while (timeout_us) {
204 reg = readl_relaxed(uport->membase + offset);
205 if ((bool)(reg & field) == set)
206 return true;
207 udelay(10);
208 timeout_us -= 10;
209 }
210 return false;
194} 211}
195 212
196static void qcom_geni_serial_setup_tx(struct uart_port *uport, u32 xmit_size) 213static void qcom_geni_serial_setup_tx(struct uart_port *uport, u32 xmit_size)
@@ -286,6 +303,10 @@ __qcom_geni_serial_console_write(struct uart_port *uport, const char *s,
286 u32 bytes_to_send = count; 303 u32 bytes_to_send = count;
287 304
288 for (i = 0; i < count; i++) { 305 for (i = 0; i < count; i++) {
306 /*
307 * uart_console_write() adds a carriage return for each newline.
308 * Account for additional bytes to be written.
309 */
289 if (s[i] == '\n') 310 if (s[i] == '\n')
290 bytes_to_send++; 311 bytes_to_send++;
291 } 312 }
@@ -305,7 +326,7 @@ __qcom_geni_serial_console_write(struct uart_port *uport, const char *s,
305 if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, 326 if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
306 M_TX_FIFO_WATERMARK_EN, true)) 327 M_TX_FIFO_WATERMARK_EN, true))
307 break; 328 break;
308 chars_to_write = min_t(size_t, (size_t)(count - i), avail / 2); 329 chars_to_write = min_t(size_t, count - i, avail / 2);
309 uart_console_write(uport, s + i, chars_to_write, 330 uart_console_write(uport, s + i, chars_to_write,
310 qcom_geni_serial_wr_char); 331 qcom_geni_serial_wr_char);
311 writel_relaxed(M_TX_FIFO_WATERMARK_EN, uport->membase + 332 writel_relaxed(M_TX_FIFO_WATERMARK_EN, uport->membase +
@@ -406,20 +427,18 @@ static void qcom_geni_serial_start_tx(struct uart_port *uport)
406 u32 status; 427 u32 status;
407 428
408 if (port->xfer_mode == GENI_SE_FIFO) { 429 if (port->xfer_mode == GENI_SE_FIFO) {
409 status = readl_relaxed(uport->membase + SE_GENI_STATUS); 430 /*
431 * readl ensures reading & writing of IRQ_EN register
432 * is not re-ordered before checking the status of the
433 * Serial Engine.
434 */
435 status = readl(uport->membase + SE_GENI_STATUS);
410 if (status & M_GENI_CMD_ACTIVE) 436 if (status & M_GENI_CMD_ACTIVE)
411 return; 437 return;
412 438
413 if (!qcom_geni_serial_tx_empty(uport)) 439 if (!qcom_geni_serial_tx_empty(uport))
414 return; 440 return;
415 441
416 /*
417 * Ensure writing to IRQ_EN & watermark registers are not
418 * re-ordered before checking the status of the Serial
419 * Engine and TX FIFO
420 */
421 mb();
422
423 irq_en = readl_relaxed(uport->membase + SE_GENI_M_IRQ_EN); 442 irq_en = readl_relaxed(uport->membase + SE_GENI_M_IRQ_EN);
424 irq_en |= M_TX_FIFO_WATERMARK_EN | M_CMD_DONE_EN; 443 irq_en |= M_TX_FIFO_WATERMARK_EN | M_CMD_DONE_EN;
425 444
@@ -442,7 +461,6 @@ static void qcom_geni_serial_stop_tx(struct uart_port *uport)
442 writel_relaxed(0, uport->membase + 461 writel_relaxed(0, uport->membase +
443 SE_GENI_TX_WATERMARK_REG); 462 SE_GENI_TX_WATERMARK_REG);
444 } 463 }
445 port->xmit_size = 0;
446 writel_relaxed(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 464 writel_relaxed(irq_en, uport->membase + SE_GENI_M_IRQ_EN);
447 status = readl_relaxed(uport->membase + SE_GENI_STATUS); 465 status = readl_relaxed(uport->membase + SE_GENI_STATUS);
448 /* Possible stop tx is called multiple times. */ 466 /* Possible stop tx is called multiple times. */
@@ -572,21 +590,14 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport)
572 chunk = uart_circ_chars_pending(xmit); 590 chunk = uart_circ_chars_pending(xmit);
573 status = readl_relaxed(uport->membase + SE_GENI_TX_FIFO_STATUS); 591 status = readl_relaxed(uport->membase + SE_GENI_TX_FIFO_STATUS);
574 /* Both FIFO and framework buffer are drained */ 592 /* Both FIFO and framework buffer are drained */
575 if (chunk == port->xmit_size && !status) { 593 if (!chunk && !status) {
576 port->xmit_size = 0;
577 uart_circ_clear(xmit);
578 qcom_geni_serial_stop_tx(uport); 594 qcom_geni_serial_stop_tx(uport);
579 goto out_write_wakeup; 595 goto out_write_wakeup;
580 } 596 }
581 chunk -= port->xmit_size;
582 597
583 avail = (port->tx_fifo_depth - port->tx_wm) * port->tx_bytes_pw; 598 avail = (port->tx_fifo_depth - port->tx_wm) * port->tx_bytes_pw;
584 tail = (xmit->tail + port->xmit_size) & (UART_XMIT_SIZE - 1); 599 tail = xmit->tail;
585 if (chunk > (UART_XMIT_SIZE - tail)) 600 chunk = min3((size_t)chunk, (size_t)(UART_XMIT_SIZE - tail), avail);
586 chunk = UART_XMIT_SIZE - tail;
587 if (chunk > avail)
588 chunk = avail;
589
590 if (!chunk) 601 if (!chunk)
591 goto out_write_wakeup; 602 goto out_write_wakeup;
592 603
@@ -595,24 +606,27 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport)
595 remaining = chunk; 606 remaining = chunk;
596 for (i = 0; i < chunk; ) { 607 for (i = 0; i < chunk; ) {
597 unsigned int tx_bytes; 608 unsigned int tx_bytes;
598 unsigned int buf = 0; 609 u8 buf[sizeof(u32)];
599 int c; 610 int c;
600 611
601 tx_bytes = min_t(size_t, remaining, (size_t)port->tx_bytes_pw); 612 memset(buf, 0, ARRAY_SIZE(buf));
613 tx_bytes = min_t(size_t, remaining, port->tx_bytes_pw);
602 for (c = 0; c < tx_bytes ; c++) 614 for (c = 0; c < tx_bytes ; c++)
603 buf |= (xmit->buf[tail + c] << (c * BITS_PER_BYTE)); 615 buf[c] = xmit->buf[tail + c];
604 616
605 writel_relaxed(buf, uport->membase + SE_GENI_TX_FIFOn); 617 iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1);
606 618
607 i += tx_bytes; 619 i += tx_bytes;
608 tail = (tail + tx_bytes) & (UART_XMIT_SIZE - 1); 620 tail += tx_bytes;
609 uport->icount.tx += tx_bytes; 621 uport->icount.tx += tx_bytes;
610 remaining -= tx_bytes; 622 remaining -= tx_bytes;
611 } 623 }
624
625 xmit->tail = tail & (UART_XMIT_SIZE - 1);
612 qcom_geni_serial_poll_tx_done(uport); 626 qcom_geni_serial_poll_tx_done(uport);
613 port->xmit_size += chunk;
614out_write_wakeup: 627out_write_wakeup:
615 uart_write_wakeup(uport); 628 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
629 uart_write_wakeup(uport);
616} 630}
617 631
618static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) 632static irqreturn_t qcom_geni_serial_isr(int isr, void *dev)
@@ -627,7 +641,7 @@ static irqreturn_t qcom_geni_serial_isr(int isr, void *dev)
627 struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 641 struct qcom_geni_serial_port *port = to_dev_port(uport, uport);
628 642
629 if (uport->suspended) 643 if (uport->suspended)
630 return IRQ_HANDLED; 644 return IRQ_NONE;
631 645
632 spin_lock_irqsave(&uport->lock, flags); 646 spin_lock_irqsave(&uport->lock, flags);
633 m_irq_status = readl_relaxed(uport->membase + SE_GENI_M_IRQ_STATUS); 647 m_irq_status = readl_relaxed(uport->membase + SE_GENI_M_IRQ_STATUS);
@@ -667,20 +681,16 @@ out_unlock:
667 return IRQ_HANDLED; 681 return IRQ_HANDLED;
668} 682}
669 683
670static int get_tx_fifo_size(struct qcom_geni_serial_port *port) 684static void get_tx_fifo_size(struct qcom_geni_serial_port *port)
671{ 685{
672 struct uart_port *uport; 686 struct uart_port *uport;
673 687
674 if (!port)
675 return -ENODEV;
676
677 uport = &port->uport; 688 uport = &port->uport;
678 port->tx_fifo_depth = geni_se_get_tx_fifo_depth(&port->se); 689 port->tx_fifo_depth = geni_se_get_tx_fifo_depth(&port->se);
679 port->tx_fifo_width = geni_se_get_tx_fifo_width(&port->se); 690 port->tx_fifo_width = geni_se_get_tx_fifo_width(&port->se);
680 port->rx_fifo_depth = geni_se_get_rx_fifo_depth(&port->se); 691 port->rx_fifo_depth = geni_se_get_rx_fifo_depth(&port->se);
681 uport->fifosize = 692 uport->fifosize =
682 (port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE; 693 (port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE;
683 return 0;
684} 694}
685 695
686static void set_rfr_wm(struct qcom_geni_serial_port *port) 696static void set_rfr_wm(struct qcom_geni_serial_port *port)
@@ -702,7 +712,6 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
702 /* Stop the console before stopping the current tx */ 712 /* Stop the console before stopping the current tx */
703 console_stop(uport->cons); 713 console_stop(uport->cons);
704 714
705 disable_irq(uport->irq);
706 free_irq(uport->irq, uport); 715 free_irq(uport->irq, uport);
707 spin_lock_irqsave(&uport->lock, flags); 716 spin_lock_irqsave(&uport->lock, flags);
708 qcom_geni_serial_stop_tx(uport); 717 qcom_geni_serial_stop_tx(uport);
@@ -892,7 +901,7 @@ out_restart_rx:
892 901
893static unsigned int qcom_geni_serial_tx_empty(struct uart_port *uport) 902static unsigned int qcom_geni_serial_tx_empty(struct uart_port *uport)
894{ 903{
895 return !readl_relaxed(uport->membase + SE_GENI_TX_FIFO_STATUS); 904 return !readl(uport->membase + SE_GENI_TX_FIFO_STATUS);
896} 905}
897 906
898#ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE 907#ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
@@ -910,7 +919,7 @@ static int __init qcom_geni_console_setup(struct console *co, char *options)
910 919
911 port = get_port_from_line(co->index); 920 port = get_port_from_line(co->index);
912 if (IS_ERR(port)) { 921 if (IS_ERR(port)) {
913 pr_err("Invalid line %d(%d)\n", co->index, (int)PTR_ERR(port)); 922 pr_err("Invalid line %d\n", co->index);
914 return PTR_ERR(port); 923 return PTR_ERR(port);
915 } 924 }
916 925
@@ -942,6 +951,65 @@ static int __init qcom_geni_console_setup(struct console *co, char *options)
942 return uart_set_options(uport, co, baud, parity, bits, flow); 951 return uart_set_options(uport, co, baud, parity, bits, flow);
943} 952}
944 953
954static void qcom_geni_serial_earlycon_write(struct console *con,
955 const char *s, unsigned int n)
956{
957 struct earlycon_device *dev = con->data;
958
959 __qcom_geni_serial_console_write(&dev->port, s, n);
960}
961
962static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev,
963 const char *opt)
964{
965 struct uart_port *uport = &dev->port;
966 u32 tx_trans_cfg;
967 u32 tx_parity_cfg = 0; /* Disable Tx Parity */
968 u32 rx_trans_cfg = 0;
969 u32 rx_parity_cfg = 0; /* Disable Rx Parity */
970 u32 stop_bit_len = 0; /* Default stop bit length - 1 bit */
971 u32 bits_per_char;
972 struct geni_se se;
973
974 if (!uport->membase)
975 return -EINVAL;
976
977 memset(&se, 0, sizeof(se));
978 se.base = uport->membase;
979 if (geni_se_read_proto(&se) != GENI_SE_UART)
980 return -ENXIO;
981 /*
982 * Ignore Flow control.
983 * n = 8.
984 */
985 tx_trans_cfg = UART_CTS_MASK;
986 bits_per_char = BITS_PER_BYTE;
987
988 /*
989 * Make an unconditional cancel on the main sequencer to reset
990 * it else we could end up in data loss scenarios.
991 */
992 qcom_geni_serial_poll_tx_done(uport);
993 qcom_geni_serial_abort_rx(uport);
994 geni_se_config_packing(&se, BITS_PER_BYTE, 1, false, true, false);
995 geni_se_init(&se, DEF_FIFO_DEPTH_WORDS / 2, DEF_FIFO_DEPTH_WORDS - 2);
996 geni_se_select_mode(&se, GENI_SE_FIFO);
997
998 writel_relaxed(tx_trans_cfg, uport->membase + SE_UART_TX_TRANS_CFG);
999 writel_relaxed(tx_parity_cfg, uport->membase + SE_UART_TX_PARITY_CFG);
1000 writel_relaxed(rx_trans_cfg, uport->membase + SE_UART_RX_TRANS_CFG);
1001 writel_relaxed(rx_parity_cfg, uport->membase + SE_UART_RX_PARITY_CFG);
1002 writel_relaxed(bits_per_char, uport->membase + SE_UART_TX_WORD_LEN);
1003 writel_relaxed(bits_per_char, uport->membase + SE_UART_RX_WORD_LEN);
1004 writel_relaxed(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN);
1005
1006 dev->con->write = qcom_geni_serial_earlycon_write;
1007 dev->con->setup = NULL;
1008 return 0;
1009}
1010OF_EARLYCON_DECLARE(qcom_geni, "qcom,geni-debug-uart",
1011 qcom_geni_serial_earlycon_setup);
1012
945static int __init console_register(struct uart_driver *drv) 1013static int __init console_register(struct uart_driver *drv)
946{ 1014{
947 return uart_register_driver(drv); 1015 return uart_register_driver(drv);
@@ -1026,16 +1094,13 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
1026 1094
1027 if (pdev->dev.of_node) 1095 if (pdev->dev.of_node)
1028 line = of_alias_get_id(pdev->dev.of_node, "serial"); 1096 line = of_alias_get_id(pdev->dev.of_node, "serial");
1029 else
1030 line = pdev->id;
1031 1097
1032 if (line < 0 || line >= GENI_UART_CONS_PORTS) 1098 if (line < 0 || line >= GENI_UART_CONS_PORTS)
1033 return -ENXIO; 1099 return -ENXIO;
1034 port = get_port_from_line(line); 1100 port = get_port_from_line(line);
1035 if (IS_ERR(port)) { 1101 if (IS_ERR(port)) {
1036 ret = PTR_ERR(port); 1102 dev_err(&pdev->dev, "Invalid line %d\n", line);
1037 dev_err(&pdev->dev, "Invalid line %d(%d)\n", line, ret); 1103 return PTR_ERR(port);
1038 return ret;
1039 } 1104 }
1040 1105
1041 uport = &port->uport; 1106 uport = &port->uport;
@@ -1072,7 +1137,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
1072 uport->private_data = &qcom_geni_console_driver; 1137 uport->private_data = &qcom_geni_console_driver;
1073 platform_set_drvdata(pdev, port); 1138 platform_set_drvdata(pdev, port);
1074 port->handle_rx = handle_rx_console; 1139 port->handle_rx = handle_rx_console;
1075 port->setup = false;
1076 return uart_add_one_port(&qcom_geni_console_driver, uport); 1140 return uart_add_one_port(&qcom_geni_console_driver, uport);
1077} 1141}
1078 1142
@@ -1087,8 +1151,7 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)
1087 1151
1088static int __maybe_unused qcom_geni_serial_sys_suspend_noirq(struct device *dev) 1152static int __maybe_unused qcom_geni_serial_sys_suspend_noirq(struct device *dev)
1089{ 1153{
1090 struct platform_device *pdev = to_platform_device(dev); 1154 struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
1091 struct qcom_geni_serial_port *port = platform_get_drvdata(pdev);
1092 struct uart_port *uport = &port->uport; 1155 struct uart_port *uport = &port->uport;
1093 1156
1094 uart_suspend_port(uport->private_data, uport); 1157 uart_suspend_port(uport->private_data, uport);
@@ -1097,12 +1160,19 @@ static int __maybe_unused qcom_geni_serial_sys_suspend_noirq(struct device *dev)
1097 1160
1098static int __maybe_unused qcom_geni_serial_sys_resume_noirq(struct device *dev) 1161static int __maybe_unused qcom_geni_serial_sys_resume_noirq(struct device *dev)
1099{ 1162{
1100 struct platform_device *pdev = to_platform_device(dev); 1163 struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
1101 struct qcom_geni_serial_port *port = platform_get_drvdata(pdev);
1102 struct uart_port *uport = &port->uport; 1164 struct uart_port *uport = &port->uport;
1103 1165
1104 if (console_suspend_enabled && uport->suspended) { 1166 if (console_suspend_enabled && uport->suspended) {
1105 uart_resume_port(uport->private_data, uport); 1167 uart_resume_port(uport->private_data, uport);
1168 /*
1169 * uart_suspend_port() invokes port shutdown which in turn
1170 * frees the irq. uart_resume_port invokes port startup which
1171 * performs request_irq. The request_irq auto-enables the IRQ.
1172 * In addition, resume_noirq implicitly enables the IRQ and
1173 * leads to an unbalanced IRQ enable warning. Disable the IRQ
1174 * before returning so that the warning is suppressed.
1175 */
1106 disable_irq(uport->irq); 1176 disable_irq(uport->irq);
1107 } 1177 }
1108 return 0; 1178 return 0;
@@ -1133,11 +1203,6 @@ static int __init qcom_geni_serial_init(void)
1133{ 1203{
1134 int ret; 1204 int ret;
1135 1205
1136 qcom_geni_console_port.uport.iotype = UPIO_MEM;
1137 qcom_geni_console_port.uport.ops = &qcom_geni_console_pops;
1138 qcom_geni_console_port.uport.flags = UPF_BOOT_AUTOCONF;
1139 qcom_geni_console_port.uport.line = 0;
1140
1141 ret = console_register(&qcom_geni_console_driver); 1206 ret = console_register(&qcom_geni_console_driver);
1142 if (ret) 1207 if (ret)
1143 return ret; 1208 return ret;
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 3f2f8c118ce0..2f8fa184aafa 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -856,35 +856,54 @@ static void s3c24xx_serial_break_ctl(struct uart_port *port, int break_state)
856static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) 856static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p)
857{ 857{
858 struct s3c24xx_uart_dma *dma = p->dma; 858 struct s3c24xx_uart_dma *dma = p->dma;
859 struct dma_slave_caps dma_caps;
860 const char *reason = NULL;
859 int ret; 861 int ret;
860 862
861 /* Default slave configuration parameters */ 863 /* Default slave configuration parameters */
862 dma->rx_conf.direction = DMA_DEV_TO_MEM; 864 dma->rx_conf.direction = DMA_DEV_TO_MEM;
863 dma->rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 865 dma->rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
864 dma->rx_conf.src_addr = p->port.mapbase + S3C2410_URXH; 866 dma->rx_conf.src_addr = p->port.mapbase + S3C2410_URXH;
865 dma->rx_conf.src_maxburst = 16; 867 dma->rx_conf.src_maxburst = 1;
866 868
867 dma->tx_conf.direction = DMA_MEM_TO_DEV; 869 dma->tx_conf.direction = DMA_MEM_TO_DEV;
868 dma->tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 870 dma->tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
869 dma->tx_conf.dst_addr = p->port.mapbase + S3C2410_UTXH; 871 dma->tx_conf.dst_addr = p->port.mapbase + S3C2410_UTXH;
870 if (dma_get_cache_alignment() >= 16) 872 dma->tx_conf.dst_maxburst = 1;
871 dma->tx_conf.dst_maxburst = 16;
872 else
873 dma->tx_conf.dst_maxburst = 1;
874 873
875 dma->rx_chan = dma_request_chan(p->port.dev, "rx"); 874 dma->rx_chan = dma_request_chan(p->port.dev, "rx");
876 875
877 if (IS_ERR(dma->rx_chan)) 876 if (IS_ERR(dma->rx_chan)) {
878 return PTR_ERR(dma->rx_chan); 877 reason = "DMA RX channel request failed";
878 ret = PTR_ERR(dma->rx_chan);
879 goto err_warn;
880 }
881
882 ret = dma_get_slave_caps(dma->rx_chan, &dma_caps);
883 if (ret < 0 ||
884 dma_caps.residue_granularity < DMA_RESIDUE_GRANULARITY_BURST) {
885 reason = "insufficient DMA RX engine capabilities";
886 ret = -EOPNOTSUPP;
887 goto err_release_rx;
888 }
879 889
880 dmaengine_slave_config(dma->rx_chan, &dma->rx_conf); 890 dmaengine_slave_config(dma->rx_chan, &dma->rx_conf);
881 891
882 dma->tx_chan = dma_request_chan(p->port.dev, "tx"); 892 dma->tx_chan = dma_request_chan(p->port.dev, "tx");
883 if (IS_ERR(dma->tx_chan)) { 893 if (IS_ERR(dma->tx_chan)) {
894 reason = "DMA TX channel request failed";
884 ret = PTR_ERR(dma->tx_chan); 895 ret = PTR_ERR(dma->tx_chan);
885 goto err_release_rx; 896 goto err_release_rx;
886 } 897 }
887 898
899 ret = dma_get_slave_caps(dma->tx_chan, &dma_caps);
900 if (ret < 0 ||
901 dma_caps.residue_granularity < DMA_RESIDUE_GRANULARITY_BURST) {
902 reason = "insufficient DMA TX engine capabilities";
903 ret = -EOPNOTSUPP;
904 goto err_release_tx;
905 }
906
888 dmaengine_slave_config(dma->tx_chan, &dma->tx_conf); 907 dmaengine_slave_config(dma->tx_chan, &dma->tx_conf);
889 908
890 /* RX buffer */ 909 /* RX buffer */
@@ -899,6 +918,7 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p)
899 dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf, 918 dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf,
900 dma->rx_size, DMA_FROM_DEVICE); 919 dma->rx_size, DMA_FROM_DEVICE);
901 if (dma_mapping_error(p->port.dev, dma->rx_addr)) { 920 if (dma_mapping_error(p->port.dev, dma->rx_addr)) {
921 reason = "DMA mapping error for RX buffer";
902 ret = -EIO; 922 ret = -EIO;
903 goto err_free_rx; 923 goto err_free_rx;
904 } 924 }
@@ -907,6 +927,7 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p)
907 dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf, 927 dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf,
908 UART_XMIT_SIZE, DMA_TO_DEVICE); 928 UART_XMIT_SIZE, DMA_TO_DEVICE);
909 if (dma_mapping_error(p->port.dev, dma->tx_addr)) { 929 if (dma_mapping_error(p->port.dev, dma->tx_addr)) {
930 reason = "DMA mapping error for TX buffer";
910 ret = -EIO; 931 ret = -EIO;
911 goto err_unmap_rx; 932 goto err_unmap_rx;
912 } 933 }
@@ -922,6 +943,9 @@ err_release_tx:
922 dma_release_channel(dma->tx_chan); 943 dma_release_channel(dma->tx_chan);
923err_release_rx: 944err_release_rx:
924 dma_release_channel(dma->rx_chan); 945 dma_release_channel(dma->rx_chan);
946err_warn:
947 if (reason)
948 dev_warn(p->port.dev, "%s, DMA will not be used\n", reason);
925 return ret; 949 return ret;
926} 950}
927 951
@@ -1040,8 +1064,6 @@ static int s3c64xx_serial_startup(struct uart_port *port)
1040 if (ourport->dma) { 1064 if (ourport->dma) {
1041 ret = s3c24xx_serial_request_dma(ourport); 1065 ret = s3c24xx_serial_request_dma(ourport);
1042 if (ret < 0) { 1066 if (ret < 0) {
1043 dev_warn(port->dev,
1044 "DMA request failed, DMA will not be used\n");
1045 devm_kfree(port->dev, ourport->dma); 1067 devm_kfree(port->dev, ourport->dma);
1046 ourport->dma = NULL; 1068 ourport->dma = NULL;
1047 } 1069 }
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 65792a3539d0..243c96025053 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1168,7 +1168,10 @@ static int sc16is7xx_probe(struct device *dev,
1168 else 1168 else
1169 return PTR_ERR(s->clk); 1169 return PTR_ERR(s->clk);
1170 } else { 1170 } else {
1171 clk_prepare_enable(s->clk); 1171 ret = clk_prepare_enable(s->clk);
1172 if (ret)
1173 return ret;
1174
1172 freq = clk_get_rate(s->clk); 1175 freq = clk_get_rate(s->clk);
1173 } 1176 }
1174 1177
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 6ff9405954a6..890b8832aff2 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -674,8 +674,8 @@ static void uart_send_xchar(struct tty_struct *tty, char ch)
674static void uart_throttle(struct tty_struct *tty) 674static void uart_throttle(struct tty_struct *tty)
675{ 675{
676 struct uart_state *state = tty->driver_data; 676 struct uart_state *state = tty->driver_data;
677 upstat_t mask = UPSTAT_SYNC_FIFO;
677 struct uart_port *port; 678 struct uart_port *port;
678 upstat_t mask = 0;
679 679
680 port = uart_port_ref(state); 680 port = uart_port_ref(state);
681 if (!port) 681 if (!port)
@@ -703,8 +703,8 @@ static void uart_throttle(struct tty_struct *tty)
703static void uart_unthrottle(struct tty_struct *tty) 703static void uart_unthrottle(struct tty_struct *tty)
704{ 704{
705 struct uart_state *state = tty->driver_data; 705 struct uart_state *state = tty->driver_data;
706 upstat_t mask = UPSTAT_SYNC_FIFO;
706 struct uart_port *port; 707 struct uart_port *port;
707 upstat_t mask = 0;
708 708
709 port = uart_port_ref(state); 709 port = uart_port_ref(state);
710 if (!port) 710 if (!port)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index fdbbff547106..b46b146524ce 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -160,6 +160,7 @@ struct sci_port {
160#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS 160#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS
161 161
162static struct sci_port sci_ports[SCI_NPORTS]; 162static struct sci_port sci_ports[SCI_NPORTS];
163static unsigned long sci_ports_in_use;
163static struct uart_driver sci_uart_driver; 164static struct uart_driver sci_uart_driver;
164 165
165static inline struct sci_port * 166static inline struct sci_port *
@@ -2390,6 +2391,27 @@ done:
2390 2391
2391 uart_update_timeout(port, termios->c_cflag, baud); 2392 uart_update_timeout(port, termios->c_cflag, baud);
2392 2393
2394 /* byte size and parity */
2395 switch (termios->c_cflag & CSIZE) {
2396 case CS5:
2397 bits = 7;
2398 break;
2399 case CS6:
2400 bits = 8;
2401 break;
2402 case CS7:
2403 bits = 9;
2404 break;
2405 default:
2406 bits = 10;
2407 break;
2408 }
2409
2410 if (termios->c_cflag & CSTOPB)
2411 bits++;
2412 if (termios->c_cflag & PARENB)
2413 bits++;
2414
2393 if (best_clk >= 0) { 2415 if (best_clk >= 0) {
2394 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) 2416 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
2395 switch (srr + 1) { 2417 switch (srr + 1) {
@@ -2406,8 +2428,27 @@ done:
2406 serial_port_out(port, SCSCR, scr_val | s->hscif_tot); 2428 serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
2407 serial_port_out(port, SCSMR, smr_val); 2429 serial_port_out(port, SCSMR, smr_val);
2408 serial_port_out(port, SCBRR, brr); 2430 serial_port_out(port, SCBRR, brr);
2409 if (sci_getreg(port, HSSRR)->size) 2431 if (sci_getreg(port, HSSRR)->size) {
2410 serial_port_out(port, HSSRR, srr | HSCIF_SRE); 2432 unsigned int hssrr = srr | HSCIF_SRE;
2433 /* Calculate deviation from intended rate at the
2434 * center of the last stop bit in sampling clocks.
2435 */
2436 int last_stop = bits * 2 - 1;
2437 int deviation = min_err * srr * last_stop / 2 / baud;
2438
2439 if (abs(deviation) >= 2) {
2440 /* At least two sampling clocks off at the
2441 * last stop bit; we can increase the error
2442 * margin by shifting the sampling point.
2443 */
2444 int shift = min(-8, max(7, deviation / 2));
2445
2446 hssrr |= (shift << HSCIF_SRHP_SHIFT) &
2447 HSCIF_SRHP_MASK;
2448 hssrr |= HSCIF_SRDE;
2449 }
2450 serial_port_out(port, HSSRR, hssrr);
2451 }
2411 2452
2412 /* Wait one bit interval */ 2453 /* Wait one bit interval */
2413 udelay((1000000 + (baud - 1)) / baud); 2454 udelay((1000000 + (baud - 1)) / baud);
@@ -2474,27 +2515,6 @@ done:
2474 * value obtained by this formula is too small. Therefore, if the value 2515 * value obtained by this formula is too small. Therefore, if the value
2475 * is smaller than 20ms, use 20ms as the timeout value for DMA. 2516 * is smaller than 20ms, use 20ms as the timeout value for DMA.
2476 */ 2517 */
2477 /* byte size and parity */
2478 switch (termios->c_cflag & CSIZE) {
2479 case CS5:
2480 bits = 7;
2481 break;
2482 case CS6:
2483 bits = 8;
2484 break;
2485 case CS7:
2486 bits = 9;
2487 break;
2488 default:
2489 bits = 10;
2490 break;
2491 }
2492
2493 if (termios->c_cflag & CSTOPB)
2494 bits++;
2495 if (termios->c_cflag & PARENB)
2496 bits++;
2497
2498 s->rx_frame = (10000 * bits) / (baud / 100); 2518 s->rx_frame = (10000 * bits) / (baud / 100);
2499#ifdef CONFIG_SERIAL_SH_SCI_DMA 2519#ifdef CONFIG_SERIAL_SH_SCI_DMA
2500 s->rx_timeout = s->buf_len_rx * 2 * s->rx_frame; 2520 s->rx_timeout = s->buf_len_rx * 2 * s->rx_frame;
@@ -2890,16 +2910,15 @@ static void serial_console_write(struct console *co, const char *s,
2890 unsigned long flags; 2910 unsigned long flags;
2891 int locked = 1; 2911 int locked = 1;
2892 2912
2893 local_irq_save(flags);
2894#if defined(SUPPORT_SYSRQ) 2913#if defined(SUPPORT_SYSRQ)
2895 if (port->sysrq) 2914 if (port->sysrq)
2896 locked = 0; 2915 locked = 0;
2897 else 2916 else
2898#endif 2917#endif
2899 if (oops_in_progress) 2918 if (oops_in_progress)
2900 locked = spin_trylock(&port->lock); 2919 locked = spin_trylock_irqsave(&port->lock, flags);
2901 else 2920 else
2902 spin_lock(&port->lock); 2921 spin_lock_irqsave(&port->lock, flags);
2903 2922
2904 /* first save SCSCR then disable interrupts, keep clock source */ 2923 /* first save SCSCR then disable interrupts, keep clock source */
2905 ctrl = serial_port_in(port, SCSCR); 2924 ctrl = serial_port_in(port, SCSCR);
@@ -2919,8 +2938,7 @@ static void serial_console_write(struct console *co, const char *s,
2919 serial_port_out(port, SCSCR, ctrl); 2938 serial_port_out(port, SCSCR, ctrl);
2920 2939
2921 if (locked) 2940 if (locked)
2922 spin_unlock(&port->lock); 2941 spin_unlock_irqrestore(&port->lock, flags);
2923 local_irq_restore(flags);
2924} 2942}
2925 2943
2926static int serial_console_setup(struct console *co, char *options) 2944static int serial_console_setup(struct console *co, char *options)
@@ -3026,6 +3044,7 @@ static int sci_remove(struct platform_device *dev)
3026{ 3044{
3027 struct sci_port *port = platform_get_drvdata(dev); 3045 struct sci_port *port = platform_get_drvdata(dev);
3028 3046
3047 sci_ports_in_use &= ~BIT(port->port.line);
3029 uart_remove_one_port(&sci_uart_driver, &port->port); 3048 uart_remove_one_port(&sci_uart_driver, &port->port);
3030 3049
3031 sci_cleanup_single(port); 3050 sci_cleanup_single(port);
@@ -3107,6 +3126,8 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
3107 3126
3108 /* Get the line number from the aliases node. */ 3127 /* Get the line number from the aliases node. */
3109 id = of_alias_get_id(np, "serial"); 3128 id = of_alias_get_id(np, "serial");
3129 if (id < 0 && ~sci_ports_in_use)
3130 id = ffz(sci_ports_in_use);
3110 if (id < 0) { 3131 if (id < 0) {
3111 dev_err(&pdev->dev, "failed to get alias id (%d)\n", id); 3132 dev_err(&pdev->dev, "failed to get alias id (%d)\n", id);
3112 return NULL; 3133 return NULL;
@@ -3141,6 +3162,9 @@ static int sci_probe_single(struct platform_device *dev,
3141 dev_notice(&dev->dev, "Consider bumping CONFIG_SERIAL_SH_SCI_NR_UARTS!\n"); 3162 dev_notice(&dev->dev, "Consider bumping CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
3142 return -EINVAL; 3163 return -EINVAL;
3143 } 3164 }
3165 BUILD_BUG_ON(SCI_NPORTS > sizeof(sci_ports_in_use) * 8);
3166 if (sci_ports_in_use & BIT(index))
3167 return -EBUSY;
3144 3168
3145 mutex_lock(&sci_uart_registration_lock); 3169 mutex_lock(&sci_uart_registration_lock);
3146 if (!sci_uart_driver.state) { 3170 if (!sci_uart_driver.state) {
@@ -3239,6 +3263,7 @@ static int sci_probe(struct platform_device *dev)
3239 sh_bios_gdb_detach(); 3263 sh_bios_gdb_detach();
3240#endif 3264#endif
3241 3265
3266 sci_ports_in_use |= BIT(dev_id);
3242 return 0; 3267 return 0;
3243} 3268}
3244 3269
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index a5f792fd48d9..0b9e804e61a9 100644
--- a/drivers/tty/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
@@ -130,6 +130,10 @@ enum {
130 130
131/* HSSRR HSCIF */ 131/* HSSRR HSCIF */
132#define HSCIF_SRE BIT(15) /* Sampling Rate Register Enable */ 132#define HSCIF_SRE BIT(15) /* Sampling Rate Register Enable */
133#define HSCIF_SRDE BIT(14) /* Sampling Point Register Enable */
134
135#define HSCIF_SRHP_SHIFT 8
136#define HSCIF_SRHP_MASK 0x0f00
133 137
134/* SCPCR (Serial Port Control Register), SCIFA/SCIFB only */ 138/* SCPCR (Serial Port Control Register), SCIFA/SCIFB only */
135#define SCPCR_RTSC BIT(4) /* Serial Port RTS# Pin / Output Pin */ 139#define SCPCR_RTSC BIT(4) /* Serial Port RTS# Pin / Output Pin */
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index 5f9f01fac6dd..7971997cdead 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -842,16 +842,14 @@ static int asc_serial_remove(struct platform_device *pdev)
842#ifdef CONFIG_PM_SLEEP 842#ifdef CONFIG_PM_SLEEP
843static int asc_serial_suspend(struct device *dev) 843static int asc_serial_suspend(struct device *dev)
844{ 844{
845 struct platform_device *pdev = to_platform_device(dev); 845 struct uart_port *port = dev_get_drvdata(dev);
846 struct uart_port *port = platform_get_drvdata(pdev);
847 846
848 return uart_suspend_port(&asc_uart_driver, port); 847 return uart_suspend_port(&asc_uart_driver, port);
849} 848}
850 849
851static int asc_serial_resume(struct device *dev) 850static int asc_serial_resume(struct device *dev)
852{ 851{
853 struct platform_device *pdev = to_platform_device(dev); 852 struct uart_port *port = dev_get_drvdata(dev);
854 struct uart_port *port = platform_get_drvdata(pdev);
855 853
856 return uart_resume_port(&asc_uart_driver, port); 854 return uart_resume_port(&asc_uart_driver, port);
857} 855}
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index bd72dd843338..8a3e34234e98 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1097,45 +1097,6 @@ static const struct uart_ops cdns_uart_ops = {
1097#endif 1097#endif
1098}; 1098};
1099 1099
1100static struct uart_port cdns_uart_port[CDNS_UART_NR_PORTS];
1101
1102/**
1103 * cdns_uart_get_port - Configure the port from platform device resource info
1104 * @id: Port id
1105 *
1106 * Return: a pointer to a uart_port or NULL for failure
1107 */
1108static struct uart_port *cdns_uart_get_port(int id)
1109{
1110 struct uart_port *port;
1111
1112 /* Try the given port id if failed use default method */
1113 if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) {
1114 /* Find the next unused port */
1115 for (id = 0; id < CDNS_UART_NR_PORTS; id++)
1116 if (cdns_uart_port[id].mapbase == 0)
1117 break;
1118 }
1119
1120 if (id >= CDNS_UART_NR_PORTS)
1121 return NULL;
1122
1123 port = &cdns_uart_port[id];
1124
1125 /* At this point, we've got an empty uart_port struct, initialize it */
1126 spin_lock_init(&port->lock);
1127 port->membase = NULL;
1128 port->irq = 0;
1129 port->type = PORT_UNKNOWN;
1130 port->iotype = UPIO_MEM32;
1131 port->flags = UPF_BOOT_AUTOCONF;
1132 port->ops = &cdns_uart_ops;
1133 port->fifosize = CDNS_UART_FIFO_SIZE;
1134 port->line = id;
1135 port->dev = NULL;
1136 return port;
1137}
1138
1139#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE 1100#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
1140/** 1101/**
1141 * cdns_uart_console_wait_tx - Wait for the TX to be full 1102 * cdns_uart_console_wait_tx - Wait for the TX to be full
@@ -1206,6 +1167,10 @@ OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p8", cdns_early_console_setup);
1206OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup); 1167OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup);
1207OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup); 1168OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup);
1208 1169
1170
1171/* Static pointer to console port */
1172static struct uart_port *console_port;
1173
1209/** 1174/**
1210 * cdns_uart_console_write - perform write operation 1175 * cdns_uart_console_write - perform write operation
1211 * @co: Console handle 1176 * @co: Console handle
@@ -1215,7 +1180,7 @@ OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup);
1215static void cdns_uart_console_write(struct console *co, const char *s, 1180static void cdns_uart_console_write(struct console *co, const char *s,
1216 unsigned int count) 1181 unsigned int count)
1217{ 1182{
1218 struct uart_port *port = &cdns_uart_port[co->index]; 1183 struct uart_port *port = console_port;
1219 unsigned long flags; 1184 unsigned long flags;
1220 unsigned int imr, ctrl; 1185 unsigned int imr, ctrl;
1221 int locked = 1; 1186 int locked = 1;
@@ -1261,15 +1226,13 @@ static void cdns_uart_console_write(struct console *co, const char *s,
1261 */ 1226 */
1262static int __init cdns_uart_console_setup(struct console *co, char *options) 1227static int __init cdns_uart_console_setup(struct console *co, char *options)
1263{ 1228{
1264 struct uart_port *port = &cdns_uart_port[co->index]; 1229 struct uart_port *port = console_port;
1230
1265 int baud = 9600; 1231 int baud = 9600;
1266 int bits = 8; 1232 int bits = 8;
1267 int parity = 'n'; 1233 int parity = 'n';
1268 int flow = 'n'; 1234 int flow = 'n';
1269 1235
1270 if (co->index < 0 || co->index >= CDNS_UART_NR_PORTS)
1271 return -EINVAL;
1272
1273 if (!port->membase) { 1236 if (!port->membase) {
1274 pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n", 1237 pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n",
1275 co->index); 1238 co->index);
@@ -1293,20 +1256,6 @@ static struct console cdns_uart_console = {
1293 .index = -1, /* Specified on the cmdline (e.g. console=ttyPS ) */ 1256 .index = -1, /* Specified on the cmdline (e.g. console=ttyPS ) */
1294 .data = &cdns_uart_uart_driver, 1257 .data = &cdns_uart_uart_driver,
1295}; 1258};
1296
1297/**
1298 * cdns_uart_console_init - Initialization call
1299 *
1300 * Return: 0 on success, negative errno otherwise
1301 */
1302static int __init cdns_uart_console_init(void)
1303{
1304 register_console(&cdns_uart_console);
1305 return 0;
1306}
1307
1308console_initcall(cdns_uart_console_init);
1309
1310#endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */ 1259#endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */
1311 1260
1312static struct uart_driver cdns_uart_uart_driver = { 1261static struct uart_driver cdns_uart_uart_driver = {
@@ -1430,8 +1379,7 @@ static int cdns_uart_resume(struct device *device)
1430#endif /* ! CONFIG_PM_SLEEP */ 1379#endif /* ! CONFIG_PM_SLEEP */
1431static int __maybe_unused cdns_runtime_suspend(struct device *dev) 1380static int __maybe_unused cdns_runtime_suspend(struct device *dev)
1432{ 1381{
1433 struct platform_device *pdev = to_platform_device(dev); 1382 struct uart_port *port = dev_get_drvdata(dev);
1434 struct uart_port *port = platform_get_drvdata(pdev);
1435 struct cdns_uart *cdns_uart = port->private_data; 1383 struct cdns_uart *cdns_uart = port->private_data;
1436 1384
1437 clk_disable(cdns_uart->uartclk); 1385 clk_disable(cdns_uart->uartclk);
@@ -1441,8 +1389,7 @@ static int __maybe_unused cdns_runtime_suspend(struct device *dev)
1441 1389
1442static int __maybe_unused cdns_runtime_resume(struct device *dev) 1390static int __maybe_unused cdns_runtime_resume(struct device *dev)
1443{ 1391{
1444 struct platform_device *pdev = to_platform_device(dev); 1392 struct uart_port *port = dev_get_drvdata(dev);
1445 struct uart_port *port = platform_get_drvdata(pdev);
1446 struct cdns_uart *cdns_uart = port->private_data; 1393 struct cdns_uart *cdns_uart = port->private_data;
1447 1394
1448 clk_enable(cdns_uart->pclk); 1395 clk_enable(cdns_uart->pclk);
@@ -1487,6 +1434,9 @@ static int cdns_uart_probe(struct platform_device *pdev)
1487 GFP_KERNEL); 1434 GFP_KERNEL);
1488 if (!cdns_uart_data) 1435 if (!cdns_uart_data)
1489 return -ENOMEM; 1436 return -ENOMEM;
1437 port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
1438 if (!port)
1439 return -ENOMEM;
1490 1440
1491 match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); 1441 match = of_match_node(cdns_uart_of_match, pdev->dev.of_node);
1492 if (match && match->data) { 1442 if (match && match->data) {
@@ -1552,15 +1502,24 @@ static int cdns_uart_probe(struct platform_device *pdev)
1552 if (id < 0) 1502 if (id < 0)
1553 id = 0; 1503 id = 0;
1554 1504
1555 /* Initialize the port structure */ 1505 if (id >= CDNS_UART_NR_PORTS) {
1556 port = cdns_uart_get_port(id);
1557
1558 if (!port) {
1559 dev_err(&pdev->dev, "Cannot get uart_port structure\n"); 1506 dev_err(&pdev->dev, "Cannot get uart_port structure\n");
1560 rc = -ENODEV; 1507 rc = -ENODEV;
1561 goto err_out_notif_unreg; 1508 goto err_out_notif_unreg;
1562 } 1509 }
1563 1510
1511 /* At this point, we've got an empty uart_port struct, initialize it */
1512 spin_lock_init(&port->lock);
1513 port->membase = NULL;
1514 port->irq = 0;
1515 port->type = PORT_UNKNOWN;
1516 port->iotype = UPIO_MEM32;
1517 port->flags = UPF_BOOT_AUTOCONF;
1518 port->ops = &cdns_uart_ops;
1519 port->fifosize = CDNS_UART_FIFO_SIZE;
1520 port->line = id;
1521 port->dev = NULL;
1522
1564 /* 1523 /*
1565 * Register the port. 1524 * Register the port.
1566 * This function also registers this device with the tty layer 1525 * This function also registers this device with the tty layer
@@ -1579,6 +1538,17 @@ static int cdns_uart_probe(struct platform_device *pdev)
1579 pm_runtime_set_active(&pdev->dev); 1538 pm_runtime_set_active(&pdev->dev);
1580 pm_runtime_enable(&pdev->dev); 1539 pm_runtime_enable(&pdev->dev);
1581 1540
1541#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
1542 /*
1543 * If console hasn't been found yet try to assign this port
1544 * because it is required to be assigned for console setup function.
1545 * If register_console() don't assign value, then console_port pointer
1546 * is cleanup.
1547 */
1548 if (cdns_uart_uart_driver.cons->index == -1)
1549 console_port = port;
1550#endif
1551
1582 rc = uart_add_one_port(&cdns_uart_uart_driver, port); 1552 rc = uart_add_one_port(&cdns_uart_uart_driver, port);
1583 if (rc) { 1553 if (rc) {
1584 dev_err(&pdev->dev, 1554 dev_err(&pdev->dev,
@@ -1586,6 +1556,12 @@ static int cdns_uart_probe(struct platform_device *pdev)
1586 goto err_out_pm_disable; 1556 goto err_out_pm_disable;
1587 } 1557 }
1588 1558
1559#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
1560 /* This is not port which is used for console that's why clean it up */
1561 if (cdns_uart_uart_driver.cons->index == -1)
1562 console_port = NULL;
1563#endif
1564
1589 return 0; 1565 return 0;
1590 1566
1591err_out_pm_disable: 1567err_out_pm_disable:
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f97251f39c26..1eb1a376a041 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1178,15 +1178,8 @@ static void csi_J(struct vc_data *vc, int vpar)
1178 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; 1178 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
1179 start = (unsigned short *)vc->vc_origin; 1179 start = (unsigned short *)vc->vc_origin;
1180 break; 1180 break;
1181 case 3: /* erase scroll-back buffer (and whole display) */
1182 scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
1183 vc->vc_screenbuf_size);
1184 flush_scrollback(vc);
1185 set_origin(vc);
1186 if (con_is_visible(vc))
1187 update_screen(vc);
1188 /* fall through */
1189 case 2: /* erase whole display */ 1181 case 2: /* erase whole display */
1182 case 3: /* (and scrollback buffer later) */
1190 count = vc->vc_cols * vc->vc_rows; 1183 count = vc->vc_cols * vc->vc_rows;
1191 start = (unsigned short *)vc->vc_origin; 1184 start = (unsigned short *)vc->vc_origin;
1192 break; 1185 break;
@@ -1194,7 +1187,12 @@ static void csi_J(struct vc_data *vc, int vpar)
1194 return; 1187 return;
1195 } 1188 }
1196 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); 1189 scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1197 if (con_should_update(vc)) 1190 if (vpar == 3) {
1191 set_origin(vc);
1192 flush_scrollback(vc);
1193 if (con_is_visible(vc))
1194 update_screen(vc);
1195 } else if (con_should_update(vc))
1198 do_update_region(vc, (unsigned long) start, count); 1196 do_update_region(vc, (unsigned long) start, count);
1199 vc->vc_need_wrap = 0; 1197 vc->vc_need_wrap = 0;
1200} 1198}
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index a27ef5f56431..76b9db71e489 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -163,6 +163,7 @@ extern void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
163extern int fsl8250_handle_irq(struct uart_port *port); 163extern int fsl8250_handle_irq(struct uart_port *port);
164int serial8250_handle_irq(struct uart_port *port, unsigned int iir); 164int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
165unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr); 165unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr);
166void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr);
166void serial8250_tx_chars(struct uart_8250_port *up); 167void serial8250_tx_chars(struct uart_8250_port *up);
167unsigned int serial8250_modem_status(struct uart_8250_port *up); 168unsigned int serial8250_modem_status(struct uart_8250_port *up);
168void serial8250_init_port(struct uart_8250_port *up); 169void serial8250_init_port(struct uart_8250_port *up);
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index b4c9fda9d833..06ea4eeb09ab 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -233,6 +233,7 @@ struct uart_port {
233#define UPSTAT_AUTORTS ((__force upstat_t) (1 << 2)) 233#define UPSTAT_AUTORTS ((__force upstat_t) (1 << 2))
234#define UPSTAT_AUTOCTS ((__force upstat_t) (1 << 3)) 234#define UPSTAT_AUTOCTS ((__force upstat_t) (1 << 3))
235#define UPSTAT_AUTOXOFF ((__force upstat_t) (1 << 4)) 235#define UPSTAT_AUTOXOFF ((__force upstat_t) (1 << 4))
236#define UPSTAT_SYNC_FIFO ((__force upstat_t) (1 << 5))
236 237
237 int hw_stopped; /* sw-assisted CTS flow state */ 238 int hw_stopped; /* sw-assisted CTS flow state */
238 unsigned int mctrl; /* current modem ctrl settings */ 239 unsigned int mctrl; /* current modem ctrl settings */
@@ -348,7 +349,8 @@ struct earlycon_device {
348}; 349};
349 350
350struct earlycon_id { 351struct earlycon_id {
351 char name[16]; 352 char name[15];
353 char name_term; /* In case compiler didn't '\0' term name */
352 char compatible[128]; 354 char compatible[128];
353 int (*setup)(struct earlycon_device *, const char *options); 355 int (*setup)(struct earlycon_device *, const char *options);
354}; 356};
diff --git a/include/uapi/linux/tty_flags.h b/include/uapi/linux/tty_flags.h
index 6ac609a00dea..900a32e63424 100644
--- a/include/uapi/linux/tty_flags.h
+++ b/include/uapi/linux/tty_flags.h
@@ -13,7 +13,7 @@
13 */ 13 */
14#define ASYNCB_HUP_NOTIFY 0 /* Notify getty on hangups and closes 14#define ASYNCB_HUP_NOTIFY 0 /* Notify getty on hangups and closes
15 * on the callout port */ 15 * on the callout port */
16#define ASYNCB_FOURPORT 1 /* Set OU1, OUT2 per AST Fourport settings */ 16#define ASYNCB_FOURPORT 1 /* Set OUT1, OUT2 per AST Fourport settings */
17#define ASYNCB_SAK 2 /* Secure Attention Key (Orange book) */ 17#define ASYNCB_SAK 2 /* Secure Attention Key (Orange book) */
18#define ASYNCB_SPLIT_TERMIOS 3 /* [x] Separate termios for dialin/callout */ 18#define ASYNCB_SPLIT_TERMIOS 3 /* [x] Separate termios for dialin/callout */
19#define ASYNCB_SPD_HI 4 /* Use 57600 instead of 38400 bps */ 19#define ASYNCB_SPD_HI 4 /* Use 57600 instead of 38400 bps */