Skip to content
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

drivers: misc: Add support for WIZ550io module #69696

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

Conversation

gramsay0
Copy link
Contributor

@gramsay0 gramsay0 commented Mar 1, 2024

WIZ550io is a W5500 breakout board with an extra PIC12F519 MCU.
The PIC12F519 MCU initialises the W5500 with a unique MAC address after a GPIO reset.
The PIC12F519 requires a 150ms delay after GPIO reset to configure the W5500.
There is an optional "ready" GPIO signal that can be used to reduce that delay.

dts/bindings/ethernet/wiznet,w5500.yaml Outdated Show resolved Hide resolved
drivers/ethernet/eth_w5500_priv.h Outdated Show resolved Hide resolved
@gramsay0 gramsay0 force-pushed the wiz550io-support branch 3 times, most recently from 4bf0643 to 8f58b91 Compare March 3, 2024 08:17
Copy link

github-actions bot commented May 4, 2024

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label May 4, 2024
@decsny
Copy link
Member

decsny commented May 6, 2024

@parthitce @gramsay0 how are we resolving this PR?

@gramsay0
Copy link
Contributor Author

gramsay0 commented May 6, 2024

how are we resolving this PR?

@decsny @parthitce I have pushed a commit to remove the device tree specialization

@github-actions github-actions bot removed the Stale label May 7, 2024
@gramsay0 gramsay0 requested review from parthitce and decsny May 7, 2024 22:34
Copy link
Member

@parthitce parthitce 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 the changes.

drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
@@ -23,3 +23,9 @@ properties:
The reset pin of W5500 is active low.
If connected directly the MCU pin should be configured
as active low.
ready-gpios:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this should be in a new device tree binding that inherits from this one. You're sorta imposing this requirement onto everyone even if they aren't using this module which is what I believe to be the more common case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raveious an earlier revision of this PR had that, the maintainer did not agree, so it was removed

Copy link
Member

Choose a reason for hiding this comment

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

Ready gpio should not be on the w5500 binding because it is not on the w5500 chip itself.

Copy link
Member

Choose a reason for hiding this comment

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

I understand the differences between this module and underlying W5500 IC itself. Meaning, there is no ready-gpio from W5500. So to address that we can potentially introduce binding consuming the w5500 binding in include.

Copy link
Contributor

@raveious raveious left a comment

Choose a reason for hiding this comment

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

Closing my review as my issues were addressed previously.

parthitce
parthitce previously approved these changes May 21, 2024
Copy link
Member

@parthitce parthitce left a comment

Choose a reason for hiding this comment

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

LGTM, please rebase. To add, does it makes sense to add the overlay based on WIZ550IO?

@gramsay0
Copy link
Contributor Author

LGTM, please rebase. To add, does it makes sense to add the overlay based on WIZ550IO?

I have added a WIZ550io shield, similar to the arceli_eth_w5500 shield

Copy link
Member

@decsny decsny left a comment

Choose a reason for hiding this comment

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

need to determine a different solution for the w5500 io board that fits into the zephyr architecture better

@@ -23,3 +23,9 @@ properties:
The reset pin of W5500 is active low.
If connected directly the MCU pin should be configured
as active low.
ready-gpios:
Copy link
Member

Choose a reason for hiding this comment

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

Ready gpio should not be on the w5500 binding because it is not on the w5500 chip itself.

drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
drivers/ethernet/eth_w5500.c Outdated Show resolved Hide resolved
boards/shields/arceli_eth_w5500/doc/index.rst Outdated Show resolved Hide resolved
@decsny
Copy link
Member

decsny commented May 28, 2024

BTW, I changed the assignee to myself since I am on the list for both DT binding and ethernet, and galak is inactive

@decsny
Copy link
Member

decsny commented May 29, 2024

@gramsay0 I'm a bit confused because I looked for this W5500io module on the internet and found these docs: https://docs.wiznet.io/Product/ioModule/W5500-io#pin-description but they don't say anything about a ready pin as far as I can tell, can you clarify the discrepancy?

@decsny
Copy link
Member

decsny commented May 29, 2024

nevermind, I just realized there is a w5500io and a w550io.... that's a bit confusing itself

@decsny
Copy link
Member

decsny commented May 29, 2024

@gramsay0

I noticed the RST pin on the w550io board is actually not the same signal as the RST going to the w5500 controller itself. It actually is a signal that goes to the PIC12F519, and a different pin from the PIC12F519 is connected to the w5500. And this signal is even documented differently, having different timing requirements.

I think this breakout board should have a different compatible, adding a ready signal to the w5500 compatible is incorrect. The DT could look something like this

&arduino_spi {
 	status = "okay";

	eth_w5500: eth_w5500@0 {
		compatible = "wiznet,w5500";
                ....
               /* do not put the reset gpio property here */
               no-reset;
	};
}

w550io {
		compatible = "wiznet,w550io";
		reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>;  /* D8 */
		ready-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
                wiznet,w5500 = <&eth_w5500>
}

The issue of having board specific code in the file is actually not a huge problem, but I don't like how it's done right now which is just putting the code within some #if and checking if that property is present, which it shouldn't be since it shouldn't be part of that binding. Also, in my opinion, since these reset signals are not the same as each other, and the whole reset sequence really is different, code should reflect that, right now it's a weird hack looking code that can be misleading to future readers and potentially annoying to maintain.

