Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp584785rwr; Wed, 3 May 2023 03:16:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eZU6A2a+qr8YCBFTuqsF2JHBocCflJFqb5MJJV/7OFSljn9KbPw6zpeHXeunlrzlLsor4 X-Received: by 2002:a17:903:18b:b0:1aa:ea2e:7b42 with SMTP id z11-20020a170903018b00b001aaea2e7b42mr1584866plg.32.1683109015404; Wed, 03 May 2023 03:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683109015; cv=none; d=google.com; s=arc-20160816; b=dIksw3/Il78a+mZsR+LO7MaxV3NZolZxUqL6SEBwxidzsUNRhq4Fh/H7YOjE4mfSRm ipb0RZJSLXzAS8KBiXHWojUR8H4hORKlfvVWNjGqjGfT1jztwvR/WXBXPnYAzpy+3dqm KXNnSsXRqFuwGmrl+RmEvlGtLA/xJZQs/+nprpo+PBPL31BgH1+dxKqRGUi14vSG/afp kqfkk/afpbdmj6CgjiC/391rvVgEH+e3AuPbCPrFmFmCiAauNTkUm/CIgjrzsSqIU04C zz0oSHABIpuSHzaPM1crL724uma7crgKUOtpRJgWt0tKEK4SvGoa2Ztp+dF8ntsC3NeF DMhA== 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=TPDO4Om9yjcPWH9ANN/EN8sQlVWPtQhVOQp30fzdMYU=; b=C+CERUmHInk6tJmfa20bsuGDpTo1WThhVcl4hKCXpokfDNQ9vFofRIoklKpLEIGHum WxyvroNOvjX0C8fqrrUU95LMSTLaJGjy34UGuxtxQ4QfcQGkJeUWJDI3aSh/sTDCzvSA hKQ9xQDw0B49P6Do3+EZmTEOdmzimWIwFciHVDJ5o1EfsfSSAejWE/ng1A5oJ4BQQ8l8 pEBjlwd7gkqnIhL5M7Enapi6hY73qqo4tPR6T/SXxpBlnTCU3QUqEI5FB2KgdlUAALTr rcARC+JiyN7kkoiGO1wgoWuDQd3U7loVg4eX2Gp3SpDXbCoBALzW2SJqcHs2kyg0ro3a bjNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=p3mhAlx6; 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 b10-20020a170902bd4a00b001a92672eb57si31631126plx.179.2023.05.03.03.16.35; Wed, 03 May 2023 03:16:55 -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=p3mhAlx6; 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 S229698AbjECKN2 (ORCPT + 99 others); Wed, 3 May 2023 06:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjECKN0 (ORCPT ); Wed, 3 May 2023 06:13:26 -0400 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B3D8CE; Wed, 3 May 2023 03:13:24 -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 92F233EF; Wed, 3 May 2023 12:13:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1683108801; 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=TPDO4Om9yjcPWH9ANN/EN8sQlVWPtQhVOQp30fzdMYU=; b=p3mhAlx624E1Mtm8WvgkKyTUyjuOahHgpQXF5nZZyo+SHTN5KqDgeMixTXiorRE8qQAB30 wYQp/nM3+XwSugMK6j0O9lJKtchxZEhV4lqjF5Bvfq7ITplzXRwg6iVUcRse6K2NPfSDHC fOhkuL+95YK70nmOdQq5zdbVuZFiYvEgrUEAAV0egGJFiB+kBhuRIqWwbYIU5F6vl15A4H c44MijOSQazd49AD0kCVQp/eX7lIEeco9dXPCYVF3dj6idZxnto1wrOLFzxhnevYLyPZSB FsDSYFGCPEMIV3V3LHDiqstlPN3m9WC9akKH8AbFweM8YK1FeaEUFTwEutl4ZA== MIME-Version: 1.0 Date: Wed, 03 May 2023 12:13:21 +0200 From: Michael Walle To: Edmund Berenson Cc: Linus Walleij , Lukasz Zemla , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] gpio: max7317: Add gpio expander driver In-Reply-To: References: <20230403114033.8336-1-edmund.berenson@emlix.com> <20230403114033.8336-2-edmund.berenson@emlix.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <14574305d829de5befd39828b0b29cfe@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-05-03 10:37, schrieb Edmund Berenson: > On 4/4/23 16:05, Linus Walleij wrote: >> On Mon, Apr 3, 2023 at 1:41 PM Edmund Berenson >> wrote: >> >>> Add driver for maxim MAX7317 SPI-Interfaced 10 Port >>> GPIO Expander. >>> >>> v2: adjust driver to use regmap >>> >>> Co-developed-by: Lukasz Zemla >>> Signed-off-by: Lukasz Zemla >>> Signed-off-by: Edmund Berenson >> >> Notwithstanding the other comments from Bartosz, this seems like >> a driver that should be using the regmap GPIO helper library. >> git grep GPIO_REGMAP will show you examples of other drivers >> that use this and how it is used. >> >> Yours, >> Linus Walleij > > Hi, > > thanks for the review and suggestion. I tried following your suggestion > and use > GPIO_REGMAP to implement the driver. > > Unfortunately I ran into two issues > 1. reg_set_base == 0: for the devcie reg_set base is 0x0. In > gpio-regmap there > are several tests for !reg_set_base. There doesn't seem a way to > distinguish > between is set to 0 and is not set. :) That's what GPIO_REGMAP_ADDR(addr) is for :) > 2. input/output direction: to set a gpio pin to input one has to write > 0x1 to > the corresponding output register. The issue starts when I configure a > port to > be an output, set output to 0x1, check the direction of the pin, doing > so trough > sysfs the system will now assume the pin is an input and I can't set > its values > anymore. Avoiding this I would like to track the direction of the pin > separately > from the device register, which is atm done in the corresponding > bespoke in/out > functions. I can't follow you here exactly. But I've briefly looked at the datasheet and the output is an open drain one. Just like the one we are currently discussing in [1]. Here too, there seems to be no direction register, although it is mentioned in the datasheet. But Table 1. Register Address Map is super confusing, so please correct me if I'm wrong. Since we now have already two different chips with this OD output and always active input buffer, it makes sense to add support to gpio-regmap for these kind of devices. To me it is still unclear wether we need the direction at all. Linus answered my question yesterday, but I haven't found time to dig into that topic myself. Please go ahead and make some suggestions :) > I could probably solve both of these issues trough the reg_mask_xlate > function > but I believe this would introduce unneeded obscurity in the driver. > > I do not believe there are any other easy obvious/better fixes for > this. (or > maybe you prove me wrong :)) > Would you be okay for this driver to stick with direct regmap usage? > (obviously > fixing the review suggestions) -michael [1] https://lore.kernel.org/r/20230502084406.3529645-1-michael@walle.cc/