Pull ec into release branch
[pandora-kernel.git] / drivers / net / ucc_geth.c
index 7e4b23c..639e1e6 100644 (file)
@@ -1709,75 +1709,13 @@ static void adjust_link(struct net_device *dev)
                if (mii_info->speed != ugeth->oldspeed) {
                        switch (mii_info->speed) {
                        case 1000:
-#ifdef CONFIG_PPC_MPC836x
-/* FIXME: This code is for 100Mbs BUG fixing,
-remove this when it is fixed!!! */
-                               if (ugeth->ug_info->enet_interface ==
-                                   ENET_1000_GMII)
-                               /* Run the commands which initialize the PHY */
-                               {
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id, 0x1b);
-                                       tempval |= 0x000f;
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, 0x1b,
-                                               (u16) tempval);
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id,
-                                               MII_BMCR);
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, MII_BMCR,
-                                               (u16) (tempval | BMCR_RESET));
-                               } else if (ugeth->ug_info->enet_interface ==
-                                          ENET_1000_RGMII)
-                               /* Run the commands which initialize the PHY */
-                               {
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id, 0x1b);
-                                       tempval = (tempval & ~0x000f) | 0x000b;
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, 0x1b,
-                                               (u16) tempval);
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id,
-                                               MII_BMCR);
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, MII_BMCR,
-                                               (u16) (tempval | BMCR_RESET));
-                               }
-                               msleep(4000);
-#endif                         /* CONFIG_MPC8360 */
-                               adjust_enet_interface(ugeth);
+                               ugeth->ug_info->enet_interface = ENET_1000_RGMII;
                                break;
                        case 100:
-                       case 10:
-#ifdef CONFIG_PPC_MPC836x
-/* FIXME: This code is for 100Mbs BUG fixing,
-remove this lines when it will be fixed!!! */
                                ugeth->ug_info->enet_interface = ENET_100_RGMII;
-                               tempval =
-                                   (u32) mii_info->mdio_read(ugeth->dev,
-                                                             mii_info->mii_id,
-                                                             0x1b);
-                               tempval = (tempval & ~0x000f) | 0x000b;
-                               mii_info->mdio_write(ugeth->dev,
-                                                    mii_info->mii_id, 0x1b,
-                                                    (u16) tempval);
-                               tempval =
-                                   (u32) mii_info->mdio_read(ugeth->dev,
-                                                             mii_info->mii_id,
-                                                             MII_BMCR);
-                               mii_info->mdio_write(ugeth->dev,
-                                                    mii_info->mii_id, MII_BMCR,
-                                                    (u16) (tempval |
-                                                           BMCR_RESET));
-                               msleep(4000);
-#endif                         /* CONFIG_MPC8360 */
-                               adjust_enet_interface(ugeth);
+                               break;
+                       case 10:
+                               ugeth->ug_info->enet_interface = ENET_10_RGMII;
                                break;
                        default:
                                ugeth_warn
@@ -1785,6 +1723,7 @@ remove this lines when it will be fixed!!! */
                                     dev->name, mii_info->speed);
                                break;
                        }
+                       adjust_enet_interface(ugeth);
 
                        ugeth_info("%s: Speed %dBT", dev->name,
                                   mii_info->speed);
@@ -2865,8 +2804,8 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                        if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4)
                                align = UCC_GETH_TX_BD_RING_ALIGNMENT;
                        ugeth->tx_bd_ring_offset[j] =
