Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d753722e authored by Geert Uytterhoeven's avatar Geert Uytterhoeven
Browse files

m68k/scsi: a3000 - Kill ugly DMA() macro

parent 6869b15e
Loading
Loading
Loading
Loading
+25 −19
Original line number Original line Diff line number Diff line
@@ -22,16 +22,15 @@
#include <linux/stat.h>
#include <linux/stat.h>




#define DMA(ptr)	((a3000_scsiregs *)((ptr)->base))

static struct Scsi_Host *a3000_host = NULL;
static struct Scsi_Host *a3000_host = NULL;


static int a3000_release(struct Scsi_Host *instance);
static int a3000_release(struct Scsi_Host *instance);


static irqreturn_t a3000_intr(int irq, void *dummy)
static irqreturn_t a3000_intr(int irq, void *dummy)
{
{
	a3000_scsiregs *regs = (a3000_scsiregs *)(a3000_host->base);
	unsigned int status = regs->ISTR;
	unsigned long flags;
	unsigned long flags;
	unsigned int status = DMA(a3000_host)->ISTR;


	if (!(status & ISTR_INT_P))
	if (!(status & ISTR_INT_P))
		return IRQ_NONE;
		return IRQ_NONE;
@@ -48,6 +47,7 @@ static irqreturn_t a3000_intr(int irq, void *dummy)
static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
{
{
	struct WD33C93_hostdata *hdata = shost_priv(a3000_host);
	struct WD33C93_hostdata *hdata = shost_priv(a3000_host);
	a3000_scsiregs *regs = (a3000_scsiregs *)(a3000_host->base);
	unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
	unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
	unsigned long addr = virt_to_bus(cmd->SCp.ptr);
	unsigned long addr = virt_to_bus(cmd->SCp.ptr);


@@ -84,10 +84,10 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
	/* remember direction */
	/* remember direction */
	hdata->dma_dir = dir_in;
	hdata->dma_dir = dir_in;


	DMA(a3000_host)->CNTR = cntr;
	regs->CNTR = cntr;


	/* setup DMA *physical* address */
	/* setup DMA *physical* address */
	DMA(a3000_host)->ACR = addr;
	regs->ACR = addr;


	if (dir_in) {
	if (dir_in) {
		/* invalidate any cache */
		/* invalidate any cache */
@@ -99,7 +99,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)


	/* start DMA */
	/* start DMA */
	mb();			/* make sure setup is completed */
	mb();			/* make sure setup is completed */
	DMA(a3000_host)->ST_DMA = 1;
	regs->ST_DMA = 1;
	mb();			/* make sure DMA has started before next IO */
	mb();			/* make sure DMA has started before next IO */


	/* return success */
	/* return success */
@@ -110,6 +110,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
		     int status)
		     int status)
{
{
	struct WD33C93_hostdata *hdata = shost_priv(instance);
	struct WD33C93_hostdata *hdata = shost_priv(instance);
	a3000_scsiregs *regs = (a3000_scsiregs *)(instance->base);


	/* disable SCSI interrupts */
	/* disable SCSI interrupts */
	unsigned short cntr = CNTR_PDMD;
	unsigned short cntr = CNTR_PDMD;
@@ -117,14 +118,14 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
	if (!hdata->dma_dir)
	if (!hdata->dma_dir)
		cntr |= CNTR_DDIR;
		cntr |= CNTR_DDIR;


	DMA(instance)->CNTR = cntr;
	regs->CNTR = cntr;
	mb();			/* make sure CNTR is updated before next IO */
	mb();			/* make sure CNTR is updated before next IO */


	/* flush if we were reading */
	/* flush if we were reading */
	if (hdata->dma_dir) {
	if (hdata->dma_dir) {
		DMA(instance)->FLUSH = 1;
		regs->FLUSH = 1;
		mb();		/* don't allow prefetch */
		mb();		/* don't allow prefetch */
		while (!(DMA(instance)->ISTR & ISTR_FE_FLG))
		while (!(regs->ISTR & ISTR_FE_FLG))
			barrier();
			barrier();
		mb();		/* no IO until FLUSH is done */
		mb();		/* no IO until FLUSH is done */
	}
	}
@@ -133,14 +134,14 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
	/* I think that this CINT is only necessary if you are
	/* I think that this CINT is only necessary if you are
	 * using the terminal count features.   HM 7 Mar 1994
	 * using the terminal count features.   HM 7 Mar 1994
	 */
	 */
	DMA(instance)->CINT = 1;
	regs->CINT = 1;


	/* stop DMA */
	/* stop DMA */
	DMA(instance)->SP_DMA = 1;
	regs->SP_DMA = 1;
	mb();			/* make sure DMA is stopped before next IO */
	mb();			/* make sure DMA is stopped before next IO */


	/* restore the CONTROL bits (minus the direction flag) */
	/* restore the CONTROL bits (minus the direction flag) */
	DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN;
	regs->CNTR = CNTR_PDMD | CNTR_INTEN;
	mb();			/* make sure CNTR is updated before next IO */
	mb();			/* make sure CNTR is updated before next IO */


	/* copy from a bounce buffer, if necessary */
	/* copy from a bounce buffer, if necessary */
@@ -163,7 +164,8 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,


static int __init a3000_detect(struct scsi_host_template *tpnt)
static int __init a3000_detect(struct scsi_host_template *tpnt)
{
{
	wd33c93_regs regs;
	wd33c93_regs wdregs;
	a3000_scsiregs *regs;
	struct WD33C93_hostdata *hdata;
	struct WD33C93_hostdata *hdata;


	if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(A3000_SCSI))
	if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(A3000_SCSI))
@@ -180,18 +182,20 @@ static int __init a3000_detect(struct scsi_host_template *tpnt)


	a3000_host->base = ZTWO_VADDR(0xDD0000);
	a3000_host->base = ZTWO_VADDR(0xDD0000);
	a3000_host->irq = IRQ_AMIGA_PORTS;
	a3000_host->irq = IRQ_AMIGA_PORTS;
	DMA(a3000_host)->DAWR = DAWR_A3000;
	regs = (a3000_scsiregs *)(a3000_host->base);
	regs.SASR = &(DMA(a3000_host)->SASR);
	regs->DAWR = DAWR_A3000;
	regs.SCMD = &(DMA(a3000_host)->SCMD);
	wdregs.SASR = &regs->SASR;
	wdregs.SCMD = &regs->SCMD;
	hdata = shost_priv(a3000_host);
	hdata = shost_priv(a3000_host);
	hdata->no_sync = 0xff;
	hdata->no_sync = 0xff;
	hdata->fast = 0;
	hdata->fast = 0;
	hdata->dma_mode = CTRL_DMA;
	hdata->dma_mode = CTRL_DMA;
	wd33c93_init(a3000_host, regs, dma_setup, dma_stop, WD33C93_FS_12_15);
	wd33c93_init(a3000_host, wdregs, dma_setup, dma_stop,
		     WD33C93_FS_12_15);
	if (request_irq(IRQ_AMIGA_PORTS, a3000_intr, IRQF_SHARED, "A3000 SCSI",
	if (request_irq(IRQ_AMIGA_PORTS, a3000_intr, IRQF_SHARED, "A3000 SCSI",
			a3000_intr))
			a3000_intr))
		goto fail_irq;
		goto fail_irq;
	DMA(a3000_host)->CNTR = CNTR_PDMD | CNTR_INTEN;
	regs->CNTR = CNTR_PDMD | CNTR_INTEN;


	return 1;
	return 1;


@@ -239,7 +243,9 @@ static struct scsi_host_template driver_template = {


static int a3000_release(struct Scsi_Host *instance)
static int a3000_release(struct Scsi_Host *instance)
{
{
	DMA(instance)->CNTR = 0;
	a3000_scsiregs *regs = (a3000_scsiregs *)(instance->base);

	regs->CNTR = 0;
	release_mem_region(0xDD0000, 256);
	release_mem_region(0xDD0000, 256);
	free_irq(IRQ_AMIGA_PORTS, a3000_intr);
	free_irq(IRQ_AMIGA_PORTS, a3000_intr);
	return 1;
	return 1;