[PATCH v1 0/2] serial_mxc: fixing reception

while writing to a imx-serial device is probably thoroughly tested - and obviosly works for the debug-serial - using a serial driver to read data received over the serial interface does not work reliably.
the patches in this series address issues found during the implementation of a custom uboot-command to query a coprocessor, connected to an imx8mm over uart4, for mainboard-identification strings
Johannes Schneider (2): serial: mxc: enable the RX pipeline serial: mxc: have putc use the TXFIFO
drivers/serial/serial_mxc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)

on imx8(mm) the RXDMUXSEL needs to be set for data going over the wire (as observable on a connected 'scope) to actually make it into the RXFIFO
the reference manual is not overly clear about this, and only mentiones that "UCR3_RXDMUXSEL should always be set." - and since the CR3 register reverts to its reset values after setting the baudrate, setting this bit is done during '_mxc_serial_setbgr'
Signed-off-by: Johannes Schneider johannes.schneider@leica-geosystems.com
---
drivers/serial/serial_mxc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 70a0e5e919..5f283cc635 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -61,6 +61,11 @@ #define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */ #define UCR3_REF25 (1<<3) /* Ref freq 25 MHz */ #define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz */ + +//imx8 names these bitsfields instead: +#define UCR3_DTRDEN BIT(3) /* bit not used in this chip */ +#define UCR3_RXDMUXSEL BIT(2) /* RXD muxed input selected; 'should always be set' */ + #define UCR3_INVT (1<<1) /* Inverted Infrared transmission */ #define UCR3_BPEN (1<<0) /* Preset registers enable */ #define UCR4_CTSTL_32 (32<<10) /* CTS trigger level (32 chars) */ @@ -176,6 +181,12 @@ static void _mxc_serial_setbrg(struct mxc_uart *base, unsigned long clk,
writel(UCR2_WS | UCR2_IRTS | UCR2_RXEN | UCR2_TXEN | UCR2_SRST, &base->cr2); + + // setting the baudrate triggers a reset, returning cr3 to its + // reset value but UCR3_RXDMUXSEL "should always be set." + // according to the imx8 reference-manual + writel(readl(&base->cr3) | UCR3_RXDMUXSEL, &base->cr3); + writel(UCR1_UARTEN, &base->cr1); }

only waiting for TXEMPTY leads to corrupted messages going over the wire - which is fixed by making use of the FIFO
Signed-off-by: Johannes Schneider johannes.schneider@leica-geosystems.com ---
drivers/serial/serial_mxc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 5f283cc635..1e0add7281 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -309,7 +309,7 @@ static int mxc_serial_putc(struct udevice *dev, const char ch) struct mxc_serial_plat *plat = dev_get_plat(dev); struct mxc_uart *const uart = plat->reg;
- if (!(readl(&uart->ts) & UTS_TXEMPTY)) + if (readl(&uart->ts) & UTS_TXFULL) return -EAGAIN;
writel(ch, &uart->txd);

On Monday 05 September 2022 10:53:58 Johannes Schneider wrote:
while writing to a imx-serial device is probably thoroughly tested - and obviosly works for the debug-serial - using a serial driver to read data received over the serial interface does not work reliably.
the patches in this series address issues found during the implementation of a custom uboot-command to query a coprocessor, connected to an imx8mm over uart4, for mainboard-identification strings
Johannes Schneider (2): serial: mxc: enable the RX pipeline serial: mxc: have putc use the TXFIFO
drivers/serial/serial_mxc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Hello! I'm really not maintainer of mxc and I do not have time to review those patches. So please do not send me them as I'm spammed with tons of unrelated emails/patches.

Hello Pali,
-----Original Message----- From: U-Boot u-boot-bounces@lists.denx.de On Behalf Of Pali Rohar Sent: Monday, September 5, 2022 10:59 AM To: u-boot@lists.denx.de Subject: Re: [PATCH v1 0/2] serial_mxc: fixing reception
On Monday 05 September 2022 10:53:58 Johannes Schneider wrote:
while writing to a imx-serial device is probably thoroughly tested - and
obviosly works for the debug-serial - using a serial driver to read data received over the serial interface does not work reliably.
the patches in this series address issues found during the implementation of a
custom uboot-command to query a coprocessor, connected to an imx8mm over uart4, for mainboard-identification strings
Johannes Schneider (2): serial: mxc: enable the RX pipeline serial: mxc: have putc use the TXFIFO
drivers/serial/serial_mxc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Hello! I'm really not maintainer of mxc and I do not have time to review those patches. So please do not send me them as I'm spammed with tons of unrelated emails/patches.
Then there is a problem with having your name as a maintainer for this file.
If I execute: $ ./scripts/get_maintainer.pl drivers/serial/serial_mxc.c "Pali Rohár" pali@kernel.org (commit_signer:1/1=100%,authored:1/1=100%,added_lines:2/2=100%,removed_lines:2/2=100%) u-boot@lists.denx.de (open list)
I guess this has to be corrected then, right?
Regards, Andrey

On Monday 05 September 2022 09:12:49 ZHIZHIKIN Andrey wrote:
Hello Pali,
-----Original Message----- From: U-Boot u-boot-bounces@lists.denx.de On Behalf Of Pali Rohar Sent: Monday, September 5, 2022 10:59 AM To: u-boot@lists.denx.de Subject: Re: [PATCH v1 0/2] serial_mxc: fixing reception
On Monday 05 September 2022 10:53:58 Johannes Schneider wrote:
while writing to a imx-serial device is probably thoroughly tested - and
obviosly works for the debug-serial - using a serial driver to read data received over the serial interface does not work reliably.
the patches in this series address issues found during the implementation of a
custom uboot-command to query a coprocessor, connected to an imx8mm over uart4, for mainboard-identification strings
Johannes Schneider (2): serial: mxc: enable the RX pipeline serial: mxc: have putc use the TXFIFO
drivers/serial/serial_mxc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Hello! I'm really not maintainer of mxc and I do not have time to review those patches. So please do not send me them as I'm spammed with tons of unrelated emails/patches.
Then there is a problem with having your name as a maintainer for this file.
If I execute: $ ./scripts/get_maintainer.pl drivers/serial/serial_mxc.c "Pali Rohár" pali@kernel.org (commit_signer:1/1=100%,authored:1/1=100%,added_lines:2/2=100%,removed_lines:2/2=100%) u-boot@lists.denx.de (open list)
I guess this has to be corrected then, right?
Regards, Andrey
Yes, please correct it. I have not added myself to the list of mxc maintainers and I a really do not have time for reviewing mxc patches.

Hello Pali,
-----Original Message----- From: U-Boot u-boot-bounces@lists.denx.de On Behalf Of Pali Rohar Sent: Monday, September 5, 2022 11:14 AM To: ZHIZHIKIN Andrey andrey.zhizhikin@leica-geosystems.com Cc: u-boot@lists.denx.de Subject: Re: [PATCH v1 0/2] serial_mxc: fixing reception
On Monday 05 September 2022 09:12:49 ZHIZHIKIN Andrey wrote:
Hello Pali,
-----Original Message----- From: U-Boot u-boot-bounces@lists.denx.de On Behalf Of Pali Rohar Sent: Monday, September 5, 2022 10:59 AM To: u-boot@lists.denx.de Subject: Re: [PATCH v1 0/2] serial_mxc: fixing reception
On Monday 05 September 2022 10:53:58 Johannes Schneider wrote:
while writing to a imx-serial device is probably thoroughly tested - and
obviosly works for the debug-serial - using a serial driver to read data
received
over the serial interface does not work reliably.
the patches in this series address issues found during the implementation
of a
custom uboot-command to query a coprocessor, connected to an imx8mm over
uart4,
for mainboard-identification strings
Johannes Schneider (2): serial: mxc: enable the RX pipeline serial: mxc: have putc use the TXFIFO
drivers/serial/serial_mxc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Hello! I'm really not maintainer of mxc and I do not have time to review those patches. So please do not send me them as I'm spammed with tons of unrelated emails/patches.
Then there is a problem with having your name as a maintainer for this file.
If I execute: $ ./scripts/get_maintainer.pl drivers/serial/serial_mxc.c "Pali Rohár" pali@kernel.org
(commit_signer:1/1=100%,authored:1/1=100%,added_lines:2/2=100%,removed_lines:2/2= 100%)
u-boot@lists.denx.de (open list)
I guess this has to be corrected then, right?
Regards, Andrey
Yes, please correct it. I have not added myself to the list of mxc maintainers and I a really do not have time for reviewing mxc patches.
I cannot modify this part since removing you from maintainer list would require a transfer of maintainership of this component to another name, which I do not know.
I've Cc:'d Tom and people from imx world here so they can make a decision on who shall continue the maintenance of this file when your entry is removed.
-- andrey

Hi Andrey,
On Mon, Sep 5, 2022 at 6:21 AM ZHIZHIKIN Andrey andrey.zhizhikin@leica-geosystems.com wrote:
I cannot modify this part since removing you from maintainer list would require a transfer of maintainership of this component to another name, which I do not know.
I've Cc:'d Tom and people from imx world here so they can make a decision on who shall continue the maintenance of this file when your entry is removed.
I have added the imx serial driver to the "ARM FREESCALE IMX" list: https://lore.kernel.org/u-boot/20220905105700.3209658-1-festevam@gmail.com/T...

Hello Fabio,
-----Original Message----- From: U-Boot u-boot-bounces@lists.denx.de On Behalf Of Fabio Estevam Sent: Monday, September 5, 2022 1:20 PM To: ZHIZHIKIN Andrey andrey.zhizhikin@leica-geosystems.com Cc: Pali Rohár pali@kernel.org; u-boot@lists.denx.de; trini trini@konsulko.com; Peng Fan (OSS) peng.fan@oss.nxp.com; Fabio Estevam festevam@denx.de; Stefano Babic sbabic@denx.de Subject: Re: [PATCH v1 0/2] serial_mxc: fixing reception
Hi Andrey,
On Mon, Sep 5, 2022 at 6:21 AM ZHIZHIKIN Andrey andrey.zhizhikin@leica-geosystems.com wrote:
I cannot modify this part since removing you from maintainer list would require a transfer of maintainership of this component to another name, which I do not know.
I've Cc:'d Tom and people from imx world here so they can make a decision on who shall continue the maintenance of this file when your entry is removed.
I have added the imx serial driver to the "ARM FREESCALE IMX" list: https://lore.kernel.org/u-boot/20220905105700.3209658-1-festevam@gmail.com/T...
I've seen your patch on the ML already, thanks a lot for taking care of this!
Regards, Andrey
participants (4)
-
Fabio Estevam
-
Johannes Schneider
-
Pali Rohár
-
ZHIZHIKIN Andrey