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.

i2c quickstart with OMAP35x

Other Parts Discussed in Thread: TPS65950

I would like to know how to access the TWL4030/TPS65950 and also how to use the I2C from Linux user space.  I cannot seem to find programming infomation on this.  I see there are drivers for the TWL4030 but are there any user guides or information to access the parts using Linux?  Any help is appreciated.

Thanks

  • I was able to build i2ctools for OMAP 3530.  You can get it from http://www.lm-sensors.org/wiki/I2CTools

    When you do the make, set CC to point to your cross-compiler:
    (e.g.,  make CC=arm-none-linux-gnueabi-gcc)

    If you edit the "prefix = " setting in the Makefile to point to the NFS folder that your target mounts, then the "make install" will copy the files to the correct location on your target.

    Now you can use i2cset and i2cget to communicate with your I2C devices from user space.  I found i2cdetect useful to see what's already out there (example below).

    # i2cdetect -r 1
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-1 using read byte commands.
    I will probe address range 0x03-0x77.
    Continue? [Y/n] y
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- UU UU UU UU -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

    If the bus speed is wrong, you have to edit the I2C init in the kernel for your board.  For example, on Beagle you would tweak the omap_register_i2c_bus() calls in omap3_beagle_i2c_init() from arch/arm/mach-omap2/board-omap3beagle.c.  I had to do this to slow things down for my own app.

    This is as far as I've gotten.  I am curious if there is a way to pass the I2C speeds as a parameter when the kernel starts up or change speeds programmatically from user space.

    Not sure if these tools will conflict with existing drivers for the TWL device, but they are useful for general debugging.  Anyhow, good luck!

    ~Chris N.

     

  • I was successful accessing the TWL(TPS) chip using i2cget, i2cset, and i2cdump.  Here's an example dump of the audio registers:

    # i2cdump -f -r 0x01-0x49 1 0x49 b

    WARNING! This program can confuse your I2C bus, cause data loss and worse!

    I will probe file /dev/i2c-1, address 0x49, mode byte

    Probe range limited to 0x01-0x49.

    Continue? [Y/n] y

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef

    00:    91 00 00 00 00 00 0a 00 00 0c 0c 00 00 01 00     ?.....?..??..?.

    10: 3f 3f 3f 3f 00 00 00 0c 00 00 00 4b 4b 00 00 00    ????...?...KK...

    20: 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 01    ..$............?

    30: 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00    ..........?.....

    40: 00 00 00 00 00 00 00 00 00 00                      ..........