Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp965190yba; Mon, 1 Apr 2019 22:36:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwJ3KKU08he2NkBWVVjyQlhS/y0sSIKkufYSoAZP8tbQim/oQQBG9LHgfx/Ki1QdrD6WEG X-Received: by 2002:a17:902:2a29:: with SMTP id i38mr69839636plb.22.1554183374456; Mon, 01 Apr 2019 22:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554183374; cv=none; d=google.com; s=arc-20160816; b=WRgKU3c+odB7XAW/ztEwb3YG+ZOvkOEVYVNhk0dF78wiGInGj5cHfWniaZs/VnNnH9 hS2bjDqIO1kSQiqZJUp6zUmCg+tI7WIMpR6961XTOFRxqJnEtmxw33U6fvttxNOimLOW DiwICtmFO9HeWoq2/zc2py/5ctGe+6NPmi+GKHZ40cnYYr5gHSTAnUhCWW84e1kTqIB6 T+HDHbOE6muwrxsd15M+TgpZbbT79UMCZCTD3Lm/+OIExFUMry5VzPFH6zDWKb2KogT9 26jjUTdjznUJqLLQgdsMRyk1x/52zjLSuEqNLoEpPXEnPOtxtY4DoBwd+AKMVMqBUm8E 5/yg== 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=rSPQ7DGVhBjhVIpC2feD1Zf1Ln5mj7QIJLWAJErFVR8=; b=FCwfJdX+f7GijymE2HUb6oVrQjFTWhw8JOt37w4ygWF33zdNXybuvUZoyr2blJM3Zv T4iAe48lUOijz0oxCO/Na+bFnacGpOCddKufRJlu8mNnVZr723bnallAJyODZ6jdY5Cm Q8oyo8eJFokou18BcHMQ2TexUpAKMr/aLcfVLNVxGo/SK0pEvGDiwjp+2qP/ne42kaCM eXJS3Xdct/kT1gpacS8RTwwmKfrQPFPk0oX9eKqO+7YF7QBLhWCZ787s/B4muEGqFrZH 8tdtBAIZJKbap5RUlKLnGnopqZlb3UdVr/hfIzNWiGrdUs08wOsK0+QdmdRd1gs3dIQ6 OV0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="be1A/4kh"; 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 e22si9989304pgv.323.2019.04.01.22.35.58; Mon, 01 Apr 2019 22:36:14 -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="be1A/4kh"; 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 S1729091AbfDBF0w (ORCPT + 99 others); Tue, 2 Apr 2019 01:26:52 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33699 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbfDBF0q (ORCPT ); Tue, 2 Apr 2019 01:26:46 -0400 Received: by mail-pg1-f195.google.com with SMTP id b12so5958247pgk.0; Mon, 01 Apr 2019 22:26:45 -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=rSPQ7DGVhBjhVIpC2feD1Zf1Ln5mj7QIJLWAJErFVR8=; b=be1A/4khegj3mIW9Gsrt9X2ep0KdCNXs6dz41ASwBfq2DIBgJ/1ttK+wzjpFYsQPhK YzBtE7MDPsfEJaD7eEhrcnx+qpQCCRRkOTzuAdooWeK2+xdzCqfHqRcFXlbqXrWkC2DQ mbVOWFhmuYANWizeIyDBnzTfRhNGYnMP0419OySztGGDQzEUcJR8sgG0w3rAKcw9u1ot jNRa2zfODowOGpXAaujbeSbYTrWZZUp29E39FVUcWqrZXs1/dWoygzHBeWcbntLm3rP5 1ma72KqfoLJNHrfxuZy8zV5koO4ykso7uSwVKQFLrNC3DJ75JRmsyNWRIMu9UO2ZGSnZ RYAw== 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=rSPQ7DGVhBjhVIpC2feD1Zf1Ln5mj7QIJLWAJErFVR8=; b=F/uPokKHcD3U1s/opRAenlMFphR2cF3a/tPEWNgX84iQqga6+9KaR8SAnDr6SHlyvJ TbtKbqEfq5GjSjU2gIXlNECoEWDU1e7ueU2SlmvMt5uCnfdzGEl7zgoA/ELwo5u2oRvM yZlv3jvudQ4GUbD3ZiD0u6FKL9UKlLY27l2kGzrNj5ZhR9ltvfZDrk+s7EPrAo+tza+o RHzeffkE7sikZGE7R7/YAZS4qiGnRDqCEXCIpPbvsj8V/4P4sBRoFQqKsms0MLzR9H5K dgoBrTBDcxBIGKIOZmNKqGPOdJtk6ltcY2o2opsHr6WWQciG3pe8tQb4XA+BzFyYQS1z tCxQ== X-Gm-Message-State: APjAAAUbR/fsqafK/kFQizWhXN62NxhQ2VNLRLNtnWxoyWGPS8tnA36a ZWHnAHsp7MnN/p5JbBvUmzY= X-Received: by 2002:a63:6fcd:: with SMTP id k196mr52581017pgc.238.1554182805315; Mon, 01 Apr 2019 22:26:45 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id d75sm30535482pga.66.2019.04.01.22.26.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 22:26:44 -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 V4 3/3] USB: serial: f81232: implement break control Date: Tue, 2 Apr 2019 13:26:37 +0800 Message-Id: <1554182797-12815-3-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554182797-12815-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1554182797-12815-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) --- 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 37da345acafd..763a51222384 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; bool lsr_work_resched; struct work_struct lsr_work; @@ -378,13 +379,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) @@ -520,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; @@ -573,11 +585,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