summaryrefslogtreecommitdiffstats
path: root/bsps/arm
diff options
context:
space:
mode:
authorChristian Mauderer <christian.mauderer@embedded-brains.de>2023-07-13 10:02:07 +0200
committerChristian Mauderer <christian.mauderer@embedded-brains.de>2023-07-24 14:40:49 +0200
commit5bfcad264158f28b4057df11ca51cdd76bce8fc5 (patch)
treea3538146ff3f8140e520705e99c861c8113f9533 /bsps/arm
parentimxrt/mcux-sdk: Add HREQ-related bits (diff)
downloadrtems-5bfcad264158f28b4057df11ca51cdd76bce8fc5.tar.bz2
bsps/imx*: Support more GPIO controllers
The imx-gpio driver used in i.MX and i.MXRT BSPs generates a name based on a fixed string. The original code only used one digit for the controller. With the 13 GPIO controllers of the i.MXRT1166, that isn't enough any more. This patch extends the name to two digits which should be enough for the next controller generations.
Diffstat (limited to 'bsps/arm')
-rw-r--r--bsps/arm/shared/pins/imx-gpio.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/bsps/arm/shared/pins/imx-gpio.c b/bsps/arm/shared/pins/imx-gpio.c
index 615e13da7d..8b7d09e864 100644
--- a/bsps/arm/shared/pins/imx-gpio.c
+++ b/bsps/arm/shared/pins/imx-gpio.c
@@ -33,14 +33,17 @@
#include <rtems.h>
#include <rtems/sysinit.h>
-#define IMX_GPIO_ALIAS_NAME "gpioX"
+/*
+ * Most of the time it's gpio1 or gpio13.
+ */
+#define IMX_GPIO_ALIAS_NAME "gpioXY"
/*
- * i.MX6ULL has 5, i.MX7D has 7
+ * i.MX6ULL has 5, i.MX7D has 7, i.MXRT1160 has 13 (base) + 2 (core-specific).
*
* Be careful when changing this. The attach() does a simple ASCII conversion.
*/
-#define IMX_MAX_GPIO_MODULES 7
+#define IMX_MAX_GPIO_MODULES 15
struct imx_gpio_regs {
uint32_t dr;
@@ -88,7 +91,14 @@ static void imx_gpio_attach(void)
int len;
memcpy(imx_gpio[i].name, IMX_GPIO_ALIAS_NAME, sizeof(IMX_GPIO_ALIAS_NAME));
- imx_gpio[i].name[sizeof(IMX_GPIO_ALIAS_NAME)-2] = (char)('0' + i);
+ if (i < 10) {
+ imx_gpio[i].name[sizeof(IMX_GPIO_ALIAS_NAME)-3] = (char)('0' + i);
+ imx_gpio[i].name[sizeof(IMX_GPIO_ALIAS_NAME)-2] = '\0';
+ } else {
+ imx_gpio[i].name[sizeof(IMX_GPIO_ALIAS_NAME)-3] = (char)('0' + i / 10);
+ imx_gpio[i].name[sizeof(IMX_GPIO_ALIAS_NAME)-2] = (char)('0' + i % 10);
+ imx_gpio[i].name[sizeof(IMX_GPIO_ALIAS_NAME)-1] = '\0';
+ }
path = fdt_get_alias(fdt, imx_gpio[i].name);
if (path == NULL) {