Set pin GPIO as output with

Hello,
I am working with imx7-colibri platform.
I need to put SODIMM_32 as gpio output and I need to set It in 1 during bootiing.
Reading imx7 datasheet I got this:

32 SAI2_RXD sai2.RX_DATA[0] ecspi3.SCLK uart4.CTS_B uart2.CTS_B flextimer2.CH[6] gpio6.IO[21] kpp.COL[7] ALT5 100k PD

I read GPIO (Linux), Device Tree Customization.

I added MX7D_PAD_SAI2_RXD_GPIO6_IO21 to iomuxc:
&iomuxc {

pinctrl_gpio1: gpio1-grp {
fsl,pins = <
MX7D_PAD_EPDC_DATA09__GPIO2_IO9 0x14 /* SODIMM 89 /
MX7D_PAD_EPDC_DATA08__GPIO2_IO8 0x74 /
SODIMM 91 /
MX7D_PAD_LCD_RESET__GPIO3_IO4 0x14 /
SODIMM 93 /
MX7D_PAD_EPDC_DATA10__GPIO2_IO10 0x74 /
SODIMM 105 /
MX7D_PAD_EPDC_DATA00__GPIO2_IO0 0x14 /
SODIMM 111 /
MX7D_PAD_EPDC_DATA01__GPIO2_IO1 0x14 /
SODIMM 113 /
MX7D_PAD_EPDC_DATA02__GPIO2_IO2 0x14 /
SODIMM 115 /
MX7D_PAD_EPDC_DATA03__GPIO2_IO3 0x14 /
SODIMM 117 /
MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14 /
SODIMM 119 /
MX7D_PAD_EPDC_DATA05__GPIO2_IO5 0x14 /
SODIMM 121 /
MX7D_PAD_EPDC_DATA06__GPIO2_IO6 0x14 /
SODIMM 123 /
MX7D_PAD_EPDC_DATA07__GPIO2_IO7 0x14 /
SODIMM 125 /
MX7D_PAD_EPDC_SDCE2__GPIO2_IO22 0x14 /
SODIMM 127 /
MX7D_PAD_UART3_RTS_B__GPIO4_IO6 0x10 /
SODIMM 131 /
MX7D_PAD_EPDC_GDRL__GPIO2_IO26 0x14 /
SODIMM 133 /
MX7D_PAD_SAI1_RX_BCLK__GPIO6_IO17 0x14 /
SODIMM 24 /
MX7D_PAD_SD2_DATA2__GPIO5_IO16 0x14 /
SODIMM 100 /
MX7D_PAD_SD2_DATA3__GPIO5_IO17 0x14 /
SODIMM 102 /
MX7D_PAD_EPDC_GDSP__GPIO2_IO27 0x14 /
SODIMM 104 /
MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0x14 /
SODIMM 110 /
MX7D_PAD_EPDC_PWR_COM__GPIO2_IO30 0x14 /
SODIMM 112 /
MX7D_PAD_EPDC_SDCLK__GPIO2_IO16 0x14 /
SODIMM 114 /
MX7D_PAD_EPDC_SDLE__GPIO2_IO17 0x14 /
SODIMM 116 /
MX7D_PAD_EPDC_SDOE__GPIO2_IO18 0x14 /
SODIMM 118 /
MX7D_PAD_EPDC_SDSHR__GPIO2_IO19 0x14 /
SODIMM 120 /
MX7D_PAD_EPDC_SDCE0__GPIO2_IO20 0x14 /
SODIMM 122 /
MX7D_PAD_EPDC_SDCE1__GPIO2_IO21 0x14 /
SODIMM 124 /
MX7D_PAD_EPDC_DATA14__GPIO2_IO14 0x14 /
SODIMM 126 /
MX7D_PAD_EPDC_PWR_STAT__GPIO2_IO31 0x14 /
SODIMM 128 /
MX7D_PAD_EPDC_SDCE3__GPIO2_IO23 0x14 /
SODIMM 130 /
MX7D_PAD_EPDC_GDCLK__GPIO2_IO24 0x14 /
SODIMM 132 /
MX7D_PAD_EPDC_GDOE__GPIO2_IO25 0x14 /
SODIMM 134 /
MX7D_PAD_EPDC_DATA12__GPIO2_IO12 0x14 /
SODIMM 150 /
MX7D_PAD_EPDC_DATA11__GPIO2_IO11 0x14 /
SODIMM 152 /
MX7D_PAD_SD2_CLK__GPIO5_IO12 0x14 /
SODIMM 184 /
MX7D_PAD_SD2_CMD__GPIO5_IO13 0x14 /
SODIMM 186 */
+ MX7D_PAD_SAI2_RXD_GPIO6_IO21 0X14
>;
};

What is 0x14 number? where can I find what value I hace to set to configure It that gpio6.io21 as output?

Pin32 is used as uart2.CTS_B as default configuration? How can I reconfigure this pin as GPIO? And How can I set this pin default value?

Hope this clue helps. I don’t know much about the rest of your question.

0x14 is the equivalent of the decimal value 20.

https://www.bing.com/search?q=ox14+to+decimal&qs=NWB&pq=ox14+to+deci&sc=1-12&cvid=66D9AFB9C115406FBA14BBD1AF5BC985&FORM=QBLH&sp=1

Greetings @emmaperea,

The hexadecimal value next to each pin in the device tree is part of the pinmux settings for that particular pin. The numbers themselves are just part of how the SoC is designed. So for example 0x14 is just the standard setting for a normal GPIO in this case. If you want to know more about possible settings you’d need to check the NXP reference manual for the i.MX7.

As for Pin 32, you’d need disable the UART2 interface in the device tree. Then, you can define the pin as a GPIO in the iomuxc. Otherwise if you don’t disable UART2 then you’ll get a conflict when trying to use pin 32 for other purposes.

Best Regards,
Jeremias

1 Like

Hi Jeremias,
Thanks for you reply.
There is a way to put in high that pin (SODIM_32) without disabling uart2?
I am using uart2 tx and rx pins but I don’t use cts, there is a way to use tx and rx and set cts bit as output in “1”?

Yes you can do it without disabling Uart2 by removing MX7D_PAD_SAI2_RX_DATA__UART2_DTE_RTS from pinctrl_uart2 group.
Could you please specify which BSP version your are using as a base? In our BSPs SODIM pin 32 defined as MX7D_PAD_SAI2_RX_DATA__xxxx.

Please note that by Linux Device Tree you can specify pin as GPUIO but not its direction or state. To set that pin to HIGH state you will need to run a Linux script or some app. And it will take seconds while pin will be set to 1 after power on or reset. If you need a shorter time you can also modify a U_boot device tree and set pin direction and value in board_init(). But still can take a milliseconds. It’s recommended to use an external pull-up resistor on your carrier board to set this pin HIGH upon power ON.

1 Like

Hello Alex,

I am using 5.3.0 BSP version.

I could do It with a Linux script in u-boot but yes I need a shorter time, so I will try to set pin direction and value in board_init().

Hi @alex.tx and @jeremias.tx,
I could resolve it.
This is my solution:

+void turn_on_power_enable(void)
+{

  • gpio_request(181, “sodimm_32”);
  •    gpio_direction_output(181, 1);
    

+}

int board_init(void)
{
/* address of boot parameters */
@@ -200,6 +207,7 @@ int board_init(void)
gpio_request(FLASH_DET_GPIO, “flash-detection-gpio”);
is_emmc = gpio_get_value(FLASH_DET_GPIO);
gpio_free(FLASH_DET_GPIO);

  • turn_on_power_enable();

#ifdef CONFIG_FEC_MXC
setup_fec();

Thanks!

Glad we were able to assist you. Also thank you for sharing your solution, it may be helpful for others in the community.