162306a36Sopenharmony_ci/*=======================================================/
262306a36Sopenharmony_ci  Header file for nsp_cs.c
362306a36Sopenharmony_ci      By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci    Ver.1.0 : Cut unused lines.
662306a36Sopenharmony_ci    Ver 0.1 : Initial version.
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci    This software may be used and distributed according to the terms of
962306a36Sopenharmony_ci    the GNU General Public License.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci=========================================================*/
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef  __nsp_cs__
1462306a36Sopenharmony_ci#define  __nsp_cs__
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/* for debugging */
1762306a36Sopenharmony_ci//#define NSP_DEBUG 9
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*
2062306a36Sopenharmony_ci#define static
2162306a36Sopenharmony_ci#define inline
2262306a36Sopenharmony_ci*/
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/************************************
2562306a36Sopenharmony_ci * Some useful macros...
2662306a36Sopenharmony_ci */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/* SCSI initiator must be ID 7 */
2962306a36Sopenharmony_ci#define NSP_INITIATOR_ID  7
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define NSP_SELTIMEOUT 200
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/***************************************************************************
3462306a36Sopenharmony_ci * register definitions
3562306a36Sopenharmony_ci ***************************************************************************/
3662306a36Sopenharmony_ci/*========================================================================
3762306a36Sopenharmony_ci * base register
3862306a36Sopenharmony_ci ========================================================================*/
3962306a36Sopenharmony_ci#define	IRQCONTROL	0x00  /* R */
4062306a36Sopenharmony_ci#  define IRQCONTROL_RESELECT_CLEAR     BIT(0)
4162306a36Sopenharmony_ci#  define IRQCONTROL_PHASE_CHANGE_CLEAR BIT(1)
4262306a36Sopenharmony_ci#  define IRQCONTROL_TIMER_CLEAR        BIT(2)
4362306a36Sopenharmony_ci#  define IRQCONTROL_FIFO_CLEAR         BIT(3)
4462306a36Sopenharmony_ci#  define IRQCONTROL_ALLMASK            0xff
4562306a36Sopenharmony_ci#  define IRQCONTROL_ALLCLEAR           (IRQCONTROL_RESELECT_CLEAR     | \
4662306a36Sopenharmony_ci					 IRQCONTROL_PHASE_CHANGE_CLEAR | \
4762306a36Sopenharmony_ci					 IRQCONTROL_TIMER_CLEAR        | \
4862306a36Sopenharmony_ci					 IRQCONTROL_FIFO_CLEAR          )
4962306a36Sopenharmony_ci#  define IRQCONTROL_IRQDISABLE         0xf0
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#define	IRQSTATUS	0x00  /* W */
5262306a36Sopenharmony_ci#  define IRQSTATUS_SCSI  BIT(0)
5362306a36Sopenharmony_ci#  define IRQSTATUS_TIMER BIT(2)
5462306a36Sopenharmony_ci#  define IRQSTATUS_FIFO  BIT(3)
5562306a36Sopenharmony_ci#  define IRQSTATUS_MASK  0x0f
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define	IFSELECT	0x01 /* W */
5862306a36Sopenharmony_ci#  define IF_IFSEL    BIT(0)
5962306a36Sopenharmony_ci#  define IF_REGSEL   BIT(2)
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define	FIFOSTATUS	0x01 /* R */
6262306a36Sopenharmony_ci#  define FIFOSTATUS_CHIP_REVISION_MASK 0x0f
6362306a36Sopenharmony_ci#  define FIFOSTATUS_CHIP_ID_MASK       0x70
6462306a36Sopenharmony_ci#  define FIFOSTATUS_FULL_EMPTY         BIT(7)
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#define	INDEXREG	0x02 /* R/W */
6762306a36Sopenharmony_ci#define	DATAREG		0x03 /* R/W */
6862306a36Sopenharmony_ci#define	FIFODATA	0x04 /* R/W */
6962306a36Sopenharmony_ci#define	FIFODATA1	0x05 /* R/W */
7062306a36Sopenharmony_ci#define	FIFODATA2	0x06 /* R/W */
7162306a36Sopenharmony_ci#define	FIFODATA3	0x07 /* R/W */
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci/*====================================================================
7462306a36Sopenharmony_ci * indexed register
7562306a36Sopenharmony_ci ====================================================================*/
7662306a36Sopenharmony_ci#define EXTBUSCTRL	0x10 /* R/W,deleted */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define CLOCKDIV	0x11 /* R/W */
7962306a36Sopenharmony_ci#  define CLOCK_40M 0x02
8062306a36Sopenharmony_ci#  define CLOCK_20M 0x01
8162306a36Sopenharmony_ci#  define FAST_20   BIT(2)
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#define TERMPWRCTRL	0x13 /* R/W */
8462306a36Sopenharmony_ci#  define POWER_ON BIT(0)
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#define SCSIIRQMODE	0x15 /* R/W */
8762306a36Sopenharmony_ci#  define SCSI_PHASE_CHANGE_EI BIT(0)
8862306a36Sopenharmony_ci#  define RESELECT_EI          BIT(4)
8962306a36Sopenharmony_ci#  define FIFO_IRQ_EI          BIT(5)
9062306a36Sopenharmony_ci#  define SCSI_RESET_IRQ_EI    BIT(6)
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#define IRQPHASESENCE	0x16 /* R */
9362306a36Sopenharmony_ci#  define LATCHED_MSG      BIT(0)
9462306a36Sopenharmony_ci#  define LATCHED_IO       BIT(1)
9562306a36Sopenharmony_ci#  define LATCHED_CD       BIT(2)
9662306a36Sopenharmony_ci#  define LATCHED_BUS_FREE BIT(3)
9762306a36Sopenharmony_ci#  define PHASE_CHANGE_IRQ BIT(4)
9862306a36Sopenharmony_ci#  define RESELECT_IRQ     BIT(5)
9962306a36Sopenharmony_ci#  define FIFO_IRQ         BIT(6)
10062306a36Sopenharmony_ci#  define SCSI_RESET_IRQ   BIT(7)
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#define TIMERCOUNT	0x17 /* R/W */
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define SCSIBUSCTRL	0x18 /* R/W */
10562306a36Sopenharmony_ci#  define SCSI_SEL         BIT(0)
10662306a36Sopenharmony_ci#  define SCSI_RST         BIT(1)
10762306a36Sopenharmony_ci#  define SCSI_DATAOUT_ENB BIT(2)
10862306a36Sopenharmony_ci#  define SCSI_ATN         BIT(3)
10962306a36Sopenharmony_ci#  define SCSI_ACK         BIT(4)
11062306a36Sopenharmony_ci#  define SCSI_BSY         BIT(5)
11162306a36Sopenharmony_ci#  define AUTODIRECTION    BIT(6)
11262306a36Sopenharmony_ci#  define ACKENB           BIT(7)
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define SCSIBUSMON	0x19 /* R */
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define SETARBIT	0x1A /* W */
11762306a36Sopenharmony_ci#  define ARBIT_GO         BIT(0)
11862306a36Sopenharmony_ci#  define ARBIT_FLAG_CLEAR BIT(1)
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci#define ARBITSTATUS	0x1A /* R */
12162306a36Sopenharmony_ci/*#  define ARBIT_GO        BIT(0)*/
12262306a36Sopenharmony_ci#  define ARBIT_WIN        BIT(1)
12362306a36Sopenharmony_ci#  define ARBIT_FAIL       BIT(2)
12462306a36Sopenharmony_ci#  define RESELECT_FLAG    BIT(3)
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define PARITYCTRL	0x1B  /* W */
12762306a36Sopenharmony_ci#define PARITYSTATUS	0x1B  /* R */
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci#define COMMANDCTRL	0x1C  /* W */
13062306a36Sopenharmony_ci#  define CLEAR_COMMAND_POINTER BIT(0)
13162306a36Sopenharmony_ci#  define AUTO_COMMAND_GO       BIT(1)
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci#define RESELECTID	0x1C  /* R   */
13462306a36Sopenharmony_ci#define COMMANDDATA	0x1D  /* R/W */
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#define POINTERCLR	0x1E  /*   W */
13762306a36Sopenharmony_ci#  define POINTER_CLEAR      BIT(0)
13862306a36Sopenharmony_ci#  define ACK_COUNTER_CLEAR  BIT(1)
13962306a36Sopenharmony_ci#  define REQ_COUNTER_CLEAR  BIT(2)
14062306a36Sopenharmony_ci#  define HOST_COUNTER_CLEAR BIT(3)
14162306a36Sopenharmony_ci#  define READ_SOURCE        (BIT(4) | BIT(5))
14262306a36Sopenharmony_ci#    define ACK_COUNTER        (0)
14362306a36Sopenharmony_ci#    define REQ_COUNTER        (BIT(4))
14462306a36Sopenharmony_ci#    define HOST_COUNTER       (BIT(5))
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define TRANSFERCOUNT	0x1E  /* R   */
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci#define TRANSFERMODE	0x20  /* R/W */
14962306a36Sopenharmony_ci#  define MODE_MEM8   BIT(0)
15062306a36Sopenharmony_ci#  define MODE_MEM32  BIT(1)
15162306a36Sopenharmony_ci#  define MODE_ADR24  BIT(2)
15262306a36Sopenharmony_ci#  define MODE_ADR32  BIT(3)
15362306a36Sopenharmony_ci#  define MODE_IO8    BIT(4)
15462306a36Sopenharmony_ci#  define MODE_IO32   BIT(5)
15562306a36Sopenharmony_ci#  define TRANSFER_GO BIT(6)
15662306a36Sopenharmony_ci#  define BRAIND      BIT(7)
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define SYNCREG		0x21 /* R/W */
15962306a36Sopenharmony_ci#  define SYNCREG_OFFSET_MASK  0x0f
16062306a36Sopenharmony_ci#  define SYNCREG_PERIOD_MASK  0xf0
16162306a36Sopenharmony_ci#  define SYNCREG_PERIOD_SHIFT 4
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci#define SCSIDATALATCH	0x22 /*   W */
16462306a36Sopenharmony_ci#define SCSIDATAIN	0x22 /* R   */
16562306a36Sopenharmony_ci#define SCSIDATAWITHACK	0x23 /* R/W */
16662306a36Sopenharmony_ci#define SCAMCONTROL	0x24 /*   W */
16762306a36Sopenharmony_ci#define SCAMSTATUS	0x24 /* R   */
16862306a36Sopenharmony_ci#define SCAMDATA	0x25 /* R/W */
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define OTHERCONTROL	0x26 /* R/W */
17162306a36Sopenharmony_ci#  define TPL_ROM_WRITE_EN BIT(0)
17262306a36Sopenharmony_ci#  define TPWR_OUT         BIT(1)
17362306a36Sopenharmony_ci#  define TPWR_SENSE       BIT(2)
17462306a36Sopenharmony_ci#  define RA8_CONTROL      BIT(3)
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci#define ACKWIDTH	0x27 /* R/W */
17762306a36Sopenharmony_ci#define CLRTESTPNT	0x28 /*   W */
17862306a36Sopenharmony_ci#define ACKCNTLD	0x29 /*   W */
17962306a36Sopenharmony_ci#define REQCNTLD	0x2A /*   W */
18062306a36Sopenharmony_ci#define HSTCNTLD	0x2B /*   W */
18162306a36Sopenharmony_ci#define CHECKSUM	0x2C /* R/W */
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci/************************************************************************
18462306a36Sopenharmony_ci * Input status bit definitions.
18562306a36Sopenharmony_ci ************************************************************************/
18662306a36Sopenharmony_ci#define S_MESSAGE	BIT(0)    /* Message line from SCSI bus      */
18762306a36Sopenharmony_ci#define S_IO		BIT(1)    /* Input/Output line from SCSI bus */
18862306a36Sopenharmony_ci#define S_CD		BIT(2)    /* Command/Data line from SCSI bus */
18962306a36Sopenharmony_ci#define S_BUSY		BIT(3)    /* Busy line from SCSI bus         */
19062306a36Sopenharmony_ci#define S_ACK		BIT(4)    /* Acknowledge line from SCSI bus  */
19162306a36Sopenharmony_ci#define S_REQUEST	BIT(5)    /* Request line from SCSI bus      */
19262306a36Sopenharmony_ci#define S_SELECT	BIT(6)	  /*                                 */
19362306a36Sopenharmony_ci#define S_ATN		BIT(7)	  /*                                 */
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/***********************************************************************
19662306a36Sopenharmony_ci * Useful Bus Monitor status combinations.
19762306a36Sopenharmony_ci ***********************************************************************/
19862306a36Sopenharmony_ci#define BUSMON_SEL         S_SELECT
19962306a36Sopenharmony_ci#define BUSMON_BSY         S_BUSY
20062306a36Sopenharmony_ci#define BUSMON_REQ         S_REQUEST
20162306a36Sopenharmony_ci#define BUSMON_IO          S_IO
20262306a36Sopenharmony_ci#define BUSMON_ACK         S_ACK
20362306a36Sopenharmony_ci#define BUSMON_BUS_FREE    0
20462306a36Sopenharmony_ci#define BUSMON_COMMAND     ( S_BUSY | S_CD |                    S_REQUEST )
20562306a36Sopenharmony_ci#define BUSMON_MESSAGE_IN  ( S_BUSY | S_CD | S_IO | S_MESSAGE | S_REQUEST )
20662306a36Sopenharmony_ci#define BUSMON_MESSAGE_OUT ( S_BUSY | S_CD |        S_MESSAGE | S_REQUEST )
20762306a36Sopenharmony_ci#define BUSMON_DATA_IN     ( S_BUSY |        S_IO |             S_REQUEST )
20862306a36Sopenharmony_ci#define BUSMON_DATA_OUT    ( S_BUSY |                           S_REQUEST )
20962306a36Sopenharmony_ci#define BUSMON_STATUS      ( S_BUSY | S_CD | S_IO |             S_REQUEST )
21062306a36Sopenharmony_ci#define BUSMON_SELECT      (                 S_IO |                        S_SELECT )
21162306a36Sopenharmony_ci#define BUSMON_RESELECT    (                 S_IO |                        S_SELECT )
21262306a36Sopenharmony_ci#define BUSMON_PHASE_MASK  (          S_CD | S_IO | S_MESSAGE |            S_SELECT )
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci#define BUSPHASE_SELECT      ( BUSMON_SELECT      & BUSMON_PHASE_MASK )
21562306a36Sopenharmony_ci#define BUSPHASE_COMMAND     ( BUSMON_COMMAND     & BUSMON_PHASE_MASK )
21662306a36Sopenharmony_ci#define BUSPHASE_MESSAGE_IN  ( BUSMON_MESSAGE_IN  & BUSMON_PHASE_MASK )
21762306a36Sopenharmony_ci#define BUSPHASE_MESSAGE_OUT ( BUSMON_MESSAGE_OUT & BUSMON_PHASE_MASK )
21862306a36Sopenharmony_ci#define BUSPHASE_DATA_IN     ( BUSMON_DATA_IN     & BUSMON_PHASE_MASK )
21962306a36Sopenharmony_ci#define BUSPHASE_DATA_OUT    ( BUSMON_DATA_OUT    & BUSMON_PHASE_MASK )
22062306a36Sopenharmony_ci#define BUSPHASE_STATUS      ( BUSMON_STATUS      & BUSMON_PHASE_MASK )
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci/*====================================================================*/
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_citypedef struct scsi_info_t {
22562306a36Sopenharmony_ci	struct pcmcia_device	*p_dev;
22662306a36Sopenharmony_ci	struct Scsi_Host      *host;
22762306a36Sopenharmony_ci	int                    stop;
22862306a36Sopenharmony_ci} scsi_info_t;
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci/* synchronous transfer negotiation data */
23262306a36Sopenharmony_citypedef struct _sync_data {
23362306a36Sopenharmony_ci	unsigned int SyncNegotiation;
23462306a36Sopenharmony_ci#define SYNC_NOT_YET 0
23562306a36Sopenharmony_ci#define SYNC_OK      1
23662306a36Sopenharmony_ci#define SYNC_NG      2
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci	unsigned int  SyncPeriod;
23962306a36Sopenharmony_ci	unsigned int  SyncOffset;
24062306a36Sopenharmony_ci	unsigned char SyncRegister;
24162306a36Sopenharmony_ci	unsigned char AckWidth;
24262306a36Sopenharmony_ci} sync_data;
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_citypedef struct _nsp_hw_data {
24562306a36Sopenharmony_ci	unsigned int  BaseAddress;
24662306a36Sopenharmony_ci	unsigned int  NumAddress;
24762306a36Sopenharmony_ci	unsigned int  IrqNumber;
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci	unsigned long MmioAddress;
25062306a36Sopenharmony_ci#define NSP_MMIO_OFFSET 0x0800
25162306a36Sopenharmony_ci	unsigned long MmioLength;
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci	unsigned char ScsiClockDiv;
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci	unsigned char TransferMode;
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci	int           TimerCount;
25862306a36Sopenharmony_ci	int           SelectionTimeOut;
25962306a36Sopenharmony_ci	struct scsi_cmnd *CurrentSC;
26062306a36Sopenharmony_ci	//int           CurrnetTarget;
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	int           FifoCount;
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci#define MSGBUF_SIZE 20
26562306a36Sopenharmony_ci	unsigned char MsgBuffer[MSGBUF_SIZE];
26662306a36Sopenharmony_ci	int MsgLen;
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci#define N_TARGET 8
26962306a36Sopenharmony_ci	sync_data     Sync[N_TARGET];
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci	char nspinfo[110];     /* description */
27262306a36Sopenharmony_ci	spinlock_t Lock;
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_ci	scsi_info_t   *ScsiInfo; /* attach <-> detect glue */
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci#ifdef NSP_DEBUG
27862306a36Sopenharmony_ci	int CmdId; /* Accepted command serial number.
27962306a36Sopenharmony_ci		      Used for debugging.             */
28062306a36Sopenharmony_ci#endif
28162306a36Sopenharmony_ci} nsp_hw_data;
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci/****************************************************************************
28462306a36Sopenharmony_ci *
28562306a36Sopenharmony_ci */
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci/* Card service functions */
28862306a36Sopenharmony_cistatic void        nsp_cs_detach (struct pcmcia_device *p_dev);
28962306a36Sopenharmony_cistatic void        nsp_cs_release(struct pcmcia_device *link);
29062306a36Sopenharmony_cistatic int        nsp_cs_config (struct pcmcia_device *link);
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci/* Linux SCSI subsystem specific functions */
29362306a36Sopenharmony_cistatic struct Scsi_Host *nsp_detect     (struct scsi_host_template *sht);
29462306a36Sopenharmony_cistatic const  char      *nsp_info       (struct Scsi_Host *shpnt);
29562306a36Sopenharmony_cistatic        int        nsp_show_info  (struct seq_file *m,
29662306a36Sopenharmony_ci	                                 struct Scsi_Host *host);
29762306a36Sopenharmony_cistatic int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/* Error handler */
30062306a36Sopenharmony_ci/*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
30162306a36Sopenharmony_ci/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
30262306a36Sopenharmony_cistatic int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
30362306a36Sopenharmony_cistatic int nsp_eh_host_reset   (struct scsi_cmnd *SCpnt);
30462306a36Sopenharmony_cistatic int nsp_bus_reset       (nsp_hw_data *data);
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_ci/* */
30762306a36Sopenharmony_cistatic void nsphw_init           (nsp_hw_data *data);
30862306a36Sopenharmony_cistatic bool nsphw_start_selection(struct scsi_cmnd *SCpnt);
30962306a36Sopenharmony_cistatic void nsp_start_timer      (struct scsi_cmnd *SCpnt, int time);
31062306a36Sopenharmony_cistatic int  nsp_fifo_count       (struct scsi_cmnd *SCpnt);
31162306a36Sopenharmony_cistatic void nsp_pio_read         (struct scsi_cmnd *SCpnt);
31262306a36Sopenharmony_cistatic void nsp_pio_write        (struct scsi_cmnd *SCpnt);
31362306a36Sopenharmony_cistatic int  nsp_nexus            (struct scsi_cmnd *SCpnt);
31462306a36Sopenharmony_cistatic void nsp_scsi_done        (struct scsi_cmnd *SCpnt);
31562306a36Sopenharmony_cistatic int  nsp_analyze_sdtr     (struct scsi_cmnd *SCpnt);
31662306a36Sopenharmony_cistatic int  nsp_negate_signal    (struct scsi_cmnd *SCpnt,
31762306a36Sopenharmony_ci				  unsigned char mask, char *str);
31862306a36Sopenharmony_cistatic int  nsp_expect_signal    (struct scsi_cmnd *SCpnt,
31962306a36Sopenharmony_ci				  unsigned char current_phase,
32062306a36Sopenharmony_ci				  unsigned char  mask);
32162306a36Sopenharmony_cistatic int  nsp_xfer             (struct scsi_cmnd *SCpnt, int phase);
32262306a36Sopenharmony_cistatic int  nsp_dataphase_bypass (struct scsi_cmnd *SCpnt);
32362306a36Sopenharmony_cistatic void nsp_reselected       (struct scsi_cmnd *SCpnt);
32462306a36Sopenharmony_cistatic struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci/* Interrupt handler */
32762306a36Sopenharmony_ci//static irqreturn_t nspintr(int irq, void *dev_id);
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci/* Debug */
33062306a36Sopenharmony_ci#ifdef NSP_DEBUG
33162306a36Sopenharmony_cistatic void show_command (struct scsi_cmnd *SCpnt);
33262306a36Sopenharmony_cistatic void show_phase   (struct scsi_cmnd *SCpnt);
33362306a36Sopenharmony_cistatic void show_busphase(unsigned char stat);
33462306a36Sopenharmony_cistatic void show_message (nsp_hw_data *data);
33562306a36Sopenharmony_ci#else
33662306a36Sopenharmony_ci# define show_command(ptr)   /* */
33762306a36Sopenharmony_ci# define show_phase(SCpnt)   /* */
33862306a36Sopenharmony_ci# define show_busphase(stat) /* */
33962306a36Sopenharmony_ci# define show_message(data)  /* */
34062306a36Sopenharmony_ci#endif
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci/*
34362306a36Sopenharmony_ci * SCSI phase
34462306a36Sopenharmony_ci */
34562306a36Sopenharmony_cienum _scsi_phase {
34662306a36Sopenharmony_ci	PH_UNDETERMINED ,
34762306a36Sopenharmony_ci	PH_ARBSTART     ,
34862306a36Sopenharmony_ci	PH_SELSTART     ,
34962306a36Sopenharmony_ci	PH_SELECTED     ,
35062306a36Sopenharmony_ci	PH_COMMAND      ,
35162306a36Sopenharmony_ci	PH_DATA         ,
35262306a36Sopenharmony_ci	PH_STATUS       ,
35362306a36Sopenharmony_ci	PH_MSG_IN       ,
35462306a36Sopenharmony_ci	PH_MSG_OUT      ,
35562306a36Sopenharmony_ci	PH_DISCONNECT   ,
35662306a36Sopenharmony_ci	PH_RESELECT     ,
35762306a36Sopenharmony_ci	PH_ABORT        ,
35862306a36Sopenharmony_ci	PH_RESET
35962306a36Sopenharmony_ci};
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_cienum _data_in_out {
36262306a36Sopenharmony_ci	IO_UNKNOWN,
36362306a36Sopenharmony_ci	IO_IN,
36462306a36Sopenharmony_ci	IO_OUT
36562306a36Sopenharmony_ci};
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_cienum _burst_mode {
36862306a36Sopenharmony_ci	BURST_IO8   = 0,
36962306a36Sopenharmony_ci	BURST_IO32  = 1,
37062306a36Sopenharmony_ci	BURST_MEM32 = 2,
37162306a36Sopenharmony_ci};
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ci/* scatter-gather table */
37462306a36Sopenharmony_ci#define BUFFER_ADDR(SCpnt) ((char *)(sg_virt(nsp_priv(SCpnt)->buffer)))
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci#endif  /*__nsp_cs__*/
37762306a36Sopenharmony_ci/* end */
378