IOMUX GPIO configuration

Hello,
I am working with colibri-imx6ull.
Bsp version 5.6.0.
Colibri evaluation board v3.2.
For give a little context:
For hardware specifications I had to change pwm backlight pin, as defalut the backlight pwm is PWM_A taht is the pin 59. I had to change it for pin 28 that is PWM_B, I made those changes in dts and It works, the pwm backlight is pin 28 right now.
PWM_A (pin 59) I had to use It to control another thing.
I noticed that when the system is booting (whne u-boot is runnning) this pin 59 is turn on.
Cheking in colibri-imx6ull.c find this:

#ifdef CONFIG_DM_VIDEO
static const iomux_v3_cfg_t backlight_pads[] = {
	/* Backlight On */
	MX6_PAD_JTAG_TMS__GPIO1_IO11		| MUX_PAD_CTRL(NO_PAD_CTRL),
	/* Backlight PWM<A> (multiplexed pin) */
	MX6_PAD_NAND_WP_B__GPIO4_IO11		| MUX_PAD_CTRL(NO_PAD_CTRL),
};

#define GPIO_BL_ON IMX_GPIO_NR(1, 11)
#define GPIO_PWM_A IMX_GPIO_NR(4, 11)

static int setup_lcd(void)
{
	imx_iomux_v3_setup_multiple_pads(backlight_pads, ARRAY_SIZE(backlight_pads));

	/* Set BL_ON */
	gpio_request(GPIO_BL_ON, "BL_ON");
	gpio_direction_output(GPIO_BL_ON, 1);

	/* Set PWM<A> to full brightness (assuming inversed polarity) */
	gpio_request(GPIO_PWM_A, "PWM<A>");
	gpio_direction_output(GPIO_PWM_A, 0);

	return 0;
}
#endif

MX6_PAD_NAND_WP_B__GPIO4_IO11 is the pin 59, for my concern u-boot is turn on backlight, so I chenged that to use pin 28 as follow:

