]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tg3] Fix driver for BCM5719, BCM5720, BCM5764M, BCM57762
authorKevin Tran <ktran@broadcom.com>
Mon, 20 Aug 2012 17:48:50 +0000 (18:48 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 20 Aug 2012 17:50:35 +0000 (18:50 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/tg3/tg3.c
src/drivers/net/tg3/tg3.h
src/drivers/net/tg3/tg3_hw.c
src/drivers/net/tg3/tg3_phy.c

index b2cba72ea2c1f1a209d0a5792e6960ba2e47fa37..32ca1609c127a2b4c076be1c64972d2c1d2f07bd 100644 (file)
@@ -247,11 +247,12 @@ static int tg3_open(struct net_device *dev)
                return err;
 
        tpr->rx_std_iob_cnt = 0;
-       tg3_refill_prod_ring(tp);
 
        err = tg3_init_hw(tp, 1);
        if (err != 0)
                DBGC(tp->dev, "tg3_init_hw failed: %s\n", strerror(err));
+       else
+               tg3_refill_prod_ring(tp);
 
        return err;
 }
@@ -301,7 +302,6 @@ static int tg3_transmit(struct net_device *dev, struct io_buffer *iob)
        struct tg3 *tp = netdev_priv(dev);
        u32 len, entry;
        dma_addr_t mapping;
-       u32 bmsr;
 
        if (tg3_tx_avail(tp) < 1) {
                DBGC(dev, "Transmit ring full\n");
@@ -323,14 +323,10 @@ static int tg3_transmit(struct net_device *dev, struct io_buffer *iob)
        /* Packets are ready, update Tx producer idx local and on card. */
        tw32_tx_mbox(tp->prodmbox, entry);
 
-       writel(entry, tp->regs + MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW);
-
        tp->tx_prod = entry;
 
        mb();
 
-       tg3_readphy(tp, MII_BMSR, &bmsr);
-
        return 0;
 }
 
@@ -422,8 +418,10 @@ static void tg3_refill_prod_ring(struct tg3 *tp)
                tpr->rx_std_iob_cnt++;
        }
 
-       tpr->rx_std_prod_idx = idx;
-       tw32_rx_mbox(TG3_RX_STD_PROD_IDX_REG, idx);
+       if ((u32)idx != tpr->rx_std_prod_idx) {
+               tpr->rx_std_prod_idx = idx;
+               tw32_rx_mbox(TG3_RX_STD_PROD_IDX_REG, idx);
+       }
 }
 
 static void tg3_rx_complete(struct net_device *dev)
@@ -469,7 +467,10 @@ static void tg3_rx_complete(struct net_device *dev)
                tpr->rx_std_iob_cnt--;
        }
 
-       tp->rx_rcb_ptr = sw_idx;
+       if (tp->rx_rcb_ptr != sw_idx) {
+               tw32_rx_mbox(tp->consmbox, sw_idx);
+               tp->rx_rcb_ptr = sw_idx;
+       }
 
        tg3_refill_prod_ring(tp);
 }
@@ -480,7 +481,9 @@ static void tg3_poll(struct net_device *dev)
        struct tg3 *tp = netdev_priv(dev);
 
        /* ACK interrupts */
-       tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00);
+       /*
+        *tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00);
+        */
        tp->hw_status->status &= ~SD_STATUS_UPDATED;
 
        tg3_poll_link(tp);
