[parisc-linux-cvs] Make EISA work on CCIO machines (2.4.17-pa8)

Matthew Wilcox willy@debian.org
Sun, 13 Jan 2002 16:07:33 +0000


 * Rewrite ccio_init_resources to factor out common setup and not bother
   registering resources for busses which aren't used (found on C360).
 * Change ccio_find_parisc_resource to take the struct parisc_device and
   return the appropriate resource rather than always returning the first.
 * Move ccio_find_parisc_resource and ccio_extend_mmio_range prototypes
   from dino.c to pci.h
 * Change eisa.c to use ccio_find_parisc_resource like dino does.

Index: arch/parisc/kernel/ccio-dma.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/ccio-dma.c,v
retrieving revision 1.49
diff -u -p -r1.49 ccio-dma.c
--- arch/parisc/kernel/ccio-dma.c	2001/12/21 23:50:07	1.49
+++ arch/parisc/kernel/ccio-dma.c	2002/01/13 15:09:46
@@ -1390,48 +1390,40 @@ ccio_ioc_init(struct ioc *ioc)
 	}
 }
 
-static int __init ccio_init_resources(struct ioc *ioc)
+static int ccio_init_resource(struct resource *res, unsigned long ioaddr)
 {
 	int result;
-	char *name;
-	struct resource *res = ioc->mmio_region;
 
-	name = kmalloc(17, GFP_KERNEL);
-	sprintf(name, "GSC Bus %d Primary", ioc_count);
-	res->name = name;
 	res->flags = IORESOURCE_MEM;
-
-	res->start = (unsigned long)(signed)
-		__raw_readl((unsigned long)&ioc->ioc_hpa->io_io_low) << 16;
-	res->end = ((unsigned long)(signed)
-		__raw_readl((unsigned long)&ioc->ioc_hpa->io_io_high) << 16) - 1;
+	res->start = (unsigned long)(signed) __raw_readl(ioaddr) << 16;
+	res->end = (unsigned long)(signed) (__raw_readl(ioaddr + 4) << 16) - 1;
+	if (res->end < res->start)
+		return 0;
 	result = request_resource(&iomem_resource, res);
 	if (result < 0) {
 		printk(KERN_ERR 
 		       "%s: failed to claim CCIO bus address space!\n", 
 		       __FILE__);
-		return result;
+		return 0;
 	}
-
-	res++;
-	name = kmalloc(19, GFP_KERNEL);
-	sprintf(name, "GSC Bus %d Secondary", ioc_count);
-	res->name = name;
-	res->flags = IORESOURCE_MEM;
+	return 1;
+}
 
