diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2009-10-13 01:31:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-13 14:48:20 -0400 |
commit | 907fa1201c76f426a13bdff5be2747fb62c2353f (patch) | |
tree | 2bffcd1f472f03f9a294e0e4b16bbac705b52ba6 /drivers | |
parent | 47abe35610cbbfb3cc92847efdf588a8be1f5ebc (diff) |
netxen: annotate register windowing code
Use common variables crb_win, ocm_win for all revisions of chip.
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 4 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 100 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 4 |
3 files changed, 51 insertions, 57 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index eef9e66becbd..2a42132b9799 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -549,7 +549,7 @@ struct netxen_hardware_context { | |||
549 | unsigned long pci_len0; | 549 | unsigned long pci_len0; |
550 | 550 | ||
551 | u32 ocm_win; | 551 | u32 ocm_win; |
552 | u32 resv1; | 552 | u32 crb_win; |
553 | 553 | ||
554 | u8 cut_through; | 554 | u8 cut_through; |
555 | u8 revision_id; | 555 | u8 revision_id; |
@@ -1115,8 +1115,6 @@ struct netxen_adapter { | |||
1115 | struct pci_dev *pdev; | 1115 | struct pci_dev *pdev; |
1116 | struct list_head mac_list; | 1116 | struct list_head mac_list; |
1117 | 1117 | ||
1118 | u32 curr_window; | ||
1119 | u32 crb_win; | ||
1120 | rwlock_t adapter_lock; | 1118 | rwlock_t adapter_lock; |
1121 | 1119 | ||
1122 | spinlock_t tx_clean_lock; | 1120 | spinlock_t tx_clean_lock; |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index f677752dbe22..37f47660dcdd 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -1046,46 +1046,34 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac) | |||
1046 | * Changes the CRB window to the specified window. | 1046 | * Changes the CRB window to the specified window. |
1047 | */ | 1047 | */ |
1048 | static void | 1048 | static void |
1049 | netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter, u32 wndw) | 1049 | netxen_nic_pci_set_crbwindow_128M(struct netxen_adapter *adapter, |
1050 | u32 window) | ||
1050 | { | 1051 | { |
1051 | void __iomem *offset; | 1052 | void __iomem *offset; |
1052 | u32 tmp; | 1053 | int count = 10; |
1053 | int count = 0; | 1054 | u8 func = adapter->ahw.pci_func; |
1054 | uint8_t func = adapter->ahw.pci_func; | ||
1055 | 1055 | ||
1056 | if (adapter->curr_window == wndw) | 1056 | if (adapter->ahw.crb_win == window) |
1057 | return; | 1057 | return; |
1058 | /* | 1058 | |
1059 | * Move the CRB window. | ||
1060 | * We need to write to the "direct access" region of PCI | ||
1061 | * to avoid a race condition where the window register has | ||
1062 | * not been successfully written across CRB before the target | ||
1063 | * register address is received by PCI. The direct region bypasses | ||
1064 | * the CRB bus. | ||
1065 | */ | ||
1066 | offset = PCI_OFFSET_SECOND_RANGE(adapter, | 1059 | offset = PCI_OFFSET_SECOND_RANGE(adapter, |
1067 | NETXEN_PCIX_PH_REG(PCIE_CRB_WINDOW_REG(func))); | 1060 | NETXEN_PCIX_PH_REG(PCIE_CRB_WINDOW_REG(func))); |
1068 | 1061 | ||
1069 | if (wndw & 0x1) | 1062 | writel(window, offset); |
1070 | wndw = NETXEN_WINDOW_ONE; | 1063 | do { |
1064 | if (window == readl(offset)) | ||
1065 | break; | ||
1071 | 1066 | ||
1072 | writel(wndw, offset); | 1067 | if (printk_ratelimit()) |
1068 | dev_warn(&adapter->pdev->dev, | ||
1069 | "failed to set CRB window to %d\n", | ||
1070 | (window == NETXEN_WINDOW_ONE)); | ||
1071 | udelay(1); | ||
1073 | 1072 | ||
1074 | /* MUST make sure window is set before we forge on... */ | 1073 | } while (--count > 0); |
1075 | while ((tmp = readl(offset)) != wndw) { | ||
1076 | printk(KERN_WARNING "%s: %s WARNING: CRB window value not " | ||
1077 | "registered properly: 0x%08x.\n", | ||
1078 | netxen_nic_driver_name, __func__, tmp); | ||
1079 | mdelay(1); | ||
1080 | if (count >= 10) | ||
1081 | break; | ||
1082 | count++; | ||
1083 | } | ||
1084 | 1074 | ||
1085 | if (wndw == NETXEN_WINDOW_ONE) | 1075 | if (count > 0) |
1086 | adapter->curr_window = 1; | 1076 | adapter->ahw.crb_win = window; |
1087 | else | ||
1088 | adapter->curr_window = 0; | ||
1089 | } | 1077 | } |
1090 | 1078 | ||
1091 | /* | 1079 | /* |
@@ -1140,20 +1128,24 @@ netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter, ulong *off) | |||
1140 | static void | 1128 | static void |
1141 | netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong *off) | 1129 | netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong *off) |
1142 | { | 1130 | { |
1143 | u32 win_read; | 1131 | u32 window; |
1132 | void __iomem *addr = adapter->ahw.pci_base0 + CRB_WINDOW_2M; | ||
1144 | 1133 | ||
1145 | adapter->crb_win = CRB_HI(*off); | 1134 | window = CRB_HI(*off); |
1146 | writel(adapter->crb_win, (adapter->ahw.pci_base0 + CRB_WINDOW_2M)); | 1135 | |
1147 | /* | 1136 | if (adapter->ahw.crb_win == window) |
1148 | * Read back value to make sure write has gone through before trying | 1137 | goto done; |
1149 | * to use it. | 1138 | |
1150 | */ | 1139 | writel(window, addr); |
1151 | win_read = readl(adapter->ahw.pci_base0 + CRB_WINDOW_2M); | 1140 | if (readl(addr) != window) { |
1152 | if (win_read != adapter->crb_win) { | 1141 | if (printk_ratelimit()) |
1153 | printk(KERN_ERR "%s: Written crbwin (0x%x) != " | 1142 | dev_warn(&adapter->pdev->dev, |
1154 | "Read crbwin (0x%x), off=0x%lx\n", | 1143 | "failed to set CRB window to %d off 0x%lx\n", |
1155 | __func__, adapter->crb_win, win_read, *off); | 1144 | window, *off); |
1156 | } | 1145 | } |
1146 | adapter->ahw.crb_win = window; | ||
1147 | |||
1148 | done: | ||
1157 | *off = (*off & MASK(16)) + CRB_INDIRECT_2M + | 1149 | *off = (*off & MASK(16)) + CRB_INDIRECT_2M + |
1158 | (ulong)adapter->ahw.pci_base0; | 1150 | (ulong)adapter->ahw.pci_base0; |
1159 | } | 1151 | } |
@@ -1178,9 +1170,10 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data) | |||
1178 | } else { /* Window 0 */ | 1170 | } else { /* Window 0 */ |
1179 | write_lock_irqsave(&adapter->adapter_lock, flags); | 1171 | write_lock_irqsave(&adapter->adapter_lock, flags); |
1180 | addr = pci_base_offset(adapter, off); | 1172 | addr = pci_base_offset(adapter, off); |
1181 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); | 1173 | netxen_nic_pci_set_crbwindow_128M(adapter, 0); |
1182 | writel(data, addr); | 1174 | writel(data, addr); |
1183 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); | 1175 | netxen_nic_pci_set_crbwindow_128M(adapter, |
1176 | NETXEN_WINDOW_ONE); | ||
1184 | write_unlock_irqrestore(&adapter->adapter_lock, flags); | 1177 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
1185 | } | 1178 | } |
1186 | 1179 | ||
@@ -1207,9 +1200,10 @@ netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off) | |||
1207 | read_unlock(&adapter->adapter_lock); | 1200 | read_unlock(&adapter->adapter_lock); |
1208 | } else { /* Window 0 */ | 1201 | } else { /* Window 0 */ |
1209 | write_lock_irqsave(&adapter->adapter_lock, flags); | 1202 | write_lock_irqsave(&adapter->adapter_lock, flags); |
1210 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); | 1203 | netxen_nic_pci_set_crbwindow_128M(adapter, 0); |
1211 | data = readl(addr); | 1204 | data = readl(addr); |
1212 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); | 1205 | netxen_nic_pci_set_crbwindow_128M(adapter, |
1206 | NETXEN_WINDOW_ONE); | ||
1213 | write_unlock_irqrestore(&adapter->adapter_lock, flags); | 1207 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
1214 | } | 1208 | } |
1215 | 1209 | ||
@@ -1460,7 +1454,7 @@ netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, | |||
1460 | 1454 | ||
1461 | correct: | 1455 | correct: |
1462 | write_lock_irqsave(&adapter->adapter_lock, flags); | 1456 | write_lock_irqsave(&adapter->adapter_lock, flags); |
1463 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); | 1457 | netxen_nic_pci_set_crbwindow_128M(adapter, 0); |
1464 | 1458 | ||
1465 | writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO)); | 1459 | writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO)); |
1466 | writel(off_hi, (mem_crb + addr_hi)); | 1460 | writel(off_hi, (mem_crb + addr_hi)); |
@@ -1484,7 +1478,7 @@ correct: | |||
1484 | } else | 1478 | } else |
1485 | ret = 0; | 1479 | ret = 0; |
1486 | 1480 | ||
1487 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); | 1481 | netxen_nic_pci_set_crbwindow_128M(adapter, NETXEN_WINDOW_ONE); |
1488 | write_unlock_irqrestore(&adapter->adapter_lock, flags); | 1482 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
1489 | return ret; | 1483 | return ret; |
1490 | } | 1484 | } |
@@ -1539,7 +1533,7 @@ netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, | |||
1539 | 1533 | ||
1540 | correct: | 1534 | correct: |
1541 | write_lock_irqsave(&adapter->adapter_lock, flags); | 1535 | write_lock_irqsave(&adapter->adapter_lock, flags); |
1542 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); | 1536 | netxen_nic_pci_set_crbwindow_128M(adapter, 0); |
1543 | 1537 | ||
1544 | writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO)); | 1538 | writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO)); |
1545 | writel(off_hi, (mem_crb + addr_hi)); | 1539 | writel(off_hi, (mem_crb + addr_hi)); |
@@ -1566,7 +1560,7 @@ correct: | |||
1566 | ret = 0; | 1560 | ret = 0; |
1567 | } | 1561 | } |
1568 | 1562 | ||
1569 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); | 1563 | netxen_nic_pci_set_crbwindow_128M(adapter, NETXEN_WINDOW_ONE); |
1570 | write_unlock_irqrestore(&adapter->adapter_lock, flags); | 1564 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
1571 | 1565 | ||
1572 | return ret; | 1566 | return ret; |
@@ -1664,8 +1658,10 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, | |||
1664 | goto correct; | 1658 | goto correct; |
1665 | } | 1659 | } |
1666 | 1660 | ||
1667 | if (ADDR_IN_RANGE(off, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) | 1661 | if (ADDR_IN_RANGE(off, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) { |
1668 | return netxen_nic_pci_mem_access_direct(adapter, off, data, 0); | 1662 | return netxen_nic_pci_mem_access_direct(adapter, |
1663 | off, data, 0); | ||
1664 | } | ||
1669 | 1665 | ||
1670 | return -EIO; | 1666 | return -EIO; |
1671 | 1667 | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index b7f607061865..6695e5473027 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -606,7 +606,7 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) | |||
606 | * Set the CRB window to invalid. If any register in window 0 is | 606 | * Set the CRB window to invalid. If any register in window 0 is |
607 | * accessed it should set the window to 0 and then reset it to 1. | 607 | * accessed it should set the window to 0 and then reset it to 1. |
608 | */ | 608 | */ |
609 | adapter->curr_window = 255; | 609 | adapter->ahw.crb_win = -1; |
610 | adapter->ahw.ocm_win = -1; | 610 | adapter->ahw.ocm_win = -1; |
611 | 611 | ||
612 | /* remap phys address */ | 612 | /* remap phys address */ |
@@ -1437,7 +1437,7 @@ netxen_nic_resume(struct pci_dev *pdev) | |||
1437 | if (err) | 1437 | if (err) |
1438 | return err; | 1438 | return err; |
1439 | 1439 | ||
1440 | adapter->curr_window = 255; | 1440 | adapter->ahw.crb_win = -1; |
1441 | adapter->ahw.ocm_win = -1; | 1441 | adapter->ahw.ocm_win = -1; |
1442 | 1442 | ||
1443 | err = netxen_start_firmware(adapter); | 1443 | err = netxen_start_firmware(adapter); |