]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/macb.c
mmc_write.c: Make mmc_berase do 32bit safe 64bit math
[karo-tx-uboot.git] / drivers / net / macb.c
index 01a94a4c4d117795fc6b2f42b8da701974b7e184..82e80cf5640d26a253d677bdbc0ec6ade4973d71 100644 (file)
@@ -347,14 +347,14 @@ static int macb_recv(struct eth_device *netdev)
                                headlen = 128 * (MACB_RX_RING_SIZE
                                                 - macb->rx_tail);
                                taillen = length - headlen;
-                               memcpy((void *)NetRxPackets[0],
+                               memcpy((void *)net_rx_packets[0],
                                       buffer, headlen);
-                               memcpy((void *)NetRxPackets[0] + headlen,
+                               memcpy((void *)net_rx_packets[0] + headlen,
                                       macb->rx_buffer, taillen);
-                               buffer = (void *)NetRxPackets[0];
+                               buffer = (void *)net_rx_packets[0];
                        }
 
-                       NetReceive(buffer, length);
+                       net_process_received_packet(buffer, length);
                        if (++rx_tail >= MACB_RX_RING_SIZE)
                                rx_tail = 0;
                        reclaim_rx_buffers(macb, rx_tail);
@@ -419,6 +419,15 @@ static int macb_phy_find(struct macb_device *macb)
 }
 #endif /* CONFIG_MACB_SEARCH_PHY */
 
+#ifdef CONFIG_PHYLIB
+#define gbit_phy_support(p)    ((p)->supported &                       \
+                                       (SUPPORTED_1000baseT_Full |     \
+                                       SUPPORTED_1000baseT_Half))
+#elif defined(CONFIG_RGMII) || defined(CONFIG_GMII)
+#define gbit_phy_support(p)    1
+#else
+#define gbit_phy_support(p)    0
+#endif
 
 static int macb_phy_init(struct macb_device *macb)
 {
@@ -478,35 +487,28 @@ static int macb_phy_init(struct macb_device *macb)
 
        /* First check for GMAC */
        if (macb_is_gem(macb)) {
-               lpa = macb_mdio_read(macb, MII_STAT1000);
-               if (lpa & (1 << 11)) {
-                       speed = 1000;
-                       duplex = 1;
-               } else {
-                      if (lpa & (1 << 10)) {
-                               speed = 1000;
-                               duplex = 1;
-                       } else {
-                               speed = 0;
-                       }
-               }
+               if (gbit_phy_support(phydev)) {
+                       lpa = macb_mdio_read(macb, MII_STAT1000);
 
-               if (speed == 1000) {
-                       printf("%s: link up, %dMbps %s-duplex (lpa: 0x%04x)\n",
-                              netdev->name,
-                              speed,
-                              duplex ? "full" : "half",
-                              lpa);
+                       if (lpa & (LPA_1000FULL | LPA_1000HALF)) {
+                               duplex = ((lpa & LPA_1000FULL) ? 1 : 0);
 
-                       ncfgr = macb_readl(macb, NCFGR);
-                       ncfgr &= ~(GEM_BIT(GBE) | MACB_BIT(SPD) | MACB_BIT(FD));
-                       if (speed)
+                               printf("%s: link up, 1000Mbps %s-duplex (lpa: 0x%04x)\n",
+                                       netdev->name,
+                                       duplex ? "full" : "half",
+                                       lpa);
+
+                               ncfgr = macb_readl(macb, NCFGR);
+                               ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
                                ncfgr |= GEM_BIT(GBE);
-                       if (duplex)
-                               ncfgr |= MACB_BIT(FD);
-                       macb_writel(macb, NCFGR, ncfgr);
 
-                       return 1;
+                               if (duplex)
+                                       ncfgr |= MACB_BIT(FD);
+
+                               macb_writel(macb, NCFGR, ncfgr);
+
+                               return 1;
+                       }
                }
        }
 
@@ -524,7 +526,7 @@ static int macb_phy_init(struct macb_device *macb)
               lpa);
 
        ncfgr = macb_readl(macb, NCFGR);
-       ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
+       ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD) | GEM_BIT(GBE));
        if (speed)
                ncfgr |= MACB_BIT(SPD);
        if (duplex)
@@ -574,7 +576,13 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
        macb_writel(macb, TBQP, macb->tx_ring_dma);
 
        if (macb_is_gem(macb)) {
-#ifdef CONFIG_RGMII
+               /*
+                * When the GMAC IP with GE feature, this bit is used to
+                * select interface between RGMII and GMII.
+                * When the GMAC IP without GE feature, this bit is used
+                * to select interface between RMII and MII.
+                */
+#if defined(CONFIG_RGMII) || defined(CONFIG_RMII)
                gem_writel(macb, UR, GEM_BIT(RGMII));
 #else
                gem_writel(macb, UR, 0);