-
Notifications
You must be signed in to change notification settings - Fork 8.1k
drivers: ethernet: phy: add driver for ksz9131 #90711
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
base: main
Are you sure you want to change the base?
Conversation
Add an entry to https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/drivers/build_all/ethernet/app.overlay so it builds in CI. |
6944d51
to
5055226
Compare
@pdgendt An entry for ksz9131 added to |
@TonyHan11 pls add PR description and address the things from sonarqube |
@maass-hamburg updated with removing the unused property, renaming |
5055226
to
cfd8c64
Compare
1ac4658
to
e7778f7
Compare
@maass-hamburg
|
ffe8e46
to
94224d7
Compare
Resolve the CI error by rebasing the commits (without changes). |
94224d7
to
35d32e6
Compare
reg_val |= PHY_KSZ9131_ICS_LINK_UP_IE_MASK | PHY_KSZ9131_ICS_LINK_DOWN_IE_MASK; | ||
|
||
/* Write settings to Interrupt Control/Status register */ | ||
ret = ksz9131_write(dev, 27, reg_val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use PHY_KSZ9131_ICS_REG macro instead of magic number
goto done; | ||
} | ||
|
||
gpio_init_callback(&data->gpio_callback, phy_mc_ksz8081_interrupt_handler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gpio_init_callback(&data->gpio_callback, phy_mc_ksz8081_interrupt_handler, | |
ret = gpio_init_callback(&data->gpio_callback, phy_mc_ksz8081_interrupt_handler, |
rebased, thanks. |
ef7bf97
to
a2640e1
Compare
drivers/ethernet/phy/Kconfig
Outdated
depends on MDIO | ||
depends on GPIO || (!$(dt_compat_any_has_prop,$(DT_COMPAT_MICROCHIP_KSZ9131),reset-gpios) && \ | ||
!$(dt_compat_any_has_prop,$(DT_COMPAT_MICROCHIP_KSZ9131),int-gpios)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply changes from #94806
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and updated with the changes applied.
uint16_t anar = 0; | ||
int ret = 0; | ||
|
||
(void)config; /* avoid warnings due to config is only used in LOG_DBG() */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use __maybe_unused
attribute on config instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.
goto done; | ||
} | ||
|
||
ret = phy_mchp_ksz9131_autonegotiate(dev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding the changes from #93118 here too and using phy_mii_cfg_link_autoneg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve some of the logging.
No changes with auto-negotiate due to no block issue in ksz9131 using interrupt mode.
It seems that the interrupt mode for ksz8081 is not fully supported in the PR.
a2640e1
to
93fc888
Compare
93fc888
to
cc48784
Compare
cc48784
to
9201e0f
Compare
Dropped the commit for adding interrupt mode support for ksz8081 as it has conflicts with the code on mainline. |
Support for ksz8081 interrupt mode added in #95305 |
9201e0f
to
7ecff65
Compare
Updated ksz9131 driver with:
|
} | ||
} | ||
|
||
ret = phy_mchp_ksz9131_get_link(dev, &state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to apply the changes of 4683dae here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied by adding an additional commit.
} else { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call phy_mchp_ksz9131_speed
here, instead of in phy_mchp_ksz9131_get_link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added phy_mchp_ksz9131_speed()
to the else
branch inside phy_mchp_ksz9131_gigabit()
.
ret = phy_mchp_ksz9131_update_anar(dev, adv_speeds); | ||
if (ret < 0) { | ||
goto done; | ||
} | ||
|
||
ret = ksz9131_read(dev, MII_1KTCR, &c1kt); | ||
if (ret < 0) { | ||
goto done; | ||
} | ||
|
||
if (adv_speeds & LINK_FULL_1000BASE) { | ||
c1kt |= MII_ADVERTISE_1000_FULL; | ||
} else { | ||
c1kt &= ~MII_ADVERTISE_1000_FULL; | ||
} | ||
|
||
if (adv_speeds & LINK_HALF_1000BASE) { | ||
c1kt |= MII_ADVERTISE_1000_HALF; | ||
} else { | ||
c1kt &= ~MII_ADVERTISE_1000_HALF; | ||
} | ||
|
||
ret = ksz9131_write(dev, MII_1KTCR, c1kt); | ||
if (ret < 0) { | ||
goto done; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't want to use phy_mii_cfg_link_autoneg
, at least use phy_mii_set_anar_reg
and phy_mii_set_c1kt_reg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced this lines with phy_mii_set_anar_reg
and phy_mii_set_c1kt_reg
, thanks a lot.
Add support for KSZ9131 (Gigabit Ethernet Transceiver with RGMII Support). As first starter, 100MBit/s mode is tested. https://www.microchip.com/en-us/product/ksz9131 Signed-off-by: Tony Han <[email protected]>
Add build tests for Microchip KSZ9131. Signed-off-by: Tony Han <[email protected]>
Enable Link-Up and Link-Down interrupts. On the interrupt handling the monitor work is scheduled to update the link status and calling corresponding callback routine. Signed-off-by: Tony Han <[email protected]>
Read gigabit status from Master Slave Status Register. Signed-off-by: Tony Han <[email protected]>
477a671
to
2b6b529
Compare
Get the link state in the monitor and save it for get_link api implementation to use. Signed-off-by: Tony Han <[email protected]>
|
# Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Microchip KSZ9131 Ethernet PHY device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @TonyHan11 ,
I think you already know:
- re-order
- split the content and put in the correct dependency order
- you need board that uses this phy
This PR includes: