-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Designware (DW) I2C Slave Support and Raspberry Pi Pico I2C Support #42513
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
Designware (DW) I2C Slave Support and Raspberry Pi Pico I2C Support #42513
Conversation
added pinctrl include support for I2C designware chip Signed-off-by: Andrei-Edward Popa <[email protected]>
gmarull
left a comment
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.
Thanks for this PR, I have a few comments
added pinctrl support for designware i2c driver Signed-off-by: Andrei-Edward Popa <[email protected]>
a7d837b to
ded0e15
Compare
gmarull
left a comment
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.
LGTM, pinctrl and board parts. Note: please check my I2C pull-up comment.
So, in this case, bias-pull-up needs to be removed? |
I'm not 100% familiar with pico, so maybe its internal pull-ups are fine when working with I2C standard bitrate. You can check https://electronics.stackexchange.com/questions/1849/is-there-a-correct-resistance-value-for-i2c-pull-up-resistors |
teburd
left a comment
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.
looks great to me, now I need to get a pico at some point
added slave mode support for I2C designware chip Signed-off-by: Andrei-Edward Popa <[email protected]>
added I2C pin macros for pinctrl of Raspberry Pi Pico board Signed-off-by: Andrei-Edward Popa <[email protected]>
ded0e15 to
a977fd2
Compare
yonsch
left a comment
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.
A few comments/questions about the RPi part (I didn't look at the I2C driver itself).
boards/arm/rpi_pico/rpi_pico.dts
Outdated
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 think this should be enabled by default. If I'm not wrong, peripherals should be disabled by default, and enabled in an overlay file (with the console UART and GPIO being the exceptions). But input from others on this topic is welcomed.
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's ok to have status = "okay";. Board doesn't set CONFIG_I2C=y, so i2c driver won't be enabled unless applications do.
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.
But the rp2040 has two i2c peripherals, one might enable i2c to use one and unintentionally enable the other. It happened to me once on an STM32 board. When I enabled i2c, UART suddenly stopped working because an i2c peripheral using the same pin was enabled by default. It was quite a misery to debug.
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.
So what do you suggest? To remove those ref nodes from dts or to make status disabled for both of them?
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.
Applications can always override using an overlay, so if they want i2c1 and not i2c0, an overlay can be used:
&i2c0 {
status = "disabled";
};
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 tend to agree with @yonsch. Here is our policy:
https://docs.zephyrproject.org/latest/guides/porting/board_porting.html#general-recommendations
In particular (emphasis mine):
Unless explicitly recommended otherwise by this section, leave peripherals and their drivers disabled by default.
So @gmarull 's comment that the driver isn't enabled by default does not meet this requirement.
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's ok to have status = "okay";. Board doesn't set CONFIG_I2C=y, so i2c driver won't be enabled unless applications do.
@gmarull 's comment is correct, decisive is CONFIG_I2C and reflects our general practice, it is also consistent with board porting guide.
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.
If we let boards add status = "disabled";, it means that we'll need many overlays in samples that are board-specific, whereas CONFIG_I2C=y in prj.conf works for all boards that have an I2C enabled in DT. I think it's a bit confusing, but I can't think of a better way.
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.
Opened an issue to continue this discussion: #42998
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.
Note that this would likely not happen with a custom out-of-tree board. In those cases, you generally describe what you have/need, and the application tends to be specifically designed for that hardware. Upstream, we have lots of eval kits or demo boards that do not have a specific purpose. Or sometimes, boards are meant to be plugged into an expansion kit, where hardware really gets defined from a board perspective (see for example https://www.tindie.com/products/arturo182/rp2040-stamp/). For maintainability reasons, I'd avoid going the path of disabling peripherals and require sample overlays.
a977fd2 to
6f272aa
Compare
6f272aa to
5a0dead
Compare
added I2C device tree nodes based on I2C designware chip Signed-off-by: Andrei-Edward Popa <[email protected]>
added Raspberry Pi Pico for testing it as I2C slave Signed-off-by: Andrei-Edward Popa <[email protected]>
5a0dead to
7a75180
Compare
mbolivar-nordic
left a comment
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.
Unless the I2C peripherals are being enabled in some way that the board porting guidelines allow, I don't think we should use other boards as an excuse for behavior against policy here.
boards/arm/rpi_pico/rpi_pico.dts
Outdated
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 tend to agree with @yonsch. Here is our policy:
https://docs.zephyrproject.org/latest/guides/porting/board_porting.html#general-recommendations
In particular (emphasis mine):
Unless explicitly recommended otherwise by this section, leave peripherals and their drivers disabled by default.
So @gmarull 's comment that the driver isn't enabled by default does not meet this requirement.
|
On second thought, I think it's not worth blocking this PR over this, but I do want to make it clear that existing bad behavior is still bad behavior. |
Added designware I2C support for slave mode
Added I2C support for Raspberry Pi Pico board. I2C chip on RP2040 is DW based.