Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'tty-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/staging driver updates from Greg KH:
"Here is the big tty/serial driver update for 4.16-rc1.

The usual number of various serial driver fixes and updates to try to
get them to work with crazy hardware configurations (seriously, how
many different ways are hardware engineers going to come up with to
hook up a simple UART?)

There is also some serdev bugfixes and updates, as well as a
smattering of other small fixes in here.

All have been in the linux-next tree for a while, with no reported
issues"

* tag 'tty-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (65 commits)
tty: serial: exar: Relocate sleep wake-up handling
tty: fix data race between tty_init_dev and flush of buf
serial: imx: fix endless loop during suspend
serial: core: mark port as initialized after successful IRQ change
serdev: only match serdev devices
serdev: do not generate modaliases for controllers
serial: mxs-auart: don't use GPIOF_* with gpiod_get_direction
serial: 8250_dw: Revert "Improve clock rate setting"
MAINTAINERS: Add myself as designated reviewer for 8250_dw
gpio: serial: max310x: Support open-drain configuration for GPIOs
serdev: Fix serdev_uevent failure on ACPI enumerated serdev-controllers
serial: 8250_ingenic: Parse earlycon options
serial: 8250_ingenic: Add support for the JZ4770 SoC
serial: core: Make uart_parse_options take const char* argument
serial: 8250_of: fix return code when probe function fails to get reset
serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTS
serial: 8250_uniphier: fix error return code in uniphier_uart_probe()
tty: n_gsm: Allow ADM response in addition to UA for control dlci
tty: omap-serial: Fix initial on-boot RTS GPIO level
tty: serial: jsm: Add one check against NULL pointer dereference
...

