Skip to contentSkip to conversation

igc: Add code for PHY support

PATCH Superseded Sasha Neftin 1 participant 1 message Aug 15, 2018

Subsystems (2)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 9/11 igc: Add code for PHY support

Sasha Neftin (v2):
minor cosmetic changes

Alexander Duyck (v3.5):
Made non-gpy versions of phy functions static
Move xmdio functions to avoid need for prototype function Move reset, read_reg, and write_reg ops into e1000_phy_ops_base Drop code implying more than one function
Fix merge conflict with v3.5 of NVM code.

Sasha Neftin (v3):
Introduce temporary workaround for PHY power down.

Sasha Neftin (v4):
address comments
remove space
fix minor grammar typo
replace e1000_ prefix with igc_ prefix

Sasha Neftin (v5):
update IGC_GEN_POLL_TIMEOUT value to 1920
fix code indentation

---
 drivers/net/ethernet/intel/igc/Makefile      |   2 +-
 drivers/net/ethernet/intel/igc/igc.h         |  16 +
 drivers/net/ethernet/intel/igc/igc_base.c    | 126 +++++++-
 drivers/net/ethernet/intel/igc/igc_base.h    |   1 +
 drivers/net/ethernet/intel/igc/igc_defines.h |  95 ++++++
 drivers/net/ethernet/intel/igc/igc_hw.h      |  62 +++-
 drivers/net/ethernet/intel/igc/igc_mac.c     |  47 ++-
 drivers/net/ethernet/intel/igc/igc_mac.h     |  11 +
 drivers/net/ethernet/intel/igc/igc_main.c    |  11 +
 drivers/net/ethernet/intel/igc/igc_phy.c     | 458 +++++++++++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_phy.h     |  20 ++
 drivers/net/ethernet/intel/igc/igc_regs.h    |   3 +
 12 files changed, 844 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/igc/igc_phy.c
 create mode 100644 drivers/net/ethernet/intel/igc/igc_phy.h
drivers/net/ethernet/intel/igc/Makefile +1 -1
index 2b5378d..4387f6b 100644
@@ -7,4 +7,4 @@
 
 obj-$(CONFIG_IGC) += igc.o
 
-igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o
+igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o igc_phy.o
drivers/net/ethernet/intel/igc/igc.h +16 -0
index 9ef6f29..901048f 100644
@@ -365,6 +365,22 @@ static inline u16 igc_desc_unused(const struct igc_ring *ring)
 	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
 }
 
+static inline s32 igc_get_phy_info(struct igc_hw *hw)
+{
+	if (hw->phy.ops.get_phy_info)
+		return hw->phy.ops.get_phy_info(hw);
+
+	return 0;
+}
+
+static inline s32 igc_reset_phy(struct igc_hw *hw)
+{
+	if (hw->phy.ops.reset)
+		return hw->phy.ops.reset(hw);
+
+	return 0;
+}
+
 static inline struct netdev_queue *txring_txq(const struct igc_ring *tx_ring)
 {
 	return netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index);
drivers/net/ethernet/intel/igc/igc_base.c +125 -1

171 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_base.h +1 -0
index 802a0cb..35588fa7 100644
@@ -6,6 +6,7 @@
 
 /* forward declaration */
 void igc_rx_fifo_flush_base(struct igc_hw *hw);
+void igc_power_down_phy_copper_base(struct igc_hw *hw);
 
 /* Transmit Descriptor - Advanced */
 union igc_adv_tx_desc {
drivers/net/ethernet/intel/igc/igc_defines.h +95 -0

124 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_hw.h +58 -4

110 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_mac.c +45 -2

62 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_mac.h +11 -0
index 7d935d5..e61b9c5 100644
@@ -5,6 +5,7 @@
 #define _IGC_MAC_H_
 
 #include "igc_hw.h"
+#include "igc_phy.h"
 #include "igc_defines.h"
 
 #ifndef IGC_REMOVED
@@ -26,4 +27,14 @@
 s32 igc_get_speed_and_duplex_copper(struct igc_hw *hw, u16 *speed,
 				    u16 *duplex);
 
+bool igc_enable_mng_pass_thru(struct igc_hw *hw);
+
+enum igc_mng_mode {
+	igc_mng_mode_none = 0,
+	igc_mng_mode_asf,
+	igc_mng_mode_pt,
+	igc_mng_mode_ipmi,
+	igc_mng_mode_host_if_only
+};
+
 #endif
drivers/net/ethernet/intel/igc/igc_main.c +11 -0
index 361effe..bd41ad5 100644
@@ -100,6 +100,8 @@ static void igc_reset(struct igc_adapter *adapter)
 
 	if (!netif_running(adapter->netdev))
 		igc_power_down_link(adapter);
+
+	igc_get_phy_info(hw);
 }
 
 /**
@@ -108,6 +110,12 @@ static void igc_reset(struct igc_adapter *adapter)
  **/
 static void igc_power_up_link(struct igc_adapter *adapter)
 {
+	igc_reset_phy(&adapter->hw);
+
+	if (adapter->hw.phy.media_type == igc_media_type_copper)
+		igc_power_up_phy_copper(&adapter->hw);
+
+	igc_setup_link(&adapter->hw);
 }
 
 /**
@@ -116,6 +124,8 @@ static void igc_power_up_link(struct igc_adapter *adapter)
  **/
 static void igc_power_down_link(struct igc_adapter *adapter)
 {
+	if (adapter->hw.phy.media_type == igc_media_type_copper)
+		igc_power_down_phy_copper_base(&adapter->hw);
 }
 
 /**
@@ -3399,6 +3409,7 @@ static int igc_probe(struct pci_dev *pdev,
 
 	/* Copy the default MAC and PHY function pointers */
 	memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
+	memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
 
 	/* Initialize skew-specific constants */
 	err = ei->get_invariants(hw);
drivers/net/ethernet/intel/igc/igc_phy.c new file +458 -0

458 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_phy.h new file +20 -0
new file mode 100644
index 0000000..deac522
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c)  2018 Intel Corporation */
+
+#ifndef _IGC_PHY_H_
+#define _IGC_PHY_H_
+
+#include "igc_mac.h"
+
+s32  igc_check_reset_block(struct igc_hw *hw);
+s32  igc_phy_hw_reset(struct igc_hw *hw);
+s32  igc_get_phy_id(struct igc_hw *hw);
+s32  igc_phy_has_link(struct igc_hw *hw, u32 iterations,
+		      u32 usec_interval, bool *success);
+s32 igc_check_downshift(struct igc_hw *hw);
+void igc_power_up_phy_copper(struct igc_hw *hw);
+void igc_power_down_phy_copper(struct igc_hw *hw);
+s32  igc_write_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 data);
+s32  igc_read_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 *data);
+
+#endif
drivers/net/ethernet/intel/igc/igc_regs.h +3 -0
index aaeaf61..68a1aa1 100644
@@ -39,6 +39,9 @@
 #define IGC_SWSM		0x05B50  /* SW Semaphore */
 #define IGC_FWSM		0x05B54  /* FW Semaphore */
 
+/* Function Active and Power State to MNG */
+#define IGC_FACTPS		0x05B30
+
 /* Interrupt Register Description */
 #define IGC_EICS		0x01520  /* Ext. Interrupt Cause Set - W0 */
 #define IGC_EIMS		0x01524  /* Ext. Interrupt Mask Set/Read - RW */
Signature · 1 line
1.8.3.1