Skip to content

Rework the I2C driver for the Microchip Polarfire SoC #92208

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sebhub
Copy link
Contributor

@sebhub sebhub commented Jun 26, 2025

Use a mutex to protect the I2C bus from concurrent access. Replace busy waiting with a binary semaphore. Process the messages in the interrupt handler state machine to generate a single transaction. In the interrupt handler, process the states until nothing more is to do. This prevents superfluous interrupt entry/exit pairs. Return error conditions to the caller. Check the messages for consistency and return an error for unsupported message lists.

The driver was tested using an Icicle development board connected to another board with an I2C target.

@sebhub
Copy link
Contributor Author

sebhub commented Jun 26, 2025

@con-pax Would you mind reviewing this MR?

@con-pax
Copy link
Collaborator

con-pax commented Jun 26, 2025

@con-pax Would you mind reviewing this MR?

Hey @sebhub,
Absolutely! thanks for this, I will test this out

@sebhub sebhub force-pushed the i2c-mchp-mss-rework branch from d040c43 to 66072fb Compare June 26, 2025 11:02
Copy link
Collaborator

@teburd teburd left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me, I've not looked in great depth at the changes in the flow using an ISR state machine as I'm not familiar with this hardware, but looked for common things across i2c drivers.

A small nit using k_sem_reset like other drivers rather than a take with no wait.

@sebhub sebhub force-pushed the i2c-mchp-mss-rework branch from 66072fb to 6dfc2ad Compare June 26, 2025 13:03
teburd
teburd previously approved these changes Jun 26, 2025
sebhub added 2 commits June 27, 2025 17:12
Clear the clock bits before setting new ones.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Use a mutex to protect the I2C bus from concurrent access.  Replace busy
waiting with a binary semaphore.  Process the messages in the interrupt
handler state machine to generate a single transaction.  In the
interrupt handler, process the states until nothing more is to do.  This
prevents superfluous interrupt entry/exit pairs.  Return error
conditions to the caller.  Check the messages for consistency and return
an error for unsupported message lists.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Copy link

Copy link
Collaborator

@con-pax con-pax left a comment

Choose a reason for hiding this comment

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

Tested this out, works as expected. LGTM

@dkalowsk dkalowsk added this to the v4.3.0 milestone Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants