summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-07-10 22:11:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-07-15 08:41:39 +0200
commit20f2c4ee27955bb43a629715de9734211885adf1 (patch)
treed404eeba471572c3f277df0028d8d1316ac69479 /include
parentaf66ec677c40dfaed68a124d21dd59d5f8c63381 (diff)
downloadbarebox-20f2c4ee27955bb43a629715de9734211885adf1.tar.gz
barebox-20f2c4ee27955bb43a629715de9734211885adf1.tar.xz
gpio: allow for arch-specific ARCH_NR_GPIOS > 256
Some architectures have non-contiguous GPIO ranges where some GPIOs can have identifiers exceeding the hardcoded ARCH_NR_GPIOs of 256. One such example is the STM32MP, whose gpioz controller has identifiers that go up to ('Z' - 'A' + 1) * 0x10 - 1 = 415. Instead of increasing the array size for all architectures or doing some sort of packing, allow architecture to define their own overriding CONFIG_ARCH_NR_GPIO like the kernel does. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/gpio.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/gpio.h b/include/gpio.h
index e822fd5347..1926edeca7 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -45,7 +45,11 @@ static inline int gpio_direction_active(unsigned gpio, int value)
}
#endif
+#if defined(CONFIG_ARCH_NR_GPIO) && CONFIG_ARCH_NR_GPIO > 0
+#define ARCH_NR_GPIOS CONFIG_ARCH_NR_GPIO
+#else
#define ARCH_NR_GPIOS 256
+#endif
static inline int gpio_is_valid(int gpio)
{