Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1299224ybb; Fri, 29 Mar 2019 01:31:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNXKFo3R5O+qZVk0pC4ZCy2cVrJHFjl4RVrgfD9ikYcoo5aM2v1kSyUQb/pO3tR6BXU5rA X-Received: by 2002:a63:5d04:: with SMTP id r4mr34798728pgb.117.1553848268596; Fri, 29 Mar 2019 01:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553848268; cv=none; d=google.com; s=arc-20160816; b=Ud0AJelZffVvbrNEv0dfna+NHLF+D0KBejxHx/MOeFlR8CkqjxwhDKWlg283O412z5 oYmMajKTDtI516VCJR8PUWnVxtEOiyCgUJq6S9U3PTlD94o9js+/8/yizelmMGRTpxLM dRo2W22h2vXS8xSy8tZdCoIkO8voOWEZ1ZGIYWN6Vw7rkJFbdW+ZuVNsm1jUgksal0i/ uyp6R+6GvTvFesT/BJu03dzdfaSfdpH2zMAg0HhQLvQXBfHujBSsnLMHsy0GqHbCPEr6 3r89sDDOm99aRTEP3qD0nRYrRHIBqvfmL2C7YQ6EcBXTUIGqVk4SxMlbRo9+xvaGKAxc wfog== 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=2m9R9NREa9VGalybY5Mom3wHFgPLYsbrTO9tvJbZ0FA=; b=W6s5wIEV8Fj3WKk27UgWPu3DvGz5mwClUrZ9CfJloFKl2airm6bj6fThZ7PyobmSGH oTy5yiPDZ1wImK891vu6712MwLkEuOhdsGE21m/ENHP1NGRwOnLpa7PqqSgRuXRJCywc 05k8cJllFA/V5wGPUdsR4A+uQIjeRVC3yBK4OQ7uMDEW23HfdvpxcCE4rNV5A4FTMM5k LtYUZCQwWKdNrrAkztJxd3sIGlRRg8MwXny2LOZfjSUmFhbgbk89aQWzIoBZK7owbgJ0 1gniTDOQ6Ph0pFiVfhcjY5b/GeFdV7SHH7de3FMl0wAyQePL5Jk6wGTFFRQ6EozrZIt0 UCQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dVuvOIRX; 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 j30si1260413pgl.338.2019.03.29.01.30.52; Fri, 29 Mar 2019 01:31:08 -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=dVuvOIRX; 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 S1729129AbfC2I3A (ORCPT + 99 others); Fri, 29 Mar 2019 04:29:00 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45048 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729104AbfC2I24 (ORCPT ); Fri, 29 Mar 2019 04:28:56 -0400 Received: by mail-pf1-f194.google.com with SMTP id y13so694489pfm.11; Fri, 29 Mar 2019 01:28:55 -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=2m9R9NREa9VGalybY5Mom3wHFgPLYsbrTO9tvJbZ0FA=; b=dVuvOIRXF9eH4X8BPxi53/6YoIJcMDrVruTzMEB1ZZ/lJ84u37qfpHm2sNCtadJ4UP dKNWRTiQCENalgy13UWe42bOAks2X8keO+2bNgkQ8i4XXz9ohjhOM6GavqN+cpPxvnF/ sBlxid34ndo5KA5+W+f2y/5TxIYFYUWbi9tL8+yn5E01bLyD5D4X/6MzE3TqRYMoHb9x 4X3REtxyX0hyAIdvP3OIc0Qg82eqgL+L6chhbSjQLO2na+a25DRdhAJ5vpgw8JKnznaP sMXlLiKk9IbHIWQsXLJ+v+m6sHHUyoYVV6uqe+b5AHRippn1qs5xevBHq9xf5J4drBxE quiQ== 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=2m9R9NREa9VGalybY5Mom3wHFgPLYsbrTO9tvJbZ0FA=; b=H0zhj+bnbFgSAHKVUgIWr9eQKOg9zW3/BF5uUutofhF7q567Saa/pPX0R74bTvIlKS iFF8V6tU8j6X7atNdb6BKApmENtpIpqDVNOGY7YJpAK37cuyIG8Ce1/Y1qsbBzm6mPC/ qaP5RvNNgsJ26vH9tPTn9NDImKoCvHO/Ir7XdTwivmYRQDYhyoiwLc9W+aD5J84qWk2W tyE/ImlbaGOjnS/F/DxoJjFcoIm9LNkmQGuPFDixfPd1xtmWEH3dhyoezGClUyhgt+NW L4Aakjsib7koxNu9sg9yUCCscYeIkVcrqau4e1SIJOk6LqAUbmxx4bJyfGczVdNDT2Ag M1Dg== X-Gm-Message-State: APjAAAUqlxYekLvhrbfqZltKZTkiP+zvkKMEgOvfAWxKkfme4ri7T80i AL6JxvFNwPUZ5jt73oWf2sY= X-Received: by 2002:a62:1ac3:: with SMTP id a186mr45206215pfa.48.1553848135423; Fri, 29 Mar 2019 01:28:55 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id a65sm3867408pgc.72.2019.03.29.01.28.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 01:28:54 -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 V3 3/3] USB: serial: f81232: implement break control Date: Fri, 29 Mar 2019 16:28:42 +0800 Message-Id: <1553848122-1227-3-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553848122-1227-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1553848122-1227-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) --- 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 e7862997b6e4..9377b827313a 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