Merge branch 'master' of /home/wd/git/u-boot/custodians
[oweals/u-boot.git] / drivers / net / e1000.c
index b8dd9f2fe4636f0d474b3fb296876de49a76568f..60b04c267cbd9fd421b31f06997a87482dbde9f8 100644 (file)
@@ -50,7 +50,8 @@ tested on both gig copper and gig fiber boards
 #define bus_to_phys(devno, a)  pci_mem_to_phys(devno, a)
 #define mdelay(n)      udelay((n)*1000)
 
-#define E1000_DEFAULT_PBA    0x000a0026
+#define E1000_DEFAULT_PCI_PBA  0x00000030
+#define E1000_DEFAULT_PCIE_PBA 0x000a0026
 
 /* NIC specific static variables go here */
 
@@ -78,6 +79,7 @@ static struct pci_device_id supported[] = {
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82546EB_COPPER},
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82545EM_FIBER},
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82546EB_FIBER},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82546GB_COPPER},
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82540EM_LOM},
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82541ER},
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82541GI_LF},
@@ -1349,9 +1351,16 @@ e1000_reset_hw(struct e1000_hw *hw)
        uint32_t ctrl_ext;
        uint32_t icr;
        uint32_t manc;
+       uint32_t pba = 0;
 
        DEBUGFUNC();
 
+       /* get the correct pba value for both PCI and PCIe*/
+       if (hw->mac_type <  e1000_82571)
+               pba = E1000_DEFAULT_PCI_PBA;
+       else
+               pba = E1000_DEFAULT_PCIE_PBA;
+
        /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
        if (hw->mac_type == e1000_82542_rev2_0) {
                DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
@@ -1419,7 +1428,7 @@ e1000_reset_hw(struct e1000_hw *hw)
        if (hw->mac_type == e1000_82542_rev2_0) {
                pci_write_config_word(hw->pdev, PCI_COMMAND, hw->pci_cmd_word);
        }
-       E1000_WRITE_REG(hw, PBA, E1000_DEFAULT_PBA);
+       E1000_WRITE_REG(hw, PBA, pba);
 }
 
 /******************************************************************************
@@ -5168,7 +5177,21 @@ e1000_initialize(bd_t * bis)
                }
 
                nic = (struct eth_device *) malloc(sizeof (*nic));
+               if (!nic) {
+                       printf("Error: e1000 - Can not alloc memory\n");
+                       return 0;
+               }
+
                hw = (struct e1000_hw *) malloc(sizeof (*hw));
+               if (!hw) {
+                       free(nic);
+                       printf("Error: e1000 - Can not alloc memory\n");
+                       return 0;
+               }
+
+               memset(nic, 0, sizeof(*nic));
+               memset(hw, 0, sizeof(*hw));
+
                hw->pdev = devno;
                nic->priv = hw;