aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_main.c
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2008-07-21 22:44:03 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-22 17:51:44 -0400
commit3ce06a320f8d5a3f16960e63021cc372283efffb (patch)
treecea5b02fc44b8c2367c57d7c249592683edffcc9 /drivers/net/netxen/netxen_nic_main.c
parente4c93c817ce650401db42db6c869cf7688217ff4 (diff)
netxen: add 2MB PCI memory support
New revision of netxen chip has 2MB PCI memory. Older chips had 128MB addressable PCI memory. To retain compatibility, this patch adds function pointers based on pci bar0 size. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_main.c')
-rw-r--r--drivers/net/netxen/netxen_nic_main.c138
1 files changed, 87 insertions, 51 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 192a22f89570..72d9f48b80dc 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -114,11 +114,12 @@ static uint32_t crb_cmd_producer[4] = {
114 CRB_CMD_PRODUCER_OFFSET_2, CRB_CMD_PRODUCER_OFFSET_3 114 CRB_CMD_PRODUCER_OFFSET_2, CRB_CMD_PRODUCER_OFFSET_3
115}; 115};
116 116
117static void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, 117static inline void
118 uint32_t crb_producer) 118netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
119 uint32_t crb_producer)
119{ 120{
120 writel(crb_producer, NETXEN_CRB_NORMALIZE(adapter, 121 adapter->pci_write_normalize(adapter,
121 adapter->crb_addr_cmd_producer)); 122 adapter->crb_addr_cmd_producer, crb_producer);
122} 123}
123 124
124static uint32_t crb_cmd_consumer[4] = { 125static uint32_t crb_cmd_consumer[4] = {
@@ -126,11 +127,12 @@ static uint32_t crb_cmd_consumer[4] = {
126 CRB_CMD_CONSUMER_OFFSET_2, CRB_CMD_CONSUMER_OFFSET_3 127 CRB_CMD_CONSUMER_OFFSET_2, CRB_CMD_CONSUMER_OFFSET_3
127}; 128};
128 129
129static void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter, 130static inline void
130 u32 crb_consumer) 131netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
132 u32 crb_consumer)
131{ 133{
132 writel(crb_consumer, NETXEN_CRB_NORMALIZE(adapter, 134 adapter->pci_write_normalize(adapter,
133 adapter->crb_addr_cmd_consumer)); 135 adapter->crb_addr_cmd_consumer, crb_consumer);
134} 136}
135 137
136static uint32_t msi_tgt_status[4] = { 138static uint32_t msi_tgt_status[4] = {
@@ -151,17 +153,18 @@ static void netxen_nic_disable_int(struct netxen_adapter *adapter)
151 int pci_fn = adapter->ahw.pci_func; 153 int pci_fn = adapter->ahw.pci_func;
152 154
153 if (adapter->msi_mode != MSI_MODE_MULTIFUNC) 155 if (adapter->msi_mode != MSI_MODE_MULTIFUNC)
154 writel(0x0, NETXEN_CRB_NORMALIZE(adapter, sw_int_mask[port])); 156 adapter->pci_write_normalize(adapter, sw_int_mask[port], 0);
155 157
156 if (adapter->intr_scheme != -1 && 158 if (adapter->intr_scheme != -1 &&
157 adapter->intr_scheme != INTR_SCHEME_PERPORT) 159 adapter->intr_scheme != INTR_SCHEME_PERPORT)
158 writel(mask,PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)); 160 adapter->pci_write_immediate(adapter, ISR_INT_MASK, mask);
159 161
160 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 162 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
161 do { 163 do {
162 writel(0xffffffff, 164 adapter->pci_write_immediate(adapter,
163 PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_STATUS)); 165 ISR_INT_TARGET_STATUS, 0xffffffff);
164 mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR)); 166 mask = adapter->pci_read_immediate(adapter,
167 ISR_INT_VECTOR);
165 if (!(mask & 0x80)) 168 if (!(mask & 0x80))
166 break; 169 break;
167 udelay(10); 170 udelay(10);
@@ -173,8 +176,8 @@ static void netxen_nic_disable_int(struct netxen_adapter *adapter)
173 } 176 }
174 } else { 177 } else {
175 if (adapter->msi_mode == MSI_MODE_MULTIFUNC) { 178 if (adapter->msi_mode == MSI_MODE_MULTIFUNC) {
176 writel(0xffffffff, PCI_OFFSET_SECOND_RANGE(adapter, 179 adapter->pci_write_immediate(adapter,
177 msi_tgt_status[pci_fn])); 180 msi_tgt_status[pci_fn], 0xffffffff);
178 } 181 }
179 } 182 }
180} 183}
@@ -200,19 +203,20 @@ static void netxen_nic_enable_int(struct netxen_adapter *adapter)
200 break; 203 break;
201 } 204 }
202 205
203 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)); 206 adapter->pci_write_immediate(adapter, ISR_INT_MASK, mask);
204 } 207 }
205 208
206 writel(0x1, NETXEN_CRB_NORMALIZE(adapter, sw_int_mask[port])); 209 adapter->pci_write_normalize(adapter, sw_int_mask[port], 0x1);
207 210
208 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 211 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
209 mask = 0xbff; 212 mask = 0xbff;
210 if (adapter->intr_scheme != -1 && 213 if (adapter->intr_scheme != -1 &&
211 adapter->intr_scheme != INTR_SCHEME_PERPORT) { 214 adapter->intr_scheme != INTR_SCHEME_PERPORT) {
212 writel(0X0, NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); 215 adapter->pci_write_normalize(adapter,
216 CRB_INT_VECTOR, 0);
213 } 217 }
214 writel(mask, 218 adapter->pci_write_immediate(adapter,
215 PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK)); 219 ISR_INT_TARGET_MASK, mask);
216 } 220 }
217 221
218 DPRINTK(1, INFO, "Done with enable Int\n"); 222 DPRINTK(1, INFO, "Done with enable Int\n");
@@ -243,7 +247,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
243 247
244 248
245 u8 __iomem *db_ptr = NULL; 249 u8 __iomem *db_ptr = NULL;
246 unsigned long mem_base, mem_len, db_base, db_len; 250 unsigned long mem_base, mem_len, db_base, db_len, pci_len0;
247 int pci_using_dac, i = 0, err; 251 int pci_using_dac, i = 0, err;
248 int ring; 252 int ring;
249 struct netxen_recv_context *recv_ctx = NULL; 253 struct netxen_recv_context *recv_ctx = NULL;
@@ -300,10 +304,24 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
300 adapter = netdev->priv; 304 adapter = netdev->priv;
301 305
302 adapter->ahw.pci_func = pci_func_id; 306 adapter->ahw.pci_func = pci_func_id;
307 rwlock_init(&adapter->adapter_lock);
308 adapter->ahw.qdr_sn_window = -1;
309 adapter->ahw.ddr_mn_window = -1;
303 310
304 /* remap phys address */ 311 /* remap phys address */
305 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ 312 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
306 mem_len = pci_resource_len(pdev, 0); 313 mem_len = pci_resource_len(pdev, 0);
314 pci_len0 = 0;
315
316 adapter->hw_write_wx = netxen_nic_hw_write_wx_128M;
317 adapter->hw_read_wx = netxen_nic_hw_read_wx_128M;
318 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M;
319 adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M;
320 adapter->pci_read_normalize = netxen_nic_pci_read_normalize_128M;
321 adapter->pci_write_normalize = netxen_nic_pci_write_normalize_128M;
322 adapter->pci_set_window = netxen_nic_pci_set_window_128M;
323 adapter->pci_mem_read = netxen_nic_pci_mem_read_128M;
324 adapter->pci_mem_write = netxen_nic_pci_mem_write_128M;
307 325
308 /* 128 Meg of memory */ 326 /* 128 Meg of memory */
309 if (mem_len == NETXEN_PCI_128MB_SIZE) { 327 if (mem_len == NETXEN_PCI_128MB_SIZE) {
@@ -320,21 +338,42 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
320 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); 338 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
321 first_page_group_start = 0; 339 first_page_group_start = 0;
322 first_page_group_end = 0; 340 first_page_group_end = 0;
341 } else if (mem_len == NETXEN_PCI_2MB_SIZE) {
342 adapter->hw_write_wx = netxen_nic_hw_write_wx_2M;
343 adapter->hw_read_wx = netxen_nic_hw_read_wx_2M;
344 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M;
345 adapter->pci_write_immediate =
346 netxen_nic_pci_write_immediate_2M;
347 adapter->pci_read_normalize = netxen_nic_pci_read_normalize_2M;
348 adapter->pci_write_normalize =
349 netxen_nic_pci_write_normalize_2M;
350 adapter->pci_set_window = netxen_nic_pci_set_window_2M;
351 adapter->pci_mem_read = netxen_nic_pci_mem_read_2M;
352 adapter->pci_mem_write = netxen_nic_pci_mem_write_2M;
353
354 mem_ptr0 = ioremap(mem_base, mem_len);
355 pci_len0 = mem_len;
356 first_page_group_start = 0;
357 first_page_group_end = 0;
358
359 adapter->ahw.ddr_mn_window = 0;
360 adapter->ahw.qdr_sn_window = 0;
361
362 adapter->ahw.mn_win_crb = 0x100000 + PCIX_MN_WINDOW +
363 (pci_func_id * 0x20);
364 adapter->ahw.ms_win_crb = 0x100000 + PCIX_SN_WINDOW;
365 if (pci_func_id < 4)
366 adapter->ahw.ms_win_crb += (pci_func_id * 0x20);
367 else
368 adapter->ahw.ms_win_crb +=
369 0xA0 + ((pci_func_id - 4) * 0x10);
323 } else { 370 } else {
324 err = -EIO; 371 err = -EIO;
325 goto err_out_free_netdev; 372 goto err_out_free_netdev;
326 } 373 }
327 374
328 if ((!mem_ptr0 && mem_len == NETXEN_PCI_128MB_SIZE) || 375 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
329 !mem_ptr1 || !mem_ptr2) {
330 DPRINTK(ERR,
331 "Cannot remap adapter memory aborting.:"
332 "0 -> %p, 1 -> %p, 2 -> %p\n",
333 mem_ptr0, mem_ptr1, mem_ptr2);
334 376
335 err = -EIO;
336 goto err_out_iounmap;
337 }
338 db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ 377 db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
339 db_len = pci_resource_len(pdev, 4); 378 db_len = pci_resource_len(pdev, 4);
340 379
@@ -357,6 +396,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
357 DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); 396 DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr);
358 397
359 adapter->ahw.pci_base0 = mem_ptr0; 398 adapter->ahw.pci_base0 = mem_ptr0;
399 adapter->ahw.pci_len0 = pci_len0;
360 adapter->ahw.first_page_group_start = first_page_group_start; 400 adapter->ahw.first_page_group_start = first_page_group_start;
361 adapter->ahw.first_page_group_end = first_page_group_end; 401 adapter->ahw.first_page_group_end = first_page_group_end;
362 adapter->ahw.pci_base1 = mem_ptr1; 402 adapter->ahw.pci_base1 = mem_ptr1;
@@ -520,9 +560,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
520 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); 560 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
521 adapter->ahw.revision_id = pdev->revision; 561 adapter->ahw.revision_id = pdev->revision;
522 562
523 /* make sure Window == 1 */
524 netxen_nic_pci_change_crbwindow(adapter, 1);
525
526 adapter->crb_addr_cmd_producer = crb_cmd_producer[adapter->portnum]; 563 adapter->crb_addr_cmd_producer = crb_cmd_producer[adapter->portnum];
527 adapter->crb_addr_cmd_consumer = crb_cmd_consumer[adapter->portnum]; 564 adapter->crb_addr_cmd_consumer = crb_cmd_consumer[adapter->portnum];
528 netxen_nic_update_cmd_producer(adapter, 0); 565 netxen_nic_update_cmd_producer(adapter, 0);
@@ -560,8 +597,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
560 err = netxen_initialize_adapter_offload(adapter); 597 err = netxen_initialize_adapter_offload(adapter);
561 if (err) 598 if (err)
562 goto err_out_free_rx_buffer; 599 goto err_out_free_rx_buffer;
563 val = readl(NETXEN_CRB_NORMALIZE(adapter, 600 val = adapter->pci_read_normalize(adapter,
564 NETXEN_CAM_RAM(0x1fc))); 601 NETXEN_CAM_RAM(0x1fc));
565 if (val == 0x55555555) { 602 if (val == 0x55555555) {
566 /* This is the first boot after power up */ 603 /* This is the first boot after power up */
567 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), &val); 604 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), &val);
@@ -573,20 +610,20 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
573 printk(KERN_ERR "%s: failed to set MSI bit in PCI-e reg\n", 610 printk(KERN_ERR "%s: failed to set MSI bit in PCI-e reg\n",
574 netxen_nic_driver_name); 611 netxen_nic_driver_name);
575 } 612 }
576 val = readl(NETXEN_CRB_NORMALIZE(adapter, 613 val = adapter->pci_read_normalize(adapter,
577 NETXEN_ROMUSB_GLB_SW_RESET)); 614 NETXEN_ROMUSB_GLB_SW_RESET);
578 printk(KERN_INFO"NetXen: read 0x%08x for reset reg.\n",val); 615 printk(KERN_INFO"NetXen: read 0x%08x for reset reg.\n",val);
579 if (val != 0x80000f) { 616 if (val != 0x80000f) {
580 /* clear the register for future unloads/loads */ 617 /* clear the register for future unloads/loads */
581 writel(0, NETXEN_CRB_NORMALIZE(adapter, 618 adapter->pci_write_normalize(adapter,
582 NETXEN_CAM_RAM(0x1fc))); 619 NETXEN_CAM_RAM(0x1fc), 0);
583 printk(KERN_ERR "ERROR in NetXen HW init sequence.\n"); 620 printk(KERN_ERR "ERROR in NetXen HW init sequence.\n");
584 err = -ENODEV; 621 err = -ENODEV;
585 goto err_out_free_dev; 622 goto err_out_free_dev;
586 } 623 }
587 } else { 624 } else {
588 writel(0, NETXEN_CRB_NORMALIZE(adapter, 625 adapter->pci_write_normalize(adapter,
589 CRB_CMDPEG_STATE)); 626 CRB_CMDPEG_STATE, 0);
590 netxen_pinit_from_rom(adapter, 0); 627 netxen_pinit_from_rom(adapter, 0);
591 msleep(1); 628 msleep(1);
592 netxen_load_firmware(adapter); 629 netxen_load_firmware(adapter);
@@ -602,9 +639,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
602 } 639 }
603 640
604 /* clear the register for future unloads/loads */ 641 /* clear the register for future unloads/loads */
605 writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_CAM_RAM(0x1fc))); 642 adapter->pci_write_normalize(adapter, NETXEN_CAM_RAM(0x1fc), 0);
606 dev_info(&pdev->dev, "cmdpeg state: 0x%0x\n", 643 dev_info(&pdev->dev, "cmdpeg state: 0x%0x\n",
607 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE))); 644 adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE));
608 645
609 /* 646 /*
610 * Tell the hardware our version number. 647 * Tell the hardware our version number.
@@ -612,12 +649,11 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
612 i = (_NETXEN_NIC_LINUX_MAJOR << 16) 649 i = (_NETXEN_NIC_LINUX_MAJOR << 16)
613 | ((_NETXEN_NIC_LINUX_MINOR << 8)) 650 | ((_NETXEN_NIC_LINUX_MINOR << 8))
614 | (_NETXEN_NIC_LINUX_SUBVERSION); 651 | (_NETXEN_NIC_LINUX_SUBVERSION);
615 writel(i, NETXEN_CRB_NORMALIZE(adapter, CRB_DRIVER_VERSION)); 652 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i);
616 653
617 /* Unlock the HW, prompting the boot sequence */ 654 /* Unlock the HW, prompting the boot sequence */
618 writel(1, 655 adapter->pci_write_normalize(adapter,
619 NETXEN_CRB_NORMALIZE(adapter, 656 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, 1);
620 NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
621 /* Handshake with the card before we register the devices. */ 657 /* Handshake with the card before we register the devices. */
622 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 658 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
623 } 659 }
@@ -626,7 +662,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
626 * See if the firmware gave us a virtual-physical port mapping. 662 * See if the firmware gave us a virtual-physical port mapping.
627 */ 663 */
628 adapter->physical_port = adapter->portnum; 664 adapter->physical_port = adapter->portnum;
629 i = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_V2P(adapter->portnum))); 665 i = adapter->pci_read_normalize(adapter, CRB_V2P(adapter->portnum));
630 if (i != 0x55555555) 666 if (i != 0x55555555)
631 adapter->physical_port = i; 667 adapter->physical_port = i;
632 668
@@ -1104,15 +1140,15 @@ static irqreturn_t netxen_intr(int irq, void *data)
1104 struct netxen_adapter *adapter = data; 1140 struct netxen_adapter *adapter = data;
1105 u32 our_int = 0; 1141 u32 our_int = 0;
1106 1142
1107 our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); 1143 our_int = adapter->pci_read_normalize(adapter, CRB_INT_VECTOR);
1108 /* not our interrupt */ 1144 /* not our interrupt */
1109 if ((our_int & (0x80 << adapter->portnum)) == 0) 1145 if ((our_int & (0x80 << adapter->portnum)) == 0)
1110 return IRQ_NONE; 1146 return IRQ_NONE;
1111 1147
1112 if (adapter->intr_scheme == INTR_SCHEME_PERPORT) { 1148 if (adapter->intr_scheme == INTR_SCHEME_PERPORT) {
1113 /* claim interrupt */ 1149 /* claim interrupt */
1114 writel(our_int & ~((u32)(0x80 << adapter->portnum)), 1150 adapter->pci_write_normalize(adapter, CRB_INT_VECTOR,
1115 NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); 1151 our_int & ~((u32)(0x80 << adapter->portnum)));
1116 } 1152 }
1117 1153
1118 netxen_handle_int(adapter); 1154 netxen_handle_int(adapter);