patch-2.3.35 linux/drivers/sbus/dvma.c

Next file: linux/drivers/sbus/sbus.c
Previous file: linux/drivers/sbus/char/zs.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.34/linux/drivers/sbus/dvma.c linux/drivers/sbus/dvma.c
@@ -15,55 +15,51 @@
 #include <asm/dma.h>
 #include <asm/sbus.h>
 
-struct Linux_SBus_DMA *dma_chain;
+struct sbus_dma *dma_chain;
 
 /* Print out the current values in the DMA control registers */
-extern __inline__ void
-dump_dma_regs(struct sparc_dma_registers *dregs)
+extern __inline__ void dump_dma_regs(unsigned long dregs)
 {
-	printk("DMA CONTROL<%08lx>  ADDR<%08lx> CNT<%08lx> TEST<%08lx>\n",
-	       (unsigned long) dregs->cond_reg,
-	       (unsigned long) dregs->st_addr,
-	       (unsigned long) dregs->cnt,
-	       (unsigned long) dregs->dma_test);
-	return;
+	printk("DMA CONTROL<%08x> ADDR<%08x> CNT<%08x> TEST<%08x>\n",
+	       sbus_readl(dregs + DMA_CSR), sbus_readl(dregs + DMA_ADDR),
+	       sbus_readl(dregs + DMA_COUNT), sbus_readl(dregs + DMA_TEST));
 }
 
-void __init init_one_dvma(struct Linux_SBus_DMA *dma, int num_dma)
+void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
 {
 	printk("dma%d: ", num_dma);
 	
 	dma->next = 0;
-	dma->running=0;      /* No transfers going on as of yet */
-	dma->allocated=0;    /* No one has allocated us yet */
-	switch((dma->regs->cond_reg)&DMA_DEVICE_ID) {
+	dma->running = 0;      /* No transfers going on as of yet */
+	dma->allocated = 0;    /* No one has allocated us yet */
+	switch(sbus_readl(dma->regs + DMA_CSR)&DMA_DEVICE_ID) {
 	case DMA_VERS0:
-		dma->revision=dvmarev0;
+		dma->revision = dvmarev0;
 		printk("Revision 0 ");
 		break;
 	case DMA_ESCV1:
-		dma->revision=dvmaesc1;
+		dma->revision = dvmaesc1;
 		printk("ESC Revision 1 ");
 		break;
 	case DMA_VERS1:
-		dma->revision=dvmarev1;
+		dma->revision = dvmarev1;
 		printk("Revision 1 ");
 		break;
 	case DMA_VERS2:
-		dma->revision=dvmarev2;
+		dma->revision = dvmarev2;
 		printk("Revision 2 ");
 		break;
 	case DMA_VERHME:
-		dma->revision=dvmahme;
+		dma->revision = dvmahme;
 		printk("HME DVMA gate array ");
 		break;
 	case DMA_VERSPLUS:
-		dma->revision=dvmarevplus;
+		dma->revision = dvmarevplus;
 		printk("Revision 1 PLUS ");
 		break;
 	default:
-		printk("unknown dma version %x",
-		       (dma->regs->cond_reg)&DMA_DEVICE_ID);
+		printk("unknown dma version %08x",
+		       sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
 		dma->allocated = 1;
 		break;
 	}
@@ -74,57 +70,47 @@
 }
 
 /* Probe this SBus DMA module(s) */
-void __init dvma_init(struct linux_sbus *sbus)
+void __init dvma_init(struct sbus_bus *sbus)
 {
-	struct linux_sbus_device *this_dev;
-	struct Linux_SBus_DMA *dma;
-	struct Linux_SBus_DMA *dchain;
-	static int num_dma=0;
+	struct sbus_dev *this_dev;
+	struct sbus_dma *dma;
+	struct sbus_dma *dchain;
+	static int num_dma = 0;
 
 	for_each_sbusdev(this_dev, sbus) {
+		char *name = this_dev->prom_name;
 		int hme = 0;
 
-		if(!strcmp(this_dev->prom_name, "SUNW,fas"))
+		if(!strcmp(name, "SUNW,fas"))
 			hme = 1;
-		else if(strcmp(this_dev->prom_name, "dma") &&
-			strcmp(this_dev->prom_name, "ledma") &&
-			strcmp(this_dev->prom_name, "espdma"))
+		else if(strcmp(name, "dma") &&
+			strcmp(name, "ledma") &&
+			strcmp(name, "espdma"))
 			continue;
 
 		/* Found one... */
-		dma = kmalloc(sizeof(struct Linux_SBus_DMA), GFP_ATOMIC);
+		dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
 
-		dma->SBus_dev = this_dev;
+		dma->sdev = this_dev;
 
 		/* Put at end of dma chain */
 		dchain = dma_chain;
 		if(dchain) {
-			while(dchain->next) dchain=dchain->next;
-			dchain->next=dma;
+			while(dchain->next)
+				dchain = dchain->next;
+			dchain->next = dma;
 		} else {
 			/* We're the first in line */
-			dma_chain=dma;
+			dma_chain = dma;
 		}
 
-		/* The constant PAGE_SIZE that is passed to sparc_alloc_io makes the
-		 * routine only alloc 1 page, that was what the original code did
-		 */
-		if(hme) /* On HME cards, dvma lives with esp, 2 reg sets. */
-			prom_apply_sbus_ranges(sbus, dma->SBus_dev->reg_addrs,
-					       0x2, dma->SBus_dev);
-		else    /* All others have only 1 reg set. */
-			prom_apply_sbus_ranges(sbus, dma->SBus_dev->reg_addrs,
-					       0x1, dma->SBus_dev);
-		dma->regs = (struct sparc_dma_registers *)
-			sparc_alloc_io (dma->SBus_dev->reg_addrs[0].phys_addr, 0,
-					PAGE_SIZE, "dma",
-					dma->SBus_dev->reg_addrs[0].which_io, 0x0);
+		dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
+					 PAGE_SIZE, "dma");
 
-		dma->node = dma->SBus_dev->prom_node;
+		dma->node = dma->sdev->prom_node;
 		
 		init_one_dvma(dma, num_dma++);
-		
-	};  /* while(this_dev) */
+	}
 }
 
 #ifdef CONFIG_SUN4
@@ -133,28 +119,29 @@
 
 void __init sun4_dvma_init(void)
 {
-	struct Linux_SBus_DMA *dma;
-	struct Linux_SBus_DMA *dchain;
+	struct sbus_dma *dma;
+	struct sbus_dma *dchain;
+	struct resource r;
 
 	if(sun4_dma_physaddr) {
-		dma = kmalloc(sizeof(struct Linux_SBus_DMA), GFP_ATOMIC);
+		dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
 
 		/* No SBUS */
-		dma->SBus_dev = 0x0;
+		dma->sdev = NULL;
 
 		/* Only one DMA device */
-		dma_chain=dma;
+		dma_chain = dma;
 
-		dma->regs = (struct sparc_dma_registers *)
-			sparc_alloc_io (sun4_dma_physaddr, 0,
-					PAGE_SIZE, "dma", 0x0, 0x0);
+		memset(&r, 0, sizeof(r));
+		r.start = sun4_dma_physaddr;
+		dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
 
 		/* No prom node */
 		dma->node = 0x0;
 
 		init_one_dvma(dma, 0);
 	} else {
-	  	dma_chain=0x0;
+	  	dma_chain = NULL;
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)