From patchwork Fri Jun 19 19:59:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 213894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44A87C433E1 for ; Fri, 19 Jun 2020 19:59:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 246D020DD4 for ; Fri, 19 Jun 2020 19:59:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="BNLhfgA+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387977AbgFST72 (ORCPT ); Fri, 19 Jun 2020 15:59:28 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:28670 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726940AbgFST71 (ORCPT ); Fri, 19 Jun 2020 15:59:27 -0400 X-UUID: daa762d178254e3cb1cb5e180b4705b4-20200620 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=mQyV9oA90nw/l5PmfxypuRikaoz6DxZG8g7s7v+PD9k=; b=BNLhfgA+H0RSegHq7gnNU1th0W2/Kr0jPoi51NdIPX9rKM/EQDa7e213hodBwSWe7wkEa34Um+Nb9R2kykyQT2oNV1LBOPSP1MCpw1o0U6EyxaOQHYrmf1+4B8IUq8nEHBQOf2P4+CxMKo3+DBAvfr6dSoB8YN3g/9224SUkrUE=; X-UUID: daa762d178254e3cb1cb5e180b4705b4-20200620 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 821304996; Sat, 20 Jun 2020 03:59:21 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 20 Jun 2020 03:59:15 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 20 Jun 2020 03:59:11 +0800 From: To: , , , , , , , , , , , , , , CC: , , , , , Sean Wang , Steven Liu , Ryder Lee Subject: [PATCH v4] tty: serial: don't do termios for BTIF Date: Sat, 20 Jun 2020 03:59:14 +0800 Message-ID: <78efa2b1e2599deff4d838b05b4054ec5ac2976a.1592595601.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-TM-SNTS-SMTP: F0184A2B374C0FECDB916DDE74159AA926AA2C638F0BA363607752D2529A60792000:8 X-MTK: N Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Sean Wang 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 Signed-off-by: Sean Wang Signed-off-by: Ryder Lee -- 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. --- drivers/tty/serial/8250/8250.h | 1 + drivers/tty/serial/8250/8250_port.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 52bb21205bb6..0d9d3bfe48af 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -82,6 +82,7 @@ struct serial8250_config { #define UART_CAP_MINI (1 << 17) /* Mini UART on BCM283X family lacks: * STOP PARITY EPAR SPAR WLEN5 WLEN6 */ +#define UART_CAP_NTIO (1 << 18) /* UART doesn't do termios */ #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 1632f7d25acc..af54db877efe 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -286,7 +286,7 @@ static const struct serial8250_config uart_config[] = { .tx_loadsz = 16, .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, - .flags = UART_CAP_FIFO, + .flags = UART_CAP_FIFO | UART_CAP_NTIO, }, [PORT_NPCM] = { .name = "Nuvoton 16550", @@ -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 (up->capabilities & UART_CAP_NTIO) + return; + if (up->capabilities & UART_CAP_MINI) { termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CMSPAR); if ((termios->c_cflag & CSIZE) == CS5 ||