[parisc-linux-cvs] [PATCH] Allow ccio to discover new devices on with a native bus walk

Ryan Bradetich rbrad@beavis.ybsoft.com
Thu, 12 Jul 2001 22:27:29 -0600


--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

This patch allows the ccio driver to discover additional devices on the native GSC bus
which are not identified by the PDC firmware.  The changes with the device inventory 
provided a clean way to only display the new devices discovered in the bus walk, without
displaying the entire device inventory every time the GSC bus was walked.

- Ryan

-- 

--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="lamont.patch"

Index: arch/parisc/kernel/ccio-dma.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/ccio-dma.c,v
retrieving revision 1.31
diff -u -p -r1.31 ccio-dma.c
--- ccio-dma.c	2001/07/09 02:33:55	1.31
+++ ccio-dma.c	2001/07/13 04:10:57
@@ -1470,6 +1470,8 @@ ccio_ioc_init(struct ioc *ioc)
 	/* CUJO20 KLUDGE end */
 }
 
+int do_native_bus_walk(unsigned long io_io_low);
+
 /*
 ** Determine if ccio should claim this chip (return 0) or not (return 1).
 ** If so, initialize the chip and tell other partners in crime they
@@ -1478,7 +1480,8 @@ ccio_ioc_init(struct ioc *ioc)
 static int
 ccio_driver_callback(struct hp_device *d, struct pa_iodc_driver *dri)
 {
-	int i;
+	int i, start_index, num_devices;
+	unsigned long io_io_low, io_io_high;
 	struct ccio_device *ioa = ccio_list;
 
 	printk("%s found %s at 0x%p\n", dri->name, dri->version, d->hpa);
@@ -1525,10 +1528,14 @@ ccio_driver_callback(struct hp_device *d
 	ccio_ioc_init(&ioa->ioc[i]);
 
 	hppa_dma_ops = &ccio_ops;
+	
+	io_io_low = READ_U32(&ioa->ioc[i].ioc_hpa->io_io_low) << 16;
+	io_io_high = READ_U32(&ioa->ioc[i].ioc_hpa->io_io_high) << 16;
+	printk("io_io_high: 0x%08lx io_io_low: 0x%08lx\n", io_io_low, io_io_high);
+	start_index = get_num_pa_dev();
+	num_devices = do_native_bus_walk(io_io_low);
+	print_pa_devices(start_index, num_devices);
 
-	printk("io_io_high: 0x%08x io_io_low: 0x%08x\n",
-	       READ_U32(&ioa->ioc[i].ioc_hpa->io_io_high) << 16,
-	       READ_U32(&ioa->ioc[i].ioc_hpa->io_io_low) << 16);
 	return 0;
 }
 
Index: arch/parisc/kernel/drivers.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/drivers.c,v
retrieving revision 1.16
diff -u -p -r1.16 drivers.c
--- drivers.c	2001/07/09 02:33:55	1.16
+++ drivers.c	2001/07/13 04:10:57
@@ -21,24 +21,33 @@
 
 static int num_devices;
 static struct hp_device pa_devices[MAX_DEVICES];
-
 static struct pa_iodc_driver *pa_drivers = NULL;
 
-static int compare_spec( struct hp_device * hp_dev,
-	struct pa_iodc_driver *driver)
+static int compare_spec(struct hp_device * hp_dev, struct pa_iodc_driver *driver)
 {
-	if ((driver->check & DRIVER_CHECK_HWTYPE)
-		&& (driver->hw_type != hp_dev->hw_type))	return 0;
-	if ((driver->check & DRIVER_CHECK_HVERSION)
-		&& (driver->hversion != hp_dev->hversion))	return 0;
-	if ((driver->check & DRIVER_CHECK_HVERSION_REV)
-		&& (driver->hversion_rev != hp_dev->hversion_rev)) return 0;
-	if ((driver->check & DRIVER_CHECK_SVERSION)
-		&& (driver->sversion != hp_dev->sversion))	return 0;
-	if ((driver->check & DRIVER_CHECK_SVERSION_REV)
-		&& (driver->sversion_rev != hp_dev->sversion_rev)) return 0;
-	if ((driver->check & DRIVER_CHECK_OPT)
-		&& (driver->opt != hp_dev->opt))		return 0;
+	if((driver->check & DRIVER_CHECK_HWTYPE)
+	   && (driver->hw_type != hp_dev->hw_type))
+		return 0;
+
+	if((driver->check & DRIVER_CHECK_HVERSION)
+	   && (driver->hversion != hp_dev->hversion))
+		return 0;
+
+	if((driver->check & DRIVER_CHECK_HVERSION_REV)
+	   && (driver->hversion_rev != hp_dev->hversion_rev)) 
+		return 0;
+
+	if((driver->check & DRIVER_CHECK_SVERSION)
+	   && (driver->sversion != hp_dev->sversion))
+		return 0;
+
+	if((driver->check & DRIVER_CHECK_SVERSION_REV)
+	   && (driver->sversion_rev != hp_dev->sversion_rev)) 
+		return 0;
+
+	if((driver->check & DRIVER_CHECK_OPT)
+	   && (driver->opt != hp_dev->opt))
+		return 0;
 
 	return 1;
 }
@@ -214,14 +223,18 @@ struct hp_device *get_pa_dev(unsigned in
 	return &pa_devices[index];
 }
 
+inline int get_num_pa_dev()
+{
+	return num_devices;
+}
 
-void print_pa_devices(char * buf)
+void print_pa_devices(int start_index, int num_indexes)
 {
 	int i, k;
+	int end_index = start_index + num_indexes;
 	struct hp_device *d;
 
-	printk("Found devices:\n");
-	for (i=0; i<num_devices; i++) {
+	for(i = start_index; i < end_index; i++) {
 		d = &pa_devices[i];
 		printk(KERN_INFO
 		"%d. %s (%d) at 0x%p, versions 0x%x, 0x%x, 0x%x, 0x%x, 0x%x",
@@ -231,12 +244,12 @@ void print_pa_devices(char * buf)
 		d->sversion, d->sversion_rev, d->opt);
 
 		if (d->num_addrs>1) {
-		    printk(",  additional addresses: ");
+		    printk(KERN_INFO ",  additional addresses: ");
 		    for (k=1; k<d->num_addrs; k++)
-			printk("0x%lx ", d->addr[k]);
+			printk(KERN_INFO "0x%lx ", d->addr[k]);
 		}
 
-		printk("\n");
+		printk(KERN_INFO "\n");
 	}
-	printk("That's a total of %d devices.\n", num_devices);
 }
+
Index: arch/parisc/kernel/inventory.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/inventory.c,v
retrieving revision 1.29
diff -u -p -r1.29 inventory.c
--- inventory.c	2001/06/20 20:24:32	1.29
+++ inventory.c	2001/07/13 04:10:57
@@ -591,7 +591,7 @@ int do_legacy_inventory(void)
 #define MAX_NATIVE_DEVICES 64
 #define NATIVE_DEVICE_OFFSET 0x1000
 
-static int do_native_bus_walk(unsigned long hpa)
+int do_native_bus_walk(unsigned long hpa)
 {
 	int num = 0;
 	struct hp_device *hp_device;
@@ -658,7 +658,7 @@ static int do_system_map_inventory(void)
 
 	/* Walk the system bus */
 	num += do_native_bus_walk(FPA);
