Skip to contentSkip to conversation

net: phy: Add LED mode driver for Microsemi

PATCH Superseded Raju Lakkaraju 6 participants 8 messages Feb 1, 2017 – Feb 7, 2017 3 messages not in the archive

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: phy: Add LED mode driver for Microsemi

From: Raju Lakkaraju <[email protected]>

LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different status information that can be selected by setting LED mode.

LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get from Device Tree.

Tested on Beaglebone Black with VSC 8531 PHY.

Change set:
v0:
- Initial version of LED driver for Microsemi PHYs. v1:
- Update all review comments given by Andrew.
- Add new header file "mscc-phy-vsc8531.h" to define DT macros.
- Add error/range check for DT LED mode input
v2:
- Fixed x86_64 build error.

Raju Lakkaraju (1):
net: phy: Add LED mode driver for Microsemi PHYs.

 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 10 +++
 drivers/net/phy/mscc.c                             | 85 +++++++++++++++++++++-
 include/dt-bindings/net/mscc-phy-vsc8531.h         | 29 ++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 net: phy: Add LED mode driver for Microsemi PHYs.

From: Raju Lakkaraju <[email protected]>

LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different status information that can be selected by setting LED mode.

LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get from Device Tree.

---
 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 10 +++
 drivers/net/phy/mscc.c                             | 85 +++++++++++++++++++++-
 include/dt-bindings/net/mscc-phy-vsc8531.h         | 29 ++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +10 -0
index bdefefc6..bb7450c 100644
@@ -27,6 +27,14 @@ Optional properties:
 			  'vddmac'.
 			  Default value is 0%.
 			  Ref: Table:1 - Edge rate change (below).
+- vsc8531,led-0-mode	: LED mode. Specify how the LED[0] should behave.
+			  Allowed values are define in
+			  "include/dt-bindings/net/mscc-phy-vsc8531.h".
+			  Default value is 1.
+- vsc8531,led-1-mode	: LED mode. Specify how the LED[1] should behave.
+			  Allowed values are define in
+			  "include/dt-bindings/net/mscc-phy-vsc8531.h".
+			  Default value is 2.
 
 Table: 1 - Edge rate change
 ----------------------------------------------------------------|
@@ -60,4 +68,6 @@ Example:
                 compatible = "ethernet-phy-id0007.0570";
                 vsc8531,vddmac		= <3300>;
                 vsc8531,edge-slowdown	= <7>;
+                vsc8531,led-0-mode	= <LINK_1000_ACTIVITY>;
+                vsc8531,led-1-mode	= <LINK_100_ACTIVITY>;
         };
drivers/net/phy/mscc.c +84 -1

139 lines not on this page · raw message

include/dt-bindings/net/mscc-phy-vsc8531.h new file +29 -0
new file mode 100644
index 0000000..af6af98
@@ -0,0 +1,29 @@
+/*
+ * Device Tree constants for Microsemi VSC8531 PHY
+ *
+ * Author: Nagaraju Lakkaraju
+ *
+ * License: Dual MIT/GPL
+ * Copyright (c) 2017 Microsemi Corporation
+ */
+
+#ifndef _DT_BINDINGS_MSCC_VSC8531_H
+#define _DT_BINDINGS_MSCC_VSC8531_H
+
+/* PHY LED Modes */
+#define LINK_ACTIVITY           0
+#define LINK_1000_ACTIVITY      1
+#define LINK_100_ACTIVITY       2
+#define LINK_10_ACTIVITY        3
+#define LINK_100_1000_ACTIVITY  4
+#define LINK_10_1000_ACTIVITY   5
+#define LINK_10_100_ACTIVITY    6
+#define DUPLEX_COLLISION        8
+#define COLLISION               9
+#define ACTIVITY                10
+#define AUTONEG_FAULT           12
+#define SERIAL_MODE             13
+#define FORCE_LED_OFF           14
+#define FORCE_LED_ON            15
+
+#endif
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi PHYs.

Quoted 22 lines · Raju Lakkaraju

