drivers: net: phy: at803x: Add missing mdio device id
Subsystems (3)
PATCH 1/2 drivers: net: phy: at803x: Add missing mdio device id
at803x supports Atheros 8030, 8031 and 8035 PHYs. 8031 was missing from the mdio device id table.
--- drivers/net/phy/at803x.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/at803x.c +1 -0
@@ -217,6 +217,7 @@ module_exit(atheros_exit);static struct mdio_device_id __maybe_unused atheros_tbl[] = { {0x004dd076 ,0xffffffef }, + {0x004dd074 ,0xffffffef }, {0x004dd072 ,0xffffffef }, { } };
Signature · 1 line
1.7.10.4
PATCH 2/2 drivers: net: phy: at803x: LED control via led subsystem
The AT8035 PHY allows to control the LED PIN behavior from software. Expose this functionality by registering an LED device.
--- drivers/net/phy/Kconfig | 7 ++++ drivers/net/phy/at803x.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)
drivers/net/phy/Kconfig +7 -0
@@ -19,6 +19,13 @@ config AT803X_PHY ---help--- Currently supports the AT8030 and AT8035 model +config AT803X_LEDS + bool "Enable access to PHY connected LEDs" + depends on AT803X_PHY && LEDS_CLASS + ---help--- + Select this to be able to control LEDs connected to the + PHY from userspace + config AMD_PHY tristate "Drivers for the AMD PHYs" ---help---
drivers/net/phy/at803x.c +87 -0
111 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 2/2] drivers: net: phy: at803x: LED control via led subsystem
Hello Helmut,
2013/7/11 Helmut Schaa <[email protected]>:
Quoted 68 lines
The AT8035 PHY allows to control the LED PIN behavior from software. Expose this functionality by registering an LED device.
Signed-off-by Helmut Schaa <[email protected]>--- drivers/net/phy/Kconfig | 7 ++++ drivers/net/phy/at803x.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)drivers/net/phy/Kconfig +7
-0@@ -19,6 +19,13 @@ config AT803X_PHY ---help--- Currently supports the AT8030 and AT8035 model +config AT803X_LEDS + bool "Enable access to PHY connected LEDs" + depends on AT803X_PHY && LEDS_CLASS + ---help--- + Select this to be able to control LEDs connected to the + PHY from userspace + config AMD_PHY tristate "Drivers for the AMD PHYs" ---help---drivers/net/phy/at803x.c +19
-0@@ -16,6 +16,7 @@#include <linux/string.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/leds.h> #define AT803X_INTR_ENABLE 0x12#define AT803X_INTR_STATUS 0x13@@ -31,6 +32,8 @@#define AT803X_DEBUG_DATA 0x1E#define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05#define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8) +#define AT8035_LED_CTRL 0x18 +#define AT8035_LED_CTRL_OFF BIT(15)MODULE_DESCRIPTION ("Atheros 803x PHY driver" );MODULE_AUTHOR ("Matus Ujhelyi" );@@ -152,6 +155,86 @@ static int at803x_config_init(struct phy_device *phydev)return 0 ; } +#ifdef CONFIG_AT803X_LEDS + +struct at8035_priv { +struct led_classdev led; +struct phy_device *phydev; +struct work_struct led_work; +bool stop; +}; + +static void at8035_led_work (struct work_struct *work) +{ +struct at8035_priv *priv = + container_of(work, struct at8035_priv, led_work); +struct phy_device *phydev = priv->phydev; +int val; +
drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 183
Quoted 10 lines
drivers/net/phy/at803x.c +10
-0+if (priv->stop) +return ; + + val =phy_read (phydev,AT8035_LED_CTRL ); + +if (priv->led.brightness >0 ) +phy_write (phydev,AT8035_LED_CTRL , val & ~AT8035_LED_CTRL_OFF ); +else +phy_write (phydev,AT8035_LED_CTRL , val |AT8035_LED_CTRL_OFF ); +}
I do like this and I believe that there is nothing specific that would prevent you from making software controllable LEDs from being used with other PHYs. How about you create a small LED class helper that PHY drivers supporting controllable LEDs can hook into and provide their own callback and LED name for setting the LED state?
drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 192
Quoted 9 lines
drivers/net/phy/at803x.c +9
-0+ +static void at8035_led_brightness_set (struct led_classdev *led, +enum led_brightness brightness) +{ + struct at8035_priv *priv = container_of(led, struct at8035_priv, led); + +/* MDIO bus can only be used from process context */ +if (!priv->stop) +schedule_work (&priv->led_work);
It seems to me that you could remove the stop boolean if you move led_classdev_unregister upper, provided that it guarantees it will not schedule the workqueue.
--
Florian
Re: [PATCH 2/2] drivers: net: phy: at803x: LED control via led subsystem
Quoted 79 lines · Florian Fainelli
Hello Helmut,
2013/7/11 Helmut Schaa <[email protected]>:
Quoted 76 lines
The AT8035 PHY allows to control the LED PIN behavior from software. Expose this functionality by registering an LED device.
Signed-off-by Helmut Schaa <[email protected]>--- drivers/net/phy/Kconfig | 7 ++++ drivers/net/phy/at803x.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)drivers/net/phy/Kconfig +7
-0@@ -19,6 +19,13 @@ config AT803X_PHY ---help--- Currently supports the AT8030 and AT8035 model +config AT803X_LEDS + bool "Enable access to PHY connected LEDs" + depends on AT803X_PHY && LEDS_CLASS + ---help--- + Select this to be able to control LEDs connected to the + PHY from userspace + config AMD_PHY tristate "Drivers for the AMD PHYs" ---help---drivers/net/phy/at803x.c +27
-0@@ -16,6 +16,7 @@#include <linux/string.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/leds.h> #define AT803X_INTR_ENABLE 0x12#define AT803X_INTR_STATUS 0x13@@ -31,6 +32,8 @@#define AT803X_DEBUG_DATA 0x1E#define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05#define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8) +#define AT8035_LED_CTRL 0x18 +#define AT8035_LED_CTRL_OFF BIT(15)MODULE_DESCRIPTION ("Atheros 803x PHY driver" );MODULE_AUTHOR ("Matus Ujhelyi" );@@ -152,6 +155,86 @@ static int at803x_config_init(struct phy_device *phydev)return 0 ; } +#ifdef CONFIG_AT803X_LEDS + +struct at8035_priv { +struct led_classdev led; +struct phy_device *phydev; +struct work_struct led_work; +bool stop; +}; + +static void at8035_led_work (struct work_struct *work) +{ +struct at8035_priv *priv = + container_of(work, struct at8035_priv, led_work); +struct phy_device *phydev = priv->phydev; +int val; + +if (priv->stop) +return ; + + val =phy_read (phydev,AT8035_LED_CTRL ); + +if (priv->led.brightness >0 ) +phy_write (phydev,AT8035_LED_CTRL , val & ~AT8035_LED_CTRL_OFF ); +else
Quoted 8 lines
drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 183
Quoted 2 lines
drivers/net/phy/at803x.c +2
-0+phy_write (phydev,AT8035_LED_CTRL , val |AT8035_LED_CTRL_OFF ); +}I do like this and I believe that there is nothing specific that would prevent you from making software controllable LEDs from being used with other PHYs. How about you create a small LED class helper that PHY drivers supporting controllable LEDs can hook into and provide their own callback and LED name for setting the LED state?
Hmm, nice idea. However, there is not much complexity in the code. The only thing worth to make generic would be the delayed register access via workqueue. The rest is just registering the led device :)
I thought about moving the code into the generic phy code and using a new phy_driver callback for setting the LED state but there might be more then one LED pin on some PHYs (activity, speed, duplexmode etc.).
Quoted 5 lines
Quoted 5 lines
drivers/net/phy/at803x.c +5
-0+ +static void at8035_led_brightness_set (struct led_classdev *led, +enum led_brightness brightness) +{ + struct at8035_priv *priv = container_of(led, struct at8035_priv, led);
Quoted 8 lines
drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 192
Quoted 4 lines
drivers/net/phy/at803x.c +4
-0+ +/* MDIO bus can only be used from process context */ +if (!priv->stop) +schedule_work (&priv->led_work);It seems to me that you could remove the stop boolean if you move
led_classdev_unregisterupper, provided that it guarantees it will not schedule the workqueue.
led_classdev_unregister will try to set brightness to 0 and thus schedule the work.
Thanks,
Helmut
Re: [PATCH 2/2] drivers: net: phy: at803x: LED control via led subsystem
2013/7/11 Helmut Schaa <[email protected]>:
Quoted 7 lines
Quoted 6 lines
I do like this and I believe that there is nothing specific that would prevent you from making software controllable LEDs from being used with other PHYs. How about you create a small LED class helper that PHY drivers supporting controllable LEDs can hook into and provide their own callback and LED name for setting the LED state?
Quoted 7 lines
Hmm, nice idea. However, there is not much complexity in the code. The only thing worth to make generic would be the delayed register access via workqueue. The rest is just registering the led device :)
I thought about moving the code into the generic phy code and using a new
phy_drivercallback for setting the LED state but there might be more then one LED pin on some PHYs (activity, speed, duplexmode etc.).
I think that the same callback for all LEDs and just take actions based on which led_classdev pointer we get passed should be enough. I agree with you that there is not much complexity, but for sure, if we add support for LEDs to another PHY driver there will be similar stuff done (registering a LED classdev, etc...) so we might just want to specialize the led_brightness_set() callback and the number of LEDs. One thing with moving this closer to the PHY state machine would be to allow for better integration, like setting the LED brightness to 0 when the link goes down etc...
Quoted 15 lines
Quoted 14 lines
drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 192
Quoted 10 lines
drivers/net/phy/at803x.c +9
-0+ +static void at8035_led_brightness_set (struct led_classdev *led, +enum led_brightness brightness) +{ + struct at8035_priv *priv = container_of(led, struct at8035_priv, led); + +/* MDIO bus can only be used from process context */ +if (!priv->stop) +schedule_work (&priv->led_work);It seems to me that you could remove the stop boolean if you move
led_classdev_unregisterupper, provided that it guarantees it will not schedule the workqueue.
Quoted 2 lines
led_classdev_unregisterwill try to set brightness to 0 and thus schedule the work.
Ok, thanks!
--
Florian
Re: [PATCH 2/2] drivers: net: phy: at803x: LED control via led subsystem
Quoted 16 lines · Florian Fainelli
2013/7/11 Helmut Schaa <[email protected]>:
Quoted 7 lines
Quoted 6 lines
I do like this and I believe that there is nothing specific that would prevent you from making software controllable LEDs from being used with other PHYs. How about you create a small LED class helper that PHY drivers supporting controllable LEDs can hook into and provide their own callback and LED name for setting the LED state?
Quoted 7 lines
Hmm, nice idea. However, there is not much complexity in the code. The only thing worth to make generic would be the delayed register access via workqueue. The rest is just registering the led device :)
I thought about moving the code into the generic phy code and using a new
phy_drivercallback for setting the LED state but there might be more then one LED pin on some PHYs (activity, speed, duplexmode etc.).
Quoted 9 lines
I think that the same callback for all LEDs and just take actions based on which
led_classdevpointer we get passed should be enough. I agree with you that there is not much complexity, but for sure, if we add support for LEDs to another PHY driver there will be similar stuff done (registering a LED classdev, etc...) so we might just want to specialize theled_brightness_set()callback and the number of LEDs. One thing with moving this closer to the PHY state machine would be to allow for better integration, like setting the LED brightness to 0 when the link goes down etc...
Agreed, let me see if I can come up with a more generic approach. Thanks,
Helmut
David Miller
maintainerRe: [PATCH 2/2] drivers: net: phy: at803x: LED control via led subsystem
In reply to Helmut SchaaFrom: Helmut Schaa <[email protected]>
Date: Thu, 11 Jul 2013 13:57:35 +0200
Quoted 4 lines
The AT8035 PHY allows to control the LED PIN behavior from software. Expose this functionality by registering an LED device.
Signed-off-by Helmut Schaa <[email protected]>
As a new feature, it is not appropriate to submit this change at this time. Please resubmit this when the net-next tree opens up again.
Re: [PATCH 2/2] drivers: net: phy: at803x: LED control via led subsystem
Quoted 10 lines · David Miller
From: Helmut Schaa <[email protected]>
Date: Thu, 11 Jul 2013 13:57:35 +0200Quoted 4 lines
The AT8035 PHY allows to control the LED PIN behavior from software. Expose this functionality by registering an LED device.
Signed-off-by Helmut Schaa <[email protected]>As a new feature, it is not appropriate to submit this change at this time. Please resubmit this when the net-next tree opens up again.
OK, will do.
Helmut
From: Helmut Schaa <[email protected]>
Date: Thu, 11 Jul 2013 13:57:34 +0200
Quoted 4 lines
at803x supports Atheros 8030, 8031 and 8035 PHYs. 8031 was missing from the mdio device id table.
Signed-off-by Helmut Schaa <[email protected]>
Applied.