This article describes how to enable the GPIO support in SPL for i.MX 93 and how to use the associated library.
| Bank | Registers' Base Address |
| GPIO1 | 0x47400000 |
| GPIO2 | 0x43810000 |
| GPIO3 | 0x43820000 |
| GPIO4 | 0x43830000 |
Tests performed using the LF6.12.20-2.0.0 BSP, but should work similarly in other versions.
Enable the CONFIG_SPL_GPIO through menuconfig.
Make sure the chosen GPIO pin is not used by any other peripheral, by checking U-Boot's device tree (example: imx93-11x11-evk.dts and its included files). If used, disable the conflicting peripheral in the device tree.
To identify the exact macro associated to the GPIO functionality, please check the arch/arm/dts/imx93-pinfunc.h file.
This pin is not used by other peripheral, so there is nothing to disable.
To use the pin with the GPIO functionality, the following pin muxing must be added in the iomux node of the imx93-11x11-evk.dts file (located in dts/upstream/src/arm64/freescale/
pinctrl_hog: hoggrp {
fsl,pins = <
MX93_PAD_GPIO_IO05__GPIO2_IO05 0x51e
>;
};
Note: 0x51e represents the value you want in the PAD register (SW_PAD_CTL_PAD_GPIO_IO05). You may configure it as you want.
In our BSP, by default, this pin is used by the SAI1 peripheral. To use this pin as GPIO, SAI1 must be disabled in device tree.
&sai1 {
status = "disabled";
};
To use the XSPI1_TXC pin with the GPIO functionality, the following pin muxing must be added in the iomux node of the imx93-11x11-evk.dts file (located in dts/upstream/src/arm64/freescale/
pinctrl_hog: hoggrp {
fsl,pins = <
MX93_PAD_SAI1_TXC__GPIO1_IO12 0x51e
>;
};
In the file you want to use the GPIO, include the following headers:
#include <asm/arch-mx7ulp/gpio.h>
#include <asm-generic/gpio.h>
To define the GPIO's handle, use the IMX_GPIO_NR(bank, index) macro.
| GPIO Bank | bank value for IMX_GPIO_NR |
| GPIO1 | 4 |
| GPIO2 | 1 |
| GPIO3 | 2 |
| GPIO4 | 3 |
#define TIMED_GPIO IMX_GPIO_NR(1, 5)
#define TIMED_GPIO IMX_GPIO_NR(4, 12)
gpio_request(TIMED_GPIO, "timed_gpio");
gpio_direction_input(TIMED_GPIO);
int val = gpio_get_value(TIMED_GPIO);
printf("GPIO value is %d\n", val);
gpio_request(TIMED_GPIO, "timed_gpio");
// set the pin as output and make it high
gpio_direction_output(TIMED_GPIO, 1);
The driver used is drivers/gpio/gpio-uclass.c.