diff mbox series

[Unstable,SRU,Disco,SRU,Cosmic] net: phy: marvell: add newdefault led configure for m88e151x

Message ID 20190516203500.11141-1-dann.frazier@canonical.com
State New
Headers show
Series [Unstable,SRU,Disco,SRU,Cosmic] net: phy: marvell: add newdefault led configure for m88e151x | expand

Commit Message

dann frazier May 16, 2019, 8:35 p.m. UTC
From: Jian Shen <shenjian15@huawei.com>

BugLink: https://bugs.launchpad.net/bugs/1829306

The default m88e151x LED configuration is 0x1177, used LED[0]
for 1000M link, LED[1] for 100M link, and LED[2] for active.
But for some boards, which use LED[0] for link, and LED[1] for
active, prefer to be 0x1040. To be compatible with this case,
this patch defines a new dev_flag, and set it before connect
phy in HNS3 driver. When phy initializing, using the new
LED configuration if this dev_flag is set.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a93f7fe134543649cf2e2d8fc2c50a8f4d742915)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 3 +++
 drivers/net/phy/marvell.c                               | 6 +++++-
 include/linux/marvell_phy.h                             | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Stefan Bader May 29, 2019, 2:18 p.m. UTC | #1
On 16.05.19 22:35, dann frazier wrote:
> From: Jian Shen <shenjian15@huawei.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1829306
> 
> The default m88e151x LED configuration is 0x1177, used LED[0]
> for 1000M link, LED[1] for 100M link, and LED[2] for active.
> But for some boards, which use LED[0] for link, and LED[1] for
> active, prefer to be 0x1040. To be compatible with this case,
> this patch defines a new dev_flag, and set it before connect
> phy in HNS3 driver. When phy initializing, using the new
> LED configuration if this dev_flag is set.
> 
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit a93f7fe134543649cf2e2d8fc2c50a8f4d742915)
> Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 3 +++
>  drivers/net/phy/marvell.c                               | 6 +++++-
>  include/linux/marvell_phy.h                             | 1 +
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
> index 48eda2c6fdae3..dda33497e79e8 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
> @@ -3,6 +3,7 @@
>  
>  #include <linux/etherdevice.h>
>  #include <linux/kernel.h>
> +#include <linux/marvell_phy.h>
>  
>  #include "hclge_cmd.h"
>  #include "hclge_main.h"
> @@ -203,6 +204,8 @@ int hclge_mac_connect_phy(struct hnae3_handle *handle)
>  
>  	linkmode_clear_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported);
>  
> +	phydev->dev_flags |= MARVELL_PHY_LED0_LINK_LED1_ACTIVE;
> +
>  	ret = phy_connect_direct(netdev, phydev,
>  				 hclge_mac_adjust_link,
>  				 PHY_INTERFACE_MODE_SGMII);
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index abb7876a87762..4609042b6bb54 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -133,6 +133,7 @@
>  #define MII_PHY_LED_CTRL	        16
>  #define MII_88E1121_PHY_LED_DEF		0x0030
>  #define MII_88E1510_PHY_LED_DEF		0x1177
> +#define MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE	0x1040
>  
>  #define MII_M1011_PHY_STATUS		0x11
>  #define MII_M1011_PHY_STATUS_1000	0x8000
> @@ -629,7 +630,10 @@ static void marvell_config_led(struct phy_device *phydev)
>  	 * LED[2] .. Blink, Activity
>  	 */
>  	case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510):
> -		def_config = MII_88E1510_PHY_LED_DEF;
> +		if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE)
> +			def_config = MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE;
> +		else
> +			def_config = MII_88E1510_PHY_LED_DEF;
>  		break;
>  	default:
>  		return;
> diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
> index 1eb6f244588da..2fe020458e744 100644
> --- a/include/linux/marvell_phy.h
> +++ b/include/linux/marvell_phy.h
> @@ -32,5 +32,6 @@
>  /* struct phy_device dev_flags definitions */
>  #define MARVELL_PHY_M1145_FLAGS_RESISTANCE	0x00000001
>  #define MARVELL_PHY_M1118_DNS323_LEDS		0x00000002
> +#define MARVELL_PHY_LED0_LINK_LED1_ACTIVE	0x00000004
>  
>  #endif /* _MARVELL_PHY_H */
>
Seth Forshee May 29, 2019, 6:47 p.m. UTC | #2
On Thu, May 16, 2019 at 02:35:00PM -0600, dann frazier wrote:
> From: Jian Shen <shenjian15@huawei.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1829306
> 
> The default m88e151x LED configuration is 0x1177, used LED[0]
> for 1000M link, LED[1] for 100M link, and LED[2] for active.
> But for some boards, which use LED[0] for link, and LED[1] for
> active, prefer to be 0x1040. To be compatible with this case,
> this patch defines a new dev_flag, and set it before connect
> phy in HNS3 driver. When phy initializing, using the new
> LED configuration if this dev_flag is set.
> 
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit a93f7fe134543649cf2e2d8fc2c50a8f4d742915)
> Signed-off-by: dann frazier <dann.frazier@canonical.com>

Upstream cherry pick, limited scope, positive testing.

Acked-by: Seth Forshee <seth.forshee@canonical.com>

