Merge branch 'rmobile' of git://git.denx.de/u-boot-sh
[oweals/u-boot.git] / drivers / net / altera_tse.c
index afd8e3126c4020069100c50060f9343408792df2..ad3bd1e2124059f7da1fed4f37859f7ec6e7f69e 100644 (file)
@@ -182,12 +182,10 @@ static int alt_sgdma_do_sync_transfer(volatile struct alt_sgdma_registers *dev,
 static int alt_sgdma_do_async_transfer(volatile struct alt_sgdma_registers *dev,
                                volatile struct alt_sgdma_descriptor *desc)
 {
-       unsigned int status;
        int counter = 0;
 
        /* Wait for any pending transfers to complete */
        alt_sgdma_print_desc(desc);
-       status = dev->status;
 
        counter = 0;
        while (dev->status & ALT_SGDMA_STATUS_BUSY_MSK) {
@@ -257,8 +255,7 @@ static int tse_adjust_link(struct altera_tse_priv *priv)
        return 0;
 }
 
-static int tse_eth_send(struct eth_device *dev,
-                       volatile void *packet, int length)
+static int tse_eth_send(struct eth_device *dev, void *packet, int length)
 {
        struct altera_tse_priv *priv = dev->priv;
        volatile struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx;
@@ -268,7 +265,8 @@ static int tse_eth_send(struct eth_device *dev,
        volatile struct alt_sgdma_descriptor *tx_desc_cur =
            (volatile struct alt_sgdma_descriptor *)&tx_desc[0];
 
-       flush_dcache((unsigned long)packet, length);
+       flush_dcache_range((unsigned long)packet,
+                       (unsigned long)packet + length);
        alt_sgdma_construct_descriptor_burst(
                (volatile struct alt_sgdma_descriptor *)&tx_desc[0],
                (volatile struct alt_sgdma_descriptor *)&tx_desc[1],
@@ -303,15 +301,17 @@ static int tse_eth_rx(struct eth_device *dev)
            ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK) {
                debug("got packet\n");
                packet_length = rx_desc->actual_bytes_transferred;
-               NetReceive(NetRxPackets[0], packet_length);
+               net_process_received_packet(net_rx_packets[0], packet_length);
 
                /* start descriptor again */
-               flush_dcache((unsigned long)(NetRxPackets[0]), PKTSIZE_ALIGN);
+               flush_dcache_range((unsigned long)(net_rx_packets[0]),
+                                  (unsigned long)(net_rx_packets[0] +
+                                                  PKTSIZE_ALIGN));
                alt_sgdma_construct_descriptor_burst(
                        (volatile struct alt_sgdma_descriptor *)&rx_desc[0],
                        (volatile struct alt_sgdma_descriptor *)&rx_desc[1],
                        (unsigned int)0x0,      /* read addr */
-                       (unsigned int *)NetRxPackets[0],
+                       (unsigned int *)net_rx_packets[0],
                        0x0,    /* length or EOP */
                        0x0,    /* gen eop */
                        0x0,    /* read fixed */
@@ -323,6 +323,8 @@ static int tse_eth_rx(struct eth_device *dev)
 
                /* setup the sgdma */
                alt_sgdma_do_async_transfer(priv->sgdma_rx, &rx_desc[0]);
+
+               return packet_length;
        }
 
        return -1;
@@ -583,7 +585,11 @@ static uint mii_m88e1111s_setmode_sr(uint mii_reg, struct altera_tse_priv *priv)
 {
        uint mii_data = tse_mdio_read(priv, mii_reg);
        mii_data &= 0xfff0;
-       mii_data |= 0xb;
+       if ((priv->flags >= 1) && (priv->flags <= 4))
+               mii_data |= 0xb;
+       else if (priv->flags == 5)
+               mii_data |= 0x4;
+
        return mii_data;
 }
 
@@ -591,7 +597,9 @@ static uint mii_m88e1111s_setmode_cr(uint mii_reg, struct altera_tse_priv *priv)
 {
        uint mii_data = tse_mdio_read(priv, mii_reg);
        mii_data &= ~0x82;
-       mii_data |= 0x82;
+       if ((priv->flags >= 1) && (priv->flags <= 4))
+               mii_data |= 0x82;
+
        return mii_data;
 }
 
@@ -826,12 +834,13 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd)
                0x0     /* channel */
                );
        debug("Configuring rx desc\n");
-       flush_dcache((unsigned long)(NetRxPackets[0]), PKTSIZE_ALIGN);
+       flush_dcache_range((unsigned long)(net_rx_packets[0]),
+                          (unsigned long)(net_rx_packets[0]) + PKTSIZE_ALIGN);
        alt_sgdma_construct_descriptor_burst(
                (volatile struct alt_sgdma_descriptor *)&rx_desc[0],
                (volatile struct alt_sgdma_descriptor *)&rx_desc[1],
                (unsigned int)0x0,      /* read addr */
-               (unsigned int *)NetRxPackets[0],
+               (unsigned int *)net_rx_packets[0],
                0x0,    /* length or EOP */
                0x0,    /* gen eop */
                0x0,    /* read fixed */