MDIO on GPIOs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MDIO on GPIOs

MDIO on GPIOs

In some cases, due to the limited resources allocated by imx pins, gpio has to be used as mdio/mdc.

This article is a simple guide on how to use MDIO on GPIOs.

The demo code is for network fec interface.

1. Add CONFIG_MDIO_GPIO=y and rebuild kernel

2. Modify fec device tree to use MDIO ON GPIO

FEC test result:

root@imx93evk:~# ethtool eth0

Settings for eth0:

        Supported ports: [ TP    MII ]

        Supported link modes:   10baseT/Half 10baseT/Full

                                100baseT/Half 100baseT/Full

                                1000baseT/Full

        Supported pause frame use: Symmetric

        Supports auto-negotiation: Yes

        Supported FEC modes: Not reported

        Advertised link modes:  10baseT/Half 10baseT/Full

                                100baseT/Half 100baseT/Full

                                1000baseT/Full

        Advertised pause frame use: Symmetric

        Advertised auto-negotiation: Yes

        Advertised FEC modes: Not reported

        Link partner advertised link modes:  10baseT/Half 10baseT/Full

                                             100baseT/Half 100baseT/Full

                                             1000baseT/Full

        Link partner advertised pause frame use: No

        Link partner advertised auto-negotiation: Yes

        Link partner advertised FEC modes: Not reported

        Speed: 1000Mb/s

        Duplex: Full

        Auto-negotiation: on

        master-slave cfg: preferred slave

        master-slave status: slave

        Port: Twisted Pair

        PHYAD: 2

        Transceiver: external

        MDI-X: Unknown

        Supports Wake-on: g

        Wake-on: d

        Link detected: yes

root@imx93evk:~# ifconfig

eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500

        inet 10.192.246.129  netmask 255.255.255.0  broadcast 10.192.246.255

        inet6 fe80::885a:aeff:fea3:7dcf  prefixlen 64  scopeid 0x20<link>

        ether 8a:5a:ae:a3:7d:cf  txqueuelen 1000  (Ethernet)

        RX packets 13  bytes 2294 (2.2 KiB)

        RX errors 0  dropped 3  overruns 0  frame 0

        TX packets 25  bytes 4691 (4.5 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

eth1: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC>  mtu 1500

        ether a2:5e:45:17:72:79  txqueuelen 1000

 

eQOS test result

imx93evk login: root
root@imx93evk:~# ifconfig
eth0: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC> mtu 1500
ether 00:04:9f:08:7f:d0 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth1: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC> mtu 1500
inet 10.192.246.112 netmask 255.255.255.0 broadcast 10.192.246.255
inet6 fe80::204:9fff:fe08:7fcf prefixlen 64 scopeid 0x20<link>
ether 00:04:9f:08:7f:cf txqueuelen 1000 (Ethernet)
RX packets 12 bytes 3020 (2.9 KiB)
RX errors 0 dropped 3 overruns 0 frame 0
TX packets 31 bytes 5355 (5.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 104

root@imx93evk:~# ethtool eth1
Settings for eth1:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Auto-negotiation: on
master-slave cfg: preferred slave
master-slave status: slave
Port: Twisted Pair
PHYAD: 1
Transceiver: external
MDI-X: Unknown
Supports Wake-on: ug
Wake-on: d
Current message level: 0x0000003f (63)
drv probe l

Attachments
No ratings
Version history
Last update:
‎01-22-2025 11:28 PM
Updated by: