igc: Add setup link functionality
Subsystems (2)
PATCH v4 10/11 igc: Add setup link functionality
Add link establishment methods
Add auto negotiation methods
Add read MAC address method
Sasha Neftin (v2):
minor cosmetic changes
Sasha Neftin (v3):
remove not addressed methods
Sasha Neftin (v4):
address comments
remove improperly insertion of method from a patch replace e1000_ prefix with igc_ prefix remove duplicate PHY MII defines
Signed-off-by Sasha Neftin <[email protected]>
--- drivers/net/ethernet/intel/igc/igc.h | 1 + drivers/net/ethernet/intel/igc/igc_base.c | 41 ++++ drivers/net/ethernet/intel/igc/igc_defines.h | 38 +++ drivers/net/ethernet/intel/igc/igc_mac.c | 272 +++++++++++++++++++++- drivers/net/ethernet/intel/igc/igc_mac.h | 2 + drivers/net/ethernet/intel/igc/igc_main.c | 33 +++ drivers/net/ethernet/intel/igc/igc_phy.c | 332 ++++++++++++++++++++++++++- drivers/net/ethernet/intel/igc/igc_phy.h | 2 + 8 files changed, 719 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +1 -0
@@ -320,6 +320,7 @@ struct igc_adapter {struct work_struct reset_task;struct work_struct watchdog_task;struct work_struct dma_err_task; +bool fc_autoneg;u8 tx_timeout_factor;
drivers/net/ethernet/intel/igc/igc_base.c +41 -0
75 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_defines.h +38 -0
@@ -20,6 +20,11 @@/* Physical Func Reset Done Indication */ #define IGC_CTRL_EXT_LINK_MODE_MASK 0x00C00000 +/* Loop limit on how long we wait for auto-negotiation to complete */ +#define COPPER_LINK_UP_LIMIT 10 +#define PHY_AUTO_NEG_LIMIT 45 +#define PHY_FORCE_LIMIT 20 +/* Number of 100 microseconds we wait for PCI Express master disable */ #define MASTER_DISABLE_TIMEOUT 800/*Blocks new Master requests */
@@ -61,6 +66,12 @@#define IGC_CTRL_RST 0x04000000/* Global reset */ #define IGC_CTRL_PHY_RST 0x80000000/* PHY Reset */ +#define IGC_CTRL_SLU 0x00000040/* Set link up (Force Link) */ +#define IGC_CTRL_FRCSPD 0x00000800/* Force Speed */ +#define IGC_CTRL_FRCDPX 0x00001000/* Force Duplex */ + +#define IGC_CTRL_RFCE 0x08000000/* Receive Flow Control enable */ +#define IGC_CTRL_TFCE 0x10000000/* Transmit flow control enable */ /* PBA constants */ #define IGC_PBA_34K 0x0022
@@ -73,6 +84,29 @@#define IGC_SWFW_EEP_SM 0x1#define IGC_SWFW_PHY0_SM 0x2 +/* Autoneg Advertisement Register */ +#define NWAY_AR_10T_HD_CAPS 0x0020/* 10T Half Duplex Capable */ +#define NWAY_AR_10T_FD_CAPS 0x0040/* 10T Full Duplex Capable */ +#define NWAY_AR_100TX_HD_CAPS 0x0080/* 100TX Half Duplex Capable */ +#define NWAY_AR_100TX_FD_CAPS 0x0100/* 100TX Full Duplex Capable */ +#define NWAY_AR_PAUSE 0x0400/* Pause operation desired */ +#define NWAY_AR_ASM_DIR 0x0800/* Asymmetric Pause Direction bit */ + +/* Link Partner Ability Register (Base Page) */ +#define NWAY_LPAR_PAUSE 0x0400/* LP Pause operation desired */ +#define NWAY_LPAR_ASM_DIR 0x0800/* LP Asymmetric Pause Direction bit */ + +/* 1000BASE-T Control Register */ +#define CR_1000T_ASYM_PAUSE 0x0080/* Advertise asymmetric pause bit */ +#define CR_1000T_HD_CAPS 0x0100/* Advertise 1000T HD capability */ +#define CR_1000T_FD_CAPS 0x0200/* Advertise 1000T FD capability */ + +/* PHY GPY 211 registers */ +#define STANDARD_AN_REG_MASK 0x0007/* MMD */ +#define ANEG_MULTIGBT_AN_CTRL 0x0020/* MULTI GBT AN Control Register */ +#define MMD_DEVADDR_SHIFT 16/* Shift MMD to higher bits */ +#define CR_2500T_FD_CAPS 0x0080/* Advertise 2500T FD capability */ +/* NVM Control */ #define IGC_EECD_REQ 0x00000040/* NVM Access Request */ #define IGC_EECD_GNT 0x00000080/* NVM Access Grant */
@@ -358,6 +392,10 @@#define PHY_STATUS 0x01/* Status Register */ #define PHY_ID1 0x02/* Phy Id Reg (word 1) */ #define PHY_ID2 0x03/* Phy Id Reg (word 2) */ +#define PHY_AUTONEG_ADV 0x04/* Autoneg Advertisement */ +#define PHY_LP_ABILITY 0x05/* Link Partner Ability (Base Page) */ +#define PHY_1000T_CTRL 0x09/* 1000Base-T Control Reg */ +#define PHY_1000T_STATUS 0x0A/* 1000Base-T Status Reg */ /* Bit definitions for valid PHY IDs. I = Integrated E = External */ #define I225_I_PHY_ID 0x67C9DC00
drivers/net/ethernet/intel/igc/igc_mac.c +271 -1
300 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_mac.h +2 -0
@@ -14,6 +14,8 @@/* forward declaration */ s32 igc_check_for_copper_link (struct igc_hw *hw); +s32 igc_config_fc_after_link_up (struct igc_hw *hw); +s32 igc_force_mac_fc (struct igc_hw *hw);s32 igc_disable_pcie_master (struct igc_hw *hw);void igc_init_rx_addrs (struct igc_hw *hw,u16 rar_count);s32 igc_setup_link (struct igc_hw *hw);
drivers/net/ethernet/intel/igc/igc_main.c +33 -0
@@ -3429,6 +3429,25 @@ static int igc_probe(struct pci_dev *pdev, netdev->min_mtu =ETH_MIN_MTU ; netdev->max_mtu =MAX_STD_JUMBO_FRAME_SIZE ; +/* before reading the NVM, reset the controller to put the device in a +* known good starting state +*/ + hw->mac.ops.reset_hw (hw); + +if (eth_platform_get_mac_address (&pdev->dev, hw->mac.addr)) { +/* copy the MAC address out of the NVM */ +if (hw->mac.ops.read_mac_addr (hw)) +dev_err (&pdev->dev,"NVM Read Error\n" ); + } + +memcpy (netdev->dev_addr, hw->mac.addr, netdev->addr_len); + +if (!is_valid_ether_addr (netdev->dev_addr)) { +dev_err (&pdev->dev,"Invalid MAC Address\n" ); + err = -EIO ; + goto err_eeprom; + } +/* configure RXPBSIZE and TXPBSIZE */ wr32 (IGC_RXPBS ,I225_RXPBSIZE_DEFAULT );wr32 (IGC_TXPBS ,I225_TXPBSIZE_DEFAULT );
@@ -3437,6 +3456,14 @@ static int igc_probe(struct pci_dev *pdev,INIT_WORK (&adapter->reset_task, igc_reset_task); +/* Initialize link properties that are user-changeable */ + adapter->fc_autoneg = true; + hw->mac.autoneg = true; + hw->phy.autoneg_advertised =0x2f ; + + hw->fc.requested_mode = igc_fc_default; + hw->fc.current_mode = igc_fc_default; +/* reset the hardware with the new settings */ igc_reset (adapter);
@@ -3464,6 +3491,12 @@ static int igc_probe(struct pci_dev *pdev, err_register:igc_release_hw_control (adapter); +err_eeprom: +if (!igc_check_reset_block (hw)) +igc_reset_phy (hw); + +if (hw->flash_address) +iounmap (hw->flash_address); err_sw_init:igc_clear_interrupt_scheme (adapter);iounmap (adapter->io_addr);
drivers/net/ethernet/intel/igc/igc_phy.c +331 -1
344 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_phy.h +2 -0
@@ -12,8 +12,10 @@ 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); +s32 igc_setup_copper_link (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);
Signature · 1 line
2.11.0