Skip to content

I2C SW cleanups#605

Merged
KinzaQamar merged 4 commits into
lowRISC:mainfrom
KinzaQamar:i2c_sw_cleanups
Jun 8, 2026
Merged

I2C SW cleanups#605
KinzaQamar merged 4 commits into
lowRISC:mainfrom
KinzaQamar:i2c_sw_cleanups

Conversation

@KinzaQamar

@KinzaQamar KinzaQamar commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Apart from 38ec242, every commit is addressing review comments in #473

compute_timing_parameters() is only used by i2c_init().

Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
Now that we are chip level I2C Host/Device tests, renaming existing
i2c/smoketest with the functionality of the test seems reasonable.

Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
The only difference b/w them was that i2c_wait_read_finish() wasn't checking
cmd_complete field of the intr_state register. In host mode, this interrupt
is raised if the host issues a repeated START or terminates the transaction
by issuing STOP. But OT's programming guide doesn't say anything about
checking that field in case of a read transfer. I think it is better to
check that field in case of Reads as it basically means that the transfer is
completed.

This also reduce the need of having 2 separate functions with just a difference
of not checking cmd_complete field of the intr_state register.

Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>

@elliotb-lowrisc elliotb-lowrisc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvements

Comment thread sw/device/lib/hal/i2c.c
Comment thread sw/device/lib/hal/i2c.c
if (i2c_intr_state_reg & i2c_intr_cmd_complete) {
i2c_status i2c_status_reg = VOLATILE_READ(i2c->status);
if (i2c_status_reg & i2c_status_fmtempty) {
if (VOLATILE_READ(i2c->status) & i2c_status_fmtempty) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably fine as-is, just with the name status.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. status name will look inconsistent with the rest of the naming convention used within this function for registers.

@KinzaQamar KinzaQamar merged commit a413a52 into lowRISC:main Jun 8, 2026
5 checks passed
@KinzaQamar KinzaQamar deleted the i2c_sw_cleanups branch June 8, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants