[parisc-linux-cvs] Claim dino address space

Matthew Wilcox willy@debian.org
Sat, 13 Oct 2001 18:21:48 +0100


 * Fix device ID comment which has been broken since it was first committed
   in September 1999 :-)
 * Claim the memory region which Dino has been programmed to forward to the
   PCI bus.  Thanks to Ryan for testing this code.

Index: drivers/gsc/dino.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/gsc/dino.c,v
retrieving revision 1.42
diff -u -p -r1.42 dino.c
--- dino.c	2001/10/13 03:56:23	1.42
+++ dino.c	2001/10/13 17:05:23
@@ -693,37 +693,42 @@ dino_card_init(struct dino_device *dino_
 	** This short-cut speeds up booting significantly.
 	*/
 	mdelay(pci_post_reset_delay);
-
 }
 
-static void __init
+static int __init
 dino_bridge_init(struct dino_device *dino_dev)
 {
-	u32 io_addr, bpos=0, bmask=1;
-	
+	unsigned long io_addr;
+	int bpos, result;
+	struct resource *res;
+
 	/*
-	** Decoding IO_ADDR_EN only works for Built-in Dino
-	** since PDC has already initialized this.
-	*/
+	 * Decoding IO_ADDR_EN only works for Built-in Dino
+	 * since PDC has already initialized this.
+	 */
 	
-	io_addr = gsc_readl(dino_dev->hba.base_addr+DINO_IO_ADDR_EN);
-
-	for ( ; ((bmask & io_addr) == 0) && (bpos <33); 
-		bmask<<=1, bpos++) { 
-	};
-
-	if (bpos == 33) {
-		printk(KERN_WARNING "%s: IO_ADDR_EN hasn't been configured.\n", __FUNCTION__ );
-		BUG();
+	io_addr = gsc_readl(dino_dev->hba.base_addr + DINO_IO_ADDR_EN);
+	if (io_addr == 0) {
+		printk(KERN_WARNING "Dino: No PCI devices enabled.\n");
+		return -ENODEV;
+	}
+
+	for (bpos = 0; (io_addr & (1 << bpos)) == 0; bpos++)
+		;
+
+	res = &dino_dev->hba.lmmio_space;
+	res->name = "PCI %d"; /* XXX */
+	res->flags = IORESOURCE_MEM;
+	res->start = (unsigned long) 0xfffffffff0000000 | bpos << 23;
+	res->end = res->start + 8 * 1024 * 1024 - 1;
+	result = request_resource(&iomem_resource, res);
+	if (result < 0) {
+		printk(KERN_ERR "Dino: failed to claim PCI Bus address space!\n");
+		return result;
 	}
-	
-	/*
-	** Calculate the base of the Host I/O address range
-	** Dino will forward to the PCI bus.
-	*/
-	dino_dev->mmio_addr = 0xf0000000 + (bpos << 23); /* bpos x 8MB */
-	dino_dev->ioport_addr =  0;	/* not used for bridge mode */
+
 	dino_dev->hba.lmmio_space_offset = 0;	/* CPU addrs == bus addrs */
+	return 0;
 }
 
 static int __init
@@ -960,18 +965,17 @@ dino_driver_callback(struct parisc_devic
 }
 
 /*
- * If we read hversion from Dino, we're OK.  But the J2240 PDC reports the
- * wrong hversion for the first Dino.  Unfortunately, the Elroy PCI bus
- * adapter (used in newer B/C/J/A/L/N-class) has the same hversion.  So we
- * test the sversion as well to distinguish between the two.
+ * Normally, we would just test sversion.  But the Elroy PCI adapter has
+ * the same sversion as Dino, so we have to check hversion as well.
+ * Unfortunately, the J2240 PDC reports the wrong hversion for the first
+ * Dino, so we have to test for Dino, Cujo and Dino-in-a-J2240.
  */
-
 static struct parisc_device_id dino_tbl[] = {
 	{ HPHW_A_DMA, HVERSION_REV_ANY_ID, 0x004, 0x0009D }, /* Card-mode Dino. */
 	{ HPHW_A_DMA, HVERSION_REV_ANY_ID, 0x444, 0x08080 }, /* Same card in a 715.  Bug? */
 	{ HPHW_BRIDGE, HVERSION_REV_ANY_ID, 0x680, 0xa }, /* Bridge-mode Dino */
 	{ HPHW_BRIDGE, HVERSION_REV_ANY_ID, 0x682, 0xa }, /* Bridge-mode Cujo */
-	{ HPHW_BRIDGE, 0x03, 0x05d, 0xa }, /* Dino in a J2240 */
+	{ HPHW_BRIDGE, HVERSION_REV_ANY_ID, 0x05d, 0xa }, /* Dino in a J2240 */
 	{ 0, }
 };