Skip to content

Commit f845cdd

Browse files
arvinfnashif
authored andcommitted
drivers: Add Ethernet PHY API
This commit adds support for Ethernet PHY drivers via a PHY API. It also includes a driver for a generic MII compliant PHY which supports most PHYs on the market. Separating PHY driver from the SoC specific Ethernet driver simplifies the Ethernet driver code and enables code re-use. Drivers for specific PHYs with more advanced features, such as RGMII delay in PHY can be developed independent of the Ethernet MAC driver. Signed-off-by: Arvin Farahmand <[email protected]>
1 parent 2bec758 commit f845cdd

File tree

9 files changed

+749
-0
lines changed

9 files changed

+749
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
/drivers/ethernet/*stm32* @Nukersson @lochej
223223
/drivers/ethernet/*w5500* @parthitce
224224
/drivers/ethernet/*xlnx_gem* @ibirnbaum
225+
/drivers/ethernet/phy/ @rlubos @tbursztyka @arvinf
225226
/drivers/mdio/ @rlubos @tbursztyka @arvinf
226227
/drivers/flash/ @nashif @nvlsianpu
227228
/drivers/flash/*b91* @yurvyn

drivers/ethernet/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ if(CONFIG_ETH_NATIVE_POSIX)
4040
eth_native_posix_adapt.c
4141
)
4242
endif()
43+
44+
add_subdirectory(phy)

drivers/ethernet/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ source "drivers/ethernet/Kconfig.w5500"
5959
source "drivers/ethernet/Kconfig.dsa"
6060
source "drivers/ethernet/Kconfig.xlnx_gem"
6161

62+
source "drivers/ethernet/phy/Kconfig"
63+
6264
endmenu # "Ethernet Drivers"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
5+
zephyr_library_sources_ifdef(CONFIG_PHY_GENERIC_MII phy_mii.c)

drivers/ethernet/phy/Kconfig

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Ethernet PHY drivers configuration options
2+
3+
# Copyright (c) 2021 IP-Logix Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
menu "Ethernet PHY Drivers"
7+
depends on NET_L2_ETHERNET
8+
9+
module = PHY
10+
module-dep = LOG
11+
module-str = Log level for Ethernet PHY driver
12+
module-help = Sets log level for Ethernet PHY Device Drivers.
13+
source "subsys/net/Kconfig.template.log_config.net"
14+
15+
config PHY_INIT_PRIORITY
16+
int "Ethernet PHY driver init priority"
17+
default 70
18+
help
19+
Ethernet PHY device driver initialization priority.
20+
Do not mess with it unless you know what you are doing.
21+
Note that the priority needs to be lower than the net stack
22+
so that it can start before the networking sub-system.
23+
24+
config PHY_GENERIC_MII
25+
bool "Generic MII PHY Driver"
26+
default y
27+
depends on MDIO
28+
help
29+
This is a generic MII PHY interface that communicates with the
30+
PHY using the MDIO bus.
31+
32+
config PHY_AUTONEG_TIMEOUT_MS
33+
int "Auto-negotiation timeout value in milliseconds"
34+
default 4000
35+
help
36+
Maximum duration of auto-negotiation sequence in milliseconds
37+
before the process fails
38+
39+
config PHY_MONITOR_PERIOD
40+
int "Monitor task execution period"
41+
default 500
42+
help
43+
Monitor task execution period in milliseconds. The monitor task is
44+
periodically executed to detect and report any changes in the
45+
PHY link status to the operating system.
46+
47+
endmenu # "Ethernet PHY Drivers"

0 commit comments

Comments
 (0)