Skip to content

Conversation

TonyHan11
Copy link
Contributor

@TonyHan11 TonyHan11 commented May 28, 2025

This PR includes:

  • add the driver for Microchip KSZ9131 Ethernet PHY
  • add interrupt mode support for KSZ8081

@pdgendt
Copy link
Contributor

pdgendt commented May 28, 2025

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 6944d51 to 5055226 Compare May 28, 2025 08:09
@TonyHan11
Copy link
Contributor Author

@pdgendt An entry for ksz9131 added to tests/drivers/build_all/ethernet/app.overlay, thanks.

@maass-hamburg
Copy link
Member

@TonyHan11 pls add PR description and address the things from sonarqube

@TonyHan11
Copy link
Contributor Author

@maass-hamburg updated with removing the unused property, renaming LINK_*BASED_T and fixing if (ret), thank you very much.

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 5055226 to cfd8c64 Compare May 29, 2025 01:21
@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch 4 times, most recently from 1ac4658 to e7778f7 Compare June 3, 2025 04:41
@TonyHan11
Copy link
Contributor Author

@maass-hamburg
Thank you for your comments. Commits updated with the following changes:

  • using goto instead of do while (0)
  • update if (ret) to if (ret < 0)
  • fix the issues reported by SonarQube Cloud
  • remove comments TODO change this to GPIO interrupt driven

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch 2 times, most recently from ffe8e46 to 94224d7 Compare June 9, 2025 04:51
@TonyHan11
Copy link
Contributor Author

Resolve the CI error by rebasing the commits (without changes).

@TonyHan11 TonyHan11 requested a review from maass-hamburg June 9, 2025 05:30
@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 94224d7 to 35d32e6 Compare June 10, 2025 09:27
maass-hamburg
maass-hamburg previously approved these changes Jun 10, 2025
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);
Copy link
Contributor

@kartben kartben Jun 26, 2025

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
gpio_init_callback(&data->gpio_callback, phy_mc_ksz8081_interrupt_handler,
ret = gpio_init_callback(&data->gpio_callback, phy_mc_ksz8081_interrupt_handler,

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch 2 times, most recently from 8892b25 to 6f9aced Compare June 30, 2025 04:53
@TonyHan11 TonyHan11 requested a review from maass-hamburg June 30, 2025 05:33
@kartben kartben added this to the v4.3.0 milestone Jul 1, 2025
@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch 2 times, most recently from 27c6e59 to 5a9a2c6 Compare July 2, 2025 03:33
@TonyHan11 TonyHan11 requested a review from kartben July 15, 2025 08:17
@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 5a9a2c6 to 50f538d Compare July 17, 2025 06:12
@TonyHan11
Copy link
Contributor Author

Rebased to the latest main branch.

struct k_work_delayable monitor_work;
struct phy_link_state state;
struct k_sem sem;
bool gigabit_supported;
Copy link
Member

Choose a reason for hiding this comment

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

gigabit_supported bool is not needed, as this phy definetly supports gigabit and it be always be true, it is only in the generic phy driver, because there we don't know it because we don't know durring build if gigabit is supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with removing gigabit_supported and code related. Thanks.

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 50f538d to 3e074d0 Compare July 18, 2025 08:08
@TonyHan11 TonyHan11 requested a review from maass-hamburg July 23, 2025 01:58
@maass-hamburg
Copy link
Member

@TonyHan11 please rebase to current main

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 3e074d0 to a762fa7 Compare August 4, 2025 01:13
@TonyHan11
Copy link
Contributor Author

@TonyHan11 please rebase to current main

rebased, thanks.

LOG_ERR("PHY (%d) init failed", cfg->phy_addr);
}

return ret;
Copy link
Member

Choose a reason for hiding this comment

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

apply changes from #91572 also to this phy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with adding default-speeds for ksz9131, thanks.

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch 2 times, most recently from ef7bf97 to a2640e1 Compare August 4, 2025 09:40
Comment on lines 59 to 61
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))
Copy link
Member

Choose a reason for hiding this comment

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

apply changes from #94806

Copy link
Contributor Author

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() */
Copy link
Member

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

Copy link
Contributor Author

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);
Copy link
Member

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

Copy link
Contributor Author

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.

@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from a2640e1 to 93fc888 Compare August 28, 2025 07:20
@zephyrbot zephyrbot requested a review from ClaCodes August 28, 2025 07:21
@TonyHan11 TonyHan11 force-pushed the phy_ksz9131_ksz8081 branch from 93fc888 to cc48784 Compare August 28, 2025 07:51
Copy link

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 <tony.han@microchip.com>
Add build tests for Microchip KSZ9131.

Signed-off-by: Tony Han <tony.han@microchip.com>
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 <tony.han@microchip.com>
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 <tony.han@microchip.com>
Read gigabit status from Master Slave Status Register.

Signed-off-by: Tony Han <tony.han@microchip.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants