]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/e1000.c
fix USERACCESS_GO checking
[karo-tx-uboot.git] / drivers / net / e1000.c
index c86bf0a0e798e26565b8314f16927800c15e9b07..8ba98b27d52283be000f0896f838ca5e13eba591 100644 (file)
@@ -135,7 +135,6 @@ static void e1000_set_media_type(struct e1000_hw *hw);
 static int32_t e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask);
 static int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
 
-#ifndef CONFIG_AP1000 /* remove for warnings */
 static int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset,
                uint16_t words,
                uint16_t *data);
@@ -884,6 +883,7 @@ static int e1000_validate_eeprom_checksum(struct e1000_hw *hw)
        }
 
        /* Compute the checksum */
+       checksum = 0;
        for (i = 0; i < EEPROM_CHECKSUM_REG; i++)
                checksum += buf[i];
        checksum = ((uint16_t)EEPROM_SUM) - checksum;
@@ -941,7 +941,6 @@ e1000_set_phy_mode(struct e1000_hw *hw)
 
        return E1000_SUCCESS;
 }
-#endif /* #ifndef CONFIG_AP1000 */
 
 /***************************************************************************
  *
@@ -1122,7 +1121,6 @@ static boolean_t e1000_is_second_port(struct e1000_hw *hw)
 static int
 e1000_read_mac_addr(struct eth_device *nic)
 {
-#ifndef CONFIG_AP1000
        struct e1000_hw *hw = nic->priv;
        uint16_t offset;
        uint16_t eeprom_data;
@@ -1145,36 +1143,11 @@ e1000_read_mac_addr(struct eth_device *nic)
                nic->enetaddr[5] ^= 1;
 
 #ifdef CONFIG_E1000_FALLBACK_MAC
-       if ( *(u32*)(nic->enetaddr) == 0 || *(u32*)(nic->enetaddr) == ~0 ) {
+       if (!is_valid_ether_addr(nic->enetaddr)) {
                unsigned char fb_mac[NODE_ADDRESS_SIZE] = CONFIG_E1000_FALLBACK_MAC;
 
                memcpy (nic->enetaddr, fb_mac, NODE_ADDRESS_SIZE);
        }
-#endif
-#else
-       /*
-        * The AP1000's e1000 has no eeprom; the MAC address is stored in the
-        * environment variables.  Currently this does not support the addition
-        * of a PMC e1000 card, which is certainly a possibility, so this should
-        * be updated to properly use the env variable only for the onboard e1000
-        */
-
-       int ii;
-       char *s, *e;
-
-       DEBUGFUNC();
-
-       s = getenv ("ethaddr");
-       if (s == NULL) {
-               return -E1000_ERR_EEPROM;
-       } else {
-               for(ii = 0; ii < 6; ii++) {
-                       nic->enetaddr[ii] = s ? simple_strtoul (s, &e, 16) : 0;
-                       if (s){
-                               s = (*e) ? e + 1 : e;
-                       }
-               }
-       }
 #endif
        return 0;
 }
