From patchwork Wed Apr 22 18:02:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 214076 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=ham 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 1A67DC5518B for ; Wed, 22 Apr 2020 18:02:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C50122098B for ; Wed, 22 Apr 2020 18:02:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="dEkvVyei" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726856AbgDVSCV (ORCPT ); Wed, 22 Apr 2020 14:02:21 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:5294 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726476AbgDVSCU (ORCPT ); Wed, 22 Apr 2020 14:02:20 -0400 X-UUID: ffaa157022074406a23ae358582cbbb0-20200423 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=Wd/MOGLi3v8IcIouicrcERfGp8lHo02kJWYXWlv+S1A=; b=dEkvVyeidV4pAvuX74tJ5sxMxMUhqa/vNIPLbHk3HKgyaqsGFelkmcyzogkGqgs5DwOCa67/MULKBy0Yud3tcsxqupahgtlGjnl3kyUvqoUvTnBBF0hbA4ZpqiapDhNWHRXHdL/cjqKT+GGxk1zdXAfRLFAPZaxZ50kivUappgw=; X-UUID: ffaa157022074406a23ae358582cbbb0-20200423 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1603115986; Thu, 23 Apr 2020 02:02:16 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 23 Apr 2020 02:02:06 +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; Thu, 23 Apr 2020 02:02:05 +0800 From: To: , , , , , , , CC: , , , , Sean Wang , Steven Liu , Ryder Lee Subject: [PATCH v3] tty: serial: don't do termios for BTIF Date: Thu, 23 Apr 2020 02:02:08 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 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. Fixes: 1c16ae65e250 ("serial: 8250: of: Add new port type for MediaTek BTIF controller on MT7622/23 SoC") Cc: Steven Liu Suggested-by: Andy Shevchenko 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. --- 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 33ad9d6de532..234d8db470c0 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 0325f2e53b74..abc974b4113f 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", @@ -2544,6 +2544,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 ||