aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@huawei.com>2012-08-20 15:28:20 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-08-23 12:11:13 -0400
commit0f49bfbd0f2ee6d57398ba5fcf39de6b566c43bb (patch)
tree8a7f907c8c4bcbd0514020f3418f3a8a207aec03 /drivers
parent2a80eebcbf3e0f2cc7df6aced54058fbdff37518 (diff)
tg3: Use PCI Express Capability accessors
Use PCI Express Capability access functions to simplify tg3 driver. [bhelgaas: split bnx2x and tg3 into separate patches] Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c50
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index bf906c51d82a..8325fd8d4e5b 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -3653,17 +3653,9 @@ static int tg3_power_down_prepare(struct tg3 *tp)
3653 tg3_enable_register_access(tp); 3653 tg3_enable_register_access(tp);
3654 3654
3655 /* Restore the CLKREQ setting. */ 3655 /* Restore the CLKREQ setting. */
3656 if (tg3_flag(tp, CLKREQ_BUG)) { 3656 if (tg3_flag(tp, CLKREQ_BUG))
3657 u16 lnkctl; 3657 pcie_capability_set_word(tp->pdev, PCI_EXP_LNKCTL,
3658 3658 PCI_EXP_LNKCTL_CLKREQ_EN);
3659 pci_read_config_word(tp->pdev,
3660 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
3661 &lnkctl);
3662 lnkctl |= PCI_EXP_LNKCTL_CLKREQ_EN;
3663 pci_write_config_word(tp->pdev,
3664 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
3665 lnkctl);
3666 }
3667 3659
3668 misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL); 3660 misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL);
3669 tw32(TG3PCI_MISC_HOST_CTRL, 3661 tw32(TG3PCI_MISC_HOST_CTRL,
@@ -4434,20 +4426,13 @@ relink:
4434 4426
4435 /* Prevent send BD corruption. */ 4427 /* Prevent send BD corruption. */
4436 if (tg3_flag(tp, CLKREQ_BUG)) { 4428 if (tg3_flag(tp, CLKREQ_BUG)) {
4437 u16 oldlnkctl, newlnkctl;
4438
4439 pci_read_config_word(tp->pdev,
4440 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
4441 &oldlnkctl);
4442 if (tp->link_config.active_speed == SPEED_100 || 4429 if (tp->link_config.active_speed == SPEED_100 ||
4443 tp->link_config.active_speed == SPEED_10) 4430 tp->link_config.active_speed == SPEED_10)
4444 newlnkctl = oldlnkctl & ~PCI_EXP_LNKCTL_CLKREQ_EN; 4431 pcie_capability_clear_word(tp->pdev, PCI_EXP_LNKCTL,
4432 PCI_EXP_LNKCTL_CLKREQ_EN);
4445 else 4433 else
4446 newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN; 4434 pcie_capability_set_word(tp->pdev, PCI_EXP_LNKCTL,
4447 if (newlnkctl != oldlnkctl) 4435 PCI_EXP_LNKCTL_CLKREQ_EN);
4448 pci_write_config_word(tp->pdev,
4449 pci_pcie_cap(tp->pdev) +
4450 PCI_EXP_LNKCTL, newlnkctl);
4451 } 4436 }
4452 4437
4453 if (current_link_up != netif_carrier_ok(tp->dev)) { 4438 if (current_link_up != netif_carrier_ok(tp->dev)) {
@@ -8054,7 +8039,7 @@ static int tg3_chip_reset(struct tg3 *tp)
8054 8039
8055 udelay(120); 8040 udelay(120);
8056 8041
8057 if (tg3_flag(tp, PCI_EXPRESS) && pci_pcie_cap(tp->pdev)) { 8042 if (tg3_flag(tp, PCI_EXPRESS) && pci_is_pcie(tp->pdev)) {
8058 u16 val16; 8043 u16 val16;
8059 8044
8060 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) { 8045 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) {
@@ -8071,24 +8056,17 @@ static int tg3_chip_reset(struct tg3 *tp)
8071 } 8056 }
8072 8057
8073 /* Clear the "no snoop" and "relaxed ordering" bits. */ 8058 /* Clear the "no snoop" and "relaxed ordering" bits. */
8074 pci_read_config_word(tp->pdev, 8059 val16 = PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;
8075 pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL,
8076 &val16);
8077 val16 &= ~(PCI_EXP_DEVCTL_RELAX_EN |
8078 PCI_EXP_DEVCTL_NOSNOOP_EN);
8079 /* 8060 /*
8080 * Older PCIe devices only support the 128 byte 8061 * Older PCIe devices only support the 128 byte
8081 * MPS setting. Enforce the restriction. 8062 * MPS setting. Enforce the restriction.
8082 */ 8063 */
8083 if (!tg3_flag(tp, CPMU_PRESENT)) 8064 if (!tg3_flag(tp, CPMU_PRESENT))
8084 val16 &= ~PCI_EXP_DEVCTL_PAYLOAD; 8065 val16 |= PCI_EXP_DEVCTL_PAYLOAD;
8085 pci_write_config_word(tp->pdev, 8066 pcie_capability_clear_word(tp->pdev, PCI_EXP_DEVCTL, val16);
8086 pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL,
8087 val16);
8088 8067
8089 /* Clear error status */ 8068 /* Clear error status */
8090 pci_write_config_word(tp->pdev, 8069 pcie_capability_write_word(tp->pdev, PCI_EXP_DEVSTA,
8091 pci_pcie_cap(tp->pdev) + PCI_EXP_DEVSTA,
8092 PCI_EXP_DEVSTA_CED | 8070 PCI_EXP_DEVSTA_CED |
8093 PCI_EXP_DEVSTA_NFED | 8071 PCI_EXP_DEVSTA_NFED |
8094 PCI_EXP_DEVSTA_FED | 8072 PCI_EXP_DEVSTA_FED |
@@ -14565,9 +14543,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
14565 14543
14566 tg3_flag_set(tp, PCI_EXPRESS); 14544 tg3_flag_set(tp, PCI_EXPRESS);
14567 14545
14568 pci_read_config_word(tp->pdev, 14546 pcie_capability_read_word(tp->pdev, PCI_EXP_LNKCTL, &lnkctl);
14569 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
14570 &lnkctl);
14571 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) { 14547 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) {
14572 if (GET_ASIC_REV(tp->pci_chip_rev_id) == 14548 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
14573 ASIC_REV_5906) { 14549 ASIC_REV_5906) {