-	res->start = (unsigned long)(signed)
-		__raw_readl((unsigned long)&ioc->ioc_hpa->io_io_low_hv) << 16;
-	res->end = ((unsigned long)(signed)
-		__raw_readl((unsigned long)&ioc->ioc_hpa->io_io_high_hv) << 16) - 1;
+static void __init ccio_init_resources(struct ioc *ioc)
+{
+	struct resource *res = ioc->mmio_region;
+	if (ccio_init_resource(res, (unsigned long)&ioc->ioc_hpa->io_io_low)) {
+		char *name = kmalloc(17, GFP_KERNEL);
+		sprintf(name, "GSC Bus %d Primary", ioc_count);
+		res->name = name;
+	}
 
-	result = request_resource(&iomem_resource, res);
-	if (result < 0) {
-		printk(KERN_ERR 
-		       "%s: failed to claim CCIO bus address space!\n", 
-		       __FILE__);
-		return result;
+	res++;
+	if (ccio_init_resource(res, (unsigned long)&ioc->ioc_hpa->io_io_low_hv)) {
+		char *name = kmalloc(19, GFP_KERNEL);
+		sprintf(name, "GSC Bus %d Secondary", ioc_count);
+		res->name = name;
 	}
-	return 0;
 }
 
 #ifdef NASTY_HACK_FOR_K_CLASS
@@ -1442,12 +1434,18 @@ void ccio_extend_mmio_range(struct ioc *
 }
 #endif
 
-struct resource * ccio_find_parisc_resource(struct ioc *ioc)
+struct resource * ccio_find_parisc_resource(struct parisc_device *dev)
 {
-	if(!ioc)
+	struct ioc *ioc = ccio_get_iommu(dev);
+	if (!ioc)
 		return &iomem_resource;
 
-	return ioc->mmio_region;
+	if ((ioc->mmio_region->start < dev->hpa) &&
+			(dev->hpa < ioc->mmio_region->end)) {
+		return ioc->mmio_region;
+	} else {
+		return ioc->mmio_region + 1;
+	}
 }
 
 
@@ -1543,7 +1541,7 @@ static struct ioc * ccio_find_ioc(int hw
 }
 
 /**
- * ccio_pci_iommu - Assign the iommu pointer for the pci device.
+ * ccio_get_iommu - Find the iommu which controls this device
  * @dev: The parisc device.
  *
  * This function searches through the registerd IOMMU's and returns the
@@ -1552,7 +1550,7 @@ static struct ioc * ccio_find_ioc(int hw
 void * ccio_get_iommu(struct parisc_device *dev)
 {
 	dev = ccio_find_ioa(dev);
-	if(!dev)
+	if (!dev)
 		return NULL;
 
 	return ccio_find_ioc(dev->hw_path);
Index: drivers/gsc/dino.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/dino.c,v
retrieving revision 1.53
diff -u -p -r1.53 dino.c
--- drivers/gsc/dino.c	2002/01/12 19:15:40	1.53
+++ drivers/gsc/dino.c	2002/01/13 15:09:47
@@ -464,15 +464,6 @@ dino_bios_init(void)
  * Claim an 8MB chunk of unused IO space and call the generic PCI routines
  * to set up the addresses of the devices on this bus.
  */
-#ifdef CONFIG_IOMMU_CCIO
-struct ioc;
-void ccio_extend_mmio_range(struct ioc *ioc);
-struct resource * ccio_find_parisc_resource(struct ioc *ioc);
-#else /* !CONFIG_IOMMU_CCIO */
-#define ccio_extend_mmio_range()
-#define ccio_find_parisc_resource(x) &iomem_resource
-#endif /* !CONFIG_IOMMU_CCIO */
-
 #define _8MB 0x00800000
 static void __init
 dino_card_setup(struct pci_bus *bus, unsigned long base_addr)
@@ -487,7 +478,7 @@ dino_card_setup(struct pci_bus *bus, uns
 #ifdef NASTY_HACK_FOR_K_CLASS
 	ccio_extend_mmio_range(dino_dev->hba.iommu);
 #endif
-	parent_resource = ccio_find_parisc_resource(dino_dev->hba.iommu);
+	parent_resource = ccio_find_parisc_resource(dino_dev->hba.dev);
 	if (allocate_resource(parent_resource, res, _8MB, 0xf0000000 | _8MB,
 			      0xffffffff &~ _8MB, _8MB, NULL, NULL) < 0) {
 		printk(KERN_WARNING "Dino: Failed to allocate memory region\n");
@@ -689,7 +680,7 @@ dino_bridge_init(struct dino_device *din
 	res->start = (unsigned long) 0xfffffffff0000000 | bpos << 23;
 	res->end = res->start + 8 * 1024 * 1024 - 1;
 
-	parent_resource = ccio_find_parisc_resource(dino_dev->hba.iommu);
+	parent_resource = ccio_find_parisc_resource(dino_dev->hba.dev);
 	result = request_resource(parent_resource, res);
 	if (result < 0) {
 		printk(KERN_ERR "Dino: failed to claim PCI Bus address space!\n");
Index: drivers/gsc/eisa.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/eisa.c,v
retrieving revision 1.13
diff -u -p -r1.13 eisa.c
--- drivers/gsc/eisa.c	2001/11/13 20:42:43	1.13
+++ drivers/gsc/eisa.c	2002/01/13 15:09:47
@@ -34,6 +34,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
+#include <linux/spinlock.h>
 
 #include <asm/byteorder.h>
 #include <asm/gsc.h>
@@ -311,16 +312,22 @@ static void init_eisa_pic(void)
 static int __devinit eisa_probe(struct parisc_device *dev)
 {
 	int result;
+	struct resource *parent_resource;
+
 	char *name = is_mongoose(dev) ? "Mongoose" : "Wax";
 
 	printk(KERN_INFO "%s EISA Adapter found at 0x%08lx\n", 
 		name, dev->hpa);
-   
+
+	eisa_dev.hba.dev = dev;
+	eisa_dev.hba.iommu = ccio_get_iommu(dev);
+	parent_resource = ccio_find_parisc_resource(eisa_dev.hba.dev);
+
 	eisa_dev.hba.lmmio_space.name = "EISA";
 	eisa_dev.hba.lmmio_space.start = (unsigned long) 0xfffffffffc000000;
 	eisa_dev.hba.lmmio_space.end = (unsigned long) 0xffffffffffbfffff;
 	eisa_dev.hba.lmmio_space.flags = IORESOURCE_MEM;
-	result = request_resource(&iomem_resource, &eisa_dev.hba.lmmio_space);
+	result = request_resource(parent_resource, &eisa_dev.hba.lmmio_space);
 	if (result < 0) {
 		printk(KERN_ERR "EISA: failed to claim EISA Bus address space!\n");
 		return result;
Index: include/asm-parisc/pci.h
===================================================================
RCS file: /var/cvs/linux/include/asm-parisc/pci.h,v
retrieving revision 1.39
diff -u -p -r1.39 pci.h
--- include/asm-parisc/pci.h	2002/01/07 23:51:15	1.39
+++ include/asm-parisc/pci.h	2002/01/13 15:09:47
@@ -247,11 +247,16 @@ extern inline void pcibios_register_hba(
 
 #ifdef CONFIG_IOMMU_CCIO
 struct parisc_device;
+struct ioc;
 void * ccio_get_iommu(struct parisc_device *dev);
 struct pci_dev * ccio_get_fake(struct parisc_device *dev);
+void ccio_extend_mmio_range(struct ioc *ioc);
+struct resource * ccio_find_parisc_resource(struct parisc_device *dev);
 #else /* !CONFIG_IOMMU_CCIO */
-#define ccio_get_iommu(dev) (NULL)
-#define ccio_get_fake(dev) (NULL)
+#define ccio_get_iommu(dev) do { } while (0)
+#define ccio_get_fake(dev) do { } while (0)
+#define ccio_extend_mmio_range(ioc) do { } while (0)
+#define ccio_find_parisc_resource(x) &iomem_resource
 #endif /* !CONFIG_IOMMU_CCIO */
 
 #ifdef CONFIG_IOMMU_SBA

-- 
Revolutions do not require corporate support.