From: Raju Lakkaraju <[email protected]>

LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different status information that can be selected by setting LED mode.

LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get from Device Tree.

---
 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 10 +++
 drivers/net/phy/mscc.c                             | 85 +++++++++++++++++++++-
 include/dt-bindings/net/mscc-phy-vsc8531.h         | 29 ++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +0 -0
index bdefefc6..bb7450c 100644

Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt Optional properties: · line 33

Quoted 7 lines
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +4 -0
@@ -27,6 +27,14 @@ Optional properties:
 			  'vddmac'.
 			  Default value is 0%.
 			  Ref: Table:1 - Edge rate change (below).
+- vsc8531,led-0-mode	: LED mode. Specify how the LED[0] should behave.
+			  Allowed values are define in
+			  "include/dt-bindings/net/mscc-phy-vsc8531.h".
+			  Default value is 1.

1 is not very useful. What does it mean? How about:

Default value is LINK_1000_ACTIVITY (1)

Quoted 92 lines
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +6 -0
+- vsc8531,led-1-mode	: LED mode. Specify how the LED[1] should behave.
+			  Allowed values are define in
+			  "include/dt-bindings/net/mscc-phy-vsc8531.h".
+			  Default value is 2.
 
 Table: 1 - Edge rate change
 ----------------------------------------------------------------|
@@ -60,4 +68,6 @@ Example:
                 compatible = "ethernet-phy-id0007.0570";
                 vsc8531,vddmac		= <3300>;
                 vsc8531,edge-slowdown	= <7>;
+                vsc8531,led-0-mode	= <LINK_1000_ACTIVITY>;
+                vsc8531,led-1-mode	= <LINK_100_ACTIVITY>;
         };
drivers/net/phy/mscc.c +42 -0
index e03ead8..f0cb7cc 100644
@@ -13,6 +13,7 @@
 #include <linux/phy.h>
 #include <linux/of.h>
 #include <linux/netdevice.h>
+#include <dt-bindings/net/mscc-phy-vsc8531.h>
 
 enum rgmii_rx_clock_delay {
 	RGMII_RX_CLK_DELAY_0_2_NS = 0,
@@ -52,6 +53,11 @@ enum rgmii_rx_clock_delay {
 #define MSCC_PHY_DEV_AUX_CNTL		  28
 #define HP_AUTO_MDIX_X_OVER_IND_MASK	  0x2000
 
+#define MSCC_PHY_LED_MODE_SEL		  29
+#define LED_1_MODE_SEL_MASK		  0x00F0
+#define LED_0_MODE_SEL_MASK		  0x000F
+#define LED_1_MODE_SEL_POS		  4
+
 #define MSCC_EXT_PAGE_ACCESS		  31
 #define MSCC_PHY_PAGE_STANDARD		  0x0000 /* Standard registers */
 #define MSCC_PHY_PAGE_EXTENDED		  0x0001 /* Extended registers */
@@ -99,6 +105,8 @@ enum rgmii_rx_clock_delay {
 
 struct vsc8531_private {
 	int rate_magic;
+	u8 led_0_mode;
+	u8 led_1_mode;
 };
 
 #ifdef CONFIG_OF_MDIO
@@ -123,6 +131,29 @@ static int vsc85xx_phy_page_set(struct phy_device *phydev, u8 page)
 	return rc;
 }
 
+static int vsc85xx_led_cntl_set(struct phy_device *phydev,
+				u8 led_num,
+				u8 mode)
+{
+	int rc;
+	u16 reg_val;
+
+	mutex_lock(&phydev->lock);
+	reg_val = phy_read(phydev, MSCC_PHY_LED_MODE_SEL);
+	if (led_num) {
+		reg_val &= ~LED_1_MODE_SEL_MASK;
+		reg_val |= (((u16)mode << LED_1_MODE_SEL_POS) &
+			    LED_1_MODE_SEL_MASK);
+	} else {
+		reg_val &= ~LED_0_MODE_SEL_MASK;
+		reg_val |= ((u16)mode & LED_0_MODE_SEL_MASK);
+	}
+	rc = phy_write(phydev, MSCC_PHY_LED_MODE_SEL, reg_val);
+	mutex_unlock(&phydev->lock);
+
+	return rc;
+}
+
 static int vsc85xx_mdix_get(struct phy_device *phydev, u8 *mdix)
 {
 	u16 reg_val;
@@ -370,11 +401,43 @@ static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
 
 	return -EINVAL;
 }
+
+static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
+				   char *led,
+				   u8 default_mode)
+{
+	struct device *dev = &phydev->mdio.dev;
+	struct device_node *of_node = dev->of_node;
+	u8 led_mode;
+	int rc;
+
+	if (!of_node)

drivers/net/phy/mscc.c static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev) · line 424

Quoted 10 lines
drivers/net/phy/mscc.c +10 -0
+		return -ENODEV;
+
+	rc = of_property_read_u8(of_node, led, &led_mode);
+	if ((rc == 0) &&
+	    ((led_mode > 15) || (led_mode == 7) || (led_mode == 11))) {
+		phydev_err(phydev, "DT %s invalid\n", led);
+		return -EINVAL;
+	} else if (rc == -EINVAL) {
+		return default_mode;
+	}

I don't think you understood my comment about of_property_read_u8() not modifying &led_mode on error. Please read the comment again, and simplify this.

Quoted 20 lines
drivers/net/phy/mscc.c +11 -0
+
+	return led_mode;
+}
+
 #else
 static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
 {
 	return 0;
 }
+
+static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
+				   char *led,
+				   u8 default_mode)
+{
+	return default_mode;
+}
 #endif /* CONFIG_OF_MDIO */
 
 static int vsc85xx_edge_rate_cntl_set(struct phy_device *phydev, u8 edge_rate)

drivers/net/phy/mscc.c static int vsc85xx_config_init(struct phy_device *phydev) · line 567

Quoted 6 lines
drivers/net/phy/mscc.c +3 -0
@@ -499,6 +562,13 @@ static int vsc85xx_config_init(struct phy_device *phydev)
 	if (rc)
 		return rc;
 
+	rc = vsc85xx_led_cntl_set(phydev, 1, vsc8531->led_1_mode);
+	if (rc)
+		return rc;

Blank line please.

Quoted 19 lines
drivers/net/phy/mscc.c +6 -1
+	rc = vsc85xx_led_cntl_set(phydev, 0, vsc8531->led_0_mode);
+	if (rc)
+		return rc;
+
 	rc = genphy_config_init(phydev);
 
 	return rc;
@@ -555,8 +625,9 @@ static int vsc85xx_read_status(struct phy_device *phydev)
 
 static int vsc85xx_probe(struct phy_device *phydev)
 {
-	int rate_magic;
 	struct vsc8531_private *vsc8531;
+	int rate_magic;
+	int led_mode;
 
 	rate_magic = vsc85xx_edge_rate_magic_get(phydev);
 	if (rate_magic < 0)

drivers/net/phy/mscc.c static int vsc85xx_probe(struct phy_device *phydev) · line 649

Quoted 9 lines
drivers/net/phy/mscc.c +6 -0
@@ -570,6 +641,18 @@ static int vsc85xx_probe(struct phy_device *phydev)
 
 	vsc8531->rate_magic = rate_magic;
 
+	/* LED[0] and LED[1] mode */
+	led_mode = vsc85xx_dt_led_mode_get(phydev, "vsc8531,led-0-mode",
+					   LINK_1000_ACTIVITY);
+	if (led_mode < 0)
+		return led_mode;
+	vsc8531->led_0_mode = led_mode;

Blank line.

Quoted 32 lines
drivers/net/phy/mscc.c +6 -0
+	led_mode = vsc85xx_dt_led_mode_get(phydev, "vsc8531,led-1-mode",
+					   LINK_100_ACTIVITY);
+	if (led_mode < 0)
+		return led_mode;
+	vsc8531->led_1_mode = led_mode;
+
 	return 0;
 }
 
include/dt-bindings/net/mscc-phy-vsc8531.h new file +17 -0
new file mode 100644
index 0000000..af6af98
@@ -0,0 +1,29 @@
+/*
+ * Device Tree constants for Microsemi VSC8531 PHY
+ *
+ * Author: Nagaraju Lakkaraju
+ *
+ * License: Dual MIT/GPL
+ * Copyright (c) 2017 Microsemi Corporation
+ */
+
+#ifndef _DT_BINDINGS_MSCC_VSC8531_H
+#define _DT_BINDINGS_MSCC_VSC8531_H
+
+/* PHY LED Modes */
+#define LINK_ACTIVITY           0
+#define LINK_1000_ACTIVITY      1
+#define LINK_100_ACTIVITY       2
+#define LINK_10_ACTIVITY        3

include/dt-bindings/net/mscc-phy-vsc8531.h line 27

Quoted 10 lines
include/dt-bindings/net/mscc-phy-vsc8531.h new file +10 -0
+#define LINK_100_1000_ACTIVITY  4
+#define LINK_10_1000_ACTIVITY   5
+#define LINK_10_100_ACTIVITY    6
+#define DUPLEX_COLLISION        8
+#define COLLISION               9
+#define ACTIVITY                10
+#define AUTONEG_FAULT           12
+#define SERIAL_MODE             13
+#define FORCE_LED_OFF           14
+#define FORCE_LED_ON            15

You should prefix these with VSC8531_. Otherwise there is potential to have issues with two different PHYs defining some of these frequently used macros.

Andrew

#8 lore raw

Re: [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi PHYs.

In reply to a message not in the archive
Quoted 22 lines · Raju Lakkaraju

From: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/[email protected]>

LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different status information that can be selected by setting LED mode.

LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get from Device Tree.

---
 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 10 +++
 drivers/net/phy/mscc.c                             | 85 +++++++++++++++++++++-
 include/dt-bindings/net/mscc-phy-vsc8531.h         | 29 ++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +0 -0
index bdefefc6..bb7450c 100644

Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt Optional properties: · line 30

Quoted 4 lines
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +1 -0
@@ -27,6 +27,14 @@ Optional properties:
 			  'vddmac'.
 			  Default value is 0%.
 			  Ref: Table:1 - Edge rate change (below).
+- vsc8531,led-0-mode	: LED mode. Specify how the LED[0] should behave.

vsc8531 is not a vendor prefix. I see other properties did this, but please don't continue it.

Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt Optional properties: · line 34

Quoted 4 lines
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +4 -0
+			  Allowed values are define in
+			  "include/dt-bindings/net/mscc-phy-vsc8531.h".
+			  Default value is 1.
+- vsc8531,led-1-mode	: LED mode. Specify how the LED[1] should behave.

Why not make this an array for LED0 and LED1?

Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt Example: · line 73

Quoted 13 lines
Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +5 -0
+			  Allowed values are define in
+			  "include/dt-bindings/net/mscc-phy-vsc8531.h".
+			  Default value is 2.
 
 Table: 1 - Edge rate change
 ----------------------------------------------------------------|
@@ -60,4 +68,6 @@ Example:
                 compatible = "ethernet-phy-id0007.0570";
                 vsc8531,vddmac		= <3300>;
                 vsc8531,edge-slowdown	= <7>;
+                vsc8531,led-0-mode	= <LINK_1000_ACTIVITY>;
+                vsc8531,led-1-mode	= <LINK_100_ACTIVITY>;
         };

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
In reply to Raju Lakkaraju
Quoted 5 lines · Raju Lakkaraju

From: Raju Lakkaraju <[email protected]>

LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different status information that can be selected by setting LED mode.

Why is this LED selection done through Device Tree/initial configuration instead of coming up with a proper LED device registered by the PHY which allows you to select exactly how you want the modes to wind-up looking like?

NB: you don't need a cover letter for single patches.

Quoted 28 lines

LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get from Device Tree.

