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.

Function call to read/write to an I2C device Maxim 4424

Hi,

               I'm trying to read/write to an I2C device from DM814x. I've already made the changes suggested by http://processors.wiki.ti.com/index.php/TI81xx_PSP_Porting_Guide#I2C_Driver

               I have a driver that can read/write to this device from another CPU. So I port it over. So far I can probe my device during initialization. However I can't read/write to it yet.

               In my driver I use

i2c_smbus_read_byte_data(client, reg_address);

i2c_smbus_write_byte_data(client, reg_address,temp_val);

               I'm wondering in DM814x, we have to use different functions for I2C read/write to an external I2C device?

               Regards

              

 

 

  • Huan,

    In the below wiki page is stated that TI81xx I2c driver is in <linux-kernel>/drivers/i2c/busses/i2c-davinci.c

    http://processors.wiki.ti.com/index.php/TI81XX_PSP_PM_SUSPEND_RESUME_User_Guide#References

    And there we have the below functions for I2C read/write:

    davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev, int reg, u16 val)
     
    davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg)

    Can you try with these two functions instead of the smbus read/write functions?

    Regards,
    Pavel

  • Hi Pavel,

                   Thanks. Here's what I see in i2c-davinci.c

    static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev,       int reg, u16 val)

    {  __raw_writew(val, i2c_dev->base + reg); }

    static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg) {  return __raw_readw(i2c_dev->base + reg); }

           So I guess I'll have to take the file i2c-davinci.c and rewrite it for my chipset Maxim 4424. Is that what you mean?

           Regards,

           Huan

  • Huan,

    After checking more carefully the DM814x linux kernel source code, it seems that i2c-davinci driver is used for old DaVinci devices, while for DM814x is used i2c-omap.c (not i2c-davinci.c).

    This is what we have inside the EZSDK5.05.02.00/PSP04.04.00.01:

    1. u-boot i2c driver:

    ti-ezsdk_dm814x-evm_5_05_02_00/board-support/u-boot-2010.06-psp04.04.00.01/drivers/i2c/omap24xx_i2c.c

    i2c_read() -> i2c_read_byte()

    i2c_write() -> i2c_write_byte()

    2. Linux kernel i2c driver:

    ti-ezsdk_dm814x-evm_5_05_02_00/board-support/linux-2.6.37-psp04.04.00.01/arch/arm/mach-omap2/i2c.c

    ti-ezsdk_dm814x-evm_5_05_02_00/board-support/linux-2.6.37-psp04.04.00.01/arch/arm/plat-omap/i2c.c

    ti-ezsdk_dm814x-evm_5_05_02_00/board-support/linux-2.6.37-psp04.04.00.01/drivers/i2c/busses/i2c-omap.c

    static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, int reg, u16 val)
    {
        __raw_writew(val, i2c_dev->base +
                (i2c_dev->regs[reg] << i2c_dev->reg_shift));
    }

    static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
    {    
        return __raw_readw(i2c_dev->base +
                    (i2c_dev->regs[reg] << i2c_dev->reg_shift));
    }

    Best regards,
    Pavel

  • This answer solve my problem. Thanks, Pavel