[rtems commit] bsps/imx*: Support more GPIO controllers

Christian Mauderer christianm at rtems.org
Mon Jul 24 12:25:22 UTC 2023


Module:    rtems
Branch:    master
Commit:    5bfcad264158f28b4057df11ca51cdd76bce8fc5
Changeset: http://git.rtems.org/rtems/commit/?id=5bfcad264158f28b4057df11ca51cdd76bce8fc5

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Thu Jul 13 10:02:07 2023 +0200

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.

---

 bsps/arm/shared/pins/imx-gpio.c | 18 ++++++++++++++----
 1 file 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) {



More information about the vc mailing list