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

driver: ethernet: add adin2111 #57848

Merged
merged 4 commits into from
May 26, 2023
Merged

Conversation

GeorgeCGV
Copy link
Collaborator

@GeorgeCGV GeorgeCGV commented May 12, 2023

Adds initial ADIN2111 2-Port 10BASE-T1L (Single Pair Ethernet [SPE]) switch support (implementation wise not really a switch). It works over SPI using ADI Generic SPI protocol instead of OPEN Alliance.

SPE:

Single Pair Ethernet (SPE) describes the transmission of Ethernet via only one pair of copper wires.
It provides the necessary infrastructure for the Industrial Internet of Things (IIoT)

ADIN2111 overview:

The ADIN2111 is a low power, 2-port 10BASE-T1L transceiver designed for industrial Ethernet applications, and is compliant with the IEEE® 802.3cg-2019™ Ethernet standard for long reach, 10 Mbps single pair Ethernet (SPE). Featuring an integrated media access control (MAC) and a switch, the ADIN2111 enables direct connectivity with a variety of controllers via a serial peripheral interface (SPI). The switch (cut through or store and forward) supports various routing configurations between the two Ethernet ports and the SPI host port providing a flexible solution for line, daisy-chain, or ring network topologies.

The ADIN2111 can be used in unmanaged configurations where the device automatically forwards the traffic between the two Ethernet ports.

The driver creates 2 eth interfaces, one for each port (PHY). Didn't use DSA as I am not sure if it fits.
It configures multicast and broadcast reception and forwarding.

Supports:

  • Link state detection via INT that is detected in the main driver and handled by PHY's driver
  • Works with CRC enabled and without
  • Provides separate drivers for MDIO and PHY.
    Where MDIO uses exposed functions of the main driver. PHY utilizes MDIO API and exposed MDIO
    functions to access Clause 45 registers.*
  • MDIO driver is integrated into the shell. There it exposes Clause 22 registers.
  • PHY hardware fault detection (at init)
  • PHY LED0, LED1 enable/disable
  • PHY TX 2.4V Mode enable/disable and ability detection
  • Ports ETH stats
  • Interface set config (MAC)

This PR doesn't modify existing APIs to not be intrusive. At the same time, the goal was to make use
of existing MDIO and PHY APIs.

Tested on custom hardware.

The existing MDIO API is very restrictive. Currently, MDIO API doesn't support Clause 45 and Clause 22 at the same time. It exposes read and write calls that are either Clause 45 or Clause 22. However, for C45 it misses the device address from the function definition. Not sure how Clause 45 works for others there.

The PHY driver shall access registers over MDIO via Clause 45 and Clause 22.

That can be solved by the introduction of specific Clause 22 and Clause 45 functions into MDIO. This would allow us not to touch the existing API but still support other cases. The alternative is to modify read and write register API functions and change reg. address type to uint32_t to integrate the device and register address in it. However, the Linux kernel went away from that approach.

Another point relates to MDIO locking. I would like to lock the whole device while MDIO is in use by the public (i.e. shell). That allows it to prevent access while it processes frame transfer, IRQ offload, or something else where sequential access to MDIO is required.

The current API doesn't provide a way to lock/unlock the MDIO bus. However, there are the enable and disable calls.

I avoided API modification proposals at this stage and implemented enable and disable as device lock/unlock. That works. However, I assume the meaning behind enable and disable won't be correct.

Should MDIO API be revised/revisited?

@gmarull, @henrikbrixandersen I hope select and depends on are not messed up.

Open for review, suggestions, comments.

@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: Ethernet labels May 12, 2023
@GeorgeCGV GeorgeCGV force-pushed the eth_adin2111 branch 4 times, most recently from 5ad982c to bee76c1 Compare May 15, 2023 08:34
@GeorgeCGV GeorgeCGV marked this pull request as draft May 15, 2023 10:03
@GeorgeCGV GeorgeCGV marked this pull request as ready for review May 15, 2023 14:33
Adds initial ADIN2111 2-Port 10BASE-T1L (SPE)
switch support. Works over SPI.

The driver creates 2 interfaces, 1 per port (PHY).
Configures multicast and broadcast filters.
The same unicast is applied to both ports.

Supports:
  - Link state detection
  - CRC enable/disable
  - Ports config set
  - Ports ETH stats

Provides functions for MDIO driver.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Adds MDIO driver. Works via exposed
ADIN2111 functions.

It is possible to access Clause 45 and 22 registers.

Due to MDIO API limitation Clause 45 access
is done using driver specific MDIO functions.

Provides API and functions for PHY driver.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Adds supprot of ADIN2111 MDIO.

The shell allows to access Clause 22 registers.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Adds PHY driver. Works via MDIO API and
exposed ADIN2111 MDIO Clause 45
functions.

Link status detection is triggered by
ADIN2111 driver within offloaded IRQ
handler.

Supports:
  - LED0, LED1 enable/disable
  - Fatal HW error detection
  - AN 2.4V tx mode enable/disable

The initialization order is important.
PHY 2 must be initialized after PHY1.
Therefore, it shall be defined after the 1st one
in the devicetree.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
@nashif nashif merged commit b0acced into zephyrproject-rtos:main May 26, 2023
24 checks passed
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: Drivers area: Ethernet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants