aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-14 00:05:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-14 00:05:31 -0500
commitfb0255fb2941ef6f21742b2bc146d6b9aef4fedc (patch)
tree8334f3485152b1c887ddfe04ba9a95c8a704481c /drivers/tty/serial
parent449fcf3ab0baf3dde9952385e6789f2ca10c3980 (diff)
parent57f5d648c45c3d40a3257c06629c14fd53c383bc (diff)
Merge tag 'tty-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial updates from Greg KH: "Here is the big tty/serial driver pull request for 4.15-rc1. Lots of serial driver updates in here, some small vt cleanups, and a raft of SPDX and license boilerplate cleanups, messing up the diffstat a bit. Nothing major, with no realy functional changes except better hardware support for some platforms. All of these have been in linux-next for a while with no reported issues" * tag 'tty-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (110 commits) tty: ehv_bytechan: fix spelling mistake tty: serial: meson: allow baud-rates lower than 9600 serial: 8250_fintek: Fix crash with baud rate B0 serial: 8250_fintek: Disable delays for ports != 0 serial: 8250_fintek: Return -EINVAL on invalid configuration tty: Remove redundant license text tty: serdev: Remove redundant license text tty: hvc: Remove redundant license text tty: serial: Remove redundant license text tty: add SPDX identifiers to all remaining files in drivers/tty/ tty: serial: jsm: remove redundant pointer ts tty: serial: jsm: add space before the open parenthesis '(' tty: serial: jsm: fix coding style tty: serial: jsm: delete space between function name and '(' tty: serial: jsm: add blank line after declarations tty: serial: jsm: change the type of local variable tty: serial: imx: remove dead code imx_dma_rxint tty: serial: imx: disable ageing timer interrupt if dma in use serial: 8250: fix potential deadlock in rs485-mode serial: m32r_sio: Drop redundant .data assignment ...
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/21285.c1
-rw-r--r--drivers/tty/serial/8250/8250.h6
-rw-r--r--drivers/tty/serial/8250/8250_accent.c5
-rw-r--r--drivers/tty/serial/8250/8250_acorn.c5
-rw-r--r--drivers/tty/serial/8250/8250_aspeed_vuart.c6
-rw-r--r--drivers/tty/serial/8250/8250_bcm2835aux.c6
-rw-r--r--drivers/tty/serial/8250/8250_boca.c5
-rw-r--r--drivers/tty/serial/8250/8250_core.c23
-rw-r--r--drivers/tty/serial/8250/8250_dma.c6
-rw-r--r--drivers/tty/serial/8250/8250_dw.c36
-rw-r--r--drivers/tty/serial/8250/8250_early.c5
-rw-r--r--drivers/tty/serial/8250/8250_em.c14
-rw-r--r--drivers/tty/serial/8250/8250_exar.c5
-rw-r--r--drivers/tty/serial/8250/8250_exar_st16c554.c5
-rw-r--r--drivers/tty/serial/8250/8250_fintek.c123
-rw-r--r--drivers/tty/serial/8250/8250_fourport.c5
-rw-r--r--drivers/tty/serial/8250/8250_fsl.c5
-rw-r--r--drivers/tty/serial/8250/8250_gsc.c6
-rw-r--r--drivers/tty/serial/8250/8250_hp300.c1
-rw-r--r--drivers/tty/serial/8250/8250_hub6.c5
-rw-r--r--drivers/tty/serial/8250/8250_ingenic.c10
-rw-r--r--drivers/tty/serial/8250/8250_lpc18xx.c6
-rw-r--r--drivers/tty/serial/8250/8250_lpss.c5
-rw-r--r--drivers/tty/serial/8250/8250_mid.c11
-rw-r--r--drivers/tty/serial/8250/8250_moxa.c5
-rw-r--r--drivers/tty/serial/8250/8250_mtk.c13
-rw-r--r--drivers/tty/serial/8250/8250_of.c7
-rw-r--r--drivers/tty/serial/8250/8250_omap.c5
-rw-r--r--drivers/tty/serial/8250/8250_pci.c6
-rw-r--r--drivers/tty/serial/8250/8250_pnp.c5
-rw-r--r--drivers/tty/serial/8250/8250_port.c16
-rw-r--r--drivers/tty/serial/8250/8250_pxa.c7
-rw-r--r--drivers/tty/serial/8250/8250_uniphier.c11
-rw-r--r--drivers/tty/serial/8250/serial_cs.c1
-rw-r--r--drivers/tty/serial/altera_jtaguart.c6
-rw-r--r--drivers/tty/serial/altera_uart.c14
-rw-r--r--drivers/tty/serial/amba-pl010.c15
-rw-r--r--drivers/tty/serial/amba-pl011.c32
-rw-r--r--drivers/tty/serial/apbuart.c1
-rw-r--r--drivers/tty/serial/ar933x_uart.c5
-rw-r--r--drivers/tty/serial/arc_uart.c5
-rw-r--r--drivers/tty/serial/atmel_serial.c65
-rw-r--r--drivers/tty/serial/atmel_serial.h6
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c5
-rw-r--r--drivers/tty/serial/bfin_sport_uart.c5
-rw-r--r--drivers/tty/serial/bfin_sport_uart.h3
-rw-r--r--drivers/tty/serial/bfin_uart.c10
-rw-r--r--drivers/tty/serial/clps711x.c6
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart.h6
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c16
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c16
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c16
-rw-r--r--drivers/tty/serial/digicolor-usart.c6
-rw-r--r--drivers/tty/serial/dz.c1
-rw-r--r--drivers/tty/serial/earlycon-arm-semihost.c13
-rw-r--r--drivers/tty/serial/earlycon.c5
-rw-r--r--drivers/tty/serial/efm32-uart.c1
-rw-r--r--drivers/tty/serial/fsl_lpuart.c33
-rw-r--r--drivers/tty/serial/icom.c16
-rw-r--r--drivers/tty/serial/icom.h15
-rw-r--r--drivers/tty/serial/ifx6x60.c20
-rw-r--r--drivers/tty/serial/ifx6x60.h18
-rw-r--r--drivers/tty/serial/imx.c103
-rw-r--r--drivers/tty/serial/ioc3_serial.c5
-rw-r--r--drivers/tty/serial/ioc4_serial.c5
-rw-r--r--drivers/tty/serial/ip22zilog.c1
-rw-r--r--drivers/tty/serial/jsm/jsm.h11
-rw-r--r--drivers/tty/serial/jsm/jsm_cls.c11
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c11
-rw-r--r--drivers/tty/serial/jsm/jsm_neo.c11
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c27
-rw-r--r--drivers/tty/serial/kgdb_nmi.c5
-rw-r--r--drivers/tty/serial/kgdboc.c5
-rw-r--r--drivers/tty/serial/lantiq.c14
-rw-r--r--drivers/tty/serial/lpc32xx_hs.c11
-rw-r--r--drivers/tty/serial/m32r_sio.c14
-rw-r--r--drivers/tty/serial/m32r_sio_reg.h4
-rw-r--r--drivers/tty/serial/max3100.c16
-rw-r--r--drivers/tty/serial/max310x.c6
-rw-r--r--drivers/tty/serial/mcf.c6
-rw-r--r--drivers/tty/serial/men_z135_uart.c5
-rw-r--r--drivers/tty/serial/meson_uart.c31
-rw-r--r--drivers/tty/serial/mpc52xx_uart.c5
-rw-r--r--drivers/tty/serial/mps2-uart.c5
-rw-r--r--drivers/tty/serial/mpsc.c6
-rw-r--r--drivers/tty/serial/msm_serial.c10
-rw-r--r--drivers/tty/serial/mux.c9
-rw-r--r--drivers/tty/serial/mvebu-uart.c495
-rw-r--r--drivers/tty/serial/mxs-auart.c5
-rw-r--r--drivers/tty/serial/netx-serial.c14
-rw-r--r--drivers/tty/serial/omap-serial.c23
-rw-r--r--drivers/tty/serial/owl-uart.c14
-rw-r--r--drivers/tty/serial/pch_uart.c14
-rw-r--r--drivers/tty/serial/pic32_uart.c3
-rw-r--r--drivers/tty/serial/pic32_uart.h3
-rw-r--r--drivers/tty/serial/pmac_zilog.c15
-rw-r--r--drivers/tty/serial/pnx8xxx_uart.c11
-rw-r--r--drivers/tty/serial/pxa.c6
-rw-r--r--drivers/tty/serial/rp2.c5
-rw-r--r--drivers/tty/serial/sa1100.c20
-rw-r--r--drivers/tty/serial/samsung.c5
-rw-r--r--drivers/tty/serial/samsung.h5
-rw-r--r--drivers/tty/serial/sb1250-duart.c6
-rw-r--r--drivers/tty/serial/sc16is7xx.c7
-rw-r--r--drivers/tty/serial/sccnxp.c13
-rw-r--r--drivers/tty/serial/serial-tegra.c13
-rw-r--r--drivers/tty/serial/serial_core.c54
-rw-r--r--drivers/tty/serial/serial_ks8695.c7
-rw-r--r--drivers/tty/serial/serial_mctrl_gpio.c11
-rw-r--r--drivers/tty/serial/serial_mctrl_gpio.h12
-rw-r--r--drivers/tty/serial/serial_txx9.c5
-rw-r--r--drivers/tty/serial/sh-sci.c103
-rw-r--r--drivers/tty/serial/sh-sci.h3
-rw-r--r--drivers/tty/serial/sirfsoc_uart.c3
-rw-r--r--drivers/tty/serial/sirfsoc_uart.h3
-rw-r--r--drivers/tty/serial/sn_console.c23
-rw-r--r--drivers/tty/serial/sprd_serial.c10
-rw-r--r--drivers/tty/serial/st-asc.c7
-rw-r--r--drivers/tty/serial/stm32-usart.c5
-rw-r--r--drivers/tty/serial/stm32-usart.h2
-rw-r--r--drivers/tty/serial/suncore.c1
-rw-r--r--drivers/tty/serial/sunhv.c1
-rw-r--r--drivers/tty/serial/sunsab.c1
-rw-r--r--drivers/tty/serial/sunsu.c1
-rw-r--r--drivers/tty/serial/sunzilog.c1
-rw-r--r--drivers/tty/serial/tilegx.c11
-rw-r--r--drivers/tty/serial/timbuart.c14
-rw-r--r--drivers/tty/serial/timbuart.h14
-rw-r--r--drivers/tty/serial/uartlite.c7
-rw-r--r--drivers/tty/serial/ucc_uart.c6
-rw-r--r--drivers/tty/serial/vr41xx_siu.c15
-rw-r--r--drivers/tty/serial/vt8500_serial.c10
-rw-r--r--drivers/tty/serial/xilinx_uartps.c9
-rw-r--r--drivers/tty/serial/zs.c1
134 files changed, 921 insertions, 1174 deletions
diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c
index 804632b4a929..32b3acf8150a 100644
--- a/drivers/tty/serial/21285.c
+++ b/drivers/tty/serial/21285.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the serial port on the 21285 StrongArm-110 core logic chip. 3 * Driver for the serial port on the 21285 StrongArm-110 core logic chip.
3 * 4 *
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index b2bdc35f7495..ebfb0bd5bef5 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for 8250/16550-type serial ports 3 * Driver for 8250/16550-type serial ports
3 * 4 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 5 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 * 6 *
6 * Copyright (C) 2001 Russell King. 7 * Copyright (C) 2001 Russell King.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#include <linux/serial_8250.h> 10#include <linux/serial_8250.h>
diff --git a/drivers/tty/serial/8250/8250_accent.c b/drivers/tty/serial/8250/8250_accent.c
index 522aeae05192..1691f1a57f89 100644
--- a/drivers/tty/serial/8250/8250_accent.c
+++ b/drivers/tty/serial/8250/8250_accent.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005 Russell King. 3 * Copyright (C) 2005 Russell King.
3 * Data taken from include/asm-i386/serial.h 4 * Data taken from include/asm-i386/serial.h
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */ 5 */
9#include <linux/module.h> 6#include <linux/module.h>
10#include <linux/init.h> 7#include <linux/init.h>
diff --git a/drivers/tty/serial/8250/8250_acorn.c b/drivers/tty/serial/8250/8250_acorn.c
index 402dfdd4940e..758c4aa203ab 100644
--- a/drivers/tty/serial/8250/8250_acorn.c
+++ b/drivers/tty/serial/8250/8250_acorn.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/drivers/serial/acorn.c 3 * linux/drivers/serial/acorn.c
3 * 4 *
4 * Copyright (C) 1996-2003 Russell King. 5 * Copyright (C) 1996-2003 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10#include <linux/module.h> 7#include <linux/module.h>
11#include <linux/types.h> 8#include <linux/types.h>
diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index 33a801353114..74a408d9db24 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Serial Port driver for Aspeed VUART device 3 * Serial Port driver for Aspeed VUART device
3 * 4 *
4 * Copyright (C) 2016 Jeremy Kerr <jk@ozlabs.org>, IBM Corp. 5 * Copyright (C) 2016 Jeremy Kerr <jk@ozlabs.org>, IBM Corp.
5 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp. 6 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */ 7 */
12#include <linux/device.h> 8#include <linux/device.h>
13#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index a23c7da42ea8..bd53661103eb 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Serial port driver for BCM2835AUX UART 3 * Serial port driver for BCM2835AUX UART
3 * 4 *
@@ -5,11 +6,6 @@
5 * 6 *
6 * Based on 8250_lpc18xx.c: 7 * Based on 8250_lpc18xx.c:
7 * Copyright (C) 2015 Joachim Eastwood <manabian@gmail.com> 8 * Copyright (C) 2015 Joachim Eastwood <manabian@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */ 9 */
14 10
15#include <linux/clk.h> 11#include <linux/clk.h>
diff --git a/drivers/tty/serial/8250/8250_boca.c b/drivers/tty/serial/8250/8250_boca.c
index a63b5998e383..a9b97c034653 100644
--- a/drivers/tty/serial/8250/8250_boca.c
+++ b/drivers/tty/serial/8250/8250_boca.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005 Russell King. 3 * Copyright (C) 2005 Russell King.
3 * Data taken from include/asm-i386/serial.h 4 * Data taken from include/asm-i386/serial.h
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */ 5 */
9#include <linux/module.h> 6#include <linux/module.h>
10#include <linux/init.h> 7#include <linux/init.h>
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index d29b512a7d9f..d64afdd93872 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Universal/legacy driver for 8250/16550-type serial ports 3 * Universal/legacy driver for 8250/16550-type serial ports
3 * 4 *
@@ -11,11 +12,6 @@
11 * userspace-configurable "phantom" ports 12 * userspace-configurable "phantom" ports
12 * "serial8250" platform devices 13 * "serial8250" platform devices
13 * serial8250_register_8250_port() ports 14 * serial8250_register_8250_port() ports
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 */ 15 */
20 16
21#include <linux/module.h> 17#include <linux/module.h>
@@ -262,17 +258,17 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up)
262 * barely passable results for a 16550A. (Although at the expense 258 * barely passable results for a 16550A. (Although at the expense
263 * of much CPU overhead). 259 * of much CPU overhead).
264 */ 260 */
265static void serial8250_timeout(unsigned long data) 261static void serial8250_timeout(struct timer_list *t)
266{ 262{
267 struct uart_8250_port *up = (struct uart_8250_port *)data; 263 struct uart_8250_port *up = from_timer(up, t, timer);
268 264
269 up->port.handle_irq(&up->port); 265 up->port.handle_irq(&up->port);
270 mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port)); 266 mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port));
271} 267}
272 268
273static void serial8250_backup_timeout(unsigned long data) 269static void serial8250_backup_timeout(struct timer_list *t)
274{ 270{
275 struct uart_8250_port *up = (struct uart_8250_port *)data; 271 struct uart_8250_port *up = from_timer(up, t, timer);
276 unsigned int iir, ier = 0, lsr; 272 unsigned int iir, ier = 0, lsr;
277 unsigned long flags; 273 unsigned long flags;
278 274
@@ -329,8 +325,7 @@ static int univ8250_setup_irq(struct uart_8250_port *up)
329 if (up->bugs & UART_BUG_THRE) { 325 if (up->bugs & UART_BUG_THRE) {
330 pr_debug("ttyS%d - using backup timer\n", serial_index(port)); 326 pr_debug("ttyS%d - using backup timer\n", serial_index(port));
331 327
332 up->timer.function = serial8250_backup_timeout; 328 up->timer.function = (TIMER_FUNC_TYPE)serial8250_backup_timeout;
333 up->timer.data = (unsigned long)up;
334 mod_timer(&up->timer, jiffies + 329 mod_timer(&up->timer, jiffies +
335 uart_poll_timeout(port) + HZ / 5); 330 uart_poll_timeout(port) + HZ / 5);
336 } 331 }
@@ -341,7 +336,6 @@ static int univ8250_setup_irq(struct uart_8250_port *up)
341 * driver used to do this with IRQ0. 336 * driver used to do this with IRQ0.
342 */ 337 */
343 if (!port->irq) { 338 if (!port->irq) {
344 up->timer.data = (unsigned long)up;
345 mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); 339 mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
346 } else 340 } else
347 retval = serial_link_irq_chain(up); 341 retval = serial_link_irq_chain(up);
@@ -354,7 +348,7 @@ static void univ8250_release_irq(struct uart_8250_port *up)
354 struct uart_port *port = &up->port; 348 struct uart_port *port = &up->port;
355 349
356 del_timer_sync(&up->timer); 350 del_timer_sync(&up->timer);
357 up->timer.function = serial8250_timeout; 351 up->timer.function = (TIMER_FUNC_TYPE)serial8250_timeout;
358 if (port->irq) 352 if (port->irq)
359 serial_unlink_irq_chain(up); 353 serial_unlink_irq_chain(up);
360} 354}
@@ -525,8 +519,7 @@ static void __init serial8250_isa_init_ports(void)
525 base_ops = port->ops; 519 base_ops = port->ops;
526 port->ops = &univ8250_port_ops; 520 port->ops = &univ8250_port_ops;
527 521
528 init_timer(&up->timer); 522 timer_setup(&up->timer, serial8250_timeout, 0);
529 up->timer.function = serial8250_timeout;
530 523
531 up->ops = &univ8250_driver_ops; 524 up->ops = &univ8250_driver_ops;
532 525
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 26f17456b0d7..bfa1a857f3ff 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * 8250_dma.c - DMA Engine API support for 8250.c 3 * 8250_dma.c - DMA Engine API support for 8250.c
3 * 4 *
4 * Copyright (C) 2013 Intel Corporation 5 * Copyright (C) 2013 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11#include <linux/tty.h> 7#include <linux/tty.h>
12#include <linux/tty_flip.h> 8#include <linux/tty_flip.h>
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 7e638997bfc2..5bb0c42c88dd 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Synopsys DesignWare 8250 driver. 3 * Synopsys DesignWare 8250 driver.
3 * 4 *
4 * Copyright 2011 Picochip, Jamie Iles. 5 * Copyright 2011 Picochip, Jamie Iles.
5 * Copyright 2013 Intel Corporation 6 * Copyright 2013 Intel Corporation
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * The Synopsys DesignWare 8250 has an extra feature whereby it detects if the 8 * The Synopsys DesignWare 8250 has an extra feature whereby it detects if the
13 * LCR is written whilst busy. If it is, then a busy detect interrupt is 9 * LCR is written whilst busy. If it is, then a busy detect interrupt is
14 * raised, the LCR needs to be rewritten and the uart status register read. 10 * raised, the LCR needs to be rewritten and the uart status register read.
@@ -256,25 +252,31 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
256 struct ktermios *old) 252 struct ktermios *old)
257{ 253{
258 unsigned int baud = tty_termios_baud_rate(termios); 254 unsigned int baud = tty_termios_baud_rate(termios);
255 unsigned int target_rate, min_rate, max_rate;
259 struct dw8250_data *d = p->private_data; 256 struct dw8250_data *d = p->private_data;
260 long rate; 257 long rate;
261 int ret; 258 int i, ret;
262 259
263 if (IS_ERR(d->clk) || !old) 260 if (IS_ERR(d->clk) || !old)
264 goto out; 261 goto out;
265 262
266 clk_disable_unprepare(d->clk); 263 /* Find a clk rate within +/-1.6% of an integer multiple of baudx16 */
267 rate = clk_round_rate(d->clk, baud * 16); 264 target_rate = baud * 16;
268 if (rate < 0) 265 min_rate = target_rate - (target_rate >> 6);
269 ret = rate; 266 max_rate = target_rate + (target_rate >> 6);
270 else if (rate == 0)
271 ret = -ENOENT;
272 else
273 ret = clk_set_rate(d->clk, rate);
274 clk_prepare_enable(d->clk);
275 267
276 if (!ret) 268 for (i = 1; i <= UART_DIV_MAX; i++) {
277 p->uartclk = rate; 269 rate = clk_round_rate(d->clk, i * target_rate);
270 if (rate >= i * min_rate && rate <= i * max_rate)
271 break;
272 }
273 if (i <= UART_DIV_MAX) {
274 clk_disable_unprepare(d->clk);
275 ret = clk_set_rate(d->clk, rate);
276 clk_prepare_enable(d->clk);
277 if (!ret)
278 p->uartclk = rate;
279 }
278 280
279out: 281out:
280 p->status &= ~UPSTAT_AUTOCTS; 282 p->status &= ~UPSTAT_AUTOCTS;
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index af72ec32e404..362c25ff188a 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Early serial console for 8250/16550 devices 3 * Early serial console for 8250/16550 devices
3 * 4 *
4 * (c) Copyright 2004 Hewlett-Packard Development Company, L.P. 5 * (c) Copyright 2004 Hewlett-Packard Development Company, L.P.
5 * Bjorn Helgaas <bjorn.helgaas@hp.com> 6 * Bjorn Helgaas <bjorn.helgaas@hp.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Based on the 8250.c serial driver, Copyright (C) 2001 Russell King, 8 * Based on the 8250.c serial driver, Copyright (C) 2001 Russell King,
12 * and on early_printk.c by Andi Kleen. 9 * and on early_printk.c by Andi Kleen.
13 * 10 *
diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c
index 0b6381214917..f6a86f2bc4e5 100644
--- a/drivers/tty/serial/8250/8250_em.c
+++ b/drivers/tty/serial/8250/8250_em.c
@@ -1,20 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Renesas Emma Mobile 8250 driver 3 * Renesas Emma Mobile 8250 driver
3 * 4 *
4 * Copyright (C) 2012 Magnus Damm 5 * Copyright (C) 2012 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 6 */
19 7
20#include <linux/device.h> 8#include <linux/device.h>
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index c55624703fdf..a402878c9f30 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Probe module for 8250/16550-type Exar chips PCI serial ports. 3 * Probe module for 8250/16550-type Exar chips PCI serial ports.
3 * 4 *
4 * Based on drivers/tty/serial/8250/8250_pci.c, 5 * Based on drivers/tty/serial/8250/8250_pci.c,
5 * 6 *
6 * Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved. 7 * Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License.
11 */ 8 */
12#include <linux/acpi.h> 9#include <linux/acpi.h>
13#include <linux/dmi.h> 10#include <linux/dmi.h>
diff --git a/drivers/tty/serial/8250/8250_exar_st16c554.c b/drivers/tty/serial/8250/8250_exar_st16c554.c
index 3a7cb8262bb9..933811ebfaac 100644
--- a/drivers/tty/serial/8250/8250_exar_st16c554.c
+++ b/drivers/tty/serial/8250/8250_exar_st16c554.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Written by Paul B Schroeder < pschroeder "at" uplogix "dot" com > 3 * Written by Paul B Schroeder < pschroeder "at" uplogix "dot" com >
3 * Based on 8250_boca. 4 * Based on 8250_boca.
4 * 5 *
5 * Copyright (C) 2005 Russell King. 6 * Copyright (C) 2005 Russell King.
6 * Data taken from include/asm-i386/serial.h 7 * Data taken from include/asm-i386/serial.h
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12#include <linux/module.h> 9#include <linux/module.h>
13#include <linux/init.h> 10#include <linux/init.h>
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index e500f7dd2470..79a4958b3f5c 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Probe for F81216A LPC to 4 UART 3 * Probe for F81216A LPC to 4 UART
3 * 4 *
4 * Copyright (C) 2014-2016 Ricardo Ribalda, Qtechnology A/S 5 * Copyright (C) 2014-2016 Ricardo Ribalda, Qtechnology A/S
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License.
10 */ 6 */
11#include <linux/module.h> 7#include <linux/module.h>
12#include <linux/pci.h> 8#include <linux/pci.h>
@@ -40,6 +36,16 @@
40#define IRQ_LEVEL_LOW 0 36#define IRQ_LEVEL_LOW 0
41#define IRQ_EDGE_HIGH BIT(5) 37#define IRQ_EDGE_HIGH BIT(5)
42 38
39/*
40 * F81216H clock source register, the value and mask is the same with F81866,
41 * but it's on F0h.
42 *
43 * Clock speeds for UART (register F0h)
44 * 00: 1.8432MHz.
45 * 01: 18.432MHz.
46 * 10: 24MHz.
47 * 11: 14.769MHz.
48 */
43#define RS485 0xF0 49#define RS485 0xF0
44#define RTS_INVERT BIT(5) 50#define RTS_INVERT BIT(5)
45#define RS485_URA BIT(4) 51#define RS485_URA BIT(4)
@@ -118,6 +124,9 @@ static int fintek_8250_enter_key(u16 base_port, u8 key)
118 if (!request_muxed_region(base_port, 2, "8250_fintek")) 124 if (!request_muxed_region(base_port, 2, "8250_fintek"))
119 return -EBUSY; 125 return -EBUSY;
120 126
127 /* Force to deactive all SuperIO in this base_port */
128 outb(EXIT_KEY, base_port + ADDR_PORT);
129
121 outb(key, base_port + ADDR_PORT); 130 outb(key, base_port + ADDR_PORT);
122 outb(key, base_port + ADDR_PORT); 131 outb(key, base_port + ADDR_PORT);
123 return 0; 132 return 0;
@@ -188,14 +197,27 @@ static int fintek_8250_rs485_config(struct uart_port *port,
188 if (!pdata) 197 if (!pdata)
189 return -EINVAL; 198 return -EINVAL;
190 199
191 if (rs485->flags & SER_RS485_ENABLED) 200 /* Hardware do not support same RTS level on send and receive */
201 if (!(rs485->flags & SER_RS485_RTS_ON_SEND) ==
202 !(rs485->flags & SER_RS485_RTS_AFTER_SEND))
203 return -EINVAL;
204
205 if (rs485->flags & SER_RS485_ENABLED) {
192 memset(rs485->padding, 0, sizeof(rs485->padding)); 206 memset(rs485->padding, 0, sizeof(rs485->padding));
193 else 207 config |= RS485_URA;
208 } else {
194 memset(rs485, 0, sizeof(*rs485)); 209 memset(rs485, 0, sizeof(*rs485));
210 }
195 211
196 rs485->flags &= SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | 212 rs485->flags &= SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND |
197 SER_RS485_RTS_AFTER_SEND; 213 SER_RS485_RTS_AFTER_SEND;
198 214
215 /* Only the first port supports delays */
216 if (pdata->index) {
217 rs485->delay_rts_before_send = 0;
218 rs485->delay_rts_after_send = 0;
219 }
220
199 if (rs485->delay_rts_before_send) { 221 if (rs485->delay_rts_before_send) {
200 rs485->delay_rts_before_send = 1; 222 rs485->delay_rts_before_send = 1;
201 config |= TXW4C_IRA; 223 config |= TXW4C_IRA;
@@ -206,12 +228,6 @@ static int fintek_8250_rs485_config(struct uart_port *port,
206 config |= RXW4C_IRA; 228 config |= RXW4C_IRA;
207 } 229 }
208 230
209 if ((!!(rs485->flags & SER_RS485_RTS_ON_SEND)) ==
210 (!!(rs485->flags & SER_RS485_RTS_AFTER_SEND)))
211 rs485->flags &= SER_RS485_ENABLED;
212 else
213 config |= RS485_URA;
214
215 if (rs485->flags & SER_RS485_RTS_ON_SEND) 231 if (rs485->flags & SER_RS485_RTS_ON_SEND)
216 config |= RTS_INVERT; 232 config |= RTS_INVERT;
217 233
@@ -280,13 +296,91 @@ static void fintek_8250_goto_highspeed(struct uart_8250_port *uart,
280 F81866_UART_CLK_MASK, 296 F81866_UART_CLK_MASK,
281 F81866_UART_CLK_14_769MHZ); 297 F81866_UART_CLK_14_769MHZ);
282 298
283 uart->port.uartclk = 921600 * 16; 299 uart->port.uartclk = 921600 * 16;
284 break; 300 break;
285 default: /* leave clock speed untouched */ 301 default: /* leave clock speed untouched */
286 break; 302 break;
287 } 303 }
288} 304}
289 305
306void fintek_8250_set_termios(struct uart_port *port, struct ktermios *termios,
307 struct ktermios *old)
308{
309 struct fintek_8250 *pdata = port->private_data;
310 unsigned int baud = tty_termios_baud_rate(termios);
311 int i;
312 u8 reg;
313 static u32 baudrate_table[] = {115200, 921600, 1152000, 1500000};
314 static u8 clock_table[] = { F81866_UART_CLK_1_8432MHZ,
315 F81866_UART_CLK_14_769MHZ, F81866_UART_CLK_18_432MHZ,
316 F81866_UART_CLK_24MHZ };
317
318 /*
319 * We'll use serial8250_do_set_termios() for baud = 0, otherwise It'll
320 * crash on baudrate_table[i] % baud with "division by zero".
321 */
322 if (!baud)
323 goto exit;
324
325 switch (pdata->pid) {
326 case CHIP_ID_F81216H:
327 reg = RS485;
328 break;
329 case CHIP_ID_F81866:
330 reg = F81866_UART_CLK;
331 break;
332 default:
333 /* Don't change clocksource with unknown PID */
334 dev_warn(port->dev,
335 "%s: pid: %x Not support. use default set_termios.\n",
336 __func__, pdata->pid);
337 goto exit;
338 }
339
340 for (i = 0; i < ARRAY_SIZE(baudrate_table); ++i) {
341 if (baud > baudrate_table[i] || baudrate_table[i] % baud != 0)
342 continue;
343
344 if (port->uartclk == baudrate_table[i] * 16)
345 break;
346
347 if (fintek_8250_enter_key(pdata->base_port, pdata->key))
348 continue;
349
350 port->uartclk = baudrate_table[i] * 16;
351
352 sio_write_reg(pdata, LDN, pdata->index);
353 sio_write_mask_reg(pdata, reg, F81866_UART_CLK_MASK,
354 clock_table[i]);
355
356 fintek_8250_exit_key(pdata->base_port);
357 break;
358 }
359
360 if (i == ARRAY_SIZE(baudrate_table)) {
361 baud = tty_termios_baud_rate(old);
362 tty_termios_encode_baud_rate(termios, baud, baud);
363 }
364
365exit:
366 serial8250_do_set_termios(port, termios, old);
367}
368
369static void fintek_8250_set_termios_handler(struct uart_8250_port *uart)
370{
371 struct fintek_8250 *pdata = uart->port.private_data;
372
373 switch (pdata->pid) {
374 case CHIP_ID_F81216H:
375 case CHIP_ID_F81866:
376 uart->port.set_termios = fintek_8250_set_termios;
377 break;
378
379 default:
380 break;
381 }
382}
383
290static int probe_setup_port(struct fintek_8250 *pdata, 384static int probe_setup_port(struct fintek_8250 *pdata,
291 struct uart_8250_port *uart) 385 struct uart_8250_port *uart)
292{ 386{
@@ -373,6 +467,7 @@ int fintek_8250_probe(struct uart_8250_port *uart)
373 memcpy(pdata, &probe_data, sizeof(probe_data)); 467 memcpy(pdata, &probe_data, sizeof(probe_data));
374 uart->port.private_data = pdata; 468 uart->port.private_data = pdata;
375 fintek_8250_set_rs485_handler(uart); 469 fintek_8250_set_rs485_handler(uart);
470 fintek_8250_set_termios_handler(uart);
376 471
377 return 0; 472 return 0;
378} 473}
diff --git a/drivers/tty/serial/8250/8250_fourport.c b/drivers/tty/serial/8250/8250_fourport.c
index 4045180a8cfc..3215b9b7afde 100644
--- a/drivers/tty/serial/8250/8250_fourport.c
+++ b/drivers/tty/serial/8250/8250_fourport.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005 Russell King. 3 * Copyright (C) 2005 Russell King.
3 * Data taken from include/asm-i386/serial.h 4 * Data taken from include/asm-i386/serial.h
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */ 5 */
9#include <linux/module.h> 6#include <linux/module.h>
10#include <linux/init.h> 7#include <linux/init.h>
diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
index 910bfee5a88b..6640a4c7ddd1 100644
--- a/drivers/tty/serial/8250/8250_fsl.c
+++ b/drivers/tty/serial/8250/8250_fsl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/serial_reg.h> 2#include <linux/serial_reg.h>
2#include <linux/serial_8250.h> 3#include <linux/serial_8250.h>
3 4
@@ -6,10 +7,6 @@
6/* 7/*
7 * Freescale 16550 UART "driver", Copyright (C) 2011 Paul Gortmaker. 8 * Freescale 16550 UART "driver", Copyright (C) 2011 Paul Gortmaker.
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This isn't a full driver; it just provides an alternate IRQ 10 * This isn't a full driver; it just provides an alternate IRQ
14 * handler to deal with an errata. Everything else is just 11 * handler to deal with an errata. Everything else is just
15 * using the bog standard 8250 support. 12 * using the bog standard 8250 support.
diff --git a/drivers/tty/serial/8250/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c
index df2931e1e086..0809ae2aa9b1 100644
--- a/drivers/tty/serial/8250/8250_gsc.c
+++ b/drivers/tty/serial/8250/8250_gsc.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Serial Device Initialisation for Lasi/Asp/Wax/Dino 3 * Serial Device Initialisation for Lasi/Asp/Wax/Dino
3 * 4 *
4 * (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002 5 * (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#include <linux/errno.h> 8#include <linux/errno.h>
diff --git a/drivers/tty/serial/8250/8250_hp300.c b/drivers/tty/serial/8250/8250_hp300.c
index 115190b7962a..3012ea03d22c 100644
--- a/drivers/tty/serial/8250/8250_hp300.c
+++ b/drivers/tty/serial/8250/8250_hp300.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the 98626/98644/internal serial interface on hp300/hp400 3 * Driver for the 98626/98644/internal serial interface on hp300/hp400
3 * (based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs) 4 * (based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs)
diff --git a/drivers/tty/serial/8250/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index 27124e21eb96..273f59b9bca5 100644
--- a/drivers/tty/serial/8250/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005 Russell King. 3 * Copyright (C) 2005 Russell King.
3 * Data taken from include/asm-i386/serial.h 4 * Data taken from include/asm-i386/serial.h
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */ 5 */
9#include <linux/module.h> 6#include <linux/module.h>
10#include <linux/init.h> 7#include <linux/init.h>
diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c
index 464389b28900..6af84900870e 100644
--- a/drivers/tty/serial/8250/8250_ingenic.c
+++ b/drivers/tty/serial/8250/8250_ingenic.c
@@ -1,17 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2010 Lars-Peter Clausen <lars@metafoo.de> 3 * Copyright (C) 2010 Lars-Peter Clausen <lars@metafoo.de>
3 * Copyright (C) 2015 Imagination Technologies 4 * Copyright (C) 2015 Imagination Technologies
4 * 5 *
5 * Ingenic SoC UART support 6 * Ingenic SoC UART support
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * You should have received a copy of the GNU General Public License along
13 * with this program; if not, write to the Free Software Foundation, Inc.,
14 * 675 Mass Ave, Cambridge, MA 02139, USA.
15 */ 7 */
16 8
17#include <linux/clk.h> 9#include <linux/clk.h>
diff --git a/drivers/tty/serial/8250/8250_lpc18xx.c b/drivers/tty/serial/8250/8250_lpc18xx.c
index 99cd478851ff..eddf119374e1 100644
--- a/drivers/tty/serial/8250/8250_lpc18xx.c
+++ b/drivers/tty/serial/8250/8250_lpc18xx.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Serial port driver for NXP LPC18xx/43xx UART 3 * Serial port driver for NXP LPC18xx/43xx UART
3 * 4 *
@@ -6,11 +7,6 @@
6 * Based on 8250_mtk.c: 7 * Based on 8250_mtk.c:
7 * Copyright (c) 2014 MundoReader S.L. 8 * Copyright (c) 2014 MundoReader S.L.
8 * Matthias Brugger <matthias.bgg@gmail.com> 9 * Matthias Brugger <matthias.bgg@gmail.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */ 10 */
15 11
16#include <linux/clk.h> 12#include <linux/clk.h>
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 7dddd7e6a01c..98dbc796353f 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * 8250_lpss.c - Driver for UART on Intel Braswell and various other Intel SoCs 3 * 8250_lpss.c - Driver for UART on Intel Braswell and various other Intel SoCs
3 * 4 *
4 * Copyright (C) 2016 Intel Corporation 5 * Copyright (C) 2016 Intel Corporation
5 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 6 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/bitops.h> 9#include <linux/bitops.h>
diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
index ec957cce8c9a..efa0515139f8 100644
--- a/drivers/tty/serial/8250/8250_mid.c
+++ b/drivers/tty/serial/8250/8250_mid.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * 8250_mid.c - Driver for UART on Intel Penwell and various other Intel SOCs 3 * 8250_mid.c - Driver for UART on Intel Penwell and various other Intel SOCs
3 * 4 *
4 * Copyright (C) 2015 Intel Corporation 5 * Copyright (C) 2015 Intel Corporation
5 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/bitops.h> 9#include <linux/bitops.h>
@@ -23,10 +20,11 @@
23#define PCI_DEVICE_ID_INTEL_PNW_UART2 0x081c 20#define PCI_DEVICE_ID_INTEL_PNW_UART2 0x081c
24#define PCI_DEVICE_ID_INTEL_PNW_UART3 0x081d 21#define PCI_DEVICE_ID_INTEL_PNW_UART3 0x081d
25#define PCI_DEVICE_ID_INTEL_TNG_UART 0x1191 22#define PCI_DEVICE_ID_INTEL_TNG_UART 0x1191
23#define PCI_DEVICE_ID_INTEL_CDF_UART 0x18d8
26#define PCI_DEVICE_ID_INTEL_DNV_UART 0x19d8 24#define PCI_DEVICE_ID_INTEL_DNV_UART 0x19d8
27 25
28/* Intel MID Specific registers */ 26/* Intel MID Specific registers */
29#define INTEL_MID_UART_DNV_FISR 0x08 27#define INTEL_MID_UART_FISR 0x08
30#define INTEL_MID_UART_PS 0x30 28#define INTEL_MID_UART_PS 0x30
31#define INTEL_MID_UART_MUL 0x34 29#define INTEL_MID_UART_MUL 0x34
32#define INTEL_MID_UART_DIV 0x38 30#define INTEL_MID_UART_DIV 0x38
@@ -130,7 +128,7 @@ static int dnv_handle_irq(struct uart_port *p)
130{ 128{
131 struct mid8250 *mid = p->private_data; 129 struct mid8250 *mid = p->private_data;
132 struct uart_8250_port *up = up_to_u8250p(p); 130 struct uart_8250_port *up = up_to_u8250p(p);
133 unsigned int fisr = serial_port_in(p, INTEL_MID_UART_DNV_FISR); 131 unsigned int fisr = serial_port_in(p, INTEL_MID_UART_FISR);
134 u32 status; 132 u32 status;
135 int ret = 0; 133 int ret = 0;
136 int err; 134 int err;
@@ -377,6 +375,7 @@ static const struct pci_device_id pci_ids[] = {
377 MID_DEVICE(PCI_DEVICE_ID_INTEL_PNW_UART2, pnw_board), 375 MID_DEVICE(PCI_DEVICE_ID_INTEL_PNW_UART2, pnw_board),
378 MID_DEVICE(PCI_DEVICE_ID_INTEL_PNW_UART3, pnw_board), 376 MID_DEVICE(PCI_DEVICE_ID_INTEL_PNW_UART3, pnw_board),
379 MID_DEVICE(PCI_DEVICE_ID_INTEL_TNG_UART, tng_board), 377 MID_DEVICE(PCI_DEVICE_ID_INTEL_TNG_UART, tng_board),
378 MID_DEVICE(PCI_DEVICE_ID_INTEL_CDF_UART, dnv_board),
380 MID_DEVICE(PCI_DEVICE_ID_INTEL_DNV_UART, dnv_board), 379 MID_DEVICE(PCI_DEVICE_ID_INTEL_DNV_UART, dnv_board),
381 { }, 380 { },
382}; 381};
diff --git a/drivers/tty/serial/8250/8250_moxa.c b/drivers/tty/serial/8250/8250_moxa.c
index d5069b2d4d79..1ee4cd94d4fa 100644
--- a/drivers/tty/serial/8250/8250_moxa.c
+++ b/drivers/tty/serial/8250/8250_moxa.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * 8250_moxa.c - MOXA Smartio/Industio MUE multiport serial driver. 3 * 8250_moxa.c - MOXA Smartio/Industio MUE multiport serial driver.
3 * 4 *
4 * Author: Mathieu OTHACEHE <m.othacehe@gmail.com> 5 * Author: Mathieu OTHACEHE <m.othacehe@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index fb45770d47aa..dd5e1cede2b5 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Mediatek 8250 driver. 3 * Mediatek 8250 driver.
3 * 4 *
4 * Copyright (c) 2014 MundoReader S.L. 5 * Copyright (c) 2014 MundoReader S.L.
5 * Author: Matthias Brugger <matthias.bgg@gmail.com> 6 * Author: Matthias Brugger <matthias.bgg@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 7 */
17#include <linux/clk.h> 8#include <linux/clk.h>
18#include <linux/io.h> 9#include <linux/io.h>
@@ -61,7 +52,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
61 * registers to their default values. 52 * registers to their default values.
62 */ 53 */
63 baud = uart_get_baud_rate(port, termios, old, 54 baud = uart_get_baud_rate(port, termios, old,
64 port->uartclk / 16 / 0xffff, 55 port->uartclk / 16 / UART_DIV_MAX,
65 port->uartclk); 56 port->uartclk);
66 57
67 if (baud <= 115200) { 58 if (baud <= 115200) {
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 1222c005fb98..1e67a7e4a5fd 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -1,13 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Serial Port driver for Open Firmware platform devices 3 * Serial Port driver for Open Firmware platform devices
3 * 4 *
4 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp. 5 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */ 6 */
12#include <linux/console.h> 7#include <linux/console.h>
13#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 833771bca0a5..bd40ba402410 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * 8250-core based driver for the OMAP internal UART 3 * 8250-core based driver for the OMAP internal UART
3 * 4 *
@@ -199,7 +200,7 @@ static void omap_8250_get_divisor(struct uart_port *port, unsigned int baud,
199 * Old custom speed handling. 200 * Old custom speed handling.
200 */ 201 */
201 if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) { 202 if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) {
202 priv->quot = port->custom_divisor & 0xffff; 203 priv->quot = port->custom_divisor & UART_DIV_MAX;
203 /* 204 /*
204 * I assume that nobody is using this. But hey, if somebody 205 * I assume that nobody is using this. But hey, if somebody
205 * would like to specify the divisor _and_ the mode then the 206 * would like to specify the divisor _and_ the mode then the
@@ -358,7 +359,7 @@ static void omap_8250_set_termios(struct uart_port *port,
358 * Ask the core to calculate the divisor for us. 359 * Ask the core to calculate the divisor for us.
359 */ 360 */
360 baud = uart_get_baud_rate(port, termios, old, 361 baud = uart_get_baud_rate(port, termios, old,
361 port->uartclk / 16 / 0xffff, 362 port->uartclk / 16 / UART_DIV_MAX,
362 port->uartclk / 13); 363 port->uartclk / 13);
363 omap_8250_get_divisor(port, baud, priv); 364 omap_8250_get_divisor(port, baud, priv);
364 365
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 0c101a7470b0..b7e0e3416641 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Probe module for 8250/16550-type PCI serial ports. 3 * Probe module for 8250/16550-type PCI serial ports.
3 * 4 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 5 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 * 6 *
6 * Copyright (C) 2001 Russell King, All Rights Reserved. 7 * Copyright (C) 2001 Russell King, All Rights Reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License.
11 */ 8 */
12#undef DEBUG 9#undef DEBUG
13#include <linux/module.h> 10#include <linux/module.h>
@@ -3368,6 +3365,7 @@ static const struct pci_device_id blacklist[] = {
3368 { PCI_VDEVICE(INTEL, 0x081c), }, 3365 { PCI_VDEVICE(INTEL, 0x081c), },
3369 { PCI_VDEVICE(INTEL, 0x081d), }, 3366 { PCI_VDEVICE(INTEL, 0x081d), },
3370 { PCI_VDEVICE(INTEL, 0x1191), }, 3367 { PCI_VDEVICE(INTEL, 0x1191), },
3368 { PCI_VDEVICE(INTEL, 0x18d8), },
3371 { PCI_VDEVICE(INTEL, 0x19d8), }, 3369 { PCI_VDEVICE(INTEL, 0x19d8), },
3372 3370
3373 /* Intel platforms with DesignWare UART */ 3371 /* Intel platforms with DesignWare UART */
diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index 34f05ed78b68..431e69a5a6a0 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Probe for 8250/16550-type ISAPNP serial ports. 3 * Probe for 8250/16550-type ISAPNP serial ports.
3 * 4 *
@@ -6,10 +7,6 @@
6 * Copyright (C) 2001 Russell King, All Rights Reserved. 7 * Copyright (C) 2001 Russell King, All Rights Reserved.
7 * 8 *
8 * Ported to the Linux PnP Layer - (C) Adam Belay. 9 * Ported to the Linux PnP Layer - (C) Adam Belay.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License.
13 */ 10 */
14#include <linux/module.h> 11#include <linux/module.h>
15#include <linux/pci.h> 12#include <linux/pci.h>
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index f0cc04f62b67..11434551ac0a 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Base port operations for 8250/16550-type serial ports 3 * Base port operations for 8250/16550-type serial ports
3 * 4 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 5 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 * Split from 8250_core.c, Copyright (C) 2001 Russell King. 6 * Split from 8250_core.c, Copyright (C) 2001 Russell King.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * A note about mapbase / membase 8 * A note about mapbase / membase
13 * 9 *
14 * mapbase is the physical address of the IO port. 10 * mapbase is the physical address of the IO port.
@@ -1516,7 +1512,6 @@ static inline void __stop_tx(struct uart_8250_port *p)
1516 return; 1512 return;
1517 1513
1518 em485->active_timer = NULL; 1514 em485->active_timer = NULL;
1519 hrtimer_cancel(&em485->start_tx_timer);
1520 1515
1521 __stop_tx_rs485(p); 1516 __stop_tx_rs485(p);
1522 } 1517 }
@@ -1580,8 +1575,6 @@ static inline void start_tx_rs485(struct uart_port *port)
1580 serial8250_stop_rx(&up->port); 1575 serial8250_stop_rx(&up->port);
1581 1576
1582 em485->active_timer = NULL; 1577 em485->active_timer = NULL;
1583 if (hrtimer_is_queued(&em485->stop_tx_timer))
1584 hrtimer_cancel(&em485->stop_tx_timer);
1585 1578
1586 mcr = serial8250_in_MCR(up); 1579 mcr = serial8250_in_MCR(up);
1587 if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) != 1580 if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) !=
@@ -2586,8 +2579,11 @@ static void serial8250_set_divisor(struct uart_port *port, unsigned int baud,
2586 serial_dl_write(up, quot); 2579 serial_dl_write(up, quot);
2587 2580
2588 /* XR17V35x UARTs have an extra fractional divisor register (DLD) */ 2581 /* XR17V35x UARTs have an extra fractional divisor register (DLD) */
2589 if (up->port.type == PORT_XR17V35X) 2582 if (up->port.type == PORT_XR17V35X) {
2583 /* Preserve bits not related to baudrate; DLD[7:4]. */
2584 quot_frac |= serial_port_in(port, 0x2) & 0xf0;
2590 serial_port_out(port, 0x2, quot_frac); 2585 serial_port_out(port, 0x2, quot_frac);
2586 }
2591} 2587}
2592 2588
2593static unsigned int serial8250_get_baud_rate(struct uart_port *port, 2589static unsigned int serial8250_get_baud_rate(struct uart_port *port,
@@ -2601,7 +2597,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
2601 * causing transmission errors. 2597 * causing transmission errors.
2602 */ 2598 */
2603 return uart_get_baud_rate(port, termios, old, 2599 return uart_get_baud_rate(port, termios, old,
2604 port->uartclk / 16 / 0xffff, 2600 port->uartclk / 16 / UART_DIV_MAX,
2605 port->uartclk); 2601 port->uartclk);
2606} 2602}
2607 2603
diff --git a/drivers/tty/serial/8250/8250_pxa.c b/drivers/tty/serial/8250/8250_pxa.c
index 4d68731af534..b9bcbe20a2be 100644
--- a/drivers/tty/serial/8250/8250_pxa.c
+++ b/drivers/tty/serial/8250/8250_pxa.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * drivers/tty/serial/8250/8250_pxa.c -- driver for PXA on-board UARTS 3 * drivers/tty/serial/8250/8250_pxa.c -- driver for PXA on-board UARTS
3 * Copyright: (C) 2013 Sergei Ianovich <ynvich@gmail.com> 4 * Copyright: (C) 2013 Sergei Ianovich <ynvich@gmail.com>
@@ -7,12 +8,6 @@
7 * Copyright: (C) 2003 Monta Vista Software, Inc. 8 * Copyright: (C) 2003 Monta Vista Software, Inc.
8 * 9 *
9 * Based on drivers/serial/8250.c by Russell King. 10 * Based on drivers/serial/8250.c by Russell King.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 */ 11 */
17 12
18#include <linux/device.h> 13#include <linux/device.h>
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c
index 8a10b10e27aa..45ef506293ae 100644
--- a/drivers/tty/serial/8250/8250_uniphier.c
+++ b/drivers/tty/serial/8250/8250_uniphier.c
@@ -1,15 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com> 3 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */ 4 */
14 5
15#include <linux/clk.h> 6#include <linux/clk.h>
diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
index 933c2688dd7e..9963a766dcfb 100644
--- a/drivers/tty/serial/8250/serial_cs.c
+++ b/drivers/tty/serial/8250/serial_cs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
1/*====================================================================== 2/*======================================================================
2 3
3 A driver for PCMCIA serial devices 4 A driver for PCMCIA serial devices
diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index 0475f5d261ce..c90e503d6b57 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * altera_jtaguart.c -- Altera JTAG UART driver 3 * altera_jtaguart.c -- Altera JTAG UART driver
3 * 4 *
@@ -6,11 +7,6 @@
6 * (C) Copyright 2003-2007, Greg Ungerer <gerg@snapgear.com> 7 * (C) Copyright 2003-2007, Greg Ungerer <gerg@snapgear.com>
7 * (C) Copyright 2008, Thomas Chou <thomas@wytron.com.tw> 8 * (C) Copyright 2008, Thomas Chou <thomas@wytron.com.tw>
8 * (C) Copyright 2010, Tobias Klauser <tklauser@distanz.ch> 9 * (C) Copyright 2010, Tobias Klauser <tklauser@distanz.ch>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */ 10 */
15 11
16#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 3e4b717670d7..b88b05f8e81e 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * altera_uart.c -- Altera UART driver 3 * altera_uart.c -- Altera UART driver
3 * 4 *
@@ -6,11 +7,6 @@
6 * (C) Copyright 2003-2007, Greg Ungerer <gerg@snapgear.com> 7 * (C) Copyright 2003-2007, Greg Ungerer <gerg@snapgear.com>
7 * (C) Copyright 2008, Thomas Chou <thomas@wytron.com.tw> 8 * (C) Copyright 2008, Thomas Chou <thomas@wytron.com.tw>
8 * (C) Copyright 2010, Tobias Klauser <tklauser@distanz.ch> 9 * (C) Copyright 2010, Tobias Klauser <tklauser@distanz.ch>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */ 10 */
15 11
16#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -288,10 +284,10 @@ static irqreturn_t altera_uart_interrupt(int irq, void *data)
288 return IRQ_RETVAL(isr); 284 return IRQ_RETVAL(isr);
289} 285}
290 286
291static void altera_uart_timer(unsigned long data) 287static void altera_uart_timer(struct timer_list *t)
292{ 288{
293 struct uart_port *port = (void *)data; 289 struct altera_uart *pp = from_timer(pp, t, tmr);
294 struct altera_uart *pp = container_of(port, struct altera_uart, port); 290 struct uart_port *port = &pp->port;
295 291
296 altera_uart_interrupt(0, port); 292 altera_uart_interrupt(0, port);
297 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); 293 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port));
@@ -314,7 +310,7 @@ static int altera_uart_startup(struct uart_port *port)
314 int ret; 310 int ret;
315 311
316 if (!port->irq) { 312 if (!port->irq) {
317 setup_timer(&pp->tmr, altera_uart_timer, (unsigned long)port); 313 timer_setup(&pp->tmr, altera_uart_timer, 0);
318 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); 314 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port));
319 return 0; 315 return 0;
320 } 316 }
diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 9ec4b8d2879f..2c37d11726ab 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for AMBA serial ports 3 * Driver for AMBA serial ports
3 * 4 *
@@ -6,20 +7,6 @@
6 * Copyright 1999 ARM Limited 7 * Copyright 1999 ARM Limited
7 * Copyright (C) 2000 Deep Blue Solutions Ltd. 8 * Copyright (C) 2000 Deep Blue Solutions Ltd.
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * This is a generic driver for ARM AMBA-type serial ports. They 10 * This is a generic driver for ARM AMBA-type serial ports. They
24 * have a lot of 16550-like features, but are not register compatible. 11 * have a lot of 16550-like features, but are not register compatible.
25 * Note that although they do have CTS, DCD and DSR inputs, they do 12 * Note that although they do have CTS, DCD and DSR inputs, they do
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 111e6a950779..04af8de8617e 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for AMBA serial ports 3 * Driver for AMBA serial ports
3 * 4 *
@@ -7,20 +8,6 @@
7 * Copyright (C) 2000 Deep Blue Solutions Ltd. 8 * Copyright (C) 2000 Deep Blue Solutions Ltd.
8 * Copyright (C) 2010 ST-Ericsson SA 9 * Copyright (C) 2010 ST-Ericsson SA
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * This is a generic driver for ARM AMBA-type serial ports. They 11 * This is a generic driver for ARM AMBA-type serial ports. They
25 * have a lot of 16550-like features, but are not register compatible. 12 * have a lot of 16550-like features, but are not register compatible.
26 * Note that although they do have CTS, DCD and DSR inputs, they do 13 * Note that although they do have CTS, DCD and DSR inputs, they do
@@ -281,7 +268,6 @@ struct uart_amba_port {
281 unsigned int old_status; 268 unsigned int old_status;
282 unsigned int fifosize; /* vendor-specific */ 269 unsigned int fifosize; /* vendor-specific */
283 unsigned int old_cr; /* state during shutdown */ 270 unsigned int old_cr; /* state during shutdown */
284 bool autorts;
285 unsigned int fixed_baud; /* vendor-set fixed baud rate */ 271 unsigned int fixed_baud; /* vendor-set fixed baud rate */
286 char type[12]; 272 char type[12];
287#ifdef CONFIG_DMA_ENGINE 273#ifdef CONFIG_DMA_ENGINE
@@ -1078,9 +1064,9 @@ static inline void pl011_dma_rx_stop(struct uart_amba_port *uap)
1078 * Every polling, It checks the residue in the dma buffer and transfer 1064 * Every polling, It checks the residue in the dma buffer and transfer
1079 * data to the tty. Also, last_residue is updated for the next polling. 1065 * data to the tty. Also, last_residue is updated for the next polling.
1080 */ 1066 */
1081static void pl011_dma_rx_poll(unsigned long args) 1067static void pl011_dma_rx_poll(struct timer_list *t)
1082{ 1068{
1083 struct uart_amba_port *uap = (struct uart_amba_port *)args; 1069 struct uart_amba_port *uap = from_timer(uap, t, dmarx.timer);
1084 struct tty_port *port = &uap->port.state->port; 1070 struct tty_port *port = &uap->port.state->port;
1085 struct pl011_dmarx_data *dmarx = &uap->dmarx; 1071 struct pl011_dmarx_data *dmarx = &uap->dmarx;
1086 struct dma_chan *rxchan = uap->dmarx.chan; 1072 struct dma_chan *rxchan = uap->dmarx.chan;
@@ -1192,9 +1178,7 @@ skip_rx:
1192 dev_dbg(uap->port.dev, "could not trigger initial " 1178 dev_dbg(uap->port.dev, "could not trigger initial "
1193 "RX DMA job, fall back to interrupt mode\n"); 1179 "RX DMA job, fall back to interrupt mode\n");
1194 if (uap->dmarx.poll_rate) { 1180 if (uap->dmarx.poll_rate) {
1195 init_timer(&(uap->dmarx.timer)); 1181 timer_setup(&uap->dmarx.timer, pl011_dma_rx_poll, 0);
1196 uap->dmarx.timer.function = pl011_dma_rx_poll;
1197 uap->dmarx.timer.data = (unsigned long)uap;
1198 mod_timer(&uap->dmarx.timer, 1182 mod_timer(&uap->dmarx.timer,
1199 jiffies + 1183 jiffies +
1200 msecs_to_jiffies(uap->dmarx.poll_rate)); 1184 msecs_to_jiffies(uap->dmarx.poll_rate));
@@ -1588,7 +1572,7 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
1588 TIOCMBIT(TIOCM_OUT2, UART011_CR_OUT2); 1572 TIOCMBIT(TIOCM_OUT2, UART011_CR_OUT2);
1589 TIOCMBIT(TIOCM_LOOP, UART011_CR_LBE); 1573 TIOCMBIT(TIOCM_LOOP, UART011_CR_LBE);
1590 1574
1591 if (uap->autorts) { 1575 if (port->status & UPSTAT_AUTORTS) {
1592 /* We need to disable auto-RTS if we want to turn RTS off */ 1576 /* We need to disable auto-RTS if we want to turn RTS off */
1593 TIOCMBIT(TIOCM_RTS, UART011_CR_RTSEN); 1577 TIOCMBIT(TIOCM_RTS, UART011_CR_RTSEN);
1594 } 1578 }
@@ -1842,7 +1826,7 @@ static void pl011_disable_uart(struct uart_amba_port *uap)
1842{ 1826{
1843 unsigned int cr; 1827 unsigned int cr;
1844 1828
1845 uap->autorts = false; 1829 uap->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS);
1846 spin_lock_irq(&uap->port.lock); 1830 spin_lock_irq(&uap->port.lock);
1847 cr = pl011_read(uap, REG_CR); 1831 cr = pl011_read(uap, REG_CR);
1848 uap->old_cr = cr; 1832 uap->old_cr = cr;
@@ -2028,10 +2012,10 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
2028 old_cr |= UART011_CR_RTSEN; 2012 old_cr |= UART011_CR_RTSEN;
2029 2013
2030 old_cr |= UART011_CR_CTSEN; 2014 old_cr |= UART011_CR_CTSEN;
2031 uap->autorts = true; 2015 port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS;
2032 } else { 2016 } else {
2033 old_cr &= ~(UART011_CR_CTSEN | UART011_CR_RTSEN); 2017 old_cr &= ~(UART011_CR_CTSEN | UART011_CR_RTSEN);
2034 uap->autorts = false; 2018 port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS);
2035 } 2019 }
2036 2020
2037 if (uap->vendor->oversampling) { 2021 if (uap->vendor->oversampling) {
diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index dd60ed96a0ad..60cd133ffbbc 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for GRLIB serial ports (APBUART) 3 * Driver for GRLIB serial ports (APBUART)
3 * 4 *
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index decc7f3c1ab2..db5df3d54818 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Atheros AR933X SoC built-in UART driver 3 * Atheros AR933X SoC built-in UART driver
3 * 4 *
4 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org> 5 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
5 * 6 *
6 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 7 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 77fe306690c4..2599f9ecccfe 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ARC On-Chip(fpga) UART Driver 3 * ARC On-Chip(fpga) UART Driver
3 * 4 *
4 * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) 5 * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com)
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * vineetg: July 10th 2012 7 * vineetg: July 10th 2012
11 * -Decoupled the driver from arch/arc 8 * -Decoupled the driver from arch/arc
12 * +Using platform_get_resource() for irq/membase (thx to bfin_uart.c) 9 * +Using platform_get_resource() for irq/membase (thx to bfin_uart.c)
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 7551cab438ff..efa25611ca0c 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Atmel AT91 Serial ports 3 * Driver for Atmel AT91 Serial ports
3 * Copyright (C) 2003 Rick Bronson 4 * Copyright (C) 2003 Rick Bronson
@@ -6,21 +7,6 @@
6 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 7 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
7 * 8 *
8 * DMA support added by Chip Coldwell. 9 * DMA support added by Chip Coldwell.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 10 */
25#include <linux/tty.h> 11#include <linux/tty.h>
26#include <linux/ioport.h> 12#include <linux/ioport.h>
@@ -171,6 +157,7 @@ struct atmel_uart_port {
171 bool has_hw_timer; 157 bool has_hw_timer;
172 struct timer_list uart_timer; 158 struct timer_list uart_timer;
173 159
160 bool tx_stopped;
174 bool suspended; 161 bool suspended;
175 unsigned int pending; 162 unsigned int pending;
176 unsigned int pending_status; 163 unsigned int pending_status;
@@ -380,6 +367,10 @@ static int atmel_config_rs485(struct uart_port *port,
380 */ 367 */
381static u_int atmel_tx_empty(struct uart_port *port) 368static u_int atmel_tx_empty(struct uart_port *port)
382{ 369{
370 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
371
372 if (atmel_port->tx_stopped)
373 return TIOCSER_TEMT;
383 return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ? 374 return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?
384 TIOCSER_TEMT : 375 TIOCSER_TEMT :
385 0; 376 0;
@@ -485,6 +476,7 @@ static void atmel_stop_tx(struct uart_port *port)
485 * is fully transmitted. 476 * is fully transmitted.
486 */ 477 */
487 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); 478 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
479 atmel_port->tx_stopped = true;
488 480
489 /* Disable interrupts */ 481 /* Disable interrupts */
490 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); 482 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
@@ -521,6 +513,7 @@ static void atmel_start_tx(struct uart_port *port)
521 513
522 /* re-enable the transmitter */ 514 /* re-enable the transmitter */
523 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); 515 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
516 atmel_port->tx_stopped = false;
524} 517}
525 518
526/* 519/*
@@ -1178,10 +1171,11 @@ chan_err:
1178 return -EINVAL; 1171 return -EINVAL;
1179} 1172}
1180 1173
1181static void atmel_uart_timer_callback(unsigned long data) 1174static void atmel_uart_timer_callback(struct timer_list *t)
1182{ 1175{
1183 struct uart_port *port = (void *)data; 1176 struct atmel_uart_port *atmel_port = from_timer(atmel_port, t,
1184 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1177 uart_timer);
1178 struct uart_port *port = &atmel_port->uart;
1185 1179
1186 if (!atomic_read(&atmel_port->tasklet_shutdown)) { 1180 if (!atomic_read(&atmel_port->tasklet_shutdown)) {
1187 tasklet_schedule(&atmel_port->tasklet_rx); 1181 tasklet_schedule(&atmel_port->tasklet_rx);
@@ -1667,29 +1661,6 @@ static void atmel_init_property(struct atmel_uart_port *atmel_port,
1667 } 1661 }
1668} 1662}
1669 1663
1670static void atmel_init_rs485(struct uart_port *port,
1671 struct platform_device *pdev)
1672{
1673 struct device_node *np = pdev->dev.of_node;
1674
1675 struct serial_rs485 *rs485conf = &port->rs485;
1676 u32 rs485_delay[2];
1677
1678 /* rs485 properties */
1679 if (of_property_read_u32_array(np, "rs485-rts-delay",
1680 rs485_delay, 2) == 0) {
1681 rs485conf->delay_rts_before_send = rs485_delay[0];
1682 rs485conf->delay_rts_after_send = rs485_delay[1];
1683 rs485conf->flags = 0;
1684 }
1685
1686 if (of_get_property(np, "rs485-rx-during-tx", NULL))
1687 rs485conf->flags |= SER_RS485_RX_DURING_TX;
1688
1689 if (of_get_property(np, "linux,rs485-enabled-at-boot-time", NULL))
1690 rs485conf->flags |= SER_RS485_ENABLED;
1691}
1692
1693static void atmel_set_ops(struct uart_port *port) 1664static void atmel_set_ops(struct uart_port *port)
1694{ 1665{
1695 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1666 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
@@ -1866,10 +1837,9 @@ static int atmel_startup(struct uart_port *port)
1866 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); 1837 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
1867 /* enable xmit & rcvr */ 1838 /* enable xmit & rcvr */
1868 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); 1839 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
1840 atmel_port->tx_stopped = false;
1869 1841
1870 setup_timer(&atmel_port->uart_timer, 1842 timer_setup(&atmel_port->uart_timer, atmel_uart_timer_callback, 0);
1871 atmel_uart_timer_callback,
1872 (unsigned long)port);
1873 1843
1874 if (atmel_use_pdc_rx(port)) { 1844 if (atmel_use_pdc_rx(port)) {
1875 /* set UART timeout */ 1845 /* set UART timeout */
@@ -2122,6 +2092,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2122 2092
2123 /* disable receiver and transmitter */ 2093 /* disable receiver and transmitter */
2124 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS); 2094 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
2095 atmel_port->tx_stopped = true;
2125 2096
2126 /* mode */ 2097 /* mode */
2127 if (port->rs485.flags & SER_RS485_ENABLED) { 2098 if (port->rs485.flags & SER_RS485_ENABLED) {
@@ -2207,6 +2178,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2207 atmel_uart_writel(port, ATMEL_US_BRGR, quot); 2178 atmel_uart_writel(port, ATMEL_US_BRGR, quot);
2208 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); 2179 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
2209 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); 2180 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
2181 atmel_port->tx_stopped = false;
2210 2182
2211 /* restore interrupts */ 2183 /* restore interrupts */
2212 atmel_uart_writel(port, ATMEL_US_IER, imr); 2184 atmel_uart_writel(port, ATMEL_US_IER, imr);
@@ -2373,7 +2345,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
2373 atmel_init_property(atmel_port, pdev); 2345 atmel_init_property(atmel_port, pdev);
2374 atmel_set_ops(port); 2346 atmel_set_ops(port);
2375 2347
2376 atmel_init_rs485(port, pdev); 2348 of_get_rs485_mode(pdev->dev.of_node, &port->rs485);
2377 2349
2378 port->iotype = UPIO_MEM; 2350 port->iotype = UPIO_MEM;
2379 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; 2351 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP;
@@ -2450,6 +2422,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
2450 2422
2451 /* Make sure that tx path is actually able to send characters */ 2423 /* Make sure that tx path is actually able to send characters */
2452 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); 2424 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
2425 atmel_port->tx_stopped = false;
2453 2426
2454 uart_console_write(port, s, count, atmel_console_putchar); 2427 uart_console_write(port, s, count, atmel_console_putchar);
2455 2428
@@ -2511,6 +2484,7 @@ static int __init atmel_console_setup(struct console *co, char *options)
2511{ 2484{
2512 int ret; 2485 int ret;
2513 struct uart_port *port = &atmel_ports[co->index].uart; 2486 struct uart_port *port = &atmel_ports[co->index].uart;
2487 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2514 int baud = 115200; 2488 int baud = 115200;
2515 int bits = 8; 2489 int bits = 8;
2516 int parity = 'n'; 2490 int parity = 'n';
@@ -2528,6 +2502,7 @@ static int __init atmel_console_setup(struct console *co, char *options)
2528 atmel_uart_writel(port, ATMEL_US_IDR, -1); 2502 atmel_uart_writel(port, ATMEL_US_IDR, -1);
2529 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); 2503 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
2530 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); 2504 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
2505 atmel_port->tx_stopped = false;
2531 2506
2532 if (options) 2507 if (options)
2533 uart_parse_options(options, &baud, &parity, &bits, &flow); 2508 uart_parse_options(options, &baud, &parity, &bits, &flow);
diff --git a/drivers/tty/serial/atmel_serial.h b/drivers/tty/serial/atmel_serial.h
index bd2560502f3c..ba3a2437cde4 100644
--- a/drivers/tty/serial/atmel_serial.h
+++ b/drivers/tty/serial/atmel_serial.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * include/linux/atmel_serial.h 3 * include/linux/atmel_serial.h
3 * 4 *
@@ -6,11 +7,6 @@
6 * 7 *
7 * USART registers. 8 * USART registers.
8 * Based on AT91RM9200 datasheet revision E. 9 * Based on AT91RM9200 datasheet revision E.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */ 10 */
15 11
16#ifndef ATMEL_SERIAL_H 12#ifndef ATMEL_SERIAL_H
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index 8c48c3784831..9d1b7bf7378c 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -1,8 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from many drivers using generic_serial interface. 3 * Derived from many drivers using generic_serial interface.
7 * 4 *
8 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 5 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c
index 6b03fb12cd19..4ccca5d22f4f 100644
--- a/drivers/tty/serial/bfin_sport_uart.c
+++ b/drivers/tty/serial/bfin_sport_uart.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Blackfin On-Chip Sport Emulated UART Driver 3 * Blackfin On-Chip Sport Emulated UART Driver
3 * 4 *
4 * Copyright 2006-2009 Analog Devices Inc. 5 * Copyright 2006-2009 Analog Devices Inc.
5 * 6 *
6 * Enter bugs at http://blackfin.uclinux.org/ 7 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */ 8 */
10 9
11/* 10/*
@@ -584,7 +583,7 @@ static void sport_set_termios(struct uart_port *port,
584 spin_unlock_irqrestore(&up->port.lock, flags); 583 spin_unlock_irqrestore(&up->port.lock, flags);
585} 584}
586 585
587struct uart_ops sport_uart_ops = { 586static const struct uart_ops sport_uart_ops = {
588 .tx_empty = sport_tx_empty, 587 .tx_empty = sport_tx_empty,
589 .set_mctrl = sport_set_mctrl, 588 .set_mctrl = sport_set_mctrl,
590 .get_mctrl = sport_get_mctrl, 589 .get_mctrl = sport_get_mctrl,
diff --git a/drivers/tty/serial/bfin_sport_uart.h b/drivers/tty/serial/bfin_sport_uart.h
index e4510ea135ce..4b12f45d6580 100644
--- a/drivers/tty/serial/bfin_sport_uart.h
+++ b/drivers/tty/serial/bfin_sport_uart.h
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Blackfin On-Chip Sport Emulated UART Driver 3 * Blackfin On-Chip Sport Emulated UART Driver
3 * 4 *
4 * Copyright 2006-2008 Analog Devices Inc. 5 * Copyright 2006-2008 Analog Devices Inc.
5 * 6 *
6 * Enter bugs at http://blackfin.uclinux.org/ 7 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */ 8 */
10 9
11/* 10/*
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 293ecbb00684..4755fa696321 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Blackfin On-Chip Serial Driver 3 * Blackfin On-Chip Serial Driver
3 * 4 *
4 * Copyright 2006-2011 Analog Devices Inc. 5 * Copyright 2006-2011 Analog Devices Inc.
5 * 6 *
6 * Enter bugs at http://blackfin.uclinux.org/ 7 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */ 8 */
10 9
11#if defined(CONFIG_SERIAL_BFIN_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 10#if defined(CONFIG_SERIAL_BFIN_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -456,8 +455,9 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
456 tty_flip_buffer_push(&uart->port.state->port); 455 tty_flip_buffer_push(&uart->port.state->port);
457} 456}
458 457
459void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) 458void bfin_serial_rx_dma_timeout(struct timer_list *t)
460{ 459{
460 struct bfin_serial_port *uart = from_timer(uart, t, rx_dma_timer);
461 int x_pos, pos; 461 int x_pos, pos;
462 unsigned long flags; 462 unsigned long flags;
463 463
@@ -624,8 +624,6 @@ static int bfin_serial_startup(struct uart_port *port)
624 set_dma_start_addr(uart->rx_dma_channel, (unsigned long)uart->rx_dma_buf.buf); 624 set_dma_start_addr(uart->rx_dma_channel, (unsigned long)uart->rx_dma_buf.buf);
625 enable_dma(uart->rx_dma_channel); 625 enable_dma(uart->rx_dma_channel);
626 626
627 uart->rx_dma_timer.data = (unsigned long)(uart);
628 uart->rx_dma_timer.function = (void *)bfin_serial_rx_dma_timeout;
629 uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES; 627 uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES;
630 add_timer(&(uart->rx_dma_timer)); 628 add_timer(&(uart->rx_dma_timer));
631#else 629#else
@@ -1316,7 +1314,7 @@ static int bfin_serial_probe(struct platform_device *pdev)
1316 } 1314 }
1317 uart->rx_dma_channel = res->start; 1315 uart->rx_dma_channel = res->start;
1318 1316
1319 init_timer(&(uart->rx_dma_timer)); 1317 timer_setup(&uart->rx_dma_timer, bfin_serial_rx_dma_timeout, 0);
1320#endif 1318#endif
1321 1319
1322#if defined(SERIAL_BFIN_CTSRTS) || \ 1320#if defined(SERIAL_BFIN_CTSRTS) || \
diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index ac1328629baa..98f193a83392 100644
--- a/drivers/tty/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for CLPS711x serial ports 3 * Driver for CLPS711x serial ports
3 * 4 *
@@ -5,11 +6,6 @@
5 * 6 *
6 * Copyright 1999 ARM Limited 7 * Copyright 1999 ARM Limited
7 * Copyright (C) 2000 Deep Blue Solutions Ltd. 8 * Copyright (C) 2000 Deep Blue Solutions Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 11#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 0ad027b95873..9f175a92fb5d 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for CPM (SCC/SMC) serial ports 3 * Driver for CPM (SCC/SMC) serial ports
3 * 4 *
@@ -5,11 +6,6 @@
5 * 6 *
6 * 2006 (c) MontaVista Software, Inc. 7 * 2006 (c) MontaVista Software, Inc.
7 * Vitaly Bordug <vbordug@ru.mvista.com> 8 * Vitaly Bordug <vbordug@ru.mvista.com>
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 *
13 */ 9 */
14#ifndef CPM_UART_H 10#ifndef CPM_UART_H
15#define CPM_UART_H 11#define CPM_UART_H
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 9ac142cfc1f1..24a5f05e769b 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for CPM (SCC/SMC) serial ports; core driver 3 * Driver for CPM (SCC/SMC) serial ports; core driver
3 * 4 *
@@ -12,21 +13,6 @@
12 * (C) 2004 Intracom, S.A. 13 * (C) 2004 Intracom, S.A.
13 * (C) 2005-2006 MontaVista Software, Inc. 14 * (C) 2005-2006 MontaVista Software, Inc.
14 * Vitaly Bordug <vbordug@ru.mvista.com> 15 * Vitaly Bordug <vbordug@ru.mvista.com>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 */ 16 */
31 17
32#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
index 6d3b22e93246..4eba17f3d293 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for CPM (SCC/SMC) serial ports; CPM1 definitions 3 * Driver for CPM (SCC/SMC) serial ports; CPM1 definitions
3 * 4 *
@@ -8,21 +9,6 @@
8 * (C) 2004 Intracom, S.A. 9 * (C) 2004 Intracom, S.A.
9 * (C) 2006 MontaVista Software, Inc. 10 * (C) 2006 MontaVista Software, Inc.
10 * Vitaly Bordug <vbordug@ru.mvista.com> 11 * Vitaly Bordug <vbordug@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */ 12 */
27 13
28#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index f46d2ca87209..e3bff068dc3c 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for CPM (SCC/SMC) serial ports; CPM2 definitions 3 * Driver for CPM (SCC/SMC) serial ports; CPM2 definitions
3 * 4 *
@@ -8,21 +9,6 @@
8 * (C) 2004 Intracom, S.A. 9 * (C) 2004 Intracom, S.A.
9 * (C) 2006 MontaVista Software, Inc. 10 * (C) 2006 MontaVista Software, Inc.
10 * Vitaly Bordug <vbordug@ru.mvista.com> 11 * Vitaly Bordug <vbordug@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */ 12 */
27 13
28#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
index 02ad6953b167..f460cca139e2 100644
--- a/drivers/tty/serial/digicolor-usart.c
+++ b/drivers/tty/serial/digicolor-usart.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Conexant Digicolor serial ports (USART) 3 * Driver for Conexant Digicolor serial ports (USART)
3 * 4 *
4 * Author: Baruch Siach <baruch@tkos.co.il> 5 * Author: Baruch Siach <baruch@tkos.co.il>
5 * 6 *
6 * Copyright (C) 2014 Paradox Innovation Ltd. 7 * Copyright (C) 2014 Paradox Innovation Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index ff465ff43577..7b57e840e255 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * dz.c: Serial port driver for DECstations equipped 3 * dz.c: Serial port driver for DECstations equipped
3 * with the DZ chipset. 4 * with the DZ chipset.
diff --git a/drivers/tty/serial/earlycon-arm-semihost.c b/drivers/tty/serial/earlycon-arm-semihost.c
index 6bbeb699777c..fa096c10b591 100644
--- a/drivers/tty/serial/earlycon-arm-semihost.c
+++ b/drivers/tty/serial/earlycon-arm-semihost.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2012 ARM Ltd. 3 * Copyright (C) 2012 ARM Ltd.
3 * Author: Marc Zyngier <marc.zyngier@arm.com> 4 * Author: Marc Zyngier <marc.zyngier@arm.com>
@@ -5,18 +6,6 @@
5 * Adapted for ARM and earlycon: 6 * Adapted for ARM and earlycon:
6 * Copyright (C) 2014 Linaro Ltd. 7 * Copyright (C) 2014 Linaro Ltd.
7 * Author: Rob Herring <robh@kernel.org> 8 * Author: Rob Herring <robh@kernel.org>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */ 9 */
21#include <linux/kernel.h> 10#include <linux/kernel.h>
22#include <linux/console.h> 11#include <linux/console.h>
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 98928f082d87..4c8b80f1c688 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2014 Linaro Ltd. 3 * Copyright (C) 2014 Linaro Ltd.
3 * Author: Rob Herring <robh@kernel.org> 4 * Author: Rob Herring <robh@kernel.org>
@@ -5,10 +6,6 @@
5 * Based on 8250 earlycon: 6 * Based on 8250 earlycon:
6 * (c) Copyright 2004 Hewlett-Packard Development Company, L.P. 7 * (c) Copyright 2004 Hewlett-Packard Development Company, L.P.
7 * Bjorn Helgaas <bjorn.helgaas@hp.com> 8 * Bjorn Helgaas <bjorn.helgaas@hp.com>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */ 9 */
13 10
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index 9fff25be87f9..d6b5e5463746 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#if defined(CONFIG_SERIAL_EFM32_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 2#if defined(CONFIG_SERIAL_EFM32_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
2#define SUPPORT_SYSRQ 3#define SUPPORT_SYSRQ
3#endif 4#endif
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index f0252184291e..c84e6f0db54e 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale lpuart serial port driver 3 * Freescale lpuart serial port driver
3 * 4 *
4 * Copyright 2012-2014 Freescale Semiconductor, Inc. 5 * Copyright 2012-2014 Freescale Semiconductor, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#if defined(CONFIG_SERIAL_FSL_LPUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 8#if defined(CONFIG_SERIAL_FSL_LPUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -1632,12 +1628,11 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
1632{ 1628{
1633 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 1629 struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
1634 unsigned long flags; 1630 unsigned long flags;
1635 unsigned long ctrl, old_ctrl, bd, modem; 1631 unsigned long ctrl, old_ctrl, modem;
1636 unsigned int baud; 1632 unsigned int baud;
1637 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; 1633 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
1638 1634
1639 ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL); 1635 ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL);
1640 bd = lpuart32_read(&sport->port, UARTBAUD);
1641 modem = lpuart32_read(&sport->port, UARTMODIR); 1636 modem = lpuart32_read(&sport->port, UARTMODIR);
1642 /* 1637 /*
1643 * only support CS8 and CS7, and for CS7 must enable PE. 1638 * only support CS8 and CS7, and for CS7 must enable PE.
@@ -2212,6 +2207,24 @@ static int lpuart_probe(struct platform_device *pdev)
2212 if (ret) 2207 if (ret)
2213 goto failed_attach_port; 2208 goto failed_attach_port;
2214 2209
2210 of_get_rs485_mode(np, &sport->port.rs485);
2211
2212 if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) {
2213 dev_err(&pdev->dev, "driver doesn't support RX during TX\n");
2214 return -ENOSYS;
2215 }
2216
2217 if (sport->port.rs485.delay_rts_before_send ||
2218 sport->port.rs485.delay_rts_after_send) {
2219 dev_err(&pdev->dev, "driver doesn't support RTS delays\n");
2220 return -ENOSYS;
2221 }
2222
2223 if (sport->port.rs485.flags & SER_RS485_ENABLED) {
2224 sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
2225 writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
2226 }
2227
2215 sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx"); 2228 sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx");
2216 if (!sport->dma_tx_chan) 2229 if (!sport->dma_tx_chan)
2217 dev_info(sport->port.dev, "DMA tx channel request failed, " 2230 dev_info(sport->port.dev, "DMA tx channel request failed, "
@@ -2222,12 +2235,6 @@ static int lpuart_probe(struct platform_device *pdev)
2222 dev_info(sport->port.dev, "DMA rx channel request failed, " 2235 dev_info(sport->port.dev, "DMA rx channel request failed, "
2223 "operating without rx DMA\n"); 2236 "operating without rx DMA\n");
2224 2237
2225 if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) {
2226 sport->port.rs485.flags |= SER_RS485_ENABLED;
2227 sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
2228 writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
2229 }
2230
2231 return 0; 2238 return 0;
2232 2239
2233failed_attach_port: 2240failed_attach_port:
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index fe92d74f4ea5..ad374f7c476d 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * icom.c 3 * icom.c
3 * 4 *
@@ -6,21 +7,6 @@
6 * Serial device driver. 7 * Serial device driver.
7 * 8 *
8 * Based on code from serial.c 9 * Based on code from serial.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 10 */
25#include <linux/module.h> 11#include <linux/module.h>
26#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/tty/serial/icom.h b/drivers/tty/serial/icom.h
index c8029e0025c9..8a77e739b333 100644
--- a/drivers/tty/serial/icom.h
+++ b/drivers/tty/serial/icom.h
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * icom.h 3 * icom.h
3 * 4 *
4 * Copyright (C) 2001 Michael Anderson, IBM Corporation 5 * Copyright (C) 2001 Michael Anderson, IBM Corporation
5 * 6 *
6 * Serial device driver include file. 7 * Serial device driver include file.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 8 */
22 9
23#include <linux/serial_core.h> 10#include <linux/serial_core.h>
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index f190a84a0246..473f4f81d690 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/**************************************************************************** 2/****************************************************************************
2 * 3 *
3 * Driver for the IFX 6x60 spi modem. 4 * Driver for the IFX 6x60 spi modem.
@@ -10,20 +11,6 @@
10 * Copyright (C) 2009, 2010 Intel Corp 11 * Copyright (C) 2009, 2010 Intel Corp
11 * Russ Gorby <russ.gorby@intel.com> 12 * Russ Gorby <russ.gorby@intel.com>
12 * 13 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 * USA
26 *
27 * Driver modified by Intel from Option gtm501l_spi.c 14 * Driver modified by Intel from Option gtm501l_spi.c
28 * 15 *
29 * Notes 16 * Notes
@@ -1029,9 +1016,8 @@ static int ifx_spi_spi_probe(struct spi_device *spi)
1029 spin_lock_init(&ifx_dev->write_lock); 1016 spin_lock_init(&ifx_dev->write_lock);
1030 spin_lock_init(&ifx_dev->power_lock); 1017 spin_lock_init(&ifx_dev->power_lock);
1031 ifx_dev->power_status = 0; 1018 ifx_dev->power_status = 0;
1032 init_timer(&ifx_dev->spi_timer); 1019 setup_timer(&ifx_dev->spi_timer, ifx_spi_timeout,
1033 ifx_dev->spi_timer.function = ifx_spi_timeout; 1020 (unsigned long)ifx_dev);
1034 ifx_dev->spi_timer.data = (unsigned long)ifx_dev;
1035 ifx_dev->modem = pl_data->modem_type; 1021 ifx_dev->modem = pl_data->modem_type;
1036 ifx_dev->use_dma = pl_data->use_dma; 1022 ifx_dev->use_dma = pl_data->use_dma;
1037 ifx_dev->max_hz = pl_data->max_hz; 1023 ifx_dev->max_hz = pl_data->max_hz;
diff --git a/drivers/tty/serial/ifx6x60.h b/drivers/tty/serial/ifx6x60.h
index 4fbddc297839..c5a2514212ff 100644
--- a/drivers/tty/serial/ifx6x60.h
+++ b/drivers/tty/serial/ifx6x60.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/**************************************************************************** 2/****************************************************************************
2 * 3 *
3 * Driver for the IFX spi modem. 4 * Driver for the IFX spi modem.
@@ -5,23 +6,6 @@
5 * Copyright (C) 2009, 2010 Intel Corp 6 * Copyright (C) 2009, 2010 Intel Corp
6 * Jim Stanley <jim.stanley@intel.com> 7 * Jim Stanley <jim.stanley@intel.com>
7 * 8 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * USA
22 *
23 *
24 *
25 *****************************************************************************/ 9 *****************************************************************************/
26#ifndef _IFX6X60_H 10#ifndef _IFX6X60_H
27#define _IFX6X60_H 11#define _IFX6X60_H
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index dfeff3951f93..a67a606c38eb 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Motorola/Freescale IMX serial ports 3 * Driver for Motorola/Freescale IMX serial ports
3 * 4 *
@@ -5,16 +6,6 @@
5 * 6 *
6 * Author: Sascha Hauer <sascha@saschahauer.de> 7 * Author: Sascha Hauer <sascha@saschahauer.de>
7 * Copyright (C) 2004 Pengutronix 8 * Copyright (C) 2004 Pengutronix
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */ 9 */
19 10
20#if defined(CONFIG_SERIAL_IMX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 11#if defined(CONFIG_SERIAL_IMX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -334,7 +325,8 @@ static void imx_port_rts_active(struct imx_port *sport, unsigned long *ucr2)
334{ 325{
335 *ucr2 &= ~(UCR2_CTSC | UCR2_CTS); 326 *ucr2 &= ~(UCR2_CTSC | UCR2_CTS);
336 327
337 mctrl_gpio_set(sport->gpios, sport->port.mctrl | TIOCM_RTS); 328 sport->port.mctrl |= TIOCM_RTS;
329 mctrl_gpio_set(sport->gpios, sport->port.mctrl);
338} 330}
339 331
340static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2) 332static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2)
@@ -342,7 +334,8 @@ static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2)
342 *ucr2 &= ~UCR2_CTSC; 334 *ucr2 &= ~UCR2_CTSC;
343 *ucr2 |= UCR2_CTS; 335 *ucr2 |= UCR2_CTS;
344 336
345 mctrl_gpio_set(sport->gpios, sport->port.mctrl & ~TIOCM_RTS); 337 sport->port.mctrl &= ~TIOCM_RTS;
338 mctrl_gpio_set(sport->gpios, sport->port.mctrl);
346} 339}
347 340
348static void imx_port_rts_auto(struct imx_port *sport, unsigned long *ucr2) 341static void imx_port_rts_auto(struct imx_port *sport, unsigned long *ucr2)
@@ -714,8 +707,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
714{ 707{
715 unsigned long temp; 708 unsigned long temp;
716 709
717 sport->dma_is_rxing = 1;
718
719 /* disable the receiver ready and aging timer interrupts */ 710 /* disable the receiver ready and aging timer interrupts */
720 temp = readl(sport->port.membase + UCR1); 711 temp = readl(sport->port.membase + UCR1);
721 temp &= ~(UCR1_RRDYEN); 712 temp &= ~(UCR1_RRDYEN);
@@ -732,29 +723,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
732} 723}
733 724
734static void clear_rx_errors(struct imx_port *sport); 725static void clear_rx_errors(struct imx_port *sport);
735static int start_rx_dma(struct imx_port *sport);
736/*
737 * If the RXFIFO is filled with some data, and then we
738 * arise a DMA operation to receive them.
739 */
740static void imx_dma_rxint(struct imx_port *sport)
741{
742 unsigned long temp;
743 unsigned long flags;
744
745 spin_lock_irqsave(&sport->port.lock, flags);
746
747 temp = readl(sport->port.membase + USR2);
748 if ((temp & USR2_RDR) && !sport->dma_is_rxing) {
749
750 imx_disable_rx_int(sport);
751
752 /* tell the DMA to receive the data. */
753 start_rx_dma(sport);
754 }
755
756 spin_unlock_irqrestore(&sport->port.lock, flags);
757}
758 726
759/* 727/*
760 * We have a modem side uart, so the meanings of RTS and CTS are inverted. 728 * We have a modem side uart, so the meanings of RTS and CTS are inverted.
@@ -816,11 +784,8 @@ static irqreturn_t imx_int(int irq, void *dev_id)
816 sts = readl(sport->port.membase + USR1); 784 sts = readl(sport->port.membase + USR1);
817 sts2 = readl(sport->port.membase + USR2); 785 sts2 = readl(sport->port.membase + USR2);
818 786
819 if (sts & (USR1_RRDY | USR1_AGTIM)) { 787 if (!sport->dma_is_enabled && (sts & (USR1_RRDY | USR1_AGTIM))) {
820 if (sport->dma_is_enabled) 788 imx_rxint(irq, dev_id);
821 imx_dma_rxint(sport);
822 else
823 imx_rxint(irq, dev_id);
824 ret = IRQ_HANDLED; 789 ret = IRQ_HANDLED;
825 } 790 }
826 791
@@ -1074,6 +1039,7 @@ static int start_rx_dma(struct imx_port *sport)
1074 desc->callback_param = sport; 1039 desc->callback_param = sport;
1075 1040
1076 dev_dbg(dev, "RX: prepare for the DMA.\n"); 1041 dev_dbg(dev, "RX: prepare for the DMA.\n");
1042 sport->dma_is_rxing = 1;
1077 sport->rx_cookie = dmaengine_submit(desc); 1043 sport->rx_cookie = dmaengine_submit(desc);
1078 dma_async_issue_pending(chan); 1044 dma_async_issue_pending(chan);
1079 return 0; 1045 return 0;
@@ -1165,7 +1131,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
1165 goto err; 1131 goto err;
1166 } 1132 }
1167 1133
1168 sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL); 1134 sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
1169 if (!sport->rx_buf) { 1135 if (!sport->rx_buf) {
1170 ret = -ENOMEM; 1136 ret = -ENOMEM;
1171 goto err; 1137 goto err;
@@ -1207,10 +1173,6 @@ static void imx_enable_dma(struct imx_port *sport)
1207 temp |= UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN; 1173 temp |= UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN;
1208 writel(temp, sport->port.membase + UCR1); 1174 writel(temp, sport->port.membase + UCR1);
1209 1175
1210 temp = readl(sport->port.membase + UCR2);
1211 temp |= UCR2_ATEN;
1212 writel(temp, sport->port.membase + UCR2);
1213
1214 imx_setup_ufcr(sport, TXTL_DMA, RXTL_DMA); 1176 imx_setup_ufcr(sport, TXTL_DMA, RXTL_DMA);
1215 1177
1216 sport->dma_is_enabled = 1; 1178 sport->dma_is_enabled = 1;
@@ -1411,15 +1373,19 @@ static void imx_flush_buffer(struct uart_port *port)
1411 temp = readl(sport->port.membase + UCR1); 1373 temp = readl(sport->port.membase + UCR1);
1412 temp &= ~UCR1_TDMAEN; 1374 temp &= ~UCR1_TDMAEN;
1413 writel(temp, sport->port.membase + UCR1); 1375 writel(temp, sport->port.membase + UCR1);
1414 sport->dma_is_txing = false; 1376 sport->dma_is_txing = 0;
1415 } 1377 }
1416 1378
1417 /* 1379 /*
1418 * According to the Reference Manual description of the UART SRST bit: 1380 * According to the Reference Manual description of the UART SRST bit:
1381 *
1419 * "Reset the transmit and receive state machines, 1382 * "Reset the transmit and receive state machines,
1420 * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD 1383 * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
1421 * and UTS[6-3]". As we don't need to restore the old values from 1384 * and UTS[6-3]".
1422 * USR1, USR2, URXD, UTXD, only save/restore the other four registers 1385 *
1386 * We don't need to restore the old values from USR1, USR2, URXD and
1387 * UTXD. UBRC is read only, so only save/restore the other three
1388 * registers.
1423 */ 1389 */
1424 ubir = readl(sport->port.membase + UBIR); 1390 ubir = readl(sport->port.membase + UBIR);
1425 ubmr = readl(sport->port.membase + UBMR); 1391 ubmr = readl(sport->port.membase + UBMR);
@@ -2051,6 +2017,8 @@ static int serial_imx_probe_dt(struct imx_port *sport,
2051 if (of_get_property(np, "rts-gpios", NULL)) 2017 if (of_get_property(np, "rts-gpios", NULL))
2052 sport->have_rtsgpio = 1; 2018 sport->have_rtsgpio = 1;
2053 2019
2020 of_get_rs485_mode(np, &sport->port.rs485);
2021
2054 return 0; 2022 return 0;
2055} 2023}
2056#else 2024#else
@@ -2112,12 +2080,9 @@ static int serial_imx_probe(struct platform_device *pdev)
2112 sport->port.fifosize = 32; 2080 sport->port.fifosize = 32;
2113 sport->port.ops = &imx_pops; 2081 sport->port.ops = &imx_pops;
2114 sport->port.rs485_config = imx_rs485_config; 2082 sport->port.rs485_config = imx_rs485_config;
2115 sport->port.rs485.flags = 2083 sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
2116 SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX;
2117 sport->port.flags = UPF_BOOT_AUTOCONF; 2084 sport->port.flags = UPF_BOOT_AUTOCONF;
2118 init_timer(&sport->timer); 2085 setup_timer(&sport->timer, imx_timeout, (unsigned long)sport);
2119 sport->timer.function = imx_timeout;
2120 sport->timer.data = (unsigned long)sport;
2121 2086
2122 sport->gpios = mctrl_gpio_init(&sport->port, 0); 2087 sport->gpios = mctrl_gpio_init(&sport->port, 0);
2123 if (IS_ERR(sport->gpios)) 2088 if (IS_ERR(sport->gpios))
@@ -2346,11 +2311,39 @@ static int imx_serial_port_resume(struct device *dev)
2346 return 0; 2311 return 0;
2347} 2312}
2348 2313
2314static int imx_serial_port_freeze(struct device *dev)
2315{
2316 struct platform_device *pdev = to_platform_device(dev);
2317 struct imx_port *sport = platform_get_drvdata(pdev);
2318
2319 uart_suspend_port(&imx_reg, &sport->port);
2320
2321 /* Needed to enable clock in suspend_noirq */
2322 return clk_prepare(sport->clk_ipg);
2323}
2324
2325static int imx_serial_port_thaw(struct device *dev)
2326{
2327 struct platform_device *pdev = to_platform_device(dev);
2328 struct imx_port *sport = platform_get_drvdata(pdev);
2329
2330 uart_resume_port(&imx_reg, &sport->port);
2331
2332 clk_unprepare(sport->clk_ipg);
2333
2334 return 0;
2335}
2336
2349static const struct dev_pm_ops imx_serial_port_pm_ops = { 2337static const struct dev_pm_ops imx_serial_port_pm_ops = {
2350 .suspend_noirq = imx_serial_port_suspend_noirq, 2338 .suspend_noirq = imx_serial_port_suspend_noirq,
2351 .resume_noirq = imx_serial_port_resume_noirq, 2339 .resume_noirq = imx_serial_port_resume_noirq,
2340 .freeze_noirq = imx_serial_port_suspend_noirq,
2341 .restore_noirq = imx_serial_port_resume_noirq,
2352 .suspend = imx_serial_port_suspend, 2342 .suspend = imx_serial_port_suspend,
2353 .resume = imx_serial_port_resume, 2343 .resume = imx_serial_port_resume,
2344 .freeze = imx_serial_port_freeze,
2345 .thaw = imx_serial_port_thaw,
2346 .restore = imx_serial_port_thaw,
2354}; 2347};
2355 2348
2356static struct platform_driver serial_imx_driver = { 2349static struct platform_driver serial_imx_driver = {
diff --git a/drivers/tty/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c
index 906ee770ff4a..d8a1cdd6a53d 100644
--- a/drivers/tty/serial/ioc3_serial.c
+++ b/drivers/tty/serial/ioc3_serial.c
@@ -1,8 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. 3 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved.
7 */ 4 */
8 5
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 43d7d32eb150..db5b979e5a0c 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1,8 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003-2006 Silicon Graphics, Inc. All Rights Reserved. 3 * Copyright (C) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 4 */
8 5
diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 7ddddb4c3844..8c810733df3d 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for Zilog serial chips found on SGI workstations and 3 * Driver for Zilog serial chips found on SGI workstations and
3 * servers. This driver could actually be made more generic. 4 * servers. This driver could actually be made more generic.
diff --git a/drivers/tty/serial/jsm/jsm.h b/drivers/tty/serial/jsm/jsm.h
index 0b79b87df47d..7a128aaa3a66 100644
--- a/drivers/tty/serial/jsm/jsm.h
+++ b/drivers/tty/serial/jsm/jsm.h
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * Copyright 2003 Digi International (www.digi.com) 3 * Copyright 2003 Digi International (www.digi.com)
3 * 4 *
4 * Copyright (C) 2004 IBM Corporation. All rights reserved. 5 * Copyright (C) 2004 IBM Corporation. All rights reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * Contact Information: 7 * Contact Information:
17 * Scott H Kilau <Scott_Kilau@digi.com> 8 * Scott H Kilau <Scott_Kilau@digi.com>
18 * Wendy Xiong <wendyx@us.ibm.com> 9 * Wendy Xiong <wendyx@us.ibm.com>
diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
index 4eb12a9cae76..c061a7b7bd23 100644
--- a/drivers/tty/serial/jsm/jsm_cls.c
+++ b/drivers/tty/serial/jsm/jsm_cls.c
@@ -1,17 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2003 Digi International (www.digi.com) 3 * Copyright 2003 Digi International (www.digi.com)
3 * Scott H Kilau <Scott_Kilau at digi dot com> 4 * Scott H Kilau <Scott_Kilau at digi dot com>
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
12 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
14 *
15 * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! 6 * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE!
16 * 7 *
17 * This is shared code between Digi's CVS archive and the 8 * This is shared code between Digi's CVS archive and the
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 102d499814ac..592e51d8944e 100644
--- a/drivers/tty/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * Copyright 2003 Digi International (www.digi.com) 3 * Copyright 2003 Digi International (www.digi.com)
3 * 4 *
4 * Copyright (C) 2004 IBM Corporation. All rights reserved. 5 * Copyright (C) 2004 IBM Corporation. All rights reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * Contact Information: 7 * Contact Information:
17 * Scott H Kilau <Scott_Kilau@digi.com> 8 * Scott H Kilau <Scott_Kilau@digi.com>
18 * Wendy Xiong <wendyx@us.ibm.com> 9 * Wendy Xiong <wendyx@us.ibm.com>
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index c6fdd6369534..4718560b8fdc 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * Copyright 2003 Digi International (www.digi.com) 3 * Copyright 2003 Digi International (www.digi.com)
3 * 4 *
4 * Copyright (C) 2004 IBM Corporation. All rights reserved. 5 * Copyright (C) 2004 IBM Corporation. All rights reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * Contact Information: 7 * Contact Information:
17 * Scott H Kilau <Scott_Kilau@digi.com> 8 * Scott H Kilau <Scott_Kilau@digi.com>
18 * Wendy Xiong <wendyx@us.ibm.com> 9 * Wendy Xiong <wendyx@us.ibm.com>
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index ec7d8383900f..469927d37b41 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * Copyright 2003 Digi International (www.digi.com) 3 * Copyright 2003 Digi International (www.digi.com)
3 * 4 *
4 * Copyright (C) 2004 IBM Corporation. All rights reserved. 5 * Copyright (C) 2004 IBM Corporation. All rights reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * Contact Information: 7 * Contact Information:
17 * Scott H Kilau <Scott_Kilau@digi.com> 8 * Scott H Kilau <Scott_Kilau@digi.com>
18 * Ananda Venkatarman <mansarov@us.ibm.com> 9 * Ananda Venkatarman <mansarov@us.ibm.com>
@@ -36,7 +27,7 @@ static void jsm_carrier(struct jsm_channel *ch);
36static inline int jsm_get_mstat(struct jsm_channel *ch) 27static inline int jsm_get_mstat(struct jsm_channel *ch)
37{ 28{
38 unsigned char mstat; 29 unsigned char mstat;
39 unsigned result; 30 int result;
40 31
41 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "start\n"); 32 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "start\n");
42 33
@@ -124,6 +115,7 @@ static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
124static void jsm_tty_write(struct uart_port *port) 115static void jsm_tty_write(struct uart_port *port)
125{ 116{
126 struct jsm_channel *channel; 117 struct jsm_channel *channel;
118
127 channel = container_of(port, struct jsm_channel, uart_port); 119 channel = container_of(port, struct jsm_channel, uart_port);
128 channel->ch_bd->bd_ops->copy_data_from_queue_to_uart(channel); 120 channel->ch_bd->bd_ops->copy_data_from_queue_to_uart(channel);
129} 121}
@@ -275,14 +267,12 @@ static int jsm_tty_open(struct uart_port *port)
275static void jsm_tty_close(struct uart_port *port) 267static void jsm_tty_close(struct uart_port *port)
276{ 268{
277 struct jsm_board *bd; 269 struct jsm_board *bd;
278 struct ktermios *ts;
279 struct jsm_channel *channel = 270 struct jsm_channel *channel =
280 container_of(port, struct jsm_channel, uart_port); 271 container_of(port, struct jsm_channel, uart_port);
281 272
282 jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "start\n"); 273 jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "start\n");
283 274
284 bd = channel->ch_bd; 275 bd = channel->ch_bd;
285 ts = &port->state->port.tty->termios;
286 276
287 channel->ch_flags &= ~(CH_STOPI); 277 channel->ch_flags &= ~(CH_STOPI);
288 278
@@ -473,12 +463,11 @@ int jsm_uart_port_init(struct jsm_board *brd)
473 } else 463 } else
474 set_bit(line, linemap); 464 set_bit(line, linemap);
475 brd->channels[i]->uart_port.line = line; 465 brd->channels[i]->uart_port.line = line;
476 rc = uart_add_one_port (&jsm_uart_driver, &brd->channels[i]->uart_port); 466 rc = uart_add_one_port(&jsm_uart_driver, &brd->channels[i]->uart_port);
477 if (rc){ 467 if (rc) {
478 printk(KERN_INFO "jsm: Port %d failed. Aborting...\n", i); 468 printk(KERN_INFO "jsm: Port %d failed. Aborting...\n", i);
479 return rc; 469 return rc;
480 } 470 } else
481 else
482 printk(KERN_INFO "jsm: Port %d added\n", i); 471 printk(KERN_INFO "jsm: Port %d added\n", i);
483 } 472 }
484 473
@@ -541,7 +530,7 @@ void jsm_input(struct jsm_channel *ch)
541 tp = port->tty; 530 tp = port->tty;
542 531
543 bd = ch->ch_bd; 532 bd = ch->ch_bd;
544 if(!bd) 533 if (!bd)
545 return; 534 return;
546 535
547 spin_lock_irqsave(&ch->ch_lock, lock_flags); 536 spin_lock_irqsave(&ch->ch_lock, lock_flags);
@@ -781,7 +770,7 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
781 if (qleft < 256) { 770 if (qleft < 256) {
782 /* HWFLOW */ 771 /* HWFLOW */
783 if (ch->ch_c_cflag & CRTSCTS) { 772 if (ch->ch_c_cflag & CRTSCTS) {
784 if(!(ch->ch_flags & CH_RECEIVER_OFF)) { 773 if (!(ch->ch_flags & CH_RECEIVER_OFF)) {
785 bd_ops->disable_receiver(ch); 774 bd_ops->disable_receiver(ch);
786 ch->ch_flags |= (CH_RECEIVER_OFF); 775 ch->ch_flags |= (CH_RECEIVER_OFF);
787 jsm_dbg(READ, &ch->ch_bd->pci_dev, 776 jsm_dbg(READ, &ch->ch_bd->pci_dev,
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 117df151627d..ed2b03058627 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * KGDB NMI serial console 3 * KGDB NMI serial console
3 * 4 *
@@ -6,10 +7,6 @@
6 * Colin Cross <ccross@android.com> 7 * Colin Cross <ccross@android.com>
7 * Copyright 2012 Linaro Ltd. 8 * Copyright 2012 Linaro Ltd.
8 * Anton Vorontsov <anton.vorontsov@linaro.org> 9 * Anton Vorontsov <anton.vorontsov@linaro.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */ 10 */
14 11
15#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
index a260cde743e2..ddb46fa2d07f 100644
--- a/drivers/tty/serial/kgdboc.c
+++ b/drivers/tty/serial/kgdboc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Based on the same principle as kgdboe using the NETPOLL api, this 3 * Based on the same principle as kgdboe using the NETPOLL api, this
3 * driver uses a console polling api to implement a gdb serial inteface 4 * driver uses a console polling api to implement a gdb serial inteface
@@ -6,10 +7,6 @@
6 * Maintainer: Jason Wessel <jason.wessel@windriver.com> 7 * Maintainer: Jason Wessel <jason.wessel@windriver.com>
7 * 8 *
8 * 2007-2008 (c) Jason Wessel - Wind River Systems, Inc. 9 * 2007-2008 (c) Jason Wessel - Wind River Systems, Inc.
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 */ 10 */
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/ctype.h> 12#include <linux/ctype.h>
diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
index 22df94f107e5..044128277248 100644
--- a/drivers/tty/serial/lantiq.c
+++ b/drivers/tty/serial/lantiq.c
@@ -1,19 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 3 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Copyright (C) 2004 Infineon IFAP DC COM CPE 5 * Copyright (C) 2004 Infineon IFAP DC COM CPE
18 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org> 6 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
19 * Copyright (C) 2007 John Crispin <john@phrozen.org> 7 * Copyright (C) 2007 John Crispin <john@phrozen.org>
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index cea57ff32c33..d1d73261575b 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * High Speed Serial Ports on NXP LPC32xx SoC 3 * High Speed Serial Ports on NXP LPC32xx SoC
3 * 4 *
@@ -6,16 +7,6 @@
6 * 7 *
7 * Copyright (C) 2010 NXP Semiconductors 8 * Copyright (C) 2010 NXP Semiconductors
8 * Copyright (C) 2012 Roland Stigge 9 * Copyright (C) 2012 Roland Stigge
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 */ 10 */
20 11
21#include <linux/module.h> 12#include <linux/module.h>
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index 5b3bd9511993..7b83a8aab495 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * m32r_sio.c 3 * m32r_sio.c
3 * 4 *
@@ -8,11 +9,6 @@
8 * 9 *
9 * Copyright (C) 2001 Russell King. 10 * Copyright (C) 2001 Russell King.
10 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> 11 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */ 12 */
17 13
18/* 14/*
@@ -511,9 +507,9 @@ static void serial_unlink_irq_chain(struct uart_sio_port *up)
511/* 507/*
512 * This function is used to handle ports that do not have an interrupt. 508 * This function is used to handle ports that do not have an interrupt.
513 */ 509 */
514static void m32r_sio_timeout(unsigned long data) 510static void m32r_sio_timeout(struct timer_list *t)
515{ 511{
516 struct uart_sio_port *up = (struct uart_sio_port *)data; 512 struct uart_sio_port *up = from_timer(up, t, timer);
517 unsigned int timeout; 513 unsigned int timeout;
518 unsigned int sts; 514 unsigned int sts;
519 515
@@ -576,7 +572,6 @@ static int m32r_sio_startup(struct uart_port *port)
576 572
577 timeout = timeout > 6 ? (timeout / 2 - 2) : 1; 573 timeout = timeout > 6 ? (timeout / 2 - 2) : 1;
578 574
579 up->timer.data = (unsigned long)up;
580 mod_timer(&up->timer, jiffies + timeout); 575 mod_timer(&up->timer, jiffies + timeout);
581 } else { 576 } else {
582 retval = serial_link_irq_chain(up); 577 retval = serial_link_irq_chain(up);
@@ -907,8 +902,7 @@ static void __init m32r_sio_register_ports(struct uart_driver *drv)
907 902
908 up->port.line = i; 903 up->port.line = i;
909 up->port.ops = &m32r_sio_pops; 904 up->port.ops = &m32r_sio_pops;
910 init_timer(&up->timer); 905 timer_setup(&up->timer, m32r_sio_timeout, 0);
911 up->timer.function = m32r_sio_timeout;
912 906
913 uart_add_one_port(drv, &up->port); 907 uart_add_one_port(drv, &up->port);
914 } 908 }
diff --git a/drivers/tty/serial/m32r_sio_reg.h b/drivers/tty/serial/m32r_sio_reg.h
index 4671473793e3..6eed48828f94 100644
--- a/drivers/tty/serial/m32r_sio_reg.h
+++ b/drivers/tty/serial/m32r_sio_reg.h
@@ -1,12 +1,10 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * m32r_sio_reg.h 3 * m32r_sio_reg.h
3 * 4 *
4 * Copyright (C) 1992, 1994 by Theodore Ts'o. 5 * Copyright (C) 1992, 1994 by Theodore Ts'o.
5 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> 6 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
6 * 7 *
7 * Redistribution of this file is permitted under the terms of the GNU
8 * Public License (GPL)
9 *
10 * These are the UART port assignments, expressed as offsets from the base 8 * These are the UART port assignments, expressed as offsets from the base
11 * register. These assignments should hold for any serial port based on 9 * register. These assignments should hold for any serial port based on
12 * a 8250, 16450, or 16550(A). 10 * a 8250, 16450, or 16550(A).
diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
index ace82645b123..27d6049eb6a9 100644
--- a/drivers/tty/serial/max3100.c
+++ b/drivers/tty/serial/max3100.c
@@ -1,13 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * 3 *
3 * Copyright (C) 2008 Christian Pellegrin <chripell@evolware.org> 4 * Copyright (C) 2008 Christian Pellegrin <chripell@evolware.org>
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 *
11 * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have 6 * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
12 * to use polling for flow control. TX empty IRQ is unusable, since 7 * to use polling for flow control. TX empty IRQ is unusable, since
13 * writing conf clears FIFO buffer and we cannot have this interrupt 8 * writing conf clears FIFO buffer and we cannot have this interrupt
@@ -263,7 +258,7 @@ static void max3100_work(struct work_struct *w)
263 struct max3100_port *s = container_of(w, struct max3100_port, work); 258 struct max3100_port *s = container_of(w, struct max3100_port, work);
264 int rxchars; 259 int rxchars;
265 u16 tx, rx; 260 u16 tx, rx;
266 int conf, cconf, rts, crts; 261 int conf, cconf, crts;
267 struct circ_buf *xmit = &s->port.state->xmit; 262 struct circ_buf *xmit = &s->port.state->xmit;
268 263
269 dev_dbg(&s->spi->dev, "%s\n", __func__); 264 dev_dbg(&s->spi->dev, "%s\n", __func__);
@@ -274,7 +269,6 @@ static void max3100_work(struct work_struct *w)
274 conf = s->conf; 269 conf = s->conf;
275 cconf = s->conf_commit; 270 cconf = s->conf_commit;
276 s->conf_commit = 0; 271 s->conf_commit = 0;
277 rts = s->rts;
278 crts = s->rts_commit; 272 crts = s->rts_commit;
279 s->rts_commit = 0; 273 s->rts_commit = 0;
280 spin_unlock(&s->conf_lock); 274 spin_unlock(&s->conf_lock);
@@ -436,7 +430,6 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios,
436 dev_dbg(&s->spi->dev, "%s\n", __func__); 430 dev_dbg(&s->spi->dev, "%s\n", __func__);
437 431
438 cflag = termios->c_cflag; 432 cflag = termios->c_cflag;
439 param_new = 0;
440 param_mask = 0; 433 param_mask = 0;
441 434
442 baud = tty_termios_baud_rate(termios); 435 baud = tty_termios_baud_rate(termios);
@@ -787,9 +780,8 @@ static int max3100_probe(struct spi_device *spi)
787 max3100s[i]->poll_time = 1; 780 max3100s[i]->poll_time = 1;
788 max3100s[i]->max3100_hw_suspend = pdata->max3100_hw_suspend; 781 max3100s[i]->max3100_hw_suspend = pdata->max3100_hw_suspend;
789 max3100s[i]->minor = i; 782 max3100s[i]->minor = i;
790 init_timer(&max3100s[i]->timer); 783 setup_timer(&max3100s[i]->timer, max3100_timeout,
791 max3100s[i]->timer.function = max3100_timeout; 784 (unsigned long)max3100s[i]);
792 max3100s[i]->timer.data = (unsigned long) max3100s[i];
793 785
794 dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i); 786 dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i);
795 max3100s[i]->port.irq = max3100s[i]->irq; 787 max3100s[i]->port.irq = max3100s[i]->irq;
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 9dfedbe6c071..ecb6513a6505 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Maxim (Dallas) MAX3107/8/9, MAX14830 serial driver 3 * Maxim (Dallas) MAX3107/8/9, MAX14830 serial driver
3 * 4 *
@@ -6,11 +7,6 @@
6 * Based on max3100.c, by Christian Pellegrin <chripell@evolware.org> 7 * Based on max3100.c, by Christian Pellegrin <chripell@evolware.org>
7 * Based on max3110.c, by Feng Tang <feng.tang@intel.com> 8 * Based on max3110.c, by Feng Tang <feng.tang@intel.com>
8 * Based on max3107.c, by Aavamobile 9 * Based on max3107.c, by Aavamobile
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */ 10 */
15 11
16#include <linux/bitops.h> 12#include <linux/bitops.h>
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 02eb32217685..7dbfb4cde124 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/****************************************************************************/ 2/****************************************************************************/
2 3
3/* 4/*
4 * mcf.c -- Freescale ColdFire UART driver 5 * mcf.c -- Freescale ColdFire UART driver
5 * 6 *
6 * (C) Copyright 2003-2007, Greg Ungerer <gerg@uclinux.org> 7 * (C) Copyright 2003-2007, Greg Ungerer <gerg@uclinux.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14/****************************************************************************/ 10/****************************************************************************/
diff --git a/drivers/tty/serial/men_z135_uart.c b/drivers/tty/serial/men_z135_uart.c
index e72ea61c70db..ef89534dd760 100644
--- a/drivers/tty/serial/men_z135_uart.c
+++ b/drivers/tty/serial/men_z135_uart.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MEN 16z135 High Speed UART 3 * MEN 16z135 High Speed UART
3 * 4 *
4 * Copyright (C) 2014 MEN Mikroelektronik GmbH (www.men.de) 5 * Copyright (C) 2014 MEN Mikroelektronik GmbH (www.men.de)
5 * Author: Johannes Thumshirn <johannes.thumshirn@men.de> 6 * Author: Johannes Thumshirn <johannes.thumshirn@men.de>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; version 2 of the License.
10 */ 7 */
11#define pr_fmt(fmt) KBUILD_MODNAME ":" fmt 8#define pr_fmt(fmt) KBUILD_MODNAME ":" fmt
12 9
diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 07c0f98be3ac..daafe60175da 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -1,19 +1,14 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Based on meson_uart.c, by AMLOGIC, INC. 3 * Based on meson_uart.c, by AMLOGIC, INC.
3 * 4 *
4 * Copyright (C) 2014 Carlo Caione <carlo@caione.org> 5 * Copyright (C) 2014 Carlo Caione <carlo@caione.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */ 6 */
16 7
8#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
9#define SUPPORT_SYSRQ
10#endif
11
17#include <linux/clk.h> 12#include <linux/clk.h>
18#include <linux/console.h> 13#include <linux/console.h>
19#include <linux/delay.h> 14#include <linux/delay.h>
@@ -183,12 +178,12 @@ static void meson_receive_chars(struct uart_port *port)
183{ 178{
184 struct tty_port *tport = &port->state->port; 179 struct tty_port *tport = &port->state->port;
185 char flag; 180 char flag;
186 u32 status, ch, mode; 181 u32 ostatus, status, ch, mode;
187 182
188 do { 183 do {
189 flag = TTY_NORMAL; 184 flag = TTY_NORMAL;
190 port->icount.rx++; 185 port->icount.rx++;
191 status = readl(port->membase + AML_UART_STATUS); 186 ostatus = status = readl(port->membase + AML_UART_STATUS);
192 187
193 if (status & AML_UART_ERR) { 188 if (status & AML_UART_ERR) {
194 if (status & AML_UART_TX_FIFO_WERR) 189 if (status & AML_UART_TX_FIFO_WERR)
@@ -216,6 +211,16 @@ static void meson_receive_chars(struct uart_port *port)
216 ch = readl(port->membase + AML_UART_RFIFO); 211 ch = readl(port->membase + AML_UART_RFIFO);
217 ch &= 0xff; 212 ch &= 0xff;
218 213
214 if ((ostatus & AML_UART_FRAME_ERR) && (ch == 0)) {
215 port->icount.brk++;
216 flag = TTY_BREAK;
217 if (uart_handle_break(port))
218 continue;
219 }
220
221 if (uart_handle_sysrq_char(port, ch))
222 continue;
223
219 if ((status & port->ignore_status_mask) == 0) 224 if ((status & port->ignore_status_mask) == 0)
220 tty_insert_flip_char(tport, ch, flag); 225 tty_insert_flip_char(tport, ch, flag);
221 226
@@ -362,7 +367,7 @@ static void meson_uart_set_termios(struct uart_port *port,
362 367
363 writel(val, port->membase + AML_UART_CONTROL); 368 writel(val, port->membase + AML_UART_CONTROL);
364 369
365 baud = uart_get_baud_rate(port, termios, old, 9600, 4000000); 370 baud = uart_get_baud_rate(port, termios, old, 50, 4000000);
366 meson_uart_change_speed(port, baud); 371 meson_uart_change_speed(port, baud);
367 372
368 port->read_status_mask = AML_UART_TX_FIFO_WERR; 373 port->read_status_mask = AML_UART_TX_FIFO_WERR;
diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 791c4c74f6d6..3a75ee08d619 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs. 3 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs.
3 * 4 *
@@ -23,10 +24,6 @@
23 * Grant Likely <grant.likely@secretlab.ca> 24 * Grant Likely <grant.likely@secretlab.ca>
24 * Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com> 25 * Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com>
25 * Copyright (C) 2003 MontaVista, Software, Inc. 26 * Copyright (C) 2003 MontaVista, Software, Inc.
26 *
27 * This file is licensed under the terms of the GNU General Public License
28 * version 2. This program is licensed "as is" without any warranty of any
29 * kind, whether express or implied.
30 */ 27 */
31 28
32#undef DEBUG 29#undef DEBUG
diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 492ec4b375a0..9f8f63719126 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MPS2 UART driver 3 * MPS2 UART driver
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Author: Vladimir Murzin <vladimir.murzin@arm.com> 7 * Author: Vladimir Murzin <vladimir.murzin@arm.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * TODO: support for SysRq 9 * TODO: support for SysRq
13 */ 10 */
14 11
diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 67ffecc50e42..1f60d6fe4ff2 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Generic driver for the MPSC (UART mode) on Marvell parts (e.g., GT64240, 3 * Generic driver for the MPSC (UART mode) on Marvell parts (e.g., GT64240,
3 * GT64260, MV64340, MV64360, GT96100, ... ). 4 * GT64260, MV64340, MV64360, GT96100, ... ).
@@ -10,10 +11,7 @@
10 * taken from PPCBoot (now U-Boot). Also based on drivers/serial/8250.c 11 * taken from PPCBoot (now U-Boot). Also based on drivers/serial/8250.c
11 * by Russell King. 12 * by Russell King.
12 * 13 *
13 * 2004 (c) MontaVista, Software, Inc. This file is licensed under 14 * 2004 (c) MontaVista, Software, Inc.
14 * the terms of the GNU General Public License version 2. This program
15 * is licensed "as is" without any warranty of any kind, whether express
16 * or implied.
17 */ 15 */
18/* 16/*
19 * The MPSC interface is much like a typical network controller's interface. 17 * The MPSC interface is much like a typical network controller's interface.
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 1db79ee8a886..ee96cf0d0057 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for msm7k serial device and console 3 * Driver for msm7k serial device and console
3 * 4 *
4 * Copyright (C) 2007 Google, Inc. 5 * Copyright (C) 2007 Google, Inc.
5 * Author: Robert Love <rlove@google.com> 6 * Author: Robert Love <rlove@google.com>
6 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 7 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#if defined(CONFIG_SERIAL_MSM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 10#if defined(CONFIG_SERIAL_MSM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c
index 2bff69e70e4b..3b74369c262f 100644
--- a/drivers/tty/serial/mux.c
+++ b/drivers/tty/serial/mux.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2** mux.c: 3** mux.c:
3** serial driver for the Mux console found in some PA-RISC servers. 4** serial driver for the Mux console found in some PA-RISC servers.
@@ -5,11 +6,6 @@
5** (c) Copyright 2002 Ryan Bradetich 6** (c) Copyright 2002 Ryan Bradetich
6** (c) Copyright 2002 Hewlett-Packard Company 7** (c) Copyright 2002 Hewlett-Packard Company
7** 8**
8** This program is free software; you can redistribute it and/or modify
9** it under the terms of the GNU General Public License as published by
10** the Free Software Foundation; either version 2 of the License, or
11** (at your option) any later version.
12**
13** This Driver currently only supports the console (port 0) on the MUX. 9** This Driver currently only supports the console (port 0) on the MUX.
14** Additional work will be needed on this driver to enable the full 10** Additional work will be needed on this driver to enable the full
15** functionality of the MUX. 11** functionality of the MUX.
@@ -576,8 +572,7 @@ static int __init mux_init(void)
576 572
577 if(port_cnt > 0) { 573 if(port_cnt > 0) {
578 /* Start the Mux timer */ 574 /* Start the Mux timer */
579 init_timer(&mux_timer); 575 setup_timer(&mux_timer, mux_poll, 0UL);
580 mux_timer.function = mux_poll;
581 mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY); 576 mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
582 577
583#ifdef CONFIG_SERIAL_MUX_CONSOLE 578#ifdef CONFIG_SERIAL_MUX_CONSOLE
diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
index 45b57c294d13..a100e98259d7 100644
--- a/drivers/tty/serial/mvebu-uart.c
+++ b/drivers/tty/serial/mvebu-uart.c
@@ -1,21 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2* *************************************************************************** 3* ***************************************************************************
3* Marvell Armada-3700 Serial Driver 4* Marvell Armada-3700 Serial Driver
4* Author: Wilson Ding <dingwei@marvell.com> 5* Author: Wilson Ding <dingwei@marvell.com>
5* Copyright (C) 2015 Marvell International Ltd. 6* Copyright (C) 2015 Marvell International Ltd.
6* *************************************************************************** 7* ***************************************************************************
7* This program is free software: you can redistribute it and/or modify it
8* under the terms of the GNU General Public License as published by the Free
9* Software Foundation, either version 2 of the License, or any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program. If not, see <http://www.gnu.org/licenses/>.
18* ***************************************************************************
19*/ 8*/
20 9
21#include <linux/clk.h> 10#include <linux/clk.h>
@@ -38,46 +27,40 @@
38#include <linux/tty_flip.h> 27#include <linux/tty_flip.h>
39 28
40/* Register Map */ 29/* Register Map */
41#define UART_RBR 0x00 30#define UART_STD_RBR 0x00
42#define RBR_BRK_DET BIT(15) 31#define UART_EXT_RBR 0x18
43#define RBR_FRM_ERR_DET BIT(14)
44#define RBR_PAR_ERR_DET BIT(13)
45#define RBR_OVR_ERR_DET BIT(12)
46 32
47#define UART_TSH 0x04 33#define UART_STD_TSH 0x04
34#define UART_EXT_TSH 0x1C
48 35
49#define UART_CTRL 0x08 36#define UART_STD_CTRL1 0x08
37#define UART_EXT_CTRL1 0x04
50#define CTRL_SOFT_RST BIT(31) 38#define CTRL_SOFT_RST BIT(31)
51#define CTRL_TXFIFO_RST BIT(15) 39#define CTRL_TXFIFO_RST BIT(15)
52#define CTRL_RXFIFO_RST BIT(14) 40#define CTRL_RXFIFO_RST BIT(14)
53#define CTRL_ST_MIRR_EN BIT(13)
54#define CTRL_LPBK_EN BIT(12)
55#define CTRL_SND_BRK_SEQ BIT(11) 41#define CTRL_SND_BRK_SEQ BIT(11)
56#define CTRL_PAR_EN BIT(10)
57#define CTRL_TWO_STOP BIT(9)
58#define CTRL_TX_HFL_INT BIT(8)
59#define CTRL_RX_HFL_INT BIT(7)
60#define CTRL_TX_EMP_INT BIT(6)
61#define CTRL_TX_RDY_INT BIT(5)
62#define CTRL_RX_RDY_INT BIT(4)
63#define CTRL_BRK_DET_INT BIT(3) 42#define CTRL_BRK_DET_INT BIT(3)
64#define CTRL_FRM_ERR_INT BIT(2) 43#define CTRL_FRM_ERR_INT BIT(2)
65#define CTRL_PAR_ERR_INT BIT(1) 44#define CTRL_PAR_ERR_INT BIT(1)
66#define CTRL_OVR_ERR_INT BIT(0) 45#define CTRL_OVR_ERR_INT BIT(0)
67#define CTRL_RX_INT (CTRL_RX_RDY_INT | CTRL_BRK_DET_INT |\ 46#define CTRL_BRK_INT (CTRL_BRK_DET_INT | CTRL_FRM_ERR_INT | \
68 CTRL_FRM_ERR_INT | CTRL_PAR_ERR_INT | CTRL_OVR_ERR_INT) 47 CTRL_PAR_ERR_INT | CTRL_OVR_ERR_INT)
48
49#define UART_STD_CTRL2 UART_STD_CTRL1
50#define UART_EXT_CTRL2 0x20
51#define CTRL_STD_TX_RDY_INT BIT(5)
52#define CTRL_EXT_TX_RDY_INT BIT(6)
53#define CTRL_STD_RX_RDY_INT BIT(4)
54#define CTRL_EXT_RX_RDY_INT BIT(5)
69 55
70#define UART_STAT 0x0c 56#define UART_STAT 0x0C
71#define STAT_TX_FIFO_EMP BIT(13) 57#define STAT_TX_FIFO_EMP BIT(13)
72#define STAT_RX_FIFO_EMP BIT(12)
73#define STAT_TX_FIFO_FUL BIT(11) 58#define STAT_TX_FIFO_FUL BIT(11)
74#define STAT_TX_FIFO_HFL BIT(10)
75#define STAT_RX_TOGL BIT(9)
76#define STAT_RX_FIFO_FUL BIT(8)
77#define STAT_RX_FIFO_HFL BIT(7)
78#define STAT_TX_EMP BIT(6) 59#define STAT_TX_EMP BIT(6)
79#define STAT_TX_RDY BIT(5) 60#define STAT_STD_TX_RDY BIT(5)
80#define STAT_RX_RDY BIT(4) 61#define STAT_EXT_TX_RDY BIT(15)
62#define STAT_STD_RX_RDY BIT(4)
63#define STAT_EXT_RX_RDY BIT(14)
81#define STAT_BRK_DET BIT(3) 64#define STAT_BRK_DET BIT(3)
82#define STAT_FRM_ERR BIT(2) 65#define STAT_FRM_ERR BIT(2)
83#define STAT_PAR_ERR BIT(1) 66#define STAT_PAR_ERR BIT(1)
@@ -86,18 +69,73 @@
86 | STAT_PAR_ERR | STAT_OVR_ERR) 69 | STAT_PAR_ERR | STAT_OVR_ERR)
87 70
88#define UART_BRDV 0x10 71#define UART_BRDV 0x10
72#define BRDV_BAUD_MASK 0x3FF
89 73
90#define MVEBU_NR_UARTS 1 74#define MVEBU_NR_UARTS 2
91 75
92#define MVEBU_UART_TYPE "mvebu-uart" 76#define MVEBU_UART_TYPE "mvebu-uart"
77#define DRIVER_NAME "mvebu_serial"
78
79enum {
80 /* Either there is only one summed IRQ... */
81 UART_IRQ_SUM = 0,
82 /* ...or there are two separate IRQ for RX and TX */
83 UART_RX_IRQ = 0,
84 UART_TX_IRQ,
85 UART_IRQ_COUNT
86};
93 87
94static struct uart_port mvebu_uart_ports[MVEBU_NR_UARTS]; 88/* Diverging register offsets */
89struct uart_regs_layout {
90 unsigned int rbr;
91 unsigned int tsh;
92 unsigned int ctrl;
93 unsigned int intr;
94};
95
96/* Diverging flags */
97struct uart_flags {
98 unsigned int ctrl_tx_rdy_int;
99 unsigned int ctrl_rx_rdy_int;
100 unsigned int stat_tx_rdy;
101 unsigned int stat_rx_rdy;
102};
103
104/* Driver data, a structure for each UART port */
105struct mvebu_uart_driver_data {
106 bool is_ext;
107 struct uart_regs_layout regs;
108 struct uart_flags flags;
109};
95 110
96struct mvebu_uart_data { 111/* MVEBU UART driver structure */
112struct mvebu_uart {
97 struct uart_port *port; 113 struct uart_port *port;
98 struct clk *clk; 114 struct clk *clk;
115 int irq[UART_IRQ_COUNT];
116 unsigned char __iomem *nb;
117 struct mvebu_uart_driver_data *data;
99}; 118};
100 119
120static struct mvebu_uart *to_mvuart(struct uart_port *port)
121{
122 return (struct mvebu_uart *)port->private_data;
123}
124
125#define IS_EXTENDED(port) (to_mvuart(port)->data->is_ext)
126
127#define UART_RBR(port) (to_mvuart(port)->data->regs.rbr)
128#define UART_TSH(port) (to_mvuart(port)->data->regs.tsh)
129#define UART_CTRL(port) (to_mvuart(port)->data->regs.ctrl)
130#define UART_INTR(port) (to_mvuart(port)->data->regs.intr)
131
132#define CTRL_TX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_tx_rdy_int)
133#define CTRL_RX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_rx_rdy_int)
134#define STAT_TX_RDY(port) (to_mvuart(port)->data->flags.stat_tx_rdy)
135#define STAT_RX_RDY(port) (to_mvuart(port)->data->flags.stat_rx_rdy)
136
137static struct uart_port mvebu_uart_ports[MVEBU_NR_UARTS];
138
101/* Core UART Driver Operations */ 139/* Core UART Driver Operations */
102static unsigned int mvebu_uart_tx_empty(struct uart_port *port) 140static unsigned int mvebu_uart_tx_empty(struct uart_port *port)
103{ 141{
@@ -127,26 +165,39 @@ static void mvebu_uart_set_mctrl(struct uart_port *port,
127 165
128static void mvebu_uart_stop_tx(struct uart_port *port) 166static void mvebu_uart_stop_tx(struct uart_port *port)
129{ 167{
130 unsigned int ctl = readl(port->membase + UART_CTRL); 168 unsigned int ctl = readl(port->membase + UART_INTR(port));
131 169
132 ctl &= ~CTRL_TX_RDY_INT; 170 ctl &= ~CTRL_TX_RDY_INT(port);
133 writel(ctl, port->membase + UART_CTRL); 171 writel(ctl, port->membase + UART_INTR(port));
134} 172}
135 173
136static void mvebu_uart_start_tx(struct uart_port *port) 174static void mvebu_uart_start_tx(struct uart_port *port)
137{ 175{
138 unsigned int ctl = readl(port->membase + UART_CTRL); 176 unsigned int ctl;
177 struct circ_buf *xmit = &port->state->xmit;
178
179 if (IS_EXTENDED(port) && !uart_circ_empty(xmit)) {
180 writel(xmit->buf[xmit->tail], port->membase + UART_TSH(port));
181 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
182 port->icount.tx++;
183 }
139 184
140 ctl |= CTRL_TX_RDY_INT; 185 ctl = readl(port->membase + UART_INTR(port));
141 writel(ctl, port->membase + UART_CTRL); 186 ctl |= CTRL_TX_RDY_INT(port);
187 writel(ctl, port->membase + UART_INTR(port));
142} 188}
143 189
144static void mvebu_uart_stop_rx(struct uart_port *port) 190static void mvebu_uart_stop_rx(struct uart_port *port)
145{ 191{
146 unsigned int ctl = readl(port->membase + UART_CTRL); 192 unsigned int ctl;
193
194 ctl = readl(port->membase + UART_CTRL(port));
195 ctl &= ~CTRL_BRK_INT;
196 writel(ctl, port->membase + UART_CTRL(port));
147 197
148 ctl &= ~CTRL_RX_INT; 198 ctl = readl(port->membase + UART_INTR(port));
149 writel(ctl, port->membase + UART_CTRL); 199 ctl &= ~CTRL_RX_RDY_INT(port);
200 writel(ctl, port->membase + UART_INTR(port));
150} 201}
151 202
152static void mvebu_uart_break_ctl(struct uart_port *port, int brk) 203static void mvebu_uart_break_ctl(struct uart_port *port, int brk)
@@ -155,12 +206,12 @@ static void mvebu_uart_break_ctl(struct uart_port *port, int brk)
155 unsigned long flags; 206 unsigned long flags;
156 207
157 spin_lock_irqsave(&port->lock, flags); 208 spin_lock_irqsave(&port->lock, flags);
158 ctl = readl(port->membase + UART_CTRL); 209 ctl = readl(port->membase + UART_CTRL(port));
159 if (brk == -1) 210 if (brk == -1)
160 ctl |= CTRL_SND_BRK_SEQ; 211 ctl |= CTRL_SND_BRK_SEQ;
161 else 212 else
162 ctl &= ~CTRL_SND_BRK_SEQ; 213 ctl &= ~CTRL_SND_BRK_SEQ;
163 writel(ctl, port->membase + UART_CTRL); 214 writel(ctl, port->membase + UART_CTRL(port));
164 spin_unlock_irqrestore(&port->lock, flags); 215 spin_unlock_irqrestore(&port->lock, flags);
165} 216}
166 217
@@ -171,8 +222,8 @@ static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status)
171 char flag = 0; 222 char flag = 0;
172 223
173 do { 224 do {
174 if (status & STAT_RX_RDY) { 225 if (status & STAT_RX_RDY(port)) {
175 ch = readl(port->membase + UART_RBR); 226 ch = readl(port->membase + UART_RBR(port));
176 ch &= 0xff; 227 ch &= 0xff;
177 flag = TTY_NORMAL; 228 flag = TTY_NORMAL;
178 port->icount.rx++; 229 port->icount.rx++;
@@ -198,7 +249,7 @@ static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status)
198 goto ignore_char; 249 goto ignore_char;
199 250
200 if (status & port->ignore_status_mask & STAT_PAR_ERR) 251 if (status & port->ignore_status_mask & STAT_PAR_ERR)
201 status &= ~STAT_RX_RDY; 252 status &= ~STAT_RX_RDY(port);
202 253
203 status &= port->read_status_mask; 254 status &= port->read_status_mask;
204 255
@@ -207,7 +258,7 @@ static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status)
207 258
208 status &= ~port->ignore_status_mask; 259 status &= ~port->ignore_status_mask;
209 260
210 if (status & STAT_RX_RDY) 261 if (status & STAT_RX_RDY(port))
211 tty_insert_flip_char(tport, ch, flag); 262 tty_insert_flip_char(tport, ch, flag);
212 263
213 if (status & STAT_BRK_DET) 264 if (status & STAT_BRK_DET)
@@ -221,7 +272,7 @@ static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status)
221 272
222ignore_char: 273ignore_char:
223 status = readl(port->membase + UART_STAT); 274 status = readl(port->membase + UART_STAT);
224 } while (status & (STAT_RX_RDY | STAT_BRK_DET)); 275 } while (status & (STAT_RX_RDY(port) | STAT_BRK_DET));
225 276
226 tty_flip_buffer_push(tport); 277 tty_flip_buffer_push(tport);
227} 278}
@@ -233,7 +284,7 @@ static void mvebu_uart_tx_chars(struct uart_port *port, unsigned int status)
233 unsigned int st; 284 unsigned int st;
234 285
235 if (port->x_char) { 286 if (port->x_char) {
236 writel(port->x_char, port->membase + UART_TSH); 287 writel(port->x_char, port->membase + UART_TSH(port));
237 port->icount.tx++; 288 port->icount.tx++;
238 port->x_char = 0; 289 port->x_char = 0;
239 return; 290 return;
@@ -245,7 +296,7 @@ static void mvebu_uart_tx_chars(struct uart_port *port, unsigned int status)
245 } 296 }
246 297
247 for (count = 0; count < port->fifosize; count++) { 298 for (count = 0; count < port->fifosize; count++) {
248 writel(xmit->buf[xmit->tail], port->membase + UART_TSH); 299 writel(xmit->buf[xmit->tail], port->membase + UART_TSH(port));
249 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 300 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
250 port->icount.tx++; 301 port->icount.tx++;
251 302
@@ -269,10 +320,34 @@ static irqreturn_t mvebu_uart_isr(int irq, void *dev_id)
269 struct uart_port *port = (struct uart_port *)dev_id; 320 struct uart_port *port = (struct uart_port *)dev_id;
270 unsigned int st = readl(port->membase + UART_STAT); 321 unsigned int st = readl(port->membase + UART_STAT);
271 322
272 if (st & (STAT_RX_RDY | STAT_OVR_ERR | STAT_FRM_ERR | STAT_BRK_DET)) 323 if (st & (STAT_RX_RDY(port) | STAT_OVR_ERR | STAT_FRM_ERR |
324 STAT_BRK_DET))
273 mvebu_uart_rx_chars(port, st); 325 mvebu_uart_rx_chars(port, st);
274 326
275 if (st & STAT_TX_RDY) 327 if (st & STAT_TX_RDY(port))
328 mvebu_uart_tx_chars(port, st);
329
330 return IRQ_HANDLED;
331}
332
333static irqreturn_t mvebu_uart_rx_isr(int irq, void *dev_id)
334{
335 struct uart_port *port = (struct uart_port *)dev_id;
336 unsigned int st = readl(port->membase + UART_STAT);
337
338 if (st & (STAT_RX_RDY(port) | STAT_OVR_ERR | STAT_FRM_ERR |
339 STAT_BRK_DET))
340 mvebu_uart_rx_chars(port, st);
341
342 return IRQ_HANDLED;
343}
344
345static irqreturn_t mvebu_uart_tx_isr(int irq, void *dev_id)
346{
347 struct uart_port *port = (struct uart_port *)dev_id;
348 unsigned int st = readl(port->membase + UART_STAT);
349
350 if (st & STAT_TX_RDY(port))
276 mvebu_uart_tx_chars(port, st); 351 mvebu_uart_tx_chars(port, st);
277 352
278 return IRQ_HANDLED; 353 return IRQ_HANDLED;
@@ -280,18 +355,57 @@ static irqreturn_t mvebu_uart_isr(int irq, void *dev_id)
280 355
281static int mvebu_uart_startup(struct uart_port *port) 356static int mvebu_uart_startup(struct uart_port *port)
282{ 357{
358 struct mvebu_uart *mvuart = to_mvuart(port);
359 unsigned int ctl;
283 int ret; 360 int ret;
284 361
285 writel(CTRL_TXFIFO_RST | CTRL_RXFIFO_RST, 362 writel(CTRL_TXFIFO_RST | CTRL_RXFIFO_RST,
286 port->membase + UART_CTRL); 363 port->membase + UART_CTRL(port));
287 udelay(1); 364 udelay(1);
288 writel(CTRL_RX_INT, port->membase + UART_CTRL);
289 365
290 ret = request_irq(port->irq, mvebu_uart_isr, port->irqflags, "serial", 366 /* Clear the error bits of state register before IRQ request */
291 port); 367 ret = readl(port->membase + UART_STAT);
292 if (ret) { 368 ret |= STAT_BRK_ERR;
293 dev_err(port->dev, "failed to request irq\n"); 369 writel(ret, port->membase + UART_STAT);
294 return ret; 370
371 writel(CTRL_BRK_INT, port->membase + UART_CTRL(port));
372
373 ctl = readl(port->membase + UART_INTR(port));
374 ctl |= CTRL_RX_RDY_INT(port);
375 writel(ctl, port->membase + UART_INTR(port));
376
377 if (!mvuart->irq[UART_TX_IRQ]) {
378 /* Old bindings with just one interrupt (UART0 only) */
379 ret = devm_request_irq(port->dev, mvuart->irq[UART_IRQ_SUM],
380 mvebu_uart_isr, port->irqflags,
381 dev_name(port->dev), port);
382 if (ret) {
383 dev_err(port->dev, "unable to request IRQ %d\n",
384 mvuart->irq[UART_IRQ_SUM]);
385 return ret;
386 }
387 } else {
388 /* New bindings with an IRQ for RX and TX (both UART) */
389 ret = devm_request_irq(port->dev, mvuart->irq[UART_RX_IRQ],
390 mvebu_uart_rx_isr, port->irqflags,
391 dev_name(port->dev), port);
392 if (ret) {
393 dev_err(port->dev, "unable to request IRQ %d\n",
394 mvuart->irq[UART_RX_IRQ]);
395 return ret;
396 }
397
398 ret = devm_request_irq(port->dev, mvuart->irq[UART_TX_IRQ],
399 mvebu_uart_tx_isr, port->irqflags,
400 dev_name(port->dev),
401 port);
402 if (ret) {
403 dev_err(port->dev, "unable to request IRQ %d\n",
404 mvuart->irq[UART_TX_IRQ]);
405 devm_free_irq(port->dev, mvuart->irq[UART_RX_IRQ],
406 port);
407 return ret;
408 }
295 } 409 }
296 410
297 return 0; 411 return 0;
@@ -299,9 +413,41 @@ static int mvebu_uart_startup(struct uart_port *port)
299 413
300static void mvebu_uart_shutdown(struct uart_port *port) 414static void mvebu_uart_shutdown(struct uart_port *port)
301{ 415{
302 writel(0, port->membase + UART_CTRL); 416 struct mvebu_uart *mvuart = to_mvuart(port);
417
418 writel(0, port->membase + UART_INTR(port));
419
420 if (!mvuart->irq[UART_TX_IRQ]) {
421 devm_free_irq(port->dev, mvuart->irq[UART_IRQ_SUM], port);
422 } else {
423 devm_free_irq(port->dev, mvuart->irq[UART_RX_IRQ], port);
424 devm_free_irq(port->dev, mvuart->irq[UART_TX_IRQ], port);
425 }
426}
427
428static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
429{
430 struct mvebu_uart *mvuart = to_mvuart(port);
431 unsigned int baud_rate_div;
432 u32 brdv;
433
434 if (IS_ERR(mvuart->clk))
435 return -PTR_ERR(mvuart->clk);
436
437 /*
438 * The UART clock is divided by the value of the divisor to generate
439 * UCLK_OUT clock, which is 16 times faster than the baudrate.
440 * This prescaler can achieve all standard baudrates until 230400.
441 * Higher baudrates could be achieved for the extended UART by using the
442 * programmable oversampling stack (also called fractional divisor).
443 */
444 baud_rate_div = DIV_ROUND_UP(port->uartclk, baud * 16);
445 brdv = readl(port->membase + UART_BRDV);
446 brdv &= ~BRDV_BAUD_MASK;
447 brdv |= baud_rate_div;
448 writel(brdv, port->membase + UART_BRDV);
303 449
304 free_irq(port->irq, port); 450 return 0;
305} 451}
306 452
307static void mvebu_uart_set_termios(struct uart_port *port, 453static void mvebu_uart_set_termios(struct uart_port *port,
@@ -313,8 +459,8 @@ static void mvebu_uart_set_termios(struct uart_port *port,
313 459
314 spin_lock_irqsave(&port->lock, flags); 460 spin_lock_irqsave(&port->lock, flags);
315 461
316 port->read_status_mask = STAT_RX_RDY | STAT_OVR_ERR | 462 port->read_status_mask = STAT_RX_RDY(port) | STAT_OVR_ERR |
317 STAT_TX_RDY | STAT_TX_FIFO_FUL; 463 STAT_TX_RDY(port) | STAT_TX_FIFO_FUL;
318 464
319 if (termios->c_iflag & INPCK) 465 if (termios->c_iflag & INPCK)
320 port->read_status_mask |= STAT_FRM_ERR | STAT_PAR_ERR; 466 port->read_status_mask |= STAT_FRM_ERR | STAT_PAR_ERR;
@@ -325,13 +471,32 @@ static void mvebu_uart_set_termios(struct uart_port *port,
325 STAT_FRM_ERR | STAT_PAR_ERR | STAT_OVR_ERR; 471 STAT_FRM_ERR | STAT_PAR_ERR | STAT_OVR_ERR;
326 472
327 if ((termios->c_cflag & CREAD) == 0) 473 if ((termios->c_cflag & CREAD) == 0)
328 port->ignore_status_mask |= STAT_RX_RDY | STAT_BRK_ERR; 474 port->ignore_status_mask |= STAT_RX_RDY(port) | STAT_BRK_ERR;
329 475
330 if (old) 476 /*
331 tty_termios_copy_hw(termios, old); 477 * Maximum achievable frequency with simple baudrate divisor is 230400.
478 * Since the error per bit frame would be of more than 15%, achieving
479 * higher frequencies would require to implement the fractional divisor
480 * feature.
481 */
482 baud = uart_get_baud_rate(port, termios, old, 0, 230400);
483 if (mvebu_uart_baud_rate_set(port, baud)) {
484 /* No clock available, baudrate cannot be changed */
485 if (old)
486 baud = uart_get_baud_rate(port, old, NULL, 0, 230400);
487 } else {
488 tty_termios_encode_baud_rate(termios, baud, baud);
489 uart_update_timeout(port, termios->c_cflag, baud);
490 }
332 491
333 baud = uart_get_baud_rate(port, termios, old, 0, 460800); 492 /* Only the following flag changes are supported */
334 uart_update_timeout(port, termios->c_cflag, baud); 493 if (old) {
494 termios->c_iflag &= INPCK | IGNPAR;
495 termios->c_iflag |= old->c_iflag & ~(INPCK | IGNPAR);
496 termios->c_cflag &= CREAD | CBAUD;
497 termios->c_cflag |= old->c_cflag & ~(CREAD | CBAUD);
498 termios->c_lflag = old->c_lflag;
499 }
335 500
336 spin_unlock_irqrestore(&port->lock, flags); 501 spin_unlock_irqrestore(&port->lock, flags);
337} 502}
@@ -356,10 +521,10 @@ static int mvebu_uart_get_poll_char(struct uart_port *port)
356{ 521{
357 unsigned int st = readl(port->membase + UART_STAT); 522 unsigned int st = readl(port->membase + UART_STAT);
358 523
359 if (!(st & STAT_RX_RDY)) 524 if (!(st & STAT_RX_RDY(port)))
360 return NO_POLL_CHAR; 525 return NO_POLL_CHAR;
361 526
362 return readl(port->membase + UART_RBR); 527 return readl(port->membase + UART_RBR(port));
363} 528}
364 529
365static void mvebu_uart_put_poll_char(struct uart_port *port, unsigned char c) 530static void mvebu_uart_put_poll_char(struct uart_port *port, unsigned char c)
@@ -375,7 +540,7 @@ static void mvebu_uart_put_poll_char(struct uart_port *port, unsigned char c)
375 udelay(1); 540 udelay(1);
376 } 541 }
377 542
378 writel(c, port->membase + UART_TSH); 543 writel(c, port->membase + UART_TSH(port));
379} 544}
380#endif 545#endif
381 546
@@ -413,7 +578,8 @@ static void mvebu_uart_putc(struct uart_port *port, int c)
413 break; 578 break;
414 } 579 }
415 580
416 writel(c, port->membase + UART_TSH); 581 /* At early stage, DT is not parsed yet, only use UART0 */
582 writel(c, port->membase + UART_STD_TSH);
417 583
418 for (;;) { 584 for (;;) {
419 st = readl(port->membase + UART_STAT); 585 st = readl(port->membase + UART_STAT);
@@ -458,7 +624,7 @@ static void wait_for_xmitr(struct uart_port *port)
458static void mvebu_uart_console_putchar(struct uart_port *port, int ch) 624static void mvebu_uart_console_putchar(struct uart_port *port, int ch)
459{ 625{
460 wait_for_xmitr(port); 626 wait_for_xmitr(port);
461 writel(ch, port->membase + UART_TSH); 627 writel(ch, port->membase + UART_TSH(port));
462} 628}
463 629
464static void mvebu_uart_console_write(struct console *co, const char *s, 630static void mvebu_uart_console_write(struct console *co, const char *s,
@@ -466,7 +632,7 @@ static void mvebu_uart_console_write(struct console *co, const char *s,
466{ 632{
467 struct uart_port *port = &mvebu_uart_ports[co->index]; 633 struct uart_port *port = &mvebu_uart_ports[co->index];
468 unsigned long flags; 634 unsigned long flags;
469 unsigned int ier; 635 unsigned int ier, intr, ctl;
470 int locked = 1; 636 int locked = 1;
471 637
472 if (oops_in_progress) 638 if (oops_in_progress)
@@ -474,16 +640,23 @@ static void mvebu_uart_console_write(struct console *co, const char *s,
474 else 640 else
475 spin_lock_irqsave(&port->lock, flags); 641 spin_lock_irqsave(&port->lock, flags);
476 642
477 ier = readl(port->membase + UART_CTRL) & 643 ier = readl(port->membase + UART_CTRL(port)) & CTRL_BRK_INT;
478 (CTRL_RX_INT | CTRL_TX_RDY_INT); 644 intr = readl(port->membase + UART_INTR(port)) &
479 writel(0, port->membase + UART_CTRL); 645 (CTRL_RX_RDY_INT(port) | CTRL_TX_RDY_INT(port));
646 writel(0, port->membase + UART_CTRL(port));
647 writel(0, port->membase + UART_INTR(port));
480 648
481 uart_console_write(port, s, count, mvebu_uart_console_putchar); 649 uart_console_write(port, s, count, mvebu_uart_console_putchar);
482 650
483 wait_for_xmitr(port); 651 wait_for_xmitr(port);
484 652
485 if (ier) 653 if (ier)
486 writel(ier, port->membase + UART_CTRL); 654 writel(ier, port->membase + UART_CTRL(port));
655
656 if (intr) {
657 ctl = intr | readl(port->membase + UART_INTR(port));
658 writel(ctl, port->membase + UART_INTR(port));
659 }
487 660
488 if (locked) 661 if (locked)
489 spin_unlock_irqrestore(&port->lock, flags); 662 spin_unlock_irqrestore(&port->lock, flags);
@@ -538,7 +711,7 @@ console_initcall(mvebu_uart_console_init);
538 711
539static struct uart_driver mvebu_uart_driver = { 712static struct uart_driver mvebu_uart_driver = {
540 .owner = THIS_MODULE, 713 .owner = THIS_MODULE,
541 .driver_name = "mvebu_serial", 714 .driver_name = DRIVER_NAME,
542 .dev_name = "ttyMV", 715 .dev_name = "ttyMV",
543 .nr = MVEBU_NR_UARTS, 716 .nr = MVEBU_NR_UARTS,
544#ifdef CONFIG_SERIAL_MVEBU_CONSOLE 717#ifdef CONFIG_SERIAL_MVEBU_CONSOLE
@@ -546,20 +719,39 @@ static struct uart_driver mvebu_uart_driver = {
546#endif 719#endif
547}; 720};
548 721
722static const struct of_device_id mvebu_uart_of_match[];
723
724/* Counter to keep track of each UART port id when not using CONFIG_OF */
725static int uart_num_counter;
726
549static int mvebu_uart_probe(struct platform_device *pdev) 727static int mvebu_uart_probe(struct platform_device *pdev)
550{ 728{
551 struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0); 729 struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
552 struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 730 const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
731 &pdev->dev);
553 struct uart_port *port; 732 struct uart_port *port;
554 struct mvebu_uart_data *data; 733 struct mvebu_uart *mvuart;
555 int ret; 734 int ret, id, irq;
735
736 if (!reg) {
737 dev_err(&pdev->dev, "no registers defined\n");
738 return -EINVAL;
739 }
740
741 /* Assume that all UART ports have a DT alias or none has */
742 id = of_alias_get_id(pdev->dev.of_node, "serial");
743 if (!pdev->dev.of_node || id < 0)
744 pdev->id = uart_num_counter++;
745 else
746 pdev->id = id;
556 747
557 if (!reg || !irq) { 748 if (pdev->id >= MVEBU_NR_UARTS) {
558 dev_err(&pdev->dev, "no registers/irq defined\n"); 749 dev_err(&pdev->dev, "cannot have more than %d UART ports\n",
750 MVEBU_NR_UARTS);
559 return -EINVAL; 751 return -EINVAL;
560 } 752 }
561 753
562 port = &mvebu_uart_ports[0]; 754 port = &mvebu_uart_ports[pdev->id];
563 755
564 spin_lock_init(&port->lock); 756 spin_lock_init(&port->lock);
565 757
@@ -571,9 +763,14 @@ static int mvebu_uart_probe(struct platform_device *pdev)
571 port->fifosize = 32; 763 port->fifosize = 32;
572 port->iotype = UPIO_MEM32; 764 port->iotype = UPIO_MEM32;
573 port->flags = UPF_FIXED_PORT; 765 port->flags = UPF_FIXED_PORT;
574 port->line = 0; /* single port: force line number to 0 */ 766 port->line = pdev->id;
575 767
576 port->irq = irq->start; 768 /*
769 * IRQ number is not stored in this structure because we may have two of
770 * them per port (RX and TX). Instead, use the driver UART structure
771 * array so called ->irq[].
772 */
773 port->irq = 0;
577 port->irqflags = 0; 774 port->irqflags = 0;
578 port->mapbase = reg->start; 775 port->mapbase = reg->start;
579 776
@@ -581,15 +778,70 @@ static int mvebu_uart_probe(struct platform_device *pdev)
581 if (IS_ERR(port->membase)) 778 if (IS_ERR(port->membase))
582 return -PTR_ERR(port->membase); 779 return -PTR_ERR(port->membase);
583 780
584 data = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_uart_data), 781 mvuart = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_uart),
585 GFP_KERNEL); 782 GFP_KERNEL);
586 if (!data) 783 if (!mvuart)
587 return -ENOMEM; 784 return -ENOMEM;
588 785
589 data->port = port; 786 /* Get controller data depending on the compatible string */
787 mvuart->data = (struct mvebu_uart_driver_data *)match->data;
788 mvuart->port = port;
789
790 port->private_data = mvuart;
791 platform_set_drvdata(pdev, mvuart);
792
793 /* Get fixed clock frequency */
794 mvuart->clk = devm_clk_get(&pdev->dev, NULL);
795 if (IS_ERR(mvuart->clk)) {
796 if (PTR_ERR(mvuart->clk) == -EPROBE_DEFER)
797 return PTR_ERR(mvuart->clk);
798
799 if (IS_EXTENDED(port)) {
800 dev_err(&pdev->dev, "unable to get UART clock\n");
801 return PTR_ERR(mvuart->clk);
802 }
803 } else {
804 if (!clk_prepare_enable(mvuart->clk))
805 port->uartclk = clk_get_rate(mvuart->clk);
806 }
807
808 /* Manage interrupts */
809 if (platform_irq_count(pdev) == 1) {
810 /* Old bindings: no name on the single unamed UART0 IRQ */
811 irq = platform_get_irq(pdev, 0);
812 if (irq < 0) {
813 dev_err(&pdev->dev, "unable to get UART IRQ\n");
814 return irq;
815 }
816
817 mvuart->irq[UART_IRQ_SUM] = irq;
818 } else {
819 /*
820 * New bindings: named interrupts (RX, TX) for both UARTS,
821 * only make use of uart-rx and uart-tx interrupts, do not use
822 * uart-sum of UART0 port.
823 */
824 irq = platform_get_irq_byname(pdev, "uart-rx");
825 if (irq < 0) {
826 dev_err(&pdev->dev, "unable to get 'uart-rx' IRQ\n");
827 return irq;
828 }
829
830 mvuart->irq[UART_RX_IRQ] = irq;
590 831
591 port->private_data = data; 832 irq = platform_get_irq_byname(pdev, "uart-tx");
592 platform_set_drvdata(pdev, data); 833 if (irq < 0) {
834 dev_err(&pdev->dev, "unable to get 'uart-tx' IRQ\n");
835 return irq;
836 }
837
838 mvuart->irq[UART_TX_IRQ] = irq;
839 }
840
841 /* UART Soft Reset*/
842 writel(CTRL_SOFT_RST, port->membase + UART_CTRL(port));
843 udelay(1);
844 writel(0, port->membase + UART_CTRL(port));
593 845
594 ret = uart_add_one_port(&mvebu_uart_driver, port); 846 ret = uart_add_one_port(&mvebu_uart_driver, port);
595 if (ret) 847 if (ret)
@@ -597,9 +849,40 @@ static int mvebu_uart_probe(struct platform_device *pdev)
597 return 0; 849 return 0;
598} 850}
599 851
852static struct mvebu_uart_driver_data uart_std_driver_data = {
853 .is_ext = false,
854 .regs.rbr = UART_STD_RBR,
855 .regs.tsh = UART_STD_TSH,
856 .regs.ctrl = UART_STD_CTRL1,
857 .regs.intr = UART_STD_CTRL2,
858 .flags.ctrl_tx_rdy_int = CTRL_STD_TX_RDY_INT,
859 .flags.ctrl_rx_rdy_int = CTRL_STD_RX_RDY_INT,
860 .flags.stat_tx_rdy = STAT_STD_TX_RDY,
861 .flags.stat_rx_rdy = STAT_STD_RX_RDY,
862};
863
864static struct mvebu_uart_driver_data uart_ext_driver_data = {
865 .is_ext = true,
866 .regs.rbr = UART_EXT_RBR,
867 .regs.tsh = UART_EXT_TSH,
868 .regs.ctrl = UART_EXT_CTRL1,
869 .regs.intr = UART_EXT_CTRL2,
870 .flags.ctrl_tx_rdy_int = CTRL_EXT_TX_RDY_INT,
871 .flags.ctrl_rx_rdy_int = CTRL_EXT_RX_RDY_INT,
872 .flags.stat_tx_rdy = STAT_EXT_TX_RDY,
873 .flags.stat_rx_rdy = STAT_EXT_RX_RDY,
874};
875
600/* Match table for of_platform binding */ 876/* Match table for of_platform binding */
601static const struct of_device_id mvebu_uart_of_match[] = { 877static const struct of_device_id mvebu_uart_of_match[] = {
602 { .compatible = "marvell,armada-3700-uart", }, 878 {
879 .compatible = "marvell,armada-3700-uart",
880 .data = (void *)&uart_std_driver_data,
881 },
882 {
883 .compatible = "marvell,armada-3700-uart-ext",
884 .data = (void *)&uart_ext_driver_data,
885 },
603 {} 886 {}
604}; 887};
605 888
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index be94246b6fcc..efb4fd3784ed 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Application UART driver for: 3 * Application UART driver for:
3 * Freescale STMP37XX/STMP378X 4 * Freescale STMP37XX/STMP378X
@@ -9,10 +10,6 @@
9 * Provide Alphascale ASM9260 support. 10 * Provide Alphascale ASM9260 support.
10 * Copyright 2008-2010 Freescale Semiconductor, Inc. 11 * Copyright 2008-2010 Freescale Semiconductor, Inc.
11 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. 12 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
12 *
13 * The code contained herein is licensed under the GNU General Public
14 * License. You may obtain a copy of the GNU General Public License
15 * Version 2 or later at the following locations:
16 */ 13 */
17 14
18#if defined(CONFIG_SERIAL_MXS_AUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 15#if defined(CONFIG_SERIAL_MXS_AUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/netx-serial.c b/drivers/tty/serial/netx-serial.c
index 207a0a032ed1..b3556863491f 100644
--- a/drivers/tty/serial/netx-serial.c
+++ b/drivers/tty/serial/netx-serial.c
@@ -1,18 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix 3 * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 4 */
17 5
18#if defined(CONFIG_SERIAL_NETX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 6#if defined(CONFIG_SERIAL_NETX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 7754053deeda..53d59e9b944a 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for OMAP-UART controller. 3 * Driver for OMAP-UART controller.
3 * Based on drivers/serial/8250.c 4 * Based on drivers/serial/8250.c
@@ -8,11 +9,6 @@
8 * Govindraj R <govindraj.raja@ti.com> 9 * Govindraj R <govindraj.raja@ti.com>
9 * Thara Gopinath <thara@ti.com> 10 * Thara Gopinath <thara@ti.com>
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * Note: This driver is made separate from 8250 driver as we cannot 12 * Note: This driver is made separate from 8250 driver as we cannot
17 * over load 8250 driver with omap platform specific configuration for 13 * over load 8250 driver with omap platform specific configuration for
18 * features like DMA, it makes easier to implement features like DMA and 14 * features like DMA, it makes easier to implement features like DMA and
@@ -610,7 +606,7 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)
610 default: 606 default:
611 break; 607 break;
612 } 608 }
613 } while (!(iir & UART_IIR_NO_INT) && max_count--); 609 } while (max_count--);
614 610
615 spin_unlock(&up->port.lock); 611 spin_unlock(&up->port.lock);
616 612
@@ -693,7 +689,7 @@ static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl)
693 if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS)) 689 if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS))
694 up->efr |= UART_EFR_RTS; 690 up->efr |= UART_EFR_RTS;
695 else 691 else
696 up->efr &= UART_EFR_RTS; 692 up->efr &= ~UART_EFR_RTS;
697 serial_out(up, UART_EFR, up->efr); 693 serial_out(up, UART_EFR, up->efr);
698 serial_out(up, UART_LCR, lcr); 694 serial_out(up, UART_LCR, lcr);
699 695
@@ -1606,7 +1602,6 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up,
1606 struct device_node *np) 1602 struct device_node *np)
1607{ 1603{
1608 struct serial_rs485 *rs485conf = &up->port.rs485; 1604 struct serial_rs485 *rs485conf = &up->port.rs485;
1609 u32 rs485_delay[2];
1610 enum of_gpio_flags flags; 1605 enum of_gpio_flags flags;
1611 int ret; 1606 int ret;
1612 1607
@@ -1637,17 +1632,7 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up,
1637 up->rts_gpio = -EINVAL; 1632 up->rts_gpio = -EINVAL;
1638 } 1633 }
1639 1634
1640 if (of_property_read_u32_array(np, "rs485-rts-delay", 1635 of_get_rs485_mode(np, rs485conf);
1641 rs485_delay, 2) == 0) {
1642 rs485conf->delay_rts_before_send = rs485_delay[0];
1643 rs485conf->delay_rts_after_send = rs485_delay[1];
1644 }
1645
1646 if (of_property_read_bool(np, "rs485-rx-during-tx"))
1647 rs485conf->flags |= SER_RS485_RX_DURING_TX;
1648
1649 if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time"))
1650 rs485conf->flags |= SER_RS485_ENABLED;
1651 1636
1652 return 0; 1637 return 0;
1653} 1638}
diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index b9c859365334..29a6dc6a8d23 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Actions Semi Owl family serial console 3 * Actions Semi Owl family serial console
3 * 4 *
@@ -5,19 +6,6 @@
5 * Author: Actions Semi, Inc. 6 * Author: Actions Semi, Inc.
6 * 7 *
7 * Copyright (c) 2016-2017 Andreas Färber 8 * Copyright (c) 2016-2017 Andreas Färber
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */ 9 */
22 10
23#include <linux/clk.h> 11#include <linux/clk.h>
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index d9123f995705..760d5dd0aada 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -1,18 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 *Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. 3 *Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
3 *
4 *This program is free software; you can redistribute it and/or modify
5 *it under the terms of the GNU General Public License as published by
6 *the Free Software Foundation; version 2 of the License.
7 *
8 *This program is distributed in the hope that it will be useful,
9 *but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 *GNU General Public License for more details.
12 *
13 *You should have received a copy of the GNU General Public License
14 *along with this program; if not, write to the Free Software
15 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16 */ 4 */
17#if defined(CONFIG_SERIAL_PCH_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 5#if defined(CONFIG_SERIAL_PCH_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
18#define SUPPORT_SYSRQ 6#define SUPPORT_SYSRQ
diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
index 00a33eb859d3..fd80d999308d 100644
--- a/drivers/tty/serial/pic32_uart.c
+++ b/drivers/tty/serial/pic32_uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * PIC32 Integrated Serial Driver. 3 * PIC32 Integrated Serial Driver.
3 * 4 *
@@ -5,8 +6,6 @@
5 * 6 *
6 * Authors: 7 * Authors:
7 * Sorin-Andrei Pistirica <andrei.pistirica@microchip.com> 8 * Sorin-Andrei Pistirica <andrei.pistirica@microchip.com>
8 *
9 * Licensed under GPLv2 or later.
10 */ 9 */
11 10
12#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/tty/serial/pic32_uart.h b/drivers/tty/serial/pic32_uart.h
index ec379da55ebb..2f2b56927dc6 100644
--- a/drivers/tty/serial/pic32_uart.h
+++ b/drivers/tty/serial/pic32_uart.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * PIC32 Integrated Serial Driver. 3 * PIC32 Integrated Serial Driver.
3 * 4 *
@@ -5,8 +6,6 @@
5 * 6 *
6 * Authors: 7 * Authors:
7 * Sorin-Andrei Pistirica <andrei.pistirica@microchip.com> 8 * Sorin-Andrei Pistirica <andrei.pistirica@microchip.com>
8 *
9 * Licensed under GPLv2 or later.
10 */ 9 */
11#ifndef __DT_PIC32_UART_H__ 10#ifndef __DT_PIC32_UART_H__
12#define __DT_PIC32_UART_H__ 11#define __DT_PIC32_UART_H__
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 6ccdd018fb45..3d21790d961e 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for PowerMac Z85c30 based ESCC cell found in the 3 * Driver for PowerMac Z85c30 based ESCC cell found in the
3 * "macio" ASICs of various PowerMac models 4 * "macio" ASICs of various PowerMac models
@@ -13,20 +14,6 @@
13 * and once done, I expect that driver to remain fairly stable in 14 * and once done, I expect that driver to remain fairly stable in
14 * the long term, unless we change the driver model again... 15 * the long term, unless we change the driver model again...
15 * 16 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * 2004-08-06 Harald Welte <laforge@gnumonks.org> 17 * 2004-08-06 Harald Welte <laforge@gnumonks.org>
31 * - Enable BREAK interrupt 18 * - Enable BREAK interrupt
32 * - Add support for sysreq 19 * - Add support for sysreq
diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c
index dab2668d3879..f8812389b8a8 100644
--- a/drivers/tty/serial/pnx8xxx_uart.c
+++ b/drivers/tty/serial/pnx8xxx_uart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * UART driver for PNX8XXX SoCs 3 * UART driver for PNX8XXX SoCs
3 * 4 *
@@ -7,11 +8,6 @@
7 * 8 *
8 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 9 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
9 * Copyright (C) 2000 Deep Blue Solutions Ltd. 10 * Copyright (C) 2000 Deep Blue Solutions Ltd.
10 *
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of
13 * any kind, whether express or implied.
14 *
15 */ 11 */
16 12
17#if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 13#if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -666,9 +662,8 @@ static void __init pnx8xxx_init_ports(void)
666 first = 0; 662 first = 0;
667 663
668 for (i = 0; i < NR_PORTS; i++) { 664 for (i = 0; i < NR_PORTS; i++) {
669 init_timer(&pnx8xxx_ports[i].timer); 665 setup_timer(&pnx8xxx_ports[i].timer, pnx8xxx_timeout,
670 pnx8xxx_ports[i].timer.function = pnx8xxx_timeout; 666 (unsigned long)&pnx8xxx_ports[i]);
671 pnx8xxx_ports[i].timer.data = (unsigned long)&pnx8xxx_ports[i];
672 pnx8xxx_ports[i].port.ops = &pnx8xxx_pops; 667 pnx8xxx_ports[i].port.ops = &pnx8xxx_pops;
673 } 668 }
674} 669}
diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 905631df1f8b..baf552944d56 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Based on drivers/serial/8250.c by Russell King. 3 * Based on drivers/serial/8250.c by Russell King.
3 * 4 *
@@ -5,11 +6,6 @@
5 * Created: Feb 20, 2003 6 * Created: Feb 20, 2003
6 * Copyright: (C) 2003 Monta Vista Software, Inc. 7 * Copyright: (C) 2003 Monta Vista Software, Inc.
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * Note 1: This driver is made separate from the already too overloaded 9 * Note 1: This driver is made separate from the already too overloaded
14 * 8250.c because it needs some kirks of its own and that'll make it 10 * 8250.c because it needs some kirks of its own and that'll make it
15 * easier to add DMA support. 11 * easier to add DMA support.
diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c
index 056f91b3a4ca..520b43b23543 100644
--- a/drivers/tty/serial/rp2.c
+++ b/drivers/tty/serial/rp2.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for Comtrol RocketPort EXPRESS/INFINITY cards 3 * Driver for Comtrol RocketPort EXPRESS/INFINITY cards
3 * 4 *
@@ -10,10 +11,6 @@
10 * 11 *
11 * rocketport_infinity_express-linux-1.20.tar.gz 12 * rocketport_infinity_express-linux-1.20.tar.gz
12 * Copyright (C) 2004-2011 Comtrol, Inc. 13 * Copyright (C) 2004-2011 Comtrol, Inc.
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License version 2 as published
16 * by the Free Software Foundation.
17 */ 14 */
18 15
19#include <linux/bitops.h> 16#include <linux/bitops.h>
diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index fd3d1329d48c..4e3f169b30cf 100644
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for SA11x0 serial ports 3 * Driver for SA11x0 serial ports
3 * 4 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. 5 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 * 6 *
6 * Copyright (C) 2000 Deep Blue Solutions Ltd. 7 * Copyright (C) 2000 Deep Blue Solutions Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 8 */
22 9
23#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 10#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -640,9 +627,8 @@ static void __init sa1100_init_ports(void)
640 sa1100_ports[i].port.fifosize = 8; 627 sa1100_ports[i].port.fifosize = 8;
641 sa1100_ports[i].port.line = i; 628 sa1100_ports[i].port.line = i;
642 sa1100_ports[i].port.iotype = UPIO_MEM; 629 sa1100_ports[i].port.iotype = UPIO_MEM;
643 init_timer(&sa1100_ports[i].timer); 630 setup_timer(&sa1100_ports[i].timer, sa1100_timeout,
644 sa1100_ports[i].timer.function = sa1100_timeout; 631 (unsigned long)&sa1100_ports[i]);
645 sa1100_ports[i].timer.data = (unsigned long)&sa1100_ports[i];
646 } 632 }
647 633
648 /* 634 /*
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 8aca18c4cdea..f9fecc5ed0ce 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver core for Samsung SoC onboard UARTs. 3 * Driver core for Samsung SoC onboard UARTs.
3 * 4 *
4 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics 5 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
5 * http://armlinux.simtec.co.uk/ 6 * http://armlinux.simtec.co.uk/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/ 7*/
11 8
12/* Hote on 2410 error handling 9/* Hote on 2410 error handling
diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h
index 965199b6c16f..f93022113f59 100644
--- a/drivers/tty/serial/samsung.h
+++ b/drivers/tty/serial/samsung.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#ifndef __SAMSUNG_H 2#ifndef __SAMSUNG_H
2#define __SAMSUNG_H 3#define __SAMSUNG_H
3 4
@@ -6,10 +7,6 @@
6 * 7 *
7 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics 8 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
8 * http://armlinux.simtec.co.uk/ 9 * http://armlinux.simtec.co.uk/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13*/ 10*/
14 11
15#include <linux/dmaengine.h> 12#include <linux/dmaengine.h>
diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
index 041625cc24bb..329aced26bd8 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Support for the asynchronous serial interface (DUART) included 3 * Support for the asynchronous serial interface (DUART) included
3 * in the BCM1250 and derived System-On-a-Chip (SOC) devices. 4 * in the BCM1250 and derived System-On-a-Chip (SOC) devices.
@@ -9,11 +10,6 @@
9 * 10 *
10 * Copyright (c) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation 11 * Copyright (c) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
11 * 12 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 *
17 * References: 13 * References:
18 * 14 *
19 * "BCM1250/BCM1125/BCM1125H User Manual", Broadcom Corporation 15 * "BCM1250/BCM1125/BCM1125H User Manual", Broadcom Corporation
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index ca54ce074a5f..65792a3539d0 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1,14 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * SC16IS7xx tty serial driver - Copyright (C) 2014 GridPoint 3 * SC16IS7xx tty serial driver - Copyright (C) 2014 GridPoint
3 * Author: Jon Ringle <jringle@gridpoint.com> 4 * Author: Jon Ringle <jringle@gridpoint.com>
4 * 5 *
5 * Based on max310x.c, by Alexander Shiyan <shc_work@mail.ru> 6 * Based on max310x.c, by Alexander Shiyan <shc_work@mail.ru>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 */ 7 */
13 8
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index b9c7a904c1ea..d6ae3086c2a2 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * NXP (Philips) SCC+++(SCN+++) serial driver 3 * NXP (Philips) SCC+++(SCN+++) serial driver
3 * 4 *
4 * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru> 5 * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru>
5 * 6 *
6 * Based on sc26xx.c, by Thomas Bogendörfer (tsbogend@alpha.franken.de) 7 * Based on sc26xx.c, by Thomas Bogendörfer (tsbogend@alpha.franken.de)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#if defined(CONFIG_SERIAL_SCCNXP_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 10#if defined(CONFIG_SERIAL_SCCNXP_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -465,9 +461,9 @@ static void sccnxp_handle_events(struct sccnxp_port *s)
465 } while (1); 461 } while (1);
466} 462}
467 463
468static void sccnxp_timer(unsigned long data) 464static void sccnxp_timer(struct timer_list *t)
469{ 465{
470 struct sccnxp_port *s = (struct sccnxp_port *)data; 466 struct sccnxp_port *s = from_timer(s, t, timer);
471 unsigned long flags; 467 unsigned long flags;
472 468
473 spin_lock_irqsave(&s->lock, flags); 469 spin_lock_irqsave(&s->lock, flags);
@@ -987,8 +983,7 @@ static int sccnxp_probe(struct platform_device *pdev)
987 983
988 dev_err(&pdev->dev, "Unable to reguest IRQ %i\n", s->irq); 984 dev_err(&pdev->dev, "Unable to reguest IRQ %i\n", s->irq);
989 } else { 985 } else {
990 init_timer(&s->timer); 986 timer_setup(&s->timer, sccnxp_timer, 0);
991 setup_timer(&s->timer, sccnxp_timer, (unsigned long)s);
992 mod_timer(&s->timer, jiffies + 987 mod_timer(&s->timer, jiffies +
993 usecs_to_jiffies(s->pdata.poll_time_us)); 988 usecs_to_jiffies(s->pdata.poll_time_us));
994 return 0; 989 return 0;
diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index cf9b736f26f8..af2a29cfbbe9 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * serial_tegra.c 3 * serial_tegra.c
3 * 4 *
@@ -6,18 +7,6 @@
6 * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved. 7 * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
7 * 8 *
8 * Author: Laxman Dewangan <ldewangan@nvidia.com> 9 * Author: Laxman Dewangan <ldewangan@nvidia.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms and conditions of the GNU General Public License,
12 * version 2, as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */ 10 */
22 11
23#include <linux/clk.h> 12#include <linux/clk.h>
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 3a14cccbd7ff..854995e1cae7 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver core for serial ports 3 * Driver core for serial ports
3 * 4 *
@@ -5,20 +6,6 @@
5 * 6 *
6 * Copyright 1999 ARM Limited 7 * Copyright 1999 ARM Limited
7 * Copyright (C) 2000-2001 Deep Blue Solutions Ltd. 8 * Copyright (C) 2000-2001 Deep Blue Solutions Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 9 */
23#include <linux/module.h> 10#include <linux/module.h>
24#include <linux/tty.h> 11#include <linux/tty.h>
@@ -1482,10 +1469,10 @@ out:
1482static void uart_close(struct tty_struct *tty, struct file *filp) 1469static void uart_close(struct tty_struct *tty, struct file *filp)
1483{ 1470{
1484 struct uart_state *state = tty->driver_data; 1471 struct uart_state *state = tty->driver_data;
1485 struct tty_port *port;
1486 1472
1487 if (!state) { 1473 if (!state) {
1488 struct uart_driver *drv = tty->driver->driver_state; 1474 struct uart_driver *drv = tty->driver->driver_state;
1475 struct tty_port *port;
1489 1476
1490 state = drv->state + tty->index; 1477 state = drv->state + tty->index;
1491 port = &state->port; 1478 port = &state->port;
@@ -1495,7 +1482,6 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
1495 return; 1482 return;
1496 } 1483 }
1497 1484
1498 port = &state->port;
1499 pr_debug("uart_close(%d) called\n", tty->index); 1485 pr_debug("uart_close(%d) called\n", tty->index);
1500 1486
1501 tty_port_close(tty->port, tty, filp); 1487 tty_port_close(tty->port, tty, filp);
@@ -3026,5 +3012,41 @@ EXPORT_SYMBOL(uart_resume_port);
3026EXPORT_SYMBOL(uart_add_one_port); 3012EXPORT_SYMBOL(uart_add_one_port);
3027EXPORT_SYMBOL(uart_remove_one_port); 3013EXPORT_SYMBOL(uart_remove_one_port);
3028 3014
3015/**
3016 * of_get_rs485_mode() - Implement parsing rs485 properties
3017 * @np: uart node
3018 * @rs485conf: output parameter
3019 *
3020 * This function implements the device tree binding described in
3021 * Documentation/devicetree/bindings/serial/rs485.txt.
3022 */
3023void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf)
3024{
3025 u32 rs485_delay[2];
3026 int ret;
3027
3028 ret = of_property_read_u32_array(np, "rs485-rts-delay", rs485_delay, 2);
3029 if (!ret) {
3030 rs485conf->delay_rts_before_send = rs485_delay[0];
3031 rs485conf->delay_rts_after_send = rs485_delay[1];
3032 } else {
3033 rs485conf->delay_rts_before_send = 0;
3034 rs485conf->delay_rts_after_send = 0;
3035 }
3036
3037 /*
3038 * clear full-duplex and enabled flags to get to a defined state with
3039 * the two following properties.
3040 */
3041 rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED);
3042
3043 if (of_property_read_bool(np, "rs485-rx-during-tx"))
3044 rs485conf->flags |= SER_RS485_RX_DURING_TX;
3045
3046 if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time"))
3047 rs485conf->flags |= SER_RS485_ENABLED;
3048}
3049EXPORT_SYMBOL_GPL(of_get_rs485_mode);
3050
3029MODULE_DESCRIPTION("Serial driver core"); 3051MODULE_DESCRIPTION("Serial driver core");
3030MODULE_LICENSE("GPL"); 3052MODULE_LICENSE("GPL");
diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c
index 57f152394af5..b461d791188c 100644
--- a/drivers/tty/serial/serial_ks8695.c
+++ b/drivers/tty/serial/serial_ks8695.c
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for KS8695 serial ports 3 * Driver for KS8695 serial ports
3 * 4 *
4 * Based on drivers/serial/serial_amba.c, by Kam Lee. 5 * Based on drivers/serial/serial_amba.c, by Kam Lee.
5 * 6 *
6 * Copyright 2002-2005 Micrel Inc. 7 * Copyright 2002-2005 Micrel Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */ 8 */
14#include <linux/module.h> 9#include <linux/module.h>
15#include <linux/tty.h> 10#include <linux/tty.h>
diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
index d2da6aa7f27d..1c06325beaca 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.c
+++ b/drivers/tty/serial/serial_mctrl_gpio.c
@@ -1,17 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Helpers for controlling modem lines via GPIO 3 * Helpers for controlling modem lines via GPIO
3 * 4 *
4 * Copyright (C) 2014 Paratronic S.A. 5 * Copyright (C) 2014 Paratronic S.A.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */ 6 */
16 7
17#include <linux/err.h> 8#include <linux/err.h>
diff --git a/drivers/tty/serial/serial_mctrl_gpio.h b/drivers/tty/serial/serial_mctrl_gpio.h
index fa000bcff217..b7d3cca48ede 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.h
+++ b/drivers/tty/serial/serial_mctrl_gpio.h
@@ -1,18 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Helpers for controlling modem lines via GPIO 3 * Helpers for controlling modem lines via GPIO
3 * 4 *
4 * Copyright (C) 2014 Paratronic S.A. 5 * Copyright (C) 2014 Paratronic S.A.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */ 6 */
17 7
18#ifndef __SERIAL_MCTRL_GPIO__ 8#ifndef __SERIAL_MCTRL_GPIO__
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index f80fead6c5fc..1b4008d022bf 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Derived from many drivers using generic_serial interface, 3 * Derived from many drivers using generic_serial interface,
3 * especially serial_tx3912.c by Steven J. Hill and r39xx_serial.c 4 * especially serial_tx3912.c by Steven J. Hill and r39xx_serial.c
@@ -8,10 +9,6 @@
8 * Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com) 9 * Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
9 * Copyright (C) 2000-2002 Toshiba Corporation 10 * Copyright (C) 2000-2002 Toshiba Corporation
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * Serial driver for TX3927/TX4927/TX4925/TX4938 internal SIO controller 12 * Serial driver for TX3927/TX4927/TX4925/TX4938 internal SIO controller
16 */ 13 */
17 14
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 784dd42002ea..31fcc7072a90 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO) 3 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
3 * 4 *
@@ -13,10 +14,6 @@
13 * Modified to support SecureEdge. David McCullough (2002) 14 * Modified to support SecureEdge. David McCullough (2002)
14 * Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003). 15 * Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003).
15 * Removed SH7300 support (Jul 2007). 16 * Removed SH7300 support (Jul 2007).
16 *
17 * This file is subject to the terms and conditions of the GNU General Public
18 * License. See the file "COPYING" in the main directory of this archive
19 * for more details.
20 */ 17 */
21#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 18#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
22#define SUPPORT_SYSRQ 19#define SUPPORT_SYSRQ
@@ -40,6 +37,7 @@
40#include <linux/module.h> 37#include <linux/module.h>
41#include <linux/mm.h> 38#include <linux/mm.h>
42#include <linux/of.h> 39#include <linux/of.h>
40#include <linux/of_device.h>
43#include <linux/platform_device.h> 41#include <linux/platform_device.h>
44#include <linux/pm_runtime.h> 42#include <linux/pm_runtime.h>
45#include <linux/scatterlist.h> 43#include <linux/scatterlist.h>
@@ -152,6 +150,7 @@ struct sci_port {
152 int rx_trigger; 150 int rx_trigger;
153 struct timer_list rx_fifo_timer; 151 struct timer_list rx_fifo_timer;
154 int rx_fifo_timeout; 152 int rx_fifo_timeout;
153 u16 hscif_tot;
155 154
156 bool has_rtscts; 155 bool has_rtscts;
157 bool autorts; 156 bool autorts;
@@ -1107,8 +1106,14 @@ static ssize_t rx_fifo_timeout_show(struct device *dev,
1107{ 1106{
1108 struct uart_port *port = dev_get_drvdata(dev); 1107 struct uart_port *port = dev_get_drvdata(dev);
1109 struct sci_port *sci = to_sci_port(port); 1108 struct sci_port *sci = to_sci_port(port);
1109 int v;
1110
1111 if (port->type == PORT_HSCIF)
1112 v = sci->hscif_tot >> HSSCR_TOT_SHIFT;
1113 else
1114 v = sci->rx_fifo_timeout;
1110 1115
1111 return sprintf(buf, "%d\n", sci->rx_fifo_timeout); 1116 return sprintf(buf, "%d\n", v);
1112} 1117}
1113 1118
1114static ssize_t rx_fifo_timeout_store(struct device *dev, 1119static ssize_t rx_fifo_timeout_store(struct device *dev,
@@ -1124,11 +1129,19 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
1124 ret = kstrtol(buf, 0, &r); 1129 ret = kstrtol(buf, 0, &r);
1125 if (ret) 1130 if (ret)
1126 return ret; 1131 return ret;
1127 sci->rx_fifo_timeout = r; 1132
1128 scif_set_rtrg(port, 1); 1133 if (port->type == PORT_HSCIF) {
1129 if (r > 0) 1134 if (r < 0 || r > 3)
1130 setup_timer(&sci->rx_fifo_timer, rx_fifo_timer_fn, 1135 return -EINVAL;
1131 (unsigned long)sci); 1136 sci->hscif_tot = r << HSSCR_TOT_SHIFT;
1137 } else {
1138 sci->rx_fifo_timeout = r;
1139 scif_set_rtrg(port, 1);
1140 if (r > 0)
1141 setup_timer(&sci->rx_fifo_timer, rx_fifo_timer_fn,
1142 (unsigned long)sci);
1143 }
1144
1132 return count; 1145 return count;
1133} 1146}
1134 1147
@@ -1210,8 +1223,11 @@ static void sci_rx_dma_release(struct sci_port *s, bool enable_pio)
1210 dma_free_coherent(chan->device->dev, s->buf_len_rx * 2, s->rx_buf[0], 1223 dma_free_coherent(chan->device->dev, s->buf_len_rx * 2, s->rx_buf[0],
1211 sg_dma_address(&s->sg_rx[0])); 1224 sg_dma_address(&s->sg_rx[0]));
1212 dma_release_channel(chan); 1225 dma_release_channel(chan);
1213 if (enable_pio) 1226 if (enable_pio) {
1227 spin_lock_irqsave(&port->lock, flags);
1214 sci_start_rx(port); 1228 sci_start_rx(port);
1229 spin_unlock_irqrestore(&port->lock, flags);
1230 }
1215} 1231}
1216 1232
1217static void sci_dma_rx_complete(void *arg) 1233static void sci_dma_rx_complete(void *arg)
@@ -1278,8 +1294,11 @@ static void sci_tx_dma_release(struct sci_port *s, bool enable_pio)
1278 dma_unmap_single(chan->device->dev, s->tx_dma_addr, UART_XMIT_SIZE, 1294 dma_unmap_single(chan->device->dev, s->tx_dma_addr, UART_XMIT_SIZE,
1279 DMA_TO_DEVICE); 1295 DMA_TO_DEVICE);
1280 dma_release_channel(chan); 1296 dma_release_channel(chan);
1281 if (enable_pio) 1297 if (enable_pio) {
1298 spin_lock_irqsave(&port->lock, flags);
1282 sci_start_tx(port); 1299 sci_start_tx(port);
1300 spin_unlock_irqrestore(&port->lock, flags);
1301 }
1283} 1302}
1284 1303
1285static void sci_submit_rx(struct sci_port *s) 1304static void sci_submit_rx(struct sci_port *s)
@@ -1491,6 +1510,14 @@ static void sci_request_dma(struct uart_port *port)
1491 return; 1510 return;
1492 1511
1493 s->cookie_tx = -EINVAL; 1512 s->cookie_tx = -EINVAL;
1513
1514 /*
1515 * Don't request a dma channel if no channel was specified
1516 * in the device tree.
1517 */
1518 if (!of_find_property(port->dev->of_node, "dmas", NULL))
1519 return;
1520
1494 chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV); 1521 chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV);
1495 dev_dbg(port->dev, "%s: TX: got channel %p\n", __func__, chan); 1522 dev_dbg(port->dev, "%s: TX: got channel %p\n", __func__, chan);
1496 if (chan) { 1523 if (chan) {
@@ -1980,6 +2007,7 @@ static void sci_enable_ms(struct uart_port *port)
1980static void sci_break_ctl(struct uart_port *port, int break_state) 2007static void sci_break_ctl(struct uart_port *port, int break_state)
1981{ 2008{
1982 unsigned short scscr, scsptr; 2009 unsigned short scscr, scsptr;
2010 unsigned long flags;
1983 2011
1984 /* check wheter the port has SCSPTR */ 2012 /* check wheter the port has SCSPTR */
1985 if (!sci_getreg(port, SCSPTR)->size) { 2013 if (!sci_getreg(port, SCSPTR)->size) {
@@ -1990,6 +2018,7 @@ static void sci_break_ctl(struct uart_port *port, int break_state)
1990 return; 2018 return;
1991 } 2019 }
1992 2020
2021 spin_lock_irqsave(&port->lock, flags);
1993 scsptr = serial_port_in(port, SCSPTR); 2022 scsptr = serial_port_in(port, SCSPTR);
1994 scscr = serial_port_in(port, SCSCR); 2023 scscr = serial_port_in(port, SCSCR);
1995 2024
@@ -2003,6 +2032,7 @@ static void sci_break_ctl(struct uart_port *port, int break_state)
2003 2032
2004 serial_port_out(port, SCSPTR, scsptr); 2033 serial_port_out(port, SCSPTR, scsptr);
2005 serial_port_out(port, SCSCR, scscr); 2034 serial_port_out(port, SCSCR, scscr);
2035 spin_unlock_irqrestore(&port->lock, flags);
2006} 2036}
2007 2037
2008static int sci_startup(struct uart_port *port) 2038static int sci_startup(struct uart_port *port)
@@ -2037,9 +2067,13 @@ static void sci_shutdown(struct uart_port *port)
2037 spin_lock_irqsave(&port->lock, flags); 2067 spin_lock_irqsave(&port->lock, flags);
2038 sci_stop_rx(port); 2068 sci_stop_rx(port);
2039 sci_stop_tx(port); 2069 sci_stop_tx(port);
2040 /* Stop RX and TX, disable related interrupts, keep clock source */ 2070 /*
2071 * Stop RX and TX, disable related interrupts, keep clock source
2072 * and HSCIF TOT bits
2073 */
2041 scr = serial_port_in(port, SCSCR); 2074 scr = serial_port_in(port, SCSCR);
2042 serial_port_out(port, SCSCR, scr & (SCSCR_CKE1 | SCSCR_CKE0)); 2075 serial_port_out(port, SCSCR, scr &
2076 (SCSCR_CKE1 | SCSCR_CKE0 | s->hscif_tot));
2043 spin_unlock_irqrestore(&port->lock, flags); 2077 spin_unlock_irqrestore(&port->lock, flags);
2044 2078
2045#ifdef CONFIG_SERIAL_SH_SCI_DMA 2079#ifdef CONFIG_SERIAL_SH_SCI_DMA
@@ -2186,7 +2220,7 @@ static void sci_reset(struct uart_port *port)
2186 unsigned int status; 2220 unsigned int status;
2187 struct sci_port *s = to_sci_port(port); 2221 struct sci_port *s = to_sci_port(port);
2188 2222
2189 serial_port_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ 2223 serial_port_out(port, SCSCR, s->hscif_tot); /* TE=0, RE=0, CKE1=0 */
2190 2224
2191 reg = sci_getreg(port, SCFCR); 2225 reg = sci_getreg(port, SCFCR);
2192 if (reg->size) 2226 if (reg->size)
@@ -2227,6 +2261,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
2227 int min_err = INT_MAX, err; 2261 int min_err = INT_MAX, err;
2228 unsigned long max_freq = 0; 2262 unsigned long max_freq = 0;
2229 int best_clk = -1; 2263 int best_clk = -1;
2264 unsigned long flags;
2230 2265
2231 if ((termios->c_cflag & CSIZE) == CS7) 2266 if ((termios->c_cflag & CSIZE) == CS7)
2232 smr_val |= SCSMR_CHR; 2267 smr_val |= SCSMR_CHR;
@@ -2336,6 +2371,8 @@ done:
2336 serial_port_out(port, SCCKS, sccks); 2371 serial_port_out(port, SCCKS, sccks);
2337 } 2372 }
2338 2373
2374 spin_lock_irqsave(&port->lock, flags);
2375
2339 sci_reset(port); 2376 sci_reset(port);
2340 2377
2341 uart_update_timeout(port, termios->c_cflag, baud); 2378 uart_update_timeout(port, termios->c_cflag, baud);
@@ -2353,10 +2390,7 @@ done:
2353 case 27: smr_val |= SCSMR_SRC_27; break; 2390 case 27: smr_val |= SCSMR_SRC_27; break;
2354 } 2391 }
2355 smr_val |= cks; 2392 smr_val |= cks;
2356 dev_dbg(port->dev, 2393 serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
2357 "SCR 0x%x SMR 0x%x BRR %u CKS 0x%x DL %u SRR %u\n",
2358 scr_val, smr_val, brr, sccks, dl, srr);
2359 serial_port_out(port, SCSCR, scr_val);
2360 serial_port_out(port, SCSMR, smr_val); 2394 serial_port_out(port, SCSMR, smr_val);
2361 serial_port_out(port, SCBRR, brr); 2395 serial_port_out(port, SCBRR, brr);
2362 if (sci_getreg(port, HSSRR)->size) 2396 if (sci_getreg(port, HSSRR)->size)
@@ -2369,8 +2403,7 @@ done:
2369 scr_val = s->cfg->scscr & (SCSCR_CKE1 | SCSCR_CKE0); 2403 scr_val = s->cfg->scscr & (SCSCR_CKE1 | SCSCR_CKE0);
2370 smr_val |= serial_port_in(port, SCSMR) & 2404 smr_val |= serial_port_in(port, SCSMR) &
2371 (SCSMR_CKEDG | SCSMR_SRC_MASK | SCSMR_CKS); 2405 (SCSMR_CKEDG | SCSMR_SRC_MASK | SCSMR_CKS);
2372 dev_dbg(port->dev, "SCR 0x%x SMR 0x%x\n", scr_val, smr_val); 2406 serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
2373 serial_port_out(port, SCSCR, scr_val);
2374 serial_port_out(port, SCSMR, smr_val); 2407 serial_port_out(port, SCSMR, smr_val);
2375 } 2408 }
2376 2409
@@ -2406,8 +2439,7 @@ done:
2406 2439
2407 scr_val |= SCSCR_RE | SCSCR_TE | 2440 scr_val |= SCSCR_RE | SCSCR_TE |
2408 (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0)); 2441 (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
2409 dev_dbg(port->dev, "SCSCR 0x%x\n", scr_val); 2442 serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
2410 serial_port_out(port, SCSCR, scr_val);
2411 if ((srr + 1 == 5) && 2443 if ((srr + 1 == 5) &&
2412 (port->type == PORT_SCIFA || port->type == PORT_SCIFB)) { 2444 (port->type == PORT_SCIFA || port->type == PORT_SCIFB)) {
2413 /* 2445 /*
@@ -2453,8 +2485,6 @@ done:
2453 s->rx_frame = (100 * bits * HZ) / (baud / 10); 2485 s->rx_frame = (100 * bits * HZ) / (baud / 10);
2454#ifdef CONFIG_SERIAL_SH_SCI_DMA 2486#ifdef CONFIG_SERIAL_SH_SCI_DMA
2455 s->rx_timeout = DIV_ROUND_UP(s->buf_len_rx * 2 * s->rx_frame, 1000); 2487 s->rx_timeout = DIV_ROUND_UP(s->buf_len_rx * 2 * s->rx_frame, 1000);
2456 dev_dbg(port->dev, "DMA Rx t-out %ums, tty t-out %u jiffies\n",
2457 s->rx_timeout * 1000 / HZ, port->timeout);
2458 if (s->rx_timeout < msecs_to_jiffies(20)) 2488 if (s->rx_timeout < msecs_to_jiffies(20))
2459 s->rx_timeout = msecs_to_jiffies(20); 2489 s->rx_timeout = msecs_to_jiffies(20);
2460#endif 2490#endif
@@ -2462,6 +2492,8 @@ done:
2462 if ((termios->c_cflag & CREAD) != 0) 2492 if ((termios->c_cflag & CREAD) != 0)
2463 sci_start_rx(port); 2493 sci_start_rx(port);
2464 2494
2495 spin_unlock_irqrestore(&port->lock, flags);
2496
2465 sci_port_disable(s); 2497 sci_port_disable(s);
2466 2498
2467 if (UART_ENABLE_MS(port, termios->c_cflag)) 2499 if (UART_ENABLE_MS(port, termios->c_cflag))
@@ -2773,6 +2805,7 @@ static int sci_init_single(struct platform_device *dev,
2773 } 2805 }
2774 2806
2775 sci_port->rx_fifo_timeout = 0; 2807 sci_port->rx_fifo_timeout = 0;
2808 sci_port->hscif_tot = 0;
2776 2809
2777 /* SCIFA on sh7723 and sh7724 need a custom sampling rate that doesn't 2810 /* SCIFA on sh7723 and sh7724 need a custom sampling rate that doesn't
2778 * match the SoC datasheet, this should be investigated. Let platform 2811 * match the SoC datasheet, this should be investigated. Let platform
@@ -2860,7 +2893,7 @@ static void serial_console_write(struct console *co, const char *s,
2860 ctrl_temp = SCSCR_RE | SCSCR_TE | 2893 ctrl_temp = SCSCR_RE | SCSCR_TE |
2861 (sci_port->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0)) | 2894 (sci_port->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0)) |
2862 (ctrl & (SCSCR_CKE1 | SCSCR_CKE0)); 2895 (ctrl & (SCSCR_CKE1 | SCSCR_CKE0));
2863 serial_port_out(port, SCSCR, ctrl_temp); 2896 serial_port_out(port, SCSCR, ctrl_temp | sci_port->hscif_tot);
2864 2897
2865 uart_console_write(port, s, count, serial_console_putchar); 2898 uart_console_write(port, s, count, serial_console_putchar);
2866 2899
@@ -2988,7 +3021,8 @@ static int sci_remove(struct platform_device *dev)
2988 sysfs_remove_file(&dev->dev.kobj, 3021 sysfs_remove_file(&dev->dev.kobj,
2989 &dev_attr_rx_fifo_trigger.attr); 3022 &dev_attr_rx_fifo_trigger.attr);
2990 } 3023 }
2991 if (port->port.type == PORT_SCIFA || port->port.type == PORT_SCIFB) { 3024 if (port->port.type == PORT_SCIFA || port->port.type == PORT_SCIFB ||
3025 port->port.type == PORT_HSCIF) {
2992 sysfs_remove_file(&dev->dev.kobj, 3026 sysfs_remove_file(&dev->dev.kobj,
2993 &dev_attr_rx_fifo_timeout.attr); 3027 &dev_attr_rx_fifo_timeout.attr);
2994 } 3028 }
@@ -3044,17 +3078,15 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
3044 unsigned int *dev_id) 3078 unsigned int *dev_id)
3045{ 3079{
3046 struct device_node *np = pdev->dev.of_node; 3080 struct device_node *np = pdev->dev.of_node;
3047 const struct of_device_id *match;
3048 struct plat_sci_port *p; 3081 struct plat_sci_port *p;
3049 struct sci_port *sp; 3082 struct sci_port *sp;
3083 const void *data;
3050 int id; 3084 int id;
3051 3085
3052 if (!IS_ENABLED(CONFIG_OF) || !np) 3086 if (!IS_ENABLED(CONFIG_OF) || !np)
3053 return NULL; 3087 return NULL;
3054 3088
3055 match = of_match_node(of_sci_match, np); 3089 data = of_device_get_match_data(&pdev->dev);
3056 if (!match)
3057 return NULL;
3058 3090
3059 p = devm_kzalloc(&pdev->dev, sizeof(struct plat_sci_port), GFP_KERNEL); 3091 p = devm_kzalloc(&pdev->dev, sizeof(struct plat_sci_port), GFP_KERNEL);
3060 if (!p) 3092 if (!p)
@@ -3070,8 +3102,8 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
3070 sp = &sci_ports[id]; 3102 sp = &sci_ports[id];
3071 *dev_id = id; 3103 *dev_id = id;
3072 3104
3073 p->type = SCI_OF_TYPE(match->data); 3105 p->type = SCI_OF_TYPE(data);
3074 p->regtype = SCI_OF_REGTYPE(match->data); 3106 p->regtype = SCI_OF_REGTYPE(data);
3075 3107
3076 sp->has_rtscts = of_property_read_bool(np, "uart-has-rtscts"); 3108 sp->has_rtscts = of_property_read_bool(np, "uart-has-rtscts");
3077 3109
@@ -3173,7 +3205,8 @@ static int sci_probe(struct platform_device *dev)
3173 if (ret) 3205 if (ret)
3174 return ret; 3206 return ret;
3175 } 3207 }
3176 if (sp->port.type == PORT_SCIFA || sp->port.type == PORT_SCIFB) { 3208 if (sp->port.type == PORT_SCIFA || sp->port.type == PORT_SCIFB ||
3209 sp->port.type == PORT_HSCIF) {
3177 ret = sysfs_create_file(&dev->dev.kobj, 3210 ret = sysfs_create_file(&dev->dev.kobj,
3178 &dev_attr_rx_fifo_timeout.attr); 3211 &dev_attr_rx_fifo_timeout.attr);
3179 if (ret) { 3212 if (ret) {
@@ -3244,7 +3277,7 @@ early_platform_init_buffer("earlyprintk", &sci_driver,
3244 early_serial_buf, ARRAY_SIZE(early_serial_buf)); 3277 early_serial_buf, ARRAY_SIZE(early_serial_buf));
3245#endif 3278#endif
3246#ifdef CONFIG_SERIAL_SH_SCI_EARLYCON 3279#ifdef CONFIG_SERIAL_SH_SCI_EARLYCON
3247static struct __init plat_sci_port port_cfg; 3280static struct plat_sci_port port_cfg __initdata;
3248 3281
3249static int __init early_console_setup(struct earlycon_device *device, 3282static int __init early_console_setup(struct earlycon_device *device,
3250 int type) 3283 int type)
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index 938e23a2d166..a5f792fd48d9 100644
--- a/drivers/tty/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
@@ -63,6 +63,9 @@ enum {
63#define SCSCR_TDRQE BIT(15) /* Tx Data Transfer Request Enable */ 63#define SCSCR_TDRQE BIT(15) /* Tx Data Transfer Request Enable */
64#define SCSCR_RDRQE BIT(14) /* Rx Data Transfer Request Enable */ 64#define SCSCR_RDRQE BIT(14) /* Rx Data Transfer Request Enable */
65 65
66/* Serial Control Register, HSCIF-only bits */
67#define HSSCR_TOT_SHIFT 14
68
66/* SCxSR (Serial Status Register) on SCI */ 69/* SCxSR (Serial Status Register) on SCI */
67#define SCI_TDRE BIT(7) /* Transmit Data Register Empty */ 70#define SCI_TDRE BIT(7) /* Transmit Data Register Empty */
68#define SCI_RDRF BIT(6) /* Receive Data Register Full */ 71#define SCI_RDRF BIT(6) /* Receive Data Register Full */
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c
index 684cb8dd8050..9925b00a9777 100644
--- a/drivers/tty/serial/sirfsoc_uart.c
+++ b/drivers/tty/serial/sirfsoc_uart.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for CSR SiRFprimaII onboard UARTs. 3 * Driver for CSR SiRFprimaII onboard UARTs.
3 * 4 *
4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
5 *
6 * Licensed under GPLv2 or later.
7 */ 6 */
8 7
9#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/tty/serial/sirfsoc_uart.h b/drivers/tty/serial/sirfsoc_uart.h
index 43756bd9111c..004ca684d3ae 100644
--- a/drivers/tty/serial/sirfsoc_uart.h
+++ b/drivers/tty/serial/sirfsoc_uart.h
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Drivers for CSR SiRFprimaII onboard UARTs. 3 * Drivers for CSR SiRFprimaII onboard UARTs.
3 * 4 *
4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
5 *
6 * Licensed under GPLv2 or later.
7 */ 6 */
8#include <linux/bitops.h> 7#include <linux/bitops.h>
9#include <linux/log2.h> 8#include <linux/log2.h>
diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c
index 9e0e6586c698..ed78542c4c37 100644
--- a/drivers/tty/serial/sn_console.c
+++ b/drivers/tty/serial/sn_console.c
@@ -8,25 +8,6 @@
8 * 8 *
9 * Copyright (c) 2004-2006 Silicon Graphics, Inc. All Rights Reserved. 9 * Copyright (c) 2004-2006 Silicon Graphics, Inc. All Rights Reserved.
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of version 2 of the GNU General Public License
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it would be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 *
19 * Further, this software is distributed without any warranty that it is
20 * free of the rightful claim of any third person regarding infringement
21 * or the like. Any license provided herein, whether implied or
22 * otherwise, applies only to this software file. Patent licenses, if
23 * any, provided herein do not apply to combinations of this program with
24 * other software, or any other product whatsoever.
25 *
26 * You should have received a copy of the GNU General Public
27 * License along with this program; if not, write the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
29 *
30 * Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, 11 * Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
31 * Mountain View, CA 94043, or: 12 * Mountain View, CA 94043, or:
32 * 13 *
@@ -687,9 +668,7 @@ static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
687 * timer to poll for input and push data from the console 668 * timer to poll for input and push data from the console
688 * buffer. 669 * buffer.
689 */ 670 */
690 init_timer(&port->sc_timer); 671 setup_timer(&port->sc_timer, sn_sal_timer_poll, (unsigned long)port);
691 port->sc_timer.function = sn_sal_timer_poll;
692 port->sc_timer.data = (unsigned long)port;
693 672
694 if (IS_RUNNING_ON_SIMULATOR()) 673 if (IS_RUNNING_ON_SIMULATOR())
695 port->sc_interrupt_timeout = 6; 674 port->sc_interrupt_timeout = 6;
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index e902494ebbd5..828f1143859c 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -1,14 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2012-2015 Spreadtrum Communications Inc. 3 * Copyright (C) 2012-2015 Spreadtrum Communications Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */ 4 */
13 5
14#if defined(CONFIG_SERIAL_SPRD_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 6#if defined(CONFIG_SERIAL_SPRD_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index b313a792b149..c763253514e9 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -1,13 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * st-asc.c: ST Asynchronous serial controller (ASC) driver 3 * st-asc.c: ST Asynchronous serial controller (ASC) driver
3 * 4 *
4 * Copyright (C) 2003-2013 STMicroelectronics (R&D) Limited 5 * Copyright (C) 2003-2013 STMicroelectronics (R&D) Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 */ 6 */
12 7
13#if defined(CONFIG_SERIAL_ST_ASC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 8#if defined(CONFIG_SERIAL_ST_ASC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 03a583264d9e..0fa735b60f2d 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -1,9 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) Maxime Coquelin 2015 3 * Copyright (C) Maxime Coquelin 2015
3 * Copyright (C) STMicroelectronics SA 2017 4 * Copyright (C) STMicroelectronics SA 2017
4 * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com> 5 * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com>
5 * Gerald Baeza <gerald.baeza@st.com> 6 * Gerald Baeza <gerald.baeza@st.com>
6 * License terms: GNU General Public License (GPL), version 2
7 * 7 *
8 * Inspired by st-asc.c from STMicroelectronics (c) 8 * Inspired by st-asc.c from STMicroelectronics (c)
9 */ 9 */
@@ -736,11 +736,8 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev)
736 736
737#ifdef CONFIG_OF 737#ifdef CONFIG_OF
738static const struct of_device_id stm32_match[] = { 738static const struct of_device_id stm32_match[] = {
739 { .compatible = "st,stm32-usart", .data = &stm32f4_info},
740 { .compatible = "st,stm32-uart", .data = &stm32f4_info}, 739 { .compatible = "st,stm32-uart", .data = &stm32f4_info},
741 { .compatible = "st,stm32f7-usart", .data = &stm32f7_info},
742 { .compatible = "st,stm32f7-uart", .data = &stm32f7_info}, 740 { .compatible = "st,stm32f7-uart", .data = &stm32f7_info},
743 { .compatible = "st,stm32h7-usart", .data = &stm32h7_info},
744 { .compatible = "st,stm32h7-uart", .data = &stm32h7_info}, 741 { .compatible = "st,stm32h7-uart", .data = &stm32h7_info},
745 {}, 742 {},
746}; 743};
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index ffc0c5285e51..8a5ff54d0f42 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -1,9 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) Maxime Coquelin 2015 3 * Copyright (C) Maxime Coquelin 2015
3 * Copyright (C) STMicroelectronics SA 2017 4 * Copyright (C) STMicroelectronics SA 2017
4 * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com> 5 * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com>
5 * Gerald Baeza <gerald_baeza@yahoo.fr> 6 * Gerald Baeza <gerald_baeza@yahoo.fr>
6 * License terms: GNU General Public License (GPL), version 2
7 */ 7 */
8 8
9#define DRIVER_NAME "stm32-usart" 9#define DRIVER_NAME "stm32-usart"
diff --git a/drivers/tty/serial/suncore.c b/drivers/tty/serial/suncore.c
index 127472bd6a7c..70a4ea4eaa6e 100644
--- a/drivers/tty/serial/suncore.c
+++ b/drivers/tty/serial/suncore.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* suncore.c 2/* suncore.c
2 * 3 *
3 * Common SUN serial routines. Based entirely 4 * Common SUN serial routines. Based entirely
diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index 46e46894e918..63e34d868de8 100644
--- a/drivers/tty/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* sunhv.c: Serial driver for SUN4V hypervisor console. 2/* sunhv.c: Serial driver for SUN4V hypervisor console.
2 * 3 *
3 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net) 4 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net)
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 653a076d89d3..b93d0225f8c9 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* sunsab.c: ASYNC Driver for the SIEMENS SAB82532 DUSCC. 2/* sunsab.c: ASYNC Driver for the SIEMENS SAB82532 DUSCC.
2 * 3 *
3 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) 4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 95d34d7565c9..6cf3e9b0728f 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * su.c: Small serial driver for keyboard/mouse interface on sparc32/PCI 3 * su.c: Small serial driver for keyboard/mouse interface on sparc32/PCI
3 * 4 *
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index 252cea49c068..bc7af8b08a72 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* sunzilog.c: Zilog serial driver for Sparc systems. 2/* sunzilog.c: Zilog serial driver for Sparc systems.
2 * 3 *
3 * Driver for Zilog serial chips found on Sun workstations and 4 * Driver for Zilog serial chips found on Sun workstations and
diff --git a/drivers/tty/serial/tilegx.c b/drivers/tty/serial/tilegx.c
index 453215f5420d..f0a3ae57f881 100644
--- a/drivers/tty/serial/tilegx.c
+++ b/drivers/tty/serial/tilegx.c
@@ -1,16 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2013 Tilera Corporation. All Rights Reserved. 3 * Copyright 2013 Tilera Corporation. All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 *
14 * TILEGx UART driver. 5 * TILEGx UART driver.
15 */ 6 */
16 7
diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index 5da7fe40e391..19d38b504e27 100644
--- a/drivers/tty/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
@@ -1,19 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * timbuart.c timberdale FPGA UART driver 3 * timbuart.c timberdale FPGA UART driver
3 * Copyright (c) 2009 Intel Corporation 4 * Copyright (c) 2009 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 5 */
18 6
19/* Supports: 7/* Supports:
diff --git a/drivers/tty/serial/timbuart.h b/drivers/tty/serial/timbuart.h
index 7e566766bc43..fb00b172117d 100644
--- a/drivers/tty/serial/timbuart.h
+++ b/drivers/tty/serial/timbuart.h
@@ -1,19 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * timbuart.c timberdale FPGA GPIO driver 3 * timbuart.c timberdale FPGA GPIO driver
3 * Copyright (c) 2009 Intel Corporation 4 * Copyright (c) 2009 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 5 */
18 6
19/* Supports: 7/* Supports:
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index c9b8d702dadc..c47db7826189 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * uartlite.c: Serial driver for Xilinx uartlite serial controller 3 * uartlite.c: Serial driver for Xilinx uartlite serial controller
3 * 4 *
4 * Copyright (C) 2006 Peter Korsgaard <jacmet@sunsite.dk> 5 * Copyright (C) 2006 Peter Korsgaard <jacmet@sunsite.dk>
5 * Copyright (C) 2007 Secret Lab Technologies Ltd. 6 * Copyright (C) 2007 Secret Lab Technologies Ltd.
6 *
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.
10 */ 7 */
11 8
12#include <linux/platform_device.h> 9#include <linux/platform_device.h>
@@ -739,7 +736,7 @@ static int __init ulite_init(void)
739err_plat: 736err_plat:
740 uart_unregister_driver(&ulite_uart_driver); 737 uart_unregister_driver(&ulite_uart_driver);
741err_uart: 738err_uart:
742 pr_err("registering uartlite driver failed: err=%i", ret); 739 pr_err("registering uartlite driver failed: err=%i\n", ret);
743 return ret; 740 return ret;
744} 741}
745 742
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 55b702775786..2b6376e6e5ad 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -1,12 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Freescale QUICC Engine UART device driver 3 * Freescale QUICC Engine UART device driver
3 * 4 *
4 * Author: Timur Tabi <timur@freescale.com> 5 * Author: Timur Tabi <timur@freescale.com>
5 * 6 *
6 * Copyright 2007 Freescale Semiconductor, Inc. This file is licensed under 7 * Copyright 2007 Freescale Semiconductor, Inc.
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 * 8 *
11 * This driver adds support for UART devices via Freescale's QUICC Engine 9 * This driver adds support for UART devices via Freescale's QUICC Engine
12 * found on some Freescale SOCs. 10 * found on some Freescale SOCs.
diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c
index 439057e8107a..6d106e33f842 100644
--- a/drivers/tty/serial/vr41xx_siu.c
+++ b/drivers/tty/serial/vr41xx_siu.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for NEC VR4100 series Serial Interface Unit. 3 * Driver for NEC VR4100 series Serial Interface Unit.
3 * 4 *
4 * Copyright (C) 2004-2008 Yoichi Yuasa <yuasa@linux-mips.org> 5 * Copyright (C) 2004-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 6 *
6 * Based on drivers/serial/8250.c, by Russell King. 7 * Based on drivers/serial/8250.c, by Russell King.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 8 */
22 9
23#if defined(CONFIG_SERIAL_VR41XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 10#if defined(CONFIG_SERIAL_VR41XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 435a6f3260be..3d58e9b34553 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com> 3 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
3 * 4 *
4 * Based on msm_serial.c, which is: 5 * Based on msm_serial.c, which is:
5 * Copyright (C) 2007 Google, Inc. 6 * Copyright (C) 2007 Google, Inc.
6 * Author: Robert Love <rlove@google.com> 7 * Author: Robert Love <rlove@google.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#if defined(CONFIG_SERIAL_VT8500_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 10#if defined(CONFIG_SERIAL_VT8500_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 31a630ae0870..b9b2bc76bcac 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1,14 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Cadence UART driver (found in Xilinx Zynq) 3 * Cadence UART driver (found in Xilinx Zynq)
3 * 4 *
4 * 2011 - 2014 (C) Xilinx Inc. 5 * 2011 - 2014 (C) Xilinx Inc.
5 * 6 *
6 * This program is free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation;
9 * either version 2 of the License, or (at your option) any
10 * later version.
11 *
12 * This driver has originally been pushed by Xilinx using a Zynq-branding. This 7 * This driver has originally been pushed by Xilinx using a Zynq-branding. This
13 * still shows in the naming of this file, the kconfig symbols and some symbols 8 * still shows in the naming of this file, the kconfig symbols and some symbols
14 * in the code. 9 * in the code.
@@ -1673,7 +1668,7 @@ static void __exit cdns_uart_exit(void)
1673 uart_unregister_driver(&cdns_uart_uart_driver); 1668 uart_unregister_driver(&cdns_uart_uart_driver);
1674} 1669}
1675 1670
1676module_init(cdns_uart_init); 1671arch_initcall(cdns_uart_init);
1677module_exit(cdns_uart_exit); 1672module_exit(cdns_uart_exit);
1678 1673
1679MODULE_DESCRIPTION("Driver for Cadence UART"); 1674MODULE_DESCRIPTION("Driver for Cadence UART");
diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c
index d32bd499d684..b03d3e458ea2 100644
--- a/drivers/tty/serial/zs.c
+++ b/drivers/tty/serial/zs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * zs.c: Serial port driver for IOASIC DECstations. 3 * zs.c: Serial port driver for IOASIC DECstations.
3 * 4 *