xref: /openbmc/linux/drivers/scsi/zorro_esp.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
13109e5aeSMichael Schmitz // SPDX-License-Identifier: GPL-2.0
23109e5aeSMichael Schmitz /*
33109e5aeSMichael Schmitz  * ESP front-end for Amiga ZORRO SCSI systems.
43109e5aeSMichael Schmitz  *
53109e5aeSMichael Schmitz  * Copyright (C) 1996 Jesper Skov (jskov@cygnus.co.uk)
63109e5aeSMichael Schmitz  *
73109e5aeSMichael Schmitz  * Copyright (C) 2011,2018 Michael Schmitz (schmitz@debian.org) for
83109e5aeSMichael Schmitz  *               migration to ESP SCSI core
93109e5aeSMichael Schmitz  *
103109e5aeSMichael Schmitz  * Copyright (C) 2013 Tuomas Vainikka (tuomas.vainikka@aalto.fi) for
113109e5aeSMichael Schmitz  *               Blizzard 1230 DMA and probe function fixes
123109e5aeSMichael Schmitz  */
133109e5aeSMichael Schmitz /*
143109e5aeSMichael Schmitz  * ZORRO bus code from:
153109e5aeSMichael Schmitz  */
163109e5aeSMichael Schmitz /*
173109e5aeSMichael Schmitz  * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
183109e5aeSMichael Schmitz  *		Amiga MacroSystemUS WarpEngine SCSI controller.
193109e5aeSMichael Schmitz  *		Amiga Technologies/DKB A4091 SCSI controller.
203109e5aeSMichael Schmitz  *
213109e5aeSMichael Schmitz  * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
223109e5aeSMichael Schmitz  * plus modifications of the 53c7xx.c driver to support the Amiga.
233109e5aeSMichael Schmitz  *
243109e5aeSMichael Schmitz  * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
253109e5aeSMichael Schmitz  */
263109e5aeSMichael Schmitz 
273109e5aeSMichael Schmitz #define pr_fmt(fmt)        KBUILD_MODNAME ": " fmt
283109e5aeSMichael Schmitz 
293109e5aeSMichael Schmitz #include <linux/module.h>
303109e5aeSMichael Schmitz #include <linux/init.h>
313109e5aeSMichael Schmitz #include <linux/interrupt.h>
323109e5aeSMichael Schmitz #include <linux/dma-mapping.h>
333109e5aeSMichael Schmitz #include <linux/scatterlist.h>
343109e5aeSMichael Schmitz #include <linux/delay.h>
353109e5aeSMichael Schmitz #include <linux/zorro.h>
363109e5aeSMichael Schmitz #include <linux/slab.h>
3765fddcfcSMike Rapoport #include <linux/pgtable.h>
383109e5aeSMichael Schmitz 
393109e5aeSMichael Schmitz #include <asm/page.h>
403109e5aeSMichael Schmitz #include <asm/cacheflush.h>
413109e5aeSMichael Schmitz #include <asm/amigahw.h>
423109e5aeSMichael Schmitz #include <asm/amigaints.h>
433109e5aeSMichael Schmitz 
443109e5aeSMichael Schmitz #include <scsi/scsi_host.h>
453109e5aeSMichael Schmitz #include <scsi/scsi_transport_spi.h>
463109e5aeSMichael Schmitz #include <scsi/scsi_device.h>
473109e5aeSMichael Schmitz #include <scsi/scsi_tcq.h>
483109e5aeSMichael Schmitz 
493109e5aeSMichael Schmitz #include "esp_scsi.h"
503109e5aeSMichael Schmitz 
513109e5aeSMichael Schmitz MODULE_AUTHOR("Michael Schmitz <schmitz@debian.org>");
523109e5aeSMichael Schmitz MODULE_DESCRIPTION("Amiga Zorro NCR5C9x (ESP) driver");
533109e5aeSMichael Schmitz MODULE_LICENSE("GPL");
543109e5aeSMichael Schmitz 
553109e5aeSMichael Schmitz /* per-board register layout definitions */
563109e5aeSMichael Schmitz 
573109e5aeSMichael Schmitz /* Blizzard 1230 DMA interface */
583109e5aeSMichael Schmitz 
593109e5aeSMichael Schmitz struct blz1230_dma_registers {
603109e5aeSMichael Schmitz 	unsigned char dma_addr;		/* DMA address      [0x0000] */
613109e5aeSMichael Schmitz 	unsigned char dmapad2[0x7fff];
623109e5aeSMichael Schmitz 	unsigned char dma_latch;	/* DMA latch        [0x8000] */
633109e5aeSMichael Schmitz };
643109e5aeSMichael Schmitz 
653109e5aeSMichael Schmitz /* Blizzard 1230II DMA interface */
663109e5aeSMichael Schmitz 
673109e5aeSMichael Schmitz struct blz1230II_dma_registers {
683109e5aeSMichael Schmitz 	unsigned char dma_addr;		/* DMA address      [0x0000] */
693109e5aeSMichael Schmitz 	unsigned char dmapad2[0xf];
703109e5aeSMichael Schmitz 	unsigned char dma_latch;	/* DMA latch        [0x0010] */
713109e5aeSMichael Schmitz };
723109e5aeSMichael Schmitz 
733109e5aeSMichael Schmitz /* Blizzard 2060 DMA interface */
743109e5aeSMichael Schmitz 
753109e5aeSMichael Schmitz struct blz2060_dma_registers {
763109e5aeSMichael Schmitz 	unsigned char dma_led_ctrl;	/* DMA led control   [0x000] */
773109e5aeSMichael Schmitz 	unsigned char dmapad1[0x0f];
783109e5aeSMichael Schmitz 	unsigned char dma_addr0;	/* DMA address (MSB) [0x010] */
793109e5aeSMichael Schmitz 	unsigned char dmapad2[0x03];
803109e5aeSMichael Schmitz 	unsigned char dma_addr1;	/* DMA address       [0x014] */
813109e5aeSMichael Schmitz 	unsigned char dmapad3[0x03];
823109e5aeSMichael Schmitz 	unsigned char dma_addr2;	/* DMA address       [0x018] */
833109e5aeSMichael Schmitz 	unsigned char dmapad4[0x03];
843109e5aeSMichael Schmitz 	unsigned char dma_addr3;	/* DMA address (LSB) [0x01c] */
853109e5aeSMichael Schmitz };
863109e5aeSMichael Schmitz 
873109e5aeSMichael Schmitz /* DMA control bits */
883109e5aeSMichael Schmitz #define DMA_WRITE 0x80000000
893109e5aeSMichael Schmitz 
903109e5aeSMichael Schmitz /* Cyberstorm DMA interface */
913109e5aeSMichael Schmitz 
923109e5aeSMichael Schmitz struct cyber_dma_registers {
933109e5aeSMichael Schmitz 	unsigned char dma_addr0;	/* DMA address (MSB) [0x000] */
943109e5aeSMichael Schmitz 	unsigned char dmapad1[1];
953109e5aeSMichael Schmitz 	unsigned char dma_addr1;	/* DMA address       [0x002] */
963109e5aeSMichael Schmitz 	unsigned char dmapad2[1];
973109e5aeSMichael Schmitz 	unsigned char dma_addr2;	/* DMA address       [0x004] */
983109e5aeSMichael Schmitz 	unsigned char dmapad3[1];
993109e5aeSMichael Schmitz 	unsigned char dma_addr3;	/* DMA address (LSB) [0x006] */
1003109e5aeSMichael Schmitz 	unsigned char dmapad4[0x3fb];
1013109e5aeSMichael Schmitz 	unsigned char cond_reg;		/* DMA cond    (ro)  [0x402] */
1023109e5aeSMichael Schmitz #define ctrl_reg  cond_reg		/* DMA control (wo)  [0x402] */
1033109e5aeSMichael Schmitz };
1043109e5aeSMichael Schmitz 
1053109e5aeSMichael Schmitz /* DMA control bits */
1063109e5aeSMichael Schmitz #define CYBER_DMA_WRITE  0x40	/* DMA direction. 1 = write */
1073109e5aeSMichael Schmitz #define CYBER_DMA_Z3     0x20	/* 16 (Z2) or 32 (CHIP/Z3) bit DMA transfer */
1083109e5aeSMichael Schmitz 
1093109e5aeSMichael Schmitz /* DMA status bits */
1103109e5aeSMichael Schmitz #define CYBER_DMA_HNDL_INTR 0x80	/* DMA IRQ pending? */
1113109e5aeSMichael Schmitz 
1123109e5aeSMichael Schmitz /* The CyberStorm II DMA interface */
1133109e5aeSMichael Schmitz struct cyberII_dma_registers {
1143109e5aeSMichael Schmitz 	unsigned char cond_reg;		/* DMA cond    (ro)  [0x000] */
1153109e5aeSMichael Schmitz #define ctrl_reg  cond_reg		/* DMA control (wo)  [0x000] */
1163109e5aeSMichael Schmitz 	unsigned char dmapad4[0x3f];
1173109e5aeSMichael Schmitz 	unsigned char dma_addr0;	/* DMA address (MSB) [0x040] */
1183109e5aeSMichael Schmitz 	unsigned char dmapad1[3];
1193109e5aeSMichael Schmitz 	unsigned char dma_addr1;	/* DMA address       [0x044] */
1203109e5aeSMichael Schmitz 	unsigned char dmapad2[3];
1213109e5aeSMichael Schmitz 	unsigned char dma_addr2;	/* DMA address       [0x048] */
1223109e5aeSMichael Schmitz 	unsigned char dmapad3[3];
1233109e5aeSMichael Schmitz 	unsigned char dma_addr3;	/* DMA address (LSB) [0x04c] */
1243109e5aeSMichael Schmitz };
1253109e5aeSMichael Schmitz 
1263109e5aeSMichael Schmitz /* Fastlane DMA interface */
1273109e5aeSMichael Schmitz 
1283109e5aeSMichael Schmitz struct fastlane_dma_registers {
1293109e5aeSMichael Schmitz 	unsigned char cond_reg;		/* DMA status  (ro) [0x0000] */
1303109e5aeSMichael Schmitz #define ctrl_reg  cond_reg		/* DMA control (wo) [0x0000] */
1313109e5aeSMichael Schmitz 	char dmapad1[0x3f];
1323109e5aeSMichael Schmitz 	unsigned char clear_strobe;	/* DMA clear   (wo) [0x0040] */
1333109e5aeSMichael Schmitz };
1343109e5aeSMichael Schmitz 
1353109e5aeSMichael Schmitz /*
1363109e5aeSMichael Schmitz  * The controller registers can be found in the Z2 config area at these
1373109e5aeSMichael Schmitz  * offsets:
1383109e5aeSMichael Schmitz  */
1393109e5aeSMichael Schmitz #define FASTLANE_ESP_ADDR	0x1000001
1403109e5aeSMichael Schmitz 
1413109e5aeSMichael Schmitz /* DMA status bits */
1423109e5aeSMichael Schmitz #define FASTLANE_DMA_MINT	0x80
1433109e5aeSMichael Schmitz #define FASTLANE_DMA_IACT	0x40
1443109e5aeSMichael Schmitz #define FASTLANE_DMA_CREQ	0x20
1453109e5aeSMichael Schmitz 
1463109e5aeSMichael Schmitz /* DMA control bits */
1473109e5aeSMichael Schmitz #define FASTLANE_DMA_FCODE	0xa0
1483109e5aeSMichael Schmitz #define FASTLANE_DMA_MASK	0xf3
1493109e5aeSMichael Schmitz #define FASTLANE_DMA_WRITE	0x08	/* 1 = write */
1503109e5aeSMichael Schmitz #define FASTLANE_DMA_ENABLE	0x04	/* Enable DMA */
1513109e5aeSMichael Schmitz #define FASTLANE_DMA_EDI	0x02	/* Enable DMA IRQ ? */
1523109e5aeSMichael Schmitz #define FASTLANE_DMA_ESI	0x01	/* Enable SCSI IRQ */
1533109e5aeSMichael Schmitz 
1543109e5aeSMichael Schmitz /*
1553109e5aeSMichael Schmitz  * private data used for driver
1563109e5aeSMichael Schmitz  */
1573109e5aeSMichael Schmitz struct zorro_esp_priv {
1583109e5aeSMichael Schmitz 	struct esp *esp;		/* our ESP instance - for Scsi_host* */
1593109e5aeSMichael Schmitz 	void __iomem *board_base;	/* virtual address (Zorro III board) */
1603109e5aeSMichael Schmitz 	int zorro3;			/* board is Zorro III */
1613109e5aeSMichael Schmitz 	unsigned char ctrl_data;	/* shadow copy of ctrl_reg */
1623109e5aeSMichael Schmitz };
1633109e5aeSMichael Schmitz 
1643109e5aeSMichael Schmitz /*
1653109e5aeSMichael Schmitz  * On all implementations except for the Oktagon, padding between ESP
1663109e5aeSMichael Schmitz  * registers is three bytes.
1673109e5aeSMichael Schmitz  * On Oktagon, it is one byte - use a different accessor there.
1683109e5aeSMichael Schmitz  *
1693109e5aeSMichael Schmitz  * Oktagon needs PDMA - currently unsupported!
1703109e5aeSMichael Schmitz  */
1713109e5aeSMichael Schmitz 
zorro_esp_write8(struct esp * esp,u8 val,unsigned long reg)1723109e5aeSMichael Schmitz static void zorro_esp_write8(struct esp *esp, u8 val, unsigned long reg)
1733109e5aeSMichael Schmitz {
1743109e5aeSMichael Schmitz 	writeb(val, esp->regs + (reg * 4UL));
1753109e5aeSMichael Schmitz }
1763109e5aeSMichael Schmitz 
zorro_esp_read8(struct esp * esp,unsigned long reg)1773109e5aeSMichael Schmitz static u8 zorro_esp_read8(struct esp *esp, unsigned long reg)
1783109e5aeSMichael Schmitz {
1793109e5aeSMichael Schmitz 	return readb(esp->regs + (reg * 4UL));
1803109e5aeSMichael Schmitz }
1813109e5aeSMichael Schmitz 
zorro_esp_irq_pending(struct esp * esp)1823109e5aeSMichael Schmitz static int zorro_esp_irq_pending(struct esp *esp)
1833109e5aeSMichael Schmitz {
1843109e5aeSMichael Schmitz 	/* check ESP status register; DMA has no status reg. */
1853109e5aeSMichael Schmitz 	if (zorro_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR)
1863109e5aeSMichael Schmitz 		return 1;
1873109e5aeSMichael Schmitz 
1883109e5aeSMichael Schmitz 	return 0;
1893109e5aeSMichael Schmitz }
1903109e5aeSMichael Schmitz 
cyber_esp_irq_pending(struct esp * esp)1913109e5aeSMichael Schmitz static int cyber_esp_irq_pending(struct esp *esp)
1923109e5aeSMichael Schmitz {
1933109e5aeSMichael Schmitz 	struct cyber_dma_registers __iomem *dregs = esp->dma_regs;
1943109e5aeSMichael Schmitz 	unsigned char dma_status = readb(&dregs->cond_reg);
1953109e5aeSMichael Schmitz 
1963109e5aeSMichael Schmitz 	/* It's important to check the DMA IRQ bit in the correct way! */
1973109e5aeSMichael Schmitz 	return ((zorro_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR) &&
1983109e5aeSMichael Schmitz 		(dma_status & CYBER_DMA_HNDL_INTR));
1993109e5aeSMichael Schmitz }
2003109e5aeSMichael Schmitz 
fastlane_esp_irq_pending(struct esp * esp)2013109e5aeSMichael Schmitz static int fastlane_esp_irq_pending(struct esp *esp)
2023109e5aeSMichael Schmitz {
2033109e5aeSMichael Schmitz 	struct fastlane_dma_registers __iomem *dregs = esp->dma_regs;
2043109e5aeSMichael Schmitz 	unsigned char dma_status;
2053109e5aeSMichael Schmitz 
2063109e5aeSMichael Schmitz 	dma_status = readb(&dregs->cond_reg);
2073109e5aeSMichael Schmitz 
2083109e5aeSMichael Schmitz 	if (dma_status & FASTLANE_DMA_IACT)
2093109e5aeSMichael Schmitz 		return 0;	/* not our IRQ */
2103109e5aeSMichael Schmitz 
2113109e5aeSMichael Schmitz 	/* Return non-zero if ESP requested IRQ */
2123109e5aeSMichael Schmitz 	return (
2133109e5aeSMichael Schmitz 	   (dma_status & FASTLANE_DMA_CREQ) &&
2143109e5aeSMichael Schmitz 	   (!(dma_status & FASTLANE_DMA_MINT)) &&
2153109e5aeSMichael Schmitz 	   (zorro_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR));
2163109e5aeSMichael Schmitz }
2173109e5aeSMichael Schmitz 
zorro_esp_dma_length_limit(struct esp * esp,u32 dma_addr,u32 dma_len)2183109e5aeSMichael Schmitz static u32 zorro_esp_dma_length_limit(struct esp *esp, u32 dma_addr,
2193109e5aeSMichael Schmitz 					u32 dma_len)
2203109e5aeSMichael Schmitz {
22102f7e9f3SKars de Jong 	return dma_len > (1U << 16) ? (1U << 16) : dma_len;
22202f7e9f3SKars de Jong }
22302f7e9f3SKars de Jong 
fastlane_esp_dma_length_limit(struct esp * esp,u32 dma_addr,u32 dma_len)22402f7e9f3SKars de Jong static u32 fastlane_esp_dma_length_limit(struct esp *esp, u32 dma_addr,
22502f7e9f3SKars de Jong 					u32 dma_len)
22602f7e9f3SKars de Jong {
22702f7e9f3SKars de Jong 	/* The old driver used 0xfffc as limit, so do that here too */
22802f7e9f3SKars de Jong 	return dma_len > 0xfffc ? 0xfffc : dma_len;
2293109e5aeSMichael Schmitz }
2303109e5aeSMichael Schmitz 
zorro_esp_reset_dma(struct esp * esp)2313109e5aeSMichael Schmitz static void zorro_esp_reset_dma(struct esp *esp)
2323109e5aeSMichael Schmitz {
2333109e5aeSMichael Schmitz 	/* nothing to do here */
2343109e5aeSMichael Schmitz }
2353109e5aeSMichael Schmitz 
zorro_esp_dma_drain(struct esp * esp)2363109e5aeSMichael Schmitz static void zorro_esp_dma_drain(struct esp *esp)
2373109e5aeSMichael Schmitz {
2383109e5aeSMichael Schmitz 	/* nothing to do here */
2393109e5aeSMichael Schmitz }
2403109e5aeSMichael Schmitz 
zorro_esp_dma_invalidate(struct esp * esp)2413109e5aeSMichael Schmitz static void zorro_esp_dma_invalidate(struct esp *esp)
2423109e5aeSMichael Schmitz {
2433109e5aeSMichael Schmitz 	/* nothing to do here */
2443109e5aeSMichael Schmitz }
2453109e5aeSMichael Schmitz 
fastlane_esp_dma_invalidate(struct esp * esp)2463109e5aeSMichael Schmitz static void fastlane_esp_dma_invalidate(struct esp *esp)
2473109e5aeSMichael Schmitz {
2483109e5aeSMichael Schmitz 	struct zorro_esp_priv *zep = dev_get_drvdata(esp->dev);
2493109e5aeSMichael Schmitz 	struct fastlane_dma_registers __iomem *dregs = esp->dma_regs;
2503109e5aeSMichael Schmitz 	unsigned char *ctrl_data = &zep->ctrl_data;
2513109e5aeSMichael Schmitz 
2523109e5aeSMichael Schmitz 	*ctrl_data = (*ctrl_data & FASTLANE_DMA_MASK);
2533109e5aeSMichael Schmitz 	writeb(0, &dregs->clear_strobe);
2543109e5aeSMichael Schmitz 	z_writel(0, zep->board_base);
2553109e5aeSMichael Schmitz }
2563109e5aeSMichael Schmitz 
2573109e5aeSMichael Schmitz /* Blizzard 1230/60 SCSI-IV DMA */
2583109e5aeSMichael Schmitz 
zorro_esp_send_blz1230_dma_cmd(struct esp * esp,u32 addr,u32 esp_count,u32 dma_count,int write,u8 cmd)2593109e5aeSMichael Schmitz static void zorro_esp_send_blz1230_dma_cmd(struct esp *esp, u32 addr,
2603109e5aeSMichael Schmitz 			u32 esp_count, u32 dma_count, int write, u8 cmd)
2613109e5aeSMichael Schmitz {
2623109e5aeSMichael Schmitz 	struct blz1230_dma_registers __iomem *dregs = esp->dma_regs;
2633109e5aeSMichael Schmitz 	u8 phase = esp->sreg & ESP_STAT_PMASK;
2643109e5aeSMichael Schmitz 
2653109e5aeSMichael Schmitz 	/*
2663109e5aeSMichael Schmitz 	 * Use PIO if transferring message bytes to esp->command_block_dma.
2673109e5aeSMichael Schmitz 	 * PIO requires a virtual address, so substitute esp->command_block
2683109e5aeSMichael Schmitz 	 * for addr.
2693109e5aeSMichael Schmitz 	 */
2703109e5aeSMichael Schmitz 	if (phase == ESP_MIP && addr == esp->command_block_dma) {
27153dce332SFinn Thain 		esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count,
27253dce332SFinn Thain 				 dma_count, write, cmd);
2733109e5aeSMichael Schmitz 		return;
2743109e5aeSMichael Schmitz 	}
2753109e5aeSMichael Schmitz 
27653dce332SFinn Thain 	/* Clear the results of a possible prior esp->ops->send_dma_cmd() */
27753dce332SFinn Thain 	esp->send_cmd_error = 0;
27853dce332SFinn Thain 	esp->send_cmd_residual = 0;
27953dce332SFinn Thain 
2803109e5aeSMichael Schmitz 	if (write)
2813109e5aeSMichael Schmitz 		/* DMA receive */
2823109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
2833109e5aeSMichael Schmitz 				DMA_FROM_DEVICE);
2843109e5aeSMichael Schmitz 	else
2853109e5aeSMichael Schmitz 		/* DMA send */
2863109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
2873109e5aeSMichael Schmitz 				DMA_TO_DEVICE);
2883109e5aeSMichael Schmitz 
2893109e5aeSMichael Schmitz 	addr >>= 1;
2903109e5aeSMichael Schmitz 	if (write)
2913109e5aeSMichael Schmitz 		addr &= ~(DMA_WRITE);
2923109e5aeSMichael Schmitz 	else
2933109e5aeSMichael Schmitz 		addr |= DMA_WRITE;
2943109e5aeSMichael Schmitz 
2953109e5aeSMichael Schmitz 	writeb((addr >> 24) & 0xff, &dregs->dma_latch);
2963109e5aeSMichael Schmitz 	writeb((addr >> 24) & 0xff, &dregs->dma_addr);
2973109e5aeSMichael Schmitz 	writeb((addr >> 16) & 0xff, &dregs->dma_addr);
2983109e5aeSMichael Schmitz 	writeb((addr >>  8) & 0xff, &dregs->dma_addr);
2993109e5aeSMichael Schmitz 	writeb(addr & 0xff, &dregs->dma_addr);
3003109e5aeSMichael Schmitz 
3013109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, ESP_CMD_DMA);
3023109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
3033109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
3043109e5aeSMichael Schmitz 
3053109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, cmd);
3063109e5aeSMichael Schmitz }
3073109e5aeSMichael Schmitz 
3083109e5aeSMichael Schmitz /* Blizzard 1230-II DMA */
3093109e5aeSMichael Schmitz 
zorro_esp_send_blz1230II_dma_cmd(struct esp * esp,u32 addr,u32 esp_count,u32 dma_count,int write,u8 cmd)3103109e5aeSMichael Schmitz static void zorro_esp_send_blz1230II_dma_cmd(struct esp *esp, u32 addr,
3113109e5aeSMichael Schmitz 			u32 esp_count, u32 dma_count, int write, u8 cmd)
3123109e5aeSMichael Schmitz {
3133109e5aeSMichael Schmitz 	struct blz1230II_dma_registers __iomem *dregs = esp->dma_regs;
3143109e5aeSMichael Schmitz 	u8 phase = esp->sreg & ESP_STAT_PMASK;
3153109e5aeSMichael Schmitz 
3163109e5aeSMichael Schmitz 	/* Use PIO if transferring message bytes to esp->command_block_dma */
3173109e5aeSMichael Schmitz 	if (phase == ESP_MIP && addr == esp->command_block_dma) {
31853dce332SFinn Thain 		esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count,
31953dce332SFinn Thain 				 dma_count, write, cmd);
3203109e5aeSMichael Schmitz 		return;
3213109e5aeSMichael Schmitz 	}
3223109e5aeSMichael Schmitz 
32353dce332SFinn Thain 	esp->send_cmd_error = 0;
32453dce332SFinn Thain 	esp->send_cmd_residual = 0;
32553dce332SFinn Thain 
3263109e5aeSMichael Schmitz 	if (write)
3273109e5aeSMichael Schmitz 		/* DMA receive */
3283109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
3293109e5aeSMichael Schmitz 				DMA_FROM_DEVICE);
3303109e5aeSMichael Schmitz 	else
3313109e5aeSMichael Schmitz 		/* DMA send */
3323109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
3333109e5aeSMichael Schmitz 				DMA_TO_DEVICE);
3343109e5aeSMichael Schmitz 
3353109e5aeSMichael Schmitz 	addr >>= 1;
3363109e5aeSMichael Schmitz 	if (write)
3373109e5aeSMichael Schmitz 		addr &= ~(DMA_WRITE);
3383109e5aeSMichael Schmitz 	else
3393109e5aeSMichael Schmitz 		addr |= DMA_WRITE;
3403109e5aeSMichael Schmitz 
3413109e5aeSMichael Schmitz 	writeb((addr >> 24) & 0xff, &dregs->dma_latch);
3423109e5aeSMichael Schmitz 	writeb((addr >> 16) & 0xff, &dregs->dma_addr);
3433109e5aeSMichael Schmitz 	writeb((addr >>  8) & 0xff, &dregs->dma_addr);
3443109e5aeSMichael Schmitz 	writeb(addr & 0xff, &dregs->dma_addr);
3453109e5aeSMichael Schmitz 
3463109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, ESP_CMD_DMA);
3473109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
3483109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
3493109e5aeSMichael Schmitz 
3503109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, cmd);
3513109e5aeSMichael Schmitz }
3523109e5aeSMichael Schmitz 
3533109e5aeSMichael Schmitz /* Blizzard 2060 DMA */
3543109e5aeSMichael Schmitz 
zorro_esp_send_blz2060_dma_cmd(struct esp * esp,u32 addr,u32 esp_count,u32 dma_count,int write,u8 cmd)3553109e5aeSMichael Schmitz static void zorro_esp_send_blz2060_dma_cmd(struct esp *esp, u32 addr,
3563109e5aeSMichael Schmitz 			u32 esp_count, u32 dma_count, int write, u8 cmd)
3573109e5aeSMichael Schmitz {
3583109e5aeSMichael Schmitz 	struct blz2060_dma_registers __iomem *dregs = esp->dma_regs;
3593109e5aeSMichael Schmitz 	u8 phase = esp->sreg & ESP_STAT_PMASK;
3603109e5aeSMichael Schmitz 
3613109e5aeSMichael Schmitz 	/* Use PIO if transferring message bytes to esp->command_block_dma */
3623109e5aeSMichael Schmitz 	if (phase == ESP_MIP && addr == esp->command_block_dma) {
36353dce332SFinn Thain 		esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count,
36453dce332SFinn Thain 				 dma_count, write, cmd);
3653109e5aeSMichael Schmitz 		return;
3663109e5aeSMichael Schmitz 	}
3673109e5aeSMichael Schmitz 
36853dce332SFinn Thain 	esp->send_cmd_error = 0;
36953dce332SFinn Thain 	esp->send_cmd_residual = 0;
37053dce332SFinn Thain 
3713109e5aeSMichael Schmitz 	if (write)
3723109e5aeSMichael Schmitz 		/* DMA receive */
3733109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
3743109e5aeSMichael Schmitz 				DMA_FROM_DEVICE);
3753109e5aeSMichael Schmitz 	else
3763109e5aeSMichael Schmitz 		/* DMA send */
3773109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
3783109e5aeSMichael Schmitz 				DMA_TO_DEVICE);
3793109e5aeSMichael Schmitz 
3803109e5aeSMichael Schmitz 	addr >>= 1;
3813109e5aeSMichael Schmitz 	if (write)
3823109e5aeSMichael Schmitz 		addr &= ~(DMA_WRITE);
3833109e5aeSMichael Schmitz 	else
3843109e5aeSMichael Schmitz 		addr |= DMA_WRITE;
3853109e5aeSMichael Schmitz 
3863109e5aeSMichael Schmitz 	writeb(addr & 0xff, &dregs->dma_addr3);
3873109e5aeSMichael Schmitz 	writeb((addr >>  8) & 0xff, &dregs->dma_addr2);
3883109e5aeSMichael Schmitz 	writeb((addr >> 16) & 0xff, &dregs->dma_addr1);
3893109e5aeSMichael Schmitz 	writeb((addr >> 24) & 0xff, &dregs->dma_addr0);
3903109e5aeSMichael Schmitz 
3913109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, ESP_CMD_DMA);
3923109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
3933109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
3943109e5aeSMichael Schmitz 
3953109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, cmd);
3963109e5aeSMichael Schmitz }
3973109e5aeSMichael Schmitz 
3983109e5aeSMichael Schmitz /* Cyberstorm I DMA */
3993109e5aeSMichael Schmitz 
zorro_esp_send_cyber_dma_cmd(struct esp * esp,u32 addr,u32 esp_count,u32 dma_count,int write,u8 cmd)4003109e5aeSMichael Schmitz static void zorro_esp_send_cyber_dma_cmd(struct esp *esp, u32 addr,
4013109e5aeSMichael Schmitz 			u32 esp_count, u32 dma_count, int write, u8 cmd)
4023109e5aeSMichael Schmitz {
4033109e5aeSMichael Schmitz 	struct zorro_esp_priv *zep = dev_get_drvdata(esp->dev);
4043109e5aeSMichael Schmitz 	struct cyber_dma_registers __iomem *dregs = esp->dma_regs;
4053109e5aeSMichael Schmitz 	u8 phase = esp->sreg & ESP_STAT_PMASK;
4063109e5aeSMichael Schmitz 	unsigned char *ctrl_data = &zep->ctrl_data;
4073109e5aeSMichael Schmitz 
4083109e5aeSMichael Schmitz 	/* Use PIO if transferring message bytes to esp->command_block_dma */
4093109e5aeSMichael Schmitz 	if (phase == ESP_MIP && addr == esp->command_block_dma) {
41053dce332SFinn Thain 		esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count,
41153dce332SFinn Thain 				 dma_count, write, cmd);
4123109e5aeSMichael Schmitz 		return;
4133109e5aeSMichael Schmitz 	}
4143109e5aeSMichael Schmitz 
41553dce332SFinn Thain 	esp->send_cmd_error = 0;
41653dce332SFinn Thain 	esp->send_cmd_residual = 0;
41753dce332SFinn Thain 
4183109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
4193109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
4203109e5aeSMichael Schmitz 
4213109e5aeSMichael Schmitz 	if (write) {
4223109e5aeSMichael Schmitz 		/* DMA receive */
4233109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
4243109e5aeSMichael Schmitz 				DMA_FROM_DEVICE);
4253109e5aeSMichael Schmitz 		addr &= ~(1);
4263109e5aeSMichael Schmitz 	} else {
4273109e5aeSMichael Schmitz 		/* DMA send */
4283109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
4293109e5aeSMichael Schmitz 				DMA_TO_DEVICE);
4303109e5aeSMichael Schmitz 		addr |= 1;
4313109e5aeSMichael Schmitz 	}
4323109e5aeSMichael Schmitz 
4333109e5aeSMichael Schmitz 	writeb((addr >> 24) & 0xff, &dregs->dma_addr0);
4343109e5aeSMichael Schmitz 	writeb((addr >> 16) & 0xff, &dregs->dma_addr1);
4353109e5aeSMichael Schmitz 	writeb((addr >>  8) & 0xff, &dregs->dma_addr2);
4363109e5aeSMichael Schmitz 	writeb(addr & 0xff, &dregs->dma_addr3);
4373109e5aeSMichael Schmitz 
4383109e5aeSMichael Schmitz 	if (write)
4393109e5aeSMichael Schmitz 		*ctrl_data &= ~(CYBER_DMA_WRITE);
4403109e5aeSMichael Schmitz 	else
4413109e5aeSMichael Schmitz 		*ctrl_data |= CYBER_DMA_WRITE;
4423109e5aeSMichael Schmitz 
4433109e5aeSMichael Schmitz 	*ctrl_data &= ~(CYBER_DMA_Z3);	/* Z2, do 16 bit DMA */
4443109e5aeSMichael Schmitz 
4453109e5aeSMichael Schmitz 	writeb(*ctrl_data, &dregs->ctrl_reg);
4463109e5aeSMichael Schmitz 
4473109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, cmd);
4483109e5aeSMichael Schmitz }
4493109e5aeSMichael Schmitz 
4503109e5aeSMichael Schmitz /* Cyberstorm II DMA */
4513109e5aeSMichael Schmitz 
zorro_esp_send_cyberII_dma_cmd(struct esp * esp,u32 addr,u32 esp_count,u32 dma_count,int write,u8 cmd)4523109e5aeSMichael Schmitz static void zorro_esp_send_cyberII_dma_cmd(struct esp *esp, u32 addr,
4533109e5aeSMichael Schmitz 			u32 esp_count, u32 dma_count, int write, u8 cmd)
4543109e5aeSMichael Schmitz {
4553109e5aeSMichael Schmitz 	struct cyberII_dma_registers __iomem *dregs = esp->dma_regs;
4563109e5aeSMichael Schmitz 	u8 phase = esp->sreg & ESP_STAT_PMASK;
4573109e5aeSMichael Schmitz 
4583109e5aeSMichael Schmitz 	/* Use PIO if transferring message bytes to esp->command_block_dma */
4593109e5aeSMichael Schmitz 	if (phase == ESP_MIP && addr == esp->command_block_dma) {
46053dce332SFinn Thain 		esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count,
46153dce332SFinn Thain 				 dma_count, write, cmd);
4623109e5aeSMichael Schmitz 		return;
4633109e5aeSMichael Schmitz 	}
4643109e5aeSMichael Schmitz 
46553dce332SFinn Thain 	esp->send_cmd_error = 0;
46653dce332SFinn Thain 	esp->send_cmd_residual = 0;
46753dce332SFinn Thain 
4683109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
4693109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
4703109e5aeSMichael Schmitz 
4713109e5aeSMichael Schmitz 	if (write) {
4723109e5aeSMichael Schmitz 		/* DMA receive */
4733109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
4743109e5aeSMichael Schmitz 				DMA_FROM_DEVICE);
4753109e5aeSMichael Schmitz 		addr &= ~(1);
4763109e5aeSMichael Schmitz 	} else {
4773109e5aeSMichael Schmitz 		/* DMA send */
4783109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
4793109e5aeSMichael Schmitz 				DMA_TO_DEVICE);
4803109e5aeSMichael Schmitz 		addr |= 1;
4813109e5aeSMichael Schmitz 	}
4823109e5aeSMichael Schmitz 
4833109e5aeSMichael Schmitz 	writeb((addr >> 24) & 0xff, &dregs->dma_addr0);
4843109e5aeSMichael Schmitz 	writeb((addr >> 16) & 0xff, &dregs->dma_addr1);
4853109e5aeSMichael Schmitz 	writeb((addr >>  8) & 0xff, &dregs->dma_addr2);
4863109e5aeSMichael Schmitz 	writeb(addr & 0xff, &dregs->dma_addr3);
4873109e5aeSMichael Schmitz 
4883109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, cmd);
4893109e5aeSMichael Schmitz }
4903109e5aeSMichael Schmitz 
4913109e5aeSMichael Schmitz /* Fastlane DMA */
4923109e5aeSMichael Schmitz 
zorro_esp_send_fastlane_dma_cmd(struct esp * esp,u32 addr,u32 esp_count,u32 dma_count,int write,u8 cmd)4933109e5aeSMichael Schmitz static void zorro_esp_send_fastlane_dma_cmd(struct esp *esp, u32 addr,
4943109e5aeSMichael Schmitz 			u32 esp_count, u32 dma_count, int write, u8 cmd)
4953109e5aeSMichael Schmitz {
4963109e5aeSMichael Schmitz 	struct zorro_esp_priv *zep = dev_get_drvdata(esp->dev);
4973109e5aeSMichael Schmitz 	struct fastlane_dma_registers __iomem *dregs = esp->dma_regs;
4983109e5aeSMichael Schmitz 	u8 phase = esp->sreg & ESP_STAT_PMASK;
4993109e5aeSMichael Schmitz 	unsigned char *ctrl_data = &zep->ctrl_data;
5003109e5aeSMichael Schmitz 
5013109e5aeSMichael Schmitz 	/* Use PIO if transferring message bytes to esp->command_block_dma */
5023109e5aeSMichael Schmitz 	if (phase == ESP_MIP && addr == esp->command_block_dma) {
50353dce332SFinn Thain 		esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count,
50453dce332SFinn Thain 				 dma_count, write, cmd);
5053109e5aeSMichael Schmitz 		return;
5063109e5aeSMichael Schmitz 	}
5073109e5aeSMichael Schmitz 
50853dce332SFinn Thain 	esp->send_cmd_error = 0;
50953dce332SFinn Thain 	esp->send_cmd_residual = 0;
51053dce332SFinn Thain 
5113109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
5123109e5aeSMichael Schmitz 	zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
5133109e5aeSMichael Schmitz 
5143109e5aeSMichael Schmitz 	if (write) {
5153109e5aeSMichael Schmitz 		/* DMA receive */
5163109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
5173109e5aeSMichael Schmitz 				DMA_FROM_DEVICE);
5183109e5aeSMichael Schmitz 		addr &= ~(1);
5193109e5aeSMichael Schmitz 	} else {
5203109e5aeSMichael Schmitz 		/* DMA send */
5213109e5aeSMichael Schmitz 		dma_sync_single_for_device(esp->dev, addr, esp_count,
5223109e5aeSMichael Schmitz 				DMA_TO_DEVICE);
5233109e5aeSMichael Schmitz 		addr |= 1;
5243109e5aeSMichael Schmitz 	}
5253109e5aeSMichael Schmitz 
5263109e5aeSMichael Schmitz 	writeb(0, &dregs->clear_strobe);
5273109e5aeSMichael Schmitz 	z_writel(addr, ((addr & 0x00ffffff) + zep->board_base));
5283109e5aeSMichael Schmitz 
5293109e5aeSMichael Schmitz 	if (write) {
5303109e5aeSMichael Schmitz 		*ctrl_data = (*ctrl_data & FASTLANE_DMA_MASK) |
5313109e5aeSMichael Schmitz 				FASTLANE_DMA_ENABLE;
5323109e5aeSMichael Schmitz 	} else {
5333109e5aeSMichael Schmitz 		*ctrl_data = ((*ctrl_data & FASTLANE_DMA_MASK) |
5343109e5aeSMichael Schmitz 				FASTLANE_DMA_ENABLE |
5353109e5aeSMichael Schmitz 				FASTLANE_DMA_WRITE);
5363109e5aeSMichael Schmitz 	}
5373109e5aeSMichael Schmitz 
5383109e5aeSMichael Schmitz 	writeb(*ctrl_data, &dregs->ctrl_reg);
5393109e5aeSMichael Schmitz 
5403109e5aeSMichael Schmitz 	scsi_esp_cmd(esp, cmd);
5413109e5aeSMichael Schmitz }
5423109e5aeSMichael Schmitz 
zorro_esp_dma_error(struct esp * esp)5433109e5aeSMichael Schmitz static int zorro_esp_dma_error(struct esp *esp)
5443109e5aeSMichael Schmitz {
54553dce332SFinn Thain 	return esp->send_cmd_error;
5463109e5aeSMichael Schmitz }
5473109e5aeSMichael Schmitz 
5483109e5aeSMichael Schmitz /* per-board ESP driver ops */
5493109e5aeSMichael Schmitz 
5503109e5aeSMichael Schmitz static const struct esp_driver_ops blz1230_esp_ops = {
5513109e5aeSMichael Schmitz 	.esp_write8		= zorro_esp_write8,
5523109e5aeSMichael Schmitz 	.esp_read8		= zorro_esp_read8,
5533109e5aeSMichael Schmitz 	.irq_pending		= zorro_esp_irq_pending,
5543109e5aeSMichael Schmitz 	.dma_length_limit	= zorro_esp_dma_length_limit,
5553109e5aeSMichael Schmitz 	.reset_dma		= zorro_esp_reset_dma,
5563109e5aeSMichael Schmitz 	.dma_drain		= zorro_esp_dma_drain,
5573109e5aeSMichael Schmitz 	.dma_invalidate		= zorro_esp_dma_invalidate,
5583109e5aeSMichael Schmitz 	.send_dma_cmd		= zorro_esp_send_blz1230_dma_cmd,
5593109e5aeSMichael Schmitz 	.dma_error		= zorro_esp_dma_error,
5603109e5aeSMichael Schmitz };
5613109e5aeSMichael Schmitz 
5623109e5aeSMichael Schmitz static const struct esp_driver_ops blz1230II_esp_ops = {
5633109e5aeSMichael Schmitz 	.esp_write8		= zorro_esp_write8,
5643109e5aeSMichael Schmitz 	.esp_read8		= zorro_esp_read8,
5653109e5aeSMichael Schmitz 	.irq_pending		= zorro_esp_irq_pending,
5663109e5aeSMichael Schmitz 	.dma_length_limit	= zorro_esp_dma_length_limit,
5673109e5aeSMichael Schmitz 	.reset_dma		= zorro_esp_reset_dma,
5683109e5aeSMichael Schmitz 	.dma_drain		= zorro_esp_dma_drain,
5693109e5aeSMichael Schmitz 	.dma_invalidate		= zorro_esp_dma_invalidate,
5703109e5aeSMichael Schmitz 	.send_dma_cmd		= zorro_esp_send_blz1230II_dma_cmd,
5713109e5aeSMichael Schmitz 	.dma_error		= zorro_esp_dma_error,
5723109e5aeSMichael Schmitz };
5733109e5aeSMichael Schmitz 
5743109e5aeSMichael Schmitz static const struct esp_driver_ops blz2060_esp_ops = {
5753109e5aeSMichael Schmitz 	.esp_write8		= zorro_esp_write8,
5763109e5aeSMichael Schmitz 	.esp_read8		= zorro_esp_read8,
5773109e5aeSMichael Schmitz 	.irq_pending		= zorro_esp_irq_pending,
5783109e5aeSMichael Schmitz 	.dma_length_limit	= zorro_esp_dma_length_limit,
5793109e5aeSMichael Schmitz 	.reset_dma		= zorro_esp_reset_dma,
5803109e5aeSMichael Schmitz 	.dma_drain		= zorro_esp_dma_drain,
5813109e5aeSMichael Schmitz 	.dma_invalidate		= zorro_esp_dma_invalidate,
5823109e5aeSMichael Schmitz 	.send_dma_cmd		= zorro_esp_send_blz2060_dma_cmd,
5833109e5aeSMichael Schmitz 	.dma_error		= zorro_esp_dma_error,
5843109e5aeSMichael Schmitz };
5853109e5aeSMichael Schmitz 
5863109e5aeSMichael Schmitz static const struct esp_driver_ops cyber_esp_ops = {
5873109e5aeSMichael Schmitz 	.esp_write8		= zorro_esp_write8,
5883109e5aeSMichael Schmitz 	.esp_read8		= zorro_esp_read8,
5893109e5aeSMichael Schmitz 	.irq_pending		= cyber_esp_irq_pending,
5903109e5aeSMichael Schmitz 	.dma_length_limit	= zorro_esp_dma_length_limit,
5913109e5aeSMichael Schmitz 	.reset_dma		= zorro_esp_reset_dma,
5923109e5aeSMichael Schmitz 	.dma_drain		= zorro_esp_dma_drain,
5933109e5aeSMichael Schmitz 	.dma_invalidate		= zorro_esp_dma_invalidate,
5943109e5aeSMichael Schmitz 	.send_dma_cmd		= zorro_esp_send_cyber_dma_cmd,
5953109e5aeSMichael Schmitz 	.dma_error		= zorro_esp_dma_error,
5963109e5aeSMichael Schmitz };
5973109e5aeSMichael Schmitz 
5983109e5aeSMichael Schmitz static const struct esp_driver_ops cyberII_esp_ops = {
5993109e5aeSMichael Schmitz 	.esp_write8		= zorro_esp_write8,
6003109e5aeSMichael Schmitz 	.esp_read8		= zorro_esp_read8,
6013109e5aeSMichael Schmitz 	.irq_pending		= zorro_esp_irq_pending,
6023109e5aeSMichael Schmitz 	.dma_length_limit	= zorro_esp_dma_length_limit,
6033109e5aeSMichael Schmitz 	.reset_dma		= zorro_esp_reset_dma,
6043109e5aeSMichael Schmitz 	.dma_drain		= zorro_esp_dma_drain,
6053109e5aeSMichael Schmitz 	.dma_invalidate		= zorro_esp_dma_invalidate,
6063109e5aeSMichael Schmitz 	.send_dma_cmd		= zorro_esp_send_cyberII_dma_cmd,
6073109e5aeSMichael Schmitz 	.dma_error		= zorro_esp_dma_error,
6083109e5aeSMichael Schmitz };
6093109e5aeSMichael Schmitz 
6103109e5aeSMichael Schmitz static const struct esp_driver_ops fastlane_esp_ops = {
6113109e5aeSMichael Schmitz 	.esp_write8		= zorro_esp_write8,
6123109e5aeSMichael Schmitz 	.esp_read8		= zorro_esp_read8,
6133109e5aeSMichael Schmitz 	.irq_pending		= fastlane_esp_irq_pending,
61402f7e9f3SKars de Jong 	.dma_length_limit	= fastlane_esp_dma_length_limit,
6153109e5aeSMichael Schmitz 	.reset_dma		= zorro_esp_reset_dma,
6163109e5aeSMichael Schmitz 	.dma_drain		= zorro_esp_dma_drain,
6173109e5aeSMichael Schmitz 	.dma_invalidate		= fastlane_esp_dma_invalidate,
6183109e5aeSMichael Schmitz 	.send_dma_cmd		= zorro_esp_send_fastlane_dma_cmd,
6193109e5aeSMichael Schmitz 	.dma_error		= zorro_esp_dma_error,
6203109e5aeSMichael Schmitz };
6213109e5aeSMichael Schmitz 
6223109e5aeSMichael Schmitz /* Zorro driver config data */
6233109e5aeSMichael Schmitz 
6243109e5aeSMichael Schmitz struct zorro_driver_data {
6253109e5aeSMichael Schmitz 	const char *name;
6263109e5aeSMichael Schmitz 	unsigned long offset;
6273109e5aeSMichael Schmitz 	unsigned long dma_offset;
6283109e5aeSMichael Schmitz 	int absolute;	/* offset is absolute address */
6293109e5aeSMichael Schmitz 	int scsi_option;
6303109e5aeSMichael Schmitz 	const struct esp_driver_ops *esp_ops;
6313109e5aeSMichael Schmitz };
6323109e5aeSMichael Schmitz 
6333109e5aeSMichael Schmitz /* board types */
6343109e5aeSMichael Schmitz 
6353109e5aeSMichael Schmitz enum {
6363109e5aeSMichael Schmitz 	ZORRO_BLZ1230,
6373109e5aeSMichael Schmitz 	ZORRO_BLZ1230II,
6383109e5aeSMichael Schmitz 	ZORRO_BLZ2060,
6393109e5aeSMichael Schmitz 	ZORRO_CYBER,
6403109e5aeSMichael Schmitz 	ZORRO_CYBERII,
6413109e5aeSMichael Schmitz 	ZORRO_FASTLANE,
6423109e5aeSMichael Schmitz };
6433109e5aeSMichael Schmitz 
6443109e5aeSMichael Schmitz /* per-board config data */
6453109e5aeSMichael Schmitz 
6463109e5aeSMichael Schmitz static const struct zorro_driver_data zorro_esp_boards[] = {
6473109e5aeSMichael Schmitz 	[ZORRO_BLZ1230] = {
6483109e5aeSMichael Schmitz 				.name		= "Blizzard 1230",
6493109e5aeSMichael Schmitz 				.offset		= 0x8000,
6503109e5aeSMichael Schmitz 				.dma_offset	= 0x10000,
6513109e5aeSMichael Schmitz 				.scsi_option	= 1,
6523109e5aeSMichael Schmitz 				.esp_ops	= &blz1230_esp_ops,
6533109e5aeSMichael Schmitz 	},
6543109e5aeSMichael Schmitz 	[ZORRO_BLZ1230II] = {
6553109e5aeSMichael Schmitz 				.name		= "Blizzard 1230II",
6563109e5aeSMichael Schmitz 				.offset		= 0x10000,
6573109e5aeSMichael Schmitz 				.dma_offset	= 0x10021,
6583109e5aeSMichael Schmitz 				.scsi_option	= 1,
6593109e5aeSMichael Schmitz 				.esp_ops	= &blz1230II_esp_ops,
6603109e5aeSMichael Schmitz 	},
6613109e5aeSMichael Schmitz 	[ZORRO_BLZ2060] = {
6623109e5aeSMichael Schmitz 				.name		= "Blizzard 2060",
6633109e5aeSMichael Schmitz 				.offset		= 0x1ff00,
6643109e5aeSMichael Schmitz 				.dma_offset	= 0x1ffe0,
6653109e5aeSMichael Schmitz 				.esp_ops	= &blz2060_esp_ops,
6663109e5aeSMichael Schmitz 	},
6673109e5aeSMichael Schmitz 	[ZORRO_CYBER] = {
6683109e5aeSMichael Schmitz 				.name		= "CyberStormI",
6693109e5aeSMichael Schmitz 				.offset		= 0xf400,
6703109e5aeSMichael Schmitz 				.dma_offset	= 0xf800,
6713109e5aeSMichael Schmitz 				.esp_ops	= &cyber_esp_ops,
6723109e5aeSMichael Schmitz 	},
6733109e5aeSMichael Schmitz 	[ZORRO_CYBERII] = {
6743109e5aeSMichael Schmitz 				.name		= "CyberStormII",
6753109e5aeSMichael Schmitz 				.offset		= 0x1ff03,
6763109e5aeSMichael Schmitz 				.dma_offset	= 0x1ff43,
6773109e5aeSMichael Schmitz 				.scsi_option	= 1,
6783109e5aeSMichael Schmitz 				.esp_ops	= &cyberII_esp_ops,
6793109e5aeSMichael Schmitz 	},
6803109e5aeSMichael Schmitz 	[ZORRO_FASTLANE] = {
6813109e5aeSMichael Schmitz 				.name		= "Fastlane",
6823109e5aeSMichael Schmitz 				.offset		= 0x1000001,
6833109e5aeSMichael Schmitz 				.dma_offset	= 0x1000041,
6843109e5aeSMichael Schmitz 				.esp_ops	= &fastlane_esp_ops,
6853109e5aeSMichael Schmitz 	},
6863109e5aeSMichael Schmitz };
6873109e5aeSMichael Schmitz 
6883109e5aeSMichael Schmitz static const struct zorro_device_id zorro_esp_zorro_tbl[] = {
6893109e5aeSMichael Schmitz 	{	/* Blizzard 1230 IV */
6903109e5aeSMichael Schmitz 		.id = ZORRO_ID(PHASE5, 0x11, 0),
6913109e5aeSMichael Schmitz 		.driver_data = ZORRO_BLZ1230,
6923109e5aeSMichael Schmitz 	},
6933109e5aeSMichael Schmitz 	{	/* Blizzard 1230 II (Zorro II) or Fastlane (Zorro III) */
6943109e5aeSMichael Schmitz 		.id = ZORRO_ID(PHASE5, 0x0B, 0),
6953109e5aeSMichael Schmitz 		.driver_data = ZORRO_BLZ1230II,
6963109e5aeSMichael Schmitz 	},
6973109e5aeSMichael Schmitz 	{	/* Blizzard 2060 */
6983109e5aeSMichael Schmitz 		.id = ZORRO_ID(PHASE5, 0x18, 0),
6993109e5aeSMichael Schmitz 		.driver_data = ZORRO_BLZ2060,
7003109e5aeSMichael Schmitz 	},
7013109e5aeSMichael Schmitz 	{	/* Cyberstorm */
7023109e5aeSMichael Schmitz 		.id = ZORRO_ID(PHASE5, 0x0C, 0),
7033109e5aeSMichael Schmitz 		.driver_data = ZORRO_CYBER,
7043109e5aeSMichael Schmitz 	},
7053109e5aeSMichael Schmitz 	{	/* Cyberstorm II */
7063109e5aeSMichael Schmitz 		.id = ZORRO_ID(PHASE5, 0x19, 0),
7073109e5aeSMichael Schmitz 		.driver_data = ZORRO_CYBERII,
7083109e5aeSMichael Schmitz 	},
7093109e5aeSMichael Schmitz 	{ 0 }
7103109e5aeSMichael Schmitz };
7113109e5aeSMichael Schmitz MODULE_DEVICE_TABLE(zorro, zorro_esp_zorro_tbl);
7123109e5aeSMichael Schmitz 
zorro_esp_probe(struct zorro_dev * z,const struct zorro_device_id * ent)7133109e5aeSMichael Schmitz static int zorro_esp_probe(struct zorro_dev *z,
7143109e5aeSMichael Schmitz 				       const struct zorro_device_id *ent)
7153109e5aeSMichael Schmitz {
716*3b465a14SBart Van Assche 	const struct scsi_host_template *tpnt = &scsi_esp_template;
7173109e5aeSMichael Schmitz 	struct Scsi_Host *host;
7183109e5aeSMichael Schmitz 	struct esp *esp;
7193109e5aeSMichael Schmitz 	const struct zorro_driver_data *zdd;
7203109e5aeSMichael Schmitz 	struct zorro_esp_priv *zep;
7213109e5aeSMichael Schmitz 	unsigned long board, ioaddr, dmaaddr;
7223109e5aeSMichael Schmitz 	int err;
7233109e5aeSMichael Schmitz 
7243109e5aeSMichael Schmitz 	board = zorro_resource_start(z);
7253109e5aeSMichael Schmitz 	zdd = &zorro_esp_boards[ent->driver_data];
7263109e5aeSMichael Schmitz 
7273109e5aeSMichael Schmitz 	pr_info("%s found at address 0x%lx.\n", zdd->name, board);
7283109e5aeSMichael Schmitz 
7293109e5aeSMichael Schmitz 	zep = kzalloc(sizeof(*zep), GFP_KERNEL);
7303109e5aeSMichael Schmitz 	if (!zep) {
7313109e5aeSMichael Schmitz 		pr_err("Can't allocate device private data!\n");
7323109e5aeSMichael Schmitz 		return -ENOMEM;
7333109e5aeSMichael Schmitz 	}
7343109e5aeSMichael Schmitz 
7353109e5aeSMichael Schmitz 	/* let's figure out whether we have a Zorro II or Zorro III board */
7363109e5aeSMichael Schmitz 	if ((z->rom.er_Type & ERT_TYPEMASK) == ERT_ZORROIII) {
7373109e5aeSMichael Schmitz 		if (board > 0xffffff)
7383109e5aeSMichael Schmitz 			zep->zorro3 = 1;
7393109e5aeSMichael Schmitz 	} else {
7403109e5aeSMichael Schmitz 		/*
7413109e5aeSMichael Schmitz 		 * Even though most of these boards identify as Zorro II,
7423109e5aeSMichael Schmitz 		 * they are in fact CPU expansion slot boards and have full
7433109e5aeSMichael Schmitz 		 * access to all of memory. Fix up DMA bitmask here.
7443109e5aeSMichael Schmitz 		 */
7453109e5aeSMichael Schmitz 		z->dev.coherent_dma_mask = DMA_BIT_MASK(32);
7463109e5aeSMichael Schmitz 	}
7473109e5aeSMichael Schmitz 
7483109e5aeSMichael Schmitz 	/*
7493109e5aeSMichael Schmitz 	 * If Zorro III and ID matches Fastlane, our device table entry
7503109e5aeSMichael Schmitz 	 * contains data for the Blizzard 1230 II board which does share the
7513109e5aeSMichael Schmitz 	 * same ID. Fix up device table entry here.
7523109e5aeSMichael Schmitz 	 * TODO: Some Cyberstom060 boards also share this ID but would need
7533109e5aeSMichael Schmitz 	 * to use the Cyberstorm I driver data ... we catch this by checking
7543109e5aeSMichael Schmitz 	 * for presence of ESP chip later, but don't try to fix up yet.
7553109e5aeSMichael Schmitz 	 */
7563109e5aeSMichael Schmitz 	if (zep->zorro3 && ent->driver_data == ZORRO_BLZ1230II) {
7573109e5aeSMichael Schmitz 		pr_info("%s at address 0x%lx is Fastlane Z3, fixing data!\n",
7583109e5aeSMichael Schmitz 			zdd->name, board);
7593109e5aeSMichael Schmitz 		zdd = &zorro_esp_boards[ZORRO_FASTLANE];
7603109e5aeSMichael Schmitz 	}
7613109e5aeSMichael Schmitz 
7623109e5aeSMichael Schmitz 	if (zdd->absolute) {
7633109e5aeSMichael Schmitz 		ioaddr  = zdd->offset;
7643109e5aeSMichael Schmitz 		dmaaddr = zdd->dma_offset;
7653109e5aeSMichael Schmitz 	} else {
7663109e5aeSMichael Schmitz 		ioaddr  = board + zdd->offset;
7673109e5aeSMichael Schmitz 		dmaaddr = board + zdd->dma_offset;
7683109e5aeSMichael Schmitz 	}
7693109e5aeSMichael Schmitz 
7703109e5aeSMichael Schmitz 	if (!zorro_request_device(z, zdd->name)) {
7713109e5aeSMichael Schmitz 		pr_err("cannot reserve region 0x%lx, abort\n",
7723109e5aeSMichael Schmitz 		       board);
7733109e5aeSMichael Schmitz 		err = -EBUSY;
7743109e5aeSMichael Schmitz 		goto fail_free_zep;
7753109e5aeSMichael Schmitz 	}
7763109e5aeSMichael Schmitz 
7773109e5aeSMichael Schmitz 	host = scsi_host_alloc(tpnt, sizeof(struct esp));
7783109e5aeSMichael Schmitz 
7793109e5aeSMichael Schmitz 	if (!host) {
7803109e5aeSMichael Schmitz 		pr_err("No host detected; board configuration problem?\n");
7813109e5aeSMichael Schmitz 		err = -ENOMEM;
7823109e5aeSMichael Schmitz 		goto fail_release_device;
7833109e5aeSMichael Schmitz 	}
7843109e5aeSMichael Schmitz 
7853109e5aeSMichael Schmitz 	host->base		= ioaddr;
7863109e5aeSMichael Schmitz 	host->this_id		= 7;
7873109e5aeSMichael Schmitz 
7883109e5aeSMichael Schmitz 	esp			= shost_priv(host);
7893109e5aeSMichael Schmitz 	esp->host		= host;
7903109e5aeSMichael Schmitz 	esp->dev		= &z->dev;
7913109e5aeSMichael Schmitz 
7923109e5aeSMichael Schmitz 	esp->scsi_id		= host->this_id;
7933109e5aeSMichael Schmitz 	esp->scsi_id_mask	= (1 << esp->scsi_id);
7943109e5aeSMichael Schmitz 
7953109e5aeSMichael Schmitz 	esp->cfreq = 40000000;
7963109e5aeSMichael Schmitz 
7973109e5aeSMichael Schmitz 	zep->esp = esp;
7983109e5aeSMichael Schmitz 
7993109e5aeSMichael Schmitz 	dev_set_drvdata(esp->dev, zep);
8003109e5aeSMichael Schmitz 
8013109e5aeSMichael Schmitz 	/* additional setup required for Fastlane */
8023109e5aeSMichael Schmitz 	if (zep->zorro3 && ent->driver_data == ZORRO_BLZ1230II) {
8033109e5aeSMichael Schmitz 		/* map full address space up to ESP base for DMA */
8040d963008SGeert Uytterhoeven 		zep->board_base = ioremap(board, FASTLANE_ESP_ADDR - 1);
8053109e5aeSMichael Schmitz 		if (!zep->board_base) {
8063109e5aeSMichael Schmitz 			pr_err("Cannot allocate board address space\n");
8073109e5aeSMichael Schmitz 			err = -ENOMEM;
8083109e5aeSMichael Schmitz 			goto fail_free_host;
8093109e5aeSMichael Schmitz 		}
8103109e5aeSMichael Schmitz 		/* initialize DMA control shadow register */
8113109e5aeSMichael Schmitz 		zep->ctrl_data = (FASTLANE_DMA_FCODE |
8123109e5aeSMichael Schmitz 				  FASTLANE_DMA_EDI | FASTLANE_DMA_ESI);
8133109e5aeSMichael Schmitz 	}
8143109e5aeSMichael Schmitz 
8153109e5aeSMichael Schmitz 	esp->ops = zdd->esp_ops;
8163109e5aeSMichael Schmitz 
8173109e5aeSMichael Schmitz 	if (ioaddr > 0xffffff)
8184bdc0d67SChristoph Hellwig 		esp->regs = ioremap(ioaddr, 0x20);
8193109e5aeSMichael Schmitz 	else
8203109e5aeSMichael Schmitz 		/* ZorroII address space remapped nocache by early startup */
8213109e5aeSMichael Schmitz 		esp->regs = ZTWO_VADDR(ioaddr);
8223109e5aeSMichael Schmitz 
8233109e5aeSMichael Schmitz 	if (!esp->regs) {
8243109e5aeSMichael Schmitz 		err = -ENOMEM;
8253109e5aeSMichael Schmitz 		goto fail_unmap_fastlane;
8263109e5aeSMichael Schmitz 	}
8273109e5aeSMichael Schmitz 
82853dce332SFinn Thain 	esp->fifo_reg = esp->regs + ESP_FDATA * 4;
82953dce332SFinn Thain 
8303109e5aeSMichael Schmitz 	/* Check whether a Blizzard 12x0 or CyberstormII really has SCSI */
8313109e5aeSMichael Schmitz 	if (zdd->scsi_option) {
8323109e5aeSMichael Schmitz 		zorro_esp_write8(esp, (ESP_CONFIG1_PENABLE | 7), ESP_CFG1);
8333109e5aeSMichael Schmitz 		if (zorro_esp_read8(esp, ESP_CFG1) != (ESP_CONFIG1_PENABLE|7)) {
8343109e5aeSMichael Schmitz 			err = -ENODEV;
8353109e5aeSMichael Schmitz 			goto fail_unmap_regs;
8363109e5aeSMichael Schmitz 		}
8373109e5aeSMichael Schmitz 	}
8383109e5aeSMichael Schmitz 
8393109e5aeSMichael Schmitz 	if (zep->zorro3) {
8403109e5aeSMichael Schmitz 		/*
8413109e5aeSMichael Schmitz 		 * Only Fastlane Z3 for now - add switch for correct struct
8423109e5aeSMichael Schmitz 		 * dma_registers size if adding any more
8433109e5aeSMichael Schmitz 		 */
8444bdc0d67SChristoph Hellwig 		esp->dma_regs = ioremap(dmaaddr,
8453109e5aeSMichael Schmitz 					sizeof(struct fastlane_dma_registers));
8463109e5aeSMichael Schmitz 	} else
8473109e5aeSMichael Schmitz 		/* ZorroII address space remapped nocache by early startup */
8483109e5aeSMichael Schmitz 		esp->dma_regs = ZTWO_VADDR(dmaaddr);
8493109e5aeSMichael Schmitz 
8503109e5aeSMichael Schmitz 	if (!esp->dma_regs) {
8513109e5aeSMichael Schmitz 		err = -ENOMEM;
8523109e5aeSMichael Schmitz 		goto fail_unmap_regs;
8533109e5aeSMichael Schmitz 	}
8543109e5aeSMichael Schmitz 
8553109e5aeSMichael Schmitz 	esp->command_block = dma_alloc_coherent(esp->dev, 16,
8563109e5aeSMichael Schmitz 						&esp->command_block_dma,
8573109e5aeSMichael Schmitz 						GFP_KERNEL);
8583109e5aeSMichael Schmitz 
8593109e5aeSMichael Schmitz 	if (!esp->command_block) {
8603109e5aeSMichael Schmitz 		err = -ENOMEM;
8613109e5aeSMichael Schmitz 		goto fail_unmap_dma_regs;
8623109e5aeSMichael Schmitz 	}
8633109e5aeSMichael Schmitz 
8643109e5aeSMichael Schmitz 	host->irq = IRQ_AMIGA_PORTS;
8653109e5aeSMichael Schmitz 	err = request_irq(host->irq, scsi_esp_intr, IRQF_SHARED,
8663109e5aeSMichael Schmitz 			  "Amiga Zorro ESP", esp);
8673109e5aeSMichael Schmitz 	if (err < 0) {
8683109e5aeSMichael Schmitz 		err = -ENODEV;
8693109e5aeSMichael Schmitz 		goto fail_free_command_block;
8703109e5aeSMichael Schmitz 	}
8713109e5aeSMichael Schmitz 
8723109e5aeSMichael Schmitz 	/* register the chip */
87344b1b4d2SChristoph Hellwig 	err = scsi_esp_register(esp);
8743109e5aeSMichael Schmitz 
8753109e5aeSMichael Schmitz 	if (err) {
8763109e5aeSMichael Schmitz 		err = -ENOMEM;
8773109e5aeSMichael Schmitz 		goto fail_free_irq;
8783109e5aeSMichael Schmitz 	}
8793109e5aeSMichael Schmitz 
8803109e5aeSMichael Schmitz 	return 0;
8813109e5aeSMichael Schmitz 
8823109e5aeSMichael Schmitz fail_free_irq:
8833109e5aeSMichael Schmitz 	free_irq(host->irq, esp);
8843109e5aeSMichael Schmitz 
8853109e5aeSMichael Schmitz fail_free_command_block:
8863109e5aeSMichael Schmitz 	dma_free_coherent(esp->dev, 16,
8873109e5aeSMichael Schmitz 			  esp->command_block,
8883109e5aeSMichael Schmitz 			  esp->command_block_dma);
8893109e5aeSMichael Schmitz 
8903109e5aeSMichael Schmitz fail_unmap_dma_regs:
8913109e5aeSMichael Schmitz 	if (zep->zorro3)
8923109e5aeSMichael Schmitz 		iounmap(esp->dma_regs);
8933109e5aeSMichael Schmitz 
8943109e5aeSMichael Schmitz fail_unmap_regs:
8953109e5aeSMichael Schmitz 	if (ioaddr > 0xffffff)
8963109e5aeSMichael Schmitz 		iounmap(esp->regs);
8973109e5aeSMichael Schmitz 
8983109e5aeSMichael Schmitz fail_unmap_fastlane:
8993109e5aeSMichael Schmitz 	if (zep->zorro3)
9003109e5aeSMichael Schmitz 		iounmap(zep->board_base);
9013109e5aeSMichael Schmitz 
9023109e5aeSMichael Schmitz fail_free_host:
9033109e5aeSMichael Schmitz 	scsi_host_put(host);
9043109e5aeSMichael Schmitz 
9053109e5aeSMichael Schmitz fail_release_device:
9063109e5aeSMichael Schmitz 	zorro_release_device(z);
9073109e5aeSMichael Schmitz 
9083109e5aeSMichael Schmitz fail_free_zep:
9093109e5aeSMichael Schmitz 	kfree(zep);
9103109e5aeSMichael Schmitz 
9113109e5aeSMichael Schmitz 	return err;
9123109e5aeSMichael Schmitz }
9133109e5aeSMichael Schmitz 
zorro_esp_remove(struct zorro_dev * z)9143109e5aeSMichael Schmitz static void zorro_esp_remove(struct zorro_dev *z)
9153109e5aeSMichael Schmitz {
9163109e5aeSMichael Schmitz 	struct zorro_esp_priv *zep = dev_get_drvdata(&z->dev);
9173109e5aeSMichael Schmitz 	struct esp *esp	= zep->esp;
9183109e5aeSMichael Schmitz 	struct Scsi_Host *host = esp->host;
9193109e5aeSMichael Schmitz 
9203109e5aeSMichael Schmitz 	scsi_esp_unregister(esp);
9213109e5aeSMichael Schmitz 
9223109e5aeSMichael Schmitz 	free_irq(host->irq, esp);
9233109e5aeSMichael Schmitz 	dma_free_coherent(esp->dev, 16,
9243109e5aeSMichael Schmitz 			  esp->command_block,
9253109e5aeSMichael Schmitz 			  esp->command_block_dma);
9263109e5aeSMichael Schmitz 
9273109e5aeSMichael Schmitz 	if (zep->zorro3) {
9283109e5aeSMichael Schmitz 		iounmap(zep->board_base);
9293109e5aeSMichael Schmitz 		iounmap(esp->dma_regs);
9303109e5aeSMichael Schmitz 	}
9313109e5aeSMichael Schmitz 
9323109e5aeSMichael Schmitz 	if (host->base > 0xffffff)
9333109e5aeSMichael Schmitz 		iounmap(esp->regs);
9343109e5aeSMichael Schmitz 
9353109e5aeSMichael Schmitz 	scsi_host_put(host);
9363109e5aeSMichael Schmitz 
9373109e5aeSMichael Schmitz 	zorro_release_device(z);
9383109e5aeSMichael Schmitz 
9393109e5aeSMichael Schmitz 	kfree(zep);
9403109e5aeSMichael Schmitz }
9413109e5aeSMichael Schmitz 
9423109e5aeSMichael Schmitz static struct zorro_driver zorro_esp_driver = {
9433109e5aeSMichael Schmitz 	.name	  = KBUILD_MODNAME,
9443109e5aeSMichael Schmitz 	.id_table = zorro_esp_zorro_tbl,
9453109e5aeSMichael Schmitz 	.probe	  = zorro_esp_probe,
9463109e5aeSMichael Schmitz 	.remove	  = zorro_esp_remove,
9473109e5aeSMichael Schmitz };
9483109e5aeSMichael Schmitz 
zorro_esp_scsi_init(void)9493109e5aeSMichael Schmitz static int __init zorro_esp_scsi_init(void)
9503109e5aeSMichael Schmitz {
9513109e5aeSMichael Schmitz 	return zorro_register_driver(&zorro_esp_driver);
9523109e5aeSMichael Schmitz }
9533109e5aeSMichael Schmitz 
zorro_esp_scsi_exit(void)9543109e5aeSMichael Schmitz static void __exit zorro_esp_scsi_exit(void)
9553109e5aeSMichael Schmitz {
9563109e5aeSMichael Schmitz 	zorro_unregister_driver(&zorro_esp_driver);
9573109e5aeSMichael Schmitz }
9583109e5aeSMichael Schmitz 
9593109e5aeSMichael Schmitz module_init(zorro_esp_scsi_init);
9603109e5aeSMichael Schmitz module_exit(zorro_esp_scsi_exit);
961