Skip to content

Conversation

@andrei-edward-popa
Copy link
Contributor

Added designware I2C support for slave mode
Added I2C support for Raspberry Pi Pico board. I2C chip on RP2040 is DW based.

added pinctrl include support for I2C designware chip

Signed-off-by: Andrei-Edward Popa <[email protected]>
@github-actions github-actions bot added area: API Changes to public APIs area: Boards area: Devicetree area: Devicetree Binding PR modifies or adds a Device Tree binding area: I2C area: Tests Issues related to a particular existing or missing test labels Feb 6, 2022
Copy link
Member

@gmarull gmarull left a 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]>
Copy link
Member

@gmarull gmarull left a 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.

@andrei-edward-popa
Copy link
Contributor Author

LGTM, pinctrl and board parts. Note: please check my I2C pull-up comment.

So, in this case, bias-pull-up needs to be removed?

@gmarull
Copy link
Member

gmarull commented Feb 11, 2022

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

Copy link
Contributor

@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 great to me, now I need to get a pico at some point

Andrei-Edward Popa added 2 commits February 14, 2022 18:02
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]>
Copy link
Contributor

@yonsch yonsch left a 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).

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

@yonsch yonsch Feb 16, 2022

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.

Copy link
Contributor Author

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?

Copy link
Member

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";
};

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic Feb 17, 2022

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.

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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

Copy link
Member

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.

Andrei-Edward Popa added 2 commits February 17, 2022 14:12
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]>
Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a 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.

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic Feb 17, 2022

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.

@mbolivar-nordic mbolivar-nordic dismissed their stale review February 17, 2022 22:42

Not worth blocking

@mbolivar-nordic
Copy link
Contributor

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.

@nashif nashif merged commit 34d921b into zephyrproject-rtos:main Feb 22, 2022
@andrei-edward-popa andrei-edward-popa deleted the rpi_pico_i2c branch February 22, 2022 01:00
@andrei-edward-popa andrei-edward-popa restored the rpi_pico_i2c branch May 4, 2022 13:03
@andrei-edward-popa andrei-edward-popa deleted the rpi_pico_i2c branch May 4, 2022 13:04
@str4t0m str4t0m added the platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) label Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Changes to public APIs area: Boards area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: Documentation area: I2C area: Tests Issues related to a particular existing or missing test platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants