Commit ea9e8648 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: phy: marvell: Implement led_blink_set()

The Marvell PHY can blink the LEDs, simple on/off. All LEDs blink at
the same rate, and the reset default is 84ms per blink, which is
around 12Hz.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4e901018
...@@ -147,6 +147,8 @@ ...@@ -147,6 +147,8 @@
#define MII_88E1318S_PHY_LED_FUNC 0x10 #define MII_88E1318S_PHY_LED_FUNC 0x10
#define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) #define MII_88E1318S_PHY_LED_FUNC_OFF (0x8)
#define MII_88E1318S_PHY_LED_FUNC_ON (0x9) #define MII_88E1318S_PHY_LED_FUNC_ON (0x9)
#define MII_88E1318S_PHY_LED_FUNC_HI_Z (0xa)
#define MII_88E1318S_PHY_LED_FUNC_BLINK (0xb)
#define MII_88E1318S_PHY_LED_TCR 0x12 #define MII_88E1318S_PHY_LED_TCR 0x12
#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
...@@ -2862,6 +2864,35 @@ static int m88e1318_led_brightness_set(struct phy_device *phydev, ...@@ -2862,6 +2864,35 @@ static int m88e1318_led_brightness_set(struct phy_device *phydev,
MII_88E1318S_PHY_LED_FUNC, reg); MII_88E1318S_PHY_LED_FUNC, reg);
} }
static int m88e1318_led_blink_set(struct phy_device *phydev, u8 index,
unsigned long *delay_on,
unsigned long *delay_off)
{
int reg;
reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE,
MII_88E1318S_PHY_LED_FUNC);
if (reg < 0)
return reg;
switch (index) {
case 0:
case 1:
case 2:
reg &= ~(0xf << (4 * index));
reg |= MII_88E1318S_PHY_LED_FUNC_BLINK << (4 * index);
/* Reset default is 84ms */
*delay_on = 84 / 2;
*delay_off = 84 / 2;
break;
default:
return -EINVAL;
}
return phy_write_paged(phydev, MII_MARVELL_LED_PAGE,
MII_88E1318S_PHY_LED_FUNC, reg);
}
static int marvell_probe(struct phy_device *phydev) static int marvell_probe(struct phy_device *phydev)
{ {
struct marvell_priv *priv; struct marvell_priv *priv;
...@@ -3112,6 +3143,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -3112,6 +3143,7 @@ static struct phy_driver marvell_drivers[] = {
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.led_brightness_set = m88e1318_led_brightness_set, .led_brightness_set = m88e1318_led_brightness_set,
.led_blink_set = m88e1318_led_blink_set,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1145, .phy_id = MARVELL_PHY_ID_88E1145,
...@@ -3219,6 +3251,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -3219,6 +3251,7 @@ static struct phy_driver marvell_drivers[] = {
.cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start,
.cable_test_get_status = marvell_vct7_cable_test_get_status, .cable_test_get_status = marvell_vct7_cable_test_get_status,
.led_brightness_set = m88e1318_led_brightness_set, .led_brightness_set = m88e1318_led_brightness_set,
.led_blink_set = m88e1318_led_blink_set,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1540, .phy_id = MARVELL_PHY_ID_88E1540,
...@@ -3246,6 +3279,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -3246,6 +3279,7 @@ static struct phy_driver marvell_drivers[] = {
.cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start,
.cable_test_get_status = marvell_vct7_cable_test_get_status, .cable_test_get_status = marvell_vct7_cable_test_get_status,
.led_brightness_set = m88e1318_led_brightness_set, .led_brightness_set = m88e1318_led_brightness_set,
.led_blink_set = m88e1318_led_blink_set,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1545, .phy_id = MARVELL_PHY_ID_88E1545,
...@@ -3273,6 +3307,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -3273,6 +3307,7 @@ static struct phy_driver marvell_drivers[] = {
.cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start,
.cable_test_get_status = marvell_vct7_cable_test_get_status, .cable_test_get_status = marvell_vct7_cable_test_get_status,
.led_brightness_set = m88e1318_led_brightness_set, .led_brightness_set = m88e1318_led_brightness_set,
.led_blink_set = m88e1318_led_blink_set,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E3016, .phy_id = MARVELL_PHY_ID_88E3016,
...@@ -3415,6 +3450,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -3415,6 +3450,7 @@ static struct phy_driver marvell_drivers[] = {
.get_tunable = m88e1540_get_tunable, .get_tunable = m88e1540_get_tunable,
.set_tunable = m88e1540_set_tunable, .set_tunable = m88e1540_set_tunable,
.led_brightness_set = m88e1318_led_brightness_set, .led_brightness_set = m88e1318_led_brightness_set,
.led_blink_set = m88e1318_led_blink_set,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment