This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GPIO control from spl binary

Other Parts Discussed in Thread: TMDXEVM3358

HI,

can we read a gpio status from SPL ? 
being specific, I would like to read SW3 push button[am335x evm starter kit :TMDXEVM3358-SK] status from \common\spl\spl.c: preloader_console_init() function.

I had compiled uboot with CONFIG_SPL_GPIO_SUPPORT enabled and  tried functions such as gpio_request(),gpio_get_value() etcc.. and not working .SPL is hanging after reaching this code part .

Thanks and regards

Gokul CG

  • Hi Gokul,

    You have to add one more declaration to define the direction of this GPIO. This you can make with: gpio_direction_output();
    And so to can you control some gpio you have to initialize like that:

    ret = gpio_request(GPIO_xxx, "xxx");
    ret = gpio_direction_output(GPIO_xxx, value); or gpio_direction_input(GPIO_xxx);

    val = gpio_get_value(GPIO_xxx);
    or
    gpio_set_value(GPIO_xxx, value);

    BR
    Ivan
  • Hi,
    I had done that also .

    My actual intention is to avoid SPL version print if I press a push button at start-up.
    This is my code snippet from spl.c

    #include <asm/gpio.h>
    #include <asm/io.h>


    void preloader_console_init(void)
    {
    int value = 0;

    gd->bd = &bdata;
    gd->baudrate = CONFIG_BAUDRATE;

    serial_init(); /* serial communications setup */

    gd->have_console = 1;

    puts("\START:\n");

    gpio_request(30, " ");
    gpio_direction_input(30);
    value = gpio_get_value(30);
    if(value)
    {
    puts("\nU-Boot SPL: " PLAIN_VERSION " (" U_BOOT_DATE " - " \
    U_BOOT_TIME ")\n");
    }

    #ifdef CONFIG_SPL_DISPLAY_PRINT
    spl_display_print();
    #endif
    }


    I am only getting START print to console . But SPL hangs @ GPIO section added . And u-boot is also not loading .If I comment gpio related function everything working fine .

    Thanks and regards
    Gokul CG
  • Hi Gokul,

    It seems that all is OK. If the SPL hangs mean that is too early to use GPIO. I mean that some clock or power were not initialized in this moment. For that reason you can yourself to initialize or if it possible to use in u-boot or of place where you are sure that needed clock and PM are switched on.

    BR
    Ivan
  • Hi Gokul,

    Could you see if this pin is initialized in this place as GPIO or some other functionality.

    BR
    Ivan
  • Hi Gokul,

    I put reading of GPIO code of end of SPL code and MLO not hanging. You have to choose the well place.

    BR
    Ivan
  • Hi Ivan,

    I don't know where it should place . Whats the last function executed by SPL/MLO ? is it last function inside s_init() ,that is sdram_init();

    BR
    Gokul
  • Hi Ivan,
    Thank you Ivan .

    Its working on later parts of the code . So probably as you said "some clock or power were not initialized in this moment". Can anyone point out where is regs/clocks required for gpio module is getting initialized ?

    Thanks and regards
    Gokul CG