Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2917392pxj; Sun, 23 May 2021 15:36:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS5Pzlu2WIJQSlBOurw+IxbWkHfHo0csPrvagw6QgUy6v2hDIfX/+fkPQ1Cl9FC5Xxjn6T X-Received: by 2002:a17:906:aac8:: with SMTP id kt8mr19704194ejb.402.1621809415002; Sun, 23 May 2021 15:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621809414; cv=none; d=google.com; s=arc-20160816; b=UptqmfvWd3A0jH2ZGanWMNvYDC0nv1sJNkL0Od9ps6I2TbWiprfLXAMklAS+Z+T7nG Tz5LURhCR6gD/OOt4FSxPOSyAqYczx3l/9ZEvw/t03QE1oRmuRIwJ7i1bC0HPQOsCYA+ OhNrrdJBYEd5pSjhEK0WJIwTlJgeptJEEJdlVCO2liA6GbveXOHfptXmk0D2bdgopqG4 MwWN5icN5vInfIjBH3Ydkv2EgUWLPmsWS27QkhX8ePqiwI2rj8q+UbhYXkalZI3Qey9K eXwUH+qm96MONGQbTSmeI100/oCxvoASDWn/QMgya/8VM6wrDDx2rFW6DhSwMxZl2jCI WBJQ== 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:dkim-signature; bh=jBeGHDP0Tz5eoqu47A7M4vJJjH5RoK+PyK940cMviYU=; b=HEVI/Vwti21VWpdAJsgHLi+bRAQYlJqw99YgaGz12Lokis7HcdDPH0/o0k5rvkU1/1 rDqcd5SQHZznMcD8qChyR+jTSUZZ/Lrb4Qfz4jCQ6Q4Mo0xnJY8mPsjWN9W4FWcreZRS 7m6e23WHy08ZELO0vmVLbOBja1WzO3iKKHqog/T1guv9WIQ4AhOlhIeIFW7afLuPH0NM F3TtRBmBk4JcBUf5JKJ7XKzej5DN80mO6Xxg8t51l7puXoRXB13mUbHeVvur0b1Pk2jz 4qzXPrYLDUS2SsmqJKiKgxfA+OrQ8c+ki2bPdsoZPocgkEKPTjR1pXb4lNTVYIZgeMio C6CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=IUDJSVE1; 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=svanheule.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gq9si11192697ejb.720.2021.05.23.15.36.03; Sun, 23 May 2021 15:36:54 -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=@svanheule.net header.s=mail1707 header.b=IUDJSVE1; 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=svanheule.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbhEWWXC (ORCPT + 99 others); Sun, 23 May 2021 18:23:02 -0400 Received: from polaris.svanheule.net ([84.16.241.116]:44406 "EHLO polaris.svanheule.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbhEWWXB (ORCPT ); Sun, 23 May 2021 18:23:01 -0400 Received: from [IPv6:2a02:a03f:eafb:ee01:bd37:7535:eb00:6fa] (unknown [IPv6:2a02:a03f:eafb:ee01:bd37:7535:eb00:6fa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id 08A33202A44; Mon, 24 May 2021 00:21:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1621808493; 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=jBeGHDP0Tz5eoqu47A7M4vJJjH5RoK+PyK940cMviYU=; b=IUDJSVE1BeBfPkWGNB/a/KeGc0ZKZoSeTrKZ782c9nTSun9G+D/R/rqpTQqcZ25m2+qbCF GBW4ptVnHawMdA80G6vXGXiCL6tk4CfTKE/p2rYA5wHke+2UCUiiQbS3NinC6ZnO29lWUU k/srPeIaRJQn04OwlA5FfcptgMgwLdp2ZJOZPZBMHaq8SwRVFnhuV9pJWab2jUIArYN6uu EhDByWCunGJ0wI9jbAQcjm6UcsMGdM2qfgfTsfV6MzJRE8af/wcmWH3BkktZV7rpqH7FED S/UxVKqVVTVMWHIZj6HaWEm3CK0nWuXg43ECZNj++1m/DBb5tjb1NzVcOfabog== Message-ID: <7536875f01b0420acb88de1ea3a48c31fdb26962.camel@svanheule.net> Subject: Re: [PATCH v2 2/7] gpio: regmap: Add configurable dir/value order From: Sander Vanheule To: Andrew Lunn Cc: Pavel Machek , Rob Herring , Lee Jones , Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Michael Walle , Linus Walleij , Bartosz Golaszewski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Andy Shevchenko , linux-kernel@vger.kernel.org Date: Mon, 24 May 2021 00:21:29 +0200 In-Reply-To: References: 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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Adrew, On Tue, 2021-05-18 at 03:40 +0200, Andrew Lunn wrote: > On Mon, May 17, 2021 at 09:28:04PM +0200, Sander Vanheule wrote: > > GPIO chips may not support setting the output value when a pin is > > configured as an input > > Could you describe what happens with the hardware you are playing > with. Not being able to do this means you will get glitches when > enabling the output so you should not use these GPIOs with bit banging > busses like i2c. As I reported earlier, using value-before-direction breaks the GPIO driven LEDs on one of my devices. I've tried to use another device to test if I could reproduce this. Using the gpioset and gpioget utilities, I can't seem to reproduce this however. Whether I enable the (new) quirk or not, doesn't seem to make any difference. The documentation we have on this chip is quite scarce, so I'm unaware of different chip revisions, or how I would distinguish between revisions. As far as I can see, Realtek's code (present in the GPL archives we got from some vendors) set the pin direction before setting the value. For now, I've made the implementation so that the quirk is always applied. Like the behaviour that is implicit in the origal code. If prefered, I could also supply a separate devicetree compatible or extra devictree flag. Regarding bit banged I2C, glitches may not actually be an issue. If a pull-up resistor is used for HIGH values, and an open drain for LOW values, the GPIO pin doesn't actually have to change value, only direction (IN for HIGH, OUT for LOW). A configuration like this would perhaps glitch once on the initial OUT-LOW configuration. Like I mentioned, bit banged I2C is frequently used in ethernet switches with these chips to talk to SFP modules. Best, Sander