@@ -905,6 +908,7 @@ static struct pci_device_id tg3_nics[] = {
        PCI_ROM(0x14e4, 0x1684, "14e4-1684", "14e4-1684", 0),
        PCI_ROM(0x14e4, 0x165b, "14e4-165b", "14e4-165b", 0),
        PCI_ROM(0x14e4, 0x1681, "14e4-1681", "14e4-1681", 0),
+       PCI_ROM(0x14e4, 0x1682, "14e4-1682", "14e4-1682", 0),
        PCI_ROM(0x14e4, 0x1680, "14e4-1680", "14e4-1680", 0),
        PCI_ROM(0x14e4, 0x1688, "14e4-1688", "14e4-1688", 0),
        PCI_ROM(0x14e4, 0x1689, "14e4-1689", "14e4-1689", 0),
index 1913cb166a5d070675a9e26b26e97ed4af3b8c3e..e84eed8791e48f39fa590f3927bbf95568e6d166 100644 (file)
 #define TG3_BDINFO_NIC_ADDR            0xcUL /* 32-bit */
 #define TG3_BDINFO_SIZE                        0x10UL
 
+#define RX_STD_MAX_SIZE                 1536
 #define TG3_RX_STD_MAX_SIZE_5700       512
 #define TG3_RX_STD_MAX_SIZE_5717       2048
 #define TG3_RX_JMB_MAX_SIZE_5700       256
 #define  TG3PCI_DEVICE_TIGON3_57781     0x16b1
 #define  TG3PCI_DEVICE_TIGON3_57785     0x16b5
 #define  TG3PCI_DEVICE_TIGON3_57761     0x16b0
+#define  TG3PCI_DEVICE_TIGON3_57762     0x1682
 #define  TG3PCI_DEVICE_TIGON3_57765     0x16b4
 #define  TG3PCI_DEVICE_TIGON3_57791     0x16b2
 #define  TG3PCI_DEVICE_TIGON3_57795     0x16b6
index 13d5962ce2cd68bbc0cece5c909aec7a577a5407..9ae007c2fb0183699bf78909c476ba1f745dbe50 100644 (file)
@@ -434,6 +434,7 @@ int tg3_get_invariants(struct tg3 *tp)
                else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57781 ||
                         tp->pdev->device == TG3PCI_DEVICE_TIGON3_57785 ||
                         tp->pdev->device == TG3PCI_DEVICE_TIGON3_57761 ||
+                        tp->pdev->device == TG3PCI_DEVICE_TIGON3_57762 ||
                         tp->pdev->device == TG3PCI_DEVICE_TIGON3_57765 ||
                         tp->pdev->device == TG3PCI_DEVICE_TIGON3_57791 ||
                         tp->pdev->device == TG3PCI_DEVICE_TIGON3_57795)
@@ -2127,9 +2128,12 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
 
        val = TG3_RX_STD_MAX_SIZE_5700 << BDINFO_FLAGS_MAXLEN_SHIFT;
 
+       if (tg3_flag(tp, 57765_PLUS))
+               val |= (RX_STD_MAX_SIZE << 2);
+
        tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS, val);
 
-       tpr->rx_std_prod_idx = TG3_DEF_RX_RING_PENDING;
+       tpr->rx_std_prod_idx = 0;
 
        /* std prod index is updated by tg3_refill_prod_ring() */
        tw32_rx_mbox(TG3_RX_STD_PROD_IDX_REG, 0);
@@ -2137,6 +2141,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
 
        tg3_rings_reset(tp);
 
+       __tg3_set_mac_addr(tp,0);
+
 #define        TG3_MAX_MTU     1522
        /* MTU + ethernet header + FCS + optional VLAN tag */
        tw32(MAC_RX_MTU_SIZE, TG3_MAX_MTU);
index f49c7f0b2690a64b33a7983bad008e0015748a53..65dea7e662cc4e224f7cb1cb360a0f5944cfc4de 100644 (file)
@@ -1008,12 +1008,11 @@ skip_phy_reset:
 void tg3_poll_link(struct tg3 *tp)
 {      DBGP("%s\n", __func__);
 
-       u32 mac_stat;
-
-       mac_stat = tr32(MAC_STATUS);
-
-       if (mac_stat & MAC_STATUS_LNKSTATE_CHANGED)
+       if (tp->hw_status->status & SD_STATUS_LINK_CHG) {
+               DBGC(tp->dev,"link_changed\n");
+               tp->hw_status->status &= ~SD_STATUS_LINK_CHG;
                tg3_setup_phy(tp, 0);
+       }
 }
 
 static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u16 *speed, u8 *duplex)
@@ -1506,9 +1505,8 @@ relink:
        tw32_f(MAC_MODE, tp->mac_mode);
        udelay(40);
 
-       /* We always use the link change register */
-       /* NOTE: this freezes for mdc? */
-       tw32_f(MAC_EVENT, 0);
+       /* Enabled attention when the link has changed state. */
+       tw32_f(MAC_EVENT, MAC_EVENT_LNKSTATE_CHANGED);
        udelay(40);
 
        if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 &&