18c2ecf20Sopenharmony_ci/*=======================================================/
28c2ecf20Sopenharmony_ci  Header file for nsp_cs.c
38c2ecf20Sopenharmony_ci      By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci    Ver.1.0 : Cut unused lines.
68c2ecf20Sopenharmony_ci    Ver 0.1 : Initial version.
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci    This software may be used and distributed according to the terms of
98c2ecf20Sopenharmony_ci    the GNU General Public License.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci=========================================================*/
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef  __nsp_cs__
148c2ecf20Sopenharmony_ci#define  __nsp_cs__
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* for debugging */
178c2ecf20Sopenharmony_ci//#define NSP_DEBUG 9
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/*
208c2ecf20Sopenharmony_ci#define static
218c2ecf20Sopenharmony_ci#define inline
228c2ecf20Sopenharmony_ci*/
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/************************************
258c2ecf20Sopenharmony_ci * Some useful macros...
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* SCSI initiator must be ID 7 */
298c2ecf20Sopenharmony_ci#define NSP_INITIATOR_ID  7
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define NSP_SELTIMEOUT 200
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/***************************************************************************
348c2ecf20Sopenharmony_ci * register definitions
358c2ecf20Sopenharmony_ci ***************************************************************************/
368c2ecf20Sopenharmony_ci/*========================================================================
378c2ecf20Sopenharmony_ci * base register
388c2ecf20Sopenharmony_ci ========================================================================*/
398c2ecf20Sopenharmony_ci#define	IRQCONTROL	0x00  /* R */
408c2ecf20Sopenharmony_ci#  define IRQCONTROL_RESELECT_CLEAR     BIT(0)
418c2ecf20Sopenharmony_ci#  define IRQCONTROL_PHASE_CHANGE_CLEAR BIT(1)
428c2ecf20Sopenharmony_ci#  define IRQCONTROL_TIMER_CLEAR        BIT(2)
438c2ecf20Sopenharmony_ci#  define IRQCONTROL_FIFO_CLEAR         BIT(3)
448c2ecf20Sopenharmony_ci#  define IRQCONTROL_ALLMASK            0xff
458c2ecf20Sopenharmony_ci#  define IRQCONTROL_ALLCLEAR           (IRQCONTROL_RESELECT_CLEAR     | \
468c2ecf20Sopenharmony_ci					 IRQCONTROL_PHASE_CHANGE_CLEAR | \
478c2ecf20Sopenharmony_ci					 IRQCONTROL_TIMER_CLEAR        | \
488c2ecf20Sopenharmony_ci					 IRQCONTROL_FIFO_CLEAR          )
498c2ecf20Sopenharmony_ci#  define IRQCONTROL_IRQDISABLE         0xf0
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define	IRQSTATUS	0x00  /* W */
528c2ecf20Sopenharmony_ci#  define IRQSTATUS_SCSI  BIT(0)
538c2ecf20Sopenharmony_ci#  define IRQSTATUS_TIMER BIT(2)
548c2ecf20Sopenharmony_ci#  define IRQSTATUS_FIFO  BIT(3)
558c2ecf20Sopenharmony_ci#  define IRQSTATUS_MASK  0x0f
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define	IFSELECT	0x01 /* W */
588c2ecf20Sopenharmony_ci#  define IF_IFSEL    BIT(0)
598c2ecf20Sopenharmony_ci#  define IF_REGSEL   BIT(2)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define	FIFOSTATUS	0x01 /* R */
628c2ecf20Sopenharmony_ci#  define FIFOSTATUS_CHIP_REVISION_MASK 0x0f
638c2ecf20Sopenharmony_ci#  define FIFOSTATUS_CHIP_ID_MASK       0x70
648c2ecf20Sopenharmony_ci#  define FIFOSTATUS_FULL_EMPTY         BIT(7)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define	INDEXREG	0x02 /* R/W */
678c2ecf20Sopenharmony_ci#define	DATAREG		0x03 /* R/W */
688c2ecf20Sopenharmony_ci#define	FIFODATA	0x04 /* R/W */
698c2ecf20Sopenharmony_ci#define	FIFODATA1	0x05 /* R/W */
708c2ecf20Sopenharmony_ci#define	FIFODATA2	0x06 /* R/W */
718c2ecf20Sopenharmony_ci#define	FIFODATA3	0x07 /* R/W */
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/*====================================================================
748c2ecf20Sopenharmony_ci * indexed register
758c2ecf20Sopenharmony_ci ====================================================================*/
768c2ecf20Sopenharmony_ci#define EXTBUSCTRL	0x10 /* R/W,deleted */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define CLOCKDIV	0x11 /* R/W */
798c2ecf20Sopenharmony_ci#  define CLOCK_40M 0x02
808c2ecf20Sopenharmony_ci#  define CLOCK_20M 0x01
818c2ecf20Sopenharmony_ci#  define FAST_20   BIT(2)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define TERMPWRCTRL	0x13 /* R/W */
848c2ecf20Sopenharmony_ci#  define POWER_ON BIT(0)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define SCSIIRQMODE	0x15 /* R/W */
878c2ecf20Sopenharmony_ci#  define SCSI_PHASE_CHANGE_EI BIT(0)
888c2ecf20Sopenharmony_ci#  define RESELECT_EI          BIT(4)
898c2ecf20Sopenharmony_ci#  define FIFO_IRQ_EI          BIT(5)
908c2ecf20Sopenharmony_ci#  define SCSI_RESET_IRQ_EI    BIT(6)
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define IRQPHASESENCE	0x16 /* R */
938c2ecf20Sopenharmony_ci#  define LATCHED_MSG      BIT(0)
948c2ecf20Sopenharmony_ci#  define LATCHED_IO       BIT(1)
958c2ecf20Sopenharmony_ci#  define LATCHED_CD       BIT(2)
968c2ecf20Sopenharmony_ci#  define LATCHED_BUS_FREE BIT(3)
978c2ecf20Sopenharmony_ci#  define PHASE_CHANGE_IRQ BIT(4)
988c2ecf20Sopenharmony_ci#  define RESELECT_IRQ     BIT(5)
998c2ecf20Sopenharmony_ci#  define FIFO_IRQ         BIT(6)
1008c2ecf20Sopenharmony_ci#  define SCSI_RESET_IRQ   BIT(7)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define TIMERCOUNT	0x17 /* R/W */
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define SCSIBUSCTRL	0x18 /* R/W */
1058c2ecf20Sopenharmony_ci#  define SCSI_SEL         BIT(0)
1068c2ecf20Sopenharmony_ci#  define SCSI_RST         BIT(1)
1078c2ecf20Sopenharmony_ci#  define SCSI_DATAOUT_ENB BIT(2)
1088c2ecf20Sopenharmony_ci#  define SCSI_ATN         BIT(3)
1098c2ecf20Sopenharmony_ci#  define SCSI_ACK         BIT(4)
1108c2ecf20Sopenharmony_ci#  define SCSI_BSY         BIT(5)
1118c2ecf20Sopenharmony_ci#  define AUTODIRECTION    BIT(6)
1128c2ecf20Sopenharmony_ci#  define ACKENB           BIT(7)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define SCSIBUSMON	0x19 /* R */
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define SETARBIT	0x1A /* W */
1178c2ecf20Sopenharmony_ci#  define ARBIT_GO         BIT(0)
1188c2ecf20Sopenharmony_ci#  define ARBIT_FLAG_CLEAR BIT(1)
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define ARBITSTATUS	0x1A /* R */
1218c2ecf20Sopenharmony_ci/*#  define ARBIT_GO        BIT(0)*/
1228c2ecf20Sopenharmony_ci#  define ARBIT_WIN        BIT(1)
1238c2ecf20Sopenharmony_ci#  define ARBIT_FAIL       BIT(2)
1248c2ecf20Sopenharmony_ci#  define RESELECT_FLAG    BIT(3)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci#define PARITYCTRL	0x1B  /* W */
1278c2ecf20Sopenharmony_ci#define PARITYSTATUS	0x1B  /* R */
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define COMMANDCTRL	0x1C  /* W */
1308c2ecf20Sopenharmony_ci#  define CLEAR_COMMAND_POINTER BIT(0)
1318c2ecf20Sopenharmony_ci#  define AUTO_COMMAND_GO       BIT(1)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define RESELECTID	0x1C  /* R   */
1348c2ecf20Sopenharmony_ci#define COMMANDDATA	0x1D  /* R/W */
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#define POINTERCLR	0x1E  /*   W */
1378c2ecf20Sopenharmony_ci#  define POINTER_CLEAR      BIT(0)
1388c2ecf20Sopenharmony_ci#  define ACK_COUNTER_CLEAR  BIT(1)
1398c2ecf20Sopenharmony_ci#  define REQ_COUNTER_CLEAR  BIT(2)
1408c2ecf20Sopenharmony_ci#  define HOST_COUNTER_CLEAR BIT(3)
1418c2ecf20Sopenharmony_ci#  define READ_SOURCE        (BIT(4) | BIT(5))
1428c2ecf20Sopenharmony_ci#    define ACK_COUNTER        (0)
1438c2ecf20Sopenharmony_ci#    define REQ_COUNTER        (BIT(4))
1448c2ecf20Sopenharmony_ci#    define HOST_COUNTER       (BIT(5))
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#define TRANSFERCOUNT	0x1E  /* R   */
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#define TRANSFERMODE	0x20  /* R/W */
1498c2ecf20Sopenharmony_ci#  define MODE_MEM8   BIT(0)
1508c2ecf20Sopenharmony_ci#  define MODE_MEM32  BIT(1)
1518c2ecf20Sopenharmony_ci#  define MODE_ADR24  BIT(2)
1528c2ecf20Sopenharmony_ci#  define MODE_ADR32  BIT(3)
1538c2ecf20Sopenharmony_ci#  define MODE_IO8    BIT(4)
1548c2ecf20Sopenharmony_ci#  define MODE_IO32   BIT(5)
1558c2ecf20Sopenharmony_ci#  define TRANSFER_GO BIT(6)
1568c2ecf20Sopenharmony_ci#  define BRAIND      BIT(7)
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define SYNCREG		0x21 /* R/W */
1598c2ecf20Sopenharmony_ci#  define SYNCREG_OFFSET_MASK  0x0f
1608c2ecf20Sopenharmony_ci#  define SYNCREG_PERIOD_MASK  0xf0
1618c2ecf20Sopenharmony_ci#  define SYNCREG_PERIOD_SHIFT 4
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci#define SCSIDATALATCH	0x22 /*   W */
1648c2ecf20Sopenharmony_ci#define SCSIDATAIN	0x22 /* R   */
1658c2ecf20Sopenharmony_ci#define SCSIDATAWITHACK	0x23 /* R/W */
1668c2ecf20Sopenharmony_ci#define SCAMCONTROL	0x24 /*   W */
1678c2ecf20Sopenharmony_ci#define SCAMSTATUS	0x24 /* R   */
1688c2ecf20Sopenharmony_ci#define SCAMDATA	0x25 /* R/W */
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#define OTHERCONTROL	0x26 /* R/W */
1718c2ecf20Sopenharmony_ci#  define TPL_ROM_WRITE_EN BIT(0)
1728c2ecf20Sopenharmony_ci#  define TPWR_OUT         BIT(1)
1738c2ecf20Sopenharmony_ci#  define TPWR_SENSE       BIT(2)
1748c2ecf20Sopenharmony_ci#  define RA8_CONTROL      BIT(3)
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci#define ACKWIDTH	0x27 /* R/W */
1778c2ecf20Sopenharmony_ci#define CLRTESTPNT	0x28 /*   W */
1788c2ecf20Sopenharmony_ci#define ACKCNTLD	0x29 /*   W */
1798c2ecf20Sopenharmony_ci#define REQCNTLD	0x2A /*   W */
1808c2ecf20Sopenharmony_ci#define HSTCNTLD	0x2B /*   W */
1818c2ecf20Sopenharmony_ci#define CHECKSUM	0x2C /* R/W */
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci/************************************************************************
1848c2ecf20Sopenharmony_ci * Input status bit definitions.
1858c2ecf20Sopenharmony_ci ************************************************************************/
1868c2ecf20Sopenharmony_ci#define S_MESSAGE	BIT(0)    /* Message line from SCSI bus      */
1878c2ecf20Sopenharmony_ci#define S_IO		BIT(1)    /* Input/Output line from SCSI bus */
1888c2ecf20Sopenharmony_ci#define S_CD		BIT(2)    /* Command/Data line from SCSI bus */
1898c2ecf20Sopenharmony_ci#define S_BUSY		BIT(3)    /* Busy line from SCSI bus         */
1908c2ecf20Sopenharmony_ci#define S_ACK		BIT(4)    /* Acknowledge line from SCSI bus  */
1918c2ecf20Sopenharmony_ci#define S_REQUEST	BIT(5)    /* Request line from SCSI bus      */
1928c2ecf20Sopenharmony_ci#define S_SELECT	BIT(6)	  /*                                 */
1938c2ecf20Sopenharmony_ci#define S_ATN		BIT(7)	  /*                                 */
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci/***********************************************************************
1968c2ecf20Sopenharmony_ci * Useful Bus Monitor status combinations.
1978c2ecf20Sopenharmony_ci ***********************************************************************/
1988c2ecf20Sopenharmony_ci#define BUSMON_SEL         S_SELECT
1998c2ecf20Sopenharmony_ci#define BUSMON_BSY         S_BUSY
2008c2ecf20Sopenharmony_ci#define BUSMON_REQ         S_REQUEST
2018c2ecf20Sopenharmony_ci#define BUSMON_IO          S_IO
2028c2ecf20Sopenharmony_ci#define BUSMON_ACK         S_ACK
2038c2ecf20Sopenharmony_ci#define BUSMON_BUS_FREE    0
2048c2ecf20Sopenharmony_ci#define BUSMON_COMMAND     ( S_BUSY | S_CD |                    S_REQUEST )
2058c2ecf20Sopenharmony_ci#define BUSMON_MESSAGE_IN  ( S_BUSY | S_CD | S_IO | S_MESSAGE | S_REQUEST )
2068c2ecf20Sopenharmony_ci#define BUSMON_MESSAGE_OUT ( S_BUSY | S_CD |        S_MESSAGE | S_REQUEST )
2078c2ecf20Sopenharmony_ci#define BUSMON_DATA_IN     ( S_BUSY |        S_IO |             S_REQUEST )
2088c2ecf20Sopenharmony_ci#define BUSMON_DATA_OUT    ( S_BUSY |                           S_REQUEST )
2098c2ecf20Sopenharmony_ci#define BUSMON_STATUS      ( S_BUSY | S_CD | S_IO |             S_REQUEST )
2108c2ecf20Sopenharmony_ci#define BUSMON_SELECT      (                 S_IO |                        S_SELECT )
2118c2ecf20Sopenharmony_ci#define BUSMON_RESELECT    (                 S_IO |                        S_SELECT )
2128c2ecf20Sopenharmony_ci#define BUSMON_PHASE_MASK  (          S_CD | S_IO | S_MESSAGE |            S_SELECT )
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define BUSPHASE_SELECT      ( BUSMON_SELECT      & BUSMON_PHASE_MASK )
2158c2ecf20Sopenharmony_ci#define BUSPHASE_COMMAND     ( BUSMON_COMMAND     & BUSMON_PHASE_MASK )
2168c2ecf20Sopenharmony_ci#define BUSPHASE_MESSAGE_IN  ( BUSMON_MESSAGE_IN  & BUSMON_PHASE_MASK )
2178c2ecf20Sopenharmony_ci#define BUSPHASE_MESSAGE_OUT ( BUSMON_MESSAGE_OUT & BUSMON_PHASE_MASK )
2188c2ecf20Sopenharmony_ci#define BUSPHASE_DATA_IN     ( BUSMON_DATA_IN     & BUSMON_PHASE_MASK )
2198c2ecf20Sopenharmony_ci#define BUSPHASE_DATA_OUT    ( BUSMON_DATA_OUT    & BUSMON_PHASE_MASK )
2208c2ecf20Sopenharmony_ci#define BUSPHASE_STATUS      ( BUSMON_STATUS      & BUSMON_PHASE_MASK )
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci/*====================================================================*/
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_citypedef struct scsi_info_t {
2258c2ecf20Sopenharmony_ci	struct pcmcia_device	*p_dev;
2268c2ecf20Sopenharmony_ci	struct Scsi_Host      *host;
2278c2ecf20Sopenharmony_ci	int                    stop;
2288c2ecf20Sopenharmony_ci} scsi_info_t;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/* synchronous transfer negotiation data */
2328c2ecf20Sopenharmony_citypedef struct _sync_data {
2338c2ecf20Sopenharmony_ci	unsigned int SyncNegotiation;
2348c2ecf20Sopenharmony_ci#define SYNC_NOT_YET 0
2358c2ecf20Sopenharmony_ci#define SYNC_OK      1
2368c2ecf20Sopenharmony_ci#define SYNC_NG      2
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	unsigned int  SyncPeriod;
2398c2ecf20Sopenharmony_ci	unsigned int  SyncOffset;
2408c2ecf20Sopenharmony_ci	unsigned char SyncRegister;
2418c2ecf20Sopenharmony_ci	unsigned char AckWidth;
2428c2ecf20Sopenharmony_ci} sync_data;
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_citypedef struct _nsp_hw_data {
2458c2ecf20Sopenharmony_ci	unsigned int  BaseAddress;
2468c2ecf20Sopenharmony_ci	unsigned int  NumAddress;
2478c2ecf20Sopenharmony_ci	unsigned int  IrqNumber;
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci	unsigned long MmioAddress;
2508c2ecf20Sopenharmony_ci#define NSP_MMIO_OFFSET 0x0800
2518c2ecf20Sopenharmony_ci	unsigned long MmioLength;
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	unsigned char ScsiClockDiv;
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	unsigned char TransferMode;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	int           TimerCount;
2588c2ecf20Sopenharmony_ci	int           SelectionTimeOut;
2598c2ecf20Sopenharmony_ci	struct scsi_cmnd *CurrentSC;
2608c2ecf20Sopenharmony_ci	//int           CurrnetTarget;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	int           FifoCount;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci#define MSGBUF_SIZE 20
2658c2ecf20Sopenharmony_ci	unsigned char MsgBuffer[MSGBUF_SIZE];
2668c2ecf20Sopenharmony_ci	int MsgLen;
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci#define N_TARGET 8
2698c2ecf20Sopenharmony_ci	sync_data     Sync[N_TARGET];
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	char nspinfo[110];     /* description */
2728c2ecf20Sopenharmony_ci	spinlock_t Lock;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	scsi_info_t   *ScsiInfo; /* attach <-> detect glue */
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci#ifdef NSP_DEBUG
2788c2ecf20Sopenharmony_ci	int CmdId; /* Accepted command serial number.
2798c2ecf20Sopenharmony_ci		      Used for debugging.             */
2808c2ecf20Sopenharmony_ci#endif
2818c2ecf20Sopenharmony_ci} nsp_hw_data;
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci/****************************************************************************
2848c2ecf20Sopenharmony_ci *
2858c2ecf20Sopenharmony_ci */
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci/* Card service functions */
2888c2ecf20Sopenharmony_cistatic void        nsp_cs_detach (struct pcmcia_device *p_dev);
2898c2ecf20Sopenharmony_cistatic void        nsp_cs_release(struct pcmcia_device *link);
2908c2ecf20Sopenharmony_cistatic int        nsp_cs_config (struct pcmcia_device *link);
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci/* Linux SCSI subsystem specific functions */
2938c2ecf20Sopenharmony_cistatic struct Scsi_Host *nsp_detect     (struct scsi_host_template *sht);
2948c2ecf20Sopenharmony_cistatic const  char      *nsp_info       (struct Scsi_Host *shpnt);
2958c2ecf20Sopenharmony_cistatic        int        nsp_show_info  (struct seq_file *m,
2968c2ecf20Sopenharmony_ci	                                 struct Scsi_Host *host);
2978c2ecf20Sopenharmony_cistatic int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci/* Error handler */
3008c2ecf20Sopenharmony_ci/*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
3018c2ecf20Sopenharmony_ci/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
3028c2ecf20Sopenharmony_cistatic int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
3038c2ecf20Sopenharmony_cistatic int nsp_eh_host_reset   (struct scsi_cmnd *SCpnt);
3048c2ecf20Sopenharmony_cistatic int nsp_bus_reset       (nsp_hw_data *data);
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci/* */
3078c2ecf20Sopenharmony_cistatic int  nsphw_init           (nsp_hw_data *data);
3088c2ecf20Sopenharmony_cistatic int  nsphw_start_selection(struct scsi_cmnd *SCpnt);
3098c2ecf20Sopenharmony_cistatic void nsp_start_timer      (struct scsi_cmnd *SCpnt, int time);
3108c2ecf20Sopenharmony_cistatic int  nsp_fifo_count       (struct scsi_cmnd *SCpnt);
3118c2ecf20Sopenharmony_cistatic void nsp_pio_read         (struct scsi_cmnd *SCpnt);
3128c2ecf20Sopenharmony_cistatic void nsp_pio_write        (struct scsi_cmnd *SCpnt);
3138c2ecf20Sopenharmony_cistatic int  nsp_nexus            (struct scsi_cmnd *SCpnt);
3148c2ecf20Sopenharmony_cistatic void nsp_scsi_done        (struct scsi_cmnd *SCpnt);
3158c2ecf20Sopenharmony_cistatic int  nsp_analyze_sdtr     (struct scsi_cmnd *SCpnt);
3168c2ecf20Sopenharmony_cistatic int  nsp_negate_signal    (struct scsi_cmnd *SCpnt,
3178c2ecf20Sopenharmony_ci				  unsigned char mask, char *str);
3188c2ecf20Sopenharmony_cistatic int  nsp_expect_signal    (struct scsi_cmnd *SCpnt,
3198c2ecf20Sopenharmony_ci				  unsigned char current_phase,
3208c2ecf20Sopenharmony_ci				  unsigned char  mask);
3218c2ecf20Sopenharmony_cistatic int  nsp_xfer             (struct scsi_cmnd *SCpnt, int phase);
3228c2ecf20Sopenharmony_cistatic int  nsp_dataphase_bypass (struct scsi_cmnd *SCpnt);
3238c2ecf20Sopenharmony_cistatic int  nsp_reselected       (struct scsi_cmnd *SCpnt);
3248c2ecf20Sopenharmony_cistatic struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci/* Interrupt handler */
3278c2ecf20Sopenharmony_ci//static irqreturn_t nspintr(int irq, void *dev_id);
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/* Debug */
3308c2ecf20Sopenharmony_ci#ifdef NSP_DEBUG
3318c2ecf20Sopenharmony_cistatic void show_command (struct scsi_cmnd *SCpnt);
3328c2ecf20Sopenharmony_cistatic void show_phase   (struct scsi_cmnd *SCpnt);
3338c2ecf20Sopenharmony_cistatic void show_busphase(unsigned char stat);
3348c2ecf20Sopenharmony_cistatic void show_message (nsp_hw_data *data);
3358c2ecf20Sopenharmony_ci#else
3368c2ecf20Sopenharmony_ci# define show_command(ptr)   /* */
3378c2ecf20Sopenharmony_ci# define show_phase(SCpnt)   /* */
3388c2ecf20Sopenharmony_ci# define show_busphase(stat) /* */
3398c2ecf20Sopenharmony_ci# define show_message(data)  /* */
3408c2ecf20Sopenharmony_ci#endif
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci/*
3438c2ecf20Sopenharmony_ci * SCSI phase
3448c2ecf20Sopenharmony_ci */
3458c2ecf20Sopenharmony_cienum _scsi_phase {
3468c2ecf20Sopenharmony_ci	PH_UNDETERMINED ,
3478c2ecf20Sopenharmony_ci	PH_ARBSTART     ,
3488c2ecf20Sopenharmony_ci	PH_SELSTART     ,
3498c2ecf20Sopenharmony_ci	PH_SELECTED     ,
3508c2ecf20Sopenharmony_ci	PH_COMMAND      ,
3518c2ecf20Sopenharmony_ci	PH_DATA         ,
3528c2ecf20Sopenharmony_ci	PH_STATUS       ,
3538c2ecf20Sopenharmony_ci	PH_MSG_IN       ,
3548c2ecf20Sopenharmony_ci	PH_MSG_OUT      ,
3558c2ecf20Sopenharmony_ci	PH_DISCONNECT   ,
3568c2ecf20Sopenharmony_ci	PH_RESELECT     ,
3578c2ecf20Sopenharmony_ci	PH_ABORT        ,
3588c2ecf20Sopenharmony_ci	PH_RESET
3598c2ecf20Sopenharmony_ci};
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_cienum _data_in_out {
3628c2ecf20Sopenharmony_ci	IO_UNKNOWN,
3638c2ecf20Sopenharmony_ci	IO_IN,
3648c2ecf20Sopenharmony_ci	IO_OUT
3658c2ecf20Sopenharmony_ci};
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_cienum _burst_mode {
3688c2ecf20Sopenharmony_ci	BURST_IO8   = 0,
3698c2ecf20Sopenharmony_ci	BURST_IO32  = 1,
3708c2ecf20Sopenharmony_ci	BURST_MEM32 = 2,
3718c2ecf20Sopenharmony_ci};
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci/**************************************************************************
3748c2ecf20Sopenharmony_ci * SCSI messaage
3758c2ecf20Sopenharmony_ci */
3768c2ecf20Sopenharmony_ci#define MSG_COMMAND_COMPLETE 0x00
3778c2ecf20Sopenharmony_ci#define MSG_EXTENDED         0x01
3788c2ecf20Sopenharmony_ci#define MSG_ABORT            0x06
3798c2ecf20Sopenharmony_ci#define MSG_NO_OPERATION     0x08
3808c2ecf20Sopenharmony_ci#define MSG_BUS_DEVICE_RESET 0x0c
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci#define MSG_EXT_SDTR         0x01
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci/* scatter-gather table */
3858c2ecf20Sopenharmony_ci#  define BUFFER_ADDR ((char *)((sg_virt(SCpnt->SCp.buffer))))
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci#endif  /*__nsp_cs__*/
3888c2ecf20Sopenharmony_ci/* end */
389