aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2005-08-09 23:16:32 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:50:12 -0400
commit2009493065e01b1fe27c1b98ffbcfab98e185f72 (patch)
tree8a8981461a4f84a007f4725a027f3185055737ea /drivers/net/tg3.c
parent757f612e091e7d13707eedc3ff71f1a9b53f5537 (diff)
[TG3]: Add basic register access function pointers
This patch adds the basic function pointers to do register accesses in the fast path. This was suggested by David Miller. The idea is that various register access methods for different hardware errata can easily be implemented with these function pointers and performance will not be degraded on chips that use normal register access methods. The various register read write macros (e.g. tw32, tr32, tw32_mailbox) are redefined to call the function pointers. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6d4ab1e333b5..13283c29f802 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -366,7 +366,7 @@ static void _tw32_flush(struct tg3 *tp, u32 off, u32 val)
366 } 366 }
367} 367}
368 368
369static inline void _tw32_rx_mbox(struct tg3 *tp, u32 off, u32 val) 369static void tg3_write32_rx_mbox(struct tg3 *tp, u32 off, u32 val)
370{ 370{
371 void __iomem *mbox = tp->regs + off; 371 void __iomem *mbox = tp->regs + off;
372 writel(val, mbox); 372 writel(val, mbox);
@@ -374,7 +374,7 @@ static inline void _tw32_rx_mbox(struct tg3 *tp, u32 off, u32 val)
374 readl(mbox); 374 readl(mbox);
375} 375}
376 376
377static inline void _tw32_tx_mbox(struct tg3 *tp, u32 off, u32 val) 377static void tg3_write32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
378{ 378{
379 void __iomem *mbox = tp->regs + off; 379 void __iomem *mbox = tp->regs + off;
380 writel(val, mbox); 380 writel(val, mbox);
@@ -384,17 +384,23 @@ static inline void _tw32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
384 readl(mbox); 384 readl(mbox);
385} 385}
386 386
387#define tw32_mailbox(reg, val) writel(((val) & 0xffffffff), tp->regs + (reg)) 387static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
388#define tw32_rx_mbox(reg, val) _tw32_rx_mbox(tp, reg, val) 388{
389#define tw32_tx_mbox(reg, val) _tw32_tx_mbox(tp, reg, val) 389 writel(val, tp->regs + off);
390}
390 391
391#define tw32(reg,val) tg3_write_indirect_reg32(tp,(reg),(val)) 392static u32 tg3_read32(struct tg3 *tp, u32 off)
393{
394 return (readl(tp->regs + off));
395}
396
397#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
398#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
399#define tw32_tx_mbox(reg, val) tp->write32_tx_mbox(tp, reg, val)
400
401#define tw32(reg,val) tp->write32(tp, reg, val)
392#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val)) 402#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val))
393#define tw16(reg,val) writew(((val) & 0xffff), tp->regs + (reg)) 403#define tr32(reg) tp->read32(tp, reg)
394#define tw8(reg,val) writeb(((val) & 0xff), tp->regs + (reg))
395#define tr32(reg) readl(tp->regs + (reg))
396#define tr16(reg) readw(tp->regs + (reg))
397#define tr8(reg) readb(tp->regs + (reg))
398 404
399static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 405static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
400{ 406{
@@ -9325,6 +9331,12 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9325 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg); 9331 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg);
9326 } 9332 }
9327 9333
9334 tp->read32 = tg3_read32;
9335 tp->write32 = tg3_write_indirect_reg32;
9336 tp->write32_mbox = tg3_write32;
9337 tp->write32_tx_mbox = tg3_write32_tx_mbox;
9338 tp->write32_rx_mbox = tg3_write32_rx_mbox;
9339
9328 /* Get eeprom hw config before calling tg3_set_power_state(). 9340 /* Get eeprom hw config before calling tg3_set_power_state().
9329 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be 9341 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be
9330 * determined before calling tg3_set_power_state() so that 9342 * determined before calling tg3_set_power_state() so that