From: Menachem Fogel <menachem.fo...@intel.com>

Implement LED blinking for i225.

Signed-off-by: Fogel Menachem <menachem.fo...@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
---
 drivers/net/intel/e1000/base/e1000_i225.c | 44 +++++++++++++++++++++++
 drivers/net/intel/e1000/base/e1000_i225.h |  8 +++++
 2 files changed, 52 insertions(+)

diff --git a/drivers/net/intel/e1000/base/e1000_i225.c 
b/drivers/net/intel/e1000/base/e1000_i225.c
index a6f113608b..a2d4faa0a9 100644
--- a/drivers/net/intel/e1000/base/e1000_i225.c
+++ b/drivers/net/intel/e1000/base/e1000_i225.c
@@ -123,6 +123,11 @@ static s32 e1000_init_mac_params_i225(struct e1000_hw *hw)
 
        mac->ops.write_vfta = e1000_write_vfta_generic;
 
+       /* LED */
+       mac->ops.cleanup_led = e1000_cleanup_led_generic;
+       mac->ops.id_led_init = e1000_id_led_init_i225;
+       mac->ops.blink_led = e1000_blink_led_i225;
+
        /* Disable EEE by default */
        dev_spec->eee_disable = true;
 
@@ -1213,6 +1218,45 @@ s32 e1000_set_d3_lplu_state_i225(struct e1000_hw *hw, 
bool active)
        return E1000_SUCCESS;
 }
 
+/**
+ *  e1000_blink_led_i225 - Blink SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  This starts the adapter LED blinking.
+ *  Request the LED to be setup first.
+ **/
+s32 e1000_blink_led_i225(struct e1000_hw *hw)
+{
+       u32 blink = 0;
+
+       DEBUGFUNC("e1000_blink_led_i225");
+
+       e1000_id_led_init_i225(hw);
+
+       blink = hw->mac.ledctl_default;
+       blink &= ~(E1000_GLOBAL_BLINK_MODE | E1000_LED1_MODE_MASK | 
E1000_LED2_MODE_MASK);
+       blink |= E1000_LED1_BLINK;
+
+       E1000_WRITE_REG(hw, E1000_LEDCTL, blink);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_id_led_init_i225 - store LED configurations in SW
+ *  @hw: pointer to the HW structure
+ *
+ *  Initializes the LED config in SW.
+ **/
+s32 e1000_id_led_init_i225(struct e1000_hw *hw)
+{
+       DEBUGFUNC("e1000_id_led_init_i225");
+
+       hw->mac.ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
+
+       return E1000_SUCCESS;
+}
+
 /**
  *  e1000_set_eee_i225 - Enable/disable EEE support
  *  @hw: pointer to the HW structure
diff --git a/drivers/net/intel/e1000/base/e1000_i225.h 
b/drivers/net/intel/e1000/base/e1000_i225.h
index ef4e646e02..61b049b1f4 100644
--- a/drivers/net/intel/e1000/base/e1000_i225.h
+++ b/drivers/net/intel/e1000/base/e1000_i225.h
@@ -17,6 +17,8 @@ s32 e1000_set_flsw_flash_burst_counter_i225(struct e1000_hw 
*hw,
                                            u32 burst_counter);
 s32 e1000_write_erase_flash_command_i225(struct e1000_hw *hw, u32 opcode,
                                         u32 address);
+s32 e1000_id_led_init_i225(struct e1000_hw *hw);
+s32 e1000_blink_led_i225(struct e1000_hw *hw);
 s32 e1000_check_for_link_i225(struct e1000_hw *hw);
 s32 e1000_acquire_swfw_sync_i225(struct e1000_hw *hw, u16 mask);
 void e1000_release_swfw_sync_i225(struct e1000_hw *hw, u16 mask);
@@ -105,4 +107,10 @@ s32 e1000_set_eee_i225(struct e1000_hw *hw, bool adv2p5G, 
bool adv1G,
 #define E1000_RXDADV_PKTTYPE_ETQF_MASK 0x00000070 /* ETQF has 8 indices */
 #define E1000_RXDADV_PKTTYPE_ETQF_SHIFT        4 /* Right-shift 4 bits */
 
+/* LED Control */
+#define E1000_GLOBAL_BLINK_MODE        0x00000020 /*Blink at 200 ms on and 200 
ms off.*/
+#define E1000_LED1_MODE_MASK   0x00000F00
+#define E1000_LED1_BLINK       0x00008000
+#define E1000_LED2_MODE_MASK   0x000F0000
+
 #endif
-- 
2.43.5

Reply via email to