]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/ucc_geth.c
forcedeth bug fix: vitesse phy
[linux-2.6-omap-h63xx.git] / drivers / net / ucc_geth.c
index d7aff8189377dacb7d0ee68d15e933fe266eee6c..e4736a3b1b7a4f7cc24bb0916cb33172e67a519d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
+ * Copyright (C) 2006-2007 Freescale Semicondutor, Inc. All rights reserved.
  *
  * Author: Shlomi Gridish <gridish@freescale.com>
  *        Li Yang <leoli@freescale.com>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
-#include <linux/ethtool.h>
-#include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/fsl_devices.h>
-#include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/phy.h>
 #include <linux/workqueue.h>
@@ -293,7 +290,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
                else {
                        init_enet_offset =
                            qe_muram_alloc(thread_size, thread_alignment);
-                       if (IS_MURAM_ERR(init_enet_offset)) {
+                       if (IS_ERR_VALUE(init_enet_offset)) {
                                ugeth_err
                ("fill_init_enet_entries: Can not allocate DPRAM memory.");
                                qe_put_snum((u8) snum);
@@ -2279,7 +2276,7 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
        phy_stop(phydev);
 
        /* Mask all interrupts */
-       out_be32(ugeth->uccf->p_ucce, 0x00000000);
+       out_be32(ugeth->uccf->p_uccm, 0x00000000);
 
        /* Clear all interrupts */
        out_be32(ugeth->uccf->p_ucce, 0xffffffff);
@@ -2594,7 +2591,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                        ugeth->tx_bd_ring_offset[j] =
                            qe_muram_alloc(length,
                                           UCC_GETH_TX_BD_RING_ALIGNMENT);
-                       if (!IS_MURAM_ERR(ugeth->tx_bd_ring_offset[j]))
+                       if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j]))
                                ugeth->p_tx_bd_ring[j] =
                                    (u8 *) qe_muram_addr(ugeth->
                                                         tx_bd_ring_offset[j]);
@@ -2629,7 +2626,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                        ugeth->rx_bd_ring_offset[j] =
                            qe_muram_alloc(length,
                                           UCC_GETH_RX_BD_RING_ALIGNMENT);
-                       if (!IS_MURAM_ERR(ugeth->rx_bd_ring_offset[j]))
+                       if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j]))
                                ugeth->p_rx_bd_ring[j] =
                                    (u8 *) qe_muram_addr(ugeth->
                                                         rx_bd_ring_offset[j]);
@@ -2713,7 +2710,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
        ugeth->tx_glbl_pram_offset =
            qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
                           UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) {
+       if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_tx_glbl_pram.",
                     __FUNCTION__);
@@ -2735,7 +2732,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                           sizeof(struct ucc_geth_thread_data_tx) +
                           32 * (numThreadsTxNumerical == 1),
                           UCC_GETH_THREAD_DATA_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) {
+       if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_thread_data_tx.",
                     __FUNCTION__);
@@ -2763,7 +2760,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
            qe_muram_alloc(ug_info->numQueuesTx *
                           sizeof(struct ucc_geth_send_queue_qd),
                           UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) {
+       if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_send_q_mem_reg.",
                     __FUNCTION__);
@@ -2806,7 +2803,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                ugeth->scheduler_offset =
                    qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
                                   UCC_GETH_SCHEDULER_ALIGNMENT);
-               if (IS_MURAM_ERR(ugeth->scheduler_offset)) {
+               if (IS_ERR_VALUE(ugeth->scheduler_offset)) {
                        ugeth_err
                         ("%s: Can not allocate DPRAM memory for p_scheduler.",
                             __FUNCTION__);
@@ -2854,7 +2851,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                    qe_muram_alloc(sizeof
                                   (struct ucc_geth_tx_firmware_statistics_pram),
                                   UCC_GETH_TX_STATISTICS_ALIGNMENT);
-               if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) {
+               if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) {
                        ugeth_err
                            ("%s: Can not allocate DPRAM memory for"
                                " p_tx_fw_statistics_pram.", __FUNCTION__);
@@ -2893,7 +2890,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
        ugeth->rx_glbl_pram_offset =
            qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
                           UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) {
+       if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_rx_glbl_pram.",
                     __FUNCTION__);
@@ -2914,7 +2911,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
            qe_muram_alloc(numThreadsRxNumerical *
                           sizeof(struct ucc_geth_thread_data_rx),
                           UCC_GETH_THREAD_DATA_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) {
+       if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_thread_data_rx.",
                     __FUNCTION__);
@@ -2937,7 +2934,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                    qe_muram_alloc(sizeof
                                   (struct ucc_geth_rx_firmware_statistics_pram),
                                   UCC_GETH_RX_STATISTICS_ALIGNMENT);
-               if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) {
+               if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) {
                        ugeth_err
                                ("%s: Can not allocate DPRAM memory for"
                                " p_rx_fw_statistics_pram.", __FUNCTION__);
@@ -2959,7 +2956,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
            qe_muram_alloc(ug_info->numQueuesRx *
                           sizeof(struct ucc_geth_rx_interrupt_coalescing_entry)
                           + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) {
+       if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for"
                        " p_rx_irq_coalescing_tbl.", __FUNCTION__);
@@ -3027,7 +3024,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                           (sizeof(struct ucc_geth_rx_bd_queues_entry) +
                            sizeof(struct ucc_geth_rx_prefetched_bds)),
                           UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
-       if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) {
+       if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_rx_bd_qs_tbl.",
                     __FUNCTION__);
@@ -3116,7 +3113,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                ugeth->exf_glbl_param_offset =
                    qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
                UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
-               if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) {
+               if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) {
                        ugeth_err
                                ("%s: Can not allocate DPRAM memory for"
                                " p_exf_glbl_param.", __FUNCTION__);
@@ -3258,7 +3255,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
 
        /* Allocate InitEnet command parameter structure */
        init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
-       if (IS_MURAM_ERR(init_enet_pram_offset)) {
+       if (IS_ERR_VALUE(init_enet_pram_offset)) {
                ugeth_err
                    ("%s: Can not allocate DPRAM memory for p_init_enet_pram.",
                     __FUNCTION__);
@@ -3737,21 +3734,21 @@ static int ucc_geth_close(struct net_device *dev)
 
 const struct ethtool_ops ucc_geth_ethtool_ops = { };
 
-static phy_interface_t to_phy_interface(const char *interface_type)
+static phy_interface_t to_phy_interface(const char *phy_connection_type)
 {
-       if (strcasecmp(interface_type, "mii") == 0)
+       if (strcasecmp(phy_connection_type, "mii") == 0)
                return PHY_INTERFACE_MODE_MII;
-       if (strcasecmp(interface_type, "gmii") == 0)
+       if (strcasecmp(phy_connection_type, "gmii") == 0)
                return PHY_INTERFACE_MODE_GMII;
-       if (strcasecmp(interface_type, "tbi") == 0)
+       if (strcasecmp(phy_connection_type, "tbi") == 0)
                return PHY_INTERFACE_MODE_TBI;
-       if (strcasecmp(interface_type, "rmii") == 0)
+       if (strcasecmp(phy_connection_type, "rmii") == 0)
                return PHY_INTERFACE_MODE_RMII;
-       if (strcasecmp(interface_type, "rgmii") == 0)
+       if (strcasecmp(phy_connection_type, "rgmii") == 0)
                return PHY_INTERFACE_MODE_RGMII;
-       if (strcasecmp(interface_type, "rgmii-id") == 0)
+       if (strcasecmp(phy_connection_type, "rgmii-id") == 0)
                return PHY_INTERFACE_MODE_RGMII_ID;
-       if (strcasecmp(interface_type, "rtbi") == 0)
+       if (strcasecmp(phy_connection_type, "rtbi") == 0)
                return PHY_INTERFACE_MODE_RTBI;
 
        return PHY_INTERFACE_MODE_MII;
@@ -3819,29 +3816,21 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
        ug_info->phy_address = *prop;
 
        /* get the phy interface type, or default to MII */
-       prop = of_get_property(np, "interface-type", NULL);
+       prop = of_get_property(np, "phy-connection-type", NULL);
        if (!prop) {
                /* handle interface property present in old trees */
                prop = of_get_property(phy, "interface", NULL);
-               if (prop != NULL)
+               if (prop != NULL) {
                        phy_interface = enet_to_phy_interface[*prop];
-               else
+                       max_speed = enet_to_speed[*prop];
+               } else
                        phy_interface = PHY_INTERFACE_MODE_MII;
        } else {
                phy_interface = to_phy_interface((const char *)prop);
        }
 
-       /* get speed, or derive from interface */
-       prop = of_get_property(np, "max-speed", NULL);
-       if (!prop) {
-               /* handle interface property present in old trees */
-               prop = of_get_property(phy, "interface", NULL);
-               if (prop != NULL)
-                       max_speed = enet_to_speed[*prop];
-       } else {
-               max_speed = *prop;
-       }
-       if (!max_speed) {
+       /* get speed, or derive from PHY interface */
+       if (max_speed == 0)
                switch (phy_interface) {
                case PHY_INTERFACE_MODE_GMII:
                case PHY_INTERFACE_MODE_RGMII:
@@ -3854,9 +3843,9 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
                        max_speed = SPEED_100;
                        break;
                }
-       }
 
        if (max_speed == SPEED_1000) {
+               /* configure muram FIFOs for gigabit operation */
                ug_info->uf_info.urfs = UCC_GETH_URFS_GIGA_INIT;
                ug_info->uf_info.urfet = UCC_GETH_URFET_GIGA_INIT;
                ug_info->uf_info.urfset = UCC_GETH_URFSET_GIGA_INIT;