aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sk98lin
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sk98lin')
-rw-r--r--drivers/net/sk98lin/skge.c129
1 files changed, 76 insertions, 53 deletions
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 9a76ac180b11..197edd74fbb5 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -282,26 +282,22 @@ SK_U32 Val) /* pointer to store the read value */
282 * Description: 282 * Description:
283 * This function initialize the PCI resources and IO 283 * This function initialize the PCI resources and IO
284 * 284 *
285 * Returns: N/A 285 * Returns:
286 * 286 * 0 - indicate everything worked ok.
287 * != 0 - error indication
287 */ 288 */
288int SkGeInitPCI(SK_AC *pAC) 289static __devinit int SkGeInitPCI(SK_AC *pAC)
289{ 290{
290 struct SK_NET_DEVICE *dev = pAC->dev[0]; 291 struct SK_NET_DEVICE *dev = pAC->dev[0];
291 struct pci_dev *pdev = pAC->PciDev; 292 struct pci_dev *pdev = pAC->PciDev;
292 int retval; 293 int retval;
293 294
294 if (pci_enable_device(pdev) != 0) {
295 return 1;
296 }
297
298 dev->mem_start = pci_resource_start (pdev, 0); 295 dev->mem_start = pci_resource_start (pdev, 0);
299 pci_set_master(pdev); 296 pci_set_master(pdev);
300 297
301 if (pci_request_regions(pdev, "sk98lin") != 0) { 298 retval = pci_request_regions(pdev, "sk98lin");
302 retval = 2; 299 if (retval)
303 goto out_disable; 300 goto out;
304 }
305 301
306#ifdef SK_BIG_ENDIAN 302#ifdef SK_BIG_ENDIAN
307 /* 303 /*
@@ -320,9 +316,8 @@ int SkGeInitPCI(SK_AC *pAC)
320 * Remap the regs into kernel space. 316 * Remap the regs into kernel space.
321 */ 317 */
322 pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000); 318 pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000);
323 319 if (!pAC->IoBase) {
324 if (!pAC->IoBase){ 320 retval = -EIO;
325 retval = 3;
326 goto out_release; 321 goto out_release;
327 } 322 }
328 323
@@ -330,8 +325,7 @@ int SkGeInitPCI(SK_AC *pAC)
330 325
331 out_release: 326 out_release:
332 pci_release_regions(pdev); 327 pci_release_regions(pdev);
333 out_disable: 328 out:
334 pci_disable_device(pdev);
335 return retval; 329 return retval;
336} 330}
337 331
@@ -492,7 +486,7 @@ module_param_array(AutoSizing, charp, NULL, 0);
492 * 0, if everything is ok 486 * 0, if everything is ok
493 * !=0, on error 487 * !=0, on error
494 */ 488 */
495static int __init SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC) 489static int __devinit SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC)
496{ 490{
497short i; 491short i;
498unsigned long Flags; 492unsigned long Flags;
@@ -529,7 +523,7 @@ SK_BOOL DualNet;
529 if (SkGeInit(pAC, pAC->IoBase, SK_INIT_DATA) != 0) { 523 if (SkGeInit(pAC, pAC->IoBase, SK_INIT_DATA) != 0) {
530 printk("HWInit (0) failed.\n"); 524 printk("HWInit (0) failed.\n");
531 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); 525 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
532 return(-EAGAIN); 526 return -EIO;
533 } 527 }
534 SkI2cInit( pAC, pAC->IoBase, SK_INIT_DATA); 528 SkI2cInit( pAC, pAC->IoBase, SK_INIT_DATA);
535 SkEventInit(pAC, pAC->IoBase, SK_INIT_DATA); 529 SkEventInit(pAC, pAC->IoBase, SK_INIT_DATA);
@@ -551,7 +545,7 @@ SK_BOOL DualNet;
551 if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) { 545 if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
552 printk("sk98lin: HWInit (1) failed.\n"); 546 printk("sk98lin: HWInit (1) failed.\n");
553 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); 547 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
554 return(-EAGAIN); 548 return -EIO;
555 } 549 }
556 SkI2cInit( pAC, pAC->IoBase, SK_INIT_IO); 550 SkI2cInit( pAC, pAC->IoBase, SK_INIT_IO);
557 SkEventInit(pAC, pAC->IoBase, SK_INIT_IO); 551 SkEventInit(pAC, pAC->IoBase, SK_INIT_IO);
@@ -583,20 +577,20 @@ SK_BOOL DualNet;
583 } else { 577 } else {
584 printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n", 578 printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
585 pAC->GIni.GIMacsFound); 579 pAC->GIni.GIMacsFound);
586 return -EAGAIN; 580 return -EIO;
587 } 581 }
588 582
589 if (Ret) { 583 if (Ret) {
590 printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n", 584 printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n",
591 dev->irq); 585 dev->irq);
592 return -EAGAIN; 586 return Ret;
593 } 587 }
594 pAC->AllocFlag |= SK_ALLOC_IRQ; 588 pAC->AllocFlag |= SK_ALLOC_IRQ;
595 589
596 /* Alloc memory for this board (Mem for RxD/TxD) : */ 590 /* Alloc memory for this board (Mem for RxD/TxD) : */
597 if(!BoardAllocMem(pAC)) { 591 if(!BoardAllocMem(pAC)) {
598 printk("No memory for descriptor rings.\n"); 592 printk("No memory for descriptor rings.\n");
599 return(-EAGAIN); 593 return -ENOMEM;
600 } 594 }
601 595
602 BoardInitMem(pAC); 596 BoardInitMem(pAC);
@@ -612,7 +606,7 @@ SK_BOOL DualNet;
612 DualNet)) { 606 DualNet)) {
613 BoardFreeMem(pAC); 607 BoardFreeMem(pAC);
614 printk("sk98lin: SkGeInitAssignRamToQueues failed.\n"); 608 printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
615 return(-EAGAIN); 609 return -EIO;
616 } 610 }
617 611
618 return (0); 612 return (0);
@@ -633,8 +627,7 @@ SK_BOOL DualNet;
633 * SK_TRUE, if all memory could be allocated 627 * SK_TRUE, if all memory could be allocated
634 * SK_FALSE, if not 628 * SK_FALSE, if not
635 */ 629 */
636static SK_BOOL BoardAllocMem( 630static __devinit SK_BOOL BoardAllocMem(SK_AC *pAC)
637SK_AC *pAC)
638{ 631{
639caddr_t pDescrMem; /* pointer to descriptor memory area */ 632caddr_t pDescrMem; /* pointer to descriptor memory area */
640size_t AllocLength; /* length of complete descriptor area */ 633size_t AllocLength; /* length of complete descriptor area */
@@ -727,8 +720,7 @@ size_t AllocLength; /* length of complete descriptor area */
727 * 720 *
728 * Returns: N/A 721 * Returns: N/A
729 */ 722 */
730static void BoardInitMem( 723static __devinit void BoardInitMem(SK_AC *pAC)
731SK_AC *pAC) /* pointer to adapter context */
732{ 724{
733int i; /* loop counter */ 725int i; /* loop counter */
734int RxDescrSize; /* the size of a rx descriptor rounded up to alignment*/ 726int RxDescrSize; /* the size of a rx descriptor rounded up to alignment*/
@@ -4776,32 +4768,47 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4776 struct net_device *dev = NULL; 4768 struct net_device *dev = NULL;
4777 static int boards_found = 0; 4769 static int boards_found = 0;
4778 int error = -ENODEV; 4770 int error = -ENODEV;
4771 int using_dac = 0;
4779 char DeviceStr[80]; 4772 char DeviceStr[80];
4780 4773
4781 if (pci_enable_device(pdev)) 4774 if (pci_enable_device(pdev))
4782 goto out; 4775 goto out;
4783 4776
4784 /* Configure DMA attributes. */ 4777 /* Configure DMA attributes. */
4785 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) && 4778 if (sizeof(dma_addr_t) > sizeof(u32) &&
4786 pci_set_dma_mask(pdev, DMA_32BIT_MASK)) 4779 !(error = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
4787 goto out_disable_device; 4780 using_dac = 1;
4788 4781 error = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
4782 if (error < 0) {
4783 printk(KERN_ERR "sk98lin %s unable to obtain 64 bit DMA "
4784 "for consistent allocations\n", pci_name(pdev));
4785 goto out_disable_device;
4786 }
4787 } else {
4788 error = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
4789 if (error) {
4790 printk(KERN_ERR "sk98lin %s no usable DMA configuration\n",
4791 pci_name(pdev));
4792 goto out_disable_device;
4793 }
4794 }
4789 4795
4790 if ((dev = alloc_etherdev(sizeof(DEV_NET))) == NULL) { 4796 error = -ENOMEM;
4791 printk(KERN_ERR "Unable to allocate etherdev " 4797 dev = alloc_etherdev(sizeof(DEV_NET));
4798 if (!dev) {
4799 printk(KERN_ERR "sk98lin: unable to allocate etherdev "
4792 "structure!\n"); 4800 "structure!\n");
4793 goto out_disable_device; 4801 goto out_disable_device;
4794 } 4802 }
4795 4803
4796 pNet = netdev_priv(dev); 4804 pNet = netdev_priv(dev);
4797 pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL); 4805 pNet->pAC = kzalloc(sizeof(SK_AC), GFP_KERNEL);
4798 if (!pNet->pAC) { 4806 if (!pNet->pAC) {
4799 printk(KERN_ERR "Unable to allocate adapter " 4807 printk(KERN_ERR "sk98lin: unable to allocate adapter "
4800 "structure!\n"); 4808 "structure!\n");
4801 goto out_free_netdev; 4809 goto out_free_netdev;
4802 } 4810 }
4803 4811
4804 memset(pNet->pAC, 0, sizeof(SK_AC));
4805 pAC = pNet->pAC; 4812 pAC = pNet->pAC;
4806 pAC->PciDev = pdev; 4813 pAC->PciDev = pdev;
4807 4814
@@ -4810,6 +4817,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4810 pAC->CheckQueue = SK_FALSE; 4817 pAC->CheckQueue = SK_FALSE;
4811 4818
4812 dev->irq = pdev->irq; 4819 dev->irq = pdev->irq;
4820
4813 error = SkGeInitPCI(pAC); 4821 error = SkGeInitPCI(pAC);
4814 if (error) { 4822 if (error) {
4815 printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error); 4823 printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error);
@@ -4844,19 +4852,25 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4844#endif 4852#endif
4845 } 4853 }
4846 4854
4855 if (using_dac)
4856 dev->features |= NETIF_F_HIGHDMA;
4857
4847 pAC->Index = boards_found++; 4858 pAC->Index = boards_found++;
4848 4859
4849 if (SkGeBoardInit(dev, pAC)) 4860 error = SkGeBoardInit(dev, pAC);
4861 if (error)
4850 goto out_free_netdev; 4862 goto out_free_netdev;
4851 4863
4852 /* Read Adapter name from VPD */ 4864 /* Read Adapter name from VPD */
4853 if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) { 4865 if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) {
4866 error = -EIO;
4854 printk(KERN_ERR "sk98lin: Could not read VPD data.\n"); 4867 printk(KERN_ERR "sk98lin: Could not read VPD data.\n");
4855 goto out_free_resources; 4868 goto out_free_resources;
4856 } 4869 }
4857 4870
4858 /* Register net device */ 4871 /* Register net device */
4859 if (register_netdev(dev)) { 4872 error = register_netdev(dev);
4873 if (error) {
4860 printk(KERN_ERR "sk98lin: Could not register device.\n"); 4874 printk(KERN_ERR "sk98lin: Could not register device.\n");
4861 goto out_free_resources; 4875 goto out_free_resources;
4862 } 4876 }
@@ -4883,15 +4897,17 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4883 4897
4884 boards_found++; 4898 boards_found++;
4885 4899
4900 pci_set_drvdata(pdev, dev);
4901
4886 /* More then one port found */ 4902 /* More then one port found */
4887 if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { 4903 if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
4888 if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) { 4904 dev = alloc_etherdev(sizeof(DEV_NET));
4889 printk(KERN_ERR "Unable to allocate etherdev " 4905 if (!dev) {
4906 printk(KERN_ERR "sk98lin: unable to allocate etherdev "
4890 "structure!\n"); 4907 "structure!\n");
4891 goto out; 4908 goto single_port;
4892 } 4909 }
4893 4910
4894 pAC->dev[1] = dev;
4895 pNet = netdev_priv(dev); 4911 pNet = netdev_priv(dev);
4896 pNet->PortNr = 1; 4912 pNet->PortNr = 1;
4897 pNet->NetNr = 1; 4913 pNet->NetNr = 1;
@@ -4920,20 +4936,28 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4920#endif 4936#endif
4921 } 4937 }
4922 4938
4923 if (register_netdev(dev)) { 4939 if (using_dac)
4924 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n"); 4940 dev->features |= NETIF_F_HIGHDMA;
4941
4942 error = register_netdev(dev);
4943 if (error) {
4944 printk(KERN_ERR "sk98lin: Could not register device"
4945 " for second port. (%d)\n", error);
4925 free_netdev(dev); 4946 free_netdev(dev);
4926 pAC->dev[1] = pAC->dev[0]; 4947 goto single_port;
4927 } else {
4928 memcpy(&dev->dev_addr,
4929 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4930 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
4931
4932 printk("%s: %s\n", dev->name, DeviceStr);
4933 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4934 } 4948 }
4949
4950 pAC->dev[1] = dev;
4951 memcpy(&dev->dev_addr,
4952 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4953 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
4954
4955 printk("%s: %s\n", dev->name, DeviceStr);
4956 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4935 } 4957 }
4936 4958
4959single_port:
4960
4937 /* Save the hardware revision */ 4961 /* Save the hardware revision */
4938 pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) + 4962 pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
4939 (pAC->GIni.GIPciHwRev & 0x0F); 4963 (pAC->GIni.GIPciHwRev & 0x0F);
@@ -4945,7 +4969,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4945 memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA)); 4969 memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
4946 memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA)); 4970 memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
4947 4971
4948 pci_set_drvdata(pdev, dev);
4949 return 0; 4972 return 0;
4950 4973
4951 out_free_resources: 4974 out_free_resources: