aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qlcnic/qlcnic_hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/qlcnic/qlcnic_hw.c')
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index b977874f28ce..419f46efa5df 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -963,7 +963,6 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter,
963{ 963{
964 int i, j, ret; 964 int i, j, ret;
965 u32 temp, off8; 965 u32 temp, off8;
966 u64 stride;
967 void __iomem *mem_crb; 966 void __iomem *mem_crb;
968 967
969 /* Only 64-bit aligned access */ 968 /* Only 64-bit aligned access */
@@ -972,7 +971,7 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter,
972 971
973 /* P3 onward, test agent base for MIU and SIU is same */ 972 /* P3 onward, test agent base for MIU and SIU is same */
974 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET, 973 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET,
975 QLCNIC_ADDR_QDR_NET_MAX_P3)) { 974 QLCNIC_ADDR_QDR_NET_MAX)) {
976 mem_crb = qlcnic_get_ioaddr(adapter, 975 mem_crb = qlcnic_get_ioaddr(adapter,
977 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE); 976 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE);
978 goto correct; 977 goto correct;
@@ -990,9 +989,7 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter,
990 return -EIO; 989 return -EIO;
991 990
992correct: 991correct:
993 stride = QLCNIC_IS_REVISION_P3P(adapter->ahw.revision_id) ? 16 : 8; 992 off8 = off & ~0xf;
994
995 off8 = off & ~(stride-1);
996 993
997 mutex_lock(&adapter->ahw.mem_lock); 994 mutex_lock(&adapter->ahw.mem_lock);
998 995
@@ -1000,30 +997,28 @@ correct:
1000 writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); 997 writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI));
1001 998
1002 i = 0; 999 i = 0;
1003 if (stride == 16) { 1000 writel(TA_CTL_ENABLE, (mem_crb + TEST_AGT_CTRL));
1004 writel(TA_CTL_ENABLE, (mem_crb + TEST_AGT_CTRL)); 1001 writel((TA_CTL_START | TA_CTL_ENABLE),
1005 writel((TA_CTL_START | TA_CTL_ENABLE), 1002 (mem_crb + TEST_AGT_CTRL));
1006 (mem_crb + TEST_AGT_CTRL));
1007
1008 for (j = 0; j < MAX_CTL_CHECK; j++) {
1009 temp = readl(mem_crb + TEST_AGT_CTRL);
1010 if ((temp & TA_CTL_BUSY) == 0)
1011 break;
1012 }
1013 1003
1014 if (j >= MAX_CTL_CHECK) { 1004 for (j = 0; j < MAX_CTL_CHECK; j++) {
1015 ret = -EIO; 1005 temp = readl(mem_crb + TEST_AGT_CTRL);
1016 goto done; 1006 if ((temp & TA_CTL_BUSY) == 0)
1017 } 1007 break;
1008 }
1018 1009
1019 i = (off & 0xf) ? 0 : 2; 1010 if (j >= MAX_CTL_CHECK) {
1020 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i)), 1011 ret = -EIO;
1021 mem_crb + MIU_TEST_AGT_WRDATA(i)); 1012 goto done;
1022 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i+1)),
1023 mem_crb + MIU_TEST_AGT_WRDATA(i+1));
1024 i = (off & 0xf) ? 2 : 0;
1025 } 1013 }
1026 1014
1015 i = (off & 0xf) ? 0 : 2;
1016 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i)),
1017 mem_crb + MIU_TEST_AGT_WRDATA(i));
1018 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i+1)),
1019 mem_crb + MIU_TEST_AGT_WRDATA(i+1));
1020 i = (off & 0xf) ? 2 : 0;
1021
1027 writel(data & 0xffffffff, 1022 writel(data & 0xffffffff,
1028 mem_crb + MIU_TEST_AGT_WRDATA(i)); 1023 mem_crb + MIU_TEST_AGT_WRDATA(i));
1029 writel((data >> 32) & 0xffffffff, 1024 writel((data >> 32) & 0xffffffff,
@@ -1059,7 +1054,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter,
1059{ 1054{
1060 int j, ret; 1055 int j, ret;
1061 u32 temp, off8; 1056 u32 temp, off8;
1062 u64 val, stride; 1057 u64 val;
1063 void __iomem *mem_crb; 1058 void __iomem *mem_crb;
1064 1059
1065 /* Only 64-bit aligned access */ 1060 /* Only 64-bit aligned access */
@@ -1068,7 +1063,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter,
1068 1063
1069 /* P3 onward, test agent base for MIU and SIU is same */ 1064 /* P3 onward, test agent base for MIU and SIU is same */
1070 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET, 1065 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET,
1071 QLCNIC_ADDR_QDR_NET_MAX_P3)) { 1066 QLCNIC_ADDR_QDR_NET_MAX)) {
1072 mem_crb = qlcnic_get_ioaddr(adapter, 1067 mem_crb = qlcnic_get_ioaddr(adapter,
1073 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE); 1068 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE);
1074 goto correct; 1069 goto correct;
@@ -1088,9 +1083,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter,
1088 return -EIO; 1083 return -EIO;
1089 1084
1090correct: 1085correct:
1091 stride = QLCNIC_IS_REVISION_P3P(adapter->ahw.revision_id) ? 16 : 8; 1086 off8 = off & ~0xf;
1092
1093 off8 = off & ~(stride-1);
1094 1087
1095 mutex_lock(&adapter->ahw.mem_lock); 1088 mutex_lock(&adapter->ahw.mem_lock);
1096 1089
@@ -1112,7 +1105,7 @@ correct:
1112 ret = -EIO; 1105 ret = -EIO;
1113 } else { 1106 } else {
1114 off8 = MIU_TEST_AGT_RDDATA_LO; 1107 off8 = MIU_TEST_AGT_RDDATA_LO;
1115 if ((stride == 16) && (off & 0xf)) 1108 if (off & 0xf)
1116 off8 = MIU_TEST_AGT_RDDATA_UPPER_LO; 1109 off8 = MIU_TEST_AGT_RDDATA_UPPER_LO;
1117 1110
1118 temp = readl(mem_crb + off8 + 4); 1111 temp = readl(mem_crb + off8 + 4);