-
Notifications
You must be signed in to change notification settings - Fork 7.4k
driver: i2c: cc13xx_cc26xx: to support i2c scan #38584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pillar1989 - please file an issue and link it to this PR. Describe the bug in more detail.
I know what this is for, but other reviewers might not.
It's mainly just because we are in our stabilization period right before release.
@Pillar1989 - just a few minor whitespace formatting issues. Please fix up so that CI passes and then it should be merged relatively quickly. |
update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this with an LPSTK-CC1352R with the i2c scan
command from the i2c shell and I can confirm that scanning works as expected.
It also would've been great to have this patch a few weeks ago when I was bringing up some new hardware and was puzzled by the i2c scan not showing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking this until we can validate this change.
drivers/i2c/i2c_cc13xx_cc26xx.c
Outdated
/* Sending address without data is not supported */ | ||
I2CMasterSlaveAddrSet(base, addr, false); | ||
|
||
/* Sending address without data */ | ||
if (len == 0) { | ||
return -EIO; | ||
|
||
I2CMasterControl(base, I2C_MASTER_CMD_SINGLE_SEND); | ||
|
||
k_sem_take(&data->complete, K_FOREVER); | ||
|
||
return data->error == I2C_MASTER_ERR_NONE ? 0 : -EIO; | ||
} | ||
|
||
I2CMasterSlaveAddrSet(base, addr, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really work as expected?
As far as I can see, I2C_MASTER_CMD_SINGLE_SEND
sends both address and data (written to I2CMDR
); and we do not write to I2CMDR
in this case, so we will be sending garbage data here:
Can you post an oscilloscope or logic analyser capture of the SCL/SDA waveforms and confirm that no data is sent here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leadercxn let's figure out why there is append a data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consult this document -- CC13x2, CC26x2 SimpleLink™ Wireless MCU Technical Reference Manual (Rev. D) , in chapter 25.3.5 , it introduces several models of I2C communication, but i can't see any modes that just send the address without I2C_MDR data.
In the chapter 23.5 , there are no any registers refer to how to just send the address. I try to modify the MCTRL register, but it doesn't work . so i don‘t think it's hardware I2C supports this feature that just send the address without I2C_MDR data.
CC13x2, CC26x2 SimpleLink™ Wireless MCU Technical Reference Manual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devanlai @stephanosio It seems that after some research, this additional data is justified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that after some research, this additional data is justified.
@Pillar1989 Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In chapter 23.5, which has many Master TRANSMIT modes. But every mode needs append data after the i2c address.
@Pillar1989 That means that the original comment is correct and this change is invalid.
/* Sending address without data is not supported */
@Pillar1989 - try to pull from |
@@ -58,12 +58,18 @@ static int i2c_cc13xx_cc26xx_transmit(const struct device *dev, | |||
const uint32_t base = get_dev_config(dev)->base; | |||
struct i2c_cc13xx_cc26xx_data *data = get_dev_data(dev); | |||
|
|||
/* Sending address without data is not supported */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Sending address without data is not supported */
I'm not 100% convinced that this statement is true, as I'm sure is the case for everyone else working with this SoC.
Let's ask the contributor with arguably the most experience with the vendor API in question.
@vanti - is there a way to perform an I2C scan / probe using the simplelink I2C driverlib? I.e. sending the address bits without sending data bits (with some indication as to whether the connected peripheral has ACK'ed the address bits). If so, how do we do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, a good description of the goal is here:
https://hackaday.com/2015/06/25/embed-with-elliot-i2c-bus-scanning/
and TI's API is here:
https://software-dl.ti.com/simplelink/esd/simplelink_msp432e4_sdk/2.30.00.14/docs/driverlib/msp432e4/html/group__i2c__api.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pillar1989, @Vaishnav98 - given what everyone else has said, I think we may not find the answer in the SimpleLink SDK. However, i sort of wonder if this could be bit-banged 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cfriedt @stephanosio Assume that we need to add more code to i2c scan
to support some SoC like CC13xx serial. any suggest? Or maybe this is a half-baked idea, and we still need to fix the problem of sending only addresses.
let me try again |
@stephanosio any more questions need to discuss ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the I2C peripheral of the CC13xx and CC26xx SoCs do not support sending address without data as described by the original comment, so this change is invalid.
The current I2C scan implementation expects the I2C peripheral to be able to only send the address to probe the peripherals on the bus, and that is with a good reason because sending data byte can be an intrusive behaviour.
If you want to make the I2C scan function work for this SoC (and others that do not support sending address without data), you will need to modify the I2C scan function itself and introduce something like a "intrusive" scan mode.
cc @nashif since he initially implemented the I2C scan function.
Sending address without data, make `i2c scan I2C_0` work. Signed-off-by: Baozhu Zuo <[email protected]>
https://manpages.debian.org/unstable/i2c-tools/i2cdetect.8.en.html @stephanosio |
The source of the problem is the I2C shell scan command implementation that requires a zero-length message to be sent, which the I2C peripheral of this particular SoC cannot support: zephyr/drivers/i2c/i2c_shell.c Line 64 in 21d1ad3
The current behaviour of the I2C driver returning It does not make sense to change/introduce an incorrect behaviour to the I2C driver in order to support the I2C shell scan command -- this is simply not a correct thing to do. Instead, the I2C shell scan command should be changed to support the class of devices that do not allow sending zero-length message by design (e.g. through a separate "intrusive scan" feature or by making all scans intrusive; I leave this decision up to whomever maintains this feature). |
Has TI stated that? There could be a bug or undersupported feature in the SimpleLink SDK, but I wasn't able to find anything elaborating on the '-ENOTSUP' conclusion here. It would be surprising if a TI part could not accomplish zero-length transfers, because presumably TI parts have been doing that for a long time. @Pillar1989 - have you asked about this on e2e.ti.com?
I would second that as a feature. |
The same question asked on e2e. @Vaishnav98 - are you aware if anyone at TI has investigated this issue? It seems to be a common problem and has an e2e ticket associated with it. I sort of wonder if it could be bitbanged .. 🤔 |
I think this would be best handled by pinctrl, to be honest. e.g. a gpio i2c device that shares pins with the dedicated i2c device, add a devicetree property.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will likely require some work involving the upcoming pinctrl feature
OK, close this PR |
Sending address without data, make
i2c scan I2C_0
work.Signed-off-by: Baozhu Zuo [email protected]