+545 -349
+2 -2
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
··· 6 6 - interrupts : Should contain uart interrupt 7 7 8 8 Optional properties: 9 - - fsl,irda-mode : Indicate the uart supports irda mode 10 9 - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works 11 10 in DCE mode by default. 12 - - rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt 11 + - rs485-rts-delay, rs485-rts-active-low, rs485-rx-during-tx, 12 + linux,rs485-enabled-at-boot-time: see rs485.txt 13 13 14 14 Please check Documentation/devicetree/bindings/serial/serial.txt 15 15 for the complete list of generic properties.
+2 -1
Documentation/devicetree/bindings/serial/fsl-lpuart.txt
··· 16 16 Optional properties: 17 17 - dmas: A list of two dma specifiers, one for each entry in dma-names. 18 18 - dma-names: should contain "tx" and "rx". 19 - - rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt 19 + - rs485-rts-delay, rs485-rts-active-low, rs485-rx-during-tx, 20 + linux,rs485-enabled-at-boot-time: see rs485.txt 20 21 21 22 Note: Optional properties for DMA support. Write them both or both not. 22 23
+6 -2
Documentation/devicetree/bindings/serial/ingenic,uart.txt
··· 1 1 * Ingenic SoC UART 2 2 3 3 Required properties: 4 - - compatible : "ingenic,jz4740-uart", "ingenic,jz4760-uart", 5 - "ingenic,jz4775-uart" or "ingenic,jz4780-uart" 4 + - compatible : One of: 5 + - "ingenic,jz4740-uart", 6 + - "ingenic,jz4760-uart", 7 + - "ingenic,jz4770-uart", 8 + - "ingenic,jz4775-uart", 9 + - "ingenic,jz4780-uart". 6 10 - reg : offset and length of the register set for the device. 7 11 - interrupts : should contain uart interrupt. 8 12 - clocks : phandles to the module & baud clocks.
+16 -2
Documentation/devicetree/bindings/serial/maxim,max310x.txt
··· 24 24 1 = active low. 25 25 26 26 Example: 27 + 28 + / { 29 + clocks { 30 + spi_uart_clk: osc_max14830 { 31 + compatible = "fixed-clock"; 32 + #clock-cells = <0>; 33 + clock-frequency = <3686400>; 34 + }; 35 + 36 + }; 37 + }; 38 + 39 + &spi0 { 27 40 max14830: max14830@0 { 28 41 compatible = "maxim,max14830"; 29 42 reg = <0>; 30 - clocks = <&clk20m>; 43 + clocks = <&spi_uart_clk>; 31 44 clock-names = "osc"; 32 45 interrupt-parent = <&gpio3>; 33 - interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 46 + interrupts = <7 IRQ_TYPE_LEVEL_LOW>; 34 47 gpio-controller; 35 48 #gpio-cells = <2>; 36 49 }; 50 + };
+45 -5
Documentation/devicetree/bindings/serial/mvebu-uart.txt
··· 1 - * Marvell UART : Non standard UART used in some of Marvell EBU SoCs (e.g., Armada-3700) 1 + * Marvell UART : Non standard UART used in some of Marvell EBU SoCs 2 + e.g., Armada-3700. 2 3 3 4 Required properties: 4 - - compatible: "marvell,armada-3700-uart" 5 + - compatible: 6 + - "marvell,armada-3700-uart" for the standard variant of the UART 7 + (32 bytes FIFO, no DMA, level interrupts, 8-bit access to the 8 + FIFO, baudrate limited to 230400). 9 + - "marvell,armada-3700-uart-ext" for the extended variant of the 10 + UART (128 bytes FIFO, DMA, front interrupts, 8-bit or 32-bit 11 + accesses to the FIFO, baudrate unlimited by the dividers). 5 12 - reg: offset and length of the register set for the device. 6 - - interrupts: device interrupt 13 + - clocks: UART reference clock used to derive the baudrate. If no clock 14 + is provided (possible only with the "marvell,armada-3700-uart" 15 + compatible string for backward compatibility), it will only work 16 + if the baudrate was initialized by the bootloader and no baudrate 17 + change will then be possible. 18 + - interrupts: 19 + - Must contain three elements for the standard variant of the IP 20 + (marvell,armada-3700-uart): "uart-sum", "uart-tx" and "uart-rx", 21 + respectively the UART sum interrupt, the UART TX interrupt and 22 + UART RX interrupt. A corresponding interrupt-names property must 23 + be defined. 24 + - Must contain two elements for the extended variant of the IP 25 + (marvell,armada-3700-uart-ext): "uart-tx" and "uart-rx", 26 + respectively the UART TX interrupt and the UART RX interrupt. A 27 + corresponding interrupts-names property must be defined. 28 + - For backward compatibility reasons, a single element interrupts 29 + property is also supported for the standard variant of the IP, 30 + containing only the UART sum interrupt. This form is deprecated 31 + and should no longer be used. 7 32 8 33 Example: 9 - serial@12000 { 34 + uart0: serial@12000 { 10 35 compatible = "marvell,armada-3700-uart"; 11 36 reg = <0x12000 0x200>; 12 - interrupts = <43>; 37 + clocks = <&xtalclk>; 38 + interrupts = 39 + <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, 40 + <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>, 41 + <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>; 42 + interrupt-names = "uart-sum", "uart-tx", "uart-rx"; 43 + }; 44 + 45 + uart1: serial@12200 { 46 + compatible = "marvell,armada-3700-uart-ext"; 47 + reg = <0x12200 0x30>; 48 + clocks = <&xtalclk>; 49 + interrupts = 50 + <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>, 51 + <GIC_SPI 31 IRQ_TYPE_EDGE_RISING>; 52 + interrupt-names = "uart-tx", "uart-rx"; 13 53 };
+1
Documentation/devicetree/bindings/serial/omap_serial.txt
··· 20 20 node and a DMA channel number. 21 21 - dma-names : "rx" for receive channel, "tx" for transmit channel. 22 22 - rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt 23 + - rs485-rts-active-high: drive RTS high when sending (default is low). 23 24 24 25 Example: 25 26
+1
Documentation/devicetree/bindings/serial/rs485.txt
··· 12 12 * b is the delay between end of data sent and rts signal in milliseconds 13 13 it corresponds to the delay after sending data and actual release of the line. 14 14 If this property is not specified, <0 0> is assumed. 15 + - rs485-rts-active-low: drive RTS low when sending (default is high). 15 16 - linux,rs485-enabled-at-boot-time: empty property telling to enable the rs485 16 17 feature at boot time. It can be disabled later with proper ioctl. 17 18 - rs485-rx-during-tx: empty property that enables the receiving of data even
+5
MAINTAINERS
··· 13181 13181 F: drivers/reset/reset-axs10x.c 13182 13182 F: Documentation/devicetree/bindings/reset/snps,axs10x-reset.txt 13183 13183 13184 + SYNOPSYS DESIGNWARE 8250 UART DRIVER 13185 + R: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 13186 + S: Maintained 13187 + F: drivers/tty/serial/8250/8250_dw.c 13188 + 13184 13189 SYNOPSYS DESIGNWARE APB GPIO DRIVER 13185 13190 M: Hoan Tran <hotran@apm.com> 13186 13191 L: linux-gpio@vger.kernel.org
+5 -1
drivers/tty/Kconfig
··· 394 394 depends on GOLDFISH 395 395 select SERIAL_CORE 396 396 select SERIAL_CORE_CONSOLE 397 - select SERIAL_EARLYCON 398 397 help 399 398 Console and system TTY driver for the Goldfish virtual platform. 399 + 400 + config GOLDFISH_TTY_EARLY_CONSOLE 401 + bool 402 + default y if GOLDFISH_TTY=y 403 + select SERIAL_EARLYCON 400 404 401 405 config DA_TTY 402 406 bool "DA TTY"
+2
drivers/tty/goldfish.c
··· 433 433 return 0; 434 434 } 435 435 436 + #ifdef CONFIG_GOLDFISH_TTY_EARLY_CONSOLE 436 437 static void gf_early_console_putchar(struct uart_port *port, int ch) 437 438 { 438 439 __raw_writel(ch, port->membase); ··· 457 456 } 458 457 459 458 OF_EARLYCON_DECLARE(early_gf_tty, "google,goldfish-tty", gf_earlycon_setup); 459 + #endif 460 460 461 461 static const struct of_device_id goldfish_tty_of_match[] = { 462 462 { .compatible = "google,goldfish-tty", },
+1 -5
drivers/tty/isicom.c
··· 219 219 static int WaitTillCardIsFree(unsigned long base) 220 220 { 221 221 unsigned int count = 0; 222 - unsigned int a = in_atomic(); /* do we run under spinlock? */ 223 222 224 223 while (!(inw(base + 0xe) & 0x1) && count++ < 100) 225 - if (a) 226 - mdelay(1); 227 - else 228 - msleep(1); 224 + mdelay(1); 229 225 230 226 return !(inw(base + 0xe) & 0x1); 231 227 }
+11 -6
drivers/tty/moxa.c
··· 1487 1487 if (ts->c_iflag & IXANY) 1488 1488 xany = 1; 1489 1489 1490 - /* Clear the features we don't support */ 1491 - ts->c_cflag &= ~CMSPAR; 1492 1490 MoxaPortFlowCtrl(ch, rts, cts, txflow, rxflow, xany); 1493 1491 baud = MoxaPortSetTermio(ch, ts, tty_get_baud_rate(tty)); 1494 1492 if (baud == -1) ··· 1779 1781 mode |= MX_STOP1; 1780 1782 1781 1783 if (termio->c_cflag & PARENB) { 1782 - if (termio->c_cflag & PARODD) 1783 - mode |= MX_PARODD; 1784 - else 1785 - mode |= MX_PAREVEN; 1784 + if (termio->c_cflag & PARODD) { 1785 + if (termio->c_cflag & CMSPAR) 1786 + mode |= MX_PARMARK; 1787 + else 1788 + mode |= MX_PARODD; 1789 + } else { 1790 + if (termio->c_cflag & CMSPAR) 1791 + mode |= MX_PARSPACE; 1792 + else 1793 + mode |= MX_PAREVEN; 1794 + } 1786 1795 } else 1787 1796 mode |= MX_PARNONE; 1788 1797
+2
drivers/tty/moxa.h
··· 301 301 #define MX_PARNONE 0x00 302 302 #define MX_PAREVEN 0x40 303 303 #define MX_PARODD 0xC0 304 + #define MX_PARMARK 0xA0 305 + #define MX_PARSPACE 0x20 304 306 305 307 #endif
+14 -5
drivers/tty/n_gsm.c
··· 1451 1451 * in which case an opening port goes back to closed and a closing port 1452 1452 * is simply put into closed state (any further frames from the other 1453 1453 * end will get a DM response) 1454 + * 1455 + * Some control dlci can stay in ADM mode with other dlci working just 1456 + * fine. In that case we can just keep the control dlci open after the 1457 + * DLCI_OPENING retries time out. 1454 1458 */ 1455 1459 1456 1460 static void gsm_dlci_t1(struct timer_list *t) ··· 1468 1464 if (dlci->retries) { 1469 1465 gsm_command(dlci->gsm, dlci->addr, SABM|PF); 1470 1466 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); 1471 - } else 1467 + } else if (!dlci->addr && gsm->control == (DM | PF)) { 1468 + if (debug & 8) 1469 + pr_info("DLCI %d opening in ADM mode.\n", 1470 + dlci->addr); 1471 + gsm_dlci_open(dlci); 1472 + } else { 1472 1473 gsm_dlci_close(dlci); 1474 + } 1475 + 1473 1476 break; 1474 1477 case DLCI_CLOSING: 1475 1478 dlci->retries--; ··· 1494 1483 * @dlci: DLCI to open 1495 1484 * 1496 1485 * Commence opening a DLCI from the Linux side. We issue SABM messages 1497 - * to the modem which should then reply with a UA, at which point we 1498 - * will move into open state. Opening is done asynchronously with retry 1486 + * to the modem which should then reply with a UA or ADM, at which point 1487 + * we will move into open state. Opening is done asynchronously with retry 1499 1488 * running off timers and the responses. 1500 1489 */ 1501 1490 ··· 2966 2955 static void gsmtty_close(struct tty_struct *tty, struct file *filp) 2967 2956 { 2968 2957 struct gsm_dlci *dlci = tty->driver_data; 2969 - struct gsm_mux *gsm; 2970 2958 2971 2959 if (dlci == NULL) 2972 2960 return; ··· 2974 2964 mutex_lock(&dlci->mutex); 2975 2965 gsm_destroy_network(dlci); 2976 2966 mutex_unlock(&dlci->mutex); 2977 - gsm = dlci->gsm; 2978 2967 if (tty_port_close_start(&dlci->port, tty, filp) == 0) 2979 2968 return; 2980 2969 gsm_dlci_begin_close(dlci);
+42 -33
drivers/tty/serdev/core.c
··· 19 19 static bool is_registered; 20 20 static DEFINE_IDA(ctrl_ida); 21 21 22 + static ssize_t modalias_show(struct device *dev, 23 + struct device_attribute *attr, char *buf) 24 + { 25 + int len; 26 + 27 + len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1); 28 + if (len != -ENODEV) 29 + return len; 30 + 31 + return of_device_modalias(dev, buf, PAGE_SIZE); 32 + } 33 + static DEVICE_ATTR_RO(modalias); 34 + 35 + static struct attribute *serdev_device_attrs[] = { 36 + &dev_attr_modalias.attr, 37 + NULL, 38 + }; 39 + ATTRIBUTE_GROUPS(serdev_device); 40 + 41 + static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env) 42 + { 43 + int rc; 44 + 45 + /* TODO: platform modalias */ 46 + 47 + rc = acpi_device_uevent_modalias(dev, env); 48 + if (rc != -ENODEV) 49 + return rc; 50 + 51 + return of_device_uevent_modalias(dev, env); 52 + } 53 + 22 54 static void serdev_device_release(struct device *dev) 23 55 { 24 56 struct serdev_device *serdev = to_serdev_device(dev); ··· 58 26 } 59 27 60 28 static const struct device_type serdev_device_type = { 29 + .groups = serdev_device_groups, 30 + .uevent = serdev_device_uevent, 61 31 .release = serdev_device_release, 62 32 }; 33 + 34 + static bool is_serdev_device(const struct device *dev) 35 + { 36 + return dev->type == &serdev_device_type; 37 + } 63 38 64 39 static void serdev_ctrl_release(struct device *dev) 65 40 { ··· 81 42 82 43 static int serdev_device_match(struct device *dev, struct device_driver *drv) 83 44 { 45 + if (!is_serdev_device(dev)) 46 + return 0; 47 + 84 48 /* TODO: platform matching */ 85 49 if (acpi_driver_match_device(dev, drv)) 86 50 return 1; 87 51 88 52 return of_driver_match_device(dev, drv); 89 - } 90 - 91 - static int serdev_uevent(struct device *dev, struct kobj_uevent_env *env) 92 - { 93 - int rc; 94 - 95 - /* TODO: platform modalias */ 96 - rc = acpi_device_uevent_modalias(dev, env); 97 - if (rc != -ENODEV) 98 - return rc; 99 - 100 - return of_device_uevent_modalias(dev, env); 101 53 } 102 54 103 55 /** ··· 342 312 return 0; 343 313 } 344 314 345 - static ssize_t modalias_show(struct device *dev, 346 - struct device_attribute *attr, char *buf) 347 - { 348 - int len; 349 - 350 - len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1); 351 - if (len != -ENODEV) 352 - return len; 353 - 354 - return of_device_modalias(dev, buf, PAGE_SIZE); 355 - } 356 - DEVICE_ATTR_RO(modalias); 357 - 358 - static struct attribute *serdev_device_attrs[] = { 359 - &dev_attr_modalias.attr, 360 - NULL, 361 - }; 362 - ATTRIBUTE_GROUPS(serdev_device); 363 - 364 315 static struct bus_type serdev_bus_type = { 365 316 .name = "serial", 366 317 .match = serdev_device_match, 367 318 .probe = serdev_drv_probe, 368 319 .remove = serdev_drv_remove, 369 - .uevent = serdev_uevent, 370 - .dev_groups = serdev_device_groups, 371 320 }; 372 321 373 322 /**
+6 -2
drivers/tty/serdev/serdev-ttyport.c
··· 59 59 test_bit(SERPORT_ACTIVE, &serport->flags)) 60 60 serdev_controller_write_wakeup(ctrl); 61 61 62 - wake_up_interruptible_poll(&tty->write_wait, POLLOUT); 62 + /* Wake up any tty_wait_until_sent() */ 63 + wake_up_interruptible(&tty->write_wait); 63 64 64 65 tty_kref_put(tty); 65 66 } ··· 123 122 if (ret) 124 123 goto err_close; 125 124 125 + tty_unlock(serport->tty); 126 + 126 127 /* Bring the UART into a known 8 bits no parity hw fc state */ 127 128 ktermios = tty->termios; 128 129 ktermios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | ··· 134 131 ktermios.c_cflag &= ~(CSIZE | PARENB); 135 132 ktermios.c_cflag |= CS8; 136 133 ktermios.c_cflag |= CRTSCTS; 134 + /* Hangups are not supported so make sure to ignore carrier detect. */ 135 + ktermios.c_cflag |= CLOCAL; 137 136 tty_set_termios(tty, &ktermios); 138 137 139 138 set_bit(SERPORT_ACTIVE, &serport->flags); 140 139 141 - tty_unlock(serport->tty); 142 140 return 0; 143 141 144 142 err_close:
+14 -19
drivers/tty/serial/8250/8250_dw.c
··· 252 252 struct ktermios *old) 253 253 { 254 254 unsigned int baud = tty_termios_baud_rate(termios); 255 - unsigned int target_rate, min_rate, max_rate; 256 255 struct dw8250_data *d = p->private_data; 257 256 long rate; 258 - int i, ret; 257 + int ret; 259 258 260 259 if (IS_ERR(d->clk) || !old) 261 260 goto out; 262 261 263 - /* Find a clk rate within +/-1.6% of an integer multiple of baudx16 */ 264 - target_rate = baud * 16; 265 - min_rate = target_rate - (target_rate >> 6); 266 - max_rate = target_rate + (target_rate >> 6); 267 - 268 - for (i = 1; i <= UART_DIV_MAX; i++) { 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); 262 + clk_disable_unprepare(d->clk); 263 + rate = clk_round_rate(d->clk, baud * 16); 264 + if (rate < 0) 265 + ret = rate; 266 + else if (rate == 0) 267 + ret = -ENOENT; 268 + else 275 269 ret = clk_set_rate(d->clk, rate); 276 - clk_prepare_enable(d->clk); 277 - if (!ret) 278 - p->uartclk = rate; 279 - } 270 + clk_prepare_enable(d->clk); 271 + 272 + if (!ret) 273 + p->uartclk = rate; 280 274 281 275 out: 282 276 p->status &= ~UPSTAT_AUTOCTS; ··· 509 515 /* If no clock rate is defined, fail. */ 510 516 if (!p->uartclk) { 511 517 dev_err(dev, "clock rate not defined\n"); 512 - return -EINVAL; 518 + err = -EINVAL; 519 + goto err_clk; 513 520 } 514 521 515 522 data->pclk = devm_clk_get(dev, "apb_pclk");
+30 -4
drivers/tty/serial/8250/8250_exar.c
··· 34 34 #define PCI_DEVICE_ID_EXAR_XR17V4358 0x4358 35 35 #define PCI_DEVICE_ID_EXAR_XR17V8358 0x8358 36 36 37 + #define UART_EXAR_INT0 0x80 37 38 #define UART_EXAR_8XMODE 0x88 /* 8X sampling rate select */ 38 39 39 40 #define UART_EXAR_FCTR 0x08 /* Feature Control Register */ ··· 122 121 struct exar8250 { 123 122 unsigned int nr; 124 123 struct exar8250_board *board; 124 + void __iomem *virt; 125 125 int line[0]; 126 126 }; 127 127 ··· 133 131 const struct exar8250_board *board = priv->board; 134 132 unsigned int bar = 0; 135 133 136 - if (!pcim_iomap_table(pcidev)[bar] && !pcim_iomap(pcidev, bar, 0)) 137 - return -ENOMEM; 138 - 139 134 port->port.iotype = UPIO_MEM; 140 135 port->port.mapbase = pci_resource_start(pcidev, bar) + offset; 141 - port->port.membase = pcim_iomap_table(pcidev)[bar] + offset; 136 + port->port.membase = priv->virt + offset; 142 137 port->port.regshift = board->reg_shift; 143 138 144 139 return 0; ··· 419 420 port->port.private_data = NULL; 420 421 } 421 422 423 + /* 424 + * These Exar UARTs have an extra interrupt indicator that could fire for a 425 + * few interrupts that are not presented/cleared through IIR. One of which is 426 + * a wakeup interrupt when coming out of sleep. These interrupts are only 427 + * cleared by reading global INT0 or INT1 registers as interrupts are 428 + * associated with channel 0. The INT[3:0] registers _are_ accessible from each 429 + * channel's address space, but for the sake of bus efficiency we register a 430 + * dedicated handler at the PCI device level to handle them. 431 + */ 432 + static irqreturn_t exar_misc_handler(int irq, void *data) 433 + { 434 + struct exar8250 *priv = data; 435 + 436 + /* Clear all PCI interrupts by reading INT0. No effect on IIR */ 437 + ioread8(priv->virt + UART_EXAR_INT0); 438 + 439 + return IRQ_HANDLED; 440 + } 441 + 422 442 static int 423 443 exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) 424 444 { ··· 466 448 return -ENOMEM; 467 449 468 450 priv->board = board; 451 + priv->virt = pcim_iomap(pcidev, bar, 0); 452 + if (!priv->virt) 453 + return -ENOMEM; 469 454 470 455 pci_set_master(pcidev); 471 456 ··· 481 460 | UPF_EXAR_EFR; 482 461 uart.port.irq = pci_irq_vector(pcidev, 0); 483 462 uart.port.dev = &pcidev->dev; 463 + 464 + rc = devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler, 465 + IRQF_SHARED, "exar_uart", priv); 466 + if (rc) 467 + return rc; 484 468 485 469 for (i = 0; i < nr_ports && i < maxnr; i++) { 486 470 rc = board->setup(priv, pcidev, &uart, i);
+15 -2
drivers/tty/serial/8250/8250_ingenic.c
··· 91 91 const char *opt) 92 92 { 93 93 struct uart_port *port = &dev->port; 94 - unsigned int baud, divisor; 94 + unsigned int divisor; 95 + int baud = 115200; 95 96 96 97 if (!dev->port.membase) 97 98 return -ENODEV; 98 99 100 + if (opt) { 101 + unsigned int parity, bits, flow; /* unused for now */ 102 + 103 + uart_parse_options(opt, &baud, &parity, &bits, &flow); 104 + } 105 + 99 106 ingenic_early_console_setup_clock(dev); 100 107 101 - baud = dev->baud ?: 115200; 108 + if (dev->baud) 109 + baud = dev->baud; 102 110 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * baud); 103 111 104 112 early_out(port, UART_IER, 0); ··· 131 123 132 124 EARLYCON_DECLARE(jz4740_uart, ingenic_early_console_setup); 133 125 OF_EARLYCON_DECLARE(jz4740_uart, "ingenic,jz4740-uart", 126 + ingenic_early_console_setup); 127 + 128 + EARLYCON_DECLARE(jz4770_uart, ingenic_early_console_setup); 129 + OF_EARLYCON_DECLARE(jz4770_uart, "ingenic,jz4770-uart", 134 130 ingenic_early_console_setup); 135 131 136 132 EARLYCON_DECLARE(jz4775_uart, ingenic_early_console_setup); ··· 331 319 static const struct of_device_id of_match[] = { 332 320 { .compatible = "ingenic,jz4740-uart", .data = &jz4740_uart_config }, 333 321 { .compatible = "ingenic,jz4760-uart", .data = &jz4760_uart_config }, 322 + { .compatible = "ingenic,jz4770-uart", .data = &jz4760_uart_config }, 334 323 { .compatible = "ingenic,jz4775-uart", .data = &jz4760_uart_config }, 335 324 { .compatible = "ingenic,jz4780-uart", .data = &jz4780_uart_config }, 336 325 { /* sentinel */ }
+4 -1
drivers/tty/serial/8250/8250_of.c
··· 136 136 } 137 137 138 138 info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); 139 - if (IS_ERR(info->rst)) 139 + if (IS_ERR(info->rst)) { 140 + ret = PTR_ERR(info->rst); 140 141 goto err_dispose; 142 + } 143 + 141 144 ret = reset_control_deassert(info->rst); 142 145 if (ret) 143 146 goto err_dispose;
+1 -1
drivers/tty/serial/8250/8250_omap.c
··· 414 414 /* Up to here it was mostly serial8250_do_set_termios() */ 415 415 416 416 /* 417 - * We enable TRIG_GRANU for RX and TX and additionaly we set 417 + * We enable TRIG_GRANU for RX and TX and additionally we set 418 418 * SCR_TX_EMPTY bit. The result is the following: 419 419 * - RX_TRIGGER amount of bytes in the FIFO will cause an interrupt. 420 420 * - less than RX_TRIGGER number of bytes will also cause an interrupt
-26
drivers/tty/serial/8250/8250_port.c
··· 441 441 } 442 442 443 443 static int serial8250_default_handle_irq(struct uart_port *port); 444 - static int exar_handle_irq(struct uart_port *port); 445 444 446 445 static void set_io_from_upio(struct uart_port *p) 447 446 { ··· 1883 1884 } 1884 1885 1885 1886 /* 1886 - * These Exar UARTs have an extra interrupt indicator that could 1887 - * fire for a few unimplemented interrupts. One of which is a 1888 - * wakeup event when coming out of sleep. Put this here just 1889 - * to be on the safe side that these interrupts don't go unhandled. 1890 - */ 1891 - static int exar_handle_irq(struct uart_port *port) 1892 - { 1893 - unsigned int iir = serial_port_in(port, UART_IIR); 1894 - int ret = 0; 1895 - 1896 - if (((port->type == PORT_XR17V35X) || (port->type == PORT_XR17D15X)) && 1897 - serial_port_in(port, UART_EXAR_INT0) != 0) 1898 - ret = 1; 1899 - 1900 - ret |= serial8250_handle_irq(port, iir); 1901 - 1902 - return ret; 1903 - } 1904 - 1905 - /* 1906 1887 * Newer 16550 compatible parts such as the SC16C650 & Altera 16550 Soft IP 1907 1888 * have a programmable TX threshold that triggers the THRE interrupt in 1908 1889 * the IIR register. In this case, the THRE interrupt indicates the FIFO ··· 3045 3066 3046 3067 if (port->type == PORT_UNKNOWN) 3047 3068 serial8250_release_std_resource(up); 3048 - 3049 - /* Fixme: probably not the best place for this */ 3050 - if ((port->type == PORT_XR17V35X) || 3051 - (port->type == PORT_XR17D15X)) 3052 - port->handle_irq = exar_handle_irq; 3053 3069 3054 3070 register_dev_spec_attr_grp(up); 3055 3071 up->fcr = uart_config[up->port.type].fcr;
+3 -2
drivers/tty/serial/8250/8250_uniphier.c
··· 250 250 up.dl_read = uniphier_serial_dl_read; 251 251 up.dl_write = uniphier_serial_dl_write; 252 252 253 - priv->line = serial8250_register_8250_port(&up); 254 - if (priv->line < 0) { 253 + ret = serial8250_register_8250_port(&up); 254 + if (ret < 0) { 255 255 dev_err(dev, "failed to register 8250 port\n"); 256 256 clk_disable_unprepare(priv->clk); 257 257 return ret; 258 258 } 259 + priv->line = ret; 259 260 260 261 platform_set_drvdata(pdev, priv); 261 262
+1
drivers/tty/serial/8250/Kconfig
··· 5 5 6 6 config SERIAL_8250 7 7 tristate "8250/16550 and compatible serial support" 8 + depends on !S390 8 9 select SERIAL_CORE 9 10 ---help--- 10 11 This selects whether you want to include the driver for the standard
+10 -4
drivers/tty/serial/Kconfig
··· 761 761 select SERIAL_MCTRL_GPIO if GPIOLIB 762 762 763 763 config SERIAL_SH_SCI_NR_UARTS 764 - int "Maximum number of SCI(F) serial ports" 764 + int "Maximum number of SCI(F) serial ports" if EXPERT 765 765 depends on SERIAL_SH_SCI 766 + default "3" if H8300 767 + default "10" if SUPERH 768 + default "18" if ARCH_RENESAS 766 769 default "2" 767 770 768 771 config SERIAL_SH_SCI_CONSOLE 769 - bool "Support for console on SuperH SCI(F)" 772 + bool "Support for console on SuperH SCI(F)" if EXPERT 770 773 depends on SERIAL_SH_SCI=y 771 774 select SERIAL_CORE_CONSOLE 775 + default y 772 776 773 777 config SERIAL_SH_SCI_EARLYCON 774 - bool "Support for early console on SuperH SCI(F)" 778 + bool "Support for early console on SuperH SCI(F)" if EXPERT 775 779 depends on SERIAL_SH_SCI=y 776 780 select SERIAL_CORE_CONSOLE 777 781 select SERIAL_EARLYCON 782 + default ARCH_RENESAS || H8300 778 783 779 784 config SERIAL_SH_SCI_DMA 780 - bool "DMA support" 785 + bool "DMA support" if EXPERT 781 786 depends on SERIAL_SH_SCI && DMA_ENGINE 787 + default ARCH_RENESAS 782 788 783 789 config SERIAL_PNX8XXX 784 790 bool "Enable PNX8XXX SoCs' UART Support"
+4 -8
drivers/tty/serial/amba-pl011.c
··· 314 314 static int pl011_fifo_to_tty(struct uart_amba_port *uap) 315 315 { 316 316 u16 status; 317 - unsigned int ch, flag, max_count = 256; 318 - int fifotaken = 0; 317 + unsigned int ch, flag, fifotaken; 319 318 320 - while (max_count--) { 319 + for (fifotaken = 0; fifotaken != 256; fifotaken++) { 321 320 status = pl011_read(uap, REG_FR); 322 321 if (status & UART01x_FR_RXFE) 323 322 break; ··· 325 326 ch = pl011_read(uap, REG_DR) | UART_DUMMY_DR_RX; 326 327 flag = TTY_NORMAL; 327 328 uap->port.icount.rx++; 328 - fifotaken++; 329 329 330 330 if (unlikely(ch & UART_DR_ERROR)) { 331 331 if (ch & UART011_DR_BE) { ··· 1480 1482 struct uart_amba_port *uap = dev_id; 1481 1483 unsigned long flags; 1482 1484 unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT; 1483 - u16 imsc; 1484 1485 int handled = 0; 1485 1486 1486 1487 spin_lock_irqsave(&uap->port.lock, flags); 1487 - imsc = pl011_read(uap, REG_IMSC); 1488 - status = pl011_read(uap, REG_RIS) & imsc; 1488 + status = pl011_read(uap, REG_RIS) & uap->im; 1489 1489 if (status) { 1490 1490 do { 1491 1491 check_apply_cts_event_workaround(uap); ··· 1507 1511 if (pass_counter-- == 0) 1508 1512 break; 1509 1513 1510 - status = pl011_read(uap, REG_RIS) & imsc; 1514 + status = pl011_read(uap, REG_RIS) & uap->im; 1511 1515 } while (status != 0); 1512 1516 handled = 1; 1513 1517 }
+1 -1
drivers/tty/serial/atmel_serial.c
··· 2345 2345 atmel_init_property(atmel_port, pdev); 2346 2346 atmel_set_ops(port); 2347 2347 2348 - of_get_rs485_mode(pdev->dev.of_node, &port->rs485); 2348 + uart_get_rs485_mode(&pdev->dev, &port->rs485); 2349 2349 2350 2350 port->iotype = UPIO_MEM; 2351 2351 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP;
+4 -11
drivers/tty/serial/fsl_lpuart.c
··· 2206 2206 if (ret) 2207 2207 goto failed_attach_port; 2208 2208 2209 - of_get_rs485_mode(np, &sport->port.rs485); 2209 + uart_get_rs485_mode(&pdev->dev, &sport->port.rs485); 2210 2210 2211 - if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) { 2211 + if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) 2212 2212 dev_err(&pdev->dev, "driver doesn't support RX during TX\n"); 2213 - return -ENOSYS; 2214 - } 2215 2213 2216 2214 if (sport->port.rs485.delay_rts_before_send || 2217 - sport->port.rs485.delay_rts_after_send) { 2215 + sport->port.rs485.delay_rts_after_send) 2218 2216 dev_err(&pdev->dev, "driver doesn't support RTS delays\n"); 2219 - return -ENOSYS; 2220 - } 2221 2217 2222 - if (sport->port.rs485.flags & SER_RS485_ENABLED) { 2223 - sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND; 2224 - writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM); 2225 - } 2218 + lpuart_config_rs485(&sport->port, &sport->port.rs485); 2226 2219 2227 2220 sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx"); 2228 2221 if (!sport->dma_tx_chan)
+40 -53
drivers/tty/serial/imx.c
··· 703 703 return IRQ_HANDLED; 704 704 } 705 705 706 - static void imx_disable_rx_int(struct imx_port *sport) 707 - { 708 - unsigned long temp; 709 - 710 - /* disable the receiver ready and aging timer interrupts */ 711 - temp = readl(sport->port.membase + UCR1); 712 - temp &= ~(UCR1_RRDYEN); 713 - writel(temp, sport->port.membase + UCR1); 714 - 715 - temp = readl(sport->port.membase + UCR2); 716 - temp &= ~(UCR2_ATEN); 717 - writel(temp, sport->port.membase + UCR2); 718 - 719 - /* disable the rx errors interrupts */ 720 - temp = readl(sport->port.membase + UCR4); 721 - temp &= ~UCR4_OREN; 722 - writel(temp, sport->port.membase + UCR4); 723 - } 724 - 725 706 static void clear_rx_errors(struct imx_port *sport); 726 707 727 708 /* ··· 1233 1252 if (sport->dma_is_inited && !sport->dma_is_enabled) 1234 1253 imx_enable_dma(sport); 1235 1254 1236 - temp = readl(sport->port.membase + UCR1); 1237 - temp |= UCR1_RRDYEN | UCR1_UARTEN; 1255 + temp = readl(sport->port.membase + UCR1) & ~UCR1_RRDYEN; 1256 + if (!sport->dma_is_enabled) 1257 + temp |= UCR1_RRDYEN; 1258 + temp |= UCR1_UARTEN; 1238 1259 if (sport->have_rtscts) 1239 1260 temp |= UCR1_RTSDEN; 1240 1261 1241 1262 writel(temp, sport->port.membase + UCR1); 1242 1263 1243 - temp = readl(sport->port.membase + UCR4); 1244 - temp |= UCR4_OREN; 1264 + temp = readl(sport->port.membase + UCR4) & ~UCR4_OREN; 1265 + if (!sport->dma_is_enabled) 1266 + temp |= UCR4_OREN; 1245 1267 writel(temp, sport->port.membase + UCR4); 1246 1268 1247 - temp = readl(sport->port.membase + UCR2); 1269 + temp = readl(sport->port.membase + UCR2) & ~UCR2_ATEN; 1248 1270 temp |= (UCR2_RXEN | UCR2_TXEN); 1249 1271 if (!sport->have_rtscts) 1250 1272 temp |= UCR2_IRTS; ··· 1281 1297 * In our iMX53 the average delay for the first reception dropped from 1282 1298 * approximately 35000 microseconds to 1000 microseconds. 1283 1299 */ 1284 - if (sport->dma_is_enabled) { 1285 - imx_disable_rx_int(sport); 1300 + if (sport->dma_is_enabled) 1286 1301 start_rx_dma(sport); 1287 - } 1288 1302 1289 1303 spin_unlock_irqrestore(&sport->port.lock, flags); 1290 1304 ··· 1999 2017 if (of_get_property(np, "rts-gpios", NULL)) 2000 2018 sport->have_rtsgpio = 1; 2001 2019 2002 - of_get_rs485_mode(np, &sport->port.rs485); 2003 - 2004 2020 return 0; 2005 2021 } 2006 2022 #else ··· 2060 2080 sport->port.fifosize = 32; 2061 2081 sport->port.ops = &imx_pops; 2062 2082 sport->port.rs485_config = imx_rs485_config; 2063 - sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND; 2064 2083 sport->port.flags = UPF_BOOT_AUTOCONF; 2065 2084 timer_setup(&sport->timer, imx_timeout, 0); 2066 2085 ··· 2089 2110 dev_err(&pdev->dev, "failed to enable per clk: %d\n", ret); 2090 2111 return ret; 2091 2112 } 2113 + 2114 + uart_get_rs485_mode(&pdev->dev, &sport->port.rs485); 2115 + 2116 + if (sport->port.rs485.flags & SER_RS485_ENABLED && 2117 + (!sport->have_rtscts || !sport->have_rtsgpio)) 2118 + dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); 2119 + 2120 + imx_rs485_config(&sport->port, &sport->port.rs485); 2092 2121 2093 2122 /* Disable interrupts before requesting them */ 2094 2123 reg = readl_relaxed(sport->port.membase + UCR1); ··· 2219 2232 unsigned int val; 2220 2233 2221 2234 val = readl(sport->port.membase + UCR3); 2222 - if (on) 2235 + if (on) { 2236 + writel(USR1_AWAKE, sport->port.membase + USR1); 2223 2237 val |= UCR3_AWAKEN; 2238 + } 2224 2239 else 2225 2240 val &= ~UCR3_AWAKEN; 2226 2241 writel(val, sport->port.membase + UCR3); 2227 2242 2228 - val = readl(sport->port.membase + UCR1); 2229 - if (on) 2230 - val |= UCR1_RTSDEN; 2231 - else 2232 - val &= ~UCR1_RTSDEN; 2233 - writel(val, sport->port.membase + UCR1); 2243 + if (sport->have_rtscts) { 2244 + val = readl(sport->port.membase + UCR1); 2245 + if (on) 2246 + val |= UCR1_RTSDEN; 2247 + else 2248 + val &= ~UCR1_RTSDEN; 2249 + writel(val, sport->port.membase + UCR1); 2250 + } 2234 2251 } 2235 2252 2236 2253 static int imx_serial_port_suspend_noirq(struct device *dev) 2237 2254 { 2238 2255 struct platform_device *pdev = to_platform_device(dev); 2239 2256 struct imx_port *sport = platform_get_drvdata(pdev); 2240 - int ret; 2241 - 2242 - ret = clk_enable(sport->clk_ipg); 2243 - if (ret) 2244 - return ret; 2245 2257 2246 2258 serial_imx_save_context(sport); 2247 2259 ··· 2261 2275 2262 2276 serial_imx_restore_context(sport); 2263 2277 2264 - clk_disable(sport->clk_ipg); 2265 - 2266 2278 return 0; 2267 2279 } 2268 2280 ··· 2268 2284 { 2269 2285 struct platform_device *pdev = to_platform_device(dev); 2270 2286 struct imx_port *sport = platform_get_drvdata(pdev); 2271 - 2272 - /* enable wakeup from i.MX UART */ 2273 - serial_imx_enable_wakeup(sport, true); 2287 + int ret; 2274 2288 2275 2289 uart_suspend_port(&imx_reg, &sport->port); 2276 2290 disable_irq(sport->port.irq); 2277 2291 2278 - /* Needed to enable clock in suspend_noirq */ 2279 - return clk_prepare(sport->clk_ipg); 2292 + ret = clk_prepare_enable(sport->clk_ipg); 2293 + if (ret) 2294 + return ret; 2295 + 2296 + /* enable wakeup from i.MX UART */ 2297 + serial_imx_enable_wakeup(sport, true); 2298 + 2299 + return 0; 2280 2300 } 2281 2301 2282 2302 static int imx_serial_port_resume(struct device *dev) ··· 2294 2306 uart_resume_port(&imx_reg, &sport->port); 2295 2307 enable_irq(sport->port.irq); 2296 2308 2297 - clk_unprepare(sport->clk_ipg); 2309 + clk_disable_unprepare(sport->clk_ipg); 2298 2310 2299 2311 return 0; 2300 2312 } ··· 2306 2318 2307 2319 uart_suspend_port(&imx_reg, &sport->port); 2308 2320 2309 - /* Needed to enable clock in suspend_noirq */ 2310 - return clk_prepare(sport->clk_ipg); 2321 + return clk_prepare_enable(sport->clk_ipg); 2311 2322 } 2312 2323 2313 2324 static int imx_serial_port_thaw(struct device *dev) ··· 2316 2329 2317 2330 uart_resume_port(&imx_reg, &sport->port); 2318 2331 2319 - clk_unprepare(sport->clk_ipg); 2332 + clk_disable_unprepare(sport->clk_ipg); 2320 2333 2321 2334 return 0; 2322 2335 }
+3 -3
drivers/tty/serial/jsm/jsm_neo.c
··· 282 282 u16 head; 283 283 u16 tail; 284 284 285 - if (!ch) 286 - return; 287 - 288 285 /* cache head and tail of queue */ 289 286 head = ch->ch_r_head & RQUEUEMASK; 290 287 tail = ch->ch_r_tail & RQUEUEMASK; ··· 1172 1175 continue; 1173 1176 1174 1177 ch = brd->channels[port]; 1178 + if (!ch) 1179 + continue; 1180 + 1175 1181 neo_copy_data_from_uart_to_queue(ch); 1176 1182 1177 1183 /* Call our tty layer to enforce queue flow control if needed. */
-6
drivers/tty/serial/jsm/jsm_tty.c
··· 523 523 524 524 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n"); 525 525 526 - if (!ch) 527 - return; 528 - 529 526 port = &ch->uart_port.state->port; 530 527 tp = port->tty; 531 528 ··· 645 648 int phys_carrier = 0; 646 649 647 650 jsm_dbg(CARR, &ch->ch_bd->pci_dev, "start\n"); 648 - if (!ch) 649 - return; 650 651 651 652 bd = ch->ch_bd; 652 - 653 653 if (!bd) 654 654 return; 655 655
+179 -86
drivers/tty/serial/max310x.c
··· 233 233 /* Misc definitions */ 234 234 #define MAX310X_FIFO_SIZE (128) 235 235 #define MAX310x_REV_MASK (0xf8) 236 + #define MAX310X_WRITE_BIT 0x80 236 237 237 238 /* MAX3107 specific */ 238 239 #define MAX3107_REV_ID (0xa0) ··· 594 593 return (int)bestfreq; 595 594 } 596 595 596 + static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len) 597 + { 598 + u8 header[] = { (port->iobase + MAX310X_THR_REG) | MAX310X_WRITE_BIT }; 599 + struct spi_transfer xfer[] = { 600 + { 601 + .tx_buf = &header, 602 + .len = sizeof(header), 603 + }, { 604 + .tx_buf = txbuf, 605 + .len = len, 606 + } 607 + }; 608 + spi_sync_transfer(to_spi_device(port->dev), xfer, ARRAY_SIZE(xfer)); 609 + } 610 + 611 + static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int len) 612 + { 613 + u8 header[] = { port->iobase + MAX310X_RHR_REG }; 614 + struct spi_transfer xfer[] = { 615 + { 616 + .tx_buf = &header, 617 + .len = sizeof(header), 618 + }, { 619 + .rx_buf = rxbuf, 620 + .len = len, 621 + } 622 + }; 623 + spi_sync_transfer(to_spi_device(port->dev), xfer, ARRAY_SIZE(xfer)); 624 + } 625 + 597 626 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen) 598 627 { 599 - unsigned int sts, ch, flag; 628 + unsigned int sts, ch, flag, i; 629 + u8 buf[MAX310X_FIFO_SIZE]; 600 630 601 - if (unlikely(rxlen >= port->fifosize)) { 602 - dev_warn_ratelimited(port->dev, "Possible RX FIFO overrun\n"); 603 - port->icount.buf_overrun++; 604 - /* Ensure sanity of RX level */ 605 - rxlen = port->fifosize; 606 - } 631 + if (port->read_status_mask == MAX310X_LSR_RXOVR_BIT) { 632 + /* We are just reading, happily ignoring any error conditions. 633 + * Break condition, parity checking, framing errors -- they 634 + * are all ignored. That means that we can do a batch-read. 635 + * 636 + * There is a small opportunity for race if the RX FIFO 637 + * overruns while we're reading the buffer; the datasheets says 638 + * that the LSR register applies to the "current" character. 639 + * That's also the reason why we cannot do batched reads when 640 + * asked to check the individual statuses. 641 + * */ 607 642 608 - while (rxlen--) { 609 - ch = max310x_port_read(port, MAX310X_RHR_REG); 610 643 sts = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG); 644 + max310x_batch_read(port, buf, rxlen); 611 645 612 - sts &= MAX310X_LSR_RXPAR_BIT | MAX310X_LSR_FRERR_BIT | 613 - MAX310X_LSR_RXOVR_BIT | MAX310X_LSR_RXBRK_BIT; 614 - 615 - port->icount.rx++; 646 + port->icount.rx += rxlen; 616 647 flag = TTY_NORMAL; 648 + sts &= port->read_status_mask; 617 649 618 - if (unlikely(sts)) { 619 - if (sts & MAX310X_LSR_RXBRK_BIT) { 620 - port->icount.brk++; 621 - if (uart_handle_break(port)) 622 - continue; 623 - } else if (sts & MAX310X_LSR_RXPAR_BIT) 624 - port->icount.parity++; 625 - else if (sts & MAX310X_LSR_FRERR_BIT) 626 - port->icount.frame++; 627 - else if (sts & MAX310X_LSR_RXOVR_BIT) 628 - port->icount.overrun++; 629 - 630 - sts &= port->read_status_mask; 631 - if (sts & MAX310X_LSR_RXBRK_BIT) 632 - flag = TTY_BREAK; 633 - else if (sts & MAX310X_LSR_RXPAR_BIT) 634 - flag = TTY_PARITY; 635 - else if (sts & MAX310X_LSR_FRERR_BIT) 636 - flag = TTY_FRAME; 637 - else if (sts & MAX310X_LSR_RXOVR_BIT) 638 - flag = TTY_OVERRUN; 650 + if (sts & MAX310X_LSR_RXOVR_BIT) { 651 + dev_warn_ratelimited(port->dev, "Hardware RX FIFO overrun\n"); 652 + port->icount.overrun++; 639 653 } 640 654 641 - if (uart_handle_sysrq_char(port, ch)) 642 - continue; 655 + for (i = 0; i < rxlen; ++i) { 656 + uart_insert_char(port, sts, MAX310X_LSR_RXOVR_BIT, buf[i], flag); 657 + } 643 658 644 - if (sts & port->ignore_status_mask) 645 - continue; 659 + } else { 660 + if (unlikely(rxlen >= port->fifosize)) { 661 + dev_warn_ratelimited(port->dev, "Possible RX FIFO overrun\n"); 662 + port->icount.buf_overrun++; 663 + /* Ensure sanity of RX level */ 664 + rxlen = port->fifosize; 665 + } 646 666 647 - uart_insert_char(port, sts, MAX310X_LSR_RXOVR_BIT, ch, flag); 667 + while (rxlen--) { 668 + ch = max310x_port_read(port, MAX310X_RHR_REG); 669 + sts = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG); 670 + 671 + sts &= MAX310X_LSR_RXPAR_BIT | MAX310X_LSR_FRERR_BIT | 672 + MAX310X_LSR_RXOVR_BIT | MAX310X_LSR_RXBRK_BIT; 673 + 674 + port->icount.rx++; 675 + flag = TTY_NORMAL; 676 + 677 + if (unlikely(sts)) { 678 + if (sts & MAX310X_LSR_RXBRK_BIT) { 679 + port->icount.brk++; 680 + if (uart_handle_break(port)) 681 + continue; 682 + } else if (sts & MAX310X_LSR_RXPAR_BIT) 683 + port->icount.parity++; 684 + else if (sts & MAX310X_LSR_FRERR_BIT) 685 + port->icount.frame++; 686 + else if (sts & MAX310X_LSR_RXOVR_BIT) 687 + port->icount.overrun++; 688 + 689 + sts &= port->read_status_mask; 690 + if (sts & MAX310X_LSR_RXBRK_BIT) 691 + flag = TTY_BREAK; 692 + else if (sts & MAX310X_LSR_RXPAR_BIT) 693 + flag = TTY_PARITY; 694 + else if (sts & MAX310X_LSR_FRERR_BIT) 695 + flag = TTY_FRAME; 696 + else if (sts & MAX310X_LSR_RXOVR_BIT) 697 + flag = TTY_OVERRUN; 698 + } 699 + 700 + if (uart_handle_sysrq_char(port, ch)) 701 + continue; 702 + 703 + if (sts & port->ignore_status_mask) 704 + continue; 705 + 706 + uart_insert_char(port, sts, MAX310X_LSR_RXOVR_BIT, ch, flag); 707 + } 648 708 } 649 709 650 710 tty_flip_buffer_push(&port->state->port); ··· 714 652 static void max310x_handle_tx(struct uart_port *port) 715 653 { 716 654 struct circ_buf *xmit = &port->state->xmit; 717 - unsigned int txlen, to_send; 655 + unsigned int txlen, to_send, until_end; 718 656 719 657 if (unlikely(port->x_char)) { 720 658 max310x_port_write(port, MAX310X_THR_REG, port->x_char); ··· 728 666 729 667 /* Get length of data pending in circular buffer */ 730 668 to_send = uart_circ_chars_pending(xmit); 669 + until_end = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 731 670 if (likely(to_send)) { 732 671 /* Limit to size of TX FIFO */ 733 672 txlen = max310x_port_read(port, MAX310X_TXFIFOLVL_REG); 734 673 txlen = port->fifosize - txlen; 735 674 to_send = (to_send > txlen) ? txlen : to_send; 736 675 676 + if (until_end < to_send) { 677 + /* It's a circ buffer -- wrap around. 678 + * We could do that in one SPI transaction, but meh. */ 679 + max310x_batch_write(port, xmit->buf + xmit->tail, until_end); 680 + max310x_batch_write(port, xmit->buf, to_send - until_end); 681 + } else { 682 + max310x_batch_write(port, xmit->buf + xmit->tail, to_send); 683 + } 684 + 737 685 /* Add data to send */ 738 686 port->icount.tx += to_send; 739 - while (to_send--) { 740 - max310x_port_write(port, MAX310X_THR_REG, 741 - xmit->buf[xmit->tail]); 742 - xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 743 - } 687 + xmit->tail = (xmit->tail + to_send) & (UART_XMIT_SIZE - 1); 744 688 } 745 689 746 690 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 747 691 uart_write_wakeup(port); 748 692 } 749 693 750 - static void max310x_port_irq(struct max310x_port *s, int portno) 694 + static void max310x_start_tx(struct uart_port *port) 695 + { 696 + struct max310x_one *one = container_of(port, struct max310x_one, port); 697 + 698 + if (!work_pending(&one->tx_work)) 699 + schedule_work(&one->tx_work); 700 + } 701 + 702 + static irqreturn_t max310x_port_irq(struct max310x_port *s, int portno) 751 703 { 752 704 struct uart_port *port = &s->p[portno].port; 705 + irqreturn_t res = IRQ_NONE; 753 706 754 707 do { 755 708 unsigned int ists, lsr, rxlen; ··· 775 698 if (!ists && !rxlen) 776 699 break; 777 700 701 + res = IRQ_HANDLED; 702 + 778 703 if (ists & MAX310X_IRQ_CTS_BIT) { 779 704 lsr = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG); 780 705 uart_handle_cts_change(port, ··· 784 705 } 785 706 if (rxlen) 786 707 max310x_handle_rx(port, rxlen); 787 - if (ists & MAX310X_IRQ_TXEMPTY_BIT) { 788 - mutex_lock(&s->mutex); 789 - max310x_handle_tx(port); 790 - mutex_unlock(&s->mutex); 791 - } 708 + if (ists & MAX310X_IRQ_TXEMPTY_BIT) 709 + max310x_start_tx(port); 792 710 } while (1); 711 + return res; 793 712 } 794 713 795 714 static irqreturn_t max310x_ist(int irq, void *dev_id) 796 715 { 797 716 struct max310x_port *s = (struct max310x_port *)dev_id; 717 + bool handled = false; 798 718 799 719 if (s->devtype->nr > 1) { 800 720 do { ··· 804 726 val = ((1 << s->devtype->nr) - 1) & ~val; 805 727 if (!val) 806 728 break; 807 - max310x_port_irq(s, fls(val) - 1); 729 + if (max310x_port_irq(s, fls(val) - 1) == IRQ_HANDLED) 730 + handled = true; 808 731 } while (1); 809 - } else 810 - max310x_port_irq(s, 0); 732 + } else { 733 + if (max310x_port_irq(s, 0) == IRQ_HANDLED) 734 + handled = true; 735 + } 811 736 812 - return IRQ_HANDLED; 737 + return IRQ_RETVAL(handled); 813 738 } 814 739 815 740 static void max310x_wq_proc(struct work_struct *ws) ··· 823 742 mutex_lock(&s->mutex); 824 743 max310x_handle_tx(&one->port); 825 744 mutex_unlock(&s->mutex); 826 - } 827 - 828 - static void max310x_start_tx(struct uart_port *port) 829 - { 830 - struct max310x_one *one = container_of(port, struct max310x_one, port); 831 - 832 - if (!work_pending(&one->tx_work)) 833 - schedule_work(&one->tx_work); 834 745 } 835 746 836 747 static unsigned int max310x_tx_empty(struct uart_port *port) ··· 1159 1086 1160 1087 return 0; 1161 1088 } 1089 + 1090 + static int max310x_gpio_set_config(struct gpio_chip *chip, unsigned int offset, 1091 + unsigned long config) 1092 + { 1093 + struct max310x_port *s = gpiochip_get_data(chip); 1094 + struct uart_port *port = &s->p[offset / 4].port; 1095 + 1096 + switch (pinconf_to_config_param(config)) { 1097 + case PIN_CONFIG_DRIVE_OPEN_DRAIN: 1098 + max310x_port_update(port, MAX310X_GPIOCFG_REG, 1099 + 1 << ((offset % 4) + 4), 1100 + 1 << ((offset % 4) + 4)); 1101 + return 0; 1102 + case PIN_CONFIG_DRIVE_PUSH_PULL: 1103 + max310x_port_update(port, MAX310X_GPIOCFG_REG, 1104 + 1 << ((offset % 4) + 4), 0); 1105 + return 0; 1106 + default: 1107 + return -ENOTSUPP; 1108 + } 1109 + } 1162 1110 #endif 1163 1111 1164 1112 static int max310x_probe(struct device *dev, struct max310x_devtype *devtype, 1165 - struct regmap *regmap, int irq, unsigned long flags) 1113 + struct regmap *regmap, int irq) 1166 1114 { 1167 1115 int i, ret, fmin, fmax, freq, uartclk; 1168 1116 struct clk *clk_osc, *clk_xtal; ··· 1263 1169 uartclk = max310x_set_ref_clk(s, freq, xtal); 1264 1170 dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk); 1265 1171 1266 - #ifdef CONFIG_GPIOLIB 1267 - /* Setup GPIO cotroller */ 1268 - s->gpio.owner = THIS_MODULE; 1269 - s->gpio.parent = dev; 1270 - s->gpio.label = dev_name(dev); 1271 - s->gpio.direction_input = max310x_gpio_direction_input; 1272 - s->gpio.get = max310x_gpio_get; 1273 - s->gpio.direction_output= max310x_gpio_direction_output; 1274 - s->gpio.set = max310x_gpio_set; 1275 - s->gpio.base = -1; 1276 - s->gpio.ngpio = devtype->nr * 4; 1277 - s->gpio.can_sleep = 1; 1278 - ret = devm_gpiochip_add_data(dev, &s->gpio, s); 1279 - if (ret) 1280 - goto out_clk; 1281 - #endif 1282 - 1283 1172 mutex_init(&s->mutex); 1284 1173 1285 1174 for (i = 0; i < devtype->nr; i++) { ··· 1314 1237 devtype->power(&s->p[i].port, 0); 1315 1238 } 1316 1239 1240 + #ifdef CONFIG_GPIOLIB 1241 + /* Setup GPIO cotroller */ 1242 + s->gpio.owner = THIS_MODULE; 1243 + s->gpio.parent = dev; 1244 + s->gpio.label = dev_name(dev); 1245 + s->gpio.direction_input = max310x_gpio_direction_input; 1246 + s->gpio.get = max310x_gpio_get; 1247 + s->gpio.direction_output= max310x_gpio_direction_output; 1248 + s->gpio.set = max310x_gpio_set; 1249 + s->gpio.set_config = max310x_gpio_set_config; 1250 + s->gpio.base = -1; 1251 + s->gpio.ngpio = devtype->nr * 4; 1252 + s->gpio.can_sleep = 1; 1253 + ret = devm_gpiochip_add_data(dev, &s->gpio, s); 1254 + if (ret) 1255 + goto out_uart; 1256 + #endif 1257 + 1317 1258 /* Setup interrupt */ 1318 1259 ret = devm_request_threaded_irq(dev, irq, NULL, max310x_ist, 1319 - IRQF_ONESHOT | flags, dev_name(dev), s); 1260 + IRQF_ONESHOT | IRQF_SHARED, dev_name(dev), s); 1320 1261 if (!ret) 1321 1262 return 0; 1322 1263 ··· 1388 1293 static struct regmap_config regcfg = { 1389 1294 .reg_bits = 8, 1390 1295 .val_bits = 8, 1391 - .write_flag_mask = 0x80, 1296 + .write_flag_mask = MAX310X_WRITE_BIT, 1392 1297 .cache_type = REGCACHE_RBTREE, 1393 1298 .writeable_reg = max310x_reg_writeable, 1394 1299 .volatile_reg = max310x_reg_volatile, ··· 1399 1304 static int max310x_spi_probe(struct spi_device *spi) 1400 1305 { 1401 1306 struct max310x_devtype *devtype; 1402 - unsigned long flags = 0; 1403 1307 struct regmap *regmap; 1404 1308 int ret; 1405 1309 ··· 1421 1327 devtype = (struct max310x_devtype *)id_entry->driver_data; 1422 1328 } 1423 1329 1424 - flags = IRQF_TRIGGER_FALLING; 1425 1330 regcfg.max_register = devtype->nr * 0x20 - 1; 1426 1331 regmap = devm_regmap_init_spi(spi, &regcfg); 1427 1332 1428 - return max310x_probe(&spi->dev, devtype, regmap, spi->irq, flags); 1333 + return max310x_probe(&spi->dev, devtype, regmap, spi->irq); 1429 1334 } 1430 1335 1431 1336 static int max310x_spi_remove(struct spi_device *spi)
+14 -17
drivers/tty/serial/meson_uart.c
··· 34 34 /* AML_UART_CONTROL bits */ 35 35 #define AML_UART_TX_EN BIT(12) 36 36 #define AML_UART_RX_EN BIT(13) 37 + #define AML_UART_TWO_WIRE_EN BIT(15) 38 + #define AML_UART_STOP_BIT_LEN_MASK (0x03 << 16) 39 + #define AML_UART_STOP_BIT_1SB (0x00 << 16) 40 + #define AML_UART_STOP_BIT_2SB (0x01 << 16) 41 + #define AML_UART_PARITY_TYPE BIT(18) 42 + #define AML_UART_PARITY_EN BIT(19) 37 43 #define AML_UART_TX_RST BIT(22) 38 44 #define AML_UART_RX_RST BIT(23) 39 - #define AML_UART_CLR_ERR BIT(24) 45 + #define AML_UART_CLEAR_ERR BIT(24) 40 46 #define AML_UART_RX_INT_EN BIT(27) 41 47 #define AML_UART_TX_INT_EN BIT(28) 42 48 #define AML_UART_DATA_LEN_MASK (0x03 << 20) ··· 62 56 #define AML_UART_ERR (AML_UART_PARITY_ERR | \ 63 57 AML_UART_FRAME_ERR | \ 64 58 AML_UART_TX_FIFO_WERR) 65 - 66 - /* AML_UART_CONTROL bits */ 67 - #define AML_UART_TWO_WIRE_EN BIT(15) 68 - #define AML_UART_PARITY_TYPE BIT(18) 69 - #define AML_UART_PARITY_EN BIT(19) 70 - #define AML_UART_CLEAR_ERR BIT(24) 71 - #define AML_UART_STOP_BIN_LEN_MASK (0x03 << 16) 72 - #define AML_UART_STOP_BIN_1SB (0x00 << 16) 73 - #define AML_UART_STOP_BIN_2SB (0x01 << 16) 74 59 75 60 /* AML_UART_MISC bits */ 76 61 #define AML_UART_XMIT_IRQ(c) (((c) & 0xff) << 8) ··· 260 263 u32 val; 261 264 262 265 val = readl(port->membase + AML_UART_CONTROL); 263 - val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR); 266 + val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR); 264 267 writel(val, port->membase + AML_UART_CONTROL); 265 268 266 - val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR); 269 + val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR); 267 270 writel(val, port->membase + AML_UART_CONTROL); 268 271 } 269 272 ··· 273 276 int ret = 0; 274 277 275 278 val = readl(port->membase + AML_UART_CONTROL); 276 - val |= AML_UART_CLR_ERR; 279 + val |= AML_UART_CLEAR_ERR; 277 280 writel(val, port->membase + AML_UART_CONTROL); 278 - val &= ~AML_UART_CLR_ERR; 281 + val &= ~AML_UART_CLEAR_ERR; 279 282 writel(val, port->membase + AML_UART_CONTROL); 280 283 281 284 val |= (AML_UART_RX_EN | AML_UART_TX_EN); ··· 351 354 else 352 355 val &= ~AML_UART_PARITY_TYPE; 353 356 354 - val &= ~AML_UART_STOP_BIN_LEN_MASK; 357 + val &= ~AML_UART_STOP_BIT_LEN_MASK; 355 358 if (cflags & CSTOPB) 356 - val |= AML_UART_STOP_BIN_2SB; 359 + val |= AML_UART_STOP_BIT_2SB; 357 360 else 358 - val |= AML_UART_STOP_BIN_1SB; 361 + val |= AML_UART_STOP_BIT_1SB; 359 362 360 363 if (cflags & CRTSCTS) 361 364 val &= ~AML_UART_TWO_WIRE_EN;
+7 -4
drivers/tty/serial/mxs-auart.c
··· 40 40 41 41 #include <asm/cacheflush.h> 42 42 43 - #include <linux/gpio.h> 44 43 #include <linux/gpio/consumer.h> 45 44 #include <linux/err.h> 46 45 #include <linux/irq.h> ··· 1596 1597 1597 1598 for (i = 0; i < UART_GPIO_MAX; i++) { 1598 1599 gpiod = mctrl_gpio_to_gpiod(s->gpios, i); 1599 - if (gpiod && (gpiod_get_direction(gpiod) == GPIOF_DIR_IN)) 1600 + if (gpiod && (gpiod_get_direction(gpiod) == 1)) 1600 1601 s->gpio_irq[i] = gpiod_to_irq(gpiod); 1601 1602 else 1602 1603 s->gpio_irq[i] = -EINVAL; ··· 1720 1721 1721 1722 ret = uart_add_one_port(&auart_driver, &s->port); 1722 1723 if (ret) 1723 - goto out_free_gpio_irq; 1724 + goto out_disable_clks_free_qpio_irq; 1724 1725 1725 1726 /* ASM9260 don't have version reg */ 1726 1727 if (is_asm9260_auart(s)) { ··· 1734 1735 1735 1736 return 0; 1736 1737 1737 - out_free_gpio_irq: 1738 + out_disable_clks_free_qpio_irq: 1739 + if (s->clk) 1740 + clk_disable_unprepare(s->clk_ahb); 1741 + if (s->clk_ahb) 1742 + clk_disable_unprepare(s->clk_ahb); 1738 1743 mxs_auart_free_gpio_irq(s); 1739 1744 auart_port[pdev->id] = NULL; 1740 1745 return ret;
+10 -8
drivers/tty/serial/omap-serial.c
··· 1602 1602 struct device_node *np) 1603 1603 { 1604 1604 struct serial_rs485 *rs485conf = &up->port.rs485; 1605 - enum of_gpio_flags flags; 1606 1605 int ret; 1607 1606 1608 1607 rs485conf->flags = 0; ··· 1610 1611 if (!np) 1611 1612 return 0; 1612 1613 1613 - if (of_property_read_bool(np, "rs485-rts-active-high")) 1614 + uart_get_rs485_mode(up->dev, rs485conf); 1615 + 1616 + if (of_property_read_bool(np, "rs485-rts-active-high")) { 1614 1617 rs485conf->flags |= SER_RS485_RTS_ON_SEND; 1615 - else 1618 + rs485conf->flags &= ~SER_RS485_RTS_AFTER_SEND; 1619 + } else { 1620 + rs485conf->flags &= ~SER_RS485_RTS_ON_SEND; 1616 1621 rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; 1622 + } 1617 1623 1618 1624 /* check for tx enable gpio */ 1619 - up->rts_gpio = of_get_named_gpio_flags(np, "rts-gpio", 0, &flags); 1625 + up->rts_gpio = of_get_named_gpio(np, "rts-gpio", 0); 1620 1626 if (gpio_is_valid(up->rts_gpio)) { 1621 1627 ret = devm_gpio_request(up->dev, up->rts_gpio, "omap-serial"); 1622 1628 if (ret < 0) 1623 1629 return ret; 1624 - ret = gpio_direction_output(up->rts_gpio, 1625 - flags & SER_RS485_RTS_AFTER_SEND); 1630 + ret = rs485conf->flags & SER_RS485_RTS_AFTER_SEND ? 1 : 0; 1631 + ret = gpio_direction_output(up->rts_gpio, ret); 1626 1632 if (ret < 0) 1627 1633 return ret; 1628 1634 } else if (up->rts_gpio == -EPROBE_DEFER) { ··· 1635 1631 } else { 1636 1632 up->rts_gpio = -EINVAL; 1637 1633 } 1638 - 1639 - of_get_rs485_mode(np, rs485conf); 1640 1634 1641 1635 return 0; 1642 1636 }
+23 -12
drivers/tty/serial/serial_core.c
··· 974 974 } 975 975 } else { 976 976 retval = uart_startup(tty, state, 1); 977 + if (retval == 0) 978 + tty_port_set_initialized(port, true); 977 979 if (retval > 0) 978 980 retval = 0; 979 981 } ··· 1957 1955 * eg: 115200n8r 1958 1956 */ 1959 1957 void 1960 - uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow) 1958 + uart_parse_options(const char *options, int *baud, int *parity, 1959 + int *bits, int *flow) 1961 1960 { 1962 - char *s = options; 1961 + const char *s = options; 1963 1962 1964 1963 *baud = simple_strtoul(s, NULL, 10); 1965 1964 while (*s >= '0' && *s <= '9') ··· 3016 3013 EXPORT_SYMBOL(uart_remove_one_port); 3017 3014 3018 3015 /** 3019 - * of_get_rs485_mode() - Implement parsing rs485 properties 3020 - * @np: uart node 3016 + * uart_get_rs485_mode() - retrieve rs485 properties for given uart 3017 + * @dev: uart device 3021 3018 * @rs485conf: output parameter 3022 3019 * 3023 3020 * This function implements the device tree binding described in 3024 3021 * Documentation/devicetree/bindings/serial/rs485.txt. 3025 3022 */ 3026 - void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf) 3023 + void uart_get_rs485_mode(struct device *dev, struct serial_rs485 *rs485conf) 3027 3024 { 3028 3025 u32 rs485_delay[2]; 3029 3026 int ret; 3030 3027 3031 - ret = of_property_read_u32_array(np, "rs485-rts-delay", rs485_delay, 2); 3028 + ret = device_property_read_u32_array(dev, "rs485-rts-delay", 3029 + rs485_delay, 2); 3032 3030 if (!ret) { 3033 3031 rs485conf->delay_rts_before_send = rs485_delay[0]; 3034 3032 rs485conf->delay_rts_after_send = rs485_delay[1]; ··· 3039 3035 } 3040 3036 3041 3037 /* 3042 - * clear full-duplex and enabled flags to get to a defined state with 3043 - * the two following properties. 3038 + * Clear full-duplex and enabled flags, set RTS polarity to active high 3039 + * to get to a defined state with the following properties: 3044 3040 */ 3045 - rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED); 3041 + rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED | 3042 + SER_RS485_RTS_AFTER_SEND); 3043 + rs485conf->flags |= SER_RS485_RTS_ON_SEND; 3046 3044 3047 - if (of_property_read_bool(np, "rs485-rx-during-tx")) 3045 + if (device_property_read_bool(dev, "rs485-rx-during-tx")) 3048 3046 rs485conf->flags |= SER_RS485_RX_DURING_TX; 3049 3047 3050 - if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) 3048 + if (device_property_read_bool(dev, "linux,rs485-enabled-at-boot-time")) 3051 3049 rs485conf->flags |= SER_RS485_ENABLED; 3050 + 3051 + if (device_property_read_bool(dev, "rs485-rts-active-low")) { 3052 + rs485conf->flags &= ~SER_RS485_RTS_ON_SEND; 3053 + rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; 3054 + } 3052 3055 } 3053 - EXPORT_SYMBOL_GPL(of_get_rs485_mode); 3056 + EXPORT_SYMBOL_GPL(uart_get_rs485_mode); 3054 3057 3055 3058 MODULE_DESCRIPTION("Serial driver core"); 3056 3059 MODULE_LICENSE("GPL");
+1 -1
drivers/tty/serial/stm32-usart.h
··· 236 236 #define USART_ICR_CMCF BIT(17) /* F7 */ 237 237 #define USART_ICR_WUCF BIT(20) /* H7 */ 238 238 239 - #define STM32_SERIAL_NAME "ttyS" 239 + #define STM32_SERIAL_NAME "ttySTM" 240 240 #define STM32_MAX_PORTS 8 241 241 242 242 #define RX_BUF_L 200 /* dma rx buffer length */
+9 -1
drivers/tty/tty_io.c
··· 1323 1323 "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", 1324 1324 __func__, tty->driver->name); 1325 1325 1326 + retval = tty_ldisc_lock(tty, 5 * HZ); 1327 + if (retval) 1328 + goto err_release_lock; 1326 1329 tty->port->itty = tty; 1327 1330 1328 1331 /* ··· 1336 1333 retval = tty_ldisc_setup(tty, tty->link); 1337 1334 if (retval) 1338 1335 goto err_release_tty; 1336 + tty_ldisc_unlock(tty); 1339 1337 /* Return the tty locked so that it cannot vanish under the caller */ 1340 1338 return tty; 1341 1339 ··· 1349 1345 1350 1346 /* call the tty release_tty routine to clean out this slot */ 1351 1347 err_release_tty: 1352 - tty_unlock(tty); 1348 + tty_ldisc_unlock(tty); 1353 1349 tty_info_ratelimited(tty, "ldisc open failed (%d), clearing slot %d\n", 1354 1350 retval, idx); 1351 + err_release_lock: 1352 + tty_unlock(tty); 1355 1353 release_tty(tty, idx); 1356 1354 return ERR_PTR(retval); 1357 1355 } ··· 1482 1476 if (tty->link) 1483 1477 tty->link->port->itty = NULL; 1484 1478 tty_buffer_cancel_work(tty->port); 1479 + if (tty->link) 1480 + tty_buffer_cancel_work(tty->link->port); 1485 1481 1486 1482 tty_kref_put(tty->link); 1487 1483 tty_kref_put(tty);
+2 -2
drivers/tty/tty_ldisc.c
··· 337 337 ldsem_up_write(&tty->ldisc_sem); 338 338 } 339 339 340 - static int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) 340 + int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) 341 341 { 342 342 int ret; 343 343 ··· 348 348 return 0; 349 349 } 350 350 351 - static void tty_ldisc_unlock(struct tty_struct *tty) 351 + void tty_ldisc_unlock(struct tty_struct *tty) 352 352 { 353 353 clear_bit(TTY_LDISC_HALTED, &tty->flags); 354 354 __tty_ldisc_unlock(tty);
+1 -5
drivers/tty/vt/selection.c
··· 186 186 } 187 187 188 188 if (ps > pe) /* make sel_start <= sel_end */ 189 - { 190 - int tmp = ps; 191 - ps = pe; 192 - pe = tmp; 193 - } 189 + swap(ps, pe); 194 190 195 191 if (sel_cons != vc_cons[fg_console].d) { 196 192 clear_selection();
+4 -2
include/linux/serdev.h
··· 27 27 28 28 /** 29 29 * struct serdev_device_ops - Callback operations for a serdev device 30 - * @receive_buf: Function called with data received from device. 31 - * @write_wakeup: Function called when ready to transmit more data. 30 + * @receive_buf: Function called with data received from device; 31 + * returns number of bytes accepted; may sleep. 32 + * @write_wakeup: Function called when ready to transmit more data; must 33 + * not sleep. 32 34 */ 33 35 struct serdev_device_ops { 34 36 int (*receive_buf)(struct serdev_device *, const unsigned char *, size_t);
+2 -6
include/linux/serial_core.h
··· 387 387 struct console *c); 388 388 int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr, 389 389 char **options); 390 - void uart_parse_options(char *options, int *baud, int *parity, int *bits, 390 + void uart_parse_options(const char *options, int *baud, int *parity, int *bits, 391 391 int *flow); 392 392 int uart_set_options(struct uart_port *port, struct console *co, int baud, 393 393 int parity, int bits, int flow); ··· 501 501 (cflag) & CRTSCTS || \ 502 502 !((cflag) & CLOCAL)) 503 503 504 - /* 505 - * Common device tree parsing helpers 506 - */ 507 - void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf); 508 - 504 + void uart_get_rs485_mode(struct device *dev, struct serial_rs485 *rs485conf); 509 505 #endif /* LINUX_SERIAL_CORE_H */
+2
include/linux/tty.h
··· 405 405 extern struct tty_struct *tty_kopen(dev_t device); 406 406 extern void tty_kclose(struct tty_struct *tty); 407 407 extern int tty_dev_name_to_number(const char *name, dev_t *number); 408 + extern int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout); 409 + extern void tty_ldisc_unlock(struct tty_struct *tty); 408 410 #else 409 411 static inline void tty_kref_put(struct tty_struct *tty) 410 412 { }