Adding GPIO support

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding GPIO support

3,489 Views
divyardharan
Contributor III

Hi All,

I am using imx6Q Sabre SD board,

I am a beginner in this.

I wants to implement GPIO support in U-Boot.

Plz advice me from where to start.

Regards

Divya

Labels (1)
Tags (2)
6 Replies

1,531 Views
saurabh206
Senior Contributor III

Hi

Divya

You need to first setup PAD for GPIO.

Than you can use gpio_direction_output or gpio_direction_input according to your GPIO functionality.

I hope this helps.

Thanks

Saurabh

0 Kudos
Reply

1,531 Views
divyardharan
Contributor III

Hi Saurabh,

Thanks for your quick reply.

As I mentioned in the earlier message ,am a beginner in this.

So could you plz provide any helpful link or note on how to set up all these PAD and how I can use gpio_direction_output or gpio_direction_input .

Regards

Divya

0 Kudos
Reply

1,531 Views
saurabh206
Senior Contributor III

Hi

Divya

uboot-imx\board\freescale\mx6q_sabreauto\mx6q_sabreauto.c

GPIO can be configured in input or output according to our requirement.

Suppose if I want to control LED using GPIO than I need to setup  gpio_direction_output.


Thanks

Saurabh

1,531 Views
divyardharan
Contributor III

Hi Saurabh,

Thanks for your quick reply.

I found the file mx6q_sabreauto.c.In that file there is no method named  gpio_direction_output or gpio_direction_input .

Only i could found below code snippet

#ifdef CONFIG_I2C_MXC

    if (!mx6_board_is_reva()) {

        mxc_iomux_v3_setup_multiple_pads(gpio_pads,

            ARRAY_SIZE(gpio_pads));

        gpio_direction_output(I2C_EXP_RST, 1);

       gpio_direction_output(I2C3_STEER, 1);

    }

    setup_i2c(CONFIG_SYS_I2C_PORT);

    /* Enable lvds power */

    setup_lvds_poweron();

    /* restore path for weim/spi nor */

    if (!mx6_board_is_reva())

        gpio_direction_output(I2C3_STEER, 0);

#endif

void udc_pins_setting(void)

{

    mxc_iomux_v3_setup_pad(MX6X_IOMUX(PAD_ENET_RX_ER__ANATOP_USBOTG_ID));

    /* USB_OTG_PWR = 0 */

    gpio_direction_output(SABREAUTO_USB_OTG_PWR, 0);

    /* USB_H1_POWER = 1 */

    gpio_direction_output(SABREAUTO_USB_HOST1_PWR, 1);

    mxc_iomux_set_gpr_register(1, 13, 1, 0);

}

if I want to control LED using GPIO then how will i setup  gpio_direction_output.


Regards

Divya

0 Kudos
Reply

1,531 Views
saurabh206
Senior Contributor III

Hi

If gpio_direction_output(SABREAUTO_USB_OTG_PWR, 0); mean SABREAUTO_USB_OTG_PWR GPIO set to Low.

And gpio_direction_output(SABREAUTO_USB_OTG_PWR, 1) mean SABREAUTO_USB_OTG_PWR GPIO set to High.

Same way you can set your GPIO.

0 Kudos
Reply

1,531 Views
jayaramks
Contributor III

Hi

As Saurabh said, you can configure GPIOs using:

gpio_direction_output(IMX_GPIO_NR((bank,number), 0));

gpio_direction_output(IMX_GPIO_NR((bank,number), 1));


gpio_direction_output is defined in u-boot\drivers\gpio\mxc_gpio.c


Regards,

Jayaram

0 Kudos
Reply