Skip to contentSkip to conversation

igc: Add code for PHY support

PATCH Superseded Sasha Neftin 2 participants 2 messages Jul 18, 2018 – Jul 19, 2018

Subsystems (2)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 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

---
 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 2b5378d96c7b..4387f6ba8e67 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 9ef6f290209c..901048fdf478 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 802a0cbd3123..35588fa7b8c5 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 7d935d581fc7..e61b9c5faa32 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_bus_info_pcie(struct igc_hw *hw);
 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 2514bb5e5651..24689854a0a2 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);
 }
 
 /**
@@ -3401,6 +3411,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 000000000000..deac52297052
@@ -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 aaeaf61b730a..68a1aa17b329 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
2.11.0
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Sasha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on jkirsher-next-queue/dev-queue]
[also build test WARNING on v4.18-rc5 next-20180718]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Sasha-Neftin/igc-Add-skeletal-frame-for-Intel-R-2-5G-Ethernet-Controller-support/20180719-055021
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> drivers/net/ethernet/intel/igc/igc_phy.c:198:9: sparse: incorrect type in initializer (different address spaces) @@    expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@    got deref] [usertype] <asn:2>*hw_addr @@

drivers/net/ethernet/intel/igc/igc_phy.c:198:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_phy.c:198:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_phy.c:203:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_phy.c:203:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_phy.c:203:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_phy.c:245:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_phy.c:245:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_phy.c:245:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_phy.c:302:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_phy.c:302:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_phy.c:302:9: got unsigned char [usertype] *__val

vim +198 drivers/net/ethernet/intel/igc/igc_phy.c

171
172 /**
173 * igc_phy_hw_reset - PHY hardware reset
174 * @hw: pointer to the HW structure
175 *

   176	 *  Verify the reset block is not blocking us from resetting.  Acquire
   177	 *  semaphore (if necessary) and read/set/write the device control reset
   178	 *  bit in the PHY.  Wait the appropriate delay time for the device to
   179	 *  reset and release the semaphore (if necessary).
   180	 **/
   181	s32 igc_phy_hw_reset(struct igc_hw *hw)
   182	{
   183		struct igc_phy_info *phy = &hw->phy;
   184		s32  ret_val;
   185		u32 ctrl;
   186	
   187		ret_val = igc_check_reset_block(hw);
   188		if (ret_val) {
   189			ret_val = 0;
   190			goto out;
   191		}
   192	
   193		ret_val = phy->ops.acquire(hw);
   194		if (ret_val)
   195			goto out;
   196	
   197		ctrl = rd32(IGC_CTRL);
 > 198		wr32(IGC_CTRL, ctrl | IGC_CTRL_PHY_RST);

199 wrfl();
200
201 udelay(phy->reset_delay_us);
202
203 wr32(IGC_CTRL, ctrl);
204 wrfl();
205
206 usleep_range(1500, 2000);
207
208 phy->ops.release(hw);
209
210 ret_val = phy->ops.get_cfg_done(hw);
211
212 out:
213 return ret_val;
214 }
215

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation