LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2023, 03:06 AM   #1
Javiku
LQ Newbie
 
Registered: Sep 2023
Posts: 4

Rep: Reputation: 0
How to describe PHY Wake on LAN in the device tree


I have a Rockchip-based embedded system that supports the suspend-to-RAM power mode. I want the system to wake up when the PHY receives a Wake on LAN magic packet because the MAC is not powered in suspend. So I would expect the PHY to generate an interrupt that acts as a wakeup source.
The PHY in question (TI DP83826E) can generate interrupts when a magic packet is received and Wake on LAN works fine in freeze mode, where all voltages are still available. That is simply because the MAC is still powered and it reacts to the magic packet.
I configured the PHY registers manually via mdio to get the right configuration and it generates interrupts as expected. On the other hand the driver does not configure it that way automatically and maybe that is so because I blundered in the device tree description. Defining the PHY output as an interrupt source does not seem to be the right approach because then it is used as an interrupt source for a number of events the MAC might find relevant, not just WoL. A second attempt was adding the wakeup-source property, which did not help.

These are the nodes that describe the MAC and the PHY:

Code:
&gmac0 {
        assigned-clocks = <&cru SCLK_GMAC0_RX_TX>,
                          <&cru SCLK_GMAC0>;
        assigned-clock-parents = <&cru SCLK_GMAC0_RMII_SPEED>,
                          <&gmac0_clkin>;
        clock_in_out = "input";
        phy-handle = <&dp83826>;
        phy-mode = "rmii";
        phy-supply = <&vcc3v3_eth>;
        pinctrl-names = "default";
        pinctrl-0 = <&gmac0_miim
                     &gmac0_clkinout
                     &gmac0_rx_er
                     &gmac0_rx_bus2
                     &gmac0_tx_bus2>;
        status = "okay";
};

&mdio0 {
        #address-cells = <1>;
        #size-cells = <0>;

        dp83826: ethernet-phy@0 {
                compatible = "ethernet-phy-ieee802.3-c22";
                reg = <0x0>;
                interrupt-parent = <&gpio0>;
                interrupts = <RK_PD3 IRQ_TYPE_EDGE_FALLING>;
                pinctrl-names = "default";
                pinctrl-0 = <&eth_wake_intn &eth_phy_rstn>;
                reset-assert-us = <1000>;
                reset-deassert-us = <2000>;
                reset-gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_LOW>;
                wakeup-source;
        };
};
where eth_wake_intn is a gpio.

Does anyone know how to configure this properly? Maybe I am aiming for an unsupported functionality and the MAC must be always available, but then I wonder why the PHY supports interrupts upon magic packet reception. I would expect the MAC to poll the PHY for any information it requires and leave the PHY interrupt available for WoL.

Thanks and best regards
 
Old 11-21-2023, 08:02 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
If the NIC card support Wake on LAN, most Linux distribution can support it. You can use ethertool to activate/deactivate it.
 
Old 11-22-2023, 01:51 AM   #3
Javiku
LQ Newbie
 
Registered: Sep 2023
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nini09 View Post
If the NIC card support Wake on LAN, most Linux distribution can support it. You can use ethertool to activate/deactivate it.
I am working on an embedded system, but ethtool is available and it shows that wake-on-lan is supported and active. Nevertheless I believe that it only works at the MAC level, and not at the PHY level, which is what I need. In freeze mode, where the MAC voltages are still enabled, I can use wake on LAN normally. That does not work in suspend (suspend-to-RAM) though, which points to the fact that it only works as long as the MAC is available.
Note that the PHY supports wake on LAN and it is able to generate interrupts for magic packets, which I could configure manually by accessing its registers via MDIO bus. That is of course not a valid solution because I need the system to configure the PHY properly and therefore I need some proper configuration in the device tree.
 
Old 11-22-2023, 02:39 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
The Wake on LAN need both PHY and MAC normally.
 
Old 11-23-2023, 07:51 AM   #5
Javiku
LQ Newbie
 
Registered: Sep 2023
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nini09 View Post
The Wake on LAN need both PHY and MAC normally.
I thought that setting the STMMAC_FLAG_USE_PHY_WOL flag in dwmac-rk.c would be exactly what I am looking for, but I did not make it work yet. I sent an RFC to the relevant mailing lists with a small patch where I set that flag and hopefully someone can tell me if that makes sense at all. Otherwise I will have to live with the hack we are using to make that work (using the PHY interrupt line as a named GPIO and marking it as a wakeup-source, which has many drawbacks).
 
  


Reply

Tags
wakeonlan



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Categorize the output of ec2-describe-images or ec2-describe-instances amit.naudiyal Linux - General 0 01-15-2012 12:35 AM
Can I wake up a server in "standby" or "memory" mode using wake-on-lan? songweijia Linux - Server 2 03-03-2010 06:51 PM
wake on lan magic packet does not wake. albean Linux - Networking 1 06-30-2007 03:57 PM
Marvell Gbit LAN PHY 88E1111 Compatibility mhbell Linux - Networking 2 03-01-2006 09:51 AM
search linux driver for CICADA8201 Gigabit LAN PHY chip deb75 Linux - Hardware 0 02-21-2006 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration