igc: Add setup link functionality
[linux-2.6-microblaze.git] / drivers / net / ethernet / intel / igc / igc_main.c
index 14f3248..e1a078e 100644 (file)
@@ -3403,6 +3403,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);
@@ -3411,6 +3430,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 = 0xaf;
+
+       hw->fc.requested_mode = igc_fc_default;
+       hw->fc.current_mode = igc_fc_default;
+
        /* reset the hardware with the new settings */
        igc_reset(adapter);
 
@@ -3438,6 +3465,9 @@ 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);
 err_sw_init:
        igc_clear_interrupt_scheme(adapter);
        iounmap(adapter->io_addr);