]> err.no Git - linux-2.6/blobdiff - drivers/net/mv643xx_eth.c
V4L/DVB (7849): cx88: fix Kconfig depencencies for FW_LOADER
[linux-2.6] / drivers / net / mv643xx_eth.c
index aabf1c60946d0dd8fe2c6c1ee8aacd43c65e42db..b7915cdcc6a504efc2ee422f3e29a77d37d72532 100644 (file)
@@ -519,12 +519,16 @@ struct mv643xx_shared_private {
        spinlock_t phy_lock;
 
        u32 win_protect;
+
+       unsigned int t_clk;
 };
 
 struct mv643xx_private {
        struct mv643xx_shared_private *shared;
        int port_num;                   /* User Ethernet port number    */
 
+       struct mv643xx_shared_private *shared_smi;
+
        u32 rx_sram_addr;               /* Base address of rx sram area */
        u32 rx_sram_size;               /* Size of rx sram area         */
        u32 tx_sram_addr;               /* Base address of tx sram area */
@@ -1129,7 +1133,6 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
  *
  * INPUT:
  *     struct mv643xx_private *mp      Ethernet port
- *     unsigned int t_clk              t_clk of the MV-643xx chip in HZ units
  *     unsigned int delay              Delay in usec
  *
  * OUTPUT:
@@ -1140,10 +1143,10 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
  *
  */
 static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
-                                       unsigned int t_clk, unsigned int delay)
+                                       unsigned int delay)
 {
        unsigned int port_num = mp->port_num;
-       unsigned int coal = ((t_clk / 1000000) * delay) / 64;
+       unsigned int coal = ((mp->shared->t_clk / 1000000) * delay) / 64;
 
        /* Set RX Coalescing mechanism */
        wrl(mp, SDMA_CONFIG_REG(port_num),
@@ -1168,7 +1171,6 @@ static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
  *
  * INPUT:
  *     struct mv643xx_private *mp      Ethernet port
- *     unsigned int t_clk              t_clk of the MV-643xx chip in HZ units
  *     unsigned int delay              Delay in uSeconds
  *
  * OUTPUT:
@@ -1179,9 +1181,9 @@ static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
  *
  */
 static unsigned int eth_port_set_tx_coal(struct mv643xx_private *mp,
-                                       unsigned int t_clk, unsigned int delay)
+                                       unsigned int delay)
 {
-       unsigned int coal = ((t_clk / 1000000) * delay) / 64;
+       unsigned int coal = ((mp->shared->t_clk / 1000000) * delay) / 64;
 
        /* Set TX Coalescing mechanism */
        wrl(mp, TX_FIFO_URGENT_THRESHOLD_REG(mp->port_num), coal << 4);
@@ -1423,11 +1425,11 @@ static int mv643xx_eth_open(struct net_device *dev)
 
 #ifdef MV643XX_COAL
        mp->rx_int_coal =
-               eth_port_set_rx_coal(mp, 133000000, MV643XX_RX_COAL);
+               eth_port_set_rx_coal(mp, MV643XX_RX_COAL);
 #endif
 
        mp->tx_int_coal =
-               eth_port_set_tx_coal(mp, 133000000, MV643XX_TX_COAL);
+               eth_port_set_tx_coal(mp, MV643XX_TX_COAL);
 
        /* Unmask phy and link status changes interrupts */
        wrl(mp, INTERRUPT_EXTEND_MASK_REG(port_num), ETH_INT_UNMASK_ALL_EXT);
@@ -1898,6 +1900,10 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
        if (mp->shared->win_protect)
                wrl(mp, WINDOW_PROTECT(port_num), mp->shared->win_protect);
 
+       mp->shared_smi = mp->shared;
+       if (pd->shared_smi != NULL)
+               mp->shared_smi = platform_get_drvdata(pd->shared_smi);
+
        /* set default config values */
        eth_port_uc_addr_get(mp, dev->dev_addr);
        mp->rx_ring_size = PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
@@ -2063,6 +2069,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
                goto out_free;
 
        spin_lock_init(&msp->phy_lock);
+       msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
 
        platform_set_drvdata(pdev, msp);
 
@@ -2985,15 +2992,16 @@ static void eth_port_reset(struct mv643xx_private *mp)
 static void eth_port_read_smi_reg(struct mv643xx_private *mp,
                                unsigned int phy_reg, unsigned int *value)
 {
+       void __iomem *smi_reg = mp->shared_smi->eth_base + SMI_REG;
        int phy_addr = ethernet_phy_get(mp);
        unsigned long flags;
        int i;
 
        /* the SMI register is a shared resource */
-       spin_lock_irqsave(&mp->shared->phy_lock, flags);
+       spin_lock_irqsave(&mp->shared_smi->phy_lock, flags);
 
        /* wait for the SMI register to become available */
-       for (i = 0; rdl(mp, SMI_REG) & ETH_SMI_BUSY; i++) {
+       for (i = 0; readl(smi_reg) & ETH_SMI_BUSY; i++) {
                if (i == PHY_WAIT_ITERATIONS) {
                        printk("%s: PHY busy timeout\n", mp->dev->name);
                        goto out;
@@ -3001,11 +3009,11 @@ static void eth_port_read_smi_reg(struct mv643xx_private *mp,
                udelay(PHY_WAIT_MICRO_SECONDS);
        }
 
-       wrl(mp, SMI_REG,
-               (phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ);
+       writel((phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ,
+               smi_reg);
 
        /* now wait for the data to be valid */
-       for (i = 0; !(rdl(mp, SMI_REG) & ETH_SMI_READ_VALID); i++) {
+       for (i = 0; !(readl(smi_reg) & ETH_SMI_READ_VALID); i++) {
                if (i == PHY_WAIT_ITERATIONS) {
                        printk("%s: PHY read timeout\n", mp->dev->name);
                        goto out;
@@ -3013,9 +3021,9 @@ static void eth_port_read_smi_reg(struct mv643xx_private *mp,
                udelay(PHY_WAIT_MICRO_SECONDS);
        }
 
-       *value = rdl(mp, SMI_REG) & 0xffff;
+       *value = readl(smi_reg) & 0xffff;
 out:
-       spin_unlock_irqrestore(&mp->shared->phy_lock, flags);
+       spin_unlock_irqrestore(&mp->shared_smi->phy_lock, flags);
 }
 
 /*
@@ -3041,17 +3049,16 @@ out:
 static void eth_port_write_smi_reg(struct mv643xx_private *mp,
                                   unsigned int phy_reg, unsigned int value)
 {
-       int phy_addr;
-       int i;
+       void __iomem *smi_reg = mp->shared_smi->eth_base + SMI_REG;
+       int phy_addr = ethernet_phy_get(mp);
        unsigned long flags;
-
-       phy_addr = ethernet_phy_get(mp);
+       int i;
 
        /* the SMI register is a shared resource */
-       spin_lock_irqsave(&mp->shared->phy_lock, flags);
+       spin_lock_irqsave(&mp->shared_smi->phy_lock, flags);
 
        /* wait for the SMI register to become available */
-       for (i = 0; rdl(mp, SMI_REG) & ETH_SMI_BUSY; i++) {
+       for (i = 0; readl(smi_reg) & ETH_SMI_BUSY; i++) {
                if (i == PHY_WAIT_ITERATIONS) {
                        printk("%s: PHY busy timeout\n", mp->dev->name);
                        goto out;
@@ -3059,10 +3066,10 @@ static void eth_port_write_smi_reg(struct mv643xx_private *mp,
                udelay(PHY_WAIT_MICRO_SECONDS);
        }
 
-       wrl(mp, SMI_REG, (phy_addr << 16) | (phy_reg << 21) |
-                               ETH_SMI_OPCODE_WRITE | (value & 0xffff));
+       writel((phy_addr << 16) | (phy_reg << 21) |
+               ETH_SMI_OPCODE_WRITE | (value & 0xffff), smi_reg);
 out:
-       spin_unlock_irqrestore(&mp->shared->phy_lock, flags);
+       spin_unlock_irqrestore(&mp->shared_smi->phy_lock, flags);
 }
 
 /*