Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5909163pxv; Wed, 7 Jul 2021 14:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHnJe/YlLOpNtndV3Z1ur+7FnDZuXVP+gAy5VydfzJetVQVgQkBLjyay3sI0EAqzo7kI6q X-Received: by 2002:a17:906:e088:: with SMTP id gh8mr4516786ejb.125.1625694585743; Wed, 07 Jul 2021 14:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625694585; cv=none; d=google.com; s=arc-20160816; b=LHFdEid4NkxImRANWFagb+JxDlrip1KsR7+a/5DquioVXAAJvZNcqkpIpSG2tSlNnm vKYg15/Z2ghgA14wKykFjMMocFWw+m/MNNXpIUjzaeXYKRktq1oL6a6e/qwK7KwPRrYV 1/5a7+hamzD8PNSclZEoWZ4bfWv/CUHdl9tZnCOtWLh9qDpTkFzNO32jaq5tvhJdKMwH XT6PiGis/i+pOuvb1IYuv/QddLwwUhQMPyeBOtDIJ/4S3UDcfNEjCSOdExGWTfx+tta3 GEWaKlZon2J73bape9SSMVE5sBBjInyFjTo7b02Yah7r88E80Ufrm84dJpi4EJsr1j8i U3GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=Cu+wjHGlr7rYbAKU9KAFvLVpwbt5bWsrhDW5GcK8kUY=; b=f0I16bH486dvtTF7+LMB3PBu4TkxZBvFRj9PbOTWSV9iPQue1+KDCgAH7zEqTc349T GrKCDZVmX3oZYf5Q+X+9FmxjH+UDeM1Gz8VzlwePyiDeCLBT0qo5+AqHyvkMREtoulJ3 gULEPMbrD2HPb0lhPa6kkZaYfKo8N2Kv2y0Oj4EeWAgK/+f9oXKJOdSd0YvtFqeQ0FJr ssK29gsjVS5lX1Tn0XeOJld1aXL1F+/qloW87ief4EpC0jSgmq1xQrR0/SPwBl3OD6Hw j3eHaxrygA26GqH0ZBRH0QZNC/YUFff30nN7CLacs4gRUajXEEWoQ5gNbdUNUQBBLebM dCPw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si442246ede.8.2021.07.07.14.49.20; Wed, 07 Jul 2021 14:49:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhGGU4D (ORCPT + 99 others); Wed, 7 Jul 2021 16:56:03 -0400 Received: from polaris.svanheule.net ([84.16.241.116]:50014 "EHLO polaris.svanheule.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbhGGU4D (ORCPT ); Wed, 7 Jul 2021 16:56:03 -0400 Received: from [192.168.1.109] (47.118-244-81.adsl-dyn.isp.belgacom.be [81.244.118.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id CC32522C733; Wed, 7 Jul 2021 22:53:20 +0200 (CEST) Message-ID: Subject: Re: [PATCH v5 2/8] gpio: regmap: Add quirk for aliased data registers From: Sander Vanheule To: Andy Shevchenko , Mark Brown Cc: Pavel Machek , Rob Herring , Lee Jones , Greg Kroah-Hartman , "Rafael J . Wysocki" , Michael Walle , Linus Walleij , Bartosz Golaszewski , Linux LED Subsystem , devicetree , "open list:GPIO SUBSYSTEM" , Andrew Lunn , Linux Kernel Mailing List Date: Wed, 07 Jul 2021 22:53:19 +0200 In-Reply-To: References: <5d8e5e8a29ecf39da48beb94c42003a5c686ec4e.1623532208.git.sander@svanheule.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, Mark, My apologies for the delay in replying, work has been keeping me a bit busy. On Sun, 2021-06-13 at 00:29 +0300, Andy Shevchenko wrote: > On Sun, Jun 13, 2021 at 12:13 AM Sander Vanheule wrote: > > > > Some chips have the read-only input and write-only output data registers > > aliased to the same offset. As a result it is not possible to perform > > read-modify-writes on the output values, when a line is still configured > > as input. > > > > Add a quirk for aliased data registers, and document how the regmap > > should be set up for correct operation. > > I still believe that there is no issue with gpio-regmap and we don't > need any quirk there. > > The issue is in the regmap APIs (implementation) itself. Hardware with > the concept of reading X / writing Y at the same offset is okay per > se. regmaps doesn't support it properly and should be fixed (amended) > in a way that you provide this kind of register description thru > regmap configuration or so. I've made an attempt at implementing a "regmap_aliased()", similar to "regmap_volatile()". However, this meant I had to make _regmap_read() aware of wether the read- or write-alias was being read (from cache), touching some parts of the regmap code I'm not using myself. Furthermore, this "aliased" property isn't really perpendicular to "volatile", since writes should never be volatile, and non-volatile reads don't make much sense (to me) on a read-only register. In addition to entire registers having different meanings on reads or writes, individual bitfields could also have different properties. Some bits of a register could be aliased, while other bits are just 'plain' volatile. This is the case for the last register of the RTL8231, where the low bits are GPIO data (so aliased), and the highest bit is a self-clearing "latch new data" command bit (i.e. RW-volatile). If a regmap_field could overwrite the specifiers of it's parent register, I think this may provide quite a natural solution to the aliasing problem: just create two regmap_field defintions. One definition would be 'write-only' (and cached for RMW), the other 'volatile read-only'. All regmap_fields could still rely on a single cached register value, I think. I didn't try to implement this though, so maybe I'm missing some behaviour that would disqualify this solution. Would you think this could be an acceptable way to move forward here? > I expressed the idea of trying to implement regmap-8250 as an example > of the support for such hardware. And OTOH that this kind of hardware > is not unusual. This implementation indeed requires the same aliasing support, in addition to register paging even. I've never touched that subsystem before though, so I would need some more time if I wanted to try this. Best, Sander