Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4333610yba; Mon, 29 Apr 2019 18:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtCn7kwKZlhmy3z4Aug7Jw90fC/0/dEHVYO/m8rto61xcQxuFelSG4nKlqd6P32+TrMfS0 X-Received: by 2002:a62:121c:: with SMTP id a28mr66568477pfj.58.1556587440392; Mon, 29 Apr 2019 18:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556587440; cv=none; d=google.com; s=arc-20160816; b=rhDKTf75VabNNar5pDoV2URq2R/FcO3KOxN58YpKFsNOa6dv5Mx7rN/nOSw95E8Tyy JCTfmPaN5R3RruvlCSQGtEmgFbofHj/ts3ZJPfYNkaeuly8sCcRR67E3d/J/d2Momn8x YVFvihZCeH1dYAmo11iBI26ub1vrY5fTyGAQjbww7o5K46QWGoXhxueCrR0M/7xRxR/6 xBvhemb6ZLpWMEsTuVUNKgIawAFteBcxj5IVPkpnoPE2zjhPM3aYpkX77/A9JGcio5Fs KaX3fu9n9eV9LWtMwAPPwRqqx8whee5M9Gc2rzkUYr9yzHZ2DiZpx4Uz9qsTrgEPU6/P jtkw== 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; bh=14BtYvopEGYF3ZyX/uprrfiK7My6iDbeW5Kct6Ko73U=; b=Isg86VIWp7era8rdMxvu54266zfh63Dx6PYD9ZDptKJMy0IEsl80qmk+RW4LlFTSjT aVXY6K0munLKHmkoR3B4eDMIN+fTSIgveZ5MBELmEelGCqje5KWK1XTnP358yqawI42z IJUk71lZyUmnEqSLp/3RdP8ma7IGQb8BQcoBAdB20PvvpnphtlrRn5NgFILELVDxrQ1H D/nTm3CmjveXueNykvxKs/ZddB24Ln797Qcmfr+zQqAFCM6aiC3YOsfdq0vD04TAy0lR fM/osZzQeQ0Xwklaps3OtOdlCv+bBF9602Ya8H3mzUg5NRszlDPUSKQDTcGqzdNFyIos VX+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nplkksJw; 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 d17si32692790pgh.7.2019.04.29.18.23.44; Mon, 29 Apr 2019 18:24: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=nplkksJw; 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 S1729841AbfD3BWu (ORCPT + 99 others); Mon, 29 Apr 2019 21:22:50 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34887 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729828AbfD3BWs (ORCPT ); Mon, 29 Apr 2019 21:22:48 -0400 Received: by mail-pf1-f193.google.com with SMTP id t21so6227521pfh.2; Mon, 29 Apr 2019 18:22:48 -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=14BtYvopEGYF3ZyX/uprrfiK7My6iDbeW5Kct6Ko73U=; b=nplkksJwpY6fgI5iJvv5KU0Ks/zSTkh+fr7UVRw5o0CqPzmEuk+VHDefPvenM/2HrO NCjOx+1e0KMG94NEfDxm5qVGCjPklp2QnqVBWIJ1AeDxiYf9bI6MKpBkZ8q3KKpdwwv3 V3dev3KJ0lzk4mCS3llYiGEhf+jofS7Q+HyzSYBEAP/rGnd07j2Pb6mlfP3mrxK5pfbs 9uDA1JnssqHBgqdfNIh+WofAKY3qFwFu+PX3btxPf2chTknzY3cS/X0280i80xEOvVHG qegRmBwatwTzkqMwG5Tn8bvjYU3DwCskpM9dXmVRuxEn3dA/r29URAryWJ50XsUSMEBh E8pg== 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=14BtYvopEGYF3ZyX/uprrfiK7My6iDbeW5Kct6Ko73U=; b=bkiN7k3tU2RovOsvdUjBd5hkWP8FDTSvcFvXhNO6N3/yF8PAHIEJdZcnTE8cMgnxhK W7tq9Y9s25NuXF33WWg3RIIbrQcxkG0Gqw2spW5mxD+f7yuErzCzf5jKoZVbw31bYrKy 0QyIrphqTS5m8nTTI6A0KOSyhS7b3cs524PEQbWti4IKzWXx4sZc2fYXSHVi7gMYOlnO wvZC4vQcd9kA/q/cDP0Z/rPb8gWtszudEH63GmpaI6m346fX9ncTkIhvsTdkkK9FtMsN SzZE4JDqPEvcvebmFKXgaf0Pi+LTjrmUmvx9UkO2w504+lmu//0pjUyOncDlnXSH9WNq kbvQ== X-Gm-Message-State: APjAAAVxjm2uvqXhzT9QhCdg5ncbTEfs4f+F1o/cAb7Tg8KrxQzourlr 3N6ThyHzcuLqyftIqtYSoec= X-Received: by 2002:a63:7:: with SMTP id 7mr4583794pga.108.1556587367869; Mon, 29 Apr 2019 18:22:47 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id s74sm353739pfs.26.2019.04.29.18.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 18:22:47 -0700 (PDT) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: peter_hong@fintek.com.tw, johan@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Ji-Ze Hong (Peter Hong)" Subject: [PATCH V9 4/4] USB: serial: f81232: implement break control Date: Tue, 30 Apr 2019 09:22:32 +0800 Message-Id: <1556587352-19500-4-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556587352-19500-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1556587352-19500-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) --- v9: 1: no change v8: 1: no change v7: 1: no change v6: 1: no change v5: 1: no change v4: 1: no change v3: 1: using shadow_lcr to save LCR in f81232_break_ctl() drivers/usb/serial/f81232.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 6a1e6a27ce16..562c9babd144 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; + u8 shadow_lcr; speed_t baud_base; struct work_struct lsr_work; struct work_struct interrupt_work; @@ -377,13 +378,23 @@ 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; - /* - * 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->shadow_lcr |= UART_LCR_SBC; + else + priv->shadow_lcr &= ~UART_LCR_SBC; + + status = f81232_set_register(port, LINE_CONTROL_REGISTER, + priv->shadow_lcr); + 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 +530,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 +584,16 @@ static void f81232_set_termios(struct tty_struct *tty, break; } + mutex_lock(&priv->lock); + + new_lcr |= (priv->shadow_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