[v3,14/36] net/e1000/base: add LED blink support for i225

Message ID 86b3dfd4dab01f3b545299271613a20bdede8412.1738932115.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted
Delegated to: Bruce Richardson
Headers
Series Merge Intel IGC and E1000 drivers, and update E1000 base code |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Burakov, Anatoly Feb. 7, 2025, 12:45 p.m. UTC
From: Menachem Fogel <menachem.fogel@intel.com>

Implement LED blinking for i225.

Signed-off-by: Menachem Fogel <menachem.fogel@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 .mailmap                                  |  1 +
 drivers/net/intel/e1000/base/e1000_i225.c | 44 +++++++++++++++++++++++
 drivers/net/intel/e1000/base/e1000_i225.h |  8 +++++
 3 files changed, 53 insertions(+)
  

Patch

diff --git a/.mailmap b/.mailmap
index 8ffd20cba5..857af326e3 100644
--- a/.mailmap
+++ b/.mailmap
@@ -991,6 +991,7 @@  Maxime Gouin <maxime.gouin@6wind.com>
 Maxime Leroy <maxime.leroy@6wind.com>
 Md Fahad Iqbal Polash <md.fahad.iqbal.polash@intel.com>
 Megha Ajmera <megha.ajmera@intel.com>
+Menachem Fogel <menachem.fogel@intel.com>
 Meijuan Zhao <meijuanx.zhao@intel.com>
 Meir Levi <mlevi4@marvell.com>
 Meir Tseitlin <mirots@gmail.com>
diff --git a/drivers/net/intel/e1000/base/e1000_i225.c b/drivers/net/intel/e1000/base/e1000_i225.c
index d9e3ab2cbc..7ea551014e 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;
 
@@ -1220,6 +1225,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