aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r8169.c
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2008-08-02 14:44:13 -0400
committerFrancois Romieu <romieu@fr.zoreil.com>2008-08-17 09:53:05 -0400
commitdacf815434a4d5f5b45687873df46927c64cfb19 (patch)
tree0e1e0c81996ee06faac8af55f5271c160013ccbb /drivers/net/r8169.c
parentf162a5d1b326d54b0be7e3100f69763d8a707721 (diff)
r8169: add hw start helpers for the 8168 and the 8101
This commit triggers three 'defined but not used' warnings but I prefer avoiding to tie these helpers to a specific change in the hw start sequences of the 8168 or of the 8101. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r--drivers/net/r8169.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 600540e3670f..f4ad9ff26869 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -526,6 +526,11 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
526 return value; 526 return value;
527} 527}
528 528
529static void mdio_patch(void __iomem *ioaddr, int reg_addr, int value)
530{
531 mdio_write(ioaddr, reg_addr, mdio_read(ioaddr, reg_addr) | value);
532}
533
529static void rtl_mdio_write(struct net_device *dev, int phy_id, int location, 534static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
530 int val) 535 int val)
531{ 536{
@@ -543,6 +548,72 @@ static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
543 return mdio_read(ioaddr, location); 548 return mdio_read(ioaddr, location);
544} 549}
545 550
551static void rtl_ephy_write(void __iomem *ioaddr, int reg_addr, int value)
552{
553 unsigned int i;
554
555 RTL_W32(EPHYAR, EPHYAR_WRITE_CMD | (value & EPHYAR_DATA_MASK) |
556 (reg_addr & EPHYAR_REG_MASK) << EPHYAR_REG_SHIFT);
557
558 for (i = 0; i < 100; i++) {
559 if (!(RTL_R32(EPHYAR) & EPHYAR_FLAG))
560 break;
561 udelay(10);
562 }
563}
564
565static u16 rtl_ephy_read(void __iomem *ioaddr, int reg_addr)
566{
567 u16 value = 0xffff;
568 unsigned int i;
569
570 RTL_W32(EPHYAR, (reg_addr & EPHYAR_REG_MASK) << EPHYAR_REG_SHIFT);
571
572 for (i = 0; i < 100; i++) {
573 if (RTL_R32(EPHYAR) & EPHYAR_FLAG) {
574 value = RTL_R32(EPHYAR) & EPHYAR_DATA_MASK;
575 break;
576 }
577 udelay(10);
578 }
579
580 return value;
581}
582
583static void rtl_csi_write(void __iomem *ioaddr, int addr, int value)
584{
585 unsigned int i;
586
587 RTL_W32(CSIDR, value);
588 RTL_W32(CSIAR, CSIAR_WRITE_CMD | (addr & CSIAR_ADDR_MASK) |
589 CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
590
591 for (i = 0; i < 100; i++) {
592 if (!(RTL_R32(CSIAR) & CSIAR_FLAG))
593 break;
594 udelay(10);
595 }
596}
597
598static u32 rtl_csi_read(void __iomem *ioaddr, int addr)
599{
600 u32 value = ~0x00;
601 unsigned int i;
602
603 RTL_W32(CSIAR, (addr & CSIAR_ADDR_MASK) |
604 CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
605
606 for (i = 0; i < 100; i++) {
607 if (RTL_R32(CSIAR) & CSIAR_FLAG) {
608 value = RTL_R32(CSIDR);
609 break;
610 }
611 udelay(10);
612 }
613
614 return value;
615}
616
546static void rtl8169_irq_mask_and_ack(void __iomem *ioaddr) 617static void rtl8169_irq_mask_and_ack(void __iomem *ioaddr)
547{ 618{
548 RTL_W16(IntrMask, 0x0000); 619 RTL_W16(IntrMask, 0x0000);
@@ -2114,6 +2185,31 @@ static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force)
2114 } 2185 }
2115} 2186}
2116 2187
2188static void rtl_csi_access_enable(void __iomem *ioaddr)
2189{
2190 u32 csi;
2191
2192 csi = rtl_csi_read(ioaddr, 0x070c) & 0x00ffffff;
2193 rtl_csi_write(ioaddr, 0x070c, csi | 0x27000000);
2194}
2195
2196struct ephy_info {
2197 unsigned int offset;
2198 u16 mask;
2199 u16 bits;
2200};
2201
2202static void rtl_ephy_init(void __iomem *ioaddr, struct ephy_info *e, int len)
2203{
2204 u16 w;
2205
2206 while (len-- > 0) {
2207 w = (rtl_ephy_read(ioaddr, e->offset) & ~e->mask) | e->bits;
2208 rtl_ephy_write(ioaddr, e->offset, w);
2209 e++;
2210 }
2211}
2212
2117static void rtl_hw_start_8168(struct net_device *dev) 2213static void rtl_hw_start_8168(struct net_device *dev)
2118{ 2214{
2119 struct rtl8169_private *tp = netdev_priv(dev); 2215 struct rtl8169_private *tp = netdev_priv(dev);