Skip to contentSkip to conversation

Problem with a hih6130 sensor in a OMAP I2C bus

DISCUSSION José Miguel Gonçalves 3 participants 3 messages Dec 9, 2013 2 messages not in the archive I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Hi,

While testing an HIH6130 humidity and temperature sensor with I2C interface in a BeagleBone board I've found that I was unable to read it because the driver always returned EINVAL. With some debugging I've found that the error was due to a test on omap_i2c_xfer_msg() in OMAP I2C driver that invalidates zero length writes. The hwmon hih6130 driver issues such kind of request in hih6130_update_measurements() to issue a measurement request to the sensor.

I was able to get measurements from the sensor by hacking the hih6130 driver replacing the following line in hih6130_update_measurements();

        ret = i2c_master_send(client, tmp, 0);

by

        tmp[0] = 0;
        ret = i2c_master_send(client, tmp, 1);

Is this the correct way to fix this issue, or should the fix be in the I2C OMAP driver to accept zero length transfers?

Best regards,
José Gonçalves

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
In reply to a message not in the archive

Hi José,

Quoted 13 lines · José Miguel Gonçalves

While testing an HIH6130 humidity and temperature sensor with I2C interface in a BeagleBone board I've found that I was unable to read it because the driver always returned EINVAL. With some debugging I've found that the error was due to a test on omap_i2c_xfer_msg() in OMAP I2C driver that invalidates zero length writes. The hwmon hih6130 driver issues such kind of request in hih6130_update_measurements() to issue a measurement request to the sensor.

I was able to get measurements from the sensor by hacking the hih6130 driver replacing the following line in hih6130_update_measurements();

         ret = i2c_master_send(client, tmp, 0);
Quoted 7 lines

by

         tmp[0] = 0;
         ret = i2c_master_send(client, tmp, 1);

Is this the correct way to fix this issue, or should the fix be in the I2C OMAP driver to accept zero length transfers?

Ideally it should be fixed in the i2c-omap bus driver. However, if zero-length transfers are explicitly prohibited, it may mean that the hardware itself can't do it (in which case adding a comment saying so in the source code would be great.) You'll have to check. The driver supports several generations of OMAP chipsets so you'll have to check them all, maybe some can handle zero-length messages and some do not.

If fixing it in the i2c-omap driver is not possible, then working around it in the hih6130 driver would be acceptable. You'll have to make sure there is no side effect to sending a single byte to the chip. If performance is a concern, you may have to enable the workaround only when zero-byte messages aren't supported. You can check with:

i2c_get_functionality(i2c_adapter) & I2C_FUNC_SMBUS_QUICK

Signature · 1 line
Jean Delvare
#4 lore raw
In reply to a message not in the archive

Hi Jean,

Quoted 30 lines · Jean Delvare

Hi José,

Quoted 13 lines · José Miguel Gonçalves

While testing an HIH6130 humidity and temperature sensor with I2C interface in a BeagleBone board I've found that I was unable to read it because the driver always returned EINVAL. With some debugging I've found that the error was due to a test on omap_i2c_xfer_msg() in OMAP I2C driver that invalidates zero length writes. The hwmon hih6130 driver issues such kind of request in hih6130_update_measurements() to issue a measurement request to the sensor.

I was able to get measurements from the sensor by hacking the hih6130 driver replacing the following line in hih6130_update_measurements();

          ret = i2c_master_send(client, tmp, 0);
Quoted 7 lines

by

          tmp[0] = 0;
          ret = i2c_master_send(client, tmp, 1);

Is this the correct way to fix this issue, or should the fix be in the I2C OMAP driver to accept zero length transfers?

Ideally it should be fixed in the i2c-omap bus driver. However, if zero-length transfers are explicitly prohibited, it may mean that the hardware itself can't do it (in which case adding a comment saying so in the source code would be great.) You'll have to check. The driver supports several generations of OMAP chipsets so you'll have to check them all, maybe some can handle zero-length messages and some do not.

Quoted 8 lines

If fixing it in the i2c-omap driver is not possible, then working around it in the hih6130 driver would be acceptable. You'll have to make sure there is no side effect to sending a single byte to the chip. If performance is a concern, you may have to enable the workaround only when zero-byte messages aren't supported. You can check with:

i2c_get_functionality(i2c_adapter) & I2C_FUNC_SMBUS_QUICK

I am by no means an expert on OMAP platforms and/or I2C drivers so, if anyone else with more knowledge of them has a better suggestion, I will follow your suggestion and submit my workaround patch for the hih6130 driver with the added check for support of zero-byte messages by the underlying I2C driver. From my understanding of the technical note for I2C communication on this chip;

http://www.mouser.com/pdfdocs/I2CCommunications.pdf

I see no problems on writing that dummy byte to it and my tests on a real hardware also show that.

Best regards,
José Gonçalves