Hi Beagle friends,
A couple issues I ran into with the driver. If you want to use i2cdetect, you will need these fixes.
This is for the Microchip CoreI2C drivers /dev/i2c-0 and /dev/i2c-1.
diff --git a/drivers/i2c/busses/i2c-microchip-corei2c.c b/drivers/i2c/busses/i2c-microchip-corei2c.c
@@ -463,8 +460,8 @@ static int mchp_corei2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned
switch (size) {
case I2C_SMBUS_QUICK:
- msgs[CORE_I2C_SMBUS_MSG_WR].buf = NULL;
- return 0;
+ msgs[CORE_I2C_SMBUS_MSG_WR].len = 0; /* Zero-length for quick */
+ break;
case I2C_SMBUS_BYTE:
if (read_write == I2C_SMBUS_WRITE)
msgs[CORE_I2C_SMBUS_MSG_WR].buf = &command;
The driver incorrectly assumes no bus transaction is needed. However, the data being aquired is the ack bit from sending a slave address on the bus. The above patch makes sure that actually happens.
The next part of the fix is in the same function:
@@ -505,7 +502,10 @@ static int mchp_corei2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned
return -EOPNOTSUPP;
}
- mchp_corei2c_xfer(&idev->adapter, msgs, num_msgs);
+ int ret = mchp_corei2c_xfer(&idev->adapter, msgs, num_msgs);
+ if (ret < 0)
+ return ret; // Propagate errors like -6 (I2C NACK)
if (read_write == I2C_SMBUS_WRITE || size <= I2C_SMBUS_BYTE_DATA)
return 0;
The function return code was being thrown away! Not good. The next issue is, once you make these fixes, your git tree status becomes dirty. The “dirty” tag gets added on to the version string making it too long. So I made this mod:
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 5818465ab..6cc54c2d0 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -141,12 +141,12 @@ scm_version()
# git-diff-index does not refresh the index, so it may give misleading
# results.
# See git-update-index(1), git-diff-index(1), and git-status(1).
- if {
- git --no-optional-locks status -uno --porcelain 2>/dev/null ||
- git diff-index --name-only HEAD
- } | read dummy; then
- printf '%s' -dirty
- fi
+ # if {
+ # git --no-optional-locks status -uno --porcelain 2>/dev/null ||
+ # git diff-index --name-only HEAD
+ # } | read dummy; then
+ # printf '%s' -dirty
+ # fi
}
Just commented that part out. /shrug
Hope you find it useful.
Thanks,
J