Tested on Beaglebone Black with VSC 8531 PHY.

Change set:
v0:
- Initial version of LED driver for Microsemi PHYs. v1:
- Update all review comments given by Andrew.
- Add new header file "mscc-phy-vsc8531.h" to define DT macros.
- Add error/range check for DT LED mode input
v2:
- Fixed x86_64 build error.

Raju Lakkaraju (1):
net: phy: Add LED mode driver for Microsemi PHYs.

 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 10 +++
 drivers/net/phy/mscc.c                             | 85 +++++++++++++++++++++-
 include/dt-bindings/net/mscc-phy-vsc8531.h         | 29 ++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
Signature · 1 line
Florian
#4 lore raw

Re: [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi PHYs.

In reply to a message not in the archive

Hi Andrew,

Thank you for given review comments.

Quoted 6 lines · Andrew Lunn

EXTERNAL EMAIL

Quoted 2 lines · Raju Lakkaraju

From: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/[email protected]>

Quoted 8 lines

Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt Optional properties: · line 33

Quoted 3 lines

LED Mode:

Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt +2 -0
+                       "include/dt-bindings/net/mscc-phy-vsc8531.h".
+                       Default value is 1.

1 is not very useful. What does it mean? How about:

Default value is LINK_1000_ACTIVITY (1)

Accepted.

Quoted 11 lines
Quoted 11 lines

+- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.

drivers/net/phy/mscc.c +10 -0
+                       Allowed values are define in
+     int rc;
+
+     if (!of_node)
+             return -ENODEV;
+
+     rc = of_property_read_u8(of_node, led, &led_mode);
+     if ((rc == 0) &&
+         ((led_mode > 15) || (led_mode == 7) || (led_mode == 11))) {
+             phydev_err(phydev, "DT %s invalid\n", led);
Quoted 9 lines

drivers/net/phy/mscc.c static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev) · line 424

Quoted 4 lines
drivers/net/phy/mscc.c +4 -0
+             return -EINVAL;
+     } else if (rc == -EINVAL) {
+             return default_mode;
+     }

I don't think you understood my comment about of_property_read_u8() not modifying &led_mode on error. Please read the comment again, and simplify this.

If i understand your comment correctly, in case of return value -EINVAL, it should return error. Am i correct?

i would perfer in case of of_property_read_u8( ) returns -EINVAL, i would like to configure LEDs with default state. Shall i configure?

Still if you think i did not understand your comments, please write little bit more.

Quoted 23 lines
Quoted 23 lines
drivers/net/phy/mscc.c +11 -0
+
+     return led_mode;
+}
+
 #else
 static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
 {
      return 0;
 }
+
+static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
+                                char *led,
+                                u8 default_mode)
+{
+     return default_mode;
+}
 #endif /* CONFIG_OF_MDIO */
 
 static int vsc85xx_edge_rate_cntl_set(struct phy_device *phydev, u8 edge_rate)
@@ -499,6 +562,13 @@ static int vsc85xx_config_init(struct phy_device *phydev)
      if (rc)
              return rc;
 
Quoted 6 lines

drivers/net/phy/mscc.c static int vsc85xx_config_init(struct phy_device *phydev) · line 567

Quoted 3 lines
drivers/net/phy/mscc.c +3 -0
+     rc = vsc85xx_led_cntl_set(phydev, 1, vsc8531->led_1_mode);
+     if (rc)
+             return rc;

Blank line please.

Accepted.

Quoted 6 lines
Quoted 6 lines
drivers/net/phy/mscc.c +4 -0
+     rc = vsc85xx_led_cntl_set(phydev, 0, vsc8531->led_0_mode);
+     if (rc)
+             return rc;
+
      rc = genphy_config_init(phydev);
 
Quoted 10 lines

drivers/net/phy/mscc.c static int vsc85xx_read_status(struct phy_device *phydev) · line 629

Quoted 7 lines
drivers/net/phy/mscc.c +5 -0
      return rc;
