Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3578714pxj; Tue, 1 Jun 2021 08:26:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTQTtx3TWyPSN6fyTiwsf9bExNJJPecA3SPcfsaw4N7kbZtH43WXsfVCLUWGtNJNgC/xp1 X-Received: by 2002:a5e:890f:: with SMTP id k15mr11947577ioj.177.1622561211823; Tue, 01 Jun 2021 08:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622561211; cv=none; d=google.com; s=arc-20160816; b=UyZW5Z1Er0LCXzXrKfUQCt6gA+fQQ7VTxZ0ad0jsTMOMrcGsQbLhujH2BgwqSUB0gV w1xe3RE9vwnxmL5hFI3p+raFI9mkFJkbrNEor1+fpoWbB/n0XD+mtmEU18IpbaGVWRIT XuIfjiGhSRbRecNpgGFvhNKNHtgW9oyXUpg/Li5dQehpzlVFMWb0U9fxjIVU3MLwyVE2 NLZkJpFq9Gg54wxrt79DuPepAdm356rQ1korwQxv52RckQ5zlBLWY5XsnAdQzZ0SitLl oVjc00zSRVueGV844ssQHSFta9aXrKcyGqo5kziGNoDM/1DdAYETcUKPe7zhkptW5CYV Aygg== 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=anO2W9aofrOQ+Dkybd3ysZSrKPI78hxVB+Li9Pdx2qc=; b=ZiLAQU6U2OGIlPJzI1GDIyDGSGf24MjMI98ziwqMXMAxAiXg+qHN3UsgpeJjIpyvuw dezRhSHYh7ouTeZSja5WkE/UMF4Rxx+rcXjJWM3JSFqTTmtSxEAR2hyGfcl0dWccsqKo MFHM0G00KGcB6vJbBx+bFJLTRntpKdfn/9qF91wxvu7Fsx6gZPBRqo/Sqr4+3Hl2/CKF hQ9y34mndkP1PcpoBjmI79grkI/7u5DfUt8nTQjFeFC/22drA6mZgqZ5meyEKk9YFc/H X0oDLytAg9enfTqhpLCzDZnpCrDsp9Y0Q6ZcobFeG9MV6CYAns6QWLR0632SlED9Q1WB ODLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hV2dPrV4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si18375835ila.72.2021.06.01.08.26.38; Tue, 01 Jun 2021 08:26:51 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=hV2dPrV4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234451AbhFAP0M (ORCPT + 99 others); Tue, 1 Jun 2021 11:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234452AbhFAP0I (ORCPT ); Tue, 1 Jun 2021 11:26:08 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E4FC061574; Tue, 1 Jun 2021 08:24:26 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id f22so11704336pfn.0; Tue, 01 Jun 2021 08:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=anO2W9aofrOQ+Dkybd3ysZSrKPI78hxVB+Li9Pdx2qc=; b=hV2dPrV4ysDahQFf0qY0Nj959FMEXWL/8ilS7lzw1ohUJMe14XGGtg5QdDDEuMtlQc ji1JCr5AmyR9LPluOu7DyeunkwFncZpjw4Ua67PzJ2fF15UYG7xA0qbjWPDt+H+eEYlY y1SYpCrH1dUsxWbr1BslXptOgL2wavXrEZKQe6Rj+5Gk8fDhoJLeDWEZQSENy18cKBGr QziTRZG3RsSLrPdg5KCn/EIltYD+7voJfcJTb4VYwyl+VeEsLC/ZY8178i6c+sjxyt3O jAsdYivnaHrq+zbiaWV9+uDIgcNAuVAnsswNPwPc0qMoHRWQ/qs/k4IzKOSdb6SudZxZ ivrw== 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=anO2W9aofrOQ+Dkybd3ysZSrKPI78hxVB+Li9Pdx2qc=; b=nzKDO41h71NseGQo8bcbEMenHnNeCHTz9AyMz6BF8mZZLeY5caFrvbW7ehKwkQ3LNa EDR1p/XSWFPgNhDvtmHBUTPFmiI6DpzeMfEMcc9zHcB1jlxH+K2JfQZ9m0qEwlDKrsPC eozAMVbsLMNwBjY+bNt5p0dlYjeaM0WWPBO5asuyGJfAdwc1VbHRdlNUJYZOnLn5HniD yDiN5IL1M8YCFRi3WT7YchxC4sugPx2VtvAx0hHBm2uOLugZcgP4ZLMGX69QOrTwzjkp vX4vqZM+tYvBUX7Z3QFKc0MmD0m2d6mn3ee+fwoRQs3NKTsu1FU5V++tASNI2S6X1BDl /R4w== X-Gm-Message-State: AOAM532WnssVyjJB1VjdDmqwjH7ZQcMghXgS+SblZwKx/mV+AuFU4XmJ vnW8u57OE/2RuoBYYgBNFKWsdSImVXhiXtdzhrw= X-Received: by 2002:a63:79c3:: with SMTP id u186mr28741200pgc.203.1622561065990; Tue, 01 Jun 2021 08:24:25 -0700 (PDT) MIME-Version: 1.0 References: <02bbf73ea8a14119247f07a677993aad2f45b088.camel@svanheule.net> <84352c93f27d7c8b7afea54f3932020e9cd97d02.camel@svanheule.net> <7a9978881e9ec5d4b811fa6e5d355fb6bce6f6d8.camel@svanheule.net> <0047200eecbd7ee480258cc904d6b7ee@walle.cc> <272ac6af4a5ba5df4bb085617c9267e5ece61c19.camel@svanheule.net> <8df77f619730b9e7b5cdd7ddefb60a03@walle.cc> In-Reply-To: <8df77f619730b9e7b5cdd7ddefb60a03@walle.cc> From: Andy Shevchenko Date: Tue, 1 Jun 2021 18:24:09 +0300 Message-ID: Subject: Re: [PATCH 0/5] RTL8231 GPIO expander support To: Michael Walle Cc: Sander Vanheule , Hans de Goede , Andrew Lunn , Pavel Machek , Rob Herring , Lee Jones , Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Linus Walleij , Bartosz Golaszewski , Linux LED Subsystem , devicetree , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 1, 2021 at 2:49 PM Michael Walle wrote: > Am 2021-05-31 17:48, schrieb Andy Shevchenko: > > On Mon, May 31, 2021 at 6:33 PM Sander Vanheule > > wrote: > >> On Mon, 2021-05-31 at 14:16 +0300, Andy Shevchenko wrote: > >> > On Monday, May 31, 2021, Michael Walle wrote: > >> > > Am 2021-05-31 10:36, schrieb Sander Vanheule: > > > >> Am I missing something here? It seems to me like the regmap interface > >> can't > >> really accommodate what's required, unless maybe the rtl8231 regmap > >> users > >> perform some manual locking. This all seems terribly complicated > >> compared to > >> using an internal output-value cache inside regmap-gpio. > > > > Have you had a chance to look into the PCA953x driver? > > Sounds to me that you are missing the APIs that regmap provides. > > What would that be? The register cache? We need to cache the > value somehow, because (still assuming it is write only) we cannot > read it back. Thus the read of the RMW, would need get the > value from the cache. Thus the user of gpio-regmap would need > to make sure, to (a) use a cache for the regmap supplied to > gpio-regmap and (b) populate its initial values correctly. Is > that what you are suggesting? And hopefully, no other user > of the regmap will call regcache_mark_dirty() or something > like that. > > I had a quick look at the PCA953x driver but it all its > registers are readable according to the comment on the top > of the file. Since regmap doesn't have a facility to support the registers _at the same offset_ with different meaning (depending on data direction), the only way to handle this (without redesign regmap internals) is to add specific "pages" via additional bits in the address space. So, let's say 0 = RW, 1 = RO, 2 = WO. In this case see the following offset mapping of the hypothetical hardware registers: REG1 (RW) 0x00 -> 0x000 REG2 (RW) 0x04 -> 0x004 REG3 (RO) 0x08 -> 0x108 REG3 (RW) 0x08 -> 0x208 Then these bits should be masked out. Something similar is done in the PCA953x driver for extended addresses and autoincrement. This is what I propose to look at as the starter. -- With Best Regards, Andy Shevchenko