aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-04-07 18:50:44 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-08 18:58:28 -0400
commit1fbe63235893e5dce28fe91d8465dd231b0cb3d9 (patch)
tree52d88817b8e23c2784c0e2a33a538f4eab2fcb8f
parent71dcddbdd35487eb931aa8aab28a2df474008754 (diff)
netxen: annotate register access functions
o remove unnecessary length parameter since register access width is fixed 4 byte. o remove superfluous pci_read_normalize and pci_write_normalize functions. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/netxen/netxen_nic.h75
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c18
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c45
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c229
-rw-r--r--drivers/net/netxen/netxen_nic_init.c40
-rw-r--r--drivers/net/netxen/netxen_nic_main.c66
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c110
7 files changed, 239 insertions, 344 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index e0f329ff3691..1e4190dd0c16 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1258,14 +1258,12 @@ struct netxen_adapter {
1258 int (*init_port) (struct netxen_adapter *, int); 1258 int (*init_port) (struct netxen_adapter *, int);
1259 int (*stop_port) (struct netxen_adapter *); 1259 int (*stop_port) (struct netxen_adapter *);
1260 1260
1261 int (*hw_read_wx)(struct netxen_adapter *, ulong, void *, int); 1261 u32 (*hw_read_wx)(struct netxen_adapter *, ulong);
1262 int (*hw_write_wx)(struct netxen_adapter *, ulong, void *, int); 1262 int (*hw_write_wx)(struct netxen_adapter *, ulong, u32);
1263 int (*pci_mem_read)(struct netxen_adapter *, u64, void *, int); 1263 int (*pci_mem_read)(struct netxen_adapter *, u64, void *, int);
1264 int (*pci_mem_write)(struct netxen_adapter *, u64, void *, int); 1264 int (*pci_mem_write)(struct netxen_adapter *, u64, void *, int);
1265 int (*pci_write_immediate)(struct netxen_adapter *, u64, u32); 1265 int (*pci_write_immediate)(struct netxen_adapter *, u64, u32);
1266 u32 (*pci_read_immediate)(struct netxen_adapter *, u64); 1266 u32 (*pci_read_immediate)(struct netxen_adapter *, u64);
1267 void (*pci_write_normalize)(struct netxen_adapter *, u64, u32);
1268 u32 (*pci_read_normalize)(struct netxen_adapter *, u64);
1269 unsigned long (*pci_set_window)(struct netxen_adapter *, 1267 unsigned long (*pci_set_window)(struct netxen_adapter *,
1270 unsigned long long); 1268 unsigned long long);
1271 1269
@@ -1302,46 +1300,6 @@ struct netxen_adapter {
1302#define netxen_get_dma_watchdog_disabled(config_word) \ 1300#define netxen_get_dma_watchdog_disabled(config_word) \
1303 (((config_word) >> 1) & 0x1) 1301 (((config_word) >> 1) & 0x1)
1304 1302
1305/* Max number of xmit producer threads that can run simultaneously */
1306#define MAX_XMIT_PRODUCERS 16
1307
1308#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
1309 ((adapter)->ahw.pci_base0 + (off))
1310#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
1311 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
1312#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
1313 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
1314
1315static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
1316 unsigned long off)
1317{
1318 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
1319 return (adapter->ahw.pci_base0 + off);
1320 } else if ((off < SECOND_PAGE_GROUP_END) &&
1321 (off >= SECOND_PAGE_GROUP_START)) {
1322 return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
1323 } else if ((off < THIRD_PAGE_GROUP_END) &&
1324 (off >= THIRD_PAGE_GROUP_START)) {
1325 return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
1326 }
1327 return NULL;
1328}
1329
1330static inline void __iomem *pci_base(struct netxen_adapter *adapter,
1331 unsigned long off)
1332{
1333 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
1334 return adapter->ahw.pci_base0;
1335 } else if ((off < SECOND_PAGE_GROUP_END) &&
1336 (off >= SECOND_PAGE_GROUP_START)) {
1337 return adapter->ahw.pci_base1;
1338 } else if ((off < THIRD_PAGE_GROUP_END) &&
1339 (off >= THIRD_PAGE_GROUP_START)) {
1340 return adapter->ahw.pci_base2;
1341 }
1342 return NULL;
1343}
1344
1345int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter); 1303int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
1346int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter); 1304int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
1347int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter); 1305int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
@@ -1357,18 +1315,17 @@ int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
1357void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val); 1315void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
1358int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off); 1316int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
1359void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value); 1317void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
1360void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 *value); 1318u32 netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index);
1361void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value); 1319void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value);
1362void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value); 1320u32 netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index);
1363 1321
1364int netxen_nic_get_board_info(struct netxen_adapter *adapter); 1322int netxen_nic_get_board_info(struct netxen_adapter *adapter);
1365void netxen_nic_get_firmware_info(struct netxen_adapter *adapter); 1323void netxen_nic_get_firmware_info(struct netxen_adapter *adapter);
1366int netxen_nic_wol_supported(struct netxen_adapter *adapter); 1324int netxen_nic_wol_supported(struct netxen_adapter *adapter);
1367 1325
1368int netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, 1326u32 netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off);
1369 ulong off, void *data, int len);
1370int netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, 1327int netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
1371 ulong off, void *data, int len); 1328 ulong off, u32 data);
1372int netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, 1329int netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
1373 u64 off, void *data, int size); 1330 u64 off, void *data, int size);
1374int netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, 1331int netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
@@ -1384,10 +1341,9 @@ unsigned long netxen_nic_pci_set_window_128M(struct netxen_adapter *adapter,
1384void netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter, 1341void netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter,
1385 u32 wndw); 1342 u32 wndw);
1386 1343
1387int netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, 1344u32 netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off);
1388 ulong off, void *data, int len);
1389int netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, 1345int netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
1390 ulong off, void *data, int len); 1346 ulong off, u32 data);
1391int netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, 1347int netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
1392 u64 off, void *data, int size); 1348 u64 off, void *data, int size);
1393int netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter, 1349int netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
@@ -1514,9 +1470,8 @@ dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
1514 u32 ctrl; 1470 u32 ctrl;
1515 1471
1516 /* check if already inactive */ 1472 /* check if already inactive */
1517 if (adapter->hw_read_wx(adapter, 1473 ctrl = adapter->hw_read_wx(adapter,
1518 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4)) 1474 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
1519 printk(KERN_ERR "failed to read dma watchdog status\n");
1520 1475
1521 if (netxen_get_dma_watchdog_enabled(ctrl) == 0) 1476 if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
1522 return 1; 1477 return 1;
@@ -1534,9 +1489,8 @@ dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
1534{ 1489{
1535 u32 ctrl; 1490 u32 ctrl;
1536 1491
1537 if (adapter->hw_read_wx(adapter, 1492 ctrl = adapter->hw_read_wx(adapter,
1538 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4)) 1493 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
1539 printk(KERN_ERR "failed to read dma watchdog status\n");
1540 1494
1541 return (netxen_get_dma_watchdog_enabled(ctrl) == 0); 1495 return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
1542} 1496}
@@ -1546,9 +1500,8 @@ dma_watchdog_wakeup(struct netxen_adapter *adapter)
1546{ 1500{
1547 u32 ctrl; 1501 u32 ctrl;
1548 1502
1549 if (adapter->hw_read_wx(adapter, 1503 ctrl = adapter->hw_read_wx(adapter,
1550 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4)) 1504 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
1551 printk(KERN_ERR "failed to read dma watchdog status\n");
1552 1505
1553 if (netxen_get_dma_watchdog_enabled(ctrl)) 1506 if (netxen_get_dma_watchdog_enabled(ctrl))
1554 return 1; 1507 return 1;
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index 794335188a26..7a13ee8144ee 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -41,8 +41,8 @@ netxen_api_lock(struct netxen_adapter *adapter)
41 41
42 for (;;) { 42 for (;;) {
43 /* Acquire PCIE HW semaphore5 */ 43 /* Acquire PCIE HW semaphore5 */
44 netxen_nic_read_w0(adapter, 44 done = netxen_nic_read_w0(adapter,
45 NETXEN_PCIE_REG(PCIE_SEM5_LOCK), &done); 45 NETXEN_PCIE_REG(PCIE_SEM5_LOCK));
46 46
47 if (done == 1) 47 if (done == 1)
48 break; 48 break;
@@ -65,11 +65,9 @@ netxen_api_lock(struct netxen_adapter *adapter)
65static int 65static int
66netxen_api_unlock(struct netxen_adapter *adapter) 66netxen_api_unlock(struct netxen_adapter *adapter)
67{ 67{
68 u32 val;
69
70 /* Release PCIE HW semaphore5 */ 68 /* Release PCIE HW semaphore5 */
71 netxen_nic_read_w0(adapter, 69 netxen_nic_read_w0(adapter,
72 NETXEN_PCIE_REG(PCIE_SEM5_UNLOCK), &val); 70 NETXEN_PCIE_REG(PCIE_SEM5_UNLOCK));
73 return 0; 71 return 0;
74} 72}
75 73
@@ -86,7 +84,7 @@ netxen_poll_rsp(struct netxen_adapter *adapter)
86 if (++timeout > NX_OS_CRB_RETRY_COUNT) 84 if (++timeout > NX_OS_CRB_RETRY_COUNT)
87 return NX_CDRP_RSP_TIMEOUT; 85 return NX_CDRP_RSP_TIMEOUT;
88 86
89 netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET, &rsp); 87 rsp = netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET);
90 } while (!NX_CDRP_IS_RSP(rsp)); 88 } while (!NX_CDRP_IS_RSP(rsp));
91 89
92 return rsp; 90 return rsp;
@@ -125,7 +123,7 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
125 123
126 rcode = NX_RCODE_TIMEOUT; 124 rcode = NX_RCODE_TIMEOUT;
127 } else if (rsp == NX_CDRP_RSP_FAIL) { 125 } else if (rsp == NX_CDRP_RSP_FAIL) {
128 netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET, &rcode); 126 rcode = netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET);
129 127
130 printk(KERN_ERR "%s: failed card response code:0x%x\n", 128 printk(KERN_ERR "%s: failed card response code:0x%x\n",
131 netxen_nic_driver_name, rcode); 129 netxen_nic_driver_name, rcode);
@@ -517,11 +515,11 @@ netxen_init_old_ctx(struct netxen_adapter *adapter)
517 adapter->ctx_desc->sts_ring_addr = cpu_to_le64(sds_ring->phys_addr); 515 adapter->ctx_desc->sts_ring_addr = cpu_to_le64(sds_ring->phys_addr);
518 adapter->ctx_desc->sts_ring_size = cpu_to_le32(sds_ring->num_desc); 516 adapter->ctx_desc->sts_ring_size = cpu_to_le32(sds_ring->num_desc);
519 517
520 adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id), 518 adapter->hw_write_wx(adapter, CRB_CTX_ADDR_REG_LO(func_id),
521 lower32(adapter->ctx_desc_phys_addr)); 519 lower32(adapter->ctx_desc_phys_addr));
522 adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_HI(func_id), 520 adapter->hw_write_wx(adapter, CRB_CTX_ADDR_REG_HI(func_id),
523 upper32(adapter->ctx_desc_phys_addr)); 521 upper32(adapter->ctx_desc_phys_addr));
524 adapter->pci_write_normalize(adapter, CRB_CTX_SIGNATURE_REG(func_id), 522 adapter->hw_write_wx(adapter, CRB_CTX_SIGNATURE_REG(func_id),
525 NETXEN_CTX_SIGNATURE | func_id); 523 NETXEN_CTX_SIGNATURE | func_id);
526 return 0; 524 return 0;
527} 525}
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 5fde9e088a94..6c5a111e80bf 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -92,11 +92,11 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
92 strncpy(drvinfo->driver, netxen_nic_driver_name, 32); 92 strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
93 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); 93 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
94 write_lock_irqsave(&adapter->adapter_lock, flags); 94 write_lock_irqsave(&adapter->adapter_lock, flags);
95 fw_major = adapter->pci_read_normalize(adapter, 95 fw_major = adapter->hw_read_wx(adapter,
96 NETXEN_FW_VERSION_MAJOR); 96 NETXEN_FW_VERSION_MAJOR);
97 fw_minor = adapter->pci_read_normalize(adapter, 97 fw_minor = adapter->hw_read_wx(adapter,
98 NETXEN_FW_VERSION_MINOR); 98 NETXEN_FW_VERSION_MINOR);
99 fw_build = adapter->pci_read_normalize(adapter, 99 fw_build = adapter->hw_read_wx(adapter,
100 NETXEN_FW_VERSION_SUB); 100 NETXEN_FW_VERSION_SUB);
101 write_unlock_irqrestore(&adapter->adapter_lock, flags); 101 write_unlock_irqrestore(&adapter->adapter_lock, flags);
102 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); 102 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
@@ -135,7 +135,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
135 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { 135 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
136 u32 val; 136 u32 val;
137 137
138 adapter->hw_read_wx(adapter, NETXEN_PORT_MODE_ADDR, &val, 4); 138 val = adapter->hw_read_wx(adapter, NETXEN_PORT_MODE_ADDR);
139 if (val == NETXEN_PORT_MODE_802_3_AP) { 139 if (val == NETXEN_PORT_MODE_802_3_AP) {
140 ecmd->supported = SUPPORTED_1000baseT_Full; 140 ecmd->supported = SUPPORTED_1000baseT_Full;
141 ecmd->advertising = ADVERTISED_1000baseT_Full; 141 ecmd->advertising = ADVERTISED_1000baseT_Full;
@@ -156,8 +156,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
156 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 156 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
157 u16 pcifn = adapter->ahw.pci_func; 157 u16 pcifn = adapter->ahw.pci_func;
158 158
159 adapter->hw_read_wx(adapter, 159 val = adapter->hw_read_wx(adapter,
160 P3_LINK_SPEED_REG(pcifn), &val, 4); 160 P3_LINK_SPEED_REG(pcifn));
161 ecmd->speed = P3_LINK_SPEED_MHZ * 161 ecmd->speed = P3_LINK_SPEED_MHZ *
162 P3_LINK_SPEED_VAL(pcifn, val); 162 P3_LINK_SPEED_VAL(pcifn, val);
163 } else 163 } else
@@ -423,12 +423,12 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
423 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | 423 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
424 (adapter->pdev)->device; 424 (adapter->pdev)->device;
425 /* which mode */ 425 /* which mode */
426 adapter->hw_read_wx(adapter, NETXEN_NIU_MODE, &regs_buff[0], 4); 426 regs_buff[0] = adapter->hw_read_wx(adapter, NETXEN_NIU_MODE);
427 mode = regs_buff[0]; 427 mode = regs_buff[0];
428 428
429 /* Common registers to all the modes */ 429 /* Common registers to all the modes */
430 adapter->hw_read_wx(adapter, 430 regs_buff[2] = adapter->hw_read_wx(adapter,
431 NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER, &regs_buff[2], 4); 431 NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER);
432 /* GB/XGB Mode */ 432 /* GB/XGB Mode */
433 mode = (mode / 2) - 1; 433 mode = (mode / 2) - 1;
434 window = 0; 434 window = 0;
@@ -439,9 +439,8 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
439 window = adapter->physical_port * 439 window = adapter->physical_port *
440 NETXEN_NIC_PORT_WINDOW; 440 NETXEN_NIC_PORT_WINDOW;
441 441
442 adapter->hw_read_wx(adapter, 442 regs_buff[i] = adapter->hw_read_wx(adapter,
443 niu_registers[mode].reg[i - 3] + window, 443 niu_registers[mode].reg[i - 3] + window);
444 &regs_buff[i], 4);
445 } 444 }
446 445
447 } 446 }
@@ -465,7 +464,7 @@ static u32 netxen_nic_test_link(struct net_device *dev)
465 return !val; 464 return !val;
466 } 465 }
467 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { 466 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
468 val = adapter->pci_read_normalize(adapter, CRB_XG_STATE); 467 val = adapter->hw_read_wx(adapter, CRB_XG_STATE);
469 return (val == XG_LINK_UP) ? 0 : 1; 468 return (val == XG_LINK_UP) ? 0 : 1;
470 } 469 }
471 return -EIO; 470 return -EIO;
@@ -529,10 +528,10 @@ netxen_nic_get_pauseparam(struct net_device *dev,
529 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) 528 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
530 return; 529 return;
531 /* get flow control settings */ 530 /* get flow control settings */
532 netxen_nic_read_w0(adapter,NETXEN_NIU_GB_MAC_CONFIG_0(port), 531 val = netxen_nic_read_w0(adapter,
533 &val); 532 NETXEN_NIU_GB_MAC_CONFIG_0(port));
534 pause->rx_pause = netxen_gb_get_rx_flowctl(val); 533 pause->rx_pause = netxen_gb_get_rx_flowctl(val);
535 netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val); 534 val = netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL);
536 switch (port) { 535 switch (port) {
537 case 0: 536 case 0:
538 pause->tx_pause = !(netxen_gb_get_gb0_mask(val)); 537 pause->tx_pause = !(netxen_gb_get_gb0_mask(val));
@@ -552,7 +551,7 @@ netxen_nic_get_pauseparam(struct net_device *dev,
552 if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) 551 if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
553 return; 552 return;
554 pause->rx_pause = 1; 553 pause->rx_pause = 1;
555 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val); 554 val = netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL);
556 if (port == 0) 555 if (port == 0)
557 pause->tx_pause = !(netxen_xg_get_xg0_mask(val)); 556 pause->tx_pause = !(netxen_xg_get_xg0_mask(val));
558 else 557 else
@@ -575,8 +574,8 @@ netxen_nic_set_pauseparam(struct net_device *dev,
575 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) 574 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
576 return -EIO; 575 return -EIO;
577 /* set flow control */ 576 /* set flow control */
578 netxen_nic_read_w0(adapter, 577 val = netxen_nic_read_w0(adapter,
579 NETXEN_NIU_GB_MAC_CONFIG_0(port), &val); 578 NETXEN_NIU_GB_MAC_CONFIG_0(port));
580 579
581 if (pause->rx_pause) 580 if (pause->rx_pause)
582 netxen_gb_rx_flowctl(val); 581 netxen_gb_rx_flowctl(val);
@@ -586,7 +585,7 @@ netxen_nic_set_pauseparam(struct net_device *dev,
586 netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 585 netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
587 val); 586 val);
588 /* set autoneg */ 587 /* set autoneg */
589 netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val); 588 val = netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL);
590 switch (port) { 589 switch (port) {
591 case 0: 590 case 0:
592 if (pause->tx_pause) 591 if (pause->tx_pause)
@@ -618,7 +617,7 @@ netxen_nic_set_pauseparam(struct net_device *dev,
618 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { 617 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
619 if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) 618 if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
620 return -EIO; 619 return -EIO;
621 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val); 620 val = netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL);
622 if (port == 0) { 621 if (port == 0) {
623 if (pause->tx_pause) 622 if (pause->tx_pause)
624 netxen_xg_unset_xg0_mask(val); 623 netxen_xg_unset_xg0_mask(val);
@@ -644,14 +643,14 @@ static int netxen_nic_reg_test(struct net_device *dev)
644 struct netxen_adapter *adapter = netdev_priv(dev); 643 struct netxen_adapter *adapter = netdev_priv(dev);
645 u32 data_read, data_written; 644 u32 data_read, data_written;
646 645
647 netxen_nic_read_w0(adapter, NETXEN_PCIX_PH_REG(0), &data_read); 646 data_read = netxen_nic_read_w0(adapter, NETXEN_PCIX_PH_REG(0));
648 if ((data_read & 0xffff) != PHAN_VENDOR_ID) 647 if ((data_read & 0xffff) != PHAN_VENDOR_ID)
649 return 1; 648 return 1;
650 649
651 data_written = (u32)0xa5a5a5a5; 650 data_written = (u32)0xa5a5a5a5;
652 651
653 netxen_nic_reg_write(adapter, CRB_SCRATCHPAD_TEST, data_written); 652 netxen_nic_reg_write(adapter, CRB_SCRATCHPAD_TEST, data_written);
654 data_read = adapter->pci_read_normalize(adapter, CRB_SCRATCHPAD_TEST); 653 data_read = adapter->hw_read_wx(adapter, CRB_SCRATCHPAD_TEST);
655 if (data_written != data_read) 654 if (data_written != data_read)
656 return 1; 655 return 1;
657 656
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 33444a20e4f7..87cda65ef66b 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -63,6 +63,31 @@ static inline void writeq(u64 val, void __iomem *addr)
63} 63}
64#endif 64#endif
65 65
66#define ADDR_IN_RANGE(addr, low, high) \
67 (((addr) < (high)) && ((addr) >= (low)))
68
69#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
70 ((adapter)->ahw.pci_base0 + (off))
71#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
72 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
73#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
74 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
75
76static void __iomem *pci_base_offset(struct netxen_adapter *adapter,
77 unsigned long off)
78{
79 if (ADDR_IN_RANGE(off, FIRST_PAGE_GROUP_START, FIRST_PAGE_GROUP_END))
80 return PCI_OFFSET_FIRST_RANGE(adapter, off);
81
82 if (ADDR_IN_RANGE(off, SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_END))
83 return PCI_OFFSET_SECOND_RANGE(adapter, off);
84
85 if (ADDR_IN_RANGE(off, THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_END))
86 return PCI_OFFSET_THIRD_RANGE(adapter, off);
87
88 return NULL;
89}
90
66#define CRB_WIN_LOCK_TIMEOUT 100000000 91#define CRB_WIN_LOCK_TIMEOUT 100000000
67static crb_128M_2M_block_map_t crb_128M_2M_map[64] = { 92static crb_128M_2M_block_map_t crb_128M_2M_map[64] = {
68 {{{0, 0, 0, 0} } }, /* 0: PCI */ 93 {{{0, 0, 0, 0} } }, /* 0: PCI */
@@ -294,18 +319,8 @@ static unsigned crb_hub_agt[64] =
294 319
295/* PCI Windowing for DDR regions. */ 320/* PCI Windowing for DDR regions. */
296 321
297#define ADDR_IN_RANGE(addr, low, high) \
298 (((addr) <= (high)) && ((addr) >= (low)))
299
300#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */ 322#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
301 323
302#define NETXEN_NIC_ZERO_PAUSE_ADDR 0ULL
303#define NETXEN_NIC_UNIT_PAUSE_ADDR 0x200ULL
304#define NETXEN_NIC_EPG_PAUSE_ADDR1 0x2200010000c28001ULL
305#define NETXEN_NIC_EPG_PAUSE_ADDR2 0x0100088866554433ULL
306
307#define NETXEN_NIC_WINDOW_MARGIN 0x100000
308
309int netxen_nic_set_mac(struct net_device *netdev, void *p) 324int netxen_nic_set_mac(struct net_device *netdev, void *p)
310{ 325{
311 struct netxen_adapter *adapter = netdev_priv(netdev); 326 struct netxen_adapter *adapter = netdev_priv(netdev);
@@ -346,9 +361,9 @@ netxen_nic_enable_mcast_filter(struct netxen_adapter *adapter)
346 if (adapter->mc_enabled) 361 if (adapter->mc_enabled)
347 return 0; 362 return 0;
348 363
349 adapter->hw_read_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4); 364 val = adapter->hw_read_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG);
350 val |= (1UL << (28+port)); 365 val |= (1UL << (28+port));
351 adapter->hw_write_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4); 366 adapter->hw_write_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
352 367
353 /* add broadcast addr to filter */ 368 /* add broadcast addr to filter */
354 val = 0xffffff; 369 val = 0xffffff;
@@ -377,9 +392,9 @@ netxen_nic_disable_mcast_filter(struct netxen_adapter *adapter)
377 if (!adapter->mc_enabled) 392 if (!adapter->mc_enabled)
378 return 0; 393 return 0;
379 394
380 adapter->hw_read_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4); 395 val = adapter->hw_read_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG);
381 val &= ~(1UL << (28+port)); 396 val &= ~(1UL << (28+port));
382 adapter->hw_write_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4); 397 adapter->hw_write_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
383 398
384 val = MAC_HI(addr); 399 val = MAC_HI(addr);
385 netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 0), val); 400 netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
@@ -848,8 +863,8 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac)
848 crbaddr = CRB_MAC_BLOCK_START + 863 crbaddr = CRB_MAC_BLOCK_START +
849 (4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1)); 864 (4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1));
850 865
851 adapter->hw_read_wx(adapter, crbaddr, &mac_lo, 4); 866 mac_lo = adapter->hw_read_wx(adapter, crbaddr);
852 adapter->hw_read_wx(adapter, crbaddr+4, &mac_hi, 4); 867 mac_hi = adapter->hw_read_wx(adapter, crbaddr+4);
853 868
854 if (pci_func & 1) 869 if (pci_func & 1)
855 *mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16)); 870 *mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
@@ -867,8 +882,8 @@ static int crb_win_lock(struct netxen_adapter *adapter)
867 882
868 while (!done) { 883 while (!done) {
869 /* acquire semaphore3 from PCI HW block */ 884 /* acquire semaphore3 from PCI HW block */
870 adapter->hw_read_wx(adapter, 885 done = adapter->hw_read_wx(adapter,
871 NETXEN_PCIE_REG(PCIE_SEM7_LOCK), &done, 4); 886 NETXEN_PCIE_REG(PCIE_SEM7_LOCK));
872 if (done == 1) 887 if (done == 1)
873 break; 888 break;
874 if (timeout >= CRB_WIN_LOCK_TIMEOUT) 889 if (timeout >= CRB_WIN_LOCK_TIMEOUT)
@@ -885,8 +900,8 @@ static void crb_win_unlock(struct netxen_adapter *adapter)
885{ 900{
886 int val; 901 int val;
887 902
888 adapter->hw_read_wx(adapter, 903 val = adapter->hw_read_wx(adapter,
889 NETXEN_PCIE_REG(PCIE_SEM7_UNLOCK), &val, 4); 904 NETXEN_PCIE_REG(PCIE_SEM7_UNLOCK));
890} 905}
891 906
892/* 907/*
@@ -1022,7 +1037,7 @@ netxen_do_load_firmware(struct netxen_adapter *adapter, const char *fwname,
1022 dev_info(&pdev->dev, "loading firmware from flash\n"); 1037 dev_info(&pdev->dev, "loading firmware from flash\n");
1023 1038
1024 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) 1039 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
1025 adapter->pci_write_normalize(adapter, 1040 adapter->hw_write_wx(adapter,
1026 NETXEN_ROMUSB_GLB_CAS_RST, 1); 1041 NETXEN_ROMUSB_GLB_CAS_RST, 1);
1027 1042
1028 if (fw) { 1043 if (fw) {
@@ -1075,12 +1090,12 @@ netxen_do_load_firmware(struct netxen_adapter *adapter, const char *fwname,
1075 msleep(1); 1090 msleep(1);
1076 1091
1077 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 1092 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1078 adapter->pci_write_normalize(adapter, 1093 adapter->hw_write_wx(adapter,
1079 NETXEN_ROMUSB_GLB_SW_RESET, 0x80001d); 1094 NETXEN_ROMUSB_GLB_SW_RESET, 0x80001d);
1080 else { 1095 else {
1081 adapter->pci_write_normalize(adapter, 1096 adapter->hw_write_wx(adapter,
1082 NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL, 0x3fff); 1097 NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL, 0x3fff);
1083 adapter->pci_write_normalize(adapter, 1098 adapter->hw_write_wx(adapter,
1084 NETXEN_ROMUSB_GLB_CAS_RST, 0); 1099 NETXEN_ROMUSB_GLB_CAS_RST, 0);
1085 } 1100 }
1086 1101
@@ -1168,8 +1183,8 @@ request_mn:
1168 netxen_rom_fast_read(adapter, 1183 netxen_rom_fast_read(adapter,
1169 NX_FW_VERSION_OFFSET, (int *)&flashed_ver); 1184 NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
1170 if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) { 1185 if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
1171 adapter->hw_read_wx(adapter, 1186 capability = adapter->hw_read_wx(adapter,
1172 NX_PEG_TUNE_CAPABILITY, &capability, 4); 1187 NX_PEG_TUNE_CAPABILITY);
1173 if (capability & NX_PEG_TUNE_MN_PRESENT) { 1188 if (capability & NX_PEG_TUNE_MN_PRESENT) {
1174 fw_type = NX_P3_MN_ROMIMAGE; 1189 fw_type = NX_P3_MN_ROMIMAGE;
1175 goto request_fw; 1190 goto request_fw;
@@ -1209,13 +1224,10 @@ load_fw:
1209} 1224}
1210 1225
1211int 1226int
1212netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, 1227netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data)
1213 ulong off, void *data, int len)
1214{ 1228{
1215 void __iomem *addr; 1229 void __iomem *addr;
1216 1230
1217 BUG_ON(len != 4);
1218
1219 if (ADDR_IN_WINDOW1(off)) { 1231 if (ADDR_IN_WINDOW1(off)) {
1220 addr = NETXEN_CRB_NORMALIZE(adapter, off); 1232 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1221 } else { /* Window 0 */ 1233 } else { /* Window 0 */
@@ -1228,7 +1240,7 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
1228 return 1; 1240 return 1;
1229 } 1241 }
1230 1242
1231 writel(*(u32 *) data, addr); 1243 writel(data, addr);
1232 1244
1233 if (!ADDR_IN_WINDOW1(off)) 1245 if (!ADDR_IN_WINDOW1(off))
1234 netxen_nic_pci_change_crbwindow_128M(adapter, 1); 1246 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
@@ -1236,13 +1248,11 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
1236 return 0; 1248 return 0;
1237} 1249}
1238 1250
1239int 1251u32
1240netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, 1252netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off)
1241 ulong off, void *data, int len)
1242{ 1253{
1243 void __iomem *addr; 1254 void __iomem *addr;
1244 1255 u32 data;
1245 BUG_ON(len != 4);
1246 1256
1247 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ 1257 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
1248 addr = NETXEN_CRB_NORMALIZE(adapter, off); 1258 addr = NETXEN_CRB_NORMALIZE(adapter, off);
@@ -1256,24 +1266,21 @@ netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter,
1256 return 1; 1266 return 1;
1257 } 1267 }
1258 1268
1259 *(u32 *)data = readl(addr); 1269 data = readl(addr);
1260 1270
1261 if (!ADDR_IN_WINDOW1(off)) 1271 if (!ADDR_IN_WINDOW1(off))
1262 netxen_nic_pci_change_crbwindow_128M(adapter, 1); 1272 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1263 1273
1264 return 0; 1274 return data;
1265} 1275}
1266 1276
1267int 1277int
1268netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, 1278netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, ulong off, u32 data)
1269 ulong off, void *data, int len)
1270{ 1279{
1271 unsigned long flags = 0; 1280 unsigned long flags = 0;
1272 int rv; 1281 int rv;
1273 1282
1274 BUG_ON(len != 4); 1283 rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off, 4);
1275
1276 rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off, len);
1277 1284
1278 if (rv == -1) { 1285 if (rv == -1) {
1279 printk(KERN_ERR "%s: invalid offset: 0x%016lx\n", 1286 printk(KERN_ERR "%s: invalid offset: 0x%016lx\n",
@@ -1286,26 +1293,24 @@ netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
1286 write_lock_irqsave(&adapter->adapter_lock, flags); 1293 write_lock_irqsave(&adapter->adapter_lock, flags);
1287 crb_win_lock(adapter); 1294 crb_win_lock(adapter);
1288 netxen_nic_pci_set_crbwindow_2M(adapter, &off); 1295 netxen_nic_pci_set_crbwindow_2M(adapter, &off);
1289 writel(*(uint32_t *)data, (void __iomem *)off); 1296 writel(data, (void __iomem *)off);
1290 crb_win_unlock(adapter); 1297 crb_win_unlock(adapter);
1291 write_unlock_irqrestore(&adapter->adapter_lock, flags); 1298 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1292 } else 1299 } else
1293 writel(*(uint32_t *)data, (void __iomem *)off); 1300 writel(data, (void __iomem *)off);
1294 1301
1295 1302
1296 return 0; 1303 return 0;
1297} 1304}
1298 1305
1299int 1306u32
1300netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, 1307netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off)
1301 ulong off, void *data, int len)
1302{ 1308{
1303 unsigned long flags = 0; 1309 unsigned long flags = 0;
1304 int rv; 1310 int rv;
1311 u32 data;
1305 1312
1306 BUG_ON(len != 4); 1313 rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off, 4);
1307
1308 rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off, len);
1309 1314
1310 if (rv == -1) { 1315 if (rv == -1) {
1311 printk(KERN_ERR "%s: invalid offset: 0x%016lx\n", 1316 printk(KERN_ERR "%s: invalid offset: 0x%016lx\n",
@@ -1318,47 +1323,45 @@ netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter,
1318 write_lock_irqsave(&adapter->adapter_lock, flags); 1323 write_lock_irqsave(&adapter->adapter_lock, flags);
1319 crb_win_lock(adapter); 1324 crb_win_lock(adapter);
1320 netxen_nic_pci_set_crbwindow_2M(adapter, &off); 1325 netxen_nic_pci_set_crbwindow_2M(adapter, &off);
1321 *(uint32_t *)data = readl((void __iomem *)off); 1326 data = readl((void __iomem *)off);
1322 crb_win_unlock(adapter); 1327 crb_win_unlock(adapter);
1323 write_unlock_irqrestore(&adapter->adapter_lock, flags); 1328 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1324 } else 1329 } else
1325 *(uint32_t *)data = readl((void __iomem *)off); 1330 data = readl((void __iomem *)off);
1326 1331
1327 return 0; 1332 return data;
1328} 1333}
1329 1334
1330void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val) 1335void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
1331{ 1336{
1332 adapter->hw_write_wx(adapter, off, &val, 4); 1337 adapter->hw_write_wx(adapter, off, val);
1333} 1338}
1334 1339
1335int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off) 1340int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off)
1336{ 1341{
1337 int val; 1342 return adapter->hw_read_wx(adapter, off);
1338 adapter->hw_read_wx(adapter, off, &val, 4);
1339 return val;
1340} 1343}
1341 1344
1342/* Change the window to 0, write and change back to window 1. */ 1345/* Change the window to 0, write and change back to window 1. */
1343void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value) 1346void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value)
1344{ 1347{
1345 adapter->hw_write_wx(adapter, index, &value, 4); 1348 adapter->hw_write_wx(adapter, index, value);
1346} 1349}
1347 1350
1348/* Change the window to 0, read and change back to window 1. */ 1351/* Change the window to 0, read and change back to window 1. */
1349void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 *value) 1352u32 netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index)
1350{ 1353{
1351 adapter->hw_read_wx(adapter, index, value, 4); 1354 return adapter->hw_read_wx(adapter, index);
1352} 1355}
1353 1356
1354void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value) 1357void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value)
1355{ 1358{
1356 adapter->hw_write_wx(adapter, index, &value, 4); 1359 adapter->hw_write_wx(adapter, index, value);
1357} 1360}
1358 1361
1359void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value) 1362u32 netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index)
1360{ 1363{
1361 adapter->hw_read_wx(adapter, index, value, 4); 1364 return adapter->hw_read_wx(adapter, index);
1362} 1365}
1363 1366
1364/* 1367/*
@@ -1461,17 +1464,6 @@ u32 netxen_nic_pci_read_immediate_128M(struct netxen_adapter *adapter, u64 off)
1461 return readl((void __iomem *)(pci_base_offset(adapter, off))); 1464 return readl((void __iomem *)(pci_base_offset(adapter, off)));
1462} 1465}
1463 1466
1464void netxen_nic_pci_write_normalize_128M(struct netxen_adapter *adapter,
1465 u64 off, u32 data)
1466{
1467 writel(data, NETXEN_CRB_NORMALIZE(adapter, off));
1468}
1469
1470u32 netxen_nic_pci_read_normalize_128M(struct netxen_adapter *adapter, u64 off)
1471{
1472 return readl(NETXEN_CRB_NORMALIZE(adapter, off));
1473}
1474
1475unsigned long 1467unsigned long
1476netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter, 1468netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1477 unsigned long long addr) 1469 unsigned long long addr)
@@ -1485,10 +1477,9 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1485 adapter->ahw.ddr_mn_window = window; 1477 adapter->ahw.ddr_mn_window = window;
1486 adapter->hw_write_wx(adapter, 1478 adapter->hw_write_wx(adapter,
1487 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE, 1479 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
1488 &window, 4); 1480 window);
1489 adapter->hw_read_wx(adapter, 1481 win_read = adapter->hw_read_wx(adapter,
1490 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE, 1482 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE);
1491 &win_read, 4);
1492 if ((win_read << 17) != window) { 1483 if ((win_read << 17) != window) {
1493 printk(KERN_INFO "Written MNwin (0x%x) != " 1484 printk(KERN_INFO "Written MNwin (0x%x) != "
1494 "Read MNwin (0x%x)\n", window, win_read); 1485 "Read MNwin (0x%x)\n", window, win_read);
@@ -1505,10 +1496,9 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1505 adapter->ahw.ddr_mn_window = window; 1496 adapter->ahw.ddr_mn_window = window;
1506 adapter->hw_write_wx(adapter, 1497 adapter->hw_write_wx(adapter,
1507 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE, 1498 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
1508 &window, 4); 1499 window);
1509 adapter->hw_read_wx(adapter, 1500 win_read = adapter->hw_read_wx(adapter,
1510 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE, 1501 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE);
1511 &win_read, 4);
1512 if ((win_read >> 7) != window) { 1502 if ((win_read >> 7) != window) {
1513 printk(KERN_INFO "%s: Written OCMwin (0x%x) != " 1503 printk(KERN_INFO "%s: Written OCMwin (0x%x) != "
1514 "Read OCMwin (0x%x)\n", 1504 "Read OCMwin (0x%x)\n",
@@ -1523,10 +1513,9 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1523 adapter->ahw.qdr_sn_window = window; 1513 adapter->ahw.qdr_sn_window = window;
1524 adapter->hw_write_wx(adapter, 1514 adapter->hw_write_wx(adapter,
1525 adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE, 1515 adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE,
1526 &window, 4); 1516 window);
1527 adapter->hw_read_wx(adapter, 1517 win_read = adapter->hw_read_wx(adapter,
1528 adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE, 1518 adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE);
1529 &win_read, 4);
1530 if (win_read != window) { 1519 if (win_read != window) {
1531 printk(KERN_INFO "%s: Written MSwin (0x%x) != " 1520 printk(KERN_INFO "%s: Written MSwin (0x%x) != "
1532 "Read MSwin (0x%x)\n", 1521 "Read MSwin (0x%x)\n",
@@ -1973,26 +1962,26 @@ netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
1973 for (i = 0; i < loop; i++) { 1962 for (i = 0; i < loop; i++) {
1974 temp = off8 + (i << 3); 1963 temp = off8 + (i << 3);
1975 adapter->hw_write_wx(adapter, 1964 adapter->hw_write_wx(adapter,
1976 mem_crb+MIU_TEST_AGT_ADDR_LO, &temp, 4); 1965 mem_crb+MIU_TEST_AGT_ADDR_LO, temp);
1977 temp = 0; 1966 temp = 0;
1978 adapter->hw_write_wx(adapter, 1967 adapter->hw_write_wx(adapter,
1979 mem_crb+MIU_TEST_AGT_ADDR_HI, &temp, 4); 1968 mem_crb+MIU_TEST_AGT_ADDR_HI, temp);
1980 temp = word[i] & 0xffffffff; 1969 temp = word[i] & 0xffffffff;
1981 adapter->hw_write_wx(adapter, 1970 adapter->hw_write_wx(adapter,
1982 mem_crb+MIU_TEST_AGT_WRDATA_LO, &temp, 4); 1971 mem_crb+MIU_TEST_AGT_WRDATA_LO, temp);
1983 temp = (word[i] >> 32) & 0xffffffff; 1972 temp = (word[i] >> 32) & 0xffffffff;
1984 adapter->hw_write_wx(adapter, 1973 adapter->hw_write_wx(adapter,
1985 mem_crb+MIU_TEST_AGT_WRDATA_HI, &temp, 4); 1974 mem_crb+MIU_TEST_AGT_WRDATA_HI, temp);
1986 temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE; 1975 temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1987 adapter->hw_write_wx(adapter, 1976 adapter->hw_write_wx(adapter,
1988 mem_crb+MIU_TEST_AGT_CTRL, &temp, 4); 1977 mem_crb+MIU_TEST_AGT_CTRL, temp);
1989 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE; 1978 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1990 adapter->hw_write_wx(adapter, 1979 adapter->hw_write_wx(adapter,
1991 mem_crb+MIU_TEST_AGT_CTRL, &temp, 4); 1980 mem_crb+MIU_TEST_AGT_CTRL, temp);
1992 1981
1993 for (j = 0; j < MAX_CTL_CHECK; j++) { 1982 for (j = 0; j < MAX_CTL_CHECK; j++) {
1994 adapter->hw_read_wx(adapter, 1983 temp = adapter->hw_read_wx(adapter,
1995 mem_crb + MIU_TEST_AGT_CTRL, &temp, 4); 1984 mem_crb + MIU_TEST_AGT_CTRL);
1996 if ((temp & MIU_TA_CTL_BUSY) == 0) 1985 if ((temp & MIU_TA_CTL_BUSY) == 0)
1997 break; 1986 break;
1998 } 1987 }
@@ -2050,20 +2039,20 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
2050 for (i = 0; i < loop; i++) { 2039 for (i = 0; i < loop; i++) {
2051 temp = off8 + (i << 3); 2040 temp = off8 + (i << 3);
2052 adapter->hw_write_wx(adapter, 2041 adapter->hw_write_wx(adapter,
2053 mem_crb + MIU_TEST_AGT_ADDR_LO, &temp, 4); 2042 mem_crb + MIU_TEST_AGT_ADDR_LO, temp);
2054 temp = 0; 2043 temp = 0;
2055 adapter->hw_write_wx(adapter, 2044 adapter->hw_write_wx(adapter,
2056 mem_crb + MIU_TEST_AGT_ADDR_HI, &temp, 4); 2045 mem_crb + MIU_TEST_AGT_ADDR_HI, temp);
2057 temp = MIU_TA_CTL_ENABLE; 2046 temp = MIU_TA_CTL_ENABLE;
2058 adapter->hw_write_wx(adapter, 2047 adapter->hw_write_wx(adapter,
2059 mem_crb + MIU_TEST_AGT_CTRL, &temp, 4); 2048 mem_crb + MIU_TEST_AGT_CTRL, temp);
2060 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE; 2049 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE;
2061 adapter->hw_write_wx(adapter, 2050 adapter->hw_write_wx(adapter,
2062 mem_crb + MIU_TEST_AGT_CTRL, &temp, 4); 2051 mem_crb + MIU_TEST_AGT_CTRL, temp);
2063 2052
2064 for (j = 0; j < MAX_CTL_CHECK; j++) { 2053 for (j = 0; j < MAX_CTL_CHECK; j++) {
2065 adapter->hw_read_wx(adapter, 2054 temp = adapter->hw_read_wx(adapter,
2066 mem_crb + MIU_TEST_AGT_CTRL, &temp, 4); 2055 mem_crb + MIU_TEST_AGT_CTRL);
2067 if ((temp & MIU_TA_CTL_BUSY) == 0) 2056 if ((temp & MIU_TA_CTL_BUSY) == 0)
2068 break; 2057 break;
2069 } 2058 }
@@ -2078,8 +2067,8 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
2078 start = off0[i] >> 2; 2067 start = off0[i] >> 2;
2079 end = (off0[i] + sz[i] - 1) >> 2; 2068 end = (off0[i] + sz[i] - 1) >> 2;
2080 for (k = start; k <= end; k++) { 2069 for (k = start; k <= end; k++) {
2081 adapter->hw_read_wx(adapter, 2070 temp = adapter->hw_read_wx(adapter,
2082 mem_crb + MIU_TEST_AGT_RDDATA(k), &temp, 4); 2071 mem_crb + MIU_TEST_AGT_RDDATA(k));
2083 word[i] |= ((uint64_t)temp << (32 * k)); 2072 word[i] |= ((uint64_t)temp << (32 * k));
2084 } 2073 }
2085 } 2074 }
@@ -2122,29 +2111,14 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
2122int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter, 2111int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter,
2123 u64 off, u32 data) 2112 u64 off, u32 data)
2124{ 2113{
2125 adapter->hw_write_wx(adapter, off, &data, 4); 2114 adapter->hw_write_wx(adapter, off, data);
2126 2115
2127 return 0; 2116 return 0;
2128} 2117}
2129 2118
2130u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off) 2119u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off)
2131{ 2120{
2132 u32 temp; 2121 return adapter->hw_read_wx(adapter, off);
2133 adapter->hw_read_wx(adapter, off, &temp, 4);
2134 return temp;
2135}
2136
2137void netxen_nic_pci_write_normalize_2M(struct netxen_adapter *adapter,
2138 u64 off, u32 data)
2139{
2140 adapter->hw_write_wx(adapter, off, &data, 4);
2141}
2142
2143u32 netxen_nic_pci_read_normalize_2M(struct netxen_adapter *adapter, u64 off)
2144{
2145 u32 temp;
2146 adapter->hw_read_wx(adapter, off, &temp, 4);
2147 return temp;
2148} 2122}
2149 2123
2150int netxen_nic_get_board_info(struct netxen_adapter *adapter) 2124int netxen_nic_get_board_info(struct netxen_adapter *adapter)
@@ -2253,7 +2227,7 @@ void
2253netxen_crb_writelit_adapter(struct netxen_adapter *adapter, 2227netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
2254 unsigned long off, int data) 2228 unsigned long off, int data)
2255{ 2229{
2256 adapter->hw_write_wx(adapter, off, &data, 4); 2230 adapter->hw_write_wx(adapter, off, data);
2257} 2231}
2258 2232
2259void netxen_nic_set_link_parameters(struct netxen_adapter *adapter) 2233void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
@@ -2270,8 +2244,8 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2270 } 2244 }
2271 2245
2272 if (adapter->ahw.port_type == NETXEN_NIC_GBE) { 2246 if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
2273 adapter->hw_read_wx(adapter, 2247 port_mode = adapter->hw_read_wx(adapter,
2274 NETXEN_PORT_MODE_ADDR, &port_mode, 4); 2248 NETXEN_PORT_MODE_ADDR);
2275 if (port_mode == NETXEN_PORT_MODE_802_3_AP) { 2249 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
2276 adapter->link_speed = SPEED_1000; 2250 adapter->link_speed = SPEED_1000;
2277 adapter->link_duplex = DUPLEX_FULL; 2251 adapter->link_duplex = DUPLEX_FULL;
@@ -2348,9 +2322,9 @@ void netxen_nic_get_firmware_info(struct netxen_adapter *adapter)
2348 addr += sizeof(u32); 2322 addr += sizeof(u32);
2349 } 2323 }
2350 2324
2351 adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MAJOR, &fw_major, 4); 2325 fw_major = adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MAJOR);
2352 adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MINOR, &fw_minor, 4); 2326 fw_minor = adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MINOR);
2353 adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4); 2327 fw_build = adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB);
2354 2328
2355 adapter->fw_major = fw_major; 2329 adapter->fw_major = fw_major;
2356 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); 2330 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build);
@@ -2373,8 +2347,7 @@ void netxen_nic_get_firmware_info(struct netxen_adapter *adapter)
2373 fw_major, fw_minor, fw_build); 2347 fw_major, fw_minor, fw_build);
2374 2348
2375 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 2349 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
2376 adapter->hw_read_wx(adapter, 2350 i = adapter->hw_read_wx(adapter, NETXEN_MIU_MN_CONTROL);
2377 NETXEN_MIU_MN_CONTROL, &i, 4);
2378 adapter->ahw.cut_through = (i & 0x4) ? 1 : 0; 2351 adapter->ahw.cut_through = (i & 0x4) ? 1 : 0;
2379 dev_info(&pdev->dev, "firmware running in %s mode\n", 2352 dev_info(&pdev->dev, "firmware running in %s mode\n",
2380 adapter->ahw.cut_through ? "cut-through" : "legacy"); 2353 adapter->ahw.cut_through ? "cut-through" : "legacy");
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 974783c45321..83116c2817b0 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -368,8 +368,8 @@ static int rom_lock(struct netxen_adapter *adapter)
368 368
369 while (!done) { 369 while (!done) {
370 /* acquire semaphore2 from PCI HW block */ 370 /* acquire semaphore2 from PCI HW block */
371 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_LOCK), 371 done = netxen_nic_read_w0(adapter,
372 &done); 372 NETXEN_PCIE_REG(PCIE_SEM2_LOCK));
373 if (done == 1) 373 if (done == 1)
374 break; 374 break;
375 if (timeout >= rom_lock_timeout) 375 if (timeout >= rom_lock_timeout)
@@ -411,10 +411,8 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
411 411
412static void netxen_rom_unlock(struct netxen_adapter *adapter) 412static void netxen_rom_unlock(struct netxen_adapter *adapter)
413{ 413{
414 u32 val;
415
416 /* release semaphore2 */ 414 /* release semaphore2 */
417 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK), &val); 415 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK));
418 416
419} 417}
420 418
@@ -623,7 +621,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
623 } 621 }
624 } 622 }
625 623
626 adapter->hw_write_wx(adapter, off, &buf[i].data, 4); 624 adapter->hw_write_wx(adapter, off, buf[i].data);
627 625
628 msleep(init_delay); 626 msleep(init_delay);
629 } 627 }
@@ -633,8 +631,8 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
633 631
634 /* unreset_net_cache */ 632 /* unreset_net_cache */
635 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 633 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
636 adapter->hw_read_wx(adapter, 634 val = adapter->hw_read_wx(adapter,
637 NETXEN_ROMUSB_GLB_SW_RESET, &val, 4); 635 NETXEN_ROMUSB_GLB_SW_RESET);
638 netxen_crb_writelit_adapter(adapter, 636 netxen_crb_writelit_adapter(adapter,
639 NETXEN_ROMUSB_GLB_SW_RESET, (val & 0xffffff0f)); 637 NETXEN_ROMUSB_GLB_SW_RESET, (val & 0xffffff0f));
640 } 638 }
@@ -683,12 +681,12 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
683 hi = (addr >> 32) & 0xffffffff; 681 hi = (addr >> 32) & 0xffffffff;
684 lo = addr & 0xffffffff; 682 lo = addr & 0xffffffff;
685 683
686 adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi); 684 adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
687 adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo); 685 adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
688 686
689 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 687 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
690 uint32_t temp = 0; 688 uint32_t temp = 0;
691 adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF, &temp, 4); 689 adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF, temp);
692 } 690 }
693 691
694 return 0; 692 return 0;
@@ -730,7 +728,7 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
730 728
731 if (!pegtune_val) { 729 if (!pegtune_val) {
732 do { 730 do {
733 val = adapter->pci_read_normalize(adapter, 731 val = adapter->hw_read_wx(adapter,
734 CRB_CMDPEG_STATE); 732 CRB_CMDPEG_STATE);
735 733
736 if (val == PHAN_INITIALIZE_COMPLETE || 734 if (val == PHAN_INITIALIZE_COMPLETE ||
@@ -742,7 +740,7 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
742 } while (--retries); 740 } while (--retries);
743 741
744 if (!retries) { 742 if (!retries) {
745 pegtune_val = adapter->pci_read_normalize(adapter, 743 pegtune_val = adapter->hw_read_wx(adapter,
746 NETXEN_ROMUSB_GLB_PEGTUNE_DONE); 744 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
747 printk(KERN_WARNING "netxen_phantom_init: init failed, " 745 printk(KERN_WARNING "netxen_phantom_init: init failed, "
748 "pegtune_val=%x\n", pegtune_val); 746 "pegtune_val=%x\n", pegtune_val);
@@ -760,7 +758,7 @@ netxen_receive_peg_ready(struct netxen_adapter *adapter)
760 int retries = 2000; 758 int retries = 2000;
761 759
762 do { 760 do {
763 val = adapter->pci_read_normalize(adapter, CRB_RCVPEG_STATE); 761 val = adapter->hw_read_wx(adapter, CRB_RCVPEG_STATE);
764 762
765 if (val == PHAN_PEG_RCV_INITIALIZED) 763 if (val == PHAN_PEG_RCV_INITIALIZED)
766 return 0; 764 return 0;
@@ -786,13 +784,13 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
786 if (err) 784 if (err)
787 return err; 785 return err;
788 786
789 adapter->pci_write_normalize(adapter, 787 adapter->hw_write_wx(adapter,
790 CRB_NIC_CAPABILITIES_HOST, INTR_SCHEME_PERPORT); 788 CRB_NIC_CAPABILITIES_HOST, INTR_SCHEME_PERPORT);
791 adapter->pci_write_normalize(adapter, 789 adapter->hw_write_wx(adapter,
792 CRB_NIC_MSI_MODE_HOST, MSI_MODE_MULTIFUNC); 790 CRB_NIC_MSI_MODE_HOST, MSI_MODE_MULTIFUNC);
793 adapter->pci_write_normalize(adapter, 791 adapter->hw_write_wx(adapter,
794 CRB_MPORT_MODE, MPORT_MULTI_FUNCTION_MODE); 792 CRB_MPORT_MODE, MPORT_MULTI_FUNCTION_MODE);
795 adapter->pci_write_normalize(adapter, 793 adapter->hw_write_wx(adapter,
796 CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK); 794 CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK);
797 795
798 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) { 796 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) {
@@ -1059,7 +1057,7 @@ skip:
1059 1057
1060 if (count) { 1058 if (count) {
1061 sds_ring->consumer = consumer; 1059 sds_ring->consumer = consumer;
1062 adapter->pci_write_normalize(adapter, 1060 adapter->hw_write_wx(adapter,
1063 sds_ring->crb_sts_consumer, consumer); 1061 sds_ring->crb_sts_consumer, consumer);
1064 } 1062 }
1065 1063
@@ -1178,7 +1176,7 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
1178 1176
1179 if (count) { 1177 if (count) {
1180 rds_ring->producer = producer; 1178 rds_ring->producer = producer;
1181 adapter->pci_write_normalize(adapter, 1179 adapter->hw_write_wx(adapter,
1182 rds_ring->crb_rcv_producer, 1180 rds_ring->crb_rcv_producer,
1183 (producer-1) & (rds_ring->num_desc-1)); 1181 (producer-1) & (rds_ring->num_desc-1));
1184 1182
@@ -1239,7 +1237,7 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1239 1237
1240 if (count) { 1238 if (count) {
1241 rds_ring->producer = producer; 1239 rds_ring->producer = producer;
1242 adapter->pci_write_normalize(adapter, 1240 adapter->hw_write_wx(adapter,
1243 rds_ring->crb_rcv_producer, 1241 rds_ring->crb_rcv_producer,
1244 (producer - 1) & (rds_ring->num_desc - 1)); 1242 (producer - 1) & (rds_ring->num_desc - 1));
1245 wmb(); 1243 wmb();
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index cbd47ae694ba..31966a044900 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -109,7 +109,7 @@ void
109netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, 109netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
110 struct nx_host_tx_ring *tx_ring, u32 producer) 110 struct nx_host_tx_ring *tx_ring, u32 producer)
111{ 111{
112 adapter->pci_write_normalize(adapter, 112 adapter->hw_write_wx(adapter,
113 tx_ring->crb_cmd_producer, producer); 113 tx_ring->crb_cmd_producer, producer);
114} 114}
115 115
@@ -122,7 +122,7 @@ static inline void
122netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter, 122netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
123 struct nx_host_tx_ring *tx_ring, u32 consumer) 123 struct nx_host_tx_ring *tx_ring, u32 consumer)
124{ 124{
125 adapter->pci_write_normalize(adapter, 125 adapter->hw_write_wx(adapter,
126 tx_ring->crb_cmd_consumer, consumer); 126 tx_ring->crb_cmd_consumer, consumer);
127} 127}
128 128
@@ -139,14 +139,14 @@ static inline void netxen_nic_disable_int(struct nx_host_sds_ring *sds_ring)
139{ 139{
140 struct netxen_adapter *adapter = sds_ring->adapter; 140 struct netxen_adapter *adapter = sds_ring->adapter;
141 141
142 adapter->pci_write_normalize(adapter, sds_ring->crb_intr_mask, 0); 142 adapter->hw_write_wx(adapter, sds_ring->crb_intr_mask, 0);
143} 143}
144 144
145static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring) 145static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring)
146{ 146{
147 struct netxen_adapter *adapter = sds_ring->adapter; 147 struct netxen_adapter *adapter = sds_ring->adapter;
148 148
149 adapter->pci_write_normalize(adapter, sds_ring->crb_intr_mask, 0x1); 149 adapter->hw_write_wx(adapter, sds_ring->crb_intr_mask, 0x1);
150 150
151 if (!NETXEN_IS_MSI_FAMILY(adapter)) 151 if (!NETXEN_IS_MSI_FAMILY(adapter))
152 adapter->pci_write_immediate(adapter, 152 adapter->pci_write_immediate(adapter,
@@ -309,42 +309,41 @@ netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
309 309
310 if (first_boot == 0x55555555) { 310 if (first_boot == 0x55555555) {
311 /* This is the first boot after power up */ 311 /* This is the first boot after power up */
312 adapter->pci_write_normalize(adapter, 312 adapter->hw_write_wx(adapter,
313 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); 313 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
314 314
315 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id)) 315 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
316 return 0; 316 return 0;
317 317
318 /* PCI bus master workaround */ 318 /* PCI bus master workaround */
319 adapter->hw_read_wx(adapter, 319 first_boot = adapter->hw_read_wx(adapter, NETXEN_PCIE_REG(0x4));
320 NETXEN_PCIE_REG(0x4), &first_boot, 4);
321 if (!(first_boot & 0x4)) { 320 if (!(first_boot & 0x4)) {
322 first_boot |= 0x4; 321 first_boot |= 0x4;
323 adapter->hw_write_wx(adapter, 322 adapter->hw_write_wx(adapter,
324 NETXEN_PCIE_REG(0x4), &first_boot, 4); 323 NETXEN_PCIE_REG(0x4), first_boot);
325 adapter->hw_read_wx(adapter, 324 first_boot = adapter->hw_read_wx(adapter,
326 NETXEN_PCIE_REG(0x4), &first_boot, 4); 325 NETXEN_PCIE_REG(0x4));
327 } 326 }
328 327
329 /* This is the first boot after power up */ 328 /* This is the first boot after power up */
330 adapter->hw_read_wx(adapter, 329 first_boot = adapter->hw_read_wx(adapter,
331 NETXEN_ROMUSB_GLB_SW_RESET, &first_boot, 4); 330 NETXEN_ROMUSB_GLB_SW_RESET);
332 if (first_boot != 0x80000f) { 331 if (first_boot != 0x80000f) {
333 /* clear the register for future unloads/loads */ 332 /* clear the register for future unloads/loads */
334 adapter->pci_write_normalize(adapter, 333 adapter->hw_write_wx(adapter,
335 NETXEN_CAM_RAM(0x1fc), 0); 334 NETXEN_CAM_RAM(0x1fc), 0);
336 return -EIO; 335 return -EIO;
337 } 336 }
338 337
339 /* Start P2 boot loader */ 338 /* Start P2 boot loader */
340 val = adapter->pci_read_normalize(adapter, 339 val = adapter->hw_read_wx(adapter,
341 NETXEN_ROMUSB_GLB_PEGTUNE_DONE); 340 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
342 adapter->pci_write_normalize(adapter, 341 adapter->hw_write_wx(adapter,
343 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1); 342 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
344 timeout = 0; 343 timeout = 0;
345 do { 344 do {
346 msleep(1); 345 msleep(1);
347 val = adapter->pci_read_normalize(adapter, 346 val = adapter->hw_read_wx(adapter,
348 NETXEN_CAM_RAM(0x1fc)); 347 NETXEN_CAM_RAM(0x1fc));
349 348
350 if (++timeout > 5000) 349 if (++timeout > 5000)
@@ -365,23 +364,23 @@ static void netxen_set_port_mode(struct netxen_adapter *adapter)
365 if (port_mode == NETXEN_PORT_MODE_802_3_AP) { 364 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
366 data = NETXEN_PORT_MODE_802_3_AP; 365 data = NETXEN_PORT_MODE_802_3_AP;
367 adapter->hw_write_wx(adapter, 366 adapter->hw_write_wx(adapter,
368 NETXEN_PORT_MODE_ADDR, &data, 4); 367 NETXEN_PORT_MODE_ADDR, data);
369 } else if (port_mode == NETXEN_PORT_MODE_XG) { 368 } else if (port_mode == NETXEN_PORT_MODE_XG) {
370 data = NETXEN_PORT_MODE_XG; 369 data = NETXEN_PORT_MODE_XG;
371 adapter->hw_write_wx(adapter, 370 adapter->hw_write_wx(adapter,
372 NETXEN_PORT_MODE_ADDR, &data, 4); 371 NETXEN_PORT_MODE_ADDR, data);
373 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_1G) { 372 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_1G) {
374 data = NETXEN_PORT_MODE_AUTO_NEG_1G; 373 data = NETXEN_PORT_MODE_AUTO_NEG_1G;
375 adapter->hw_write_wx(adapter, 374 adapter->hw_write_wx(adapter,
376 NETXEN_PORT_MODE_ADDR, &data, 4); 375 NETXEN_PORT_MODE_ADDR, data);
377 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_XG) { 376 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_XG) {
378 data = NETXEN_PORT_MODE_AUTO_NEG_XG; 377 data = NETXEN_PORT_MODE_AUTO_NEG_XG;
379 adapter->hw_write_wx(adapter, 378 adapter->hw_write_wx(adapter,
380 NETXEN_PORT_MODE_ADDR, &data, 4); 379 NETXEN_PORT_MODE_ADDR, data);
381 } else { 380 } else {
382 data = NETXEN_PORT_MODE_AUTO_NEG; 381 data = NETXEN_PORT_MODE_AUTO_NEG;
383 adapter->hw_write_wx(adapter, 382 adapter->hw_write_wx(adapter,
384 NETXEN_PORT_MODE_ADDR, &data, 4); 383 NETXEN_PORT_MODE_ADDR, data);
385 } 384 }
386 385
387 if ((wol_port_mode != NETXEN_PORT_MODE_802_3_AP) && 386 if ((wol_port_mode != NETXEN_PORT_MODE_802_3_AP) &&
@@ -391,7 +390,7 @@ static void netxen_set_port_mode(struct netxen_adapter *adapter)
391 wol_port_mode = NETXEN_PORT_MODE_AUTO_NEG; 390 wol_port_mode = NETXEN_PORT_MODE_AUTO_NEG;
392 } 391 }
393 adapter->hw_write_wx(adapter, NETXEN_WOL_PORT_MODE, 392 adapter->hw_write_wx(adapter, NETXEN_WOL_PORT_MODE,
394 &wol_port_mode, 4); 393 wol_port_mode);
395 } 394 }
396} 395}
397 396
@@ -572,8 +571,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
572 adapter->hw_read_wx = netxen_nic_hw_read_wx_128M; 571 adapter->hw_read_wx = netxen_nic_hw_read_wx_128M;
573 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M; 572 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M;
574 adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M; 573 adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M;
575 adapter->pci_read_normalize = netxen_nic_pci_read_normalize_128M;
576 adapter->pci_write_normalize = netxen_nic_pci_write_normalize_128M;
577 adapter->pci_set_window = netxen_nic_pci_set_window_128M; 574 adapter->pci_set_window = netxen_nic_pci_set_window_128M;
578 adapter->pci_mem_read = netxen_nic_pci_mem_read_128M; 575 adapter->pci_mem_read = netxen_nic_pci_mem_read_128M;
579 adapter->pci_mem_write = netxen_nic_pci_mem_write_128M; 576 adapter->pci_mem_write = netxen_nic_pci_mem_write_128M;
@@ -595,9 +592,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
595 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M; 592 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M;
596 adapter->pci_write_immediate = 593 adapter->pci_write_immediate =
597 netxen_nic_pci_write_immediate_2M; 594 netxen_nic_pci_write_immediate_2M;
598 adapter->pci_read_normalize = netxen_nic_pci_read_normalize_2M;
599 adapter->pci_write_normalize =
600 netxen_nic_pci_write_normalize_2M;
601 adapter->pci_set_window = netxen_nic_pci_set_window_2M; 595 adapter->pci_set_window = netxen_nic_pci_set_window_2M;
602 adapter->pci_mem_read = netxen_nic_pci_mem_read_2M; 596 adapter->pci_mem_read = netxen_nic_pci_mem_read_2M;
603 adapter->pci_mem_write = netxen_nic_pci_mem_write_2M; 597 adapter->pci_mem_write = netxen_nic_pci_mem_write_2M;
@@ -680,7 +674,7 @@ netxen_start_firmware(struct netxen_adapter *adapter)
680 if (!first_driver) 674 if (!first_driver)
681 return 0; 675 return 0;
682 676
683 first_boot = adapter->pci_read_normalize(adapter, 677 first_boot = adapter->hw_read_wx(adapter,
684 NETXEN_CAM_RAM(0x1fc)); 678 NETXEN_CAM_RAM(0x1fc));
685 679
686 err = netxen_check_hw_init(adapter, first_boot); 680 err = netxen_check_hw_init(adapter, first_boot);
@@ -690,7 +684,7 @@ netxen_start_firmware(struct netxen_adapter *adapter)
690 } 684 }
691 685
692 if (first_boot != 0x55555555) { 686 if (first_boot != 0x55555555) {
693 adapter->pci_write_normalize(adapter, 687 adapter->hw_write_wx(adapter,
694 CRB_CMDPEG_STATE, 0); 688 CRB_CMDPEG_STATE, 0);
695 netxen_pinit_from_rom(adapter, 0); 689 netxen_pinit_from_rom(adapter, 0);
696 msleep(1); 690 msleep(1);
@@ -723,7 +717,7 @@ netxen_start_firmware(struct netxen_adapter *adapter)
723 val = (_NETXEN_NIC_LINUX_MAJOR << 16) 717 val = (_NETXEN_NIC_LINUX_MAJOR << 16)
724 | ((_NETXEN_NIC_LINUX_MINOR << 8)) 718 | ((_NETXEN_NIC_LINUX_MINOR << 8))
725 | (_NETXEN_NIC_LINUX_SUBVERSION); 719 | (_NETXEN_NIC_LINUX_SUBVERSION);
726 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, val); 720 adapter->hw_write_wx(adapter, CRB_DRIVER_VERSION, val);
727 721
728 /* Handshake with the card before we register the devices. */ 722 /* Handshake with the card before we register the devices. */
729 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 723 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
@@ -1038,7 +1032,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1038 */ 1032 */
1039 adapter->physical_port = adapter->portnum; 1033 adapter->physical_port = adapter->portnum;
1040 if (adapter->fw_major < 4) { 1034 if (adapter->fw_major < 4) {
1041 i = adapter->pci_read_normalize(adapter, 1035 i = adapter->hw_read_wx(adapter,
1042 CRB_V2P(adapter->portnum)); 1036 CRB_V2P(adapter->portnum));
1043 if (i != 0x55555555) 1037 if (i != 0x55555555)
1044 adapter->physical_port = i; 1038 adapter->physical_port = i;
@@ -1486,7 +1480,7 @@ static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1486 uint32_t temp, temp_state, temp_val; 1480 uint32_t temp, temp_state, temp_val;
1487 int rv = 0; 1481 int rv = 0;
1488 1482
1489 temp = adapter->pci_read_normalize(adapter, CRB_TEMP_STATE); 1483 temp = adapter->hw_read_wx(adapter, CRB_TEMP_STATE);
1490 1484
1491 temp_state = nx_get_temp_state(temp); 1485 temp_state = nx_get_temp_state(temp);
1492 temp_val = nx_get_temp_val(temp); 1486 temp_val = nx_get_temp_val(temp);
@@ -1557,11 +1551,11 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1557 port = adapter->physical_port; 1551 port = adapter->physical_port;
1558 1552
1559 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 1553 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
1560 val = adapter->pci_read_normalize(adapter, CRB_XG_STATE_P3); 1554 val = adapter->hw_read_wx(adapter, CRB_XG_STATE_P3);
1561 val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val); 1555 val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
1562 linkup = (val == XG_LINK_UP_P3); 1556 linkup = (val == XG_LINK_UP_P3);
1563 } else { 1557 } else {
1564 val = adapter->pci_read_normalize(adapter, CRB_XG_STATE); 1558 val = adapter->hw_read_wx(adapter, CRB_XG_STATE);
1565 if (adapter->ahw.port_type == NETXEN_NIC_GBE) 1559 if (adapter->ahw.port_type == NETXEN_NIC_GBE)
1566 linkup = (val >> port) & 1; 1560 linkup = (val >> port) & 1;
1567 else { 1561 else {
@@ -1656,14 +1650,14 @@ static irqreturn_t netxen_intr(int irq, void *data)
1656 } else { 1650 } else {
1657 unsigned long our_int = 0; 1651 unsigned long our_int = 0;
1658 1652
1659 our_int = adapter->pci_read_normalize(adapter, CRB_INT_VECTOR); 1653 our_int = adapter->hw_read_wx(adapter, CRB_INT_VECTOR);
1660 1654
1661 /* not our interrupt */ 1655 /* not our interrupt */
1662 if (!test_and_clear_bit((7 + adapter->portnum), &our_int)) 1656 if (!test_and_clear_bit((7 + adapter->portnum), &our_int))
1663 return IRQ_NONE; 1657 return IRQ_NONE;
1664 1658
1665 /* claim interrupt */ 1659 /* claim interrupt */
1666 adapter->pci_write_normalize(adapter, 1660 adapter->hw_write_wx(adapter,
1667 CRB_INT_VECTOR, (our_int & 0xffffffff)); 1661 CRB_INT_VECTOR, (our_int & 0xffffffff));
1668 } 1662 }
1669 1663
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index 3310471ba1a0..b54a63a64e7b 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -105,9 +105,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
105 * so it cannot be in reset 105 * so it cannot be in reset
106 */ 106 */
107 107
108 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), 108 mac_cfg0 = adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0));
109 &mac_cfg0, 4))
110 return -EIO;
111 if (netxen_gb_get_soft_reset(mac_cfg0)) { 109 if (netxen_gb_get_soft_reset(mac_cfg0)) {
112 __u32 temp; 110 __u32 temp;
113 temp = 0; 111 temp = 0;
@@ -116,8 +114,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
116 netxen_gb_tx_reset_mac(temp); 114 netxen_gb_tx_reset_mac(temp);
117 netxen_gb_rx_reset_mac(temp); 115 netxen_gb_rx_reset_mac(temp);
118 if (adapter->hw_write_wx(adapter, 116 if (adapter->hw_write_wx(adapter,
119 NETXEN_NIU_GB_MAC_CONFIG_0(0), 117 NETXEN_NIU_GB_MAC_CONFIG_0(0), temp))
120 &temp, 4))
121 return -EIO; 118 return -EIO;
122 restore = 1; 119 restore = 1;
123 } 120 }
@@ -125,43 +122,38 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
125 address = 0; 122 address = 0;
126 netxen_gb_mii_mgmt_reg_addr(address, reg); 123 netxen_gb_mii_mgmt_reg_addr(address, reg);
127 netxen_gb_mii_mgmt_phy_addr(address, phy); 124 netxen_gb_mii_mgmt_phy_addr(address, phy);
128 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0), 125 if (adapter->hw_write_wx(adapter,
129 &address, 4)) 126 NETXEN_NIU_GB_MII_MGMT_ADDR(0), address))
130 return -EIO; 127 return -EIO;
131 command = 0; /* turn off any prior activity */ 128 command = 0; /* turn off any prior activity */
132 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), 129 if (adapter->hw_write_wx(adapter,
133 &command, 4)) 130 NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
134 return -EIO; 131 return -EIO;
135 /* send read command */ 132 /* send read command */
136 netxen_gb_mii_mgmt_set_read_cycle(command); 133 netxen_gb_mii_mgmt_set_read_cycle(command);
137 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), 134 if (adapter->hw_write_wx(adapter,
138 &command, 4)) 135 NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
139 return -EIO; 136 return -EIO;
140 137
141 status = 0; 138 status = 0;
142 do { 139 do {
143 if (adapter->hw_read_wx(adapter, 140 status = adapter->hw_read_wx(adapter,
144 NETXEN_NIU_GB_MII_MGMT_INDICATE(0), 141 NETXEN_NIU_GB_MII_MGMT_INDICATE(0));
145 &status, 4))
146 return -EIO;
147 timeout++; 142 timeout++;
148 } while ((netxen_get_gb_mii_mgmt_busy(status) 143 } while ((netxen_get_gb_mii_mgmt_busy(status)
149 || netxen_get_gb_mii_mgmt_notvalid(status)) 144 || netxen_get_gb_mii_mgmt_notvalid(status))
150 && (timeout++ < NETXEN_NIU_PHY_WAITMAX)); 145 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
151 146
152 if (timeout < NETXEN_NIU_PHY_WAITMAX) { 147 if (timeout < NETXEN_NIU_PHY_WAITMAX) {
153 if (adapter->hw_read_wx(adapter, 148 *readval = adapter->hw_read_wx(adapter,
154 NETXEN_NIU_GB_MII_MGMT_STATUS(0), 149 NETXEN_NIU_GB_MII_MGMT_STATUS(0));
155 readval, 4))
156 return -EIO;
157 result = 0; 150 result = 0;
158 } else 151 } else
159 result = -1; 152 result = -1;
160 153
161 if (restore) 154 if (restore)
162 if (adapter->hw_write_wx(adapter, 155 if (adapter->hw_write_wx(adapter,
163 NETXEN_NIU_GB_MAC_CONFIG_0(0), 156 NETXEN_NIU_GB_MAC_CONFIG_0(0), mac_cfg0))
164 &mac_cfg0, 4))
165 return -EIO; 157 return -EIO;
166 phy_unlock(adapter); 158 phy_unlock(adapter);
167 return result; 159 return result;
@@ -197,9 +189,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
197 * cannot be in reset 189 * cannot be in reset
198 */ 190 */
199 191
200 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), 192 mac_cfg0 = adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0));
201 &mac_cfg0, 4))
202 return -EIO;
203 if (netxen_gb_get_soft_reset(mac_cfg0)) { 193 if (netxen_gb_get_soft_reset(mac_cfg0)) {
204 __u32 temp; 194 __u32 temp;
205 temp = 0; 195 temp = 0;
@@ -209,34 +199,31 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
209 netxen_gb_rx_reset_mac(temp); 199 netxen_gb_rx_reset_mac(temp);
210 200
211 if (adapter->hw_write_wx(adapter, 201 if (adapter->hw_write_wx(adapter,
212 NETXEN_NIU_GB_MAC_CONFIG_0(0), 202 NETXEN_NIU_GB_MAC_CONFIG_0(0), temp))
213 &temp, 4))
214 return -EIO; 203 return -EIO;
215 restore = 1; 204 restore = 1;
216 } 205 }
217 206
218 command = 0; /* turn off any prior activity */ 207 command = 0; /* turn off any prior activity */
219 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), 208 if (adapter->hw_write_wx(adapter,
220 &command, 4)) 209 NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
221 return -EIO; 210 return -EIO;
222 211
223 address = 0; 212 address = 0;
224 netxen_gb_mii_mgmt_reg_addr(address, reg); 213 netxen_gb_mii_mgmt_reg_addr(address, reg);
225 netxen_gb_mii_mgmt_phy_addr(address, phy); 214 netxen_gb_mii_mgmt_phy_addr(address, phy);
226 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0), 215 if (adapter->hw_write_wx(adapter,
227 &address, 4)) 216 NETXEN_NIU_GB_MII_MGMT_ADDR(0), address))
228 return -EIO; 217 return -EIO;
229 218
230 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0), 219 if (adapter->hw_write_wx(adapter,
231 &val, 4)) 220 NETXEN_NIU_GB_MII_MGMT_CTRL(0), val))
232 return -EIO; 221 return -EIO;
233 222
234 status = 0; 223 status = 0;
235 do { 224 do {
236 if (adapter->hw_read_wx(adapter, 225 status = adapter->hw_read_wx(adapter,
237 NETXEN_NIU_GB_MII_MGMT_INDICATE(0), 226 NETXEN_NIU_GB_MII_MGMT_INDICATE(0));
238 &status, 4))
239 return -EIO;
240 timeout++; 227 timeout++;
241 } while ((netxen_get_gb_mii_mgmt_busy(status)) 228 } while ((netxen_get_gb_mii_mgmt_busy(status))
242 && (timeout++ < NETXEN_NIU_PHY_WAITMAX)); 229 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
@@ -249,8 +236,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
249 /* restore the state of port 0 MAC in case we tampered with it */ 236 /* restore the state of port 0 MAC in case we tampered with it */
250 if (restore) 237 if (restore)
251 if (adapter->hw_write_wx(adapter, 238 if (adapter->hw_write_wx(adapter,
252 NETXEN_NIU_GB_MAC_CONFIG_0(0), 239 NETXEN_NIU_GB_MAC_CONFIG_0(0), mac_cfg0))
253 &mac_cfg0, 4))
254 return -EIO; 240 return -EIO;
255 241
256 return result; 242 return result;
@@ -473,12 +459,10 @@ static int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
473 if ((phy < 0) || (phy > 3)) 459 if ((phy < 0) || (phy > 3))
474 return -EINVAL; 460 return -EINVAL;
475 461
476 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), 462 stationhigh = adapter->hw_read_wx(adapter,
477 &stationhigh, 4)) 463 NETXEN_NIU_GB_STATION_ADDR_0(phy));
478 return -EIO; 464 stationlow = adapter->hw_read_wx(adapter,
479 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), 465 NETXEN_NIU_GB_STATION_ADDR_1(phy));
480 &stationlow, 4))
481 return -EIO;
482 ((__le32 *)val)[1] = cpu_to_le32(stationhigh); 466 ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
483 ((__le32 *)val)[0] = cpu_to_le32(stationlow); 467 ((__le32 *)val)[0] = cpu_to_le32(stationlow);
484 468
@@ -508,13 +492,13 @@ int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
508 memcpy(temp + 2, addr, 2); 492 memcpy(temp + 2, addr, 2);
509 val = le32_to_cpu(*(__le32 *)temp); 493 val = le32_to_cpu(*(__le32 *)temp);
510 if (adapter->hw_write_wx(adapter, 494 if (adapter->hw_write_wx(adapter,
511 NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4)) 495 NETXEN_NIU_GB_STATION_ADDR_1(phy), val))
512 return -EIO; 496 return -EIO;
513 497
514 memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32)); 498 memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
515 val = le32_to_cpu(*(__le32 *)temp); 499 val = le32_to_cpu(*(__le32 *)temp);
516 if (adapter->hw_write_wx(adapter, 500 if (adapter->hw_write_wx(adapter,
517 NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4)) 501 NETXEN_NIU_GB_STATION_ADDR_0(phy), val))
518 return -2; 502 return -2;
519 503
520 netxen_niu_macaddr_get(adapter, 504 netxen_niu_macaddr_get(adapter,
@@ -545,8 +529,8 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
545 return -EINVAL; 529 return -EINVAL;
546 mac_cfg0 = 0; 530 mac_cfg0 = 0;
547 netxen_gb_soft_reset(mac_cfg0); 531 netxen_gb_soft_reset(mac_cfg0);
548 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 532 if (adapter->hw_write_wx(adapter,
549 &mac_cfg0, 4)) 533 NETXEN_NIU_GB_MAC_CONFIG_0(port), mac_cfg0))
550 return -EIO; 534 return -EIO;
551 return 0; 535 return 0;
552} 536}
@@ -565,7 +549,7 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
565 549
566 mac_cfg = 0; 550 mac_cfg = 0;
567 if (adapter->hw_write_wx(adapter, 551 if (adapter->hw_write_wx(adapter,
568 NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), &mac_cfg, 4)) 552 NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), mac_cfg))
569 return -EIO; 553 return -EIO;
570 return 0; 554 return 0;
571} 555}
@@ -581,9 +565,7 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
581 return -EINVAL; 565 return -EINVAL;
582 566
583 /* save previous contents */ 567 /* save previous contents */
584 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, 568 reg = adapter->hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR);
585 &reg, 4))
586 return -EIO;
587 if (mode == NETXEN_NIU_PROMISC_MODE) { 569 if (mode == NETXEN_NIU_PROMISC_MODE) {
588 switch (port) { 570 switch (port) {
589 case 0: 571 case 0:
@@ -619,8 +601,7 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
619 return -EIO; 601 return -EIO;
620 } 602 }
621 } 603 }
622 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, 604 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, reg))
623 &reg, 4))
624 return -EIO; 605 return -EIO;
625 return 0; 606 return 0;
626} 607}
@@ -647,28 +628,28 @@ int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
647 case 0: 628 case 0:
648 memcpy(temp + 2, addr, 2); 629 memcpy(temp + 2, addr, 2);
649 val = le32_to_cpu(*(__le32 *)temp); 630 val = le32_to_cpu(*(__le32 *)temp);
650 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, 631 if (adapter->hw_write_wx(adapter,
651 &val, 4)) 632 NETXEN_NIU_XGE_STATION_ADDR_0_1, val))
652 return -EIO; 633 return -EIO;
653 634
654 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); 635 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
655 val = le32_to_cpu(*(__le32 *)temp); 636 val = le32_to_cpu(*(__le32 *)temp);
656 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI, 637 if (adapter->hw_write_wx(adapter,
657 &val, 4)) 638 NETXEN_NIU_XGE_STATION_ADDR_0_HI, val))
658 return -EIO; 639 return -EIO;
659 break; 640 break;
660 641
661 case 1: 642 case 1:
662 memcpy(temp + 2, addr, 2); 643 memcpy(temp + 2, addr, 2);
663 val = le32_to_cpu(*(__le32 *)temp); 644 val = le32_to_cpu(*(__le32 *)temp);
664 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_1, 645 if (adapter->hw_write_wx(adapter,
665 &val, 4)) 646 NETXEN_NIU_XG1_STATION_ADDR_0_1, val))
666 return -EIO; 647 return -EIO;
667 648
668 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); 649 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
669 val = le32_to_cpu(*(__le32 *)temp); 650 val = le32_to_cpu(*(__le32 *)temp);
670 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_HI, 651 if (adapter->hw_write_wx(adapter,
671 &val, 4)) 652 NETXEN_NIU_XG1_STATION_ADDR_0_HI, val))
672 return -EIO; 653 return -EIO;
673 break; 654 break;
674 655
@@ -689,9 +670,8 @@ int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
689 if (port > NETXEN_NIU_MAX_XG_PORTS) 670 if (port > NETXEN_NIU_MAX_XG_PORTS)
690 return -EINVAL; 671 return -EINVAL;
691 672
692 if (adapter->hw_read_wx(adapter, 673 reg = adapter->hw_read_wx(adapter,
693 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), &reg, 4)) 674 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port));
694 return -EIO;
695 if (mode == NETXEN_NIU_PROMISC_MODE) 675 if (mode == NETXEN_NIU_PROMISC_MODE)
696 reg = (reg | 0x2000UL); 676 reg = (reg | 0x2000UL);
697 else 677 else