@@ -555,8 +625,9 @@ static int vsc85xx_read_status(struct phy_device *phydev)
+     led_mode = vsc85xx_dt_led_mode_get(phydev, "vsc8531,led-0-mode",
+                                        LINK_1000_ACTIVITY);
+     if (led_mode < 0)
+             return led_mode;
+     vsc8531->led_0_mode = led_mode;

Blank line.

Accepted.

Quoted 11 lines

include/dt-bindings/net/mscc-phy-vsc8531.h line 27

Quoted 6 lines
include/dt-bindings/net/mscc-phy-vsc8531.h new file +6 -0
+     led_mode = vsc85xx_dt_led_mode_get(phydev, "vsc8531,led-1-mode",
+                                        LINK_100_ACTIVITY);
+#define AUTONEG_FAULT           12
+#define SERIAL_MODE             13
+#define FORCE_LED_OFF           14
+#define FORCE_LED_ON            15

You should prefix these with VSC8531_. Otherwise there is potential to have issues with two different PHYs defining some of these frequently used macros.

Accepted.

Quoted 1 line

Andrew

---
Thanks,
Raju.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

Re: [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi PHYs.

In reply to a message not in the archive
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines

+- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.

drivers/net/phy/mscc.c +10 -0
+                       Allowed values are define in
+     int rc;
+
+     if (!of_node)
+             return -ENODEV;
+
+     rc = of_property_read_u8(of_node, led, &led_mode);
+     if ((rc == 0) &&
+         ((led_mode > 15) || (led_mode == 7) || (led_mode == 11))) {
+             phydev_err(phydev, "DT %s invalid\n", led);
Quoted 9 lines

drivers/net/phy/mscc.c static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev) · line 424

Quoted 4 lines
drivers/net/phy/mscc.c +4 -0
+             return -EINVAL;
+     } else if (rc == -EINVAL) {
+             return default_mode;
+     }

I don't think you understood my comment about of_property_read_u8() not modifying &led_mode on error. Please read the comment again, and simplify this.

Quoted 1 line

If i understand your comment correctly

Nope, you don't.

     rc = of_property_read_u8(of_node, led, &led_mode);

If rc indicates an error, led_mode is not touched. Read the documentation for this function. So you can simplifiy the code:

	led_mode = default_mode;
	err = of_property_read_u8(of_node, led, &led_mode);
	if (!err && (led_mode > 15 || led_mode == 7) | (led_mode == 11) {
             phydev_err(phydev, "DT %s invalid\n", led);
             return -EINVAL;
	}
	return led_mode;

	Andrew

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw
In reply to Florian Fainelli

Hi Florian,

Thank you for review comments.

Quoted 6 lines · Florian Fainelli

EXTERNAL EMAIL

Quoted 2 lines · Raju Lakkaraju

From: Raju Lakkaraju <[email protected]>

Quoted 9 lines
Quoted 3 lines

LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different status information that can be selected by setting LED mode.

Why is this LED selection done through Device Tree/initial configuration instead of coming up with a proper LED device registered by the PHY which allows you to select exactly how you want the modes to wind-up looking like?

I wrote the LED driver similar to "Micrel". Added only LED mode.

Quoted 2 lines

NB: you don't need a cover letter for single patches.

Accepted. I will do.

Quoted 30 lines
Quoted 19 lines

LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get from Device Tree.

Tested on Beaglebone Black with VSC 8531 PHY.

Change set:
v0:
- Initial version of LED driver for Microsemi PHYs. v1:
- Update all review comments given by Andrew.
- Add new header file "mscc-phy-vsc8531.h" to define DT macros.
- Add error/range check for DT LED mode input
v2:
- Fixed x86_64 build error.

Quoted 9 lines

Raju Lakkaraju (1):
net: phy: Add LED mode driver for Microsemi PHYs.

 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 10 +++
 drivers/net/phy/mscc.c                             | 85 +++++++++++++++++++++-
 include/dt-bindings/net/mscc-phy-vsc8531.h         | 29 ++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
Quoted 2 lines

--
Florian

---
Thanks,
Raju.