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.

AM6421: Accessing GPIO in uboot

Part Number: AM6421

Hi,

 

   We are using Processore sdk :   ti-processor-sdk-linux-rt-am64xx-evm-11.01.05.03

    Processor : AM6421.

 

 We want to access GPIO1_43(spi0_cs1) in uboot.

 We have done the below changes in dts and evm.c files

 Added 

 / {
       lcd_gpio_reset {
               gpios = <&main_gpio1 43 GPIO_ACTIVE_HIGH>;
       };
};

in k3-am642-evm-u-boot.dtsi file.

 

Added

  struct gpio_desc desc;
    int ret;

    /* Request GPIO by phandle name from DTS */
    /* Request GPIO1_43 by DTS property */
    ret = gpio_request_by_name_nodev(ofnode_path("/lcd_gpio_reset"),
                                     "gpios", 0, &desc, GPIOD_IS_OUT);
    if (ret) {
        printf("Failed to request GPIO1_43: %d\n", ret);
        return ret;
    } 
    printf("Success to request GPIO1_43: %d\n", ret);
                   
    /* Drive it high */ 
    dm_gpio_set_value(&desc, 1);

in board_late_init function in  evm.c file.

gpio_request_by_name_nodev  call return -19.

Please help us in solving this issue.

 

 

 

  • Hello, 

    I noticed you have a partial dts configuration. To properly enable a GPIO in U-Boot please take a look at the following FAQ for initialization and accessing help: [FAQ] PROCESSOR-SDK-AM62X: How to Toggle GPIOs and LEDs from U-Boot Command Prompt - Processors forum - Processors - TI E2E support forums.

    Regards,

    Shriya 

  • Hi Shriya

          Thanks for the response.

             We have tried  as suggested in the link. but still not able to access the gpio.

          We have done the below modifications:

     in kernel dts file k3-am642-evm.dts added belwo

      &main_pmx0 {

    customgpio1_pins_default: customgpio1-default-pins {
            pinctrl-single,pins = <
                
                AM64X_IOPAD(0x020c, PIN_INPUT, 7) /* (C13) SPI0_CS1.GPIO1_43 LCD_RST*/
            >;
        };

    &main_gpio1 {
              status = "okay";
             pinctrl-names = "default";
             pinctrl-0 = <&customgpio1_pins_default>;
             gpio-controller;
              
    };

    IN uboot dts file k3-am642-evm-uboot.dtsi added below

    &main_pmx0 {

          customgpio1_pins_default: customgpio1-default-pins {
                                pinctrl-single,pins = <
     
                                         AM64X_IOPAD(0x020c, PIN_OUTPUT, 7) /* (C13) SPI0_CS1.GPIO1_43 LCD_RST*/
                                >;
           };

    };

    &main_gpio1 {
                            bootph-all;

                            status = "okay";
                            pinctrl-names = "default";
                           pinctrl-0 = <&customgpio1_pins_default>;
                           gpio-controller;
    };

    / {

           lcd_gpio_reset: lcd_gpio_reset{
                                   gpios = <&main_gpio1 43 GPIO_ACTIVE_HIGH>;
              };

           aliases {
                   GPIO1_43 = &lcd_gpio_reset;
           };
    };

    Iuboot source file evm.c added below code

    int board_late_init(void)
    {
        if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
            struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;

            setup_board_eeprom_env();
            setup_serial();
            /*
             * The first MAC address for ethernet a.k.a. ethernet0 comes from
             * efuse populated via the am654 gigabit eth switch subsystem driver.
             * All the other ones are populated via EEPROM, hence continue with
             * an index of 1.
             */
            board_ti_am6_set_ethaddr(1, ep->mac_addr_cnt);
        }

    /* below added by UST for LCD reset pin*/

        struct gpio_desc lcdreset;
        int ret;
        

        ret = dm_gpio_lookup_name("GPIO1_43", &lcdreset);
        if (ret) {
            printf("Unable to lookup GPIO1_43\n");
            return ret;
        }
        
        ret = dm_gpio_request(&lcdreset, "lcd_reset");
        if (ret) {
            printf("Unable to request lcd_reset\n");
            return ret;
        }
        
        printf("Able to request lcd_reset GPIO1_43\n");
        
        /* set direction to output*/
        dm_gpio_set_dir_flags(&lcdreset, GPIOD_IS_OUT);
        
        /* Drive LCD reset low then high */
        dm_gpio_set_value(&lcdreset, 1);
        udelay(50);
        dm_gpio_set_value(&lcdreset, 0);
        udelay(150);
        dm_gpio_set_value(&lcdreset, 1);

        /*above added by UST  for LCD reset pin*/
        
        return 0;
    }

    while booting we are getting below errot

    Unable to lookup GPIO1_43
     nitcall failed at call 00000000808064a4 (err=-22)
     ### ERROR ### Please RESET the board ###

    Please check if we are doing any mistake.

  • Hi Narasimha, 

    Would you be able to share the output of gpio status -a?

    Regards,

    Shriya