Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/drivers/acorn/scsi/cumana_2.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 1997-2005 Russell King
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Changelog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *   30-08-1997	RMK	0.0.0	Created, READONLY version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *   22-01-1998	RMK	0.0.1	Updated to 2.1.80.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *   15-04-1998	RMK	0.0.1	Only do PIO if FAS216 will allow it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *   02-05-1998	RMK	0.0.2	Updated & added DMA support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *   27-06-1998	RMK		Changed asm/delay.h to linux/delay.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *   18-08-1998	RMK	0.0.3	Fixed synchronous transfer depth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *   02-04-2000	RMK	0.0.4	Updated for new error handling code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <asm/dma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <asm/ecard.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "../scsi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include "fas216.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include "scsi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <scsi/scsicam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define CUMANASCSI2_STATUS		(0x0000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define STATUS_INT			(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define STATUS_DRQ			(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define STATUS_LATCHED			(1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define CUMANASCSI2_ALATCH		(0x0014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define ALATCH_ENA_INT			(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define ALATCH_DIS_INT			(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define ALATCH_ENA_TERM			(5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define ALATCH_DIS_TERM			(4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define ALATCH_ENA_BIT32		(11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define ALATCH_DIS_BIT32		(10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define ALATCH_ENA_DMA			(13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define ALATCH_DIS_DMA			(12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define ALATCH_DMA_OUT			(15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define ALATCH_DMA_IN			(14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define CUMANASCSI2_PSEUDODMA		(0x0200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define CUMANASCSI2_FAS216_OFFSET	(0x0300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define CUMANASCSI2_FAS216_SHIFT	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * Version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define VERSION "1.00 (13/11/2002 2.5.47)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * Use term=0,1,0,0,0 to turn terminators on/off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define NR_SG	256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct cumanascsi2_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	FAS216_Info		info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct expansion_card	*ec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	void __iomem		*base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	unsigned int		terms;		/* Terminator state	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct scatterlist	sg[NR_SG];	/* Scatter DMA list	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define CSTATUS_IRQ	(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define CSTATUS_DRQ	(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) /* Prototype: void cumanascsi_2_irqenable(ec, irqnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * Purpose  : Enable interrupts on Cumana SCSI 2 card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * Params   : ec    - expansion card structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *          : irqnr - interrupt number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) cumanascsi_2_irqenable(struct expansion_card *ec, int irqnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct cumanascsi2_info *info = ec->irq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	writeb(ALATCH_ENA_INT, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /* Prototype: void cumanascsi_2_irqdisable(ec, irqnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * Purpose  : Disable interrupts on Cumana SCSI 2 card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * Params   : ec    - expansion card structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  *          : irqnr - interrupt number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) cumanascsi_2_irqdisable(struct expansion_card *ec, int irqnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct cumanascsi2_info *info = ec->irq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	writeb(ALATCH_DIS_INT, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static const expansioncard_ops_t cumanascsi_2_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	.irqenable	= cumanascsi_2_irqenable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	.irqdisable	= cumanascsi_2_irqdisable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* Prototype: void cumanascsi_2_terminator_ctl(host, on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * Purpose  : Turn the Cumana SCSI 2 terminators on or off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * Params   : host   - card to turn on/off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *          : on_off - !0 to turn on, 0 to turn off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) cumanascsi_2_terminator_ctl(struct Scsi_Host *host, int on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (on_off) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		info->terms = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		writeb(ALATCH_ENA_TERM, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		info->terms = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		writeb(ALATCH_DIS_TERM, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* Prototype: void cumanascsi_2_intr(irq, *dev_id, *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * Purpose  : handle interrupts from Cumana SCSI 2 card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * Params   : irq    - interrupt number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  *	      dev_id - user-defined (Scsi_Host structure)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static irqreturn_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) cumanascsi_2_intr(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct cumanascsi2_info *info = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return fas216_intr(&info->info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* Prototype: fasdmatype_t cumanascsi_2_dma_setup(host, SCpnt, direction, min_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * Purpose  : initialises DMA/PIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * Params   : host      - host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *	      SCpnt     - command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *	      direction - DMA on to/off of card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *	      min_type  - minimum DMA support that we must have for this transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * Returns  : type of transfer to be performed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static fasdmatype_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) cumanascsi_2_dma_setup(struct Scsi_Host *host, struct scsi_pointer *SCp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		       fasdmadir_t direction, fasdmatype_t min_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct device *dev = scsi_get_device(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	int dmach = info->info.scsi.dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	writeb(ALATCH_DIS_DMA, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (dmach != NO_DMA &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	    (min_type == fasdma_real_all || SCp->this_residual >= 512)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		int bufs, map_dir, dma_dir, alatch_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		bufs = copy_SCp_to_sg(&info->sg[0], SCp, NR_SG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		if (direction == DMA_OUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			map_dir = DMA_TO_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			dma_dir = DMA_MODE_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			alatch_dir = ALATCH_DMA_OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			map_dir = DMA_FROM_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 			dma_dir = DMA_MODE_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			alatch_dir = ALATCH_DMA_IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		dma_map_sg(dev, info->sg, bufs, map_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		disable_dma(dmach);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		set_dma_sg(dmach, info->sg, bufs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		writeb(alatch_dir, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		set_dma_mode(dmach, dma_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		enable_dma(dmach);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		writeb(ALATCH_ENA_DMA, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		writeb(ALATCH_DIS_BIT32, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return fasdma_real_all;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	 * If we're not doing DMA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	 *  we'll do pseudo DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	return fasdma_pio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  * Prototype: void cumanascsi_2_dma_pseudo(host, SCpnt, direction, transfer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  * Purpose  : handles pseudo DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * Params   : host      - host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  *	      SCpnt     - command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  *	      direction - DMA on to/off of card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  *	      transfer  - minimum number of bytes we expect to transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) cumanascsi_2_dma_pseudo(struct Scsi_Host *host, struct scsi_pointer *SCp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			fasdmadir_t direction, int transfer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	unsigned int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	unsigned char *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	length = SCp->this_residual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	addr = SCp->ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (direction == DMA_OUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		while (length > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			unsigned long word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			unsigned int status = readb(info->base + CUMANASCSI2_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			if (status & STATUS_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 				goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			if (!(status & STATUS_DRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			word = *addr | *(addr + 1) << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			writew(word, info->base + CUMANASCSI2_PSEUDODMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 			addr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			length -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		printk ("PSEUDO_OUT???\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		if (transfer && (transfer & 255)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			while (length >= 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 				unsigned int status = readb(info->base + CUMANASCSI2_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 				if (status & STATUS_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 					return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	    
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 				if (!(status & STATUS_DRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 					continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				readsw(info->base + CUMANASCSI2_PSEUDODMA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				       addr, 256 >> 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				addr += 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 				length -= 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		while (length > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			unsigned long word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			unsigned int status = readb(info->base + CUMANASCSI2_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			if (status & STATUS_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			if (!(status & STATUS_DRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 			word = readw(info->base + CUMANASCSI2_PSEUDODMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			*addr++ = word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			if (--length > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 				*addr++ = word >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				length --;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /* Prototype: int cumanascsi_2_dma_stop(host, SCpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  * Purpose  : stops DMA/PIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * Params   : host  - host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  *	      SCpnt - command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) cumanascsi_2_dma_stop(struct Scsi_Host *host, struct scsi_pointer *SCp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	if (info->info.scsi.dma != NO_DMA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		writeb(ALATCH_DIS_DMA, info->base + CUMANASCSI2_ALATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		disable_dma(info->info.scsi.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /* Prototype: const char *cumanascsi_2_info(struct Scsi_Host * host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  * Purpose  : returns a descriptive string about this interface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  * Params   : host - driver host structure to return info for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  * Returns  : pointer to a static buffer containing null terminated string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) const char *cumanascsi_2_info(struct Scsi_Host *host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	static char string[150];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	sprintf(string, "%s (%s) in slot %d v%s terminators o%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		host->hostt->name, info->info.scsi.type, info->ec->slot_no,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		VERSION, info->terms ? "n" : "ff");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	return string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /* Prototype: int cumanascsi_2_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)  * Purpose  : Set a driver specific function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)  * Params   : host   - host to setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  *          : buffer - buffer containing string describing operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  *          : length - length of string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  * Returns  : -EINVAL, or 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) cumanascsi_2_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	int ret = length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	if (length >= 11 && strncmp(buffer, "CUMANASCSI2", 11) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		buffer += 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		length -= 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		if (length >= 5 && strncmp(buffer, "term=", 5) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 			if (buffer[5] == '1')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 				cumanascsi_2_terminator_ctl(host, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			else if (buffer[5] == '0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 				cumanascsi_2_terminator_ctl(host, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 				ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 			ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) static int cumanascsi_2_show_info(struct seq_file *m, struct Scsi_Host *host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	struct cumanascsi2_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	seq_printf(m, "Cumana SCSI II driver v%s\n", VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	fas216_print_host(&info->info, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	seq_printf(m, "Term    : o%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			info->terms ? "n" : "ff");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	fas216_print_stats(&info->info, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	fas216_print_devices(&info->info, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) static struct scsi_host_template cumanascsi2_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	.module				= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	.show_info			= cumanascsi_2_show_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	.write_info			= cumanascsi_2_set_proc_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	.name				= "Cumana SCSI II",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	.info				= cumanascsi_2_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	.queuecommand			= fas216_queue_command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	.eh_host_reset_handler		= fas216_eh_host_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	.eh_bus_reset_handler		= fas216_eh_bus_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	.eh_device_reset_handler	= fas216_eh_device_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	.eh_abort_handler		= fas216_eh_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	.can_queue			= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	.this_id			= 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	.sg_tablesize			= SG_MAX_SEGMENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	.dma_boundary			= IOMD_DMA_BOUNDARY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	.proc_name			= "cumanascsi2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) static int cumanascsi2_probe(struct expansion_card *ec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			     const struct ecard_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	struct Scsi_Host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	struct cumanascsi2_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	ret = ecard_request_resources(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	if (!base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		goto out_region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	host = scsi_host_alloc(&cumanascsi2_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			       sizeof(struct cumanascsi2_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	if (!host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		goto out_region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	ecard_set_drvdata(ec, host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	info->ec	= ec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	info->base	= base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	cumanascsi_2_terminator_ctl(host, term[ec->slot_no]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	info->info.scsi.io_base		= base + CUMANASCSI2_FAS216_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	info->info.scsi.io_shift	= CUMANASCSI2_FAS216_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	info->info.scsi.irq		= ec->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	info->info.scsi.dma		= ec->dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	info->info.ifcfg.clockrate	= 40; /* MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	info->info.ifcfg.select_timeout	= 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	info->info.ifcfg.asyncperiod	= 200; /* ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	info->info.ifcfg.sync_max_depth	= 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	info->info.ifcfg.cntl3		= CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	info->info.ifcfg.disconnect_ok	= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	info->info.ifcfg.wide_max_size	= 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	info->info.ifcfg.capabilities	= FASCAP_PSEUDODMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	info->info.dma.setup		= cumanascsi_2_dma_setup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	info->info.dma.pseudo		= cumanascsi_2_dma_pseudo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	info->info.dma.stop		= cumanascsi_2_dma_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	ec->irqaddr	= info->base + CUMANASCSI2_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	ec->irqmask	= STATUS_INT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	ecard_setirq(ec, &cumanascsi_2_ops, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	ret = fas216_init(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	ret = request_irq(ec->irq, cumanascsi_2_intr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 			  0, "cumanascsi2", info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		printk("scsi%d: IRQ%d not free: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		       host->host_no, ec->irq, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		goto out_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	if (info->info.scsi.dma != NO_DMA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		if (request_dma(info->info.scsi.dma, "cumanascsi2")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			printk("scsi%d: DMA%d not free, using PIO\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 			       host->host_no, info->info.scsi.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 			info->info.scsi.dma = NO_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			set_dma_speed(info->info.scsi.dma, 180);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			info->info.ifcfg.capabilities |= FASCAP_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	ret = fas216_add(host, &ec->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	if (info->info.scsi.dma != NO_DMA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		free_dma(info->info.scsi.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	free_irq(ec->irq, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)  out_release:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	fas216_release(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	scsi_host_put(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  out_region:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	ecard_release_resources(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) static void cumanascsi2_remove(struct expansion_card *ec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	struct Scsi_Host *host = ecard_get_drvdata(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	ecard_set_drvdata(ec, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	fas216_remove(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	if (info->info.scsi.dma != NO_DMA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		free_dma(info->info.scsi.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	free_irq(ec->irq, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	fas216_release(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	scsi_host_put(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	ecard_release_resources(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) static const struct ecard_id cumanascsi2_cids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	{ MANU_CUMANA, PROD_CUMANA_SCSI_2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	{ 0xffff, 0xffff },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) static struct ecard_driver cumanascsi2_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	.probe		= cumanascsi2_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	.remove		= cumanascsi2_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	.id_table	= cumanascsi2_cids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	.drv = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		.name		= "cumanascsi2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) static int __init cumanascsi2_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	return ecard_register_driver(&cumanascsi2_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) static void __exit cumanascsi2_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	ecard_remove_driver(&cumanascsi2_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) module_init(cumanascsi2_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) module_exit(cumanascsi2_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) MODULE_AUTHOR("Russell King");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) module_param_array(term, int, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) MODULE_PARM_DESC(term, "SCSI bus termination");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) MODULE_LICENSE("GPL");