-
Notifications
You must be signed in to change notification settings - Fork 8k
drivers: add i2c driver support for MSPM0 #94627
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
base: main
Are you sure you want to change the base?
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.
This driver needs lot of re-factor. In summary,
- ISR context is handling all the data path, which needs to be abstracted.
- Target and Controller support needs to be split.
- Multi target support needs to be compile time based on devicetree target nodes.
- Current usage of data section is high and needs to be optimized based on rodata / data place-holding.
Current code base is not compilable as well. So IMO it makes sense to put in DRAFT until it's ready for review.
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's some confusing things going on, maybe because the HAL is handling interrupts? It's unclear, but those should be handled by Zephyr not by the HAL if that's the case.
drivers/i2c/i2c_mspm0.c
Outdated
DL_I2C_startControllerTransfer(config->base, data->addr, DL_I2C_CONTROLLER_DIRECTION_TX, | ||
data->msg.len); | ||
|
||
while (!(DL_I2C_getControllerStatus(config->base) & DL_I2C_CONTROLLER_STATUS_IDLE)) { |
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.
Tight polling loops like this aren't inherently wrong but typically there's an interrupt signal available.
Would recommend changing the driver, if possible, to use an interrupt (event driven) state machine that is kicked off by the transfer function, and completed when the state machine signals back to the thread that had called transfer blocking on a k_sem_take by giving a semaphore.
If you really want the tight poll loop here instead, or there's no other option, use a WAIT_FOR() macro with a timeout such that even given a faulty i2c transfer the caller isn't blocked forever and instead may get an error.
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.
Looking into refactoring transfer to use semaphores
while (!(DL_I2C_getControllerStatus(config->base) & DL_I2C_CONTROLLER_STATUS_IDLE)) { | ||
} | ||
|
||
if (data->state == I2C_MSPM0_TIMEOUT) { |
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.
And I maybe spoke too soon if there's a hardware timeout available.
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 is a configurable SCL low hardware timeout available
reg: | ||
required: true | ||
|
||
interrupts: |
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 don't see the interrupts being used?
#address-cells = <1>; | ||
#size-cells = <0>; | ||
reg = <0x400f2000 0x2000>; | ||
interrupts = <26 0>; |
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 doesn't seem like the driver supports interrupts
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.
Interrupts are used for controller and target logic
The code base is compliable. Target support is split and optional from controller via kconfig define. Multi target support is compile time based on Kconfig defines |
1f122c6
to
b708dc5
Compare
@teburd Ping for re-review. Refactored transmit logic to use semaphores instead of busy wait looping |
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.
ISR handler would gain in clarity being split: irq types handled in dedicated inline functions and as noted already: target stuff being on their own as well.
The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
In flight PR changes default pin properties for I2C. Signed-off-by: Dylan Philpot <[email protected]>
3b796f7
to
23c36c9
Compare
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'll try to find some time to dig into the logic details later
I don't see anything here to review on the charger side of things, so I am going to remove the charger label if no one has any objections. |
@teburd @tbursztyka @parthitce @ssekar15 ping for review |
@d-philpot you need to correct the issues pointed out and push your changed here so we can see them, it doesn't seem you've done that yet I don't see the comments from @tbursztyka addressed yet, and they are valid |
Addressed in latest push |
Includes driver and dts binding changes for I2C support Signed-off-by: Dylan Philpot <[email protected]>
Adds devicetree entries for different I2C peripherals on MSPM0 devices. Signed-off-by: Dylan Philpot <[email protected]>
Adds I2C peripheral for launchpad use. Signed-off-by: Dylan Philpot <[email protected]>
|
Adds I2C controller and target support for MSPM0. Includes driver changes, dts and board updates.