Finished PCI Unicontrols card memory range initialization.
authorppisa <ppisa>
Mon, 14 Jun 2004 15:23:25 +0000 (15:23 +0000)
committerppisa <ppisa>
Mon, 14 Jun 2004 15:23:25 +0000 (15:23 +0000)
There are still problems with CL2 cl2_test_card timing.

lincan/src/unican.c

index 66466d6..552d6fe 100644 (file)
@@ -854,6 +854,8 @@ int unican_register(struct hwspecops_t *hwspecops)
 
 int unican_pci_request_io(struct candevice_t *candev)
 {
+        unsigned long remap_addr;
+
     #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))
        if(pci_request_region(candev->sysdevptr.pcidev, 0, "unican_pci") != 0){
                CANMSG("Request of Unican PCI range failed\n");
@@ -866,12 +868,32 @@ int unican_pci_request_io(struct candevice_t *candev)
        }
     #endif /*(LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))*/
 
+       candev->dev_base_addr=pci_resource_start(candev->sysdevptr.pcidev,0);
+       candev->io_addr=candev->dev_base_addr;
+       candev->res_addr=candev->dev_base_addr;
+
+       if ( !( remap_addr = (long) ioremap( candev->io_addr, IO_RANGE ) ) ) {
+               CANMSG("Unable to access I/O memory at: 0x%lx\n", candev->io_addr);
+           #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))
+               pci_release_region(candev->sysdevptr.pcidev, 0);
+           #else /*(LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))*/
+               pci_release_regions(candev->sysdevptr.pcidev);
+           #endif /*(LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))*/
+               return -ENODEV;
+       
+       }
+       can_base_addr_fixup(candev, remap_addr);
+       DEBUGMSG("Registered IO-memory: 0x%lx - 0x%lx\n", candev->io_addr, candev->io_addr + IO_RANGE - 1);
+       DEBUGMSG("VMA: dev_base_addr: 0x%lx chip_base_addr: 0x%lx\n", 
+               candev->dev_base_addr, candev->chip[0]->chip_base_addr);
+
        return 0;
 }
 
 
 int unican_pci_release_io(struct candevice_t *candev)
 {
+       iounmap((void*)candev->dev_base_addr);
     #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))
        pci_release_region(candev->sysdevptr.pcidev, 0);
     #else /*(LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21))*/
@@ -900,7 +922,7 @@ int unican_pci_init_hw_data(struct candevice_t *candev)
                printk(KERN_CRIT "Unican PCI region 0 is not MEM\n");
                return -EIO;
        }
-       candev->dev_base_addr=pci_resource_start(pcidev,0); /*S5920*/
+       candev->dev_base_addr=pci_resource_start(pcidev,0);
        candev->io_addr=candev->dev_base_addr;
        candev->res_addr=candev->dev_base_addr;