From: Jon Hunter <jonathanh@nvidia.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>, Kees Cook <kees@kernel.org>,
Mika Westerberg <westeri@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Saravana Kannan <saravanak@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andy@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Srinivas Kandagatla <srini@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Alexey Klimov <alexey.klimov@linaro.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v4 03/10] gpiolib: implement low-level, shared GPIO support
Date: Thu, 12 Mar 2026 07:28:49 +0000 [thread overview]
Message-ID: <64f6e02d-c7cb-40cb-b1fb-2d3523433c66@nvidia.com> (raw)
In-Reply-To: <CAHp75VevThmDMm6VoVB9P0YbUGGGsmgnzr2gn9=1xtJZt-kuQw@mail.gmail.com>
On 11/03/2026 20:14, Andy Shevchenko wrote:
> On Wed, Mar 11, 2026 at 8:38 PM Jon Hunter <jonathanh@nvidia.com> wrote:
>> On 12/11/2025 13:55, Bartosz Golaszewski wrote:
>
> ...
>
>> On Tegra234, the main gpio controller has a total of 164 GPIOs (see
>> the tegra234_main_ports in drivers/gpio/gpio-tegra186.c). The GPIOs
>> are assigned a index by the kernel from 0-163, but these GPIOs are
>> not contiguous with respect to the device-tree specifier.
>
> If I may ask...
>
> Why? Is it sparse because there are pads that can't be used as GPIOs?
It is purely how the different port for the GPIO controller are
configured in h/w ...
static const struct tegra_gpio_port tegra234_main_ports[] = {
TEGRA234_MAIN_GPIO_PORT( A, 0, 0, 8),
TEGRA234_MAIN_GPIO_PORT( B, 0, 3, 1),
TEGRA234_MAIN_GPIO_PORT( C, 5, 1, 8),
TEGRA234_MAIN_GPIO_PORT( D, 5, 2, 4),
TEGRA234_MAIN_GPIO_PORT( E, 5, 3, 8),
TEGRA234_MAIN_GPIO_PORT( F, 5, 4, 6),
TEGRA234_MAIN_GPIO_PORT( G, 4, 0, 8),
TEGRA234_MAIN_GPIO_PORT( H, 4, 1, 8),
TEGRA234_MAIN_GPIO_PORT( I, 4, 2, 7),
TEGRA234_MAIN_GPIO_PORT( J, 5, 0, 6),
TEGRA234_MAIN_GPIO_PORT( K, 3, 0, 8),
TEGRA234_MAIN_GPIO_PORT( L, 3, 1, 4),
TEGRA234_MAIN_GPIO_PORT( M, 2, 0, 8),
TEGRA234_MAIN_GPIO_PORT( N, 2, 1, 8),
TEGRA234_MAIN_GPIO_PORT( P, 2, 2, 8),
TEGRA234_MAIN_GPIO_PORT( Q, 2, 3, 8),
TEGRA234_MAIN_GPIO_PORT( R, 2, 4, 6),
TEGRA234_MAIN_GPIO_PORT( X, 1, 0, 8),
TEGRA234_MAIN_GPIO_PORT( Y, 1, 1, 8),
TEGRA234_MAIN_GPIO_PORT( Z, 1, 2, 8),
TEGRA234_MAIN_GPIO_PORT(AC, 0, 1, 8),
TEGRA234_MAIN_GPIO_PORT(AD, 0, 2, 4),
TEGRA234_MAIN_GPIO_PORT(AE, 3, 3, 2),
TEGRA234_MAIN_GPIO_PORT(AF, 3, 4, 4),
TEGRA234_MAIN_GPIO_PORT(AG, 3, 2, 8),
};
Each port can have upto 8 pins, but some don't. Note the last number in
the column indicates the number of pins for a port.
>> For example, in device-tree, if I have a shared-gpio with the
>> following specifier ...
>>
>> gpios = <&gpio TEGRA234_MAIN_GPIO(AF, 1) GPIO_ACTIVE_LOW>;
>>
>> The macro TEGRA234_MAIN_GPIO(AF, 1) evaluates to (23 * 8) + 1 = 185.
>
> To me it sounds like a bad design of the driver for this SoC/platform.
I am not sure why you think that. Assuming a 1:1 mapping of the kernel's
GPIO index to the GPIO controller + h/w port + 1 GPIO number seems fragile.
Jon
--
nvpublic
next prev parent reply other threads:[~2026-03-12 7:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251112-gpio-shared-v4-0-b51f97b1abd8@linaro.org>
[not found] ` <20251112-gpio-shared-v4-7-b51f97b1abd8@linaro.org>
2025-11-26 14:24 ` [PATCH v4 07/10] arm64: select HAVE_SHARED_GPIOS for ARCH_QCOM Jon Hunter
2025-11-26 14:28 ` Bartosz Golaszewski
2025-11-26 14:51 ` Jon Hunter
2025-11-26 14:54 ` Bartosz Golaszewski
2025-11-26 14:55 ` Jon Hunter
2025-11-26 15:05 ` Bartosz Golaszewski
2025-11-26 15:29 ` Jon Hunter
2025-11-26 15:33 ` Bartosz Golaszewski
2025-11-26 15:47 ` Jon Hunter
2025-11-26 16:00 ` Bartosz Golaszewski
[not found] ` <20251112-gpio-shared-v4-3-b51f97b1abd8@linaro.org>
2026-03-11 18:38 ` [PATCH v4 03/10] gpiolib: implement low-level, shared GPIO support Jon Hunter
2026-03-11 20:14 ` Andy Shevchenko
2026-03-12 7:28 ` Jon Hunter [this message]
2026-03-12 7:49 ` Chen-Yu Tsai
2026-03-12 8:41 ` Jon Hunter
2026-03-12 9:28 ` Andy Shevchenko
2026-03-13 14:18 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64f6e02d-c7cb-40cb-b1fb-2d3523433c66@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=alexey.klimov@linaro.org \
--cc=andersson@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mani@kernel.org \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=srini@kernel.org \
--cc=tiwai@suse.com \
--cc=westeri@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox