[OpenWrt-Devel,PATCH/RFC] ath79: ar933x_uart: set UART_CS_{RX, TX}_READY_ORIDE
diff mbox series

Message ID 20200206181042.GA4074@makrotopia.org
State Under Review
Delegated to: Daniel Golle
Headers show
Series
  • [OpenWrt-Devel,PATCH/RFC] ath79: ar933x_uart: set UART_CS_{RX, TX}_READY_ORIDE
Related show

Commit Message

Daniel Golle Feb. 6, 2020, 6:10 p.m. UTC
On AR934x this UART is usually not initialized by the bootloader
as it is only used as a secondary serial port while the primary
UART is a newly introduced NS16550-compatible.
In order to make use of the ar933x-uart on AR934x without RTS/CTS
hardware flow control, one needs to set the
UART_CS_{RX,TX}_READY_ORIDE bits as other than on AR933x where this
UART is used as primary/console, the bootloader on AR934x typically
doesn't set those bits.
Setting them explicitely on AR933x should not do any harm, so just
set them unconditionally.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
If this works well on AR93xx there will be no need to add another
compatible string and logic to differentiate between AR933x and AR934x
in the UART driver. I don't have AR933x here to test, it'd be great if
someone with that hardware can test if applying this patch breaks the
serial console or not.

 ...uart-set-UART_CS_-RX-TX-_READY_ORIDE.patch | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 target/linux/ath79/patches-4.19/0060-serial-ar933x_uart-set-UART_CS_-RX-TX-_READY_ORIDE.patch

Comments

Chuanhong Guo Feb. 7, 2020, 2:46 a.m. UTC | #1
Hi!

On Fri, Feb 7, 2020 at 2:11 AM Daniel Golle <daniel@makrotopia.org> wrote:
>
> On AR934x this UART is usually not initialized by the bootloader
> as it is only used as a secondary serial port while the primary
> UART is a newly introduced NS16550-compatible.
> In order to make use of the ar933x-uart on AR934x without RTS/CTS
> hardware flow control, one needs to set the
> UART_CS_{RX,TX}_READY_ORIDE bits as other than on AR933x where this
> UART is used as primary/console, the bootloader on AR934x typically
> doesn't set those bits.
> Setting them explicitely on AR933x should not do any harm, so just
> set them unconditionally.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> If this works well on AR93xx there will be no need to add another
> compatible string and logic to differentiate between AR933x and AR934x
> in the UART driver. I don't have AR933x here to test, it'd be great if
> someone with that hardware can test if applying this patch breaks the
> serial console or not.

Tested on ar9331 (pisen,ts-d084) and uart console works fine.

Tested-by: Chuanhong Guo <gch981213@gmail.com>

Patch
diff mbox series

diff --git a/target/linux/ath79/patches-4.19/0060-serial-ar933x_uart-set-UART_CS_-RX-TX-_READY_ORIDE.patch b/target/linux/ath79/patches-4.19/0060-serial-ar933x_uart-set-UART_CS_-RX-TX-_READY_ORIDE.patch
new file mode 100644
index 0000000000..2b0b72edc0
--- /dev/null
+++ b/target/linux/ath79/patches-4.19/0060-serial-ar933x_uart-set-UART_CS_-RX-TX-_READY_ORIDE.patch
@@ -0,0 +1,54 @@ 
+From 39da0e7957fb68b91f6c55cc61d66ae0930f3cd3 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Thu, 6 Feb 2020 19:45:34 +0200
+Subject: [PATCH] serial: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE
+To: linux-serial@vger.kernel.org,
+    linux-kernel@vger.kernel.org
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
+    Jiri Slaby <jslaby@suse.com>
+
+On AR934x this UART is usually not initialized by the bootloader
+as it is only used as a secondary serial port while the primary
+UART is a newly introduced NS16550-compatible.
+In order to make use of the ar933x-uart on AR934x without RTS/CTS
+hardware flow control, one needs to set the
+UART_CS_{RX,TX}_READY_ORIDE bits as other than on AR933x where this
+UART is used as primary/console, the bootloader on AR934x typically
+doesn't set those bits.
+Setting them explicitely on AR933x should not do any harm, so just
+set them unconditionally.
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ drivers/tty/serial/ar933x_uart.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
+index 3bdd56a1021b..ea12f10610b6 100644
+--- a/drivers/tty/serial/ar933x_uart.c
++++ b/drivers/tty/serial/ar933x_uart.c
+@@ -286,6 +286,10 @@ static void ar933x_uart_set_termios(struct uart_port *port,
+ 	ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
+ 			    AR933X_UART_CS_HOST_INT_EN);
+ 
++	/* enable RX and TX ready overide */
++	ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
++		AR933X_UART_CS_TX_READY_ORIDE | AR933X_UART_CS_RX_READY_ORIDE);
++
+ 	/* reenable the UART */
+ 	ar933x_uart_rmw(up, AR933X_UART_CS_REG,
+ 			AR933X_UART_CS_IF_MODE_M << AR933X_UART_CS_IF_MODE_S,
+@@ -418,6 +422,10 @@ static int ar933x_uart_startup(struct uart_port *port)
+ 	ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
+ 			    AR933X_UART_CS_HOST_INT_EN);
+ 
++	/* enable RX and TX ready overide */
++	ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
++		AR933X_UART_CS_TX_READY_ORIDE | AR933X_UART_CS_RX_READY_ORIDE);
++
+ 	/* Enable RX interrupts */
+ 	up->ier = AR933X_UART_INT_RX_VALID;
+ 	ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
+-- 
+2.25.0
+