Thread (30 messages) 30 messages, 7 authors, 2022-08-31

Re: [PATCH] gpio: Allow user to customise maximum number of GPIOs

From: Arnd Bergmann <arnd@arndb.de>
Date: 2022-08-17 17:46:56
Also in: linux-arch, linux-doc, linux-gpio, lkml

On Tue, Aug 9, 2022 at 12:40 PM Christophe Leroy
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
At the time being, the default maximum number of GPIOs is set to 512
and can only get customised via an architecture specific
CONFIG_ARCH_NR_GPIO.

The maximum number of GPIOs might be dependent on the number of
interface boards and is somewhat independent of architecture.

Allow the user to select that maximum number outside of any
architecture configuration. To enable that, re-define a
core CONFIG_ARCH_NR_GPIO for architectures which don't already
define one. Guard it with a new hidden CONFIG_ARCH_HAS_NR_GPIO.

Only two architectures will need CONFIG_ARCH_HAS_NR_GPIO: x86 and arm.

On arm, do like x86 and set 512 as the default instead of 0, that
allows simplifying the logic in asm-generic/gpio.h

Signed-off-by: Christophe Leroy <redacted>
---
 Documentation/driver-api/gpio/legacy.rst |  2 +-
 arch/arm/Kconfig                         |  3 ++-
 arch/arm/include/asm/gpio.h              |  1 -
 arch/x86/Kconfig                         |  1 +
 drivers/gpio/Kconfig                     | 14 ++++++++++++++
 include/asm-generic/gpio.h               |  6 ------
 6 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
index 9b12eeb89170..566b06a584cf 100644
--- a/Documentation/driver-api/gpio/legacy.rst
+++ b/Documentation/driver-api/gpio/legacy.rst
@@ -558,7 +558,7 @@ Platform Support
 To force-enable this framework, a platform's Kconfig will "select" GPIOLIB,
 else it is up to the user to configure support for GPIO.

-It may also provide a custom value for ARCH_NR_GPIOS, so that it better
+It may also provide a custom value for CONFIG_ARCH_NR_GPIO, so that it better
 reflects the number of GPIOs in actual use on that platform, without
 wasting static table space.  (It should count both built-in/SoC GPIOs and
 also ones on GPIO expanders.
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 53e6a1da9af5..e55b6560fe4f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -14,6 +14,7 @@ config ARM
        select ARCH_HAS_KCOV
        select ARCH_HAS_MEMBARRIER_SYNC_CORE
        select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+       select ARCH_HAS_NR_GPIO
        select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
        select ARCH_HAS_PHYS_TO_DMA
        select ARCH_HAS_SETUP_DMA_OPS
@@ -1243,7 +1244,7 @@ config ARCH_NR_GPIO
        default 352 if ARCH_VT8500
        default 288 if ARCH_ROCKCHIP
        default 264 if MACH_H4700
-       default 0
+       default 512
This list should be kept sorted, otherwise you still get e.g. the '264' default
value. If you have a GPIO extender that provides hardcoded GPIO
numbers on your machine, there should be a configuration option for
that driver.

Which driver is it that needs extra hardcoded GPIO numbers for you?
Have you tried converting it to use GPIO descriptors so you don't
need the number assignment?

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help