unstable/master already has this commit, which was in 5.2-rc1. Thanks!
Khalid Elmously May 30, 2019, 5:58 a.m. UTC | #3
On 2019-05-16 14:35:00 , dann frazier wrote:
> From: Jian Shen <shenjian15@huawei.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1829306
> 
> The default m88e151x LED configuration is 0x1177, used LED[0]
> for 1000M link, LED[1] for 100M link, and LED[2] for active.
> But for some boards, which use LED[0] for link, and LED[1] for
> active, prefer to be 0x1040. To be compatible with this case,
> this patch defines a new dev_flag, and set it before connect
> phy in HNS3 driver. When phy initializing, using the new
> LED configuration if this dev_flag is set.
> 
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit a93f7fe134543649cf2e2d8fc2c50a8f4d742915)
> Signed-off-by: dann frazier <dann.frazier@canonical.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 3 +++
>  drivers/net/phy/marvell.c                               | 6 +++++-
>  include/linux/marvell_phy.h                             | 1 +
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
> index 48eda2c6fdae3..dda33497e79e8 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
> @@ -3,6 +3,7 @@
>  
>  #include <linux/etherdevice.h>
>  #include <linux/kernel.h>
> +#include <linux/marvell_phy.h>
>  
>  #include "hclge_cmd.h"
>  #include "hclge_main.h"
> @@ -203,6 +204,8 @@ int hclge_mac_connect_phy(struct hnae3_handle *handle)
>  
>  	linkmode_clear_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported);
>  
> +	phydev->dev_flags |= MARVELL_PHY_LED0_LINK_LED1_ACTIVE;
> +
>  	ret = phy_connect_direct(netdev, phydev,
>  				 hclge_mac_adjust_link,
>  				 PHY_INTERFACE_MODE_SGMII);
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index abb7876a87762..4609042b6bb54 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -133,6 +133,7 @@
>  #define MII_PHY_LED_CTRL	        16
>  #define MII_88E1121_PHY_LED_DEF		0x0030
>  #define MII_88E1510_PHY_LED_DEF		0x1177
> +#define MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE	0x1040
>  
>  #define MII_M1011_PHY_STATUS		0x11
>  #define MII_M1011_PHY_STATUS_1000	0x8000
> @@ -629,7 +630,10 @@ static void marvell_config_led(struct phy_device *phydev)
>  	 * LED[2] .. Blink, Activity
>  	 */
>  	case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510):
> -		def_config = MII_88E1510_PHY_LED_DEF;
> +		if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE)
> +			def_config = MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE;
> +		else
> +			def_config = MII_88E1510_PHY_LED_DEF;
>  		break;
>  	default:
>  		return;
> diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
> index 1eb6f244588da..2fe020458e744 100644
> --- a/include/linux/marvell_phy.h
> +++ b/include/linux/marvell_phy.h
> @@ -32,5 +32,6 @@
>  /* struct phy_device dev_flags definitions */
>  #define MARVELL_PHY_M1145_FLAGS_RESISTANCE	0x00000001
>  #define MARVELL_PHY_M1118_DNS323_LEDS		0x00000002
> +#define MARVELL_PHY_LED0_LINK_LED1_ACTIVE	0x00000004
>  
>  #endif /* _MARVELL_PHY_H */
> -- 
> 2.20.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index 48eda2c6fdae3..dda33497e79e8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -3,6 +3,7 @@ 
 
 #include <linux/etherdevice.h>
 #include <linux/kernel.h>
+#include <linux/marvell_phy.h>
 
 #include "hclge_cmd.h"
 #include "hclge_main.h"
@@ -203,6 +204,8 @@  int hclge_mac_connect_phy(struct hnae3_handle *handle)
 
 	linkmode_clear_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported);
 
+	phydev->dev_flags |= MARVELL_PHY_LED0_LINK_LED1_ACTIVE;
+
 	ret = phy_connect_direct(netdev, phydev,
 				 hclge_mac_adjust_link,
 				 PHY_INTERFACE_MODE_SGMII);
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index abb7876a87762..4609042b6bb54 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -133,6 +133,7 @@ 
 #define MII_PHY_LED_CTRL	        16
 #define MII_88E1121_PHY_LED_DEF		0x0030
 #define MII_88E1510_PHY_LED_DEF		0x1177
+#define MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE	0x1040
 
 #define MII_M1011_PHY_STATUS		0x11
 #define MII_M1011_PHY_STATUS_1000	0x8000
@@ -629,7 +630,10 @@  static void marvell_config_led(struct phy_device *phydev)
 	 * LED[2] .. Blink, Activity
 	 */
 	case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510):
-		def_config = MII_88E1510_PHY_LED_DEF;
+		if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE)
+			def_config = MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE;
+		else
+			def_config = MII_88E1510_PHY_LED_DEF;
 		break;
 	default:
 		return;
diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
index 1eb6f244588da..2fe020458e744 100644
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -32,5 +32,6 @@ 
 /* struct phy_device dev_flags definitions */
 #define MARVELL_PHY_M1145_FLAGS_RESISTANCE	0x00000001
 #define MARVELL_PHY_M1118_DNS323_LEDS		0x00000002
+#define MARVELL_PHY_LED0_LINK_LED1_ACTIVE	0x00000004
 
 #endif /* _MARVELL_PHY_H */