Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6582039rwr; Tue, 25 Apr 2023 00:09:21 -0700 (PDT) X-Google-Smtp-Source: AKy350bY+89Dq6QSta3Oe9Y5XxYtfTdC8gO2myli511tTw73YXh9VzRwI8sTcB4isnAwi8c8rR1P X-Received: by 2002:a17:90b:1957:b0:23d:376a:c2bc with SMTP id nk23-20020a17090b195700b0023d376ac2bcmr15270549pjb.5.1682406560829; Tue, 25 Apr 2023 00:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682406560; cv=none; d=google.com; s=arc-20160816; b=fa55aPwA+BlMyvaGAdpIVvG53gCz4igvqqrQ/2Kvc9iddI3dcenLnvZ6d66eLIy0o8 g/kWKrVYxup9tqyDnWgqAJmhYS5bBAgqTJBxSzxYa+8HFpM3LeqmSqKdSGs2idE28SPi qHGuX+7g5hxBHee61f9sqVDV7TOdAmM5VXcLTqm9ng1p8SPsgGWRItVmnk7MV5Hahm/m qeW9uwhMq/gHVGTtkaE0aS03IpgcbA0fefWl+iOBPwRwvgATU/0YdnkFz9cd1gqMoCxU +uLylwpDk/2yeGwl340nvNJlOeT8+Mvsedxjpcj718siY4uAVBmeXYmW/JuCAE3/56um 11ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature; bh=SbS0Ugw2E1q/i5hFAet8Qn6Xp5oVn/NtBWHp48iBMIw=; b=gki7vokTbC0kt7nn9nQNd3beodClfYzLUWncpb8V8e1gZx3Guf+1uRRoGKG7GOHwnw NynOJPm0yy+pTil9mgJccC9mmjZeMpl3uslGXmoKrgm09WwGZvZgfNkjEZDoH0m8mn0W HSdW5EjSi3t/Aac/lu7u76WDkhRZ2SwraFRPZsZbjTxo2PDSpXpxJMbTB8DOu5mqeXuq jcVuDC+dmENepAT5weEbYOr7LnU7ttvmemMbIhFzPafTAqU0supu9IRJ03r/U8undsrV zhfDA6RCwiA8+GLPjKNgNohG5jd8IrKnQhaPQFT1gvc07KrTQsXH375JckkUe9NqJCBL eabA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=UTdmkLZ5; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 13-20020a17090a08cd00b002467062c312si15010168pjn.128.2023.04.25.00.09.09; Tue, 25 Apr 2023 00:09:20 -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; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=UTdmkLZ5; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233407AbjDYHFp (ORCPT + 99 others); Tue, 25 Apr 2023 03:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232831AbjDYHFn (ORCPT ); Tue, 25 Apr 2023 03:05:43 -0400 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EA2B4ED5; Tue, 25 Apr 2023 00:05:41 -0700 (PDT) Received: from 3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 391E71251; Tue, 25 Apr 2023 09:05:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1682406337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SbS0Ugw2E1q/i5hFAet8Qn6Xp5oVn/NtBWHp48iBMIw=; b=UTdmkLZ5t90X4tpTJQLZ3hk/ueeXS5WL8v9xBGp7+vLFRZUXPjo2WRwc7R1m0J/TSSbwk2 haSZPdnhyMeYZ90ZE2j+BxjYrKX5B6HQwqsoxrINQMxyp1YMIPvSNp4F/x1HCRoD4GnI9B X3COdt56yWWHAc7ctkZvePiT6L1V9kuyhuO/liCKd3DkdoscVzRhNgTWbQs8QJwDco8r2A V4q6ALl9MGV8SrDT3/S03pI8KdFV5pqflM5QOeggffdWXDdnXh5JO9D9xL/OYKFfYfurwr uTEnSC/IKMFYnfkkc9/3I/jE4PHwfcQwlHx+4UqtNk8d1GIRgPt7t434lupQrQ== MIME-Version: 1.0 Date: Tue, 25 Apr 2023 09:05:36 +0200 From: Michael Walle To: "Sahin, Okan" Cc: andy.shevchenko@gmail.com, Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 2/2] gpio: ds4520: Add ADI DS4520 Regulator Support In-Reply-To: References: <20230327130010.8342-1-okan.sahin@analog.com> <20230327130010.8342-3-okan.sahin@analog.com> <25e1fda4b6df2d10444d7eca3cd0e387@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <1ff70a97dfbcaddd69029001ce99bb69@walle.cc> X-Sender: michael@walle.cc Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Am 2023-04-24 17:39, schrieb Sahin, Okan: >> Am 2023-04-09 16:25, schrieb Sahin, Okan: >>>> Fri, Apr 07, 2023 at 03:48:25PM +0200, Linus Walleij kirjoitti: >>>>> On Wed, Apr 5, 2023 at 3:57 PM Michael Walle >>>>> wrote: >>>>> >>>>> > OTOH I'm not sure the driver is doing it correctly, because it also >>>>> > seems to switch the pullup resisters together with the direction. >>>>> > I'm not sure that is correct. So there might be just one register >>>>> > involved after all and the GPIO_REGMAP should work again. >>>>> >>>>> I'm pretty sure that should be in the .set_config() callback. >>>>> >>>>> > Also, according to the datasheet this has some nv memory (to set the >>>>> > initial state of the GPIOs [?]). So it should really be a >>>>> > multi-function device. I'm not sure if this has to be considered >>>>> > right from the beginning or if the device support can start with >>>>> > GPIO only and later be transitioned to a full featured MFD (probably with >> nvmem >>>> support). >>>>> >>>>> That's a bit of a soft definition. >>>>> >>>>> If the chip is *only* doing GPIO and nvram it can be a GPIO-only >>>>> device I think. >>>>> >>>>> The precedent is a ton of ethernet drivers with nvram for storing >>>>> e.g. >>>>> the MAC address. We don't make all of those into MFDs, as the nvram >>>>> is >>>>> closely tied to the one and only function of the block. >>>> >>>> I agree with Linus. This should be part of the actual (main) driver >>>> for the chip as many >>>> do (like USB to serial adapters that have GPIO capability). >> >> You mean the gpio driver is calling nvmem_register()? Yeah I agree, >> that >> should work. >> >>> I think gpio_regmap is not suitable for this driver as Michael >>> stated. >>> https://www.analog.com/media/en/technical-documentation/data- >> sheets/ds4520.pdf >>> Please check block diagram. There are two input registers that >>> control >>> gpio state >>> so gpio_regmap does not look ok for this. Am I missing something? >> >> You mean F8/F9? That will work as they are for different GPIOs. What >> doesn't work with gpio-regmap is when you need to modify two different >> registers for one GPIO. Have a look at gpio_regmap_get() and >> gpio_regmap_set(). If the default gpio_regmap_simple_xlate() doesn't >> work >> you can use your own .xlate() op. >> > > Actually, I checked the functions that you suggested, but as far as I > understand > they might work if there would be one bit to set direction or value. > However, > this is not the case for ds4520. In other words, if I want to set the > gpio direction > as output, I need to set a corresponding bit for both F0 and F1 > registers. I can't follow. F0/F1 is for the pull-up. That was actually my initial question and Linus said, that should probably be done in a seperate .set_config operation not together with a direction change. > In the document, you can see block diagram. I do not know why, but > design is > not standard that’s why I think I can not use gpio-regmap. > >>> Also, at this point I am not planning to add nvmem support. >> >> That is a pity, because that is the whole use case for this gpio >> expander, >> no? "Programmable Replacement for Mechanical Jumpers and Switches" > > I can set "SEE" bit as "0" in the Configuration Register to write > EEPROM so it might solve > issue. If you do that unconditionally, that might wear out the EEPROM, though. -michael