summaryrefslogtreecommitdiff
path: root/drivers/tty/serial/imx.c
AgeCommit message (Collapse)Author
2020-02-09tty: serial: imx: fix merge inconsistencyMarcel Ziswiler
Missing commit 688f897ddd96 ("Merge remote-tracking branch 'linux-fslc/4.9-1.0.x-imx' into toradex_4.9-1.0.x-imx-next"). Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
2020-02-09serial: imx: add RS-485 device tree propertiesStefan Agner
Add device tree properties to influence RTS polarity and whether the receiver is enabled during transmission (rs485-rts-active-low, rs485-rx-during-tx). This aligns with behavior with upstream Linux, where RTS is active high by default (SER_RS485_RTS_AFTER_SEND) and the receiver is disabled by default when using RS485 (SER_RS485_RX_DURING_TX). Note that for Toradex hardware both properties are required, hence using RS-485 on Toradex Carrier Boards requires the following properties being specified in the device tree: linux,rs485-enabled-at-boot-time; rs485-rts-active-low; rs485-rx-during-tx; Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com> (cherry picked from commit 72919eb5f9e7a9aeb5fc1c2aa694b07994fb5a8d) Conflicts: drivers/tty/serial/imx.c
2020-02-09tty: serial: imx: Add support for enabling RS485 via device treeBhuvanchandra DV
Add support to enable RS485 via device tree Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com> (cherry picked from commit b8e5d21a1351bc0e45ae1762f0799b428d9993ea) (cherry picked from commit d0fa202ec506027902b3a2a427db4a494df8d64c) Conflicts: drivers/tty/serial/imx.c Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
2020-02-09tty: serial: imx: disable DCD and RI interruptsStefan Agner
If the UART is in DTE mode, the signals DCD and RI are inputs. In this case, the control bits in UCR3_DCD and UCR3_RI control the interrupt of those two inputs. The two bits are 1 on reset, hence leading to an interrupt if one of those signal changes... However, as of now the interrupt handler does not handle these interrupts, leading to a interrupt strom. Solve the issue by explicitly disabling the two interrupts during initialization. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com> (cherry picked from commit 2d027fec8264daa4cda1bcc81cabb91bd97cde0b) (cherry picked from commit 0d85191ac6663ea3e2ff84d96f20c62144549f27)
2020-02-07Merge tag 'v4.14.164' into 4.14-2.3.x-imxMarcel Ziswiler
This is the 4.14.164 stable release Conflicts: arch/arm/Kconfig.debug arch/arm/boot/dts/imx7s.dtsi arch/arm/mach-imx/cpuidle-imx6q.c arch/arm/mach-imx/cpuidle-imx6sx.c arch/arm64/kernel/cpu_errata.c arch/arm64/kvm/hyp/tlb.c drivers/crypto/caam/caamalg.c drivers/crypto/mxs-dcp.c drivers/dma/imx-sdma.c drivers/gpio/gpio-vf610.c drivers/gpu/drm/bridge/adv7511/adv7511_drv.c drivers/input/keyboard/imx_keypad.c drivers/input/keyboard/snvs_pwrkey.c drivers/mmc/core/block.c drivers/mmc/core/queue.h drivers/mmc/host/sdhci-esdhc-imx.c drivers/net/can/flexcan.c drivers/net/can/rx-offload.c drivers/net/ethernet/freescale/fec_main.c drivers/net/wireless/ath/ath10k/pci.c drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c drivers/pci/dwc/pci-imx6.c drivers/spi/spi-fsl-lpspi.c drivers/usb/dwc3/gadget.c include/net/tcp.h sound/soc/fsl/Kconfig sound/soc/fsl/fsl_esai.c
2019-12-17serial: imx: fix error handling in console_setupStefan Agner
[ Upstream commit 63fd4b94b948c14eeb27a3bbf50ea0f7f0593bad ] The ipg clock only needs to be unprepared in case preparing per clock fails. The ipg clock has already disabled at the point. Fixes: 1cf93e0d5488 ("serial: imx: remove the uart_console() check") Signed-off-by: Stefan Agner <stefan@agner.ch> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-02-12MLK-17739 tty: serial: imx: clear wakeup flag before enable wakeup interruptFugang Duan
It is better to clear wakeup flag in status register before enable wakeup interrupt bits, which can avoid system suspend fail during devices no irq suspend stage. Reviewed-by: Gao Pan <pandy.gao@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-17218 tty: serial: imx: add lock for register save/restoreFugang Duan
The driver save/restore registers in system suspend/resume noirq stage to support no_console_suspend in power lost case. In noirq stage with no_console_suspend, .imx_console_write() _maybe_ called to print out log_buf message in .printk() or console_unlock() called by other drivers. It should add port.lock to protect the registers save/restore in noirq stage since .imx_console_write() also access them. Reported-by: Anson Huang <Anson.Huang@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-16838 tty: serial: imx: add busfreq support for DMA modeFugang Duan
Add busfreq support for DMA mode. Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Reviewed-by: Robin Gong <yibin.gong@nxp.com>
2019-02-12MLK-15093 tty: serial: imx: enable bit TDMAEN in each DMA transferFugang Duan
In below case: write() -> flush() -> write() -> flush() ... .imx_flush_buffer() _MAY_ clear UCR1_TDMAEN bit if the callback is not comming or DMA transfer is not completed, to ensure DMA trigger is enabled for the new DMA prep_sg, enable the UCR1_TDMAEN bit in .dma_tx_work(). Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Tested-by: Fabio Estevam <fabio.estevam@nxp.com> Tested-by: David Wolfe <david.wolfe@nxp.com>
2019-02-12MLK-14498-13 tty: serial: imx: use tty_port_suspended() instead of ↵Andy Duan
ASYNC_SUSPENDED tty_port flag "ASYNC_SUSPENDED" has been discarded from kernel upgrade, then use .tty_port_suspended() instead of the flag check. Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-14498-8 tty: serial: imx: add modem device resetAndy Duan
Add modem device reset, wthether to reset depend on dts configuration. Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-14498-6 tty: serial: imx: pass ->dev to dma_alloc_coherent() APIAndy Duan
Pass ->dev to dma_alloc_coherent() API to avoid kernel dump. Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-12294 tty: serial: imx: init sport->flags before tx DMA readyFugang Duan
Before then DMA tx path, init the DMA tx path synchronal flags sport->flags. Signed-off-by: Fugang Duan <B38611@freescale.com>
2019-02-12MLK-12161 tty: serial: imx: only enable RTSD interrupt for hw flow controlFugang Duan
Only enable RTSD interrupt for hw flow control, otherwise RTS_B signal has some external signal disturbance without config RTS_B select input. Signed-off-by: Fugang Duan <B38611@freescale.com> (cherry picked from commit: 471e8c43aca3) Conflicts: drivers/tty/serial/imx.c
2019-02-12MLK-11851 tty: series: imx: add dma memory check before freeingFugang Duan
Add dma memory check before free it. Signed-off-by: Fugang Duan <B38611@freescale.com>
2019-02-12MLK-14498-6 tty: serial: imx: align tx path with kernel 3.14Andy Duan
Align tx path with kernel 3.14, otherwise there have data loss. The patch is cherry-picked from commit:47c1570ac934, and merge the patch 1afe15219403. Signed-off-by: Fugang Duan <B38611@freescale.com>
2019-02-12MLK-11665 tty: serial: imx: move dma init to .startup() functionAndy Duan
Kernel upgrade to 4.1.8 from 4.1.4 has one conflict: commit:3cd6a7db4c2c and commit:4eede03b97bf, and there introduces one issue during the merge. The issue cause pio mode cannot work. The patch fix the error that move the dma init function to .startup(). Signed-off-by: Fugang Duan <B38611@freescale.com>
2019-02-12MLK-10274 tty: serial: clear AWAKE bit after resume backAndy Duan
When uart port (non-console port) in dma mode and use uart as remote wakeup source, after resume back, the AWAKE bit is not cleared most of interrupts are disabled. And then let system suspend state, system resume back immediately without any wake up action. So we need to clear the AWAKE bit after resume back in DMA mode. Merge comments: it is necessary to clear AWAKE or RTSD bit. Signed-off-by: Fugang Duan <B38611@freescale.com> (merge patch from commit: d4b6b6b20eb2c5cca47292f89ab588b15d3be0a9)
2019-02-12MLK-14498-5 tty: serial: imx: fix the DMA issueAndy Duan
The commmunity driver uart DMA don't work, it better to use 4.1.y DMA process mechanism, so there have many conflict during code merging. Decisively, to use 4.1.y commit f00cf8855eaa in the merge point for DMA implemention. In DMA mode, don't involve CPU interrupt, remove .imx_dma_rxint() function. After the patch, DMA and CPU mode both work fine with the current SDMA driver. Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12Revert "serial: imx: drop useless member from driver data"Leonard Crestez
This reverts commit 64432a855148fd858e228a0faaebe7036a549706.
2019-02-12MLK-13798 tty: serial: imx: Only poke at suspend wakeup bits in noirq phaseLeonard Crestez
This prevents unwanted interrupts coming in early suspend. Loosely based on 81e8e7d91d81351d9fea4ad7c289b122706640fd from imx_4.1.y: MLK-11382 tty: serial: imx: disable irq after suspend Disable rx irq after suspend to avoid interrupt coming in early resume. Signed-off-by: Fugang Duan <B38611@freescale.com> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2019-02-12MLK-11456-01 tty: serial: imx: add pinctrl sleep mode supportFugang Duan
For LPSR mode, UART iomux settings will be lost after resume, so add pinctrl sleep mode support. Signed-off-by: Anson Huang <b20788@freescale.com> Signed-off-by: Fugang Duan <B38611@freescale.com>
2019-02-12MLK-11258 tty: serial: imx: disable overrun interrupt during uart port shutdownFugang Duan
Also disable rx fifo overrun interrupt during uart port shutdown. Signed-off-by: Fugang Duan <B38611@freescale.com> (cherry picked from commit: 39eb703f6c9f9359723f3fa22e798b1d21b44c67)
2019-02-12MLK-10406 ARM: imx: check the clk_set_rate() return valueFugang Duan
Add return value check for clk_set_rate() to avoid set clock rate fail. Signed-off-by: Fugang Duan <B38611@freescale.com> (cherry picked from commit: bcd9d743ef534cf58d2d007e6333270be12c9f06)
2019-02-12MLK-10367 tty: serial: imx: set uart module clock to 80MhzFugang Duan
When UART module clock is great than 80Mhz, there may have risk after confirming with IC owner. So set the maximum module clock to 80Mhz. Signed-off-by: Fugang Duan <B38611@freescale.com> (cherry picked from commit: 330a1245cb91583d9bc916bbb6d8c7d2c86b26f3)
2018-10-03serial: imx: restore handshaking irq for imx1Uwe Kleine-König
commit 7e620984b62532783912312e334f3c48cdacbd5d upstream. Back in 2015 when irda was dropped from the driver imx1 was broken. This change reintroduces the support for the third interrupt of the UART. Fixes: afe9cbb1a6ad ("serial: imx: drop support for IRDA") Cc: stable <stable@vger.kernel.org> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25serial: imx: Fix out-of-bounds access through serial port indexGeert Uytterhoeven
[ Upstream commit 5673444821406dda5fc25e4b52aca419f8065a19 ] The imx_ports[] array is indexed using a value derived from the "serialN" alias in DT, or from platform data, which may lead to an out-of-bounds access. Fix this by adding a range check. Fixes: ff05967a07225ab6 ("serial/imx: add of_alias_get_id() reference back") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-03serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTSFabio Estevam
commit 38b1f0fb42f772b8c9aac53593883a18ff5eb9d7 upstream. The wakeup mechanism via RTSDEN bit relies on the system using the RTS/CTS lines, so only allow such wakeup method when the system actually has RTS/CTS support. Fixes: bc85734b126f ("serial: imx: allow waking up on RTSD") Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Martin Kaiser <martin@kaiser.cx> Acked-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-10serial: imx: Update cached mctrl value when changing RTSIan Jamison
[ Upstream commit a0983c742a5885f82afb282166f83f1d3d8addf4 ] UART core function uart_update_mctrl relies on a cached value of modem control lines. This was used but not updated by local RTS control functions within imx.c. These are used for RS485 line driver enable signalling. Having an out-of-date value in the cached mctrl can result in the transmitter being enabled when it shouldn't be. Fix this by updating the mctrl value before applying it. Signed-off-by: Ian Jamison <ian.dev@arkver.com> Origin: id:8195c96e674517b82a6ff7fe914c7ba0f86e702b.1505375165.git.ian.dev@arkver.com Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-28serial: imx: Avoid post-PIO cleanup if TX DMA is startedIan Jamison
The imx_transmit_buffer function should return if TX DMA has already been started and not just skip over the buffer PIO write loop. (Which did fix the initial problem, but could have unintentional side-effects) Tested on an i.MX6Q board with half-duplex RS-485 and with RS-232. Cc: Clemens Gruber <clemens.gruber@pqgruber.com> Cc: Uwe-Kleine König <u.kleine-koenig@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Fabio Estevam <fabio.estevam@nxp.com> Fixes: 514ab34dbad6 ("serial: imx: Prevent TX buffer PIO write when a DMA has been started") Signed-off-by: Ian Jamison <ian.dev@arkver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-28tty: serial: imx: disable irq after suspendMaxim Yu. Osipov
If any key on console is pressed when board is suspended, board hangs. Driver's interrupt handler must be guaranteed not to run while resume/suspend_noirq() are being executed. See include/linux/pm.h for details. Tested on i.MX6 based board. The idea of this fix is based on commit in official i.MX kernel tree: http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git commit 81e8e7d91d81 ("tty: serial: imx: disable irq after suspend") Disable rx irq after suspend to avoid interrupt coming in early resume. Signed-off-by: Fugang Duan <B38611@freescale.com> Signed-off-by: Maxim Yu. Osipov <mosipov@ilbers.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-30serial: imx: drop useless member from driver dataUwe Kleine-König
The wait queue was only initialized and then checked if it contains active jobs but a job is never added. The last real user was removed with commit 9d297239b8cb ("serial: imx-serial - update UART IMX driver to use cyclic DMA"). Further there is no need to release the lock for the check if the port should be woken up, (and IMHO there never was) so drop the unlock/lock pair in dma_tx_callback(), too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-17serial: imx: Prevent TX buffer PIO write when a DMA has been startedIan Jamison
Function imx_transmit_buffer starts a TX DMA if DMA is enabled, since commit 91a1a909f921 ("serial: imx: Support sw flow control in DMA mode"). It also carries on and attempts to write the same TX buffer using PIO. This results in TX data corruption and double-incrementing xmit->tail with the knock-on effect of tail passing head and a page of garbage being sent out. This seems to be triggered mostly when using RS485 half duplex on SMP systems, but is probably not limited to just those. Tested locally on an i.MX6Q with an RS485 half duplex transceiver on UART3, and also by Clemens Gruber. Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com> Signed-off-by: Ian Jamison <ian.dev@arkver.com> Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-17Revert "serial: imx-serial - move DMA buffer configuration to DT"Greg Kroah-Hartman
This reverts commit a3015affdf76ef279fbbb3710a220bab7e9ea04b as there are complaints that it is incorrect. Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: Nandor Han <nandor.han@ge.com> Cc: Romain Perier <romain.perier@collabora.com> Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
2017-06-29serial: imx-serial - move DMA buffer configuration to DTNandor Han
The size of the DMA buffer can affect the delta time between data being produced and data being consumed. Basically the DMA system will move data to tty buffer when a) DMA buffer is full b) serial line is idle. The situation is visible when producer generates data continuously and there is no possibility for idle line. At this point the DMA buffer is directly affecting the delta time. The patch will add the possibility to configure the DMA buffers in DT, which case by case can be configured separately for every driver instance. The DT configuration is optional and in case missing the driver will use the 4096 buffer with 4 periods (as before), therefore no clients are impacted by this change. Signed-off-by: Nandor Han <nandor.han@ge.com> Signed-off-by: Romain Perier <romain.perier@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-29serial: imx: Enable RTSD only when neededNandor Han
Currently, this IRQ is always enabled. Some devices might mux these pins to other I/Os, like I2C. This could lead to spurious interrupts. This commit makes this IRQ optional, by using the field have_rtscts. Signed-off-by: Nandor Han <nandor.han@ge.com> Signed-off-by: Romain Perier <romain.perier@collabora.com> Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-29serial: imx: Remove unused members from imx_port structFabio Estevam
IRDA support is gone since commit afe9cbb1a6ad ("serial: imx: drop support for IRDA"), so remove the remaining irda members from imx_port structure. While at it, also remove 'trcv_delay' which is also unused. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-29Merge 4.12-rc3 into tty-nextGreg Kroah-Hartman
We need the tty fixes/changes here to handle future work. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-25serial: imx: ensure UCR3 and UFCR are setup correctlyUwe Kleine-König
Commit e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off") has a flaw: While UCR3 and UFCR were modified using read-modify-write before it switched to write register values independent of the previous state. That's a good idea in principle (and that's why I did it) but needs more care. This patch reinstates read-modify-write for UFCR and for UCR3 ensures that RXDMUXSEL and ADNIMP are set for post imx1. Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Mika Penttilä <mika.penttila@nextfour.com> Tested-by: Mika Penttilä <mika.penttila@nextfour.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Tested-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-18imx-serial: RX DMA startup latencyPeter Senna Tschudin
18a4208 introduced a change to reduce the RX DMA latency on the first reception when the serial port was opened for reading. However it was claiming a hardirq unsafe lock after a hardirq safe lock which is not allowed and causes lockdep to complain verbosely. This patch changes the code to always start RX DMA earlier, instead of relying on the flags used to open the serial port removing the code that was looking for the serial file flags. Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com> Tested-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-11imx-serial: Reduce RX DMA startup latency when opening for readingPeter Senna Tschudin
Reduce RX DMA start latency for the first reception when port is opened for reading. Instead of waiting for an interrupt signaling data on RX FIFO or data too old on RX FIFO, start RX DMA immediately when the serial port is opened for reading. Before this patch, the average RX DMA latency for the first reception was 42489 microseconds with a standard deviation of 25721 microseconds in 36 samples. After the patch the average RX DMA latency for the first reception, when the serial port is opened for reading, is 653 microseconds with a standard deviation of 294 microseconds in 36 samples. Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be offUwe Kleine-König
If the UART is operated in DTE mode and UCR3_DCD or UCR3_RI are 1 (which is the reset default) and the opposite side pulls the respective line to its active level the irq triggers after it is requested in .probe. These irqs were already disabled in .startup but this might be too late. Also setup of the UFCR_DCEDTE bit (currently done in .set_termios) is done very late which is critical as it also controls direction of some pins. So setup UFCR_DCEDTE earlier (in .probe) and also disable the broken irqs in DTE mode there before requesting irqs. Acked-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-31serial: imx: Fix the CTS_B polarity in RS485 modeFabio Estevam
When userspace passes the SER_RS485_RTS_ON_SEND flag it means that the CTS_B pin should go to logic level high before the transmission begins. CTS_B goes to logic level high when both CTSC and CTS bits are cleared. When userspace passes the SER_RS485_RTS_AFTER_SEND flag it means that the CTS_B pin should go to logic level low after the transmission finishes. CTS_B goes to logic level low when CTSC bit is cleared and CTS bit is set. So fix the CTS_B polarity logic. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-31serial: imx: Fix the RTS GPIO polarity in RS485 modeFabio Estevam
On a board that needs to drive RTS GPIO high in order to enable the transmission of a RS485 transceiver the following description is passed in the devide tree: &uart4 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart4>; rts-gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>; status = "okay"; }; and userspace configures the uart port as follows: /* enable RS485 mode: */ rs485conf.flags |= SER_RS485_ENABLED; /* set logical level for RTS pin equal to 1 when sending: */ rs485conf.flags |= SER_RS485_RTS_ON_SEND; /* set logical level for RTS pin equal to 0 after sending: */ rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND); However the RTS GPIO polarity observed in the oscilloscope is inverted. When the SER_RS485_RTS_ON_SEND flag is set the imx_port_rts_active() function should be called and following the same logic when SER_RS485_RTS_AFTER_SEND flag is cleared the imx_port_rts_inactive() should be called. Do such logic change so that RS485 communication in half duplex can work successfully when the RTS GPIO pin is passed via device tree. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-12serial: imx: Allow passing 'rst-gpios' for rs485 modeFabio Estevam
According to Documentation/devicetree/bindings/serial/serial.txt the generic 'rts-gpios' property can be used to specify the GPIO for RTS functionality. Currently it is not possible to use the imx UART port in rs485 mode when the 'rts-gpios' property is passed in the device tree. The imx uart driver only checks for the presence of the built-in RTS pin, via 'uart-has-rtscts' property and disable the rs485 flag if this property is absent. So fix this logic by also checking if RTS pin has been passed via GPIO. Tested on a imx6dl based board. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27serial: imx: Fix DCD readingSascha Hauer
The USR2_DCDIN bit is tested for in register usr1. As the name suggests the usr2 register should be used instead. This fixes reading the Carrier detect status. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Fixes: 90ebc4838666 ("serial: imx: repair and complete handshaking") Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: <stable@vger.kernel.org> # 4.5+ Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-15serial: imx: Replace dmaengine old APIFabien Lahoudere
dmaengine_terminate_all() is deprecated and should be replaced by dmaengine_terminate_sync() in non-atomic context or dmaengine_terminate_async() with dmaengine_synchronize(). See commit b36f09c3c441 ("dmaengine: Add transfer termination synchronization support") Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-13serial: imx: add error messages when .probe failsUwe Kleine-König
Some functions called by serial_imx_probe emit an error message themself (like kmalloc() and friends). clk_prepare_enable() and devm_request_irq() however don't which might make the driver silently fail to probe. So add an error message for these. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-02Allowing UART DMA to be configured on i.MX53Martyn Welch
The UART DMA was only being configured on i.MX6Q compatible devices. We know that the DMA also works for i.MX53 devices, so enable uart DMA for imx53 and let the device tree to configure if DMA should be used or not. Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>