linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] tty: serial: don't do termios for BTIF
@ 2020-07-07 23:11 sean.wang
  2020-07-08 14:58 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: sean.wang @ 2020-07-07 23:11 UTC (permalink / raw)
  To: gregkh, jslaby, andriy.shevchenko, mika.westerberg, sr, arnd,
	matthias.bgg, tthayer
  Cc: linux-mediatek, linux-serial, linux-arm-kernel, linux-kernel,
	Sean Wang, Steven Liu, Ryder Lee

From: Sean Wang <sean.wang@mediatek.com>

Bluetooth Interface (BTIF) is designed dedicatedly for MediaTek SOC with
BT in order to be instead of the UART interface between BT module and Host
CPU, and not exported to user space to access.

As the UART design, BTIF will be an APB slave and can transmit or receive
data by MCU access, but doesn't provide termios function like baudrate and
flow control setup.

Even LCR on offset 0xC that is just a FAKELCR
a. If FAKELCR[7] is equaled to 1, RBR(0x00), THR(0x00), IER(0x04)
   will not be readable/writable.

b. If FAKELCR is equaled to 0xBF, RBR(0x00), THR(0x00), IER(0x04),
   IIR(0x08), and LSR(0x14) will not be readable/writable.

So adding a new capability 'UART_CAP_NTIO' for the unusual unsupported
case.

The bluetooth driver would use BTIF device as a serdev. So the termios
still function would be called in kernelspace from ttyport_open in
drivers/tty/serdev/serdev-ttyprt.c.

Fixes: 1c16ae65e250 ("serial: 8250: of: Add new port type for MediaTek BTIF controller on MT7622/23 SoC")
Cc: Steven Liu <steven.liu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>

--
v1->v2:
no change on termios->c_cflag and refine commit message

v2->v3:
change the naming from NMOD to NTIO as TIO is a well established prefix
for termios IOCTLs.

v3->v4:
1. remove appropriate tag
2. add the explanation why the termios is required even when the connection
   isn't exported to userspace.

v4->v5:
Use up->port.quirks UPQ_IGNORE_TERMIOS instead.
---
 drivers/tty/serial/8250/8250_core.c | 3 +++
 drivers/tty/serial/8250/8250_port.c | 3 +++
 include/linux/serial_core.h         | 1 +
 3 files changed, 7 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index fc118f649887..b00060c615c2 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -490,6 +490,9 @@ static void univ8250_rsa_support(struct uart_ops *ops)
 static inline void serial8250_apply_quirks(struct uart_8250_port *up)
 {
 	up->port.quirks |= skip_txen_test ? UPQ_NO_TXEN_TEST : 0;
+
+	if (up->port.type == PORT_MTK_BTIF)
+		up->port.quirks |= UPQ_IGNORE_TERMIOS;
 }
 
 static void __init serial8250_isa_init_ports(void)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 1632f7d25acc..be380649fefb 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2640,6 +2640,9 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
 	unsigned long flags;
 	unsigned int baud, quot, frac = 0;
 
+	if (port->quirks & UPQ_IGNORE_TERMIOS)
+		return;
+
 	if (up->capabilities & UART_CAP_MINI) {
 		termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CMSPAR);
 		if ((termios->c_cflag & CSIZE) == CS5 ||
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 9fd550e7946a..c46aae374e0e 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -155,6 +155,7 @@ struct uart_port {
 
 	/* quirks must be updated while holding port mutex */
 #define UPQ_NO_TXEN_TEST	BIT(0)
+#define UPQ_IGNORE_TERMIOS	BIT(1)
 
 	unsigned int		read_status_mask;	/* driver specific */
 	unsigned int		ignore_status_mask;	/* driver specific */
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-08 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 23:11 [PATCH v5] tty: serial: don't do termios for BTIF sean.wang
2020-07-08 14:58 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).