From patchwork Thu Aug 30 01:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ji-Ze Hong (Peter Hong)" X-Patchwork-Id: 10581109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 535C6180E for ; Thu, 30 Aug 2018 01:47:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4003B2B6F8 for ; Thu, 30 Aug 2018 01:47:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3297C2B6FD; Thu, 30 Aug 2018 01:47:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B05FC2B6F8 for ; Thu, 30 Aug 2018 01:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727326AbeH3FrF (ORCPT ); Thu, 30 Aug 2018 01:47:05 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42106 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbeH3FrF (ORCPT ); Thu, 30 Aug 2018 01:47:05 -0400 Received: by mail-pg1-f193.google.com with SMTP id y4-v6so3133369pgp.9; Wed, 29 Aug 2018 18:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cu4oYdi29BeIVUgBpHHRk6wAnaM4DIFxP/7eTOSnPAw=; b=clMamF/K17MHX3zSijJ3DLqsAbOEXd1MmRHVf81IQCuvBa3BYSI/sZMH447TQZtCk4 Ec7tGKnZ14YlHqeR2asLs3exGhnnotPRYS1Tir2Pdp438cyR9rUbZFv5vMHxNeGnnBRI QaK3TTAk16+p23Zaq3TlMnZ1BLVpKZbTYwMzU4POwsubuc1OFEVfzBZACvwOM8zna+KW b8+YSVe0M8TF/lHAXe/Rqh1ZkPInrnJcdTEJ+3Xbs4oKfeqtfBJG7MbBDNGwlzUUhy1l s9S8AEud76hfe9vPY06MgZnB8oFuBNh9kpNyWFDUxDbII+x+r38bTzzd1n8S8ajTDkm4 eREQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cu4oYdi29BeIVUgBpHHRk6wAnaM4DIFxP/7eTOSnPAw=; b=aado+KC+IiZN+xsQGrkrXq6juHqUQNIC/cfyoVl/woR89Aa75dwMTjq+KPAZe0oAAj ukZaFCC3UwxaJnzbQuyTlLwilRNljT/PloBhQOfFmnCCWBQi5H5calOENll+Kl3nWml/ 7T+i4FoLaZJETl1p4ue6OwIDefxjM1TXH6K//L1ltnVnWgyCmDqbQhSo2FHIjEOkIIyM UDZ3YkBZSmjjXko0dnn0fH1h3KbjOHL+HdHiyyjI+gLQcO/FOqSb1atcem4WQPwI0e6f vW7r+FlsmKAOEFMgWDnKj43DAW9vQqwZ0ZTYygnkJqYik3ueHhiTdAkJ6u0UTzCImG1e 0S6g== X-Gm-Message-State: APzg51Ct9G6JSxqMptU9c/iRTtbn0nvGIdbDdA3kjYL7cKhJWyHgmzQC Z0NGztCd0tEbjdGjxqmCVlQ= X-Google-Smtp-Source: ANB0Vda5/FmrNnnVWNN+JvgjmkvtOEvThUNhiGFU9gzMBKlxxyTXDb9pgUBeTtD82nfSpBvc187aLA== X-Received: by 2002:a63:788b:: with SMTP id t133-v6mr7696387pgc.329.1535593643453; Wed, 29 Aug 2018 18:47:23 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id a16-v6sm6184210pgv.29.2018.08.29.18.47.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 18:47:22 -0700 (PDT) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, peter_hong@fintek.com.tw, hpeter+linux_kernel@gmail.com, Oliver Neukum Subject: [PATCH V2 1/4] USB: serial: f81232: clear overrun flag Date: Thu, 30 Aug 2018 09:47:10 +0800 Message-Id: <1535593634-22004-2-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The F81232 will report data and LSR with bulk like following format: bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]... LSR will auto clear frame/parity/break error flag when reading by H/W, but overrrun will only cleared when reading LSR. So this patch add a worker to read LSR when OE. Cc: Oliver Neukum Signed-off-by: Ji-Ze Hong (Peter Hong) --- v2: 1: Add flush_work(&port_priv->lsr_work) in f81232_close(). Thanks for notice by Oliver Neukum drivers/usb/serial/f81232.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 96036f87b1de..2f595307dd14 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -41,12 +41,14 @@ MODULE_DEVICE_TABLE(usb, id_table); #define FIFO_CONTROL_REGISTER (0x02 + SERIAL_BASE_ADDRESS) #define LINE_CONTROL_REGISTER (0x03 + SERIAL_BASE_ADDRESS) #define MODEM_CONTROL_REGISTER (0x04 + SERIAL_BASE_ADDRESS) +#define LINE_STATUS_REGISTER (0x05 + SERIAL_BASE_ADDRESS) #define MODEM_STATUS_REGISTER (0x06 + SERIAL_BASE_ADDRESS) struct f81232_private { struct mutex lock; u8 modem_control; u8 modem_status; + struct work_struct lsr_work; struct work_struct interrupt_work; struct usb_serial_port *port; }; @@ -282,6 +284,7 @@ static void f81232_read_int_callback(struct urb *urb) static void f81232_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; + struct f81232_private *priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; char tty_flag; unsigned int i; @@ -315,6 +318,7 @@ static void f81232_process_read_urb(struct urb *urb) if (lsr & UART_LSR_OE) { port->icount.overrun++; + schedule_work(&priv->lsr_work); tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); } @@ -556,9 +560,12 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port) static void f81232_close(struct usb_serial_port *port) { + struct f81232_private *port_priv = usb_get_serial_port_data(port); + f81232_port_disable(port); usb_serial_generic_close(port); usb_kill_urb(port->interrupt_in_urb); + flush_work(&port_priv->lsr_work); } static void f81232_dtr_rts(struct usb_serial_port *port, int on) @@ -623,6 +630,21 @@ static void f81232_interrupt_work(struct work_struct *work) f81232_read_msr(priv->port); } +static void f81232_lsr_worker(struct work_struct *work) +{ + struct f81232_private *priv; + struct usb_serial_port *port; + int status; + u8 tmp; + + priv = container_of(work, struct f81232_private, lsr_work); + port = priv->port; + + status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp); + if (status) + dev_warn(&port->dev, "read LSR failed: %d\n", status); +} + static int f81232_port_probe(struct usb_serial_port *port) { struct f81232_private *priv; @@ -633,6 +655,7 @@ static int f81232_port_probe(struct usb_serial_port *port) mutex_init(&priv->lock); INIT_WORK(&priv->interrupt_work, f81232_interrupt_work); + INIT_WORK(&priv->lsr_work, f81232_lsr_worker); usb_set_serial_port_data(port, priv); From patchwork Thu Aug 30 01:47:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ji-Ze Hong (Peter Hong)" X-Patchwork-Id: 10581117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F349017DB for ; Thu, 30 Aug 2018 01:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E11882B6FC for ; Thu, 30 Aug 2018 01:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53FA2B704; Thu, 30 Aug 2018 01:47:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 230EA2B6FC for ; Thu, 30 Aug 2018 01:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727328AbeH3FrH (ORCPT ); Thu, 30 Aug 2018 01:47:07 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34638 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbeH3FrG (ORCPT ); Thu, 30 Aug 2018 01:47:06 -0400 Received: by mail-pg1-f194.google.com with SMTP id d19-v6so3146603pgv.1; Wed, 29 Aug 2018 18:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pefCd/wiDF8YvelbaDuXnT91JPjUdEsdWs9c6vvOQEE=; b=Nfz6DIa6PDWxDq0MInbr9C1PzRs/kFtC/AvK9s56BgVfpiI5dNMxLdMrERBuDLvj9c CoUz/Go2FWbX4ed4X1Q+FBL2qpaVtqt+b6AwxGAyhQuTh2x6x4ZD7Sw+uNzlPubfot0v PONZgdHHmumzk+xn9bbrgv8lW/IJNWXGIEhXwxtFlpxEpv8as6iV2fTHAmlSpPPfIM+s 4Utx2HBsP+fwwpoxjTczutPreonkASuj4CnQw/9BOKtT8TpuXusTIWYJY0V99hcEMBOb FihMVRkI92980BTmb1yj6uFlKeFousDupb/zd7SglN3HbTJP0XdoEH0NQ+rREK/yElv2 +/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pefCd/wiDF8YvelbaDuXnT91JPjUdEsdWs9c6vvOQEE=; b=c3rIWDj06Anjo9lwtSXBthbUd0xSJrXLWDMymePEgKhEKCIsmmoEmJHiLXyZAMzqtG OvpCU3p/V3iI1OyffUeHysz8I4rD3n/tX5oXTfN8WeEEXk1acOz4u8bdmWrK+5/PAc7h OR3Z47b3y3KcJNNOd1UexdVNwfVZeoFSsLoPY0X0EjpF5rkFqp0f2x+4x9fF4DfKsjzr mZBbLCly0USFQgDhWoPVz0Lr7R12tpR6K2m7m1E0dvkD071dADA5kabkqRIrEgvoSyrX mUqmY/a0aNN2SXRjgxij11iGDeEl10tud9YOCugImF0oipVjJGN3Zq/aNBFNuiEJqUXi HaEg== X-Gm-Message-State: APzg51BHsDDFVpFp7sc2/pga3XcGOgYFY++sNY3igx/VS839ZTvGBGLt KrvEzahV4UOJMcqkN0DkJPc= X-Google-Smtp-Source: ANB0VdY6Jjcq1xH1q44h01VKzDZzsHLafcZkczOu6/m6x4C6OG4H+hk7GVG5CU4VP3t0rm0YzJdzJQ== X-Received: by 2002:a63:10c:: with SMTP id 12-v6mr7714243pgb.62.1535593645398; Wed, 29 Aug 2018 18:47:25 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id d24-v6sm5947734pgv.23.2018.08.29.18.47.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 18:47:24 -0700 (PDT) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, peter_hong@fintek.com.tw, hpeter+linux_kernel@gmail.com Subject: [PATCH V2 2/4] USB: serial: f81232: add high baud rate support Date: Thu, 30 Aug 2018 09:47:11 +0800 Message-Id: <1535593634-22004-3-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The F81232 had 4 clocksource 1.846/18.46/14.77/24MHz and baud rates can be up to 1.5Mbits with 24MHz. F81232 Clock registers (106h) Bit1-0: Clock source selector 00: 1.846MHz. 01: 18.46MHz. 10: 24MHz. 11: 14.77MHz. Signed-off-by: Ji-Ze Hong (Peter Hong) --- drivers/usb/serial/f81232.c | 105 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 11 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 2f595307dd14..56adae8a9ee0 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -28,7 +28,8 @@ static const struct usb_device_id id_table[] = { MODULE_DEVICE_TABLE(usb, id_table); /* Maximum baudrate for F81232 */ -#define F81232_MAX_BAUDRATE 115200 +#define F81232_MAX_BAUDRATE 1500000 +#define F81232_DEF_BAUDRATE 9600 /* USB Control EP parameter */ #define F81232_REGISTER_REQUEST 0xa0 @@ -44,18 +45,42 @@ MODULE_DEVICE_TABLE(usb, id_table); #define LINE_STATUS_REGISTER (0x05 + SERIAL_BASE_ADDRESS) #define MODEM_STATUS_REGISTER (0x06 + SERIAL_BASE_ADDRESS) +/* + * F81232 Clock registers (106h) + * + * Bit1-0: Clock source selector + * 00: 1.846MHz. + * 01: 18.46MHz. + * 10: 24MHz. + * 11: 14.77MHz. + */ +#define F81232_CLK_REGISTER 0x106 +#define F81232_CLK_1_846_MHZ 0 +#define F81232_CLK_18_46_MHZ BIT(0) +#define F81232_CLK_24_MHZ BIT(1) +#define F81232_CLK_14_77_MHZ (BIT(1) | BIT(0)) +#define F81232_CLK_MASK GENMASK(1, 0) + struct f81232_private { struct mutex lock; u8 modem_control; u8 modem_status; + speed_t baud_base; struct work_struct lsr_work; struct work_struct interrupt_work; struct usb_serial_port *port; }; -static int calc_baud_divisor(speed_t baudrate) +static u32 const baudrate_table[] = { 115200, 921600, 1152000, 1500000 }; +static u8 const clock_table[] = { F81232_CLK_1_846_MHZ, F81232_CLK_14_77_MHZ, + F81232_CLK_18_46_MHZ, F81232_CLK_24_MHZ }; + +static int calc_baud_divisor(speed_t baudrate, speed_t clockrate) { - return DIV_ROUND_CLOSEST(F81232_MAX_BAUDRATE, baudrate); + if (!baudrate) + return 0; + + return DIV_ROUND_CLOSEST(clockrate, baudrate); } static int f81232_get_register(struct usb_serial_port *port, u16 reg, u8 *val) @@ -129,6 +154,21 @@ static int f81232_set_register(struct usb_serial_port *port, u16 reg, u8 val) return status; } +static int f81232_set_mask_register(struct usb_serial_port *port, u16 reg, + u8 mask, u8 val) +{ + int status; + u8 tmp; + + status = f81232_get_register(port, reg, &tmp); + if (status) + return status; + + tmp = (tmp & ~mask) | (val & mask); + + return f81232_set_register(port, reg, tmp); +} + static void f81232_read_msr(struct usb_serial_port *port) { int status; @@ -346,13 +386,53 @@ static void f81232_break_ctl(struct tty_struct *tty, int break_state) */ } -static void f81232_set_baudrate(struct usb_serial_port *port, speed_t baudrate) +static int f81232_find_clk(speed_t baudrate) +{ + int idx; + + for (idx = 0; idx < ARRAY_SIZE(baudrate_table); ++idx) { + if (baudrate <= baudrate_table[idx] && + baudrate_table[idx] % baudrate == 0) + return idx; + } + + return -EINVAL; +} + +static void f81232_set_baudrate(struct tty_struct *tty, + struct usb_serial_port *port, speed_t baudrate, + speed_t old_baudrate) { + struct f81232_private *priv = usb_get_serial_port_data(port); u8 lcr; int divisor; int status = 0; + int i; + int idx; + speed_t baud_list[] = {baudrate, old_baudrate, F81232_DEF_BAUDRATE}; + + for (i = 0; i < ARRAY_SIZE(baud_list); ++i) { + idx = f81232_find_clk(baud_list[i]); + if (idx >= 0) { + baudrate = baud_list[i]; + tty_encode_baud_rate(tty, baudrate, baudrate); + break; + } + } - divisor = calc_baud_divisor(baudrate); + if (idx < 0) + return; + + priv->baud_base = baudrate_table[idx]; + divisor = calc_baud_divisor(baudrate, priv->baud_base); + + status = f81232_set_mask_register(port, F81232_CLK_REGISTER, + F81232_CLK_MASK, clock_table[idx]); + if (status) { + dev_err(&port->dev, "%s failed to set CLK_REG: %d\n", + __func__, status); + return; + } status = f81232_get_register(port, LINE_CONTROL_REGISTER, &lcr); /* get LCR */ @@ -442,6 +522,7 @@ static void f81232_set_termios(struct tty_struct *tty, u8 new_lcr = 0; int status = 0; speed_t baudrate; + speed_t old_baud; /* Don't change anything if nothing has changed */ if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios)) @@ -454,11 +535,12 @@ static void f81232_set_termios(struct tty_struct *tty, baudrate = tty_get_baud_rate(tty); if (baudrate > 0) { - if (baudrate > F81232_MAX_BAUDRATE) { - baudrate = F81232_MAX_BAUDRATE; - tty_encode_baud_rate(tty, baudrate, baudrate); - } - f81232_set_baudrate(port, baudrate); + if (old_termios) + old_baud = tty_termios_baud_rate(old_termios); + else + old_baud = F81232_DEF_BAUDRATE; + + f81232_set_baudrate(tty, port, baudrate, old_baud); } if (C_PARENB(tty)) { @@ -593,6 +675,7 @@ static int f81232_carrier_raised(struct usb_serial_port *port) static int f81232_get_serial_info(struct usb_serial_port *port, unsigned long arg) { + struct f81232_private *priv = usb_get_serial_port_data(port); struct serial_struct ser; memset(&ser, 0, sizeof(ser)); @@ -600,7 +683,7 @@ static int f81232_get_serial_info(struct usb_serial_port *port, ser.type = PORT_16550A; ser.line = port->minor; ser.port = port->port_number; - ser.baud_base = F81232_MAX_BAUDRATE; + ser.baud_base = priv->baud_base; if (copy_to_user((void __user *)arg, &ser, sizeof(ser))) return -EFAULT; From patchwork Thu Aug 30 01:47:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ji-Ze Hong (Peter Hong)" X-Patchwork-Id: 10581113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52D8D5A4 for ; Thu, 30 Aug 2018 01:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43DCE2B6F8 for ; Thu, 30 Aug 2018 01:47:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37B592B6FD; Thu, 30 Aug 2018 01:47:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D24322B6F8 for ; Thu, 30 Aug 2018 01:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbeH3FrL (ORCPT ); Thu, 30 Aug 2018 01:47:11 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42292 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbeH3FrK (ORCPT ); Thu, 30 Aug 2018 01:47:10 -0400 Received: by mail-pf1-f196.google.com with SMTP id l9-v6so3107553pff.9; Wed, 29 Aug 2018 18:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P/6K4S4/MCf4PvzZUqxPNwP4rElLsJ7tp0RDtzFeYlQ=; b=orczsWKVRgZuPvJeEGa/m+ZxOEvcz196T/26JY/4MHs6U+fcmT+xrG777TzOWX7++o 33xbnEe7/1cTzHn9kKiNDJz9Ay6qKo5JtsRP5cqqfrH9XJ2xIIkwSNBFwvHcDAuXg/A5 oPmaAx6SnFGYGktVSni3AUm+Lux4LFHMZFAr0fRPaeRYYpRlVmhbLBkYSdpSEdkj+ZL/ kWqJK9+wKCnrF38cXPwnavwi9SPZtc5PT9BzTQ5eiMbKtpW/2zxYpFX5ugf1ZRjOLaK6 qEjHpLNAc9D7uBCXUaeAO0kEg4IMYRRMUI4CB+wnefFdRGaNm9GQb8BVy/RNf1EMA7R4 Aj9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P/6K4S4/MCf4PvzZUqxPNwP4rElLsJ7tp0RDtzFeYlQ=; b=uGr8JN1tIHVJ9CGAwMwVQBKsGjV8CFCHM//Rq6zIp1rRD33DKY75zs/mF0y8NoUPdS +lWB/NUH7uXPoeRqs0CkqUVXNWG5HqcjUSMAceQGeYU+ld8gx8bn7kJvy1tJy88ISKWt /tMfRAZ/cM1ioJx+Pne13JcOG9htzDQd6EVMFBisezZ/pUBptqYOjgTxzGXk9dM8UyJ3 EZMb1lNSPJm6vsIlJRc93Ph/vM/Dgqt4TozUSbv9ZEDZ01cK8vBBvXBkZQfDlaxsXf6O IPQEJW8vm+nOeMPJLH2qFRli9YfSM0MT/ueapTUmLNKA1ZUtIVBjUi6XRwEeTAbuOIJQ C9ag== X-Gm-Message-State: APzg51B/PhGsYQKBMkuX/yy73HPmIPZO1jEvwfB6d+C057oNdp60T7zn DNzXxDUXkLWrgcWULdUI6R4= X-Google-Smtp-Source: ANB0VdZZF7ibGIdudvM2cc9I88J2CMbGBgPQ3LH/Np5aAojhEpC9++1Y5sq1VIU8u8VJGl8eBcvEJg== X-Received: by 2002:a62:435c:: with SMTP id q89-v6mr8383328pfa.135.1535593649045; Wed, 29 Aug 2018 18:47:29 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id e14-v6sm5922053pgv.48.2018.08.29.18.47.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 18:47:28 -0700 (PDT) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, peter_hong@fintek.com.tw, hpeter+linux_kernel@gmail.com Subject: [PATCH V2 3/4] USB: serial: f81232: implement break control Date: Thu, 30 Aug 2018 09:47:13 +0800 Message-Id: <1535593634-22004-5-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement Fintek F81232 break on/off with LCR register. It's the same with 16550A LCR register layout. Signed-off-by: Ji-Ze Hong (Peter Hong) --- v2: 1: Fix f81232_break_ctl() for mis-operated set_mask_register(). 2: Add set break control bit in f81232_set_termios(). drivers/usb/serial/f81232.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 56adae8a9ee0..863430d7535f 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -65,6 +65,7 @@ struct f81232_private { struct mutex lock; u8 modem_control; u8 modem_status; + bool is_break; speed_t baud_base; struct work_struct lsr_work; struct work_struct interrupt_work; @@ -377,13 +378,24 @@ static void f81232_process_read_urb(struct urb *urb) static void f81232_break_ctl(struct tty_struct *tty, int break_state) { - /* FIXME - Stubbed out for now */ + struct usb_serial_port *port = tty->driver_data; + struct f81232_private *priv = usb_get_serial_port_data(port); + int status; + u8 tmp = 0; - /* - * break_state = -1 to turn on break, and 0 to turn off break - * see drivers/char/tty_io.c to see it used. - * last_set_data_urb_value NEVER has the break bit set in it. - */ + mutex_lock(&priv->lock); + + if (break_state) { + priv->is_break = !!break_state; + tmp = UART_LCR_SBC; + } + + status = f81232_set_mask_register(port, LINE_CONTROL_REGISTER, + UART_LCR_SBC, tmp); + if (status) + dev_err(&port->dev, "set break failed: %d\n", status); + + mutex_unlock(&priv->lock); } static int f81232_find_clk(speed_t baudrate) @@ -519,6 +531,7 @@ static int f81232_port_disable(struct usb_serial_port *port) static void f81232_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { + struct f81232_private *priv = usb_get_serial_port_data(port); u8 new_lcr = 0; int status = 0; speed_t baudrate; @@ -572,11 +585,18 @@ static void f81232_set_termios(struct tty_struct *tty, break; } + mutex_lock(&priv->lock); + + if (priv->is_break) + new_lcr |= UART_LCR_SBC; + status = f81232_set_register(port, LINE_CONTROL_REGISTER, new_lcr); if (status) { dev_err(&port->dev, "%s failed to set LCR: %d\n", __func__, status); } + + mutex_unlock(&priv->lock); } static int f81232_tiocmget(struct tty_struct *tty) From patchwork Thu Aug 30 01:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ji-Ze Hong (Peter Hong)" X-Patchwork-Id: 10581111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1B7117DB for ; Thu, 30 Aug 2018 01:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0F442B6FD for ; Thu, 30 Aug 2018 01:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D383C2B704; Thu, 30 Aug 2018 01:47:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7828D2B6FD for ; Thu, 30 Aug 2018 01:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727459AbeH3FrM (ORCPT ); Thu, 30 Aug 2018 01:47:12 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43102 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbeH3FrM (ORCPT ); Thu, 30 Aug 2018 01:47:12 -0400 Received: by mail-pf1-f196.google.com with SMTP id j26-v6so3102651pfi.10; Wed, 29 Aug 2018 18:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dyn7GN8lH5UuIRP6OFnVsQ6loTA5lg0n6k2ZgI8W43s=; b=aq3sFlwQjigxUDonF4Ym+BX73IC3o5IwsKymldWVJvLhafHKQu+7JRMDHG5R/fkAGw ZnGMLUBeC8MV6yp9T20f1RzjnLGLE6RoldGOBzLF7ZcvgB/skRfGuE6o5j+1PnM3PhwR b5uk4+/P3198/f4F/oKBCE/P90LfOw99aB24z291nJeqmTZmd1G3RzwdzCmz8nzB2pS8 nh9ldxKUH6vFnd3/svcaGIhJhfAo65mX403CIbT36teRe6ibBXDqSYKb9cEXxmLO0boS TuW7+xktN+1n56l/8tmZ6BeeAbBFlSIESZ9uagYKkwdjxQYHydE9/GH4GT1HqUIDg2JL QbMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dyn7GN8lH5UuIRP6OFnVsQ6loTA5lg0n6k2ZgI8W43s=; b=KUw3+AweH1gdxfQnRRSFbSVn9dOdAv8MtKoEdw/KNflLdM+JDJNhha40BLLFA++9Pw CISYtO0Rh+ok1bvB5/WhZOXo136EqQo28nNqHKeTC9znA8xV5+G1lByQQ5O1VpBSIX5j ybTfBnGSWEjDcQXVsfDTTMMqCr2ktat4xI8QG5lXl9LZ1PnRwpSr0LWgatcW341z6YFs QI3QnZi2OPcT8tTFlOHHpsj8pfwfZctqRzbnWty9xayLkQv+dJFZWp4vchqE8MC3QLHc 84waO9JY3HkGK+/m9uAvvRSucDxctpecO7jqF/As4/RXnHNNdRjxhx1jTzYDFxe1mlOV sYAw== X-Gm-Message-State: APzg51DOJ1PQBqkKLUp96uDQN2z9ogeowAW+VO0k8iOtqGTa9YlfwN8a MeAuKeeff3wCOyxanx7+ZLI= X-Google-Smtp-Source: ANB0VdbYizxyiupdHl6Ze83b6InCh8t1o7o2LuHONANX9YSqio2cQIjp5UG3xvkI1xH92vXveA1ScQ== X-Received: by 2002:a62:ee06:: with SMTP id e6-v6mr8416989pfi.2.1535593650815; Wed, 29 Aug 2018 18:47:30 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id f75-v6sm9916450pfk.85.2018.08.29.18.47.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 18:47:30 -0700 (PDT) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, peter_hong@fintek.com.tw, hpeter+linux_kernel@gmail.com Subject: [PATCH V2 4/4] USB: serial: f81232: fix bulk_in/out size Date: Thu, 30 Aug 2018 09:47:14 +0800 Message-Id: <1535593634-22004-6-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1535593634-22004-1-git-send-email-hpeter+linux_kernel@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix Fintek F81232 bulk_in/out size to 64/16 according to the spec. http://html.alldatasheet.com/html-pdf/406315/FINTEK/F81232/1762/8/F81232.html Signed-off-by: Ji-Ze Hong (Peter Hong) --- drivers/usb/serial/f81232.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 863430d7535f..e3ab1646a693 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -785,8 +785,7 @@ static struct usb_serial_driver f81232_device = { }, .id_table = id_table, .num_ports = 1, - .bulk_in_size = 256, - .bulk_out_size = 256, + .bulk_out_size = 16, .open = f81232_open, .close = f81232_close, .dtr_rts = f81232_dtr_rts,