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.

DM8168:GPIO question

Other Parts Discussed in Thread: TMS320DM8168

hi,

We designed a board using DM8168.  First use SD boot mode,  it works fine. And then,i wand a GPIO pin set to high,but it seems did not work.The uboot cord as follow:

gpio_reg_val = __raw_readl(0x48033134);
 gpio_reg_val &= 0xF0FFFFFF; 
 __raw_writel(gpio_reg_val, 0x48033134); 
  gpio_reg_val = __raw_readl(0x48033000 + 0x190);
  gpio_reg_val &= 0x0F000000;
  __raw_writel(gpio_reg_val, 0x48033000 + 0x190); 
  gpio_reg_val = __raw_readl(0x48033000 + 0x194);
  gpio_reg_val |= 0x0F000000;
  __raw_writel(gpio_reg_val, 0x48033000 + 0x194);  
     gpio_reg_val = __raw_readl(0x48033000 + 0x13C);
  gpio_reg_val |= 0x0F000000;
  __raw_writel(gpio_reg_val, 0x48033000 + 0x13C);

the GPIO pin 24 ~27 didn't go high.And then we read all the gpio Registers :
gpio vertion=0x206435
gpio 0x48033010=0x0
gpio 0x48033020=0x200
gpio 0x48033024=0x0
gpio 0x48033028=0x0
gpio 0x4803302c=0x0
gpio 0x48033030=0x0
gpio 0x48033034=0x0
gpio 0x48033038=0x0
gpio 0x4803303C=0x0
gpio 0x48033040=0x0
gpio 0x48033114=0x0
gpio 0x48033130=0x0
gpio 0x48033134=0x0
gpio 0x48033138=0x0
gpio 0x4803313C=0x0
gpio 0x48033140=0x0
gpio 0x48033144=0x0
gpio 0x4804d148=0x0
gpio 0x4804d14C=0x0
gpio 0x4804d150=0x0
gpio 0x4804d154=0x0
gpio 0x4804d190=0x0
gpio 0x4804d194=0x0

who can give me a hand? Please give me a example which  set the gpio pin go high or low.

