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.

logic pd omapl138 i2c driver problem

Other Parts Discussed in Thread: OMAPL138, DA8XX, OMAP3530

hi,I have a LogicPD's OMAPL138 EVM board, now i want to test this board's i2c driver in linux.In the LogicPD evm's schemetic, OMAPL138's I2C0 port is connect to IO EXPANDER tca6416pw,and this chip output pin is connect to LED, so my experience purpose is light this led from i2c0 driver in linux.

when logic evm linux kenerl started, i could see device node /dev/i2c-1. so i write code like follow:

 #define CMD_BYTE_INPUT0  0x00
 #define CMD_BYTE_INPUT1  0x01
 #define CMD_BYTE_OUTPUT0 0x02
 #define CMD_BYTE_OUTPUT1 0x03
 #define CMD_BYTE_POLARITY0 0x04
 #define CMD_BYTE_POLARITY1 0x05
 #define CMD_BYTE_CONFIG0 0x06
 #define CMD_BYTE_CONFIG1 0x07
 
 #define I2C_ADDR_GPIO_EX  (0x0021)
 
 #define I2C_SLAVE 0x0703
 #define I2C_TENBIT 0x0704
 
 const char *i2c0="/dev/i2c-1";
 char i2cdata[3];


int main(int argc,char *argb[])
{

 int i2cfd;
 char gpio_bit=0;
 
 printf("opening i2c:%s\n",i2c0);
 
 if(i2cfd=open(i2c0,O_RDWR)<0)
  {
   printf("open i2c fail!\n");
   return i2cfd;
 }
 else
 {
  printf("open successful!\n");
 }

 
 ioctl(i2cfd,I2C_TENBIT,0);
 
 ioctl(i2cfd,I2C_SLAVE,I2C_ADDR_GPIO_EX);
 i2cdata[0]=CMD_BYTE_POLARITY0;
 i2cdata[1]=0;
 i2cdata[2]=0;
 
 printf("write first cmd\n");
 if(write(i2cfd,&i2cdata[0],3)==-1)
 {
  printf("write first cmd error\n");
 }
  ....
  ....
  ....

}

i compiled this file successful,but when i executed in linux,it has nothing from I2C0 port pin(I check i2c0 port pin by oscilloscope).
what's wrong about this?could you give me some guide for this?
thanks in advance!
 

  • Did you properly set up the pin in the pin multiplexer, either in the kernel or the bootloader? that has tripped me up in the past...

  • hi,woody

      i have checked pinmux set in my linux kernel code ,and i find i2c0 pinmux set  like following:

     /* follow code is find  in da850_pins[] --- Da850.c*/
     MUX_CFG(DA850, I2C0_SDA, 4, 12, 15, 2, false)
     MUX_CFG(DA850, I2C0_SCL, 4, 8, 15, 2, false)

    /* follow code is in function da850_evm_init(void)  ---Board-da850-evm.c*/

    ret = da8xx_pinmux_setup(da850_i2c0_pins);
     if (ret)
      pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
        ret);

     ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
     if (ret)
      pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
        ret);

     According to above code, i think i2c0 pin is propely set up in the pin multiplexer.

    did i have a wrong understand about this? could you give me a simple demo code for using of i2c0 driver?

    thanks. 

  • Sorry, I can't provide you with sample code; i don't actually have an l138 board, we do most of our development on the omap3530. I just know that the pinmux has been a problem in the past. That mux config looks alright to me; sorry i could not be of more help.

  • hi,Woody

     i display above code's ioctl function,

      i=ioctl(i2cfd,I2C_TENBIT,0);
     
      printf("var i=%d\n",i);

    when i have excuted, i=-1,and i check this retrun value is EPERM(Operation not permitted),why? i executed with root privilege.