Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724743pxb; Tue, 2 Feb 2021 16:47:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4tPLtUxOk0YQwV1v7q8q8D7GSvHYQYjeYXPOXNJTck+aCw4SkMfKfwvc40aRZGEW+K/lY X-Received: by 2002:a17:906:e84:: with SMTP id p4mr609823ejf.141.1612313242961; Tue, 02 Feb 2021 16:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313242; cv=none; d=google.com; s=arc-20160816; b=W+xkcIqKS919Can0DH2YwGiYDiplzQG7/vOeMVNb/XzFfW4CZh1MnoDmWGXqboTDeH EbqpidPXm1+u3bScKwyDR8psCFCIEhxXq9AWKE32kqClisd8yzpmowaz4QxfwB87b6h+ NrxdtB2v+nkUbqjziuFN5F5yiEL5u0qHAHEDCpIkT76+KLaXy3/L0wVjha+GKoMk5uuk QaTrtKaaIB9UUXVe4ShFaPFDQFvBKIB+KflsD1MwAioTviKqfmZsQ4oM+oY6iSPg3Wk5 tnd2qBVgw5mE7ZRWOPv8AdUjmUvkpFVCkL1mhfucBCr2tTaFbEpBadwCalpajGeIG0Hi fCNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Ea7rDE3iubBKRZgFdP9Rs4rz7Zn8SR/ombh7E1ZoYnk=; b=tr5HsHLNGOFKWz5zTrzbXd5qrX9Cp5YaJP5F2TOGkcxDJbB15RwxMhlk/jIDVV7bD3 SIYA3CjjDWhJOobudAC5m1Cm6+UI0Zlq1H05p0Q39Q9auj9/rCxdIxBGEksXLMZpAjhQ MYfZh0lJIZmRJrFE+pbg6PYtjlWZxGbFQoyCVr4qhTyb8meMGnPQvTj6d3MnUkBdzbBK xCtEMBxmiyjWlLyeSuTFPSeUHWyqNPfEtzXBjhHa1VClRH/cgDRS4fdS/4fW4YMeV+yt nLCNMtaLTXNslWW/9/5bMVYc0kBHM6P3k1WGVvtaLI6hnNJGvmr9WoS913mchP0YsvdJ T5XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8Axea17; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jt18si303137ejb.633.2021.02.02.16.46.58; Tue, 02 Feb 2021 16:47:22 -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=@linaro.org header.s=google header.b=J8Axea17; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbhBBTZ4 (ORCPT + 99 others); Tue, 2 Feb 2021 14:25:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238730AbhBBTW2 (ORCPT ); Tue, 2 Feb 2021 14:22:28 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC397C061786 for ; Tue, 2 Feb 2021 11:21:47 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id f2so25287706ljp.11 for ; Tue, 02 Feb 2021 11:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ea7rDE3iubBKRZgFdP9Rs4rz7Zn8SR/ombh7E1ZoYnk=; b=J8Axea178cTpmY5ApnnZ0gODAQh0DhK4vGyffddZPoBBxGiMvXjdaEl9zpqY4k7UVW 1H6Krn0JLJHIYornslY8vJtUd1GmtvwloJvdE6OmGt78ckvZWEYagNaMnka4KwiqsALX p98ovUQZrr2gPQX1MuD5RkSNZH70tu/cXQ1CYFcrpacO4AkqPBTJrec+i+rKfBKKtgUo EfP08CcascMJosb1AqjjxPWRA8b4q9Khfhhz1+HFVqmpLWWnMoHn+U37eDRiaATR06Le 4G7YSj1JK49cpQpKFWch/FnQrDdQrlT3wQZzekvOVMOkaP3vZd6Jz/vk6lPc4AZXt08H tLVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ea7rDE3iubBKRZgFdP9Rs4rz7Zn8SR/ombh7E1ZoYnk=; b=Ax314/9JUJEmacyTusazgWbp05AuezXoWiTi2DQZhyisgKYhJlPvyc3r6vGUJCdzzn kFQ1c2aJKaXKWeX5bFNFtBoGQXjZhV9EMWIJAHnOfI6eaOdgXi+4xUQWwN0vtT2mvFO3 O23uIvBoca0/M24kxsRDI1xv3TxiVNXIgVMP7g2cuq0DcJNMC+iedU8rgcHumJJlUae4 UnBQsnMm35srtbI/RoAJqr6SwFBvYRkaZLqmPIcNMqI687n2DCUhI8wiIxlZ9tBCg8fB 8GfFA3hqIvIA10b/G3rQGDgkUUM+L2D3B5xA3C0kgjTKuoXkQ046RFIRJNERiLSjSOXe YBQw== X-Gm-Message-State: AOAM5337zJOeinI6t0MqClnjEd4PzEc0GxrIE8X7POIZn29X5H6TmSDU 0J8aEqysCaMveXHaedjQ62Jou1s310MNwEUQ2Lp2gQ== X-Received: by 2002:a2e:9ec3:: with SMTP id h3mr13841334ljk.200.1612293705742; Tue, 02 Feb 2021 11:21:45 -0800 (PST) MIME-Version: 1.0 References: <20210128153601.153126-1-alban.bedel@aerq.com> <93036ef781d20df4c6017178cc545702bd0f42bc.camel@aerq.com> In-Reply-To: <93036ef781d20df4c6017178cc545702bd0f42bc.camel@aerq.com> From: Linus Walleij Date: Tue, 2 Feb 2021 20:21:34 +0100 Message-ID: Subject: Re: [PATCH] gpio: pca953x: add support for open drain pins on PCAL6524 To: "Bedel, Alban" Cc: "linux-gpio@vger.kernel.org" , "bgolaszewski@baylibre.com" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 2, 2021 at 6:45 PM Bedel, Alban wrote: > On Tue, 2021-02-02 at 14:57 +0100, Linus Walleij wrote: > > > + if (out_conf & BIT(offset / BANK_SZ)) > > > > I suppose this could be written if (out_conf & mask)? > > No, the mask in ODENn is per bank (group of 8 pins) and not per pin. Ah I see it now (confused % for / ...) > > The datasheet says: > > > > "If the ODENx bit is set at logic 0 (push-pull), any bit set to > > logic 1 > > in the IOCRx register will reverse the output state of that pin > > only > > to open-drain. When ODENx bit is set at logic 1 (open-drain), a > > logic 1 in IOCRx will set that pin to push-pull." > > > > So your logic is accounting for the fact that someone go and set > > one of the bits in ODENx to 1, but aren't they all by default set > > to zero (or should be programmed by the driver to zero) > > so that you can control open drain individually here by simply > > setting the corresponding bit to 1 for open drain and 0 for > > push-pull? > > Yes the ODENx bits are 0 by default, but the bootloader might have > changed them for example. Currently the driver doesn't do any reset so > I think it make sense to correctly handle this case as it doesn't bring > that much extra complexity. Hm. I guess you're right if that is the style of the driver overall (don't touch bootloader/reset defaults). We don't use that style for interrupt registers because we don't want interrupts to randomly fire, instead we usually disable them all so the driver and Linux keeps track on what is enabled. But for bias etc, I guess it is OK. But consider the option of just writing 0 into all the ODENx registers at probe(). I'm not gonna complain if you really want it like this though. Yours, Linus Walleij