Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp608358ybt; Wed, 1 Jul 2020 06:10:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcsQeIryO8888h/KXnZ0SH0OCI9sC+Pf8e/YhKpGWI/ANmSuUr/M8mcgIUNfPzbR1nByKz X-Received: by 2002:a17:906:a0f:: with SMTP id w15mr23907904ejf.332.1593609016566; Wed, 01 Jul 2020 06:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593609016; cv=none; d=google.com; s=arc-20160816; b=g5vJLa3jGeegd/Atu3XA6BfKuEv4KX5MY/CNnKGEOZBhtmN4JvuPpBDy2XauJO2sM1 36dChIwCUPXckk4E8ePuba8EV+AFBFaLqCLSmuhQUc07VfeOFeU6oXyUeOgQsnnBHguh uTwiHSfnyqMjUhjrqu8uoTblhczcZjeP1XHfB07qnnRvLQNPQYvHTm0kxCIzvIfxyS0C WiOwK5HYFh1Y51IYmHZU+C2UG0TqnznbUDL9b8pRPXSBRGSfctSEX7SlhR9gwAyXDB6y qfdSdXPEBo3JNUoBjhcMAR5XAiW5bQKnxFGKs1jzoz0cOOs/zfJJX3J9F3fbBGn+h1Td AJBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=COivOHfOocZwA37NPyRxnZREf917pes6hqCRF+dIcV4=; b=o+OjkhiuLLM1u6gLKAw349LrjfqotKgRPBsC714UEJ2BW43qT1kJti5KXae6DAw+yv pCfV/JJeHfCrat9xnhGpnbYIftAdkjDDB9IUlQKzaWGrWb7uuvS7+G/wuKXDaWjEQ7Wa /vkrwrcARvtovBXguTC7Vqr8OW8IZWdwE1COLfBsSfampPBDTiKA8TRs/FdKoCWo2pC0 BpwrMTAE2Lsb8/1kgqOpdM4UtPLvAcwMIX57geOFLMI4qqaeCj0Rr6U8Fhn5sacQ2bog xvDe8LrBYw+i4N+SOP0R8ZWcjVGPwQqPiFqrUrHOpSRSKJymmFdai3RnjYK/or+3V0+f sKJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si3733208eja.377.2020.07.01.06.09.52; Wed, 01 Jul 2020 06:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730893AbgGANJd (ORCPT + 99 others); Wed, 1 Jul 2020 09:09:33 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38677 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729402AbgGANJc (ORCPT ); Wed, 1 Jul 2020 09:09:32 -0400 Received: by mail-lf1-f65.google.com with SMTP id t9so13537481lfl.5; Wed, 01 Jul 2020 06:09:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=COivOHfOocZwA37NPyRxnZREf917pes6hqCRF+dIcV4=; b=t9lLcwTs0aM805no82txbKBtvbxqo1+q29NXY2JZ/7w5GAh0CUyJcm7dlZQmUCMnZk PbmMmfKEMIjql3qF7iDnYJ7GEUTr0w4HpOco//7fw+rQFrbYoi1W1Ph3KgwwjYMAiESL UucoXcKrW6Dr+VsuKarQYOD2fhdjPdPi4rmiZPGz9880ZwMvZdPy8aZ28H9d1L+z1bJ8 OY+l6uUmt3tW27BXUjHOJhq4rFo+u5HxH06lA4NNErdoRpRdKkbZn91lI28KvjYV+d1e /GbivsAnDDKciAYi7nHBLcbjvc9o2uclmaMXiY3PbGVVYBfO0x14KtQCxfKizChNkR+7 zOwA== X-Gm-Message-State: AOAM5321jZ4q/QQmnxOCsm7HXk8Ace54UeQqPlPmJRxo6TUEoWCcjhSV qqo0gv1SmWhQzCWOk3gsJPY= X-Received: by 2002:a19:64c:: with SMTP id 73mr15464054lfg.0.1593608969420; Wed, 01 Jul 2020 06:09:29 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id v24sm2035542lfo.4.2020.07.01.06.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 06:09:28 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1jqcUO-0007YY-7N; Wed, 01 Jul 2020 15:09:24 +0200 Date: Wed, 1 Jul 2020 15:09:24 +0200 From: Johan Hovold To: Manivannan Sadhasivam Cc: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, patong.mxl@gmail.com, linus.walleij@linaro.org, mchehab+huawei@kernel.org Subject: Re: [RESEND PATCH v4 1/3] usb: serial: Add MaxLinear/Exar USB to Serial driver Message-ID: <20200701130924.GE3334@localhost> References: <20200607162350.21297-1-mani@kernel.org> <20200607162350.21297-2-mani@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200607162350.21297-2-mani@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 07, 2020 at 09:53:48PM +0530, Manivannan Sadhasivam wrote: > Add support for MaxLinear/Exar USB to Serial converters. This driver > only supports XR21V141X series but it can be extended to other series > from Exar as well in future. > > This driver is inspired from the initial one submitted by Patong Yang: > > https://patchwork.kernel.org/patch/10543261/ > > While the initial driver was a custom tty USB driver exposing whole > new serial interface ttyXRUSBn, this version is completely based on USB > serial core thus exposing the interfaces as ttyUSBn. This will avoid > the overhead of exposing a new USB serial interface which the userspace > tools are unaware of. > > Reviewed-by: Greg Kroah-Hartman > Tested-by: Mauro Carvalho Chehab > Signed-off-by: Manivannan Sadhasivam > --- > drivers/usb/serial/Kconfig | 9 + > drivers/usb/serial/Makefile | 1 + > drivers/usb/serial/xr_serial.c | 650 +++++++++++++++++++++++++++++++++ > 3 files changed, 660 insertions(+) > create mode 100644 drivers/usb/serial/xr_serial.c > +static int xr_tiocmset_port(struct usb_serial_port *port, > + unsigned int set, unsigned int clear) > +{ > + struct xr_port_private *port_priv = usb_get_serial_port_data(port); > + int ret = 0; > + u8 gpio_set = 0; > + u8 gpio_clr = 0; > + > + /* Modem control pins are active low, so set & clr are swapped */ > + if (set & TIOCM_RTS) > + gpio_clr |= UART_MODE_RTS; > + if (set & TIOCM_DTR) > + gpio_clr |= UART_MODE_DTR; > + if (clear & TIOCM_RTS) > + gpio_set |= UART_MODE_RTS; > + if (clear & TIOCM_DTR) > + gpio_set |= UART_MODE_DTR; > + > + /* Writing '0' to gpio_{set/clr} bits has no effect, so no need to do */ > + if (gpio_clr) { > + ret = xr_set_reg(port, XR21V141X_UART_REG_BLOCK, > + port_priv->regs->gpio_clr, gpio_clr); > + } > + > + if (gpio_set) { > + ret = xr_set_reg(port, XR21V141X_UART_REG_BLOCK, > + port_priv->regs->gpio_set, gpio_set); > + } > + > + return ret; > +} > + > +static int xr_tiocmset(struct tty_struct *tty, > + unsigned int set, unsigned int clear) > +{ > + struct usb_serial_port *port = tty->driver_data; > + > + return xr_tiocmset_port(port, set, clear); > +} > +static void xr_dtr_rts(struct usb_serial_port *port, int on) > +{ > + if (on) > + xr_tiocmset_port(port, TIOCM_DTR | TIOCM_RTS, 0); > + else > + xr_tiocmset_port(port, 0, TIOCM_DTR | TIOCM_RTS); > +} By the way, don't you need to configure the DTR and RTS pins as outputs for the serial driver as well? According to the datasheet they are both configured as inputs by default (or at least RTS is). In any case, you'll need to reconfigure each pin after they are released by gpiolib. Johan