To handle the different reset sequence, I would put a boolean DT property in the w5500 binding called "no-reset". I have done some research to confirm that properties like this are common in linux DT bindings to clarify that a device may be reset by another mechanism which is the case here, as the mechanism doing the reset will be the PIC12F519 rather than the host zephyr mcu. If this property is set, don't do the reset sequence in the w5500 init. Instead, you can have a SYS_INIT function in the same file that runs for every w550 node with higher priority than the w5500 init (ie runs before) that will do the appropriate reset sequence for this w550 module involving the longer wait after RST asserted and checking the RDY pin etc. You can also put in this function the spi read to read the mac address and I think you should have no problem setting the data in the w5500_runtime struct from here for the corresponding w5500 device in the phandle.

This way the code for the w550io is separate from the code for the w5500 and the DT bindings are accurate.

@gramsay0
Copy link
Contributor Author

@decsny I agree and really like the approach you have proposed.
I'll have a look into implementing these changes, thanks

@decsny
Copy link
Member

decsny commented May 30, 2024

@decsny I agree and really like the approach you have proposed. I'll have a look into implementing these changes, thanks

I didn't look into this part too much but it looked like there is maybe some switch on the board for the spi signals to switch between the PIC MCU and the w5500, I'm not sure what's the purpose but if that's the case then maybe consider also putting the w550io node on the spi bus, not sure

@gramsay0
Copy link
Contributor Author

gramsay0 commented Jun 1, 2024

@decsny I have made the modifications you suggested.

Although I'm not certain the WIZ550io code is in the correct location, as it's not really an Ethernet controller. This could be moved elsewhere (drivers/misc?) if you prefer.

Rather than adding a "no-reset" property to W5500 I put a static assert in the WIZ550io driver to ensure the "reset-gpios" property is not set in the W5500 device

@gramsay0 gramsay0 requested a review from decsny June 1, 2024 23:43
@decsny
Copy link
Member

decsny commented Jun 3, 2024

@decsny I have made the modifications you suggested.

Although I'm not certain the WIZ550io code is in the correct location, as it's not really an Ethernet controller. This could be moved elsewhere (drivers/misc?) if you prefer.

Rather than adding a "no-reset" property to W5500 I put a static assert in the WIZ550io driver to ensure the "reset-gpios" property is not set in the W5500 device

I was going to suggest you put it in drivers/misc originally but I thought it might add some challenge, so if you want to do it then go ahead

And the idea for the assert is fine by me

WIZ550io is a W5500 breakout board with an extra PIC12F519 MCU.
The PIC12F519 MCU initialises the W5500 with a unique MAC address
after a GPIO reset. The PIC12F519 requires a 150ms delay after GPIO
reset to configure the W5500. There is an additional "ready" GPIO
signal that can be used to reduce that delay.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
WIZnet WIZ550io contains a W5500 Ethernet Controller

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
@zephyrbot zephyrbot requested a review from pdgendt June 8, 2024 23:25
@gramsay0 gramsay0 changed the title drivers: ethernet: w5500: Add support for WIZ550io module drivers: misc: Add support for WIZ550io module Jun 8, 2024
@decsny
Copy link
Member

decsny commented Jun 10, 2024

won't the init sequence in the eth_w5500 have some problems now?

@gramsay0
Copy link
Contributor Author

won't the init sequence in the eth_w5500 have some problems now?

@decsny can you be more specific, I'm not sure what you are referring to?

Copy link
Member

@decsny decsny left a comment

Choose a reason for hiding this comment

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

approving because I'm assuming it works but what I meant is, doesn't the w5500 driver init still happen and will it conflict with what the w550io init is doing

@gramsay0
Copy link
Contributor Author

approving because I'm assuming it works but what I meant is, doesn't the w5500 driver init still happen and will it conflict with what the w550io init is doing

Both the wiz550io and w5500 init occur. wiz550io has two asserts to prevent conflicts:

  • wiz550io init occurs first
  • w5500 device does not have GPIO reset enabled (SW reset is ok)

If neither "zephyr,random-mac-address" or "local-mac-address" are configured, w5500 leaves the mac address untouched, which in this case will use the wiz550io embedded MAC address

Copy link
Member

@parthitce parthitce left a comment

Choose a reason for hiding this comment

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

IMO the core view of the PR is fully changed. This is how I understand it as a whole,

  • WIZ550io uses W5500 + X IC to configure the MAC to be unique
  • This is notified to the consumer over a GPIO line to inform that the W5500 chip ready with unique mac address

So the only difference between W5500 and WIZ550io is to have unique MAC address. Regarding the bindings part, I ACK'd the ready-gpio part, which is arguably in WIZ550io binding (which uses w5500 binding). But technically this is MAC address handling for W5500, which shall reside in w5500 driver itself.

But I don't really understand the reason behind moving ethernet code to drivers/misc? Also additional Kconfig? Really IMO this is off track and unmanageable AFAIK. NACK!

@decsny decsny added the dev-review To be discussed in dev-review meeting label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Ethernet area: Shields Shields (add-on boards) dev-review To be discussed in dev-review meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants