Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1023712iog; Wed, 15 Jun 2022 18:39:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sdocA4V/3K45efvg0xNn36EvTQJF8ACgVUB3iPxunbOe9WCTxsDXVUUZAhOqU6gJC9fDPh X-Received: by 2002:a05:6402:28a9:b0:42d:cde1:cf87 with SMTP id eg41-20020a05640228a900b0042dcde1cf87mr3445189edb.368.1655343541703; Wed, 15 Jun 2022 18:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655343541; cv=none; d=google.com; s=arc-20160816; b=cvXNAVpB6t4x4u5+D4D0KxnoEDJQga2H0ZSW+ItEn3VYJ0L9UXlt0IDOKKp5sdcagG vCHMCKGhbIt/zaCSyfTP0gVB0U+4jVIRDFt9bPpnMh13sn43FFYdzZfYmTiTyFr1vvYC 19qUSb+OkaZhOCF6+hYmPodm7dfzvVaR2UnbNcR7m9A7VY5LfQyTzSd9HO4fdE70QofQ 972xgRcnyLXqBHtFxqzgNoZ9jfk2wAVlYb6x2EEu6QRnggnGfL2IhL2egToCPba3FrGw Y54XBA9YM4sHJVD4PTAHbgL3e8bbLe/I+OcmPMGC1bK9QXEzQWYznP4wvLTV28vuI68H gpVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=mx4obtfawl1q9xY31hUipoe+nMJ3xbQaSUJkskA22o0=; b=v02Bf3QK1EP6LeF8+pyBIIvLaYh6s2tSnD6pX5ZXEeMnNVaQXaT1k7TL/Bm1f7HYhw Aw8/sYV4ytexR6fNMSlS/MjkznltOCcniJ1Id1nwiRAkWNkQ3i4GQXywpQNQeBIodiTu X0UW+h6M6P0ySH/IPLc7kkUVD4wD0FwMb79ecIs3ANL6zedLkcnOLSG7mUnWt+49MMKu gBUo515bfQaZkYG6udPlSUH1ssQ/ouFGwGHd1oyDx5WvnMfKOQUMmxntYPw8PreeEhtN dECyCVYl8dCHQAQ57nnc8//6V7lfgtcJLwQ9neo7ETi64MGYKjzZs/Aqfx63iXeTnFuz a53Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a50eb0a000000b0042dc982357fsi899082edp.156.2022.06.15.18.38.36; Wed, 15 Jun 2022 18:39:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350610AbiFPBXI (ORCPT + 99 others); Wed, 15 Jun 2022 21:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236585AbiFPBXG (ORCPT ); Wed, 15 Jun 2022 21:23:06 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 667962229E; Wed, 15 Jun 2022 18:23:04 -0700 (PDT) Received: (Authenticated sender: frank@zago.net) by mail.gandi.net (Postfix) with ESMTPSA id CF658100006; Thu, 16 Jun 2022 01:22:59 +0000 (UTC) Message-ID: <825b7446-b082-8c6c-7cb0-f97a19bf0862@zago.net> Date: Wed, 15 Jun 2022 20:22:57 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v5 3/3] i2c: ch341: add I2C MFD cell driver for the CH341 Content-Language: en-US To: Wolfram Sang , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Bartosz Golaszewski , Johan Hovold , linux-usb@vger.kernel.org, Lee Jones , Linus Walleij , linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org References: <20220401023306.79532-1-frank@zago.net> <20220401023306.79532-4-frank@zago.net> From: Frank Zago In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wolfram, On 5/21/22 07:03, Wolfram Sang wrote: > Hi Frank, > > I am not super familiar with USB drivers, so mostly some high level > review questions first: > > On Thu, Mar 31, 2022 at 09:33:06PM -0500, frank zago wrote: >> The I2C interface can run at 4 different speeds. This driver currently >> only offer 100MHz. Tested with a variety of I2C sensors, and the IIO > > 100kHz. > >> subsystem. >> >> Signed-off-by: frank zago > > ... > >> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig >> index a1bae59208e3..db9797345ad5 100644 >> --- a/drivers/i2c/busses/Kconfig >> +++ b/drivers/i2c/busses/Kconfig >> @@ -1199,6 +1199,16 @@ config I2C_RCAR >> >> comment "External I2C/SMBus adapter drivers" >> >> +config I2C_CH341 >> + tristate "CH341 USB to I2C support" >> + select MFD_CH341 > > Hmm, it selects a symbol which depends on USB. Not good AFAIK. I think > this driver should depend on MFD_CH341. I've been asked earlier to change it to select. >> + >> +/* >> + * The maximum request size is 4096 bytes, both for reading and >> + * writing, split in up to 128 32-byte segments. The I2C stream must >> + * start and stop in each 32-byte segment. Reading must also be split, >> + * with up to 32-byte per segment. >> + */ >> +#define SEG_COUNT 128 > > You mean between every 32 bytes, there is a START and STOP condition on > the bus? Then, the maximum message size is 32 byte only, sadly. Or did I > misunderstand? I've tried to reword that section. The usb command is up to 4kb, but each 32-byte section is a command to the chip, not i2c. > > Can the driver send an arbitrary number of messages within one transfer? > E.g. write, read, read, write, read? All connected with a REPEATED START > and not with STOP and START? Yes it can. > > ... > >> +static u32 ch341_i2c_func(struct i2c_adapter *adap) >> +{ >> + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; >> +} > > Have you also tested zero length messages AKA SMBus Quick commands? Not properly at the time, although this didn't break the driver. I've fixed that by adding the special case. Regards, Frank