Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1650025pxb; Mon, 22 Feb 2021 07:30:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzk8ERvGfpsggBYuzvXQXKYtSUeDvSXpWEePcyEtxt33z0CeZGT6psa2zBA1uSmSGUn2QgL X-Received: by 2002:a50:cf02:: with SMTP id c2mr22911894edk.333.1614007817149; Mon, 22 Feb 2021 07:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614007817; cv=none; d=google.com; s=arc-20160816; b=KQiSdwbFXPvhtpu73N/shyPVPbMig0u2Cb7hQe3xRk66snlY/zN9IBCR5T5GM69tGZ kTMqwxf+OUizZTa/DapiVl+OTXEbY0WPtNcCWEfUP/SEHAURrSAHXlPFWBLmf32IvZaT ZJviMPFCZzbQfzcYN/XA+bz3GSDLgX3aomObF4dWUnKORdZrIgfVyND8FzbK4rCgGCCn XkCDL66p5FqmtiEyOl5GXTc0UezNb2/9icMik6iCoz20IQiwtzwSr3BtdZQF8pinPL0+ 2pmOK3cG2botKg2HXecJVHoadroavbfJsP3sUJ1f8IEwzsTPrW2tQYuQ/j+fhyw9ttd6 6+3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=gwdH88NrIOrP/xzKkCXrjZAGKyashvM+NmYVb32287o=; b=e/54pOmSswpRUplFzeRM/BrvTjvlNxcIJ2PuNZm3g1XI8TItT01m8EmNdHFllhPcq6 9Y0zFPw35XdkDQfyZ4a7vfEpoM5P5MPdqFKOBG26HvdeysRZdoOB9UOZDZslpuj6G78E +Gwop0frKXHloytB0ZmTbnTlfA6Uj2ga/sxpLdH11tEXYZzmtF6fvOmJo7U66L2YyPoz mfN2UXLcIjuLNSoWF9m5oiUjOOT0FYB3TIA8ZE/oUSTy14uX80r9wWayyC3N41vZguRA KkKuogmxnWHvjjfJ0MiWmpOSPZkz0pZ4QIGbWTKZd9457dRwLzI3S6+HcEdploA61ZHd vMxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eO1cGdcx; 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 q19si11886600ejn.331.2021.02.22.07.29.53; Mon, 22 Feb 2021 07:30:17 -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=eO1cGdcx; 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 S231245AbhBVP3V (ORCPT + 99 others); Mon, 22 Feb 2021 10:29:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:57588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhBVP21 (ORCPT ); Mon, 22 Feb 2021 10:28:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 721A764E24; Mon, 22 Feb 2021 15:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614007659; bh=q9Estwy8/COuQq0gmoB1jzKJT7r7o9dG+aiZnsncBrg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eO1cGdcxtFayjKzpEuEQAoVVTsItSUTEV7Zy90sBssqe1fe7c30+88S3SWP65BeDs FaHGPdT3U8a7aP7pRsA7q6p+TNwGwnECaS16uEc45HOhNWAKSYkPUIwQ4y7/I6159k aa5tobVGnUsBHPNsdZ6cdBlE0cTaAXvhlHGdZEwnDs/IKpG8/3TPNUoQvxi56QmEUV AV0U3YIDdm4Y+23rTwqPIsAw/dvmWGITbs5/PWRYNVrv16OO96gidoq/ZXluQsy80m zxHbatbyHLtk1CPI8XO2thrkz/+FnfPTVpGiFu3wEvyJJssDHfJfMR7+Li7Lft1Y11 wxRteMPpsHt7w== Date: Mon, 22 Feb 2021 16:27:34 +0100 From: Mauro Carvalho Chehab To: Johan Hovold 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: <20210222161119.0bd70a2b@coco.lan> In-Reply-To: References: <20201122170822.21715-1-mani@kernel.org> <20201122170822.21715-2-mani@kernel.org> <20210126154604.GC29751@thinkpad> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > > > > > There are still a few issues with this driver, but I really don't want > > > to have to review it again in a couple of months so I've fixed it up > > > myself this time. > > > > > > The trivial stuff I folded into this patch, and I'll submit a follow-on > > > series for the rest. > > > > > > > Many thanks for doing this! These days it is really difficult to find > > time for spare time stuffs. > > > > And all of your fixes makes sense to me. > > Thanks for taking a look! Thanks for merging it! - 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. 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. 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. Thanks! Mauro