-                               (u32) (kmalloc((u32) (length + align),
-                               GFP_KERNEL));
+                               kmalloc((u32) (length + align), GFP_KERNEL);
+
                        if (ugeth->tx_bd_ring_offset[j] != 0)
                                ugeth->p_tx_bd_ring[j] =
                                        (void*)((ugeth->tx_bd_ring_offset[j] +
@@ -2901,7 +2840,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                        if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
                                align = UCC_GETH_RX_BD_RING_ALIGNMENT;
                        ugeth->rx_bd_ring_offset[j] =
-                           (u32) (kmalloc((u32) (length + align), GFP_KERNEL));
+                               kmalloc((u32) (length + align), GFP_KERNEL);
                        if (ugeth->rx_bd_ring_offset[j] != 0)
                                ugeth->p_rx_bd_ring[j] =
                                        (void*)((ugeth->rx_bd_ring_offset[j] +
@@ -2927,10 +2866,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
        /* Init Tx bds */
        for (j = 0; j < ug_info->numQueuesTx; j++) {
                /* Setup the skbuff rings */
-               ugeth->tx_skbuff[j] =
-                   (struct sk_buff **)kmalloc(sizeof(struct sk_buff *) *
-                                              ugeth->ug_info->bdRingLenTx[j],
-                                              GFP_KERNEL);
+               ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
+                                             ugeth->ug_info->bdRingLenTx[j],
+                                             GFP_KERNEL);
 
                if (ugeth->tx_skbuff[j] == NULL) {
                        ugeth_err("%s: Could not allocate tx_skbuff",
@@ -2959,10 +2897,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
        /* Init Rx bds */
        for (j = 0; j < ug_info->numQueuesRx; j++) {
                /* Setup the skbuff rings */
-               ugeth->rx_skbuff[j] =
-                   (struct sk_buff **)kmalloc(sizeof(struct sk_buff *) *
-                                              ugeth->ug_info->bdRingLenRx[j],
-                                              GFP_KERNEL);
+               ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
+                                             ugeth->ug_info->bdRingLenRx[j],
+                                             GFP_KERNEL);
 
                if (ugeth->rx_skbuff[j] == NULL) {
                        ugeth_err("%s: Could not allocate rx_skbuff",
@@ -3453,8 +3390,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
         * allocated resources can be released when the channel is freed.
         */
        if (!(ugeth->p_init_enet_param_shadow =
-            (struct ucc_geth_init_pram *) kmalloc(sizeof(struct ucc_geth_init_pram),
-                                             GFP_KERNEL))) {
+             kmalloc(sizeof(struct ucc_geth_init_pram), GFP_KERNEL))) {
                ugeth_err
                    ("%s: Can not allocate memory for"
                        " p_UccInitEnetParamShadows.", __FUNCTION__);
@@ -3662,9 +3598,9 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        /* Move to next BD in the ring */
        if (!(bd_status & T_W))
-               ugeth->txBd[txQ] = bd + sizeof(struct qe_bd);
+               bd += sizeof(struct qe_bd);
        else
-               ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ];
+               bd = ugeth->p_tx_bd_ring[txQ];
 
        /* If the next BD still needs to be cleaned up, then the bds
           are full.  We need to tell the kernel to stop sending us stuff. */
@@ -3673,6 +3609,8 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        netif_stop_queue(dev);
        }
 
+       ugeth->txBd[txQ] = bd;
+
        if (ugeth->p_scheduler) {
                ugeth->cpucount[txQ]++;
                /* Indicate to QE that there are more Tx bds ready for
@@ -3786,7 +3724,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
                /* Handle the transmitted buffer and release */
                /* the BD to be used with the current frame  */
 
-               if ((bd = ugeth->txBd[txQ]) && (netif_queue_stopped(dev) == 0))
+               if ((bd == ugeth->txBd[txQ]) && (netif_queue_stopped(dev) == 0))
                        break;
 
                ugeth->stats.tx_packets++;
@@ -3805,10 +3743,12 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
 
                /* Advance the confirmation BD pointer */
                if (!(bd_status & T_W))
-                       ugeth->confBd[txQ] += sizeof(struct qe_bd);
+                       bd += sizeof(struct qe_bd);
                else
-                       ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ];
+                       bd = ugeth->p_tx_bd_ring[txQ];
+               bd_status = in_be32((u32 *)bd);
        }
+       ugeth->confBd[txQ] = bd;
        return 0;
 }
 
@@ -4003,8 +3943,8 @@ static void ugeth_phy_startup_timer(unsigned long data)
        /* Grab the PHY interrupt, if necessary/possible */
        if (ugeth->ug_info->board_flags & FSL_UGETH_BRD_HAS_PHY_INTR) {
                if (request_irq(ugeth->ug_info->phy_interrupt,
-                               phy_interrupt,
-                               SA_SHIRQ, "phy_interrupt", mii_info->dev) < 0) {
+                               phy_interrupt, IRQF_SHARED,
+                               "phy_interrupt", mii_info->dev) < 0) {
                        ugeth_err("%s: Can't get IRQ %d (PHY)",
                                  mii_info->dev->name,
                                  ugeth->ug_info->phy_interrupt);
@@ -4136,6 +4076,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
        static int mii_mng_configured = 0;
        const phandle *ph;
        const unsigned int *prop;
+       const void *mac_addr;
 
        ugeth_vdbg("%s: IN", __FUNCTION__);
 
@@ -4261,7 +4202,10 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 
        ugeth->ug_info = ug_info;
        ugeth->dev = dev;
-       memcpy(dev->dev_addr, get_property(np, "mac-address", NULL), 6);
+
+       mac_addr = of_get_mac_address(np);
+       if (mac_addr)
+               memcpy(dev->dev_addr, mac_addr, 6);
 
        return 0;
 }