This patch implements ixgbe_led_on_t_X550em and ixgbe_led_off_t_X550em
function for turning on and off LEDs on X557 external PHY.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu at intel.com>
---
 drivers/net/ixgbe/base/ixgbe_type.h |  3 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 52 +++++++++++++++++++++++++++++++++++++
 drivers/net/ixgbe/base/ixgbe_x550.h |  2 ++
 3 files changed, 57 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 672d0a5..6eb3421 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1931,6 +1931,9 @@ enum {
 #define IXGBE_LED_IVRT(_i)     IXGBE_LED_OFFSET(IXGBE_LED_IVRT_BASE, _i)
 #define IXGBE_LED_BLINK(_i)    IXGBE_LED_OFFSET(IXGBE_LED_BLINK_BASE, _i)
 #define IXGBE_LED_MODE_MASK(_i)        
IXGBE_LED_OFFSET(IXGBE_LED_MODE_MASK_BASE, _i)
+#define IXGBE_X557_LED_MANUAL_SET_MASK (1 << 8)
+#define IXGBE_X557_MAX_LED_INDEX       3
+#define IXGBE_X557_LED_PROVISIONING    0xC430

 /* LED modes */
 #define IXGBE_LED_LINK_UP      0x0
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index c2c0014..c9b1465 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -80,6 +80,10 @@ s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
        mac->ops.mdd_event = ixgbe_mdd_event_X550;
        mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
        mac->ops.disable_rx = ixgbe_disable_rx_x550;
+       if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+               hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
+               hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
+       }
        return ret_val;
 }

@@ -3131,3 +3135,51 @@ s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
        /* Configure Link Status Alarm and Temperature Threshold interrupts */
        return ixgbe_enable_lasi_ext_t_x550em(hw);
 }
+
+/**
+ *  ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @led_idx: led number to turn on
+ **/
+s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+       u16 phy_data;
+
+       DEBUGFUNC("ixgbe_led_on_t_X550em");
+
+       if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+               return IXGBE_ERR_PARAM;
+
+       /* To turn on the LED, set mode to ON. */
+       ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                          IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
+       phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
+       ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                           IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+       return IXGBE_SUCCESS;
+}
+
+/**
+ *  ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @led_idx: led number to turn off
+ **/
+s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+       u16 phy_data;
+
+       DEBUGFUNC("ixgbe_led_off_t_X550em");
+
+       if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+               return IXGBE_ERR_PARAM;
+
+       /* To turn on the LED, set mode to ON. */
+       ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                          IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
+       phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
+       ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                           IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+       return IXGBE_SUCCESS;
+}
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index 230b44f..4f986e8 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -103,4 +103,6 @@ s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, 
ixgbe_link_speed *speed,
                              bool *link_up, bool link_up_wait_to_complete);
 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw);
 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx);
+s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx);
 #endif /* _IXGBE_X550_H_ */
-- 
1.9.3

Reply via email to