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.

  • TI Thinks Resolved

Linux/INA223: Linux kernel driver & application for INA223

Part Number: INA223

Tool/software: Linux

Hi Sir,

We are using the INA223 for voltage/current monitoring on one of our arm boards.

It is interfaced on I2C BUS and the board is up with linux kernel v4.1.15

I am wondering whether there is any linux driver and user space application available to spped up our development on using this device ?

your help is greatly appreciated. Looking forward for your response.

Please do let me know if you need more information.

Thanks,

Siva

  • Hello Siva,

    We do not have any linux drivers. Although you can most likely find linux code to communicate with the INA223 or other devices online. I found this source code online using a quick and simple search.

    code.woboq.org/.../ina2xx.c.html

    This is for the INA226, INA219, and others, but all of our digital current shunt monitors are very similar with their I2C communication protocol. Hope this helps.

    Sincerely,
    Peter Iliya
    Current Sensing Applications
  • In reply to Peter Iliya:

    Siva,

    We have driver code at our website, see link belw. Seems like the same thing compared to what I sent earlier.

    www.ti.com/.../ina2xxsw-linux

    Sincerely,
    Peter Iliya
    Current Sensing Applications
  • In reply to Peter Iliya:

    Hi Peter,

    Thanks for your input. 

    I tried to cross compile the same code. But i get  the following error

    drivers/hwmon/ina2xx.c: In function ‘ina2xx_probe’:

    drivers/hwmon/ina2xx.c:447:27: error: implicit declaration of function ‘of_device_get_match_data’; did you mean ‘of_device_get_modalias’? [-Werror=implicit-function-declaration]
    chip = (enum ina2xx_ids)of_device_get_match_data(&client->dev);

    If you are aware of this error earlier. Please do let me know in first place.

    Looks like needs some modification in the code of adding a header or so..

    Thanks,

    Siva

     

  • In reply to siva prasad15:

    Actually, the code that you provided earlier through google search doesn't support the device tress
    But the code provided in the latest post supports the device tress.
    My linux kernel v4 is based on device tress to detect the devices.
  • In reply to Peter Iliya:

    This doesn't support device tress
  • In reply to Peter Iliya:

    Getting the compilation errors !!!
    drivers/hwmon/ina2xx.c: In function ‘ina2xx_probe’:

    drivers/hwmon/ina2xx.c:447:27: error: implicit declaration of function ‘of_device_get_match_data’; did you mean ‘of_device_get_modalias’? [-Werror=implicit-function-declaration]
    chip = (enum ina2xx_ids)of_device_get_match_data(&client->dev);
  • In reply to siva prasad15:

    Siva,

    I am sorry to read of your problem. I am no linux expert, but when I look through the library "<linux/of_device.h>" online I do not see a function called "of_device_get_match_data". Maybe try replacing this function with following options until the code compiles:

    of_device_get_modalias
    of_driver_match_device

    Additionally, this driver source code was not made to include INA233, but INA233 I2C is very similar to our other devices (INA226, INA219, etc) so there may be some minor modification needed for the source code like making sure register locations are correct and adding INA233 to the "MODULE_DEVICE_TABLE".

    I hope this helps.
    Sincerely,
    Peter Iliya
    Current Sensing Applications
  • In reply to Peter Iliya:

    Hi Peter,

    Thanks for your support.

    Now, I Succesfully compile the driver with proper changes to device_id  and the module inserted succesfully. 

    But I donot see the corresponding folder created under /sys/class/hwmon/

    In my case, hwmon0 is the temperature zone. I can only see that folder.

    Am I in right path in usage of this driver ?

    I am not sure how to read the register values or the voltage/current values by using the driver. 

    I am able to see the device with I2C address 0x41 when I probe with i2cdetect -y 3

    Let me know  if you need more inputs, I can share the code for your reference.

    Looking forward for your help

    Thanks,

    Siva

    Thanks,

    Siva

  • In reply to siva prasad15:

    Hi Siva,

    What folder are you looking for in /sys/class/hwmon? I would recommend to try sending individual read/writing commands similar to your "i2cdetect -y 3" over a command-line-interface. Whatever I2C library you are using must have i2c read and write commands.

    Best,
    Peter Iliya
    Current Sensing Applications
  • In reply to Peter Iliya:

    Hi Peter,

    I am not sure about the register address(configuration register) to read from i2cget

    The i2cdump gives the following values
    root@imx7d-pcm-061-2111101e:~# i2cdump 3 0x41 b
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-3, address 0x41, mode byte
    Continue? [Y/n] y
    0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
    00: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    10: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    20: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    30: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    40: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    50: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    60: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    70: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    80: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    90: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    a0: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    b0: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    c0: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    d0: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    e0: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..
    f0: 00 00 00 00 05 1e 00 00 00 00 00 00 05 1e 00 00 ....??......??..

    I am not able to find the register address from the data sheet.
    So could you please provide me the configuration register address then i will read that address from i2cget.

    Basic question if i am able to handle the device from i2ctools in userspace then what's the purpose of this INA2XX driver here ?


    Thanks,
    Siva

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.