Received: by 2002:a05:6520:3645:b029:c0:f950:43e0 with SMTP id l5csp338908lki; Mon, 22 Feb 2021 07:51:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXE0qmW0mQV1XM58dd5NM7dsXXFqbFV41XPYKBCWYaMIc1TLWWcm2RLFSRAFOZhQIvxo05 X-Received: by 2002:a17:906:4088:: with SMTP id u8mr3654682ejj.208.1614009060109; Mon, 22 Feb 2021 07:51:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614009060; cv=none; d=google.com; s=arc-20160816; b=aGnJ4Hz74659l/ss5sjnU1Fbj4PxHgC4Hkc0ffyEoS4er/Aogfg4oKzgDO8ehrol95 ilIhBIzcP/7i3jub5kuttg6YvVlioSRK55SgN6heJLDGJ17aL6dUvqQyd1xXvXHqcn1c AyqdKABYZHmvIqqD6wZRON0sHZd29rA79NIGmv6/mcV/L5h2VUCnMp2OPkJufYHzCfgX h6Mah3HOP82W01XbGwOjsK6wRtLqxP7KWs61lrnGe7OABVYTRyP6B3OHF2Z3v0pTrjXM a9qIWSWJrkbFXGHSRDjwtPz+VACxPq2bZsKnXq9hoKOYMOEO0+9KrfuDv0SByjrGqp4u 4PJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mWgJbfYpBDW6zlOeWMrAOFc7vek3z2M90r88jAg/lSk=; b=iBCp8lcAtdBdqXnj7bObppZvVxntEF1F/4XhGD2LeWd4xtiztv9Q1u9PJKDD6rBieV uJRvJ2qjsbJf02eZs01EFt6rQbK3WXtQ84HrtKUFDhGYtkjxI0/c71W5gfHjfbCo/Gqt aLEM7MlmSbaFRELe545/pc534KMAkKR9+CGQ01XRnh7NiFGBDVSiMfMkf3xnY8QUVxfm cRaYse665U1fVF4GAiscFru3hj3vwN+c4A3BGgWidBTrTGFi4PyHJIUX/HhZqCfqIB9A NTppnNp4rd1kkK4xB1WUZnCrB6Y1DkiQbqNJ0NO32loXzWTXWpxgUWRxFG87+Vw4lcfg 9yjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vx3pCzUi; 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 l6si12092344ejd.115.2021.02.22.07.50.36; Mon, 22 Feb 2021 07:51:00 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vx3pCzUi; 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 S231222AbhBVPsM (ORCPT + 99 others); Mon, 22 Feb 2021 10:48:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:60546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbhBVPsD (ORCPT ); Mon, 22 Feb 2021 10:48:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 630CF64E24; Mon, 22 Feb 2021 15:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614008840; bh=fShdMEHqdIYWDkjLvCRnUwkQHgDcPkfwGLHGj2lnCkE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Vx3pCzUiOBzlJMLnzrPdg9Tzl/PKzBUEqIt7/jVbm5S/c3me0Ha1BIXGvo7p97SSa ryb32uJxHikBtil+E3AJi1luyD+KL3gpivhT2HdIkwsVvHYWN8kMDL1EuggbUdKTmI 7Th7xo6Sax+LyK+x+K2qBza00mbbaKaRVYw24IRhdsOdhq0Wf/JdwzQyPEiIYgvAj8 lgPY3aMIUBRsjw5/Lj0SRDVBp7wLmTEoRPy3yhA3qD6WzG+RTrYvmo0Pe9nlNBPcJ/ AAutriZcyiNWZXXlgtGrF8NueVd4pnn/Id3XcO05I7IkFB9yGwA1OM0YaLmjjtBb2o UaotkCPKqJvOg== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lEDQu-00063s-7N; Mon, 22 Feb 2021 16:47:36 +0100 Date: Mon, 22 Feb 2021 16:47:36 +0100 From: Johan Hovold To: Mauro Carvalho Chehab Cc: Manivannan Sadhasivam , gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, patong.mxl@gmail.com, linus.walleij@linaro.org, angelo.dureghello@timesys.com Subject: Re: [PATCH v5 1/3] usb: serial: Add MaxLinear/Exar USB to Serial driver Message-ID: References: <20201122170822.21715-1-mani@kernel.org> <20201122170822.21715-2-mani@kernel.org> <20210126154604.GC29751@thinkpad> <20210222161119.0bd70a2b@coco.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210222161119.0bd70a2b@coco.lan> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 22, 2021 at 04:27:34PM +0100, Mauro Carvalho Chehab wrote: > Hi Johan, > > Em Tue, 26 Jan 2021 17:26:36 +0100 > Johan Hovold escreveu: > > > On Tue, Jan 26, 2021 at 09:16:04PM +0530, Manivannan Sadhasivam wrote: > > > On Thu, Jan 21, 2021 at 11:19:24AM +0100, Johan Hovold wrote: > > > > On Sun, Nov 22, 2020 at 10:38:20PM +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. > I'm now facing an issue with this driver. I have here two different > boards with those USB UART from MaxLinear/Exar. > > The first one is identical to Mani's one: > USB_DEVICE(0x04e2, 0x1411) > The second one is a different version of it: > USB_DEVICE(0x04e2, 0x1424) > > By looking at the final driver merged at linux-next, it sounds that > somewhere during the review of this series, it lost the priv struct, > and the xr_probe function. It also lost support for all MaxLinear/Exar > devices, except for just one model (04e2:1411). > > The original submission: > > https://lore.kernel.org/linux-usb/20180404070634.nhspvmxcjwfgjkcv@advantechmxl-desktop > > And the manufacturer's Linux driver on their website: > > https://www.maxlinear.com/support/design-tools/software-drivers > > Had support for other 12 different models of the MaxLinear/Exar USB > UART. IIRC Manivannan only had access to one of these models and his original submission (based on the patch you link to above) didn't include support for the others. And keeping the type abstraction didn't make sense for just one model. > Those are grouped into 5 different major types: > > + init_xr2280x_reg_map(); > + init_xr21b142x_reg_map(); > + init_xr21b1411_reg_map(); > + init_xr21v141x_reg_map(); > + > + if ((xrusb->DeviceProduct & 0xfff0) == 0x1400) > + memcpy(&(xrusb->reg_map), &xr2280x_reg_map, > + sizeof(struct reg_addr_map)); > + else if ((xrusb->DeviceProduct & 0xFFF0) == 0x1420) > + memcpy(&(xrusb->reg_map), &xr21b142x_reg_map, > + sizeof(struct reg_addr_map)); > + else if (xrusb->DeviceProduct == 0x1411) > + memcpy(&(xrusb->reg_map), &xr21b1411_reg_map, > + sizeof(struct reg_addr_map)); > + else if ((xrusb->DeviceProduct & 0xfff0) == 0x1410) > + memcpy(&(xrusb->reg_map), &xr21v141x_reg_map, > + sizeof(struct reg_addr_map)); > + else > + rv = -1; > > Note: Please don't be confused by "reg_map" name. This has nothing > to do with Linux regmap API ;-) > > What happens is that different USB IDs have different values for > each register. So, for instance, the UART enable register is set to > either one of the following values, depending on the value of > udev->descriptor.idProduct: > > xr21b140x_reg_map.uart_enable_addr = 0x00; > xr21b1411_reg_map.uart_enable_addr = 0xc00; > xr21v141x_reg_map.uart_enable_addr = 0x03; > xr21b142x_reg_map.uart_enable_addr = 0x00; > > There are other values that depend on the probing time detection, > based on other USB descriptors. Those set several fields at the > priv data that would allow to properly map the registers. > > Also, there are 4 models that support multiple channels. On those, > there are one pair of register get/set for each channel. > > - > > In summary, while supporting just 04e2:1411 there's no need for > a private struct, in order to properly support the other models, > some autodetection is needed. The best way of doing that is to > re-add the .probe method and adding a priv struct. > > As I dunno why this was dropped in the first place, I'm wondering > if it would be ok to re-introduce them. Sure. It was just not needed if we were only going to support one model. > To be clear: my main focus here is just to avoid needing to use > Windows in order to use the serial console of the hardware with > the 0x1424 variant ;-) > > I can't test the driver with the other hardware, but, IMHO, instead > of adding a hack to support 0x1424, the better (but more painful) > would be to re-add the auto-detection part and support for the > other models. Sounds good to me. Johan