From ccf99168111cfcdb2b012cbef837d05d26e6466e Mon Sep 17 00:00:00 2001 From: shenjian Date: Fri, 25 Jan 2019 11:20:08 +0800 Subject: [PATCH] net: phy: marvell: net: phy: marvell: add new m88e1510 LED configuration for hns3 The default m88e1510 LED configuration is not fit for hns3 driver. This patch adds a new configuration for it. Feature or Bugfix:Bugfix Signed-off-by: shenjian (K) Reviewed-by: lipeng Signed-off-by: Yang Yingliang --- drivers/net/phy/marvell.c | 21 ++++++++++++++++++++- include/linux/marvell_phy.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 73813c7afa49..056c2b0b89b7 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -133,6 +133,10 @@ #define MII_PHY_LED_CTRL 16 #define MII_88E1121_PHY_LED_DEF 0x0030 #define MII_88E1510_PHY_LED_DEF 0x1177 +#define MII_88E1510_PHY_HNS3_LED_DEF 0x1040 + +#define MII_88E1510_PHY_LED_POLARITY_CTRL 0x11 +#define MII_88E1510_PHY_HNS3_LED_POLARITY 0x4415 #define MII_M1011_PHY_STATUS 0x11 #define MII_M1011_PHY_STATUS_1000 0x8000 @@ -645,12 +649,19 @@ static void marvell_config_led(struct phy_device *phydev) def_config = MII_88E1121_PHY_LED_DEF; break; /* Default PHY LED config: + * For hns3: + * LED[0] .. Link + * LED[1] .. Activity + * For others: * LED[0] .. 1000Mbps Link * LED[1] .. 100Mbps Link * 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_M1510_HNS3_LEDS) + def_config = MII_88E1510_PHY_HNS3_LED_DEF; + else + def_config = MII_88E1510_PHY_LED_DEF; break; default: return; @@ -660,6 +671,14 @@ static void marvell_config_led(struct phy_device *phydev) def_config); if (err < 0) pr_warn("Fail to config marvell phy LED.\n"); + + if (phydev->dev_flags & MARVELL_PHY_M1510_HNS3_LEDS) { + err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1510_PHY_LED_POLARITY_CTRL, + MII_88E1510_PHY_HNS3_LED_POLARITY); + if (err < 0) + pr_warn("Fail to config marvell phy LED polarity.\n"); + } } static int marvell_config_init(struct phy_device *phydev) diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h index 1eb6f244588d..99e0bbb54a16 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_M1510_HNS3_LEDS 0x00000004 #endif /* _MARVELL_PHY_H */ -- GitLab