AnsweredAssumed Answered

How do you toggle GPIO during Linux boot up?

Question asked by Bobby Eshleman on Sep 25, 2018
Latest reply on Sep 26, 2018 by igorpadykov

I have a functioning U-Boot on my IMX6SX-based board.  I am using the imx6sxsabresd u-boot and Linux configurations.  I am able to toggle GPIO during U-Boot boot up.  I am attempting to toggle the exact same GPIO during Linux boot up so I can use the GPIO toggling as a debug marker (I do not have serial on Linux yet).

 

I am using source from imx-yocto-L4.9.88_2.0.0.

 

Below is my code in U-Boot that successfully toggles the GPIO (pin 6, pad 1).

static iomux_v3_cfg_t const test_gpio_pads[] = {
    MX6_PAD_GPIO1_IO06__GPIO1_IO_6 | MUX_PAD_CTRL(NO_PAD_CTRL),
    MX6_PAD_GPIO1_IO07__GPIO1_IO_7 | MUX_PAD_CTRL(NO_PAD_CTRL),
};

static void test_gpio(void)
{
    int i;

    imx_iomux_v3_setup_multiple_pads(test_gpio_pads, ARRAY_SIZE(test_gpio_pads));
    gpio_request(IMX_GPIO_NR(1, 6), "GPIO Pad 1 Pin 6");

    for(i=0; i<3; i++) {
        printf("%d: GPIO on\r\n", i);
        gpio_direction_output(IMX_GPIO_NR(1, 6), 1);
        gpio_set_value(IMX_GPIO_NR(1, 6), 1);
        mdelay(1000);
        printf("%d: GPIO off\r\n", i);
        gpio_direction_output(IMX_GPIO_NR(1, 6), 0);
        gpio_set_value(IMX_GPIO_NR(1, 6), 0);
        mdelay(1000);
    }
 
    printf("Ending GPIO test\r\n");
}

 

How would I do the equivalent in Linux?

 

Thanks in advance.

Outcomes