Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp212865imm; Wed, 29 Aug 2018 18:49:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbMk+3uYelycim3adIE9aKa9gVvzFxoK8omeswFWs59btpSvt0zh611QXt1BJKF/8CvKCxH X-Received: by 2002:a63:9dcd:: with SMTP id i196-v6mr7864197pgd.238.1535593740051; Wed, 29 Aug 2018 18:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535593740; cv=none; d=google.com; s=arc-20160816; b=0YFl8v1REpUZ3iDRFJw2YS4lup9h+EQM+W05RCAFkwRkjj5bjui7Ig/KktquZMUXJq SUNR6Pe+zbz6LXcC7vjGZ+6/DXHr+XB2uPFFhFTEbcpN5pZtZd4o8VCSzmWGyVQNIhMt +66/5DJNPuPK0rMMDKoV3jN89J3dzG+hra7eEZ5+R4EdfTFMsg7Xu9K5EZqczsaoMykP JgWa6sWswCK3RYnqQGNISE/YVXLIGiIMBXKprE4EgiCEWpnv/xkrzkseTT5ifzhEE6uA 2amkAKTVJ5/E3aswDin7db0knF/NexvFQtAdzZb4No4tmVTCxBXas4tNwGC4rB6DagM5 EcNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=P/6K4S4/MCf4PvzZUqxPNwP4rElLsJ7tp0RDtzFeYlQ=; b=eHmYV106uKdujWdizEZWNtoPXQB6VmBUaiRhtwRLZWs00LXAGvo+3Gli16KH13qAYP TBRCbyIwcT10OjRpzm9mmhE7X6DNlauZ+G+C8OtKzAdi+Ri16VIWM1ic3L960QRJs/wY YOghaa9xuajrtnhDJwL3YExmUlKlXsJkDS5E7EdQVs5wBaNqANbrR7MkD0EtZGGIRk5M 6KBCVjhLw6DwPld9TQdjk7moGo4AIsXC0CmgIG4XQymjxqkm0A2oPvjsE0ECGxwR5v9T ZyoNx9qJeLykII6kZIDTf5R8Ib1UtrZ/p2iuXaeS3ygjG0irZ5AymUsfOIfJAh/n5/xZ ddWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=orczsWKV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k20-v6si5420109pgg.7.2018.08.29.18.48.45; Wed, 29 Aug 2018 18:49:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=orczsWKV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727447AbeH3FrL (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.7.4