@@ -1369,7 +1342,6 @@ e1000_reset_hw(struct e1000_hw *hw)
 {
        uint32_t ctrl;
        uint32_t ctrl_ext;
-       uint32_t icr;
        uint32_t manc;
        uint32_t pba = 0;
 
@@ -1442,7 +1414,7 @@ e1000_reset_hw(struct e1000_hw *hw)
        E1000_WRITE_REG(hw, IMC, 0xffffffff);
 
        /* Clear any pending interrupt events. */
-       icr = E1000_READ_REG(hw, ICR);
+       E1000_READ_REG(hw, ICR);
 
        /* If MWI was previously enabled, reenable it. */
        if (hw->mac_type == e1000_82542_rev2_0) {
@@ -1716,6 +1688,16 @@ e1000_init_hw(struct eth_device *nic)
                E1000_WRITE_REG(hw, TXDCTL, ctrl);
        }
 
+       /* Set the receive descriptor write back policy */
+
+       if (hw->mac_type >= e1000_82571) {
+               ctrl = E1000_READ_REG(hw, RXDCTL);
+               ctrl =
+                   (ctrl & ~E1000_RXDCTL_WTHRESH) |
+                   E1000_RXDCTL_FULL_RX_DESC_WB;
+               E1000_WRITE_REG(hw, RXDCTL, ctrl);
+       }
+
        switch (hw->mac_type) {
        default:
                break;
@@ -1808,7 +1790,6 @@ e1000_setup_link(struct eth_device *nic)
        if (e1000_check_phy_reset_block(hw))
                return E1000_SUCCESS;
 
-#ifndef CONFIG_AP1000
        /* Read and store word 0x0F of the EEPROM. This word contains bits
         * that determine the hardware's default PAUSE (flow control) mode,
         * a bit that determines whether the HW defaults to enabling or
@@ -1822,11 +1803,6 @@ e1000_setup_link(struct eth_device *nic)
                DEBUGOUT("EEPROM Read Error\n");
                return -E1000_ERR_EEPROM;
        }
-#else
-       /* we have to hardcode the proper value for our hardware. */
-       /* this value is for the 82540EM pci card used for prototyping, and it works. */
-       eeprom_data = 0xb220;
-#endif
 
        if (hw->fc == e1000_fc_default) {
                switch (hw->mac_type) {
@@ -1836,16 +1812,12 @@ e1000_setup_link(struct eth_device *nic)
                        hw->fc = e1000_fc_full;
                        break;
                default:
-#ifndef CONFIG_AP1000
                        ret_val = e1000_read_eeprom(hw,
                                EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
                        if (ret_val) {
                                DEBUGOUT("EEPROM Read Error\n");
                                return -E1000_ERR_EEPROM;
                        }
-#else
-                       eeprom_data = 0xb220;
-#endif
                        if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
                                hw->fc = e1000_fc_none;
                        else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
@@ -2109,12 +2081,10 @@ e1000_copper_link_preconfig(struct e1000_hw *hw)
        }
        DEBUGOUT("Phy ID = %x \n", hw->phy_id);
 
-#ifndef CONFIG_AP1000
        /* Set PHY to class A mode (if necessary) */
        ret_val = e1000_set_phy_mode(hw);
        if (ret_val)
                return ret_val;
-#endif
        if ((hw->mac_type == e1000_82545_rev_3) ||
                (hw->mac_type == e1000_82546_rev_3)) {
                ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
@@ -4446,7 +4416,8 @@ e1000_phy_init_script(struct e1000_hw *hw)
                mdelay(20);
 
                /* Now enable the transmitter */
-               e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
+               if (!ret_val)
+                       e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
 
                if (hw->mac_type == e1000_82547) {
                        uint16_t fused, fine, coarse;
@@ -5030,10 +5001,9 @@ e1000_poll(struct eth_device *nic)
 /**************************************************************************
 TRANSMIT - Transmit a frame
 ***************************************************************************/
-static int
-e1000_transmit(struct eth_device *nic, volatile void *packet, int length)
+static int e1000_transmit(struct eth_device *nic, void *packet, int length)
 {
-       void * nv_packet = (void *)packet;
+       void *nv_packet = (void *)packet;
        struct e1000_hw *hw = nic->priv;
        struct e1000_tx_desc *txp;
        int i = 0;
@@ -5242,7 +5212,7 @@ e1000_initialize(bd_t * bis)
                list_add_tail(&hw->list_node, &e1000_hw_list);
 
                /* Validate the EEPROM and get chipset information */
-#if !(defined(CONFIG_AP1000) || defined(CONFIG_MVBC_1G))
+#if !defined(CONFIG_MVBC_1G)
                if (e1000_init_eeprom_params(hw)) {
                        E1000_ERR(nic, "EEPROM is invalid!\n");
                        continue;