aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/scan.c37
-rw-r--r--drivers/tty/amiserial.c1
-rw-r--r--drivers/tty/bfin_jtag_comm.c3
-rw-r--r--drivers/tty/cyclades.c17
-rw-r--r--drivers/tty/ehv_bytechan.c9
-rw-r--r--drivers/tty/goldfish.c11
-rw-r--r--drivers/tty/hvc/hvc_bfin_jtag.c3
-rw-r--r--drivers/tty/hvc/hvc_console.c15
-rw-r--r--drivers/tty/hvc/hvc_console.h15
-rw-r--r--drivers/tty/hvc/hvc_dcc.c13
-rw-r--r--drivers/tty/hvc/hvc_opal.c16
-rw-r--r--drivers/tty/hvc/hvc_rtas.c15
-rw-r--r--drivers/tty/hvc/hvc_tile.c11
-rw-r--r--drivers/tty/hvc/hvc_udbg.c15
-rw-r--r--drivers/tty/hvc/hvc_vio.c15
-rw-r--r--drivers/tty/hvc/hvc_xen.c15
-rw-r--r--drivers/tty/hvc/hvcs.c15
-rw-r--r--drivers/tty/hvc/hvsi.c15
-rw-r--r--drivers/tty/ipwireless/main.c1
-rw-r--r--drivers/tty/isicom.c6
-rw-r--r--drivers/tty/metag_da.c16
-rw-r--r--drivers/tty/mips_ejtag_fdc.c13
-rw-r--r--drivers/tty/moxa.c6
-rw-r--r--drivers/tty/mxser.c22
-rw-r--r--drivers/tty/n_gsm.c18
-rw-r--r--drivers/tty/n_hdlc.c3
-rw-r--r--drivers/tty/n_null.c14
-rw-r--r--drivers/tty/n_r3964.c4
-rw-r--r--drivers/tty/n_tracerouter.c12
-rw-r--r--drivers/tty/n_tracesink.c12
-rw-r--r--drivers/tty/n_tracesink.h12
-rw-r--r--drivers/tty/n_tty.c4
-rw-r--r--drivers/tty/nozomi.c15
-rw-r--r--drivers/tty/rocket.c15
-rw-r--r--drivers/tty/serdev/Kconfig8
-rw-r--r--drivers/tty/serdev/core.c152
-rw-r--r--drivers/tty/serdev/serdev-ttyport.c31
-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
-rw-r--r--drivers/tty/synclink.c6
-rw-r--r--drivers/tty/synclink_gt.c3
-rw-r--r--drivers/tty/synclinkmp.c2
-rw-r--r--drivers/tty/sysrq.c18
-rw-r--r--drivers/tty/tty_audit.c6
-rw-r--r--drivers/tty/tty_baudrate.c1
-rw-r--r--drivers/tty/tty_buffer.c3
-rw-r--r--drivers/tty/tty_io.c1
-rw-r--r--drivers/tty/tty_ioctl.c1
-rw-r--r--drivers/tty/tty_jobctrl.c1
-rw-r--r--drivers/tty/tty_ldisc.c1
-rw-r--r--drivers/tty/tty_ldsem.c4
-rw-r--r--drivers/tty/tty_port.c5
-rw-r--r--drivers/tty/vcc.c25
-rw-r--r--drivers/tty/vt/consolemap.c1
-rw-r--r--drivers/tty/vt/keyboard.c1
-rw-r--r--drivers/tty/vt/vt.c107
188 files changed, 1242 insertions, 1644 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 81367edc8a10..e14e964bfe6d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1505,41 +1505,38 @@ static void acpi_init_coherency(struct acpi_device *adev)
1505 adev->flags.coherent_dma = cca; 1505 adev->flags.coherent_dma = cca;
1506} 1506}
1507 1507
1508static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data) 1508static int acpi_check_serial_bus_slave(struct acpi_resource *ares, void *data)
1509{ 1509{
1510 bool *is_spi_i2c_slave_p = data; 1510 bool *is_serial_bus_slave_p = data;
1511 1511
1512 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) 1512 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
1513 return 1; 1513 return 1;
1514 1514
1515 /* 1515 *is_serial_bus_slave_p = true;
1516 * devices that are connected to UART still need to be enumerated to
1517 * platform bus
1518 */
1519 if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
1520 *is_spi_i2c_slave_p = true;
1521 1516
1522 /* no need to do more checking */ 1517 /* no need to do more checking */
1523 return -1; 1518 return -1;
1524} 1519}
1525 1520
1526static bool acpi_is_spi_i2c_slave(struct acpi_device *device) 1521static bool acpi_is_serial_bus_slave(struct acpi_device *device)
1527{ 1522{
1528 struct list_head resource_list; 1523 struct list_head resource_list;
1529 bool is_spi_i2c_slave = false; 1524 bool is_serial_bus_slave = false;
1530 1525
1531 /* Macs use device properties in lieu of _CRS resources */ 1526 /* Macs use device properties in lieu of _CRS resources */
1532 if (x86_apple_machine && 1527 if (x86_apple_machine &&
1533 (fwnode_property_present(&device->fwnode, "spiSclkPeriod") || 1528 (fwnode_property_present(&device->fwnode, "spiSclkPeriod") ||
1534 fwnode_property_present(&device->fwnode, "i2cAddress"))) 1529 fwnode_property_present(&device->fwnode, "i2cAddress") ||
1530 fwnode_property_present(&device->fwnode, "baud")))
1535 return true; 1531 return true;
1536 1532
1537 INIT_LIST_HEAD(&resource_list); 1533 INIT_LIST_HEAD(&resource_list);
1538 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave, 1534 acpi_dev_get_resources(device, &resource_list,
1539 &is_spi_i2c_slave); 1535 acpi_check_serial_bus_slave,
1536 &is_serial_bus_slave);
1540 acpi_dev_free_resource_list(&resource_list); 1537 acpi_dev_free_resource_list(&resource_list);
1541 1538
1542 return is_spi_i2c_slave; 1539 return is_serial_bus_slave;
1543} 1540}
1544 1541
1545void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 1542void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
@@ -1557,7 +1554,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1557 acpi_bus_get_flags(device); 1554 acpi_bus_get_flags(device);
1558 device->flags.match_driver = false; 1555 device->flags.match_driver = false;
1559 device->flags.initialized = true; 1556 device->flags.initialized = true;
1560 device->flags.spi_i2c_slave = acpi_is_spi_i2c_slave(device); 1557 device->flags.serial_bus_slave = acpi_is_serial_bus_slave(device);
1561 acpi_device_clear_enumerated(device); 1558 acpi_device_clear_enumerated(device);
1562 device_initialize(&device->dev); 1559 device_initialize(&device->dev);
1563 dev_set_uevent_suppress(&device->dev, true); 1560 dev_set_uevent_suppress(&device->dev, true);
@@ -1841,10 +1838,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1841static void acpi_default_enumeration(struct acpi_device *device) 1838static void acpi_default_enumeration(struct acpi_device *device)
1842{ 1839{
1843 /* 1840 /*
1844 * Do not enumerate SPI/I2C slaves as they will be enumerated by their 1841 * Do not enumerate SPI/I2C/UART slaves as they will be enumerated by
1845 * respective parents. 1842 * their respective parents.
1846 */ 1843 */
1847 if (!device->flags.spi_i2c_slave) { 1844 if (!device->flags.serial_bus_slave) {
1848 acpi_create_platform_device(device, NULL); 1845 acpi_create_platform_device(device, NULL);
1849 acpi_device_set_enumerated(device); 1846 acpi_device_set_enumerated(device);
1850 } else { 1847 } else {
@@ -1941,7 +1938,7 @@ static void acpi_bus_attach(struct acpi_device *device)
1941 return; 1938 return;
1942 1939
1943 device->flags.match_driver = true; 1940 device->flags.match_driver = true;
1944 if (ret > 0 && !device->flags.spi_i2c_slave) { 1941 if (ret > 0 && !device->flags.serial_bus_slave) {
1945 acpi_device_set_enumerated(device); 1942 acpi_device_set_enumerated(device);
1946 goto ok; 1943 goto ok;
1947 } 1944 }
@@ -1950,7 +1947,7 @@ static void acpi_bus_attach(struct acpi_device *device)
1950 if (ret < 0) 1947 if (ret < 0)
1951 return; 1948 return;
1952 1949
1953 if (!device->pnp.type.platform_id && !device->flags.spi_i2c_slave) 1950 if (!device->pnp.type.platform_id && !device->flags.serial_bus_slave)
1954 acpi_device_set_enumerated(device); 1951 acpi_device_set_enumerated(device);
1955 else 1952 else
1956 acpi_default_enumeration(device); 1953 acpi_default_enumeration(device);
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 9820e20993db..32d7ce430b02 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Serial driver for the amiga builtin port. 3 * Serial driver for the amiga builtin port.
3 * 4 *
diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c
index ce24182f8514..c369bf27a67b 100644
--- a/drivers/tty/bfin_jtag_comm.c
+++ b/drivers/tty/bfin_jtag_comm.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * TTY over Blackfin JTAG Communication 3 * TTY over Blackfin JTAG Communication
3 * 4 *
4 * Copyright 2008-2009 Analog Devices Inc. 5 * Copyright 2008-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#define DRV_NAME "bfin-jtag-comm" 10#define DRV_NAME "bfin-jtag-comm"
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index dac8a1a8e4ac..5d442469c95e 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#undef BLOCKMOVE 2#undef BLOCKMOVE
2#define Z_WAKE 3#define Z_WAKE
3#undef Z_EXT_CHARS_IN_BUFFER 4#undef Z_EXT_CHARS_IN_BUFFER
@@ -286,8 +287,7 @@ static long cyz_polling_cycle = CZ_DEF_POLL;
286static DEFINE_TIMER(cyz_timerlist, cyz_poll); 287static DEFINE_TIMER(cyz_timerlist, cyz_poll);
287 288
288#else /* CONFIG_CYZ_INTR */ 289#else /* CONFIG_CYZ_INTR */
289static void cyz_rx_restart(unsigned long); 290static void cyz_rx_restart(struct timer_list *);
290static struct timer_list cyz_rx_full_timer[NR_PORTS];
291#endif /* CONFIG_CYZ_INTR */ 291#endif /* CONFIG_CYZ_INTR */
292 292
293static void cyy_writeb(struct cyclades_port *port, u32 reg, u8 val) 293static void cyy_writeb(struct cyclades_port *port, u32 reg, u8 val)
@@ -992,10 +992,8 @@ static void cyz_handle_rx(struct cyclades_port *info)
992 else 992 else
993 char_count = rx_put - rx_get + rx_bufsize; 993 char_count = rx_put - rx_get + rx_bufsize;
994 if (char_count >= readl(&buf_ctrl->rx_threshold) && 994 if (char_count >= readl(&buf_ctrl->rx_threshold) &&
995 !timer_pending(&cyz_rx_full_timer[ 995 !timer_pending(&info->rx_full_timer))
996 info->line])) 996 mod_timer(&info->rx_full_timer, jiffies + 1);
997 mod_timer(&cyz_rx_full_timer[info->line],
998 jiffies + 1);
999#endif 997#endif
1000 info->idle_stats.recv_idle = jiffies; 998 info->idle_stats.recv_idle = jiffies;
1001 tty_schedule_flip(&info->port); 999 tty_schedule_flip(&info->port);
@@ -1197,9 +1195,9 @@ static irqreturn_t cyz_interrupt(int irq, void *dev_id)
1197 return IRQ_HANDLED; 1195 return IRQ_HANDLED;
1198} /* cyz_interrupt */ 1196} /* cyz_interrupt */
1199 1197
1200static void cyz_rx_restart(unsigned long arg) 1198static void cyz_rx_restart(struct timer_list *t)
1201{ 1199{
1202 struct cyclades_port *info = (struct cyclades_port *)arg; 1200 struct cyclades_port *info = from_timer(info, t, rx_full_timer);
1203 struct cyclades_card *card = info->card; 1201 struct cyclades_card *card = info->card;
1204 int retval; 1202 int retval;
1205 __u32 channel = info->line - card->first_line; 1203 __u32 channel = info->line - card->first_line;
@@ -3097,8 +3095,7 @@ static int cy_init_card(struct cyclades_card *cinfo)
3097 else 3095 else
3098 info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE; 3096 info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE;
3099#ifdef CONFIG_CYZ_INTR 3097#ifdef CONFIG_CYZ_INTR
3100 setup_timer(&cyz_rx_full_timer[port], 3098 timer_setup(&info->rx_full_timer, cyz_rx_restart, 0);
3101 cyz_rx_restart, (unsigned long)info);
3102#endif 3099#endif
3103 } else { 3100 } else {
3104 unsigned short chip_number; 3101 unsigned short chip_number;
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index a1c7125cb968..47ac56817c43 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* ePAPR hypervisor byte channel device driver 2/* ePAPR hypervisor byte channel device driver
2 * 3 *
3 * Copyright 2009-2011 Freescale Semiconductor, Inc. 4 * Copyright 2009-2011 Freescale Semiconductor, Inc.
4 * 5 *
5 * Author: Timur Tabi <timur@freescale.com> 6 * Author: Timur Tabi <timur@freescale.com>
6 * 7 *
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 *
11 * This driver support three distinct interfaces, all of which are related to 8 * This driver support three distinct interfaces, all of which are related to
12 * ePAPR hypervisor byte channels. 9 * ePAPR hypervisor byte channels.
13 * 10 *
@@ -328,7 +325,7 @@ console_initcall(ehv_bc_console_init);
328/******************************** TTY DRIVER ********************************/ 325/******************************** TTY DRIVER ********************************/
329 326
330/* 327/*
331 * byte channel receive interupt handler 328 * byte channel receive interrupt handler
332 * 329 *
333 * This ISR is called whenever data is available on a byte channel. 330 * This ISR is called whenever data is available on a byte channel.
334 */ 331 */
@@ -428,7 +425,7 @@ static void ehv_bc_tx_dequeue(struct ehv_bc_data *bc)
428} 425}
429 426
430/* 427/*
431 * byte channel transmit interupt handler 428 * byte channel transmit interrupt handler
432 * 429 *
433 * This ISR is called whenever space becomes available for transmitting 430 * This ISR is called whenever space becomes available for transmitting
434 * characters on a byte channel. 431 * characters on a byte channel.
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 381e981dee06..7f657bb5113c 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -1,17 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2007 Google, Inc. 3 * Copyright (C) 2007 Google, Inc.
3 * Copyright (C) 2012 Intel, Inc. 4 * Copyright (C) 2012 Intel, Inc.
4 * Copyright (C) 2017 Imagination Technologies Ltd. 5 * Copyright (C) 2017 Imagination Technologies Ltd.
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
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
17#include <linux/console.h> 8#include <linux/console.h>
diff --git a/drivers/tty/hvc/hvc_bfin_jtag.c b/drivers/tty/hvc/hvc_bfin_jtag.c
index 31d6cc6a77af..dd7cae4c195b 100644
--- a/drivers/tty/hvc/hvc_bfin_jtag.c
+++ b/drivers/tty/hvc/hvc_bfin_jtag.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Console via Blackfin JTAG Communication 3 * Console via Blackfin JTAG Communication
3 * 4 *
4 * Copyright 2008-2011 Analog Devices Inc. 5 * Copyright 2008-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#include <linux/console.h> 10#include <linux/console.h>
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index a8d399188242..7709fcc707f4 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM 3 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
3 * Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM 4 * Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM
@@ -6,20 +7,6 @@
6 * 7 *
7 * Additional Author(s): 8 * Additional Author(s):
8 * Ryan S. Arnold <rsa@us.ibm.com> 9 * Ryan S. Arnold <rsa@us.ibm.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 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 */ 10 */
24 11
25#include <linux/console.h> 12#include <linux/console.h>
diff --git a/drivers/tty/hvc/hvc_console.h b/drivers/tty/hvc/hvc_console.h
index 798c48d0d32c..ea63090e013f 100644
--- a/drivers/tty/hvc/hvc_console.h
+++ b/drivers/tty/hvc/hvc_console.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * hvc_console.h 3 * hvc_console.h
3 * Copyright (C) 2005 IBM Corporation 4 * Copyright (C) 2005 IBM Corporation
@@ -8,20 +9,6 @@
8 * hvc_console header information: 9 * hvc_console header information:
9 * moved here from arch/powerpc/include/asm/hvconsole.h 10 * moved here from arch/powerpc/include/asm/hvconsole.h
10 * and drivers/char/hvc_console.c 11 * and drivers/char/hvc_console.c
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 */ 12 */
26 13
27#ifndef HVC_CONSOLE_H 14#ifndef HVC_CONSOLE_H
diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
index 82f240fb98f0..02629a1f193d 100644
--- a/drivers/tty/hvc/hvc_dcc.c
+++ b/drivers/tty/hvc/hvc_dcc.c
@@ -1,14 +1,5 @@
1/* Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved. 1// SPDX-License-Identifier: GPL-2.0
2 * 2/* Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved. */
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12 3
13#include <linux/init.h> 4#include <linux/init.h>
14 5
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 16331a90c1e8..2ed07ca6389e 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -1,22 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * opal driver interface to hvc_console.c 3 * opal driver interface to hvc_console.c
3 * 4 *
4 * Copyright 2011 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp. 5 * Copyright 2011 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
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 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 6 */
21 7
22#undef DEBUG 8#undef DEBUG
diff --git a/drivers/tty/hvc/hvc_rtas.c b/drivers/tty/hvc/hvc_rtas.c
index 08c87920b74a..e8b8c645482b 100644
--- a/drivers/tty/hvc/hvc_rtas.c
+++ b/drivers/tty/hvc/hvc_rtas.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * IBM RTAS driver interface to hvc_console.c 3 * IBM RTAS driver interface to hvc_console.c
3 * 4 *
@@ -11,20 +12,6 @@
11 * 12 *
12 * inspired by drivers/char/hvc_console.c 13 * inspired by drivers/char/hvc_console.c
13 * written by Anton Blanchard and Paul Mackerras 14 * written by Anton Blanchard and Paul Mackerras
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 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */ 15 */
29 16
30#include <linux/console.h> 17#include <linux/console.h>
diff --git a/drivers/tty/hvc/hvc_tile.c b/drivers/tty/hvc/hvc_tile.c
index 9da1e842bbe9..b517c0661abb 100644
--- a/drivers/tty/hvc/hvc_tile.c
+++ b/drivers/tty/hvc/hvc_tile.c
@@ -1,16 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved. 3 * Copyright 2010 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 * Tilera TILE Processor hypervisor console 5 * Tilera TILE Processor hypervisor console
15 */ 6 */
16 7
diff --git a/drivers/tty/hvc/hvc_udbg.c b/drivers/tty/hvc/hvc_udbg.c
index 9cf573d06a29..a4c9913f76a0 100644
--- a/drivers/tty/hvc/hvc_udbg.c
+++ b/drivers/tty/hvc/hvc_udbg.c
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * udbg interface to hvc_console.c 3 * udbg interface to hvc_console.c
3 * 4 *
4 * (C) Copyright David Gibson, IBM Corporation 2008. 5 * (C) Copyright David Gibson, IBM Corporation 2008.
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 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 6 */
20 7
21#include <linux/console.h> 8#include <linux/console.h>
diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c
index a1d272ac82bb..59eaa620bf13 100644
--- a/drivers/tty/hvc/hvc_vio.c
+++ b/drivers/tty/hvc/hvc_vio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * vio driver interface to hvc_console.c 3 * vio driver interface to hvc_console.c
3 * 4 *
@@ -14,20 +15,6 @@
14 * Additional Author(s): 15 * Additional Author(s):
15 * Ryan S. Arnold <rsa@us.ibm.com> 16 * Ryan S. Arnold <rsa@us.ibm.com>
16 * 17 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 *
31 * TODO: 18 * TODO:
32 * 19 *
33 * - handle error in sending hvsi protocol packets 20 * - handle error in sending hvsi protocol packets
diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index 5e87e4866bcb..dc43fa96c3de 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * xen console driver interface to hvc_console.c 3 * xen console driver interface to hvc_console.c
3 * 4 *
4 * (c) 2007 Gerd Hoffmann <kraxel@suse.de> 5 * (c) 2007 Gerd Hoffmann <kraxel@suse.de>
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 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 6 */
20 7
21#include <linux/console.h> 8#include <linux/console.h>
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 63c29fe9d21f..1db1d97e72e7 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * IBM eServer Hypervisor Virtual Console Server Device Driver 3 * IBM eServer Hypervisor Virtual Console Server Device Driver
3 * Copyright (C) 2003, 2004 IBM Corp. 4 * Copyright (C) 2003, 2004 IBM Corp.
4 * Ryan S. Arnold (rsa@us.ibm.com) 5 * Ryan S. Arnold (rsa@us.ibm.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 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 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Author(s) : Ryan S. Arnold <rsa@us.ibm.com> 7 * Author(s) : Ryan S. Arnold <rsa@us.ibm.com>
21 * 8 *
22 * This is the device driver for the IBM Hypervisor Virtual Console Server, 9 * This is the device driver for the IBM Hypervisor Virtual Console Server,
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index 2e578d6433af..66f95f758be0 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2004 Hollis Blanchard <hollisb@us.ibm.com>, IBM 3 * Copyright (C) 2004 Hollis Blanchard <hollisb@us.ibm.com>, IBM
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 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 4 */
18 5
19/* Host Virtual Serial Interface (HVSI) is a protocol between the hosted OS 6/* Host Virtual Serial Interface (HVSI) is a protocol between the hosted OS
diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c
index 655c7948261c..3475e841ef5c 100644
--- a/drivers/tty/ipwireless/main.c
+++ b/drivers/tty/ipwireless/main.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * IPWireless 3G PCMCIA Network Driver 3 * IPWireless 3G PCMCIA Network Driver
3 * 4 *
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 40af32108ff5..ee7958ab269f 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -1,9 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version
5 * 2 of the License, or (at your option) any later version.
6 *
7 * Original driver code supplied by Multi-Tech 3 * Original driver code supplied by Multi-Tech
8 * 4 *
9 * Changes 5 * Changes
diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c
index 25ccef2fe748..99eaed4b2dbc 100644
--- a/drivers/tty/metag_da.c
+++ b/drivers/tty/metag_da.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * dashtty.c - tty driver for Dash channels interface. 3 * dashtty.c - tty driver for Dash channels interface.
3 * 4 *
4 * Copyright (C) 2007,2008,2012 Imagination Technologies 5 * Copyright (C) 2007,2008,2012 Imagination Technologies
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 *
10 */ 6 */
11 7
12#include <linux/atomic.h> 8#include <linux/atomic.h>
@@ -309,7 +305,7 @@ static int put_data(void *arg)
309/* 305/*
310 * This gets called every DA_TTY_POLL and polls the channels for data 306 * This gets called every DA_TTY_POLL and polls the channels for data
311 */ 307 */
312static void dashtty_timer(unsigned long ignored) 308static void dashtty_timer(struct timer_list *poll_timer)
313{ 309{
314 int channel; 310 int channel;
315 311
@@ -323,12 +319,12 @@ static void dashtty_timer(unsigned long ignored)
323 if (channel >= 0) 319 if (channel >= 0)
324 fetch_data(channel); 320 fetch_data(channel);
325 321
326 mod_timer(&poll_timer, jiffies + DA_TTY_POLL); 322 mod_timer(poll_timer, jiffies + DA_TTY_POLL);
327} 323}
328 324
329static void add_poll_timer(struct timer_list *poll_timer) 325static void add_poll_timer(struct timer_list *poll_timer)
330{ 326{
331 setup_pinned_timer(poll_timer, dashtty_timer, 0); 327 timer_setup(poll_timer, dashtty_timer, TIMER_PINNED);
332 poll_timer->expires = jiffies + DA_TTY_POLL; 328 poll_timer->expires = jiffies + DA_TTY_POLL;
333 329
334 /* 330 /*
@@ -461,7 +457,7 @@ static void dashtty_hangup(struct tty_struct *tty)
461 * buffers. It is used to delay the expensive writeout until the writer has 457 * buffers. It is used to delay the expensive writeout until the writer has
462 * stopped writing. 458 * stopped writing.
463 */ 459 */
464static void dashtty_put_timer(unsigned long ignored) 460static void dashtty_put_timer(struct timer_list *unused)
465{ 461{
466 if (atomic_read(&dashtty_xmit_cnt)) 462 if (atomic_read(&dashtty_xmit_cnt))
467 wake_up_interruptible(&dashtty_waitqueue); 463 wake_up_interruptible(&dashtty_waitqueue);
@@ -603,7 +599,7 @@ static int __init dashtty_init(void)
603 complete(&dport->xmit_empty); 599 complete(&dport->xmit_empty);
604 } 600 }
605 601
606 setup_timer(&put_timer, dashtty_put_timer, 0); 602 timer_setup(&put_timer, dashtty_put_timer, 0);
607 603
608 init_waitqueue_head(&dashtty_waitqueue); 604 init_waitqueue_head(&dashtty_waitqueue);
609 dashtty_thread = kthread_create(put_data, NULL, "ttyDA"); 605 dashtty_thread = kthread_create(put_data, NULL, "ttyDA");
diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c
index a2dab3fb8751..4c1cd49ae95b 100644
--- a/drivers/tty/mips_ejtag_fdc.c
+++ b/drivers/tty/mips_ejtag_fdc.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * TTY driver for MIPS EJTAG Fast Debug Channels. 3 * TTY driver for MIPS EJTAG Fast Debug Channels.
3 * 4 *
4 * Copyright (C) 2007-2015 Imagination Technologies Ltd 5 * Copyright (C) 2007-2015 Imagination Technologies Ltd
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for more
8 * details.
9 */ 6 */
10 7
11#include <linux/atomic.h> 8#include <linux/atomic.h>
@@ -683,9 +680,9 @@ static irqreturn_t mips_ejtag_fdc_isr(int irq, void *dev_id)
683 * It simply triggers the common FDC handler code and arranges for further 680 * It simply triggers the common FDC handler code and arranges for further
684 * polling. 681 * polling.
685 */ 682 */
686static void mips_ejtag_fdc_tty_timer(unsigned long opaque) 683static void mips_ejtag_fdc_tty_timer(struct timer_list *t)
687{ 684{
688 struct mips_ejtag_fdc_tty *priv = (void *)opaque; 685 struct mips_ejtag_fdc_tty *priv = from_timer(priv, t, poll_timer);
689 686
690 mips_ejtag_fdc_handle(priv); 687 mips_ejtag_fdc_handle(priv);
691 if (!priv->removing) 688 if (!priv->removing)
@@ -1002,8 +999,8 @@ static int mips_ejtag_fdc_tty_probe(struct mips_cdmm_device *dev)
1002 raw_spin_unlock_irq(&priv->lock); 999 raw_spin_unlock_irq(&priv->lock);
1003 } else { 1000 } else {
1004 /* If we didn't get an usable IRQ, poll instead */ 1001 /* If we didn't get an usable IRQ, poll instead */
1005 setup_pinned_timer(&priv->poll_timer, mips_ejtag_fdc_tty_timer, 1002 timer_setup(&priv->poll_timer, mips_ejtag_fdc_tty_timer,
1006 (unsigned long)priv); 1003 TIMER_PINNED);
1007 priv->poll_timer.expires = jiffies + FDC_TTY_POLL; 1004 priv->poll_timer.expires = jiffies + FDC_TTY_POLL;
1008 /* 1005 /*
1009 * Always attach the timer to the right CPU. The channels are 1006 * Always attach the timer to the right CPU. The channels are
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 93d37655d928..65a70f3c7cde 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/*****************************************************************************/ 2/*****************************************************************************/
2/* 3/*
3 * moxa.c -- MOXA Intellio family multiport serial driver. 4 * moxa.c -- MOXA Intellio family multiport serial driver.
@@ -7,11 +8,6 @@
7 * 8 *
8 * This code is loosely based on the Linux serial driver, written by 9 * This code is loosely based on the Linux serial driver, written by
9 * Linus Torvalds, Theodore T'so and others. 10 * Linus Torvalds, Theodore T'so and others.
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 */ 11 */
16 12
17/* 13/*
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 7dd38047ba23..8bc15cb67a58 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * mxser.c -- MOXA Smartio/Industio family multiport serial driver. 3 * mxser.c -- MOXA Smartio/Industio family multiport serial driver.
3 * 4 *
@@ -8,11 +9,6 @@
8 * Linux serial driver, written by Linus Torvalds, Theodore T'so and 9 * Linux serial driver, written by Linus Torvalds, Theodore T'so and
9 * others. 10 * others.
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 * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox 12 * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox
17 * <alan@lxorguk.ukuu.org.uk>. The original 1.8 code is available on 13 * <alan@lxorguk.ukuu.org.uk>. The original 1.8 code is available on
18 * www.moxa.com. 14 * www.moxa.com.
@@ -642,8 +638,7 @@ static int mxser_set_baud(struct tty_struct *tty, long newspd)
642 * This routine is called to set the UART divisor registers to match 638 * This routine is called to set the UART divisor registers to match
643 * the specified baud rate for a serial port. 639 * the specified baud rate for a serial port.
644 */ 640 */
645static int mxser_change_speed(struct tty_struct *tty, 641static int mxser_change_speed(struct tty_struct *tty)
646 struct ktermios *old_termios)
647{ 642{
648 struct mxser_port *info = tty->driver_data; 643 struct mxser_port *info = tty->driver_data;
649 unsigned cflag, cval, fcr; 644 unsigned cflag, cval, fcr;
@@ -945,7 +940,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
945 /* 940 /*
946 * and set the speed of the serial port 941 * and set the speed of the serial port
947 */ 942 */
948 mxser_change_speed(tty, NULL); 943 mxser_change_speed(tty);
949 spin_unlock_irqrestore(&info->slock, flags); 944 spin_unlock_irqrestore(&info->slock, flags);
950 945
951 return 0; 946 return 0;
@@ -1288,7 +1283,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
1288 if (tty_port_initialized(port)) { 1283 if (tty_port_initialized(port)) {
1289 if (flags != (port->flags & ASYNC_SPD_MASK)) { 1284 if (flags != (port->flags & ASYNC_SPD_MASK)) {
1290 spin_lock_irqsave(&info->slock, sl_flags); 1285 spin_lock_irqsave(&info->slock, sl_flags);
1291 mxser_change_speed(tty, NULL); 1286 mxser_change_speed(tty);
1292 spin_unlock_irqrestore(&info->slock, sl_flags); 1287 spin_unlock_irqrestore(&info->slock, sl_flags);
1293 } 1288 }
1294 } else { 1289 } else {
@@ -1946,7 +1941,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
1946 unsigned long flags; 1941 unsigned long flags;
1947 1942
1948 spin_lock_irqsave(&info->slock, flags); 1943 spin_lock_irqsave(&info->slock, flags);
1949 mxser_change_speed(tty, old_termios); 1944 mxser_change_speed(tty);
1950 spin_unlock_irqrestore(&info->slock, flags); 1945 spin_unlock_irqrestore(&info->slock, flags);
1951 1946
1952 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) { 1947 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
@@ -2375,8 +2370,7 @@ static void mxser_release_ISA_res(struct mxser_board *brd)
2375 mxser_release_vector(brd); 2370 mxser_release_vector(brd);
2376} 2371}
2377 2372
2378static int mxser_initbrd(struct mxser_board *brd, 2373static int mxser_initbrd(struct mxser_board *brd)
2379 struct pci_dev *pdev)
2380{ 2374{
2381 struct mxser_port *info; 2375 struct mxser_port *info;
2382 unsigned int i; 2376 unsigned int i;
@@ -2640,7 +2634,7 @@ static int mxser_probe(struct pci_dev *pdev,
2640 } 2634 }
2641 2635
2642 /* mxser_initbrd will hook ISR. */ 2636 /* mxser_initbrd will hook ISR. */
2643 retval = mxser_initbrd(brd, pdev); 2637 retval = mxser_initbrd(brd);
2644 if (retval) 2638 if (retval)
2645 goto err_rel3; 2639 goto err_rel3;
2646 2640
@@ -2746,7 +2740,7 @@ static int __init mxser_module_init(void)
2746 brd->info->name, ioaddr[b]); 2740 brd->info->name, ioaddr[b]);
2747 2741
2748 /* mxser_initbrd will hook ISR. */ 2742 /* mxser_initbrd will hook ISR. */
2749 if (mxser_initbrd(brd, NULL) < 0) { 2743 if (mxser_initbrd(brd) < 0) {
2750 mxser_release_ISA_res(brd); 2744 mxser_release_ISA_res(brd);
2751 brd->info = NULL; 2745 brd->info = NULL;
2752 continue; 2746 continue;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 0a3c9665e015..3a39eb685c69 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1,20 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * n_gsm.c GSM 0710 tty multiplexor 3 * n_gsm.c GSM 0710 tty multiplexor
3 * Copyright (c) 2009/10 Intel Corporation 4 * Copyright (c) 2009/10 Intel Corporation
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 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 *
18 * * THIS IS A DEVELOPMENT SNAPSHOT IT IS NOT A FINAL RELEASE * 6 * * THIS IS A DEVELOPMENT SNAPSHOT IT IS NOT A FINAL RELEASE *
19 * 7 *
20 * TO DO: 8 * TO DO:
@@ -1646,9 +1634,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
1646 } 1634 }
1647 1635
1648 skb_queue_head_init(&dlci->skb_list); 1636 skb_queue_head_init(&dlci->skb_list);
1649 init_timer(&dlci->t1); 1637 setup_timer(&dlci->t1, gsm_dlci_t1, (unsigned long)dlci);
1650 dlci->t1.function = gsm_dlci_t1;
1651 dlci->t1.data = (unsigned long)dlci;
1652 tty_port_init(&dlci->port); 1638 tty_port_init(&dlci->port);
1653 dlci->port.ops = &gsm_port_ops; 1639 dlci->port.ops = &gsm_port_ops;
1654 dlci->gsm = gsm; 1640 dlci->gsm = gsm;
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 7b2a466616d6..eea7b6cb3cc4 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* generic HDLC line discipline for Linux 2/* generic HDLC line discipline for Linux
2 * 3 *
3 * Written by Paul Fulghum paulkf@microgate.com 4 * Written by Paul Fulghum paulkf@microgate.com
@@ -11,8 +12,6 @@
11 * 12 *
12 * Original release 01/11/99 13 * Original release 01/11/99
13 * 14 *
14 * This code is released under the GNU General Public License (GPL)
15 *
16 * This module implements the tty line discipline N_HDLC for use with 15 * This module implements the tty line discipline N_HDLC for use with
17 * tty device drivers that support bit-synchronous HDLC communications. 16 * tty device drivers that support bit-synchronous HDLC communications.
18 * 17 *
diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c
index d63261c36e42..96feabae4740 100644
--- a/drivers/tty/n_null.c
+++ b/drivers/tty/n_null.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/types.h> 2#include <linux/types.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/tty.h> 4#include <linux/tty.h>
@@ -7,19 +8,6 @@
7 * n_null.c - Null line discipline used in the failure path 8 * n_null.c - Null line discipline used in the failure path
8 * 9 *
9 * Copyright (C) Intel 2017 10 * Copyright (C) Intel 2017
10 *
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 *
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
15 * as 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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 11 */
24 12
25static int n_null_open(struct tty_struct *tty) 13static int n_null_open(struct tty_struct *tty)
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index 305b6490d405..9f246d4db3ca 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* r3964 linediscipline for linux 2/* r3964 linediscipline for linux
2 * 3 *
3 * ----------------------------------------------------------- 4 * -----------------------------------------------------------
@@ -5,9 +6,6 @@
5 * Philips Automation Projects 6 * Philips Automation Projects
6 * Kassel (Germany) 7 * Kassel (Germany)
7 * ----------------------------------------------------------- 8 * -----------------------------------------------------------
8 * This software may be used and distributed according to the terms of
9 * the GNU General Public License, incorporated herein by reference.
10 *
11 * Author: 9 * Author:
12 * L. Haag 10 * L. Haag
13 * 11 *
diff --git a/drivers/tty/n_tracerouter.c b/drivers/tty/n_tracerouter.c
index ac5716979bc1..4479af4d2fa5 100644
--- a/drivers/tty/n_tracerouter.c
+++ b/drivers/tty/n_tracerouter.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * n_tracerouter.c - Trace data router through tty space 3 * n_tracerouter.c - Trace data router through tty space
3 * 4 *
@@ -5,17 +6,6 @@
5 * 6 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
10 * as published by the Free Software Foundation.
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 *
17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 *
19 * This trace router uses the Linux line discipline framework to route 9 * This trace router uses the Linux line discipline framework to route
20 * trace data coming from a HW Modem to a PTI (Parallel Trace Module) port. 10 * trace data coming from a HW Modem to a PTI (Parallel Trace Module) port.
21 * The solution is not specific to a HW modem and this line disciple can 11 * The solution is not specific to a HW modem and this line disciple can
diff --git a/drivers/tty/n_tracesink.c b/drivers/tty/n_tracesink.c
index 4616870a6b1b..d96ba82cc356 100644
--- a/drivers/tty/n_tracesink.c
+++ b/drivers/tty/n_tracesink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * n_tracesink.c - Trace data router and sink path through tty space. 3 * n_tracesink.c - Trace data router and sink path through tty space.
3 * 4 *
@@ -5,17 +6,6 @@
5 * 6 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
10 * as published by the Free Software Foundation.
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 *
17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 *
19 * The trace sink uses the Linux line discipline framework to receive 9 * The trace sink uses the Linux line discipline framework to receive
20 * trace data coming from the PTI source line discipline driver 10 * trace data coming from the PTI source line discipline driver
21 * to a user-desired tty port, like USB. 11 * to a user-desired tty port, like USB.
diff --git a/drivers/tty/n_tracesink.h b/drivers/tty/n_tracesink.h
index a68bb44f1ef5..1b846330c855 100644
--- a/drivers/tty/n_tracesink.h
+++ b/drivers/tty/n_tracesink.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * n_tracesink.h - Kernel driver API to route trace data in kernel space. 3 * n_tracesink.h - Kernel driver API to route trace data in kernel space.
3 * 4 *
@@ -5,17 +6,6 @@
5 * 6 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
10 * as published by the Free Software Foundation.
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 *
17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 *
19 * The PTI (Parallel Trace Interface) driver directs trace data routed from 9 * The PTI (Parallel Trace Interface) driver directs trace data routed from
20 * various parts in the system out through the Intel Penwell PTI port and 10 * various parts in the system out through the Intel Penwell PTI port and
21 * out of the mobile device for analysis with a debugging tool 11 * out of the mobile device for analysis with a debugging tool
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index bdf0e6e89991..427e0d5d8f13 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * n_tty.c --- implements the N_TTY line discipline. 3 * n_tty.c --- implements the N_TTY line discipline.
3 * 4 *
@@ -15,9 +16,6 @@
15 * This file also contains code originally written by Linus Torvalds, 16 * This file also contains code originally written by Linus Torvalds,
16 * Copyright 1991, 1992, 1993, and by Julian Cowley, Copyright 1994. 17 * Copyright 1991, 1992, 1993, and by Julian Cowley, Copyright 1994.
17 * 18 *
18 * This file may be redistributed under the terms of the GNU General Public
19 * License.
20 *
21 * Reduced memory usage for older ARM systems - Russell King. 19 * Reduced memory usage for older ARM systems - Russell King.
22 * 20 *
23 * 2000/01/20 Fixed SMP locking on put_tty_queue using bits of 21 * 2000/01/20 Fixed SMP locking on put_tty_queue using bits of
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index 39b3723a32a6..b57b35066ebe 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * nozomi.c -- HSDPA driver Broadband Wireless Data Card - Globe Trotter 3 * nozomi.c -- HSDPA driver Broadband Wireless Data Card - Globe Trotter
3 * 4 *
@@ -21,20 +22,6 @@
21 * Copyright (c) 2006 Option Wireless n/v 22 * Copyright (c) 2006 Option Wireless n/v
22 * All rights Reserved. 23 * All rights Reserved.
23 * 24 *
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
28 *
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37 *
38 * -------------------------------------------------------------------------- 25 * --------------------------------------------------------------------------
39 */ 26 */
40 27
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index aa695fda1084..f7dc9b1ea806 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * RocketPort device driver for Linux 3 * RocketPort device driver for Linux
3 * 4 *
4 * Written by Theodore Ts'o, 1995, 1996, 1997, 1998, 1999, 2000. 5 * Written by Theodore Ts'o, 1995, 1996, 1997, 1998, 1999, 2000.
5 * 6 *
6 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003 by Comtrol, Inc. 7 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003 by Comtrol, Inc.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 8 */
22 9
23/* 10/*
diff --git a/drivers/tty/serdev/Kconfig b/drivers/tty/serdev/Kconfig
index cdc6b820cf93..1dbc8352e027 100644
--- a/drivers/tty/serdev/Kconfig
+++ b/drivers/tty/serdev/Kconfig
@@ -6,11 +6,19 @@ menuconfig SERIAL_DEV_BUS
6 help 6 help
7 Core support for devices connected via a serial port. 7 Core support for devices connected via a serial port.
8 8
9 Note that you typically also want to enable TTY port controller support.
10
9if SERIAL_DEV_BUS 11if SERIAL_DEV_BUS
10 12
11config SERIAL_DEV_CTRL_TTYPORT 13config SERIAL_DEV_CTRL_TTYPORT
12 bool "Serial device TTY port controller" 14 bool "Serial device TTY port controller"
15 help
16 Say Y here if you want to use the Serial device bus with common TTY
17 drivers (e.g. serial drivers).
18
19 If unsure, say Y.
13 depends on TTY 20 depends on TTY
14 depends on SERIAL_DEV_BUS != m 21 depends on SERIAL_DEV_BUS != m
22 default y
15 23
16endif 24endif
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index c68fb3a8ea1c..1bef39828ca7 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -1,19 +1,12 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2016-2017 Linaro Ltd., Rob Herring <robh@kernel.org> 3 * Copyright (C) 2016-2017 Linaro Ltd., Rob Herring <robh@kernel.org>
3 * 4 *
4 * Based on drivers/spmi/spmi.c: 5 * Based on drivers/spmi/spmi.c:
5 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. 6 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
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 and
9 * only version 2 as published by the Free Software Foundation.
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 */ 7 */
16 8
9#include <linux/acpi.h>
17#include <linux/errno.h> 10#include <linux/errno.h>
18#include <linux/idr.h> 11#include <linux/idr.h>
19#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -49,13 +42,22 @@ static const struct device_type serdev_ctrl_type = {
49 42
50static int serdev_device_match(struct device *dev, struct device_driver *drv) 43static int serdev_device_match(struct device *dev, struct device_driver *drv)
51{ 44{
52 /* TODO: ACPI and platform matching */ 45 /* TODO: platform matching */
46 if (acpi_driver_match_device(dev, drv))
47 return 1;
48
53 return of_driver_match_device(dev, drv); 49 return of_driver_match_device(dev, drv);
54} 50}
55 51
56static int serdev_uevent(struct device *dev, struct kobj_uevent_env *env) 52static int serdev_uevent(struct device *dev, struct kobj_uevent_env *env)
57{ 53{
58 /* TODO: ACPI and platform modalias */ 54 int rc;
55
56 /* TODO: platform modalias */
57 rc = acpi_device_uevent_modalias(dev, env);
58 if (rc != -ENODEV)
59 return rc;
60
59 return of_device_uevent_modalias(dev, env); 61 return of_device_uevent_modalias(dev, env);
60} 62}
61 63
@@ -65,21 +67,32 @@ static int serdev_uevent(struct device *dev, struct kobj_uevent_env *env)
65 */ 67 */
66int serdev_device_add(struct serdev_device *serdev) 68int serdev_device_add(struct serdev_device *serdev)
67{ 69{
70 struct serdev_controller *ctrl = serdev->ctrl;
68 struct device *parent = serdev->dev.parent; 71 struct device *parent = serdev->dev.parent;
69 int err; 72 int err;
70 73
71 dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr); 74 dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr);
72 75
76 /* Only a single slave device is currently supported. */
77 if (ctrl->serdev) {
78 dev_err(&serdev->dev, "controller busy\n");
79 return -EBUSY;
80 }
81 ctrl->serdev = serdev;
82
73 err = device_add(&serdev->dev); 83 err = device_add(&serdev->dev);
74 if (err < 0) { 84 if (err < 0) {
75 dev_err(&serdev->dev, "Can't add %s, status %d\n", 85 dev_err(&serdev->dev, "Can't add %s, status %d\n",
76 dev_name(&serdev->dev), err); 86 dev_name(&serdev->dev), err);
77 goto err_device_add; 87 goto err_clear_serdev;
78 } 88 }
79 89
80 dev_dbg(&serdev->dev, "device %s registered\n", dev_name(&serdev->dev)); 90 dev_dbg(&serdev->dev, "device %s registered\n", dev_name(&serdev->dev));
81 91
82err_device_add: 92 return 0;
93
94err_clear_serdev:
95 ctrl->serdev = NULL;
83 return err; 96 return err;
84} 97}
85EXPORT_SYMBOL_GPL(serdev_device_add); 98EXPORT_SYMBOL_GPL(serdev_device_add);
@@ -90,7 +103,10 @@ EXPORT_SYMBOL_GPL(serdev_device_add);
90 */ 103 */
91void serdev_device_remove(struct serdev_device *serdev) 104void serdev_device_remove(struct serdev_device *serdev)
92{ 105{
106 struct serdev_controller *ctrl = serdev->ctrl;
107
93 device_unregister(&serdev->dev); 108 device_unregister(&serdev->dev);
109 ctrl->serdev = NULL;
94} 110}
95EXPORT_SYMBOL_GPL(serdev_device_remove); 111EXPORT_SYMBOL_GPL(serdev_device_remove);
96 112
@@ -260,6 +276,12 @@ static int serdev_drv_remove(struct device *dev)
260static ssize_t modalias_show(struct device *dev, 276static ssize_t modalias_show(struct device *dev,
261 struct device_attribute *attr, char *buf) 277 struct device_attribute *attr, char *buf)
262{ 278{
279 int len;
280
281 len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
282 if (len != -ENODEV)
283 return len;
284
263 return of_device_modalias(dev, buf, PAGE_SIZE); 285 return of_device_modalias(dev, buf, PAGE_SIZE);
264} 286}
265DEVICE_ATTR_RO(modalias); 287DEVICE_ATTR_RO(modalias);
@@ -295,7 +317,6 @@ struct serdev_device *serdev_device_alloc(struct serdev_controller *ctrl)
295 return NULL; 317 return NULL;
296 318
297 serdev->ctrl = ctrl; 319 serdev->ctrl = ctrl;
298 ctrl->serdev = serdev;
299 device_initialize(&serdev->dev); 320 device_initialize(&serdev->dev);
300 serdev->dev.parent = &ctrl->dev; 321 serdev->dev.parent = &ctrl->dev;
301 serdev->dev.bus = &serdev_bus_type; 322 serdev->dev.bus = &serdev_bus_type;
@@ -329,26 +350,31 @@ struct serdev_controller *serdev_controller_alloc(struct device *parent,
329 if (!ctrl) 350 if (!ctrl)
330 return NULL; 351 return NULL;
331 352
332 device_initialize(&ctrl->dev);
333 ctrl->dev.type = &serdev_ctrl_type;
334 ctrl->dev.bus = &serdev_bus_type;
335 ctrl->dev.parent = parent;
336 ctrl->dev.of_node = parent->of_node;
337 serdev_controller_set_drvdata(ctrl, &ctrl[1]);
338
339 id = ida_simple_get(&ctrl_ida, 0, 0, GFP_KERNEL); 353 id = ida_simple_get(&ctrl_ida, 0, 0, GFP_KERNEL);
340 if (id < 0) { 354 if (id < 0) {
341 dev_err(parent, 355 dev_err(parent,
342 "unable to allocate serdev controller identifier.\n"); 356 "unable to allocate serdev controller identifier.\n");
343 serdev_controller_put(ctrl); 357 goto err_free;
344 return NULL;
345 } 358 }
346 359
347 ctrl->nr = id; 360 ctrl->nr = id;
361
362 device_initialize(&ctrl->dev);
363 ctrl->dev.type = &serdev_ctrl_type;
364 ctrl->dev.bus = &serdev_bus_type;
365 ctrl->dev.parent = parent;
366 ctrl->dev.of_node = parent->of_node;
367 serdev_controller_set_drvdata(ctrl, &ctrl[1]);
368
348 dev_set_name(&ctrl->dev, "serial%d", id); 369 dev_set_name(&ctrl->dev, "serial%d", id);
349 370
350 dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id); 371 dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id);
351 return ctrl; 372 return ctrl;
373
374err_free:
375 kfree(ctrl);
376
377 return NULL;
352} 378}
353EXPORT_SYMBOL_GPL(serdev_controller_alloc); 379EXPORT_SYMBOL_GPL(serdev_controller_alloc);
354 380
@@ -385,6 +411,75 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
385 return 0; 411 return 0;
386} 412}
387 413
414#ifdef CONFIG_ACPI
415static acpi_status acpi_serdev_register_device(struct serdev_controller *ctrl,
416 struct acpi_device *adev)
417{
418 struct serdev_device *serdev = NULL;
419 int err;
420
421 if (acpi_bus_get_status(adev) || !adev->status.present ||
422 acpi_device_enumerated(adev))
423 return AE_OK;
424
425 serdev = serdev_device_alloc(ctrl);
426 if (!serdev) {
427 dev_err(&ctrl->dev, "failed to allocate serdev device for %s\n",
428 dev_name(&adev->dev));
429 return AE_NO_MEMORY;
430 }
431
432 ACPI_COMPANION_SET(&serdev->dev, adev);
433 acpi_device_set_enumerated(adev);
434
435 err = serdev_device_add(serdev);
436 if (err) {
437 dev_err(&serdev->dev,
438 "failure adding ACPI serdev device. status %d\n", err);
439 serdev_device_put(serdev);
440 }
441
442 return AE_OK;
443}
444
445static acpi_status acpi_serdev_add_device(acpi_handle handle, u32 level,
446 void *data, void **return_value)
447{
448 struct serdev_controller *ctrl = data;
449 struct acpi_device *adev;
450
451 if (acpi_bus_get_device(handle, &adev))
452 return AE_OK;
453
454 return acpi_serdev_register_device(ctrl, adev);
455}
456
457static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
458{
459 acpi_status status;
460 acpi_handle handle;
461
462 handle = ACPI_HANDLE(ctrl->dev.parent);
463 if (!handle)
464 return -ENODEV;
465
466 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
467 acpi_serdev_add_device, NULL, ctrl, NULL);
468 if (ACPI_FAILURE(status))
469 dev_dbg(&ctrl->dev, "failed to enumerate serdev slaves\n");
470
471 if (!ctrl->serdev)
472 return -ENODEV;
473
474 return 0;
475}
476#else
477static inline int acpi_serdev_register_devices(struct serdev_controller *ctrl)
478{
479 return -ENODEV;
480}
481#endif /* CONFIG_ACPI */
482
388/** 483/**
389 * serdev_controller_add() - Add an serdev controller 484 * serdev_controller_add() - Add an serdev controller
390 * @ctrl: controller to be registered. 485 * @ctrl: controller to be registered.
@@ -394,7 +489,7 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
394 */ 489 */
395int serdev_controller_add(struct serdev_controller *ctrl) 490int serdev_controller_add(struct serdev_controller *ctrl)
396{ 491{
397 int ret; 492 int ret_of, ret_acpi, ret;
398 493
399 /* Can't register until after driver model init */ 494 /* Can't register until after driver model init */
400 if (WARN_ON(!is_registered)) 495 if (WARN_ON(!is_registered))
@@ -404,9 +499,14 @@ int serdev_controller_add(struct serdev_controller *ctrl)
404 if (ret) 499 if (ret)
405 return ret; 500 return ret;
406 501
407 ret = of_serdev_register_devices(ctrl); 502 ret_of = of_serdev_register_devices(ctrl);
408 if (ret) 503 ret_acpi = acpi_serdev_register_devices(ctrl);
504 if (ret_of && ret_acpi) {
505 dev_dbg(&ctrl->dev, "no devices registered: of:%d acpi:%d\n",
506 ret_of, ret_acpi);
507 ret = -ENODEV;
409 goto out_dev_del; 508 goto out_dev_del;
509 }
410 510
411 dev_dbg(&ctrl->dev, "serdev%d registered: dev:%p\n", 511 dev_dbg(&ctrl->dev, "serdev%d registered: dev:%p\n",
412 ctrl->nr, &ctrl->dev); 512 ctrl->nr, &ctrl->dev);
diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index 302018d67efa..ce7ad0acee7a 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -1,14 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2016-2017 Linaro Ltd., Rob Herring <robh@kernel.org> 3 * Copyright (C) 2016-2017 Linaro Ltd., Rob Herring <robh@kernel.org>
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 and
6 * only version 2 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 */ 4 */
13#include <linux/kernel.h> 5#include <linux/kernel.h>
14#include <linux/serdev.h> 6#include <linux/serdev.h>
@@ -96,16 +88,21 @@ static int ttyport_open(struct serdev_controller *ctrl)
96 struct serport *serport = serdev_controller_get_drvdata(ctrl); 88 struct serport *serport = serdev_controller_get_drvdata(ctrl);
97 struct tty_struct *tty; 89 struct tty_struct *tty;
98 struct ktermios ktermios; 90 struct ktermios ktermios;
91 int ret;
99 92
100 tty = tty_init_dev(serport->tty_drv, serport->tty_idx); 93 tty = tty_init_dev(serport->tty_drv, serport->tty_idx);
101 if (IS_ERR(tty)) 94 if (IS_ERR(tty))
102 return PTR_ERR(tty); 95 return PTR_ERR(tty);
103 serport->tty = tty; 96 serport->tty = tty;
104 97
105 if (tty->ops->open) 98 if (!tty->ops->open || !tty->ops->close) {
106 tty->ops->open(serport->tty, NULL); 99 ret = -ENODEV;
107 else 100 goto err_unlock;
108 tty_port_open(serport->port, tty, NULL); 101 }
102
103 ret = tty->ops->open(serport->tty, NULL);
104 if (ret)
105 goto err_close;
109 106
110 /* Bring the UART into a known 8 bits no parity hw fc state */ 107 /* Bring the UART into a known 8 bits no parity hw fc state */
111 ktermios = tty->termios; 108 ktermios = tty->termios;
@@ -122,6 +119,14 @@ static int ttyport_open(struct serdev_controller *ctrl)
122 119
123 tty_unlock(serport->tty); 120 tty_unlock(serport->tty);
124 return 0; 121 return 0;
122
123err_close:
124 tty->ops->close(tty, NULL);
125err_unlock:
126 tty_unlock(tty);
127 tty_release_struct(tty, serport->tty_idx);
128
129 return ret;
125} 130}
126 131
127static void ttyport_close(struct serdev_controller *ctrl) 132static void ttyport_close(struct serdev_controller *ctrl)
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 *
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index 3be981101297..f2c34d656144 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * $Id: synclink.c,v 4.38 2005/11/07 16:30:34 paulkf Exp $ 3 * $Id: synclink.c,v 4.38 2005/11/07 16:30:34 paulkf Exp $
3 * 4 *
@@ -13,8 +14,6 @@
13 * 14 *
14 * Original release 01/11/99 15 * Original release 01/11/99
15 * 16 *
16 * This code is released under the GNU General Public License (GPL)
17 *
18 * This driver is primarily intended for use in synchronous 17 * This driver is primarily intended for use in synchronous
19 * HDLC mode. Asynchronous mode is also provided. 18 * HDLC mode. Asynchronous mode is also provided.
20 * 19 *
@@ -4098,8 +4097,7 @@ static int mgsl_claim_resources(struct mgsl_struct *info)
4098 if (request_dma(info->dma_level,info->device_name) < 0){ 4097 if (request_dma(info->dma_level,info->device_name) < 0){
4099 printk( "%s(%d):Can't request DMA channel on device %s DMA=%d\n", 4098 printk( "%s(%d):Can't request DMA channel on device %s DMA=%d\n",
4100 __FILE__,__LINE__,info->device_name, info->dma_level ); 4099 __FILE__,__LINE__,info->device_name, info->dma_level );
4101 mgsl_release_resources( info ); 4100 goto errout;
4102 return -ENODEV;
4103 } 4101 }
4104 info->dma_requested = true; 4102 info->dma_requested = true;
4105 4103
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 636b8ae29b46..06a03731bba7 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Device driver for Microgate SyncLink GT serial adapters. 3 * Device driver for Microgate SyncLink GT serial adapters.
3 * 4 *
@@ -6,8 +7,6 @@
6 * 7 *
7 * Microgate and SyncLink are trademarks of Microgate Corporation 8 * Microgate and SyncLink are trademarks of Microgate Corporation
8 * 9 *
9 * This code is released under the GNU General Public License (GPL)
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 11 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
13 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 12 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index 4fed9e7b281f..d45f234e1914 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $ 3 * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $
3 * 4 *
@@ -10,7 +11,6 @@
10 * Microgate and SyncLink are trademarks of Microgate Corporation 11 * Microgate and SyncLink are trademarks of Microgate Corporation
11 * 12 *
12 * Derived from serial.c written by Theodore Ts'o and Linus Torvalds 13 * Derived from serial.c written by Theodore Ts'o and Linus Torvalds
13 * This code is released under the GNU General Public License (GPL)
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index d008f5a75197..b674793be478 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -246,8 +246,10 @@ static void sysrq_handle_showallcpus(int key)
246 * architecture has no support for it: 246 * architecture has no support for it:
247 */ 247 */
248 if (!trigger_all_cpu_backtrace()) { 248 if (!trigger_all_cpu_backtrace()) {
249 struct pt_regs *regs = get_irq_regs(); 249 struct pt_regs *regs = NULL;
250 250
251 if (in_irq())
252 regs = get_irq_regs();
251 if (regs) { 253 if (regs) {
252 pr_info("CPU%d:\n", smp_processor_id()); 254 pr_info("CPU%d:\n", smp_processor_id());
253 show_regs(regs); 255 show_regs(regs);
@@ -266,7 +268,10 @@ static struct sysrq_key_op sysrq_showallcpus_op = {
266 268
267static void sysrq_handle_showregs(int key) 269static void sysrq_handle_showregs(int key)
268{ 270{
269 struct pt_regs *regs = get_irq_regs(); 271 struct pt_regs *regs = NULL;
272
273 if (in_irq())
274 regs = get_irq_regs();
270 if (regs) 275 if (regs)
271 show_regs(regs); 276 show_regs(regs);
272 perf_event_print_debug(); 277 perf_event_print_debug();
@@ -649,9 +654,9 @@ static void sysrq_parse_reset_sequence(struct sysrq_state *state)
649 state->reset_seq_version = sysrq_reset_seq_version; 654 state->reset_seq_version = sysrq_reset_seq_version;
650} 655}
651 656
652static void sysrq_do_reset(unsigned long _state) 657static void sysrq_do_reset(struct timer_list *t)
653{ 658{
654 struct sysrq_state *state = (struct sysrq_state *) _state; 659 struct sysrq_state *state = from_timer(state, t, keyreset_timer);
655 660
656 state->reset_requested = true; 661 state->reset_requested = true;
657 662
@@ -668,7 +673,7 @@ static void sysrq_handle_reset_request(struct sysrq_state *state)
668 mod_timer(&state->keyreset_timer, 673 mod_timer(&state->keyreset_timer,
669 jiffies + msecs_to_jiffies(sysrq_reset_downtime_ms)); 674 jiffies + msecs_to_jiffies(sysrq_reset_downtime_ms));
670 else 675 else
671 sysrq_do_reset((unsigned long)state); 676 sysrq_do_reset(&state->keyreset_timer);
672} 677}
673 678
674static void sysrq_detect_reset_sequence(struct sysrq_state *state, 679static void sysrq_detect_reset_sequence(struct sysrq_state *state,
@@ -904,8 +909,7 @@ static int sysrq_connect(struct input_handler *handler,
904 sysrq->handle.handler = handler; 909 sysrq->handle.handler = handler;
905 sysrq->handle.name = "sysrq"; 910 sysrq->handle.name = "sysrq";
906 sysrq->handle.private = sysrq; 911 sysrq->handle.private = sysrq;
907 setup_timer(&sysrq->keyreset_timer, 912 timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
908 sysrq_do_reset, (unsigned long)sysrq);
909 913
910 error = input_register_handle(&sysrq->handle); 914 error = input_register_handle(&sysrq->handle);
911 if (error) { 915 if (error) {
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index df2d735338e2..e30aa6bf9ff9 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -1,10 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Creating audit events from TTY input. 3 * Creating audit events from TTY input.
3 * 4 *
4 * Copyright (C) 2007 Red Hat, Inc. All rights reserved. This copyrighted 5 * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
5 * material is made available to anyone wishing to use, modify, copy, or
6 * redistribute it subject to the terms and conditions of the GNU General
7 * Public License v.2.
8 * 6 *
9 * Authors: Miloslav Trmac <mitr@redhat.com> 7 * Authors: Miloslav Trmac <mitr@redhat.com>
10 */ 8 */
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index 5c33fd25676d..6ff8cdfc9d2a 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 3 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
3 */ 4 */
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index f8eba1c5412f..c996b6859c5e 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Tty buffer allocation management 3 * Tty buffer allocation management
3 */ 4 */
@@ -446,7 +447,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
446 * Callers other than flush_to_ldisc() need to exclude the kworker 447 * Callers other than flush_to_ldisc() need to exclude the kworker
447 * from concurrent use of the line discipline, see paste_selection(). 448 * from concurrent use of the line discipline, see paste_selection().
448 * 449 *
449 * Returns the number of bytes not processed 450 * Returns the number of bytes processed
450 */ 451 */
451int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 452int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p,
452 char *f, int count) 453 char *f, int count)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 94cccb6efa32..dc60aeea87d8 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 1991, 1992 Linus Torvalds 3 * Copyright (C) 1991, 1992 Linus Torvalds
3 */ 4 */
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index efa96e6c4c1b..d9b561d89432 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 3 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
3 * 4 *
diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index e7032309ee87..c4ecd66fafef 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 1991, 1992 Linus Torvalds 3 * Copyright (C) 1991, 1992 Linus Torvalds
3 */ 4 */
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 84a8ac2a779f..24ec5c7e6b20 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/types.h> 2#include <linux/types.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/kmod.h> 4#include <linux/kmod.h>
diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c
index 52b7baef4f7a..37a91b3df980 100644
--- a/drivers/tty/tty_ldsem.c
+++ b/drivers/tty/tty_ldsem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Ldisc rw semaphore 3 * Ldisc rw semaphore
3 * 4 *
@@ -22,9 +23,6 @@
22 * Michel Lespinasse <walken@google.com>. 23 * Michel Lespinasse <walken@google.com>.
23 * 24 *
24 * Copyright (C) 2013 Peter Hurley <peter@hurleysoftware.com> 25 * Copyright (C) 2013 Peter Hurley <peter@hurleysoftware.com>
25 *
26 * This file may be redistributed under the terms of the GNU General Public
27 * License v2.
28 */ 26 */
29 27
30#include <linux/list.h> 28#include <linux/list.h>
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 6b137194069f..25d736880013 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Tty port functions 3 * Tty port functions
3 */ 4 */
@@ -78,7 +79,7 @@ EXPORT_SYMBOL(tty_port_init);
78 * @driver: tty_driver for this device 79 * @driver: tty_driver for this device
79 * @index: index of the tty 80 * @index: index of the tty
80 * 81 *
81 * Provide the tty layer wit ha link from a tty (specified by @index) to a 82 * Provide the tty layer with a link from a tty (specified by @index) to a
82 * tty_port (@port). Use this only if neither tty_port_register_device nor 83 * tty_port (@port). Use this only if neither tty_port_register_device nor
83 * tty_port_install is used in the driver. If used, this has to be called before 84 * tty_port_install is used in the driver. If used, this has to be called before
84 * tty_register_driver. 85 * tty_register_driver.
@@ -235,7 +236,7 @@ EXPORT_SYMBOL(tty_port_free_xmit_buf);
235 236
236/** 237/**
237 * tty_port_destroy -- destroy inited port 238 * tty_port_destroy -- destroy inited port
238 * @port: tty port to be doestroyed 239 * @port: tty port to be destroyed
239 * 240 *
240 * When a port was initialized using tty_port_init, one has to destroy the 241 * When a port was initialized using tty_port_init, one has to destroy the
241 * port by this function. Either indirectly by using tty_port refcounting 242 * port by this function. Either indirectly by using tty_port refcounting
diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
index ef01d24858cd..58b454c34560 100644
--- a/drivers/tty/vcc.c
+++ b/drivers/tty/vcc.c
@@ -361,17 +361,13 @@ done:
361 return rv; 361 return rv;
362} 362}
363 363
364static void vcc_rx_timer(unsigned long index) 364static void vcc_rx_timer(struct timer_list *t)
365{ 365{
366 struct vcc_port *port = from_timer(port, t, rx_timer);
366 struct vio_driver_state *vio; 367 struct vio_driver_state *vio;
367 struct vcc_port *port;
368 unsigned long flags; 368 unsigned long flags;
369 int rv; 369 int rv;
370 370
371 port = vcc_get_ne(index);
372 if (!port)
373 return;
374
375 spin_lock_irqsave(&port->lock, flags); 371 spin_lock_irqsave(&port->lock, flags);
376 port->rx_timer.expires = 0; 372 port->rx_timer.expires = 0;
377 373
@@ -391,18 +387,14 @@ done:
391 vcc_put(port, false); 387 vcc_put(port, false);
392} 388}
393 389
394static void vcc_tx_timer(unsigned long index) 390static void vcc_tx_timer(struct timer_list *t)
395{ 391{
396 struct vcc_port *port; 392 struct vcc_port *port = from_timer(port, t, tx_timer);
397 struct vio_vcc *pkt; 393 struct vio_vcc *pkt;
398 unsigned long flags; 394 unsigned long flags;
399 int tosend = 0; 395 int tosend = 0;
400 int rv; 396 int rv;
401 397
402 port = vcc_get_ne(index);
403 if (!port)
404 return;
405
406 spin_lock_irqsave(&port->lock, flags); 398 spin_lock_irqsave(&port->lock, flags);
407 port->tx_timer.expires = 0; 399 port->tx_timer.expires = 0;
408 400
@@ -645,13 +637,8 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
645 if (rv) 637 if (rv)
646 goto free_domain; 638 goto free_domain;
647 639
648 init_timer(&port->rx_timer); 640 timer_setup(&port->rx_timer, vcc_rx_timer, 0);
649 port->rx_timer.function = vcc_rx_timer; 641 timer_setup(&port->tx_timer, vcc_tx_timer, 0);
650 port->rx_timer.data = port->index;
651
652 init_timer(&port->tx_timer);
653 port->tx_timer.function = vcc_tx_timer;
654 port->tx_timer.data = port->index;
655 642
656 dev_set_drvdata(&vdev->dev, port); 643 dev_set_drvdata(&vdev->dev, port);
657 644
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index a5f88cf0f61d..722a6690c70d 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * consolemap.c 3 * consolemap.c
3 * 4 *
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index f974d6340d04..c8d90d7e7e37 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Written for linux by Johan Myreen as a translation from 3 * Written for linux by Johan Myreen as a translation from
3 * the assembly version by Linus (with diacriticals added) 4 * the assembly version by Linus (with diacriticals added)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 602d71630952..bce4c71cb338 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 1991, 1992 Linus Torvalds 3 * Copyright (C) 1991, 1992 Linus Torvalds
3 */ 4 */
@@ -102,6 +103,7 @@
102#include <linux/uaccess.h> 103#include <linux/uaccess.h>
103#include <linux/kdb.h> 104#include <linux/kdb.h>
104#include <linux/ctype.h> 105#include <linux/ctype.h>
106#include <linux/bsearch.h>
105 107
106#define MAX_NR_CON_DRIVER 16 108#define MAX_NR_CON_DRIVER 16
107 109
@@ -2142,22 +2144,15 @@ struct interval {
2142 uint32_t last; 2144 uint32_t last;
2143}; 2145};
2144 2146
2145static int bisearch(uint32_t ucs, const struct interval *table, int max) 2147static int ucs_cmp(const void *key, const void *elt)
2146{ 2148{
2147 int min = 0; 2149 uint32_t ucs = *(uint32_t *)key;
2148 int mid; 2150 struct interval e = *(struct interval *) elt;
2149 2151
2150 if (ucs < table[0].first || ucs > table[max].last) 2152 if (ucs > e.last)
2151 return 0; 2153 return 1;
2152 while (max >= min) { 2154 else if (ucs < e.first)
2153 mid = (min + max) / 2; 2155 return -1;
2154 if (ucs > table[mid].last)
2155 min = mid + 1;
2156 else if (ucs < table[mid].first)
2157 max = mid - 1;
2158 else
2159 return 1;
2160 }
2161 return 0; 2156 return 0;
2162} 2157}
2163 2158
@@ -2169,7 +2164,12 @@ static int is_double_width(uint32_t ucs)
2169 { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 }, 2164 { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 },
2170 { 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD } 2165 { 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD }
2171 }; 2166 };
2172 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1); 2167 if (ucs < double_width[0].first ||
2168 ucs > double_width[ARRAY_SIZE(double_width) - 1].last)
2169 return 0;
2170
2171 return bsearch(&ucs, double_width, ARRAY_SIZE(double_width),
2172 sizeof(struct interval), ucs_cmp) != NULL;
2173} 2173}
2174 2174
2175static void con_flush(struct vc_data *vc, unsigned long draw_from, 2175static void con_flush(struct vc_data *vc, unsigned long draw_from,
@@ -2205,7 +2205,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2205 console_lock(); 2205 console_lock();
2206 vc = tty->driver_data; 2206 vc = tty->driver_data;
2207 if (vc == NULL) { 2207 if (vc == NULL) {
2208 printk(KERN_ERR "vt: argh, driver_data is NULL !\n"); 2208 pr_err("vt: argh, driver_data is NULL !\n");
2209 console_unlock(); 2209 console_unlock();
2210 return 0; 2210 return 0;
2211 } 2211 }
@@ -3190,20 +3190,21 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
3190 3190
3191 pr_info("Console: switching "); 3191 pr_info("Console: switching ");
3192 if (!deflt) 3192 if (!deflt)
3193 printk(KERN_CONT "consoles %d-%d ", first+1, last+1); 3193 pr_cont("consoles %d-%d ", first + 1, last + 1);
3194 if (j >= 0) { 3194 if (j >= 0) {
3195 struct vc_data *vc = vc_cons[j].d; 3195 struct vc_data *vc = vc_cons[j].d;
3196 3196
3197 printk(KERN_CONT "to %s %s %dx%d\n", 3197 pr_cont("to %s %s %dx%d\n",
3198 vc->vc_can_do_color ? "colour" : "mono", 3198 vc->vc_can_do_color ? "colour" : "mono",
3199 desc, vc->vc_cols, vc->vc_rows); 3199 desc, vc->vc_cols, vc->vc_rows);
3200 3200
3201 if (k >= 0) { 3201 if (k >= 0) {
3202 vc = vc_cons[k].d; 3202 vc = vc_cons[k].d;
3203 update_screen(vc); 3203 update_screen(vc);
3204 } 3204 }
3205 } else 3205 } else {
3206 printk(KERN_CONT "to %s\n", desc); 3206 pr_cont("to %s\n", desc);
3207 }
3207 3208
3208 retval = 0; 3209 retval = 0;
3209err: 3210err:
@@ -3622,9 +3623,8 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
3622 con_driver, con_dev_groups, 3623 con_driver, con_dev_groups,
3623 "vtcon%i", con_driver->node); 3624 "vtcon%i", con_driver->node);
3624 if (IS_ERR(con_driver->dev)) { 3625 if (IS_ERR(con_driver->dev)) {
3625 printk(KERN_WARNING "Unable to create device for %s; " 3626 pr_warn("Unable to create device for %s; errno = %ld\n",
3626 "errno = %ld\n", con_driver->desc, 3627 con_driver->desc, PTR_ERR(con_driver->dev));
3627 PTR_ERR(con_driver->dev));
3628 con_driver->dev = NULL; 3628 con_driver->dev = NULL;
3629 } else { 3629 } else {
3630 vtconsole_init_device(con_driver); 3630 vtconsole_init_device(con_driver);
@@ -3761,8 +3761,8 @@ static int __init vtconsole_class_init(void)
3761 3761
3762 vtconsole_class = class_create(THIS_MODULE, "vtconsole"); 3762 vtconsole_class = class_create(THIS_MODULE, "vtconsole");
3763 if (IS_ERR(vtconsole_class)) { 3763 if (IS_ERR(vtconsole_class)) {
3764 printk(KERN_WARNING "Unable to create vt console class; " 3764 pr_warn("Unable to create vt console class; errno = %ld\n",
3765 "errno = %ld\n", PTR_ERR(vtconsole_class)); 3765 PTR_ERR(vtconsole_class));
3766 vtconsole_class = NULL; 3766 vtconsole_class = NULL;
3767 } 3767 }
3768 3768
@@ -3778,9 +3778,8 @@ static int __init vtconsole_class_init(void)
3778 "vtcon%i", con->node); 3778 "vtcon%i", con->node);
3779 3779
3780 if (IS_ERR(con->dev)) { 3780 if (IS_ERR(con->dev)) {
3781 printk(KERN_WARNING "Unable to create " 3781 pr_warn("Unable to create device for %s; errno = %ld\n",
3782 "device for %s; errno = %ld\n", 3782 con->desc, PTR_ERR(con->dev));
3783 con->desc, PTR_ERR(con->dev));
3784 con->dev = NULL; 3783 con->dev = NULL;
3785 } else { 3784 } else {
3786 vtconsole_init_device(con); 3785 vtconsole_init_device(con);
@@ -4121,37 +4120,45 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
4121 return -EINVAL; 4120 return -EINVAL;
4122 if (op->charcount > 512) 4121 if (op->charcount > 512)
4123 return -EINVAL; 4122 return -EINVAL;
4123 if (op->width <= 0 || op->width > 32 || op->height > 32)
4124 return -EINVAL;
4125 size = (op->width+7)/8 * 32 * op->charcount;
4126 if (size > max_font_size)
4127 return -ENOSPC;
4128
4129 font.data = memdup_user(op->data, size);
4130 if (IS_ERR(font.data))
4131 return PTR_ERR(font.data);
4132
4124 if (!op->height) { /* Need to guess font height [compat] */ 4133 if (!op->height) { /* Need to guess font height [compat] */
4125 int h, i; 4134 int h, i;
4126 u8 __user *charmap = op->data; 4135 u8 *charmap = font.data;
4127 u8 tmp; 4136
4128 4137 /*
4129 /* If from KDFONTOP ioctl, don't allow things which can be done in userland, 4138 * If from KDFONTOP ioctl, don't allow things which can be done
4130 so that we can get rid of this soon */ 4139 * in userland,so that we can get rid of this soon
4131 if (!(op->flags & KD_FONT_FLAG_OLD)) 4140 */
4141 if (!(op->flags & KD_FONT_FLAG_OLD)) {
4142 kfree(font.data);
4132 return -EINVAL; 4143 return -EINVAL;
4144 }
4145
4133 for (h = 32; h > 0; h--) 4146 for (h = 32; h > 0; h--)
4134 for (i = 0; i < op->charcount; i++) { 4147 for (i = 0; i < op->charcount; i++)
4135 if (get_user(tmp, &charmap[32*i+h-1])) 4148 if (charmap[32*i+h-1])
4136 return -EFAULT;
4137 if (tmp)
4138 goto nonzero; 4149 goto nonzero;
4139 } 4150
4151 kfree(font.data);
4140 return -EINVAL; 4152 return -EINVAL;
4153
4141 nonzero: 4154 nonzero:
4142 op->height = h; 4155 op->height = h;
4143 } 4156 }
4144 if (op->width <= 0 || op->width > 32 || op->height > 32) 4157
4145 return -EINVAL;
4146 size = (op->width+7)/8 * 32 * op->charcount;
4147 if (size > max_font_size)
4148 return -ENOSPC;
4149 font.charcount = op->charcount; 4158 font.charcount = op->charcount;
4150 font.height = op->height;
4151 font.width = op->width; 4159 font.width = op->width;
4152 font.data = memdup_user(op->data, size); 4160 font.height = op->height;
4153 if (IS_ERR(font.data)) 4161
4154 return PTR_ERR(font.data);
4155 console_lock(); 4162 console_lock();
4156 if (vc->vc_mode != KD_TEXT) 4163 if (vc->vc_mode != KD_TEXT)
4157 rc = -EINVAL; 4164 rc = -EINVAL;