summaryrefslogtreecommitdiff
path: root/drivers/tty
AgeCommit message (Collapse)Author
2020-03-14tty: serial: qcom_geni_serial: No need to stop tx/rx on UART shutdownDouglas Anderson
On a board using qcom_geni_serial I found that I could no longer interact with kdb if I got a crash after the "agetty" running on the same serial port was killed. This meant that various classes of crashes that happened at reboot time were undebuggable. Reading through the code, I couldn't figure out why qcom_geni_serial felt the need to run so much code at port shutdown time. All we need to do is disable the interrupt. After I make this change then a hardcoded kgdb_breakpoint in some late shutdown code now allows me to interact with the debugger. I also could freely close / re-open the port without problems. Fixes: c4f528795d1a ("tty: serial: msm_geni_serial: Add serial driver support for GENI based QUP") Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20200313134635.1.Icf54c533065306b02b880c46dfd401d8db34e213@changeid Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12vt: vt_ioctl: remove unnecessary console allocation checksEric Biggers
The vc_cons_allocated() checks in vt_ioctl() and vt_compat_ioctl() are unnecessary because they can only be reached by calling ioctl() on an open tty, which implies the corresponding virtual console is allocated. And even if the virtual console *could* be freed concurrently, then these checks would be broken since they aren't done under console_lock, and the vc_data is dereferenced before them anyway. So, remove these unneeded checks to avoid confusion. Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20200224080326.295046-1-ebiggers@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12vt: drop redundant might_sleep() in do_con_write()Eric Biggers
The might_sleep() in do_con_write() is redundant because console_lock() already contains might_sleep(). Remove it. Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20200224073450.292892-1-ebiggers@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: reorganize tty & serial menusRandy Dunlap
Move LDISC_AUTOLOAD ahead of the Serial drivers menu. Move the Serial drivers menu ahead of the Non-standard serial port support menu. Move NOZOMI out of the SERIAL_NONSTANDARD area since it does not depend on SERIAL_NONSTANDARD and it breaks the SERIAL_NONSTANDARD menu list. Alphabetize the remaining drivers (in tty/Kconfig) by their prompt strings. [The drivers in tty/hvc/Kconfig and tty/serial/Kconfig have not been alphabetized.] Cc: Jiri Slaby <jslaby@suse.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/r/20200311225736.32147-4-rdunlap@infradead.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: source all tty Kconfig files in one placeRandy Dunlap
'source' (include) all of the tty/*/Kconfig files from drivers/tty/Kconfig instead of from drivers/char/Kconfig. This consolidates them both in source code and in menu presentation to the user. Move hvc/Kconfig and serial/Kconfig 'source' lines into the if TTY/endif block and remove the if TTY/endif blocks from those 2 files. Cc: linux-serial@vger.kernel.org Cc: Jiri Slaby <jslaby@suse.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Suggested-by: Jiri Slaby <jslaby@suse.com> Suggested-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/r/20200311225736.32147-3-rdunlap@infradead.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12serial: core: Refactor uart_unlock_and_check_sysrq()Andy Shevchenko
Refactor uart_unlock_and_check_sysrq() to: - explicitly show that we release a port lock which makes static analyzers happy: CHECK drivers/tty/serial/serial_core.c .../serial_core.c:3290:17: warning: context imbalance in 'uart_unlock_and_check_sysrq' - unexpected unlock - use flags instead of irqflags to avoid confusion with IRQ flags - provide one return point - be more compact Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Link: https://lore.kernel.org/r/20200310174337.74109-4-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12serial: core: Use uart_console() helper in SysRq codeAndy Shevchenko
Use uart_console() helper in SysRq code instead of open coded variant. This eliminates the conditional entirely for SERIAL_CORE_CONSOLE=n case. While here, refactor the conditional to be more compact. Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200310174337.74109-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12serial: core: Print escaped SysRq Magic sequence if enabledAndy Shevchenko
It is useful to see on the serial console the magic sequence itself to enable SysRq without rummaging source code. Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200310174337.74109-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12serial: core: Use string length for SysRq magic sequenceAndy Shevchenko
Compiler is not happy about using ARRAY_SIZE() in comparison to smaller type: CC drivers/tty/serial/serial_core.o .../serial_core.c: In function ‘uart_try_toggle_sysrq’: .../serial_core.c:3222:24: warning: comparison is always false due to limited range of data type [-Wtype-limits] 3222 | if (++port->sysrq_seq < (ARRAY_SIZE(sysrq_toggle_seq) - 1)) { | ^ Looking at the code it appears that there is an additional weirdness, i.e. use ARRAY_SIZE() against simple string literal. Yes, the idea probably was to allow '\0' in the sequence, but it's impractical: kernel configuration won't accept it to begin with followed by a comment about '\0' before comparison in question. Drop all these by switching to strlen() and convert code accordingly. Note, GCC seems clever enough to calculate string length at compile time. Fixes: 68af43173d3f ("serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE") Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200310174337.74109-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: qcom_geni_serial: Allocate port->rx_fifo buffer in probesatya priya
To fix the RX cancel command failure, rx_fifo buffer needs to be flushed in stop_rx() by calling handle_rx().In handle_rx() the data in rx_fifo buffer is read and then dropped, not sent to upper layers. If set_termios is called before startup, by this time memory is not allocated to port->rx_fifo buffer, which leads to a NULL pointer dereference. To avoid this NULL pointer dereference allocate memory to port->rx_fifo in probe itself. Signed-off-by: satya priya <skakit@codeaurora.org> Reported-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/1583477228-32231-2-git-send-email-skakit@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: ifx6x60: Convert to GPIO descriptorsLinus Walleij
This driver for the Intel MID never seems to have been properly integrated upstream: the platform data in <linux/spi/ifx_modem.h> is not used anywhere in the kernel and haven't been since it was merged into the kernel in 2010. There might be out-of-tree users, so I don't want to delete the driver, but I will refactor it to use GPIO descriptors, which means that out-of-tree users will need to adapt. There are several examples in the kernel of how to provide the resources necessary for using GPIO descriptors to pass in the GPIO lines, for the MID platform in particular, it will suffice to inspect the code in files like: arch/x86/platform/intel-mid/device_libs/platform_bt.c This refactoring transfers all GPIOs in the driver, including a hard-coded "PMU reset" in the driver to use GPIO descriptors instead. The following named GPIO descriptors need to be supplied: - reset - power - mrdy - srdy - rst_out - pmu_reset Cc: Russ Gorby <russ.gorby@intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200311083131.693908-2-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: ifx6x60: Use helper variable for devLinus Walleij
The &spi->dev is used so many times that the code gets visibly better by introducing a simple dev helper variable. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20200311083131.693908-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: fsl_lpuart: add LS1028A earlycon supportMichael Walle
Add a early_console_setup() for the LS1028A SoC with 32bit, little endian access. If the bootloader does a fixup of the clock-frequency node the baudrate divisor register will automatically be set. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200306214433.23215-5-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: fsl_lpuart: add LS1028A supportMichael Walle
The LS1028A uses little endian register access and has a different FIFO size encoding. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200306214433.23215-4-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: fsl_lpuart: fix DMA mappingMichael Walle
Use the correct device to request the DMA mapping. Otherwise the IOMMU doesn't get the mapping and it will generate a page fault. The error messages look like: [ 19.012140] arm-smmu 5000000.iommu: Unhandled context fault: fsr=0x402, iova=0xbbfff800, fsynr=0x3e0021, cbfrsynra=0x828, cb=9 [ 19.023593] arm-smmu 5000000.iommu: Unhandled context fault: fsr=0x402, iova=0xbbfff800, fsynr=0x3e0021, cbfrsynra=0x828, cb=9 This was tested on a custom board with a LS1028A SoC. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200306214433.23215-3-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: serial: fsl_lpuart: fix DMA operation when using IOMMUMichael Walle
The DMA channel might not be available at probe time. This is esp. the case if the DMA controller has an IOMMU mapping. There is also another caveat. If there is no DMA controller at all, dma_request_chan() will also return -EPROBE_DEFER. Thus we cannot test for -EPROBE_DEFER in probe(). Otherwise the lpuart driver will fail to probe if, for example, the DMA driver is not enabled in the kernel configuration. To workaround this, we request the DMA channel in _startup(). Other serial drivers do it the same way. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200306214433.23215-2-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty/serial: atmel: Use uart_console() helperAndy Shevchenko
Use uart_console() helper in instead of open coded variant. Note, SERIAL_CORE_CONSOLE is selected by SERIAL_ATMEL_CONSOLE, thus no functional changes expected. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Richard Genoud <richard.genoud@gmail.com> Link: https://lore.kernel.org/r/20200310133057.86840-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12serial: pic32_uart: Use uart_console() helperAndy Shevchenko
Use uart_console() helper in instead of open coded variant. Note, SERIAL_CORE_CONSOLE is selected by SERIAL_PIC32_CONSOLE, thus no functional changes expected. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200311090027.64441-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12tty: sifive: Finish transmission before changing the clockPalmer Dabbelt
SiFive's UART has a software controller clock divider that produces the final baud rate clock. Whenever the clock that drives the UART is changed this divider must be updated accordingly, and given that these two events are controlled by software they cannot be done atomically. During the period between updating the UART's driving clock and internal divider the UART will transmit a different baud rate than what the user has configured, which will probably result in a corrupted transmission stream. The SiFive UART has a FIFO, but due to an issue with the programming interface there is no way to directly determine when the UART has finished transmitting. We're essentially restricted to dead reckoning in order to figure that out: we can use the FIFO's TX busy register to figure out when the last frame has begun transmission and just delay for a long enough that the last frame is guaranteed to get out. As far as the actual implementation goes: I've modified the existing existing clock notifier function to drain both the FIFO and the shift register in on PRE_RATE_CHANGE. As far as I know there is no hardware flow control in this UART, so there's no good way to ask the other end to stop transmission while we can't receive (inserting software flow control messages seems like a bad idea here). Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com> Tested-by: Yash Shah <yash.shah@sifive.com> Link: https://lore.kernel.org/r/20200307042637.83728-1-palmer@dabbelt.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-10Merge 5.6-rc5 into tty-nextGreg Kroah-Hartman
We need the vt fixes in here and it resolves a merge issue with drivers/tty/vt/selection.c Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07tty: mips_ejtag_fdc: Mark expected switch fall-throughSerge Semin
Mark mips_ejtag_fdc_encode() methods switch-case-4 as expecting to fall through. This patch fixes the following warning: drivers/tty/mips_ejtag_fdc.c: In function ‘mips_ejtag_fdc_encode’: drivers/tty/mips_ejtag_fdc.c:245:13: warning: this statement may fall through [-Wimplicit-fallthrough=] word.word &= 0x00ffffff; ~~~~~~~~~~^~~~~~~~~~~~~ drivers/tty/mips_ejtag_fdc.c:246:2: note: here case 3: ^~~~ Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Paul Burton <paulburton@kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Link: https://lore.kernel.org/r/20200306124913.151A68030792@mail.baikalelectronics.ru Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCEDmitry Safonov
Many embedded boards have a disconnected TTL level serial which can generate some garbage that can lead to spurious false sysrq detects. Currently, sysrq can be either completely disabled for serial console or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port") At Arista, we have such boards that can generate BREAK and random garbage. While disabling sysrq for serial console would solve the problem with spurious false sysrq triggers, it's also desirable to have a way to enable sysrq back. As a measure of balance between on and off options, add MAGIC_SYSRQ_SERIAL_SEQUENCE which is a string sequence that can enable sysrq if it follows BREAK on a serial line. The longer the string - the less likely it may be in the garbage. Having the way to enable sysrq was beneficial to debug lockups with a manual investigation in field and on the other side preventing false sysrq detections. Based-on-patch-by: Vasiliy Khoruzhick <vasilykh@arista.com> Signed-off-by: Dmitry Safonov <dima@arista.com> Link: https://lore.kernel.org/r/20200302175135.269397-3-dima@arista.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07sysctl/sysrq: Remove __sysrq_enabled copyDmitry Safonov
Many embedded boards have a disconnected TTL level serial which can generate some garbage that can lead to spurious false sysrq detects. Currently, sysrq can be either completely disabled for serial console or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port") At Arista, we have such boards that can generate BREAK and random garbage. While disabling sysrq for serial console would solve the problem with spurious false sysrq triggers, it's also desirable to have a way to enable sysrq back. Having the way to enable sysrq was beneficial to debug lockups with a manual investigation in field and on the other side preventing false sysrq detections. As a preparation to add sysrq_toggle_support() call into uart, remove a private copy of sysrq_enabled from sysctl - it should reflect the actual status of sysrq. Furthermore, the private copy isn't correct already in case sysrq_always_enabled is true. So, remove __sysrq_enabled and use a getter-helper sysrq_mask() to check sysrq_key_op enabled status. Cc: Iurii Zaikin <yzaikin@google.com> Cc: Jiri Slaby <jslaby@suse.com> Cc: Luis Chamberlain <mcgrof@kernel.org> Cc: Kees Cook <keescook@chromium.org> Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Dmitry Safonov <dima@arista.com> Link: https://lore.kernel.org/r/20200302175135.269397-2-dima@arista.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Support console on software emulated rs485 portsLukas Wunner
Commit e490c9144cfa ("tty: Add software emulated RS485 support for 8250") introduced support to use RTS as an rs485 Transmit Enable signal if data is transmitted through the tty layer. Console messages bypass the tty layer and instead are emitted via serial8250_console_write(). Amend that function to drive RTS as well, allowing for a console on rs485 ports. Note that serial8250_console_write() may be called concurrently to the tty layer accessing the port. The two protect their accesses with the port lock, but serial8250_console_write() may find RTS still being asserted by the tty layer, in which case it shouldn't be deasserted after the console message has been printed. Recognize such situations by checking the em485->tx_stopped flag. If a delay_rts_before_send or delay_rts_after_send has been specified, serial8250_console_write() busy-waits for its duration. Optimizations for those wait times are conceivable: E.g. if RTS is already asserted, we could check whether em485->start_tx_timer is active and wait only for the remaining expire time. But this would require calling into the hrtimer infrastructure, which involves acquiring locks and potentially reprogramming timer hardware. Such operations seem too risky in the context of console printout, which needs to work even when the kernel has crashed and emits a BUG splat. So I've gone with a simplistic solution which just always waits for the full delay. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Link: https://lore.kernel.org/r/65edffce4670a19e598015c03cbe46f1ffd93e43.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250_bcm2835aux: Support rs485 software emulationLukas Wunner
Amend 8250_bcm2835aux.c to support rs485 as introduced for 8250_omap.c by commit e490c9144cfa ("tty: Add software emulated RS485 support for 8250"). The bcm2835aux differs from omap chips by inverting the meaning of RTS in the MCR register: If the bit is clear, RTS is high. With omap, it's apparently the other way round. Moreover, omap achieves half-duplex mode by disabling the UART_IER_RDI interrupt and clearing the RX FIFO when TX stops. This approach doesn't work on bcm2835aux because the UART_LSR_DR bit is set even when UART_IER_RDI is disabled. Consequently, serial8250_handle_irq() invokes serial8250_rx_chars() to empty the FIFO and characters are received even though the user requested half-duplex. Solve by disabling the receiver using the non-standard CNTL register. Cache that register in the driver's private data for performance. Set the private data pointer before calling serial8250_register_8250_port() to prevent a null pointer deref in case one of the rs485 callbacks is invoked immediately after port registration. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Link: https://lore.kernel.org/r/dd86460e20a8f979b7272a0bde73640312b902b1.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Generalize rs485 software emulationLukas Wunner
Commit e490c9144cfa ("tty: Add software emulated RS485 support for 8250") introduced support to use RTS as an rs485 Transmit Enable signal. So far the only drivers taking advantage of it are 8250_omap.c and 8250_of.c. We're about to make use of the feature in 8250_bcm2835aux.c as well. The bcm2835aux differs from omap chips by inverting the meaning of RTS in the MCR register. Moreover, omap achieves half-duplex mode by disabling the RX interrupt and clearing the RX FIFO when TX stops. The bcm2835aux requires disabling the receiver instead. Support these behavioral differences by generalizing the rs485 emulation: Introduce ->rs485_start_tx() and ->rs485_stop_tx() callbacks in struct uart_8250_port, provide generic implementations containing the existing code and use them as callbacks in 8250_omap.c and 8250_of.c. start_tx_rs485() is idempotent in that it recognizes whether RTS is already asserted. Achieve the same by introducing a tx_stopped flag in struct uart_8250_em485. This may even perform a little better on arches where memory access is faster than mmio access. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Link: https://lore.kernel.org/r/5ac0464ae4414708e723a1e0d52b0c1b2bd41b9b.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Deduplicate rs485 active_timer assignmentLukas Wunner
When rs485 transmission over an 8250 port stops, __stop_tx() assigns active_timer = NULL before calling __stop_tx_rs485(). That function in turn either assigns active_timer = stop_tx_timer and rearms the timer (in case a delay_rts_after_send needs to be observed) or directly calls __do_stop_tx_rs485(). Move the assignment active_timer = NULL to __stop_tx_rs485() into the branch which directly calls __do_stop_tx_rs485(), thereby avoiding a duplicate assignment and simplifying the code. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Link: https://lore.kernel.org/r/bca638405550eaf92f0c6060b553b687f35885e0.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Sanitize rs485 config harderLukas Wunner
Amend the generic ->rs485_config() callback to sanitize RTS polarity and zero-fill the padding (in addition to the existing sanitization of the RTS delays). Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Link: https://lore.kernel.org/r/ff833721bc372d38678f289eb2a44dbf016d5203.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Deduplicate ->rs485_config() callbackLukas Wunner
Commit e490c9144cfa ("tty: Add software emulated RS485 support for 8250") introduced support to use RTS as an rs485 Transmit Enable signal. Drivers opt in to the feature by calling serial8250_em485_init() from their ->rs485_config() callback. So far there are two drivers doing that, 8250_omap.c and 8250_of.c. Both use an identical callback. We're about to add a third user of that callback, therefore deduplicate it and move it to 8250_port.c. Drivers now opt in to rs485 software emulation by assigning the generic serial8250_rs485_config() callback introduced herein to their .rs485_config struct member. This change allows unexporting serial8250_em485_init() and declaring it static. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Cc: Heiko Schocher <hs@denx.de> Link: https://lore.kernel.org/r/fcef63642dc4eae41ae7842d23747b2bf5d40285.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Support rs485 devicetree propertiesLukas Wunner
Retrieve rs485 devicetree properties on registration of 8250 ports in case they are attached to an rs485 transceiver. If the property "linux,rs485-enabled-at-boot-time" is present, invoke the ->rs485_config() callback to immediately deassert RTS, thereby ceasing control of the bus. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Giulio Benetti <giulio.benetti@micronovasrl.com> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/5908ea89b7f9da54872d6634b606d83db032297a.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: 8250: Don't touch RTS modem control while in rs485 modeLukas Wunner
serial8250_do_set_mctrl() currently allows modifying the RTS modem control line even when RTS is used as an rs485 Transmit Enable signal. It is thus possible for user space to interfere with rs485 communication by invoking a TIOCMSET ioctl(). Ignore such change requests and retain the current RTS polarity when in rs485 mode. Note that serial8250_set_mctrl() is always called with port->lock held, so there's no risk that RTS is changed concurrently. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Matwey V. Kornilov <matwey@sai.msu.ru> Link: https://lore.kernel.org/r/b1ce34ca9bc4d7bdc6e9852fcf30b1f4e37c8a80.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07serial: earlycon: prefer EARLYCON_DECLARE() variantMichael Walle
If a driver exposes early consoles with EARLYCON_DECLARE() and OF_EARLYCON_DECLARE(), pefer the non-OF variant if the user specifies it by earlycon=<driver>,<options> The rationale behind this is that some drivers register multiple setup functions under the same driver name. Eg. OF_EARLYCON_DECLARE(lpuart, "fsl,vf610-lpuart", lpuart_early_console_setup); OF_EARLYCON_DECLARE(lpuart32, "fsl,ls1021a-lpuart", lpuart32_early_console_setup); OF_EARLYCON_DECLARE(lpuart32, "fsl,imx7ulp-lpuart", lpuart32_imx_early_console_setup); EARLYCON_DECLARE(lpuart, lpuart_early_console_setup); EARLYCON_DECLARE(lpuart32, lpuart32_early_console_setup); It depends on the order of the entries which console_setup() actually gets called. To make things worse, I guess it also depends on the compiler how these are ordered. Thus always prefer the EARLYCON_DECLARE() ones. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200220174607.24285-1-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07tty: serial: Use the correct style for SPDX License IdentifierNishad Kamdar
This patch corrects the SPDX License Identifier style in header files related to tty serial drivers. For C header files Documentation/process/license-rules.rst mandates C-like comments (opposed to C source files where C++ style should be used). Changes made by using a script provided by Joe Perches here: https://lkml.org/lkml/2019/2/7/46. Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com> Link: https://lore.kernel.org/r/20200301204517.GA10368@nishad Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: serial: fsl_lpuart: free IDs allocated by IDAMichael Walle
Since commit 3bc3206e1c0f ("serial: fsl_lpuart: Remove the alias node dependence") the port line number can also be allocated by IDA, but in case of an error the ID will no be removed again. More importantly, any ID will be freed in remove(), even if it wasn't allocated but instead fetched by of_alias_get_id(). If it was not allocated by IDA there will be a warning: WARN(1, "ida_free called for id=%d which is not allocated.\n", id); Move the ID allocation more to the end of the probe() so that we still can use plain return in the first error cases. Fixes: 3bc3206e1c0f ("serial: fsl_lpuart: Remove the alias node dependence") Signed-off-by: Michael Walle <michael@walle.cc> Cc: stable <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20200303174306.6015-3-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06Revert "tty: serial: fsl_lpuart: drop EARLYCON_DECLARE"Michael Walle
This reverts commit a659652f6169240a5818cb244b280c5a362ef5a4. This broke the earlycon on LS1021A processors because the order of the earlycon_setup() functions were changed. Before the commit the normal lpuart32_early_console_setup() was called. After the commit the lpuart32_imx_early_console_setup() is called instead. Fixes: a659652f6169 ("tty: serial: fsl_lpuart: drop EARLYCON_DECLARE") Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200303174306.6015-2-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06serdev: Fix detection of UART devices on Apple machines.Ronald Tschalär
On Apple devices the _CRS method returns an empty resource template, and the resource settings are instead provided by the _DSM method. But commit 33364d63c75d6182fa369cea80315cf1bb0ee38e (serdev: Add ACPI devices by ResourceSource field) changed the search for serdev devices to require valid, non-empty resource template, thereby breaking Apple devices and causing bluetooth devices to not be found. This expands the check so that if we don't find a valid template, and we're on an Apple machine, then just check for the device being an immediate child of the controller and having a "baud" property. Cc: <stable@vger.kernel.org> # 5.5 Fixes: 33364d63c75d ("serdev: Add ACPI devices by ResourceSource field") Signed-off-by: Ronald Tschalär <ronald@innovation.ch> Link: https://lore.kernel.org/r/20200211194723.486217-1-ronald@innovation.ch Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: serial: make SERIAL_SPRD not depend on ARCH_SPRDChunyan Zhang
Remove the dependency with ARCH_SPRD from sprd serial/console Kconfig-s, since we want them can be built-in when ARCH_SPRD is set as 'm'. Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com> Link: https://lore.kernel.org/r/20200305103228.9686-2-zhang.lyra@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06serial: 8250_lpss: Add ->setup() for Elkhart Lake portsAndy Shevchenko
The ->setup() callback is mandatory for the devices. Provide it for Elkhart Lake UART ports. Note, for time being it's empty, but in the future it might require an additional configuration such as DMA. Reported-by: Raymond Tan <raymond.tan@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200305130822.36850-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06serial: 8250-mtk: modify mtk uart power and clock managementChangqi Hu
MTK uart design no need to control uart clock, so we just control bus clock in runtime function. Add uart clock used count to avoid repeatedly switching the clock. Signed-off-by: Changqi Hu <changqi.hu@mediatek.com> Link: https://lore.kernel.org/r/1582707225-26815-1-git-send-email-changqi.hu@mediatek.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: imx serial: Implement support for reversing TX and RX polarityGeorge Hilliard
The peripheral has support for inverting its input and/or output signals. This is useful if the hardware flips polarity of the peripheral's signal, such as swapped +/- pins on an RS-422 transceiver, or an inverting level shifter. Add support for these control registers via the device tree binding. As part of this change, make the writes of the various registers more uniform by moving the UCR3 block up near the other registers' blocks, since the INVT bit must be set before enabling the peripheral. Signed-off-by: George Hilliard <ghilliard@kopismobile.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20200226222319.18383-3-ghilliard@kopismobile.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06serial: ar933x_uart: add RS485 supportDaniel Golle
Emulate half-duplex operation and use mctrl_gpio to add support for RS485 tranceiver with transmit/receive switch hooked to RTS GPIO line. This is needed to make use of the RS485 port found on Teltonika RUT955. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Link: https://lore.kernel.org/r/20200221212331.GA21467@makrotopia.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: serial: qcom_geni_serial: Fix GPIO swapping with workaroundRoja Rani Yarubandi
Add capability to support RX-TX, CTS-RTS pins swap in HW. Configure UART_IO_MACRO_CTRL register accordingly if RX-TX pair or CTS-RTS pair or both pairs swapped. Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Tested-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Link: https://lore.kernel.org/r/20200304112203.408-1-rojay@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: serial: cpm_uart: Convert to use GPIO descriptorsLinus Walleij
The CPM UART (PowerPC) has an open coded GPIO modem control handling. Since I can't test this I can't just migrate it to the serial mctrl GPIO helper library though I wish I could. I do second best and convert it to GPIO descriptors at least. Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20200229231842.247563-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: serial: lantiq: Drop GPIO includeLinus Walleij
Nothing in this driver uses the symbols from <linux/gpio.h> so drop this include. Cc: Rahul Tanwar <rahul.tanwar@linux.intel.com> Cc: Songjun Wu <songjun.wu@linux.intel.com> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Cc: John Crispin <john@phrozen.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20200229212331.174946-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06tty: serial: atmel_serial: Drop GPIO includesLinus Walleij
Nothing in this driver uses the symbols from these GPIO includes so drop them. These are probably just historical artifacts from befor mctrl_gpio was used. Cc: Ludovic Desroches <ludovic.desroches@microchip.com> Cc: Razvan Stefanescu <razvan.stefanescu@microchip.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com> Link: https://lore.kernel.org/r/20200229220941.205599-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06vt: selection, indent switch-case properlyJiri Slaby
Shift the cases one level left as this is how we are supposed to write the switch-case code according to the CodingStyle. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219073951.16151-9-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06vt: selection, remove redeclaration of poke_blanked_consoleJiri Slaby
It is declared in vt_kern.h, so no need to declare it in selection.c which includes the header. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219073951.16151-8-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06vt: switch vt_dont_switch to boolJiri Slaby
vt_dont_switch is pure boolean, no need for whole char. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219073951.16151-6-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06vt: selection, create struct from console selection globalsJiri Slaby
Move all the selection global variables to a structure vc_selection, instantiated as vc_sel. This helps to group all the variables together and see what should be protected by the embedded lock too. It might be used later also for per-console selection support. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219073951.16151-5-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-06vt: selection, localize use_unicodeJiri Slaby
use_unicode needs not be global. It is used only in set_selection_kernel and sel_pos (a callee). It is also always set there prior calling sel_pos. So make use_unicode local and rename it to plain shorter "unicode". Finally, propagate it to sel_pos via parameter. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219073951.16151-4-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>