diff options
Diffstat (limited to 'drivers/vme')
| -rw-r--r-- | drivers/vme/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/vme/boards/vme_vmivme7805.c | 2 | ||||
| -rw-r--r-- | drivers/vme/bridges/vme_ca91cx42.c | 35 | ||||
| -rw-r--r-- | drivers/vme/bridges/vme_tsi148.c | 46 | ||||
| -rw-r--r-- | drivers/vme/vme.c | 25 | 
5 files changed, 61 insertions, 49 deletions
diff --git a/drivers/vme/Kconfig b/drivers/vme/Kconfig index c5c22465a80..a6a6f955911 100644 --- a/drivers/vme/Kconfig +++ b/drivers/vme/Kconfig @@ -3,7 +3,7 @@  #  menuconfig VME_BUS -	tristate "VME bridge support" +	bool "VME bridge support"  	depends on PCI  	---help---  	  If you say Y here you get support for the VME bridge Framework. diff --git a/drivers/vme/boards/vme_vmivme7805.c b/drivers/vme/boards/vme_vmivme7805.c index cf74aee2cef..ac422121f9b 100644 --- a/drivers/vme/boards/vme_vmivme7805.c +++ b/drivers/vme/boards/vme_vmivme7805.c @@ -27,7 +27,7 @@ static void __iomem *vmic_base;  static const char driver_name[] = "vmivme_7805"; -static DEFINE_PCI_DEVICE_TABLE(vmic_ids) = { +static const struct pci_device_id vmic_ids[] = {  	{ PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) },  	{ },  }; diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c index f8448573d03..bfb2d3f0673 100644 --- a/drivers/vme/bridges/vme_ca91cx42.c +++ b/drivers/vme/bridges/vme_ca91cx42.c @@ -42,7 +42,7 @@ static int geoid;  static const char driver_name[] = "vme_ca91cx42"; -static DEFINE_PCI_DEVICE_TABLE(ca91cx42_ids) = { +static const struct pci_device_id ca91cx42_ids[] = {  	{ PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_CA91C142) },  	{ },  }; @@ -869,14 +869,13 @@ static ssize_t ca91cx42_master_read(struct vme_master_resource *image,  	spin_lock(&image->lock); -	/* The following code handles VME address alignment problem -	 * in order to assure the maximal data width cycle. -	 * We cannot use memcpy_xxx directly here because it -	 * may cut data transfer in 8-bits cycles, thus making -	 * D16 cycle impossible. -	 * From the other hand, the bridge itself assures that -	 * maximal configured data cycle is used and splits it -	 * automatically for non-aligned addresses. +	/* The following code handles VME address alignment. We cannot use +	 * memcpy_xxx here because it may cut data transfers in to 8-bit +	 * cycles when D16 or D32 cycles are required on the VME bus. +	 * On the other hand, the bridge itself assures that the maximum data +	 * cycle configured for the transfer is used and splits it +	 * automatically for non-aligned addresses, so we don't want the +	 * overhead of needlessly forcing small transfers for the entire cycle.  	 */  	if ((uintptr_t)addr & 0x1) {  		*(u8 *)buf = ioread8(addr); @@ -884,7 +883,7 @@ static ssize_t ca91cx42_master_read(struct vme_master_resource *image,  		if (done == count)  			goto out;  	} -	if ((uintptr_t)addr & 0x2) { +	if ((uintptr_t)(addr + done) & 0x2) {  		if ((count - done) < 2) {  			*(u8 *)(buf + done) = ioread8(addr + done);  			done += 1; @@ -896,9 +895,9 @@ static ssize_t ca91cx42_master_read(struct vme_master_resource *image,  	}  	count32 = (count - done) & ~0x3; -	if (count32 > 0) { -		memcpy_fromio(buf + done, addr + done, (unsigned int)count); -		done += count32; +	while (done < count32) { +		*(u32 *)(buf + done) = ioread32(addr + done); +		done += 4;  	}  	if ((count - done) & 0x2) { @@ -930,7 +929,7 @@ static ssize_t ca91cx42_master_write(struct vme_master_resource *image,  	spin_lock(&image->lock);  	/* Here we apply for the same strategy we do in master_read -	 * function in order to assure D16 cycle when required. +	 * function in order to assure the correct cycles.  	 */  	if ((uintptr_t)addr & 0x1) {  		iowrite8(*(u8 *)buf, addr); @@ -938,7 +937,7 @@ static ssize_t ca91cx42_master_write(struct vme_master_resource *image,  		if (done == count)  			goto out;  	} -	if ((uintptr_t)addr & 0x2) { +	if ((uintptr_t)(addr + done) & 0x2) {  		if ((count - done) < 2) {  			iowrite8(*(u8 *)(buf + done), addr + done);  			done += 1; @@ -950,9 +949,9 @@ static ssize_t ca91cx42_master_write(struct vme_master_resource *image,  	}  	count32 = (count - done) & ~0x3; -	if (count32 > 0) { -		memcpy_toio(addr + done, buf + done, count32); -		done += count32; +	while (done < count32) { +		iowrite32(*(u32 *)(buf + done), addr + done); +		done += 4;  	}  	if ((count - done) & 0x2) { diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index 9cf88337e4e..61e706c0e00 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -45,7 +45,7 @@ static int geoid;  static const char driver_name[] = "vme_tsi148"; -static DEFINE_PCI_DEVICE_TABLE(tsi148_ids) = { +static const struct pci_device_id tsi148_ids[] = {  	{ PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_TSI148) },  	{ },  }; @@ -320,7 +320,7 @@ static int tsi148_irq_init(struct vme_bridge *tsi148_bridge)  	struct pci_dev *pdev;  	struct tsi148_driver *bridge; -	pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev); +	pdev = to_pci_dev(tsi148_bridge->parent);  	bridge = tsi148_bridge->driver_priv; @@ -433,9 +433,7 @@ static void tsi148_irq_set(struct vme_bridge *tsi148_bridge, int level,  		iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEO);  		if (sync != 0) { -			pdev = container_of(tsi148_bridge->parent, -				struct pci_dev, dev); - +			pdev = to_pci_dev(tsi148_bridge->parent);  			synchronize_irq(pdev->irq);  		}  	} else { @@ -741,7 +739,7 @@ static int tsi148_slave_get(struct vme_slave_resource *image, int *enabled,  	reg_join(vme_bound_high, vme_bound_low, &vme_bound);  	reg_join(pci_offset_high, pci_offset_low, &pci_offset); -	*pci_base = (dma_addr_t)vme_base + pci_offset; +	*pci_base = (dma_addr_t)(*vme_base + pci_offset);  	*enabled = 0;  	*aspace = 0; @@ -814,7 +812,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,  	tsi148_bridge = image->parent; -	pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev); +	pdev = to_pci_dev(tsi148_bridge->parent);  	existing_size = (unsigned long long)(image->bus_resource.end -  		image->bus_resource.start); @@ -910,11 +908,15 @@ static int tsi148_master_set(struct vme_master_resource *image, int enabled,  	unsigned long long pci_bound, vme_offset, pci_base;  	struct vme_bridge *tsi148_bridge;  	struct tsi148_driver *bridge; +	struct pci_bus_region region; +	struct pci_dev *pdev;  	tsi148_bridge = image->parent;  	bridge = tsi148_bridge->driver_priv; +	pdev = to_pci_dev(tsi148_bridge->parent); +  	/* Verify input data */  	if (vme_base & 0xFFFF) {  		dev_err(tsi148_bridge->parent, "Invalid VME Window " @@ -949,7 +951,9 @@ static int tsi148_master_set(struct vme_master_resource *image, int enabled,  		pci_bound = 0;  		vme_offset = 0;  	} else { -		pci_base = (unsigned long long)image->bus_resource.start; +		pcibios_resource_to_bus(pdev->bus, ®ion, +					&image->bus_resource); +		pci_base = region.start;  		/*  		 * Bound address is a valid address for the window, adjust @@ -1276,8 +1280,8 @@ static ssize_t tsi148_master_read(struct vme_master_resource *image, void *buf,  	spin_lock(&image->lock);  	/* The following code handles VME address alignment. We cannot use -	 * memcpy_xxx directly here because it may cut small data transfers in -	 * to 8-bit cycles, thus making D16 cycle impossible. +	 * memcpy_xxx here because it may cut data transfers in to 8-bit +	 * cycles when D16 or D32 cycles are required on the VME bus.  	 * On the other hand, the bridge itself assures that the maximum data  	 * cycle configured for the transfer is used and splits it  	 * automatically for non-aligned addresses, so we don't want the @@ -1289,7 +1293,7 @@ static ssize_t tsi148_master_read(struct vme_master_resource *image, void *buf,  		if (done == count)  			goto out;  	} -	if ((uintptr_t)addr & 0x2) { +	if ((uintptr_t)(addr + done) & 0x2) {  		if ((count - done) < 2) {  			*(u8 *)(buf + done) = ioread8(addr + done);  			done += 1; @@ -1301,9 +1305,9 @@ static ssize_t tsi148_master_read(struct vme_master_resource *image, void *buf,  	}  	count32 = (count - done) & ~0x3; -	if (count32 > 0) { -		memcpy_fromio(buf + done, addr + done, count32); -		done += count32; +	while (done < count32) { +		*(u32 *)(buf + done) = ioread32(addr + done); +		done += 4;  	}  	if ((count - done) & 0x2) { @@ -1363,7 +1367,7 @@ static ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf,  	spin_lock(&image->lock);  	/* Here we apply for the same strategy we do in master_read -	 * function in order to assure D16 cycle when required. +	 * function in order to assure the correct cycles.  	 */  	if ((uintptr_t)addr & 0x1) {  		iowrite8(*(u8 *)buf, addr); @@ -1371,7 +1375,7 @@ static ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf,  		if (done == count)  			goto out;  	} -	if ((uintptr_t)addr & 0x2) { +	if ((uintptr_t)(addr + done) & 0x2) {  		if ((count - done) < 2) {  			iowrite8(*(u8 *)(buf + done), addr + done);  			done += 1; @@ -1383,9 +1387,9 @@ static ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf,  	}  	count32 = (count - done) & ~0x3; -	if (count32 > 0) { -		memcpy_toio(addr + done, buf + done, count32); -		done += count32; +	while (done < count32) { +		iowrite32(*(u32 *)(buf + done), addr + done); +		done += 4;  	}  	if ((count - done) & 0x2) { @@ -2232,7 +2236,7 @@ static void *tsi148_alloc_consistent(struct device *parent, size_t size,  	struct pci_dev *pdev;  	/* Find pci_dev container of dev */ -	pdev = container_of(parent, struct pci_dev, dev); +	pdev = to_pci_dev(parent);  	return pci_alloc_consistent(pdev, size, dma);  } @@ -2243,7 +2247,7 @@ static void tsi148_free_consistent(struct device *parent, size_t size,  	struct pci_dev *pdev;  	/* Find pci_dev container of dev */ -	pdev = container_of(parent, struct pci_dev, dev); +	pdev = to_pci_dev(parent);  	pci_free_consistent(pdev, size, vaddr, dma);  } diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index f6856b42749..7516030037a 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -1274,7 +1274,7 @@ void vme_lm_free(struct vme_resource *resource)  }  EXPORT_SYMBOL(vme_lm_free); -int vme_slot_get(struct vme_dev *vdev) +int vme_slot_num(struct vme_dev *vdev)  {  	struct vme_bridge *bridge; @@ -1285,14 +1285,27 @@ int vme_slot_get(struct vme_dev *vdev)  	}  	if (bridge->slot_get == NULL) { -		printk(KERN_WARNING "vme_slot_get not supported\n"); +		printk(KERN_WARNING "vme_slot_num not supported\n");  		return -EINVAL;  	}  	return bridge->slot_get(bridge);  } -EXPORT_SYMBOL(vme_slot_get); +EXPORT_SYMBOL(vme_slot_num); +int vme_bus_num(struct vme_dev *vdev) +{ +	struct vme_bridge *bridge; + +	bridge = vdev->bridge; +	if (bridge == NULL) { +		pr_err("Can't find VME bus\n"); +		return -EINVAL; +	} + +	return bridge->num; +} +EXPORT_SYMBOL(vme_bus_num);  /* - Bridge Registration --------------------------------------------------- */ @@ -1512,9 +1525,5 @@ static void __exit vme_exit(void)  	bus_unregister(&vme_bus_type);  } -MODULE_DESCRIPTION("VME bridge driver framework"); -MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com"); -MODULE_LICENSE("GPL"); - -module_init(vme_init); +subsys_initcall(vme_init);  module_exit(vme_exit);  | 
