Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp136974pxj; Thu, 27 May 2021 23:45:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIJZOpT5pH8PhTF8KZ0eSDSg/jxgBE+e/mvL1PbBOtpDV7lYO7sJKpUXbKGmDEdHb/D4sg X-Received: by 2002:aa7:db90:: with SMTP id u16mr8200497edt.106.1622184304264; Thu, 27 May 2021 23:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622184304; cv=none; d=google.com; s=arc-20160816; b=m54Qlv+xShD8Ros4WRrfJJgqYYCYqDyC2PsWcC9zvJuTH1YBdN+EiN6Q6ODX8wcH7E RUJh9udotzmEeI5LbNMwdmICiqNq+CiYJisbgnftjkj2gaRWwbMyq0/FGDB5WhCfNjY4 ynOax6Nz+cGALCAhO5VU4KaFnqBIQQ3hQOP/3bsSlISwEnv5EgYwXNEmag+32LD81L/Y 2WCIkStSUSMCzfgN1lnyr3dO5elAFL3D6vJXh4iL9/LUXANyUl7LOP6v1/EDuJxB/jDC O+XGV0xjq9hg9q0S1XdxSJZXpBXvbH0P+l5saVyguKu4rw2GgLXFX/LVWkUSd049YeFs DtfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=TJWapB+0tUo0q37LUjS90NZA75MbdZkL3wrO0Uynr+g=; b=lfVGMcH0ZcmiVA/ial0C2trqnsImrA+WyyoGHTcqRECk1T/qOgOGqJ9Xe2j6LvhHWz 21FMBi7sjCtVvfOfN2zVjLkDYRrFJhOBBMqPTkSDqnb96YrEHlubcPXrGAtQNk3aMybn 7vNz4gXuqDBtCxP1vV6pROTcAgrmt/TIkWZ0JAeTsujx88B/jcgBv7e3IGlIhFGKxeL8 O00cfw/P0auBqcTzzY0ngs7kJHNexVJ069IQk/NE15fwy+ZAUa4Ps85WZhmhfaaKZc/p e+2Mj335VsxMDLrvsE1sB7GIEfvJxCsO3VPMFELbXxz2hucBCC5Z8kHjugxYtfOuv5Lq UvnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=hXMUBc4C; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf10si4096622ejc.541.2021.05.27.23.44.40; Thu, 27 May 2021 23:45:04 -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=@walle.cc header.s=mail2016061301 header.b=hXMUBc4C; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbhE1Gjb (ORCPT + 99 others); Fri, 28 May 2021 02:39:31 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:58649 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbhE1GjX (ORCPT ); Fri, 28 May 2021 02:39:23 -0400 Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 24B7422239; Fri, 28 May 2021 08:37:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1622183821; 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=TJWapB+0tUo0q37LUjS90NZA75MbdZkL3wrO0Uynr+g=; b=hXMUBc4CyuHgNf7W98vimOnGYFcF8Msy0XzII8uC8OIfxyczy25ilJTmFj12I6fHUl206b bDkzkm02Uk42a+JpzGN/wT7MEhBo2KUS1eLY2VEHZmpc+4BIjE4215yMEoQN15DwHb3SXj m9B5O++FKmuZDm9zazAkdHpI99HdZ9A= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 28 May 2021 08:37:00 +0200 From: Michael Walle To: Sander Vanheule Cc: Andy Shevchenko , 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 Subject: Re: [PATCH v3 0/6] RTL8231 GPIO expander support In-Reply-To: <02bbf73ea8a14119247f07a677993aad2f45b088.camel@svanheule.net> References: <02bbf73ea8a14119247f07a677993aad2f45b088.camel@svanheule.net> User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: michael@walle.cc Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2021-05-24 13:41, schrieb Sander Vanheule: > Hi Andy, Andrew, > > On Mon, 2021-05-24 at 10:53 +0300, Andy Shevchenko wrote: >> On Mon, May 24, 2021 at 4:11 AM Andrew Lunn wrote: >> > >> > > Changes since v2: >> > >   - MDIO regmap support was merged, so patch is dropped here >> > >> > Do you have any idea how this will get merged. It sounds like one of >> > the Maintainers will need a stable branch of regmap. >> >> This is not a problem if Mark provides an immutable branch to pull >> from. > > Mark has a tag (regmap-mdio) for this patch: > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/tag/?h=regmap-mdio > >> >> > >   - Introduce GPIO regmap quirks to set output direction first >> > >> > I thought you had determined it was possible to set output before >> > direction? >> >> Same thoughts when I saw an updated version of that patch. My >> anticipation was to not see it at all. > > The two devices I've been trying to test the behaviour on are: > * Netgear GS110TPP: has an RTL8231 with three LEDs, each driven via a > pin > configured as (active-low) GPIO. The LEDs are easy for a quick > visual check. > * Zyxel GS1900-8: RTL8231 used for the front panel button, and an > active-low > GPIO used to hard reset the main SoC (an RTL8380). I've modified > this board > to change some of the strapping pin values, but testing with the > jumpers and > pull-up/down resistors is a bit more tedious. > > On the Netgear, I tested the following with and without the quirk: > > # Set as OUT-LOW twice, to avoid the quirk. Always turns the LED on > gpioset 1 32=0; gpioset 1 32=0 > # Get value to change to input, turns the LED off (high impedance) > # Will return 1 due to (weak) internal pull-up > gpioget 1 32 > # Set as OUT-HIGH, should result in LED off > # When the quirk is disabled, the LED turns on (i.e. old OUT-LOW > value) > # When the quirk is enabled, the LED remains off (i.e. correct > OUT-HIGH value) > gpioset 1 32=1 > > Now, what's confusing (to me) is that the inverse doesn't depend on the > quirk: > > # Set as OUT-HIGH twice > gpioset 1 32=1; gpioset 1 32=1 > # Change to high-Z > gpioget 1 32 > # Set to OUT-LOW, always results in LED on, with or without quirk > gpioset 1 32=0 > > Any idea why this would be (or appear) broken on the former case, but > not on the > latter? Before reading this, I'd have guessed that they switch the internal register depending on the GPIO direction; I mean there is only one register address for both the input and the output register. Hm. Did you try playing around with raw register accesses and see if the value of the GPIO data register is changing when you switch GPIOs to input/output. Eg. you could try https://github.com/kontron/miitool to access the registers from userspace (your ethernet controller has to have support for the ioctl's though, see commit a613bafec516 ("enetc: add ioctl() support for PHY-related ops") for an example). -michael