@@ -71,11 +78,11 @@ static iomux_v3_cfg_t const backlight_pads[] = {
        /* Backlight On */
        MX6_PAD_JTAG_TMS__GPIO1_IO11            | MUX_PAD_CTRL(NO_PAD_CTRL),
        /* Backlight PWM<A> (multiplexed pin) */
-       MX6_PAD_NAND_WP_B__GPIO4_IO11           | MUX_PAD_CTRL(NO_PAD_CTRL),
+       MX6_PAD_NAND_DQS__GPIO4_IO16            | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
 
 #define GPIO_BL_ON IMX_GPIO_NR(1, 11)
-#define GPIO_PWM_A IMX_GPIO_NR(4, 11)
+#define GPIO_PWM_B IMX_GPIO_NR(4, 16)
 
 static int setup_lcd(void)
 {
@@ -85,9 +92,9 @@ static int setup_lcd(void)
        gpio_request(GPIO_BL_ON, "BL_ON");
        gpio_direction_output(GPIO_BL_ON, 1);
 
-       /* Set PWM<A> to full brightness (assuming inversed polarity) */
-       gpio_request(GPIO_PWM_A, "PWM<A>");
-       gpio_direction_output(GPIO_PWM_A, 0);
+       /* Set PWM<B> to full brightness (assuming inversed polarity) */
+       gpio_request(GPIO_PWM_B, "PWM<B>");
+       gpio_direction_output(GPIO_PWM_B, 0);
 
        return 0;
 }

Now backlight is turn on when the u-boot run but pin 59 that is MX6_PAD_NAND_WP_B__GPIO4_IO11 is still turn on during booting.
I forced turn off the pin doing the follwing:

static iomux_v3_cfg_t const buzzer_pads[] = {
	MX6_PAD_NAND_WP_B__GPIO4_IO11		| MUX_PAD_CTRL(NO_PAD_CTRL),
};
	imx_iomux_v3_setup_multiple_pads(buzzer_pads, ARRAY_SIZE(buzzer_pads));

	/* Set PWM<A> turno off buzzer at init. */
	gpio_request(GPIO_BUZZER, "Buzzer");
	gpio_direction_output(GPIO_BUZZER, 0);

Force turn-off is working, but for 1 second the pin is in “1” till the gpio is put in “0”.
I think that I have to configure pull down resistors to the pin but I dont know hot to do it.
I know that exist a Pad control register.
I know how to configure that in dts file but I think that I have to configure It before.

MX6_PAD_NAND_WP_B__GPIO4_IO11		| MUX_PAD_CTRL(NO_PAD_CTRL)

Maybe this MUX_PAD_CTRL is where I have to do this change.
So my questions are:
How configure the pin as pull down so the pin is in “0” as default?
Where I have to do the configuration? in which file?

It depends a little on when/how you want all of this to happen. You should remove the previous config in that file for that pin. Look for GPIO4__IO11 and you might see:

/* mux auxiliary pins to GPIO, so they can be used from the U-Boot cmdline */
iomux_v3_cfg_t const gpio_pads[] = {
    /* ADDRESS[17:18] [25] used as GPIO */
    MX6_PAD_KEY_ROW2__GPIO4_IO11    | MUX_PAD_CTRL(WEAK_PULLUP) |
                      MUX_MODE_SION,

You can remove that line if you’re using the pin somewhere else.

To define it how you want, change your buzzer_pads def to:

static iomux_v3_cfg_t const buzzer_pads[] = {
	MX6_PAD_NAND_WP_B__GPIO4_IO11		| MUX_PAD_CTRL(WEAK_PULLDOWN),
};

I don’t think that pad is used for anything else downstream, but that would be the only thing to watch out for (some other code changing the control after you do).

If you don’t want to change the uboot code at all, you could run a gpio command at startup. But, that might take too long for you also.

Of course, you probably should have a physical pulldown on the board so there is no glitch whatsoever.

Good luck!

Hello @DaveM tahnks for response,
Yes I already made that:

	imx_iomux_v3_setup_pad(MX6_PAD_NAND_WP_B__GPIO4_IO11 | MUX_PAD_CTRL(PAD_CTL_PUS_100K_DOWN));

The file that I made the pin configuration is colibir-imax6ull.c. When the system start pin is in “1” 1 second or maybe 2 seconds later the pin is put in “0”, in my opinion this state change is taken becaus the u-boot execute my configuration so, there is a place that I could made the configuration that the pin takes value “0” as default or put in “0” earlier?

I would think the gpio init is called relatively early in the code of uboot. A 1 to 2 second delay before that init code is hit seems very long. Perhaps your power up sequence does something with the reset line to keep it low for a while before code can even be executed?

Be that all as it may, if you really need it low fast, solder a resistor on the board. A don’t think you’re going to get where you need to be by sprinkling gpio init stuff in different places of uboot.

Hi @emmaperea ,

Were you able to find a solution?

The setup described by @DaveM configures the pads simultaneously as we configure the PWM, was it enough for you?

If you want to active earlier, you can add your changes to the board_init function to gain some time.

Please let me know if you need any help.

Best regards,
Daniel Morais

Hi Daniel,
No, I wasn’t able to find a solution.
I made the suggested changes as follow:


+static iomux_v3_cfg_t const buzzer_pads[] = {

+	MX6_PAD_NAND_WP_B__GPIO4_IO11		| MUX_PAD_CTRL(PAD_CTL_PUS_100K_DOWN),

+};

+void turn_off_buzzer(void)

+{

+	/* Set PWM<A> turno off buzzer at init. */

+	gpio_request(GPIO_BUZZER, "Buzzer");

+	gpio_direction_output(GPIO_BUZZER, 0);

 

+}

 int board_init(void)

 {

 	/* address of boot parameters */

@@ -131,6 +157,13 @@ 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);

+	

+	imx_iomux_v3_setup_multiple_pads(buzzer_pads, ARRAY_SIZE(buzzer_pads));

+	turn_off_buzzer();

For 1 second the pin is in “1”.
I am using Col evaluation board, I don’t know if the board has hardware connections, I have to wait my custom board to check how works.
I am using pin 30 that is a pwm too as GPIO that I turn on at init and this pin works fine.
The pin that I have the issue It was configured as backlight pwm as default and I change It, May there is another configuration in somewhere that I missing.

Where do you pick up the gpio on the eval board? You’ll want to make sure you don’t have a shunt across X11 row 26 and then pick up your gpio at X10.26.