aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarender Kumar <narender.kumar@qlogic.com>2009-12-02 10:46:18 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-02 22:57:18 -0500
commitf58dbd7320e148b25cc0088ef37f524c99c6790f (patch)
tree9396794ba9af5c37b18911d79694762ff9ce6b26
parent0be8401051c716be4533272e983b7eed3d83946d (diff)
netxen : fix debug tools access for NX2031
Driver maps only some part of the MMIO bar 0 in case of NX2031. This is sufficient for tx and rx by the driver. When debug tools need to access resources in unmapped regions, driver needs to map these on the fly in order to complete read/write request. Signed-off-by: Narender Kumar <narender.kumar@qlogic.com> Signed-off-by: Dhananjay Phadke <dhananjay.phadke@qlogic.com> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c63
1 files changed, 44 insertions, 19 deletions
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index e71ca30433ef..89bd5194e37a 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -1175,24 +1175,46 @@ netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong off)
1175 adapter->ahw.crb_win = window; 1175 adapter->ahw.crb_win = window;
1176} 1176}
1177 1177
1178static void __iomem *
1179netxen_nic_map_indirect_address_128M(struct netxen_adapter *adapter,
1180 ulong win_off, void __iomem **mem_ptr)
1181{
1182 ulong off = win_off;
1183 void __iomem *addr;
1184 resource_size_t mem_base;
1185
1186 if (ADDR_IN_WINDOW1(win_off))
1187 off = NETXEN_CRB_NORMAL(win_off);
1188
1189 addr = pci_base_offset(adapter, off);
1190 if (addr)
1191 return addr;
1192
1193 if (adapter->ahw.pci_len0 == 0)
1194 off -= NETXEN_PCI_CRBSPACE;
1195
1196 mem_base = pci_resource_start(adapter->pdev, 0);
1197 *mem_ptr = ioremap(mem_base + (off & PAGE_MASK), PAGE_SIZE);
1198 if (*mem_ptr)
1199 addr = *mem_ptr + (off & (PAGE_SIZE - 1));
1200
1201 return addr;
1202}
1203
1178static int 1204static int
1179netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data) 1205netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data)
1180{ 1206{
1181 unsigned long flags; 1207 unsigned long flags;
1182 void __iomem *addr; 1208 void __iomem *addr, *mem_ptr = NULL;
1183
1184 if (ADDR_IN_WINDOW1(off))
1185 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1186 else
1187 addr = pci_base_offset(adapter, off);
1188 1209
1189 BUG_ON(!addr); 1210 addr = netxen_nic_map_indirect_address_128M(adapter, off, &mem_ptr);
1211 if (!addr)
1212 return -EIO;
1190 1213
1191 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ 1214 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
1192 netxen_nic_io_write_128M(adapter, addr, data); 1215 netxen_nic_io_write_128M(adapter, addr, data);
1193 } else { /* Window 0 */ 1216 } else { /* Window 0 */
1194 write_lock_irqsave(&adapter->ahw.crb_lock, flags); 1217 write_lock_irqsave(&adapter->ahw.crb_lock, flags);
1195 addr = pci_base_offset(adapter, off);
1196 netxen_nic_pci_set_crbwindow_128M(adapter, 0); 1218 netxen_nic_pci_set_crbwindow_128M(adapter, 0);
1197 writel(data, addr); 1219 writel(data, addr);
1198 netxen_nic_pci_set_crbwindow_128M(adapter, 1220 netxen_nic_pci_set_crbwindow_128M(adapter,
@@ -1200,6 +1222,9 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data)
1200 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags); 1222 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
1201 } 1223 }
1202 1224
1225 if (mem_ptr)
1226 iounmap(mem_ptr);
1227
1203 return 0; 1228 return 0;
1204} 1229}
1205 1230
@@ -1207,19 +1232,16 @@ static u32
1207netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off) 1232netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off)
1208{ 1233{
1209 unsigned long flags; 1234 unsigned long flags;
1210 void __iomem *addr; 1235 void __iomem *addr, *mem_ptr = NULL;
1211 u32 data; 1236 u32 data;
1212 1237
1213 if (ADDR_IN_WINDOW1(off)) 1238 addr = netxen_nic_map_indirect_address_128M(adapter, off, &mem_ptr);
1214 addr = NETXEN_CRB_NORMALIZE(adapter, off); 1239 if (!addr)
1215 else 1240 return -EIO;
1216 addr = pci_base_offset(adapter, off);
1217
1218 BUG_ON(!addr);
1219 1241
1220 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ 1242 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
1221 data = netxen_nic_io_read_128M(adapter, addr); 1243 data = netxen_nic_io_read_128M(adapter, addr);
1222 } else { /* Window 0 */ 1244 } else { /* Window 0 */
1223 write_lock_irqsave(&adapter->ahw.crb_lock, flags); 1245 write_lock_irqsave(&adapter->ahw.crb_lock, flags);
1224 netxen_nic_pci_set_crbwindow_128M(adapter, 0); 1246 netxen_nic_pci_set_crbwindow_128M(adapter, 0);
1225 data = readl(addr); 1247 data = readl(addr);
@@ -1228,6 +1250,9 @@ netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off)
1228 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags); 1250 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
1229 } 1251 }
1230 1252
1253 if (mem_ptr)
1254 iounmap(mem_ptr);
1255
1231 return data; 1256 return data;
1232} 1257}
1233 1258