Thanks!

  • Hi Chand,

    I have few questions

    1. Have you done the pinmux configuration properly for the pins what you are using?

    2. Is there any specific reason for setting the GPIO pins from uboot?

    If not please follow the steps in the GPIO user guide.

    http://processors.wiki.ti.com/index.php/Sitara_GPIO_Driver_User_Guide

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks

  • Hi AniKumar,

    I just want a GPIO pin go high in uboot not in the kernel . is this a solution for uboot?

    May be we have some misunderstand in this issue.

    I found gpio0 support registers base address in "tms320dm8168.pdf"

    so we "__raw_writel(gpio_reg_val, 0x48033134);" first ,then write the data out , but it seems not effect.

    Regards 

    Chand

  • Hi Chand,

    The Base address what you are using is not correct.

    Steps for pulling the GPIO pin high.

    1. Configure the pinmux settings for the GPIO pin what you are using.

    2. Set data in the register BASE + 0x194

    gpio_reg_val = 0x01000000; /* for GPIO24 */
     __raw_writel(gpio_reg_val, 0x48032194);

    3. Set direction as output in the register BASE + 0x134

    gpio_reg_val = __raw_readl(0x48032134);
     gpio_reg_val &= 0x01000000;  /* for GPIO24 */
     __raw_writel(gpio_reg_val, 0x48032134);

    Then you can see GPIO pin has high.

    Note: If pin mux settings are not proper then we will not get the expected value on the GPIO lines

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Hi AniKumar,

    1. In "pinmux.h", set the gp0[24] Internal pull-up or pull-down, GPIO0 pin 24 has high or low,so the pin mux settings seems right.

    MUX_VAL(PINCTRL199, (IPD | M2 )) /* GP0[24] */\

    2. Then set data in the register BASE + 0x194

    gpio_reg_val = 0x01000000; /* for GPIO24 */
     __raw_writel(gpio_reg_val, 0x48032194);

     when uboot run the step 2 described.  stopped, the UART no output .

    Try it on EVM Board(816X/319X EVM REV F) is same results. 

    Is ther anything we did not notice?

    Regards

    Chand

  • Hi Chand,

    In u-boot by default GPIO0 clock is enable on DM8168. If you didn't clear any portion of the code meant for GPIO0 clock enable then there won't be any issues. Otherwise enable the clock for GPIO0

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Hi Chand,

    I just have same task and same problem. I believe  you have it resolved

    My code is following 

    u32 gpio_reg_val = 0;

    printf("GPIO Base address:0x%x\n",TI816X_GPIO0_BASE);

    gpio_reg_val = 0x02000000; /* for GPIO26 */ 

    __raw_writel(gpio_reg_val, TI816X_GPIO0_BASE + 0x194);

    gpio_reg_val = __raw_readl(TI816X_GPIO0_BASE + 0x134);

    gpio_reg_val &= 0x02000000;

    __raw_writel(gpio_reg_val, TI816X_GPIO0_BASE + 0x134);

    where TI816X_GPIO0_BASE is  0x48032000

    but the booting is stuck on the last command. 

    Please help to newbie :)

  • Hi Yuri,

    I think your intention is to set 26th bit as output and and set GPIO26th bit as "1".

    Your doing wrong settings so you are seeing the hang, follow these steps

    gpio_reg_val = 0x02000000; /* for GPIO26 */

    __raw_writel(gpio_reg_val, TI816X_GPIO0_BASE + 0x194);

    gpio_reg_val = __raw_readl(TI816X_GPIO0_BASE + 0x134);

    gpio_reg_val &= ~(0x02000000); /* In your case you are changing all the GPIO lines to output except GPIO26 so other modules get effected with this settings */

    __raw_writel(gpio_reg_val, TI816X_GPIO0_BASE + 0x134);

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • I just enable the gpio clk first before set gpio,the code as follow :

    /* enable GPIO clk by du*/

     __raw_writel(0x102, 0x4818155c); 

      while((__raw_readl(0x4818155c) & 0x3) != 0x2);

     __raw_writel(0x102, 0x48181560);  

    while((__raw_readl(0x48181560) & 0x3) != 0x2);

     gpio_reg_val = __raw_readl(0x48032000+ 0x134);

     gpio_reg_val &= 0xFDFFFFFF;  

    __raw_writel(gpio_reg_val, 0x48032000+ 0x134); 

     gpio_reg_val = __raw_readl(0x48032000 + 0x13C);  

    gpio_reg_val &= ~(0x02000000);  

    __raw_writel(gpio_reg_val, 0x48032000 + 0x13C);

     

    NOTE: the pin mux you set must correct.

     

     

     

  • Many thanks, guys, for quick response.
    Unfortunately it still doesn't work. Do you see something wrong in the code bellow?

    /*pin mux GPIO 26 (pull up)*/

    /*BTW I managed to see switching from logical 1 to 0 if I put 0x12 instead 0x2*/

     __raw_writel(0x2, 0x48140B20);


    /* enable GPIO clock*/
    __raw_writel(0x102, 0x4818155c);
    while((__raw_readl(0x4818155c) & 0x3) != 0x2);

      __raw_writel(0x102, 0x48181560);
    while((__raw_readl(0x48181560) & 0x3) != 0x2);

     gpio_reg_val = __raw_readl(TI816X_GPIO0_BASE + 0x134);

     gpio_reg_val &= 0xFBFFFFFF;

      __raw_writel(gpio_reg_val, TI816X_GPIO0_BASE + 0x134);

     gpio_reg_val = __raw_readl(TI816X_GPIO0_BASE + 0x13C);

    /*here I tried gpio_reg_val = 0x02000000 but anyway it doesn't work)
    gpio_reg_val &= ~(0x02000000);

     __raw_writel(gpio_reg_val, TI816X_GPIO0_BASE + 0x13C);

  • Eventually  I managed make it work . It was my stupid mistake. Thanks a lot.

  • hi everyone!

    i am trying to access the GPIO's using the BSL provided by spectrum digital, but i am not able to do so. I can access it using the sysfs entries on the kernel side. The program given by spetrum digital seems to have wrong base address. has anybody tried running gpio's using the spectrum digital BSL? 

    thanks

    regards

    hitesh

  • Hi AnilKumar,

    I have a question regarding the GPIO pinmux settings on the 8168, I do not find any pin mux settings in u-boot.

    Please help.

  • Hi Yuri Gusko,

    Can you please tell me how you solved this issue. Even I am also facing the issue. While I am trying to GPIO0 with this base 0x4803200. The system Is stuck up and can't access it.

    Thanks in advance.

    Regards
    Salih