Message ID | 20240226134656.608559-1-arturas.moskvinas@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-81527-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2085057dyb; Mon, 26 Feb 2024 05:47:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVAO/zQXvjFafMen0lRC7EnbMaFZHc3h1wNeXR068EYh5Fn8BFpjtiVniXtoA+C5vOTSHeUguVvuq67TfM3KistNwpeyg== X-Google-Smtp-Source: AGHT+IHAdaWV9KdUru2775/SPzwqSQpFRxBfZxgD98igTspLmyh6KaN4lcyFmqsP1DeSUBrFczbe X-Received: by 2002:a1f:dfc4:0:b0:4ca:f519:c25f with SMTP id w187-20020a1fdfc4000000b004caf519c25fmr3436940vkg.9.1708955270901; Mon, 26 Feb 2024 05:47:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708955270; cv=pass; d=google.com; s=arc-20160816; b=AIHvCaUqBlWHStnUHmJX/HDrByfmCnsJcLiRGPbGnz/L33HGHb5EyZG0Nap6acZTDK hczc1lQ1XYTAKLtpLoRWFURk6ei23lqzfOmTlRVnoB9dGt/clKgyyksAmQDsQN1Ni/eI EgQB+JesUL2wvWbJOMwrBZc46pAN9mrlHkhJ9ePAfbRoG6RWacn+oGehqmFl6qmIKYAq a5yY2LEyrb7iUi877SSMqtGztPCd9qfubHqYgPz3pMFth9OXvPukgcAZfqCXTzM9yP22 WeYk6VH+xLTHaLhbiigjPSlhUjSVN9bQFqNKR8DSA2wSWsQrvaNRTTxrq2NJ4kd3pBa7 6cJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=gSizykDxdC8x5yUdc/x3m/4mR390jcmCw+184ntuZ5s=; fh=ZklkTfC0Hb1UKdYlYsiwXEVtAorqFjezQjvMXQzksuk=; b=Y37qkv5cKBGH85NkI8/xK9Rp+ihMA3E/Bjr+qqGfWK8ZC9YJPoA/kd645GuzuRJwg5 qCiu5Pu8aJBYAE/LwSPTcLi1YS+W8/IxiBrU+E7myYSxyRLwu0dKcqXfI0ytaFDG65Bq ehGXh8f/fVuWh4plUm5ZKTL3DeJF6EpoAiz8dx2iqx5XqTExYF2t06pgjjvjdPA2Qc2u 7ZIGALMMYuWc8rk+KTTKe8gMWdZqnpmKAH0C25pGcYFqO0/rbWtsJh5E9w6XG07AZCKN DejS1Ky0IlNMPeCdxPCiEmpFm7b99mFi8yPyDs2NsggAfxULVV3byNR3tS3voeiqoWeE lQ+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GsRnmU4w; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-81527-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81527-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gw12-20020a0562140f0c00b00690062e6bf9si2635929qvb.597.2024.02.26.05.47.50 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:47:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81527-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GsRnmU4w; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-81527-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81527-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AA9481C23D7D for <ouuuleilei@gmail.com>; Mon, 26 Feb 2024 13:47:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 233F812AACF; Mon, 26 Feb 2024 13:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GsRnmU4w" Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE7F612883D; Mon, 26 Feb 2024 13:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708955232; cv=none; b=YrtKuMYDCAQZt4O432Js41OCYjNulGvKNzXdjQQjJU5QdEf8r208VP973Dg++Xu74yYRAHWQ+GbHm19/Qfs9cIYSPEOal2qu7GwWOL6cHXD3stiWLqxnNNeZ88kSTeLKu8T8gqAb2qVOFCS0pXxSWdQQAYfhqW/2pzzxh2+3JR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708955232; c=relaxed/simple; bh=emmNAZR0TiWv4VK6jP9M06m7OTVL5Q43QTl22ARJLOU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZkJIbLwj6nnT+arUHamK81NACtAAIJPEOpKgqCzWXL6FsQpcxK2xAeYX88NOpZCeiL4hqW6OL9YhEMhsMADle+pForufH3FGjcHDy7ZeelKEYbpvmlYflVPAG0qIYwsjyic4fewYpSi1Iq9pNIA/kE6znnnA69wDcU31BH4X3MM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GsRnmU4w; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-51197ca63f5so4659160e87.1; Mon, 26 Feb 2024 05:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708955229; x=1709560029; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gSizykDxdC8x5yUdc/x3m/4mR390jcmCw+184ntuZ5s=; b=GsRnmU4wqHZE87CalYzriwPOiMhj3fTw218ng1RwhX0f1XpAaGRdevLJkl/VsnxQoz 6Qt4WfkVZ7cY5qeVnDVT+/Yh7afjTLheuSJZ1pBkTex4ssUtDiyoWZJy69VUgJjyEOnI /moblCFM6cNkrzPbmX1h0M7Czc2xDc2VJcZprhMJzP2QUSVEKitOB0JYlhH9w3SYBFg4 x/HXXHY881J8EXzd3D7bfif7eJbEHKSmwYoNex0Le2esije0qgj9k6OMi6Ylo9RCxdqb NK0YpR96UIKRAtB1UXdbKpGbpKypWyIa3Sqywm5MLijHdLc3/7I3F22c9Ui+eV6fYvnU vR0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708955229; x=1709560029; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gSizykDxdC8x5yUdc/x3m/4mR390jcmCw+184ntuZ5s=; b=oupy5l7JxzS8bc2e7tgr1fCFRpvbsDhiKWqymJp/bN9L7Y2WZuD07acKiuN9028ebg unmrQqMdsqi3gqyV0UWRueRyFavYaLHlO1Smg8tI46U9EEyzuuxZ8YoNDAP8ucXeTCxx /B2Y1P1q5a1jWO2LQXxfMfgbxJ/1Yn96NOLx4KlxlglOh7JjVHom1dAvUw304U7DJ8JX J6wwGhl12fsnKu9qTxVYudnU9361J0dwQUcQByiez09Jrz4APVI254z/kqEGqMr+bwoO ycoVnt+9f1jQU6+qjDgUZZg+j3wB58eL/9MvU9M4l/1Q3X4lhP6YV2uOtxxmJcPnltjd V+BQ== X-Forwarded-Encrypted: i=1; AJvYcCVBuL723WFMHCR/sVLnB7J69M64n3v8Nz5pmi8LPNgGIjhV7ah8iZ3LB4XWQWgF+uMs78AaCSc2jiGwxjBdeq1/LhzROzRsFPOOhn8w X-Gm-Message-State: AOJu0YxNgIYizyMqWE8MuKJPAAp5LvrTZaPBFxzqChPebtJWi97N1Eyg Y6o6QUrEMM75Yp15xJXyhC/pZoL6MqcDmhR7fbB6HdPmVlv0hz4i X-Received: by 2002:ac2:4c2b:0:b0:512:bd81:80e4 with SMTP id u11-20020ac24c2b000000b00512bd8180e4mr4195304lfq.44.1708955228714; Mon, 26 Feb 2024 05:47:08 -0800 (PST) Received: from localhost.localdomain (IN-84-15-189-254.bitemobile.lt. [84.15.189.254]) by smtp.gmail.com with ESMTPSA id k24-20020a17090666d800b00a3d00616e1fsm2450012ejp.193.2024.02.26.05.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:47:08 -0800 (PST) From: Arturas Moskvinas <arturas.moskvinas@gmail.com> To: fabio.estevam@nxp.com, linus.walleij@linaro.org, brgl@bgdev.pl, u.kleine-koenig@pengutronix.de, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Arturas Moskvinas <arturas.moskvinas@gmail.com> Subject: [PATCH] gpio: 74x164: Enable output pins after registers are reset Date: Mon, 26 Feb 2024 15:46:56 +0200 Message-ID: <20240226134656.608559-1-arturas.moskvinas@gmail.com> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791969482054195629 X-GMAIL-MSGID: 1791969482054195629 |
Series |
gpio: 74x164: Enable output pins after registers are reset
|
|
Commit Message
Arturas Moskvinas
Feb. 26, 2024, 1:46 p.m. UTC
Move output enabling after chip registers are cleared.
Signed-off-by: Arturas Moskvinas <arturas.moskvinas@gmail.com>
---
drivers/gpio/gpio-74x164.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b
Comments
On Mon, Feb 26, 2024 at 03:46:56PM +0200, Arturas Moskvinas wrote:
> Move output enabling after chip registers are cleared.
Does this fix anything? If so, maybe elaborate a bit the potential behavioural
changes on the real lines.
Hello, On 2/26/24 16:01, Andy Shevchenko wrote: > On Mon, Feb 26, 2024 at 03:46:56PM +0200, Arturas Moskvinas wrote: >> Move output enabling after chip registers are cleared. > Does this fix anything? If so, maybe elaborate a bit the potential behavioural > changes on the real lines. Chip outputs are enabled[1] before actual reset is performed[2] which might cause pin output value to flip flop if previous pin value was set to 1 in chip. Change fixes that behavior by making sure chip is fully reset before all outputs are enabled. Flip-flop can be noticed when module is removed and inserted again and one of the pins was changed to 1 before removal. 100 microsecond flipping is noticeable on oscilloscope (100khz SPI bus). For a properly reset chip - output is enabled around 100 microseconds (on 100khz SPI bus) later during probing process hence should be irrelevant behavioral change. [1] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130 [2] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150 Arturas Moskvinas
On Tue, Feb 27, 2024 at 7:58 AM Arturas Moskvinas <arturas.moskvinas@gmail.com> wrote: > > Hello, > > On 2/26/24 16:01, Andy Shevchenko wrote: > > On Mon, Feb 26, 2024 at 03:46:56PM +0200, Arturas Moskvinas wrote: > >> Move output enabling after chip registers are cleared. > > Does this fix anything? If so, maybe elaborate a bit the potential behavioural > > changes on the real lines. > > Chip outputs are enabled[1] before actual reset is performed[2] which > might cause pin output value to flip flop if previous pin value was set > to 1 in chip. Change fixes that behavior by making sure chip is fully > reset before all outputs are enabled. > > Flip-flop can be noticed when module is removed and inserted again and > one of the pins was changed to 1 before removal. 100 microsecond > flipping is noticeable on oscilloscope (100khz SPI bus). > > For a properly reset chip - output is enabled around 100 microseconds > (on 100khz SPI bus) later during probing process hence should be > irrelevant behavioral change. > > [1] - > https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130 > [2] - > https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150 > > Arturas Moskvinas And this is precisely the kind of information that needs to go into commit messages. I can tell *what* you're doing by looking at the code. What I can't tell is *why*. Bartosz
On Tue, Feb 27, 2024 at 02:14:40PM +0100, Bartosz Golaszewski wrote: > On Tue, Feb 27, 2024 at 7:58 AM Arturas Moskvinas > <arturas.moskvinas@gmail.com> wrote: > > On 2/26/24 16:01, Andy Shevchenko wrote: > > > On Mon, Feb 26, 2024 at 03:46:56PM +0200, Arturas Moskvinas wrote: > > >> Move output enabling after chip registers are cleared. > > > Does this fix anything? If so, maybe elaborate a bit the potential behavioural > > > changes on the real lines. > > > > Chip outputs are enabled[1] before actual reset is performed[2] which > > might cause pin output value to flip flop if previous pin value was set > > to 1 in chip. Change fixes that behavior by making sure chip is fully > > reset before all outputs are enabled. > > > > Flip-flop can be noticed when module is removed and inserted again and > > one of the pins was changed to 1 before removal. 100 microsecond > > flipping is noticeable on oscilloscope (100khz SPI bus). > > > > For a properly reset chip - output is enabled around 100 microseconds > > (on 100khz SPI bus) later during probing process hence should be > > irrelevant behavioral change. > > > > [1] - > > https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130 > > [2] - > > https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150 > > > > Arturas Moskvinas > > And this is precisely the kind of information that needs to go into > commit messages. I can tell *what* you're doing by looking at the > code. What I can't tell is *why*. +1. Please, add this to the commit message of v2, also try to find the commit that you can mark to be fixed with help of Fixes tag.
Hello, .. > > And this is precisely the kind of information that needs to go into > > commit messages. I can tell *what* you're doing by looking at the > > code. What I can't tell is *why*. > > +1. Please, add this to the commit message of v2, also try to find the commit > that you can mark to be fixed with help of Fixes tag. Thanks for suggestion regarding Fixes! I thought maybe I should as well move whole GPIO initialization[0] down to the same place I move "gpiod_set_value_cansleep( chip->gpiod_oe, 1)" in patch v2? I think knowledge that a pin is brought up later during probing process might be forgotten later, it will slightly complicate code due to need to clean mutex though. [0] https://elixir.bootlin.com/linux/v6.7.6/source/drivers/gpio/gpio-74x164.c#L125 Arturas Moskvinas
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index e00c33310517..753e7be039e4 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -127,8 +127,6 @@ static int gen_74x164_probe(struct spi_device *spi) if (IS_ERR(chip->gpiod_oe)) return PTR_ERR(chip->gpiod_oe); - gpiod_set_value_cansleep(chip->gpiod_oe, 1); - spi_set_drvdata(spi, chip); chip->gpio_chip.label = spi->modalias; @@ -153,6 +151,8 @@ static int gen_74x164_probe(struct spi_device *spi) goto exit_destroy; } + gpiod_set_value_cansleep(chip->gpiod_oe, 1); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (!ret) return 0;