Add support to control PHY LEDs
Subsystems (3)
PATCH 1/1 Add support to control PHY LEDs
Hi all,
We had a requirement to disable the PHY link LEDs during system standby mode without turning off the ethernet module. To achieve that, I have prepared the sysfs interface turn on/off the PHY link LEDs.
Please suggest if there is any better way to achieve this.
Thanks,
Vishal
Vishal Thanki (1):
net: phy: at803x: Add support to control PHY LEDs
drivers/net/phy/Kconfig | 7 +++++ drivers/net/phy/at803x.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)
Signature · 1 line
2.4.3
PATCH 1/1 net: phy: at803x: Add support to control PHY LEDs
The LEDs can be turned on and off by a sysfs interface now. Write 0 to "led_enable" file to turn off the LEDs and write 1 to turn on. The support is experimental and can be enabled by kernel configuration option.
--- drivers/net/phy/Kconfig | 7 +++++ drivers/net/phy/at803x.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)
drivers/net/phy/Kconfig +7 -0
@@ -24,6 +24,13 @@ config AT803X_PHY ---help--- Currently supports the AT8030 and AT8035 model +config AT803X_PHY_LED_CONTROL + depends on AT803X_PHY + bool "Support for PHY LED control (Experimental)" + ---help--- + This option enables a sysfs interface to turn on and off the link + LEDs attached to phy. + config AMD_PHY tristate "Drivers for the AMD PHYs" ---help---
drivers/net/phy/at803x.c +71 -0
119 lines not on this page · raw message
Signature · 1 line
2.4.3
Andrew Lunn
maintainerRe: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Quoted 9 lines · Vishal Thanki
The LEDs can be turned on and off by a sysfs interface now. Write 0 to "
led_enable" file to turn off the LEDs and write 1 to turn on. The support is experimental and can be enabled by kernel configuration option.Signed-off-by Vishal Thanki <[email protected]>--- drivers/net/phy/Kconfig | 7 +++++ drivers/net/phy/at803x.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
Hi Vishal
This solution seems specific to the at803. You should be thinking of a generic solution that all PHYs can use. eg add a new callback function to phy_driver, and put the sysfs handling code in phylib.
Andrew
Re: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Quoted 11 lines · Andrew Lunn
Quoted 9 lines · Vishal Thanki
The LEDs can be turned on and off by a sysfs interface now. Write 0 to "
led_enable" file to turn off the LEDs and write 1 to turn on. The support is experimental and can be enabled by kernel configuration option.Signed-off-by Vishal Thanki <[email protected]>--- drivers/net/phy/Kconfig | 7 +++++ drivers/net/phy/at803x.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 5 lines
Hi Vishal
This solution seems specific to the at803. You should be thinking of a generic solution that all PHYs can use. eg add a new callback function to
phy_driver, and put the sysfs handling code in phylib.
Indeed, maybe we should be considering using the existing LEDS subsystem (drivers/leds/*) to expose the PHY LEDs to user-space in a standard way?
Signature · 1 line
Florian
Re: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Quoted 14 lines · Florian Fainelli
Quoted 13 lines · Andrew Lunn
Quoted 9 lines · Vishal Thanki
The LEDs can be turned on and off by a sysfs interface now. Write 0 to "
led_enable" file to turn off the LEDs and write 1 to turn on. The support is experimental and can be enabled by kernel configuration option.Signed-off-by Vishal Thanki <[email protected]>--- drivers/net/phy/Kconfig | 7 +++++ drivers/net/phy/at803x.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++Hi Vishal
Quoted 7 lines
Quoted 3 lines
This solution seems specific to the at803. You should be thinking of a generic solution that all PHYs can use. eg add a new callback function to
phy_driver, and put the sysfs handling code in phylib.Indeed, maybe we should be considering using the existing LEDS subsystem (
drivers/leds/*) to expose the PHY LEDs to user-space in a standard way? --
I agree with the idea of making a generic callback in phy_driver so that other PHYs
can use it. However I think these LEDs are tightly coupled with PHYs and it would not make much sense to expose them via LED subsystem as they cannot be controlled individually IMHO.
Quoted 1 line
Florian
Andrew Lunn
maintainerRe: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Quoted 5 lines
I agree with the idea of making a generic callback in
phy_driverso that other PHYs
can use it. However I think these LEDs are tightly coupled with PHYs and it would not make much sense to expose them via LED subsystem as they cannot be controlled individually IMHO.
They might not be on/off controllable individually, but you can often set them to show Packet RX, Packet TX, Link, speed, etc, in a reasonably flexible way. So you could have LED triggers mapping to these functionalities. The user can then pick the trigger for the LED.
Actually, the data sheet says:
2.3.4 LED Interface
The LED interface can either be controlled by the PHY or controlled manually, independent of the state of the PHY. Two status LEDs are available. These can be used to indicate operation speed, and link status. The LEDs can be programmed to different status functions from their default value. They can also be controlled directly from the MII register interface.
So maybe you can control the on/off state.
Andrew
Re: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Quoted 10 lines
They might not be on/off controllable individually, but you can often set them to show Packet RX, Packet TX, Link, speed, etc, in a reasonably flexible way. So you could have LED triggers mapping to these functionalities. The user can then pick the trigger for the LED.
Actually, the data sheet says:
2.3.4 LED Interface
Quoted 9 lines
The LED interface can either be controlled by the PHY or controlled manually, independent of the state of the PHY. Two status LEDs are available. These can be used to indicate operation speed, and link status. The LEDs can be programmed to different status functions from their default value. They can also be controlled directly from the MII register interface.
So maybe you can control the on/off state.
I need to explore more on LED subsystem. Thank you for your suggestions and input.
Thanks,
Vishal
Quoted 1 line
Andrew
Re: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Hi,
Quoted 17 lines · Vishal Thanki
Quoted 17 lines
They might not be on/off controllable individually, but you can often set them to show Packet RX, Packet TX, Link, speed, etc, in a reasonably flexible way. So you could have LED triggers mapping to these functionalities. The user can then pick the trigger for the LED.
Actually, the data sheet says:
2.3.4 LED Interface
The LED interface can either be controlled by the PHY or controlled manually, independent of the state of the PHY. Two status LEDs are available. These can be used to indicate operation speed, and link status. The LEDs can be programmed to different status functions from their default value. They can also be controlled directly from the MII register interface.
Quoted 2 lines
Quoted 2 lines
So maybe you can control the on/off state.
I need some more understanding on using the LED subsystem for this task. Pardon my lack of knowledge, and probably silly questions too.
Here is what I understood when we decide to use the LED subsystem for exposing PHY LEDs.
1) Have a generic driver under drivers/leds/, for example leds-eth-phy.c
2) Implement a set of phylib APIs which will be used by generic phy led driver to set the brightness.
3) The phylib APIs will depend on actual PHY driver, at803x.c for example, (by means of callbacks implemented in PHY driver) to control LEDs.
4) PHY driver can advertise its support for LEDs using the capability flags.
Please let me know if my understanding is correct.
Thanks,
Vishal
Quoted 1 line
Andrew Lunn
maintainerRe: [PATCH] net: phy: at803x: Add support to control PHY LEDs
Quoted 37 lines · Vishal Thanki
Hi,
Quoted 17 lines · Vishal Thanki
Quoted 17 lines
They might not be on/off controllable individually, but you can often set them to show Packet RX, Packet TX, Link, speed, etc, in a reasonably flexible way. So you could have LED triggers mapping to these functionalities. The user can then pick the trigger for the LED.
Actually, the data sheet says:
2.3.4 LED Interface
The LED interface can either be controlled by the PHY or controlled manually, independent of the state of the PHY. Two status LEDs are available. These can be used to indicate operation speed, and link status. The LEDs can be programmed to different status functions from their default value. They can also be controlled directly from the MII register interface.
Quoted 2 lines
Quoted 2 lines
So maybe you can control the on/off state.
I need some more understanding on using the LED subsystem for this task. Pardon my lack of knowledge, and probably silly questions too.
Here is what I understood when we decide to use the LED subsystem for exposing PHY LEDs.
1) Have a generic driver under
drivers/leds/, for exampleleds-eth-phy.c
2) Implement a set of phylib APIs which will be used by generic phy led driver to set the brightness.
3) The phylib APIs will depend on actual PHY driver,at803x.cfor example, (by means of callbacks implemented in PHY driver) to control LEDs.
4) PHY driver can advertise its support for LEDs using the capability flags.
Quoted 1 line
Please let me know if my understanding is correct.
LEDs are more than brightness. They can also have triggers.
It would require some rework of the LED core, but you could imagine being able to associate triggers to specific LEDs. You could have triggers like "eth-phy-link" and "eth-phy-activity" which the phylib and phy driver exports. The PHY would export LEDs and say that they can be used with these triggers. So when for example the "eth-phy-link" trigger is activated on an LED, the PHY driver programs the hardware to show the link status on the LED.
The key here is that the hardware is in control of the LED, when the trigger is used. You don't want software involved when you are transmitting a million packets per second.
Andrew
Andrew Lunn
maintainerQuoted 5 lines · Vishal Thanki
Hi all,
We had a requirement to disable the PHY link LEDs during system standby mode without turning off the ethernet module. To achieve that, I have prepared the sysfs interface turn on/off the PHY link LEDs.
Hi Vishal
Could you implement this in at803x_suspend()?
Andrew