-
Notifications
You must be signed in to change notification settings - Fork 11
ot_i2c
: Implement Target Mode Address Masking
#219
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
ot_i2c
: Implement Target Mode Address Masking
#219
Conversation
fac75c0
to
91e5071
Compare
hw/opentitan/ot_i2c.c
Outdated
s->address_mask = mask; | ||
|
||
if (mask != 0u && address != 0u) { | ||
ARRAY_FIELD_DP32(s->regs, TARGET_ID, ADDRESS0, address); |
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.
Aside: is the existing code correct here? Should we only be updating the address field and the I2C address on the bus if non-zero? We shouldn't match the address if the mask is non-zero (even though that should probably be handled in match_and_add
instead), but we should probably still reflect the write in the register at least. Is there a way to de-register the device instead of just setting its address?
Also, sorry I missed this in previous PRs, but do we need to also i2c_slave_set_address(s->target, 0u)
on reset to match the resetval? Or is this behaviour already implemented by resetting the I2C bus?
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.
Is there a way to de-register the device instead of just setting its address?
I do not think so.address
is a property ofI2CSlaveClass
.
There is some weirdness around address 0 as QEMU uses it as a "broadcast" address (hw/i2c/core.c
) - it uses that to make the default i2c_slave_match
add each I2C device.
8ce934c
to
c2f9b09
Compare
ot_i2c
: Implement Target Mode Address Masking
This implements target mode address masking as described in the documentation - OT I2C target mode will accept a transaction if the bitwise AND of an address and the device's address mask matches the device's address. This is implemented by overriding the default `I2CSlaveClass` `match_and_add` method. See `i2c_slave_match` in `hw/i2c/core.c`. Signed-off-by: Alice Ziuziakowska <a.ziuziakowska@lowrisc.org>
c2f9b09
to
5b961b2
Compare
This implements target mode address masking as described in the documentation - OT I2C target mode will accept a transaction if the bitwise AND of an address and the device's address mask matches the device's address.
This is implemented by overriding the default
I2CSlaveClass
match_and_add
method. Seei2c_slave_match
inhw/i2c/core.c
.