-	return (num > 0);
+	return num;
 }
 
 void do_memory_inventory(void)
@@ -716,5 +716,7 @@ void do_device_inventory(void)
 		panic("I can't get the hardware inventory on this machine");
 	}
 
-	print_pa_devices(NULL);
+	printk(KERN_INFO "Found devices:\n");
+	print_pa_devices(0, num);
+	printk(KERN_INFO "That's a total of %d devices.\n", num);
 }
Index: include/asm-parisc/hardware.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/hardware.h,v
retrieving revision 1.17
diff -u -p -r1.17 hardware.h
--- hardware.h	2001/07/09 02:34:06	1.17
+++ hardware.h	2001/07/13 04:11:02
@@ -111,7 +111,8 @@ extern struct hp_device *alloc_pa_dev(un
 extern int register_pa_dev(struct hp_device *hp_device);
 extern int add_pa_dev_addr(struct hp_device *hp_device, unsigned long addr);
 extern struct hp_device *get_pa_dev(unsigned int index);
-extern void print_pa_devices(char * buf);
+extern inline int get_num_pa_dev(void);
+extern void print_pa_devices(int start_index, int num_indexes);
 extern int pdc_register_driver(struct pa_iodc_driver *driver);
 extern int pdc_unregister_driver(struct pa_iodc_driver *driver);
 
Index: Makefile
===================================================================
RCS file: /home/cvs/parisc/linux/Makefile,v
retrieving revision 1.95
diff -u -p -r1.95 Makefile
--- Makefile	2001/07/11 22:27:07	1.95
+++ Makefile	2001/07/13 04:17:49
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 6
-EXTRAVERSION = -pa12
+EXTRAVERSION = -pa13
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 

--jI8keyz6grp/JLjh--