summaryrefslogtreecommitdiff
path: root/drivers/tty
AgeCommit message (Collapse)Author
2019-09-04serial: lantiq: Use proper DT compatible stringRahul Tanwar
Use explicit string instead of a macro for devicetree compatible string. This series of patches is to add support for multiple SoCs which reuse the same serial controller IP. The following patches will add another compatible string to support new Lightning Mountain(LGM) SoC. So it makes sense to have the compatible strings explicitly mentioned instead of a fixed macro. Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rahul Tanwar <rahul.tanwar@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Link: https://lore.kernel.org/r/57e2b69e9fbd93328a477b4c7dd2dcc78784ecb1.1565257887.git.rahul.tanwar@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_lpss: Enable HS UART on Elkhart LakeAndy Shevchenko
Intel Elkhart Lake may use High Speed UART from OSE IP block. This is different to what we have in main LPSS, though compatible with older version of it, which is handled by this driver. Enable OSE HS UART on Intel Elkhart Lake by adding PCI IDs. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-9-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_lpss: Get rid of custom LPSS_DEVICE() macroAndy Shevchenko
Since PCI core provides a generic PCI_DEVICE_DATA() macro, replace LPSS_DEVICE() with former one. No functional change intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-8-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_lpss: register DMA IRQ and pool with instance IDAndy Shevchenko
It is really useful not only for debugging to have an DMA IRQ line and pool being mapped to the corresponding IP by using its instance ID. Provide PCI device and function as instance ID for Intel Quark UART DMA. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-7-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_lpss: add fractional divisor supportAndy Shevchenko
For Synopsys DesignWare 8250 uart which version >= 4.00a, there's a valid divisor latch fraction register. Now the preparation is done, it's easy to add the feature support. This patch firstly tries to get the fractional divisor width during probe, then setups specific get_divisor() and set_divisor() hook. Among other changes the FIFO size is now retrieved from the hardware. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-6-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_lpss: switch to use 8250_dwlib libraryAndy Shevchenko
Since we have a common library module for Synopsys DesignWare UART, let us use it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-5-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_dw: switch to use 8250_dwlib libraryAndy Shevchenko
Since we have a common library module for Synopsys DesignWare UART, let us use it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-4-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_dw: split Synopsys DesignWare 8250 common functionsAndy Shevchenko
We would like to use same functions in the couple of drivers for Synopsys DesignWare 8250 UART. Split them from 8250_dw into new brand library module which users will select explicitly. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_dw: use pointer to uart local variableAndy Shevchenko
The use of pointer will simplify enabling runtime PM for the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190806094322.64987-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_dw: Use a unified new dev variable in removeAndy Shevchenko
The commit 2cb78eab2376 ("serial: 8250_dw: Use a unified new dev variable in probe") introduced a local dev variable in ->probe(). Do the same in ->remove() in order to prepare for sequential patches. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Link: https://lore.kernel.org/r/20190806094322.64987-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: lantiq: Add SMP supportRahul Tanwar
The existing driver can only support single core SoC. But new multicore platforms which reuse the same driver/IP need SMP support. This patch adds multicore support in the driver. Signed-off-by: Rahul Tanwar <rahul.tanwar@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Link: https://lore.kernel.org/r/7912786cccad60c72b20ea724af1def505ab22aa.1565160764.git.rahul.tanwar@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Ignore TX/RX interrupts if DMA is enabledAndrey Smirnov
In a mixed DMA/IRQ use-case (e.g.: DMA for TX, IRQ for RX), interrupt handler might try to handle Rx/Tx condition it shouldn't. Change the code to only handle TX/RX event if corresponding path isn't being handled by DMA. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190805185701.22863-7-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Don't enable TIE in .startup() or .resume()Andrey Smirnov
Enabling TIE in .startup() callback causes the driver to start (or at least try) to transmit data before .start_tx() is called. Which, while harmless (since TIE handler will immediately disable it), is a no-op and shouldn't really happen. Drop UARTCR2_TIE from list of bits set in lpuart_startup(). This change will also not enable TIE in .resume(), but it seems that, similart to .startup(), transmit interrupt shouldn't be enabled there either. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190805185701.22863-6-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart*_setup_watermark_enable()Andrey Smirnov
Most users of lpuart*_setup_watermark() enable identical set of flags right after the call, so combine those two action into a subroutine and make use of it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190805185701.22863-5-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart32_configure()Andrey Smirnov
Code doing final steps of TX/RX configuration in lpuart32_startup() and lpuart_resume() is identical, so move it into a standalone subroutine. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190805185701.22863-4-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup()Andrey Smirnov
Code doing initial DMA RX configuration in lpuart_startup() and lpuart32_startup() is exactly the same, so move it into a standalone subroutine. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190805185701.22863-3-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup()Andrey Smirnov
Code configure DMA TX path in lpuart_startup(), lpuart32_startup() and lpuart_resume() is doing exactly the same thing, so move it into a standalone subroutine. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190805185701.22863-2-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: Replace msleep(1) with usleep_range()Andy Shevchenko
As explained in Documentation/timers/timers-howto.rst the small amount of milliseconds sometimes produces much longer delays. Replace msleep(1) with usleep_range(1000, 1100). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190805142535.21948-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: Consolidate callback assignments in default_setup()Andy Shevchenko
For better maintenance consolidate port callbacks in default_setup(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190805142535.21948-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: qcom_geni_serial: use devm_platform_ioremap_resource() to ↵YueHaibing
simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: YueHaibing <yuehaibing@huawei.com> Link: https://lore.kernel.org/r/20190802130817.16220-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250: Don't check for mctrl_gpio_init() returning -ENOSYSFrieder Schrempf
Now that the mctrl_gpio code returns NULL instead of ERR_PTR(-ENOSYS) if CONFIG_GPIOLIB is disabled, we can safely remove this check. Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Acked-by: Uwe Kleine-Knig <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20190802100349.8659-4-frieder.schrempf@kontron.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: sh-sci: Don't check for mctrl_gpio_init() returning -ENOSYSFrieder Schrempf
Now that the mctrl_gpio code returns NULL instead of ERR_PTR(-ENOSYS) if CONFIG_GPIOLIB is disabled, we can safely remove this check. Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Acked-by: Uwe Kleine-Knig <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20190802100349.8659-3-frieder.schrempf@kontron.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: mctrl_gpio: Avoid probe failures in case of missing gpiolibFrieder Schrempf
If CONFIG_GPIOLIB is not enabled, mctrl_gpio_init() and mctrl_gpio_init_noauto() will currently return an error pointer with -ENOSYS. As the mctrl GPIOs are usually optional, drivers need to check for this condition to allow continue probing. To avoid the need for this check in each driver, we return NULL instead, as all the mctrl_gpio_*() functions are skipped anyway. We also adapt mctrl_gpio_to_gpiod() to be in line with this change. Reviewed-by: Fabio Estevam <festevam@gmail.com> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Reviewed-by: Uwe Kleine-Knig <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20190802100349.8659-1-frieder.schrempf@kontron.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: Absorb remaining 8250_port INT0 supportAaron Sierra
Move INT0 clearing out of common, per-port serial8250_do_startup() into PCI device probe/resume. As described in commit 2c0ac5b48a35 ("serial: exar: Fix stuck MSIs"), the purpose of clearing INT0 is to prevent the PCI interrupt line from becoming stuck asserted, "which is fatal with edge-triggered MSIs". Like the clearing via interrupt handler that moved from common code in commit c7e1b4059075 ("tty: serial: exar: Relocate sleep wake-up handling"), this clearing at startup can be better handled at the PCI device level. Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Aaron Sierra <asierra@xes-inc.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190801185956.3222-1-asierra@xes-inc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: sh-sci: Use DEVICE_ATTR_RW() for rx_fifo_triggerGeert Uytterhoeven
While commit b6b996b6cdeecf7e ("treewide: Use DEVICE_ATTR_RW") converted the rx_fifo_timeout attribute, it forgot to convert rx_fifo_trigger due to a slightly different function naming. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> Link: https://lore.kernel.org/r/20190731124555.14349-1-geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: qcom_geni_serial: Update the oversampling rateVivek Gautam
For QUP IP versions 2.5 and above the oversampling rate is halved from 32 to 16. Update this rate after reading hardware version register, so that the clock divider value is correctly set to achieve required baud rate. Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> Link: https://lore.kernel.org/r/20190801121153.10613-1-vivek.gautam@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: Clear buffer before shutdownRobert Middleton
When closing and shutting down the exar serial port, if the chip has not finished sending all of the data in its buffer, the remaining bytes will be lost. Hold off on the shutdown until the bytes have all been sent. Signed-off-by: Robert Middleton <robert.middleton@rm5248.com> Link: https://lore.kernel.org/r/20190801145640.26080-1-robert.middleton@rm5248.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: Move custom divisor support out from 8250_portAndy Shevchenko
There are Exar custom divisor support in 8250_port which belongs to 8250_exar module. Move it out to the correct module and do not contaminate generic code with it. Cc: Aaron Sierra <asierra@xes-inc.com> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190731170558.52897-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: Extract PM routine from 8250_portAndy Shevchenko
There are Exar quirks in 8250_port which belong to 8250_exar module. Extract PM routine to the correct module and do not contaminate generic code with it. Cc: Aaron Sierra <asierra@xes-inc.com> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190731170558.52897-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: 8250_exar: No need to autoconfigure Exar portsAndy Shevchenko
Since we have a separate driver there is no need to autoconfigure ports, we already know what they are. Drop autoconfiguration in 8250_port and move type detection to 8250_exar. Cc: Aaron Sierra <asierra@xes-inc.com> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190731170558.52897-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04serial: sh-sci: use driver core functions, not sysfs ones.Greg Kroah-Hartman
This is a driver, do not call "raw" sysfs functions, instead call driver core ones. Specifically convert the use of sysfs_create_file() and sysfs_remove_file() to use device_create_file() and device_remove_file() Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-serial@vger.kernel.org Link: https://lore.kernel.org/r/20190704084617.3602-4-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04xilinx_uartps.c: suppress "may be used uninitialised" warningStephen Rothwell
A powerpc allyesconfig build produces this warning: In file included from include/linux/radix-tree.h:16, from include/linux/idr.h:15, from include/linux/kernfs.h:13, from include/linux/sysfs.h:16, from include/linux/kobject.h:20, from include/linux/device.h:16, from include/linux/platform_device.h:13, from drivers/tty/serial/xilinx_uartps.c:16: drivers/tty/serial/xilinx_uartps.c: In function 'cdns_uart_console_write': include/linux/spinlock.h:288:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] _raw_spin_unlock_irqrestore(lock, flags); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/xilinx_uartps.c:1197:16: note: 'flags' was declared here unsigned long flags; ^~~~~ It looks like gcc just can't track the relationship between "locked" and "flags", and it is obvious that "flags" won't be used when "locked" is zero, so the simplest thing is to initialise flags. Cc: Jiri Slaby <jslaby@suse.com> Cc: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Link: https://lore.kernel.org/r/20190731160557.6a09c3e1@canb.auug.org.au Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: Remove dev_err() usage after platform_get_irq()Stephen Boyd
We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // <smpl> @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // </smpl> While we're here, remove braces on if statements that only have one statement (manually). Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20190730181557.90391-45-swboyd@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart_dma_shutdown()Andrey Smirnov
Last steps of .shutdown() code are identical for lpuart and lpuart32 cases, so move it all into a standalone subroutine. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-19-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Drop unnecessary lpuart*_stop_tx()Andrey Smirnov
By the time lpuart_shutdown() calls lpuart_stop_tx() UARTCR2_TE and UARTCR2_TIE (which the latter will clear) are already cleared, so that function call should effectively be a no-op. Moreso, lpuart_stop_tx() is expected to be executed with port spinlock held, which the caller doesn't. Given all that, drop the call to lpuart_stop_tx() in lpuart_shutdown(). In case of lpuart32_shutdown()/lpuart32_stop_tx(), TIE won't even be set if lpuart_dma_tx_use is true. Drop it there as well. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-18-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart_stopped_or_empty()Andrey Smirnov
The check for uart_circ_empty(xmit) || uart_tx_stopped(&sport->port) appears in multiple places in the driver. Move it into a helper function. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-17-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Use cpu_relax() instead of barrier()Andrey Smirnov
Use cpu_relax() instead of barrier() in a tight polling loops to make them a bit more idiomatic. Should also improve things on ARM64 a bit since cpu_relax() will expand into "yield" instruction there. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-16-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Introduce lpuart_wait_bit_set()Andrey Smirnov
Busy polling on a bit in a register is used in multiple places in the driver. Move it into a shared function. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-15-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Use appropriate lpuart32_* I/O funcsAndrey Smirnov
When dealing with 32-bit variant of LPUART IP block appropriate I/O helpers have to be used to properly deal with endianness differences. Change all of the offending code to do that. Fixes: a5fa2660d787 ("tty/serial/fsl_lpuart: Add CONSOLE_POLL support for lpuart32.") Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-14-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Clear CSTOPB unconditionallyAndrey Smirnov
Clearing CSTOPB bit if it is set is functionally equivalent to jsut clearing it unconditionally. Drop unnecessary check. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-13-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Drop unnecessary extra parenthesisAndrey Smirnov
Drop unnecessary extra parenthesis in the driver. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-12-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Drop no-op bit opearationAndrey Smirnov
The check for termios->c_cflag & CRTSCTS ensure that if we reach else branch, CRTSCTS in termios->c_cflag is already going to be cleard. Doing so explicitly there is not necessary. Drop it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-11-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fls_lpuart: Split shared TX IRQ handler into twoAndrey Smirnov
While sharing code for Tx interrupt handler between 8 and 32 bit variant of the peripheral saves a bit of code duplication it also adds quite a number of lpuart_is_32() checks which makes it harder to understand. Move shared bits back into corresponding lpuart*_transmit_buffer functions, split lpuart_txint into lpuart_txint and lpuart32_txint so we can drop all extra lpuart_is_32() check and make the code flow more linear. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-10-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Fix issue in software flow controlAndrey Smirnov
Although I haven't observed this bug in practice, it seems that the code for handling x_char of LPUART is pretty much identical to that of i.MX. So the fix found in commit 7e2fb5aa8d81 ("serial: imx: Fix issue in software flow control"): serial: imx: Fix issue in software flow control After send out x_char in UART driver, x_char needs to be cleared by UART driver itself, otherwise data in TXFIFO can no longer be sent out. Also tx counter needs to be increased to keep track of correct number of transmitted data. Signed-off-by: Jiada Wang <jiada_wang@mentor.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> should apply here as well. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-9-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Drop unnecessary uart_write_wakeup()Andrey Smirnov
Uart_write_wakeup() will already be called as a part of lpuart*_transmit_buffer() call, so there doesn't seem to be a reason to call it again right after. It also appears that second uart_write_wakeup() might potentially cause unwanted write wakeup when transmitting an x_char. See commit 5e42e9a30cda ("serial: imx: Fix x_char handling and tx flow control") where this problem was fixed in a very similarly structured i.MX UART driver. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-8-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Fix bogus indentationAndrey Smirnov
Fix bogus indentation in rx_dma_timer_init(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-6-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Simplify RX/TX IRQ handlersAndrey Smirnov
It appears that lpuart_rxint, lpuart_txint and lpuart32_rxint were modelled after identical function found in UART driver for i.MX. However, while said functions are used as individual IRQ handlers in i.MX driver (in case of i.MX1), it is not the case for LPUART. Given that, there's no need for us to restrict the prototype of the handler to irqreturn_t foo(int, void *) and we can drop all of uneened boilerplate code by changing it void foo(struct lpuart_port *). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-5-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: Flush HW FIFOs in .flush_bufferAndrey Smirnov
Switching baud rate might cause bogus data to appear in HW FIFO. Add code to do a HW FIFO flush to .flush_buffer callback to avoid that. Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-4-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: flush receive FIFO after overrunsStefan Agner
After overruns the FIFO pointers become misaligned. This typically shows by characters still being stuck in the FIFO despite the empty flag being asserted. After the first assertion of the overrun flag the empty flag still seems to indicate FIFO state correctly and all data can be read. However, after another overrun assertion the FIFO seems to be off by one such that the last received character is still in the FIFO (despite the empty flag being asserted). Flushing the receive FIFO reinitializes pointers. Hence it is recommended to flush the FIFO after overruns, see also: https://community.nxp.com/thread/321175 Hence, on assertion of the overrun flag read the remaining data from the FIFO and flush buffers. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-3-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04tty: serial: fsl_lpuart: fix framing error handling when using DMAStefan Agner
When using DMA framing error get cleared properly. However, due to the additional read from the data register, an underflow in the receive FIFO buffer occurs (the FIFO pointer gets out of sync). Clear the FIFO in case an underflow has occurred. Also disable the receiver during this operation and when reading the data register to minimize potential interference. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Stefan Agner <stefan@agner.ch> Cc: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: linux-imx@nxp.com Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20190729195226.8862-2-andrew.smirnov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>