153895Smckusick /*
2*63304Sbostic  * Copyright (c) 1992, 1993
3*63304Sbostic  *	The Regents of the University of California.  All rights reserved.
453895Smckusick  *
553895Smckusick  * This code is derived from software contributed to Berkeley by
653895Smckusick  * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
753895Smckusick  *
853895Smckusick  * %sccs.include.redist.c%
953895Smckusick  *
1053895Smckusick  * from: $Hdr: screg_1185.h,v 4.300 91/06/09 06:22:14 root Rel41 $ SONY
1153895Smckusick  *
12*63304Sbostic  *	@(#)screg_1185.h	8.1 (Berkeley) 06/11/93
1353895Smckusick  */
1453895Smckusick 
1553895Smckusick /*
1653895Smckusick  * Copyright (c) 1989- by SONY Corporation.
1753895Smckusick  */
1853895Smckusick 
1953895Smckusick /*
2053895Smckusick  *	screg_1185.h	ver 0.0
2153895Smckusick  *		for SCSI I/F Chip CXD1185Q
2253895Smckusick  */
2353895Smckusick 
2453895Smckusick /*
2553895Smckusick  *		SCSI I/F Chip CXD1185Q Register address assignment
2653895Smckusick  */
2753895Smckusick #ifdef mips
2853895Smckusick # define	SCSI_BASE	0xbfe00100
2953895Smckusick #else
3053895Smckusick # define	SCSI_BASE	0xe1900000
3153895Smckusick #endif
3253895Smckusick 
3353895Smckusick #ifndef U_CHAR
3453895Smckusick #ifdef mips
3553895Smckusick #define U_CHAR volatile u_char
3653895Smckusick #else
3753895Smckusick #define U_CHAR u_char
3853895Smckusick #endif
3953895Smckusick #endif
4053895Smckusick 
4153895Smckusick #define	sc_statr	*( (U_CHAR *)(SCSI_BASE + 0x0) )
4253895Smckusick #define	sc_comr		*( (U_CHAR *)(SCSI_BASE + 0x0) )
4353895Smckusick #define	sc_datr		*( (U_CHAR *)(SCSI_BASE + 0x1) )
4453895Smckusick #define	sc_intrq1	*( (U_CHAR *)(SCSI_BASE + 0x2) )
4553895Smckusick #define	sc_intrq2	*( (U_CHAR *)(SCSI_BASE + 0x3) )
4653895Smckusick #define	sc_envir	*( (U_CHAR *)(SCSI_BASE + 0x3) )
4753895Smckusick #define	sc_cmonr	*( (U_CHAR *)(SCSI_BASE + 0x4) )
4853895Smckusick #define	sc_timer	*( (U_CHAR *)(SCSI_BASE + 0x4) )
4953895Smckusick #define	sc_ffstr	*( (U_CHAR *)(SCSI_BASE + 0x5) )
5053895Smckusick #define	sc_idenr	*( (U_CHAR *)(SCSI_BASE + 0x6) )
5153895Smckusick #define	sc_tclow	*( (U_CHAR *)(SCSI_BASE + 0x7) )
5253895Smckusick #define	sc_tcmid	*( (U_CHAR *)(SCSI_BASE + 0x8) )
5353895Smckusick #define	sc_tchi		*( (U_CHAR *)(SCSI_BASE + 0x9) )
5453895Smckusick #define	sc_intok1	*( (U_CHAR *)(SCSI_BASE + 0xa) )
5553895Smckusick #define	sc_intok2	*( (U_CHAR *)(SCSI_BASE + 0xb) )
5653895Smckusick #define	sc_moder	*( (U_CHAR *)(SCSI_BASE + 0xc) )
5753895Smckusick #define	sc_syncr	*( (U_CHAR *)(SCSI_BASE + 0xd) )
5853895Smckusick #define	sc_busconr	*( (U_CHAR *)(SCSI_BASE + 0xe) )
5953895Smckusick #define	sc_ioptr	*( (U_CHAR *)(SCSI_BASE + 0xf) )
6053895Smckusick 
6153895Smckusick /*
6253895Smckusick  *		CXD1185Q Register bit assignment
6353895Smckusick  */
6453895Smckusick 
6553895Smckusick /*	sc_statr (status register) bit define
6653895Smckusick */
6753895Smckusick #define	R0_MRST		0x80
6853895Smckusick #define	R0_MDBP		0x40
6953895Smckusick #define	R0_INIT		0x10
7053895Smckusick #define	R0_TARG		8
7153895Smckusick #define	R0_TRBZ		4
7253895Smckusick #define	R0_MIRQ		2
7353895Smckusick #define	R0_CIP		1
7453895Smckusick 
7553895Smckusick /*	sc_comr (command register) bit define
7653895Smckusick */
7753895Smckusick #define	R0_DMA		0x20
7853895Smckusick #define	R0_TRBE		0x10
7953895Smckusick 
8053895Smckusick /*	sc_intrq1 (interrupt request register 1) bit define
8153895Smckusick */
8253895Smckusick #define	R2_STO		0x10
8353895Smckusick #define	R2_RSL		8
8453895Smckusick #define	R2_SWA		4
8553895Smckusick #define	R2_SWOA		2
8653895Smckusick #define	R2_ARBF		1
8753895Smckusick 
8853895Smckusick /*	sc_intrq2 (interrupt request register 2) bit define
8953895Smckusick */
9053895Smckusick #define	R3_FNC		0x80
9153895Smckusick #define	R3_DCNT		0x40
9253895Smckusick #define	R3_SRST		0x20
9353895Smckusick #define	R3_PHC		0x10
9453895Smckusick #define	R3_DATN		8
9553895Smckusick #define	R3_DPE		4
9653895Smckusick #define	R3_SPE		2
9753895Smckusick #define	R3_RMSG		1
9853895Smckusick 
9953895Smckusick /*	sc_envir (environment register) bit define
10053895Smckusick */
10153895Smckusick #define	R3_DIFE		0x80
10253895Smckusick #define	R3_SDPM		0x40
10353895Smckusick #define	R3_DPEN		0x20
10453895Smckusick #define	R3_SIRM		0x10
10553895Smckusick #define	R3_FS_MASK	3
10653895Smckusick 
10753895Smckusick /*	sc_cmonr (scsi control monitor register) bit define
10853895Smckusick */
10953895Smckusick #define	R4_MBSY		0x80
11053895Smckusick #define	R4_MSEL		0x40
11153895Smckusick #define	R4_MMSG		0x20
11253895Smckusick #define	R4_MCD		0x10
11353895Smckusick #define	R4_MIO		8
11453895Smckusick #define	R4_MREQ		4
11553895Smckusick #define	R4_MACK		2
11653895Smckusick #define	R4_MATN		1
11753895Smckusick 
11853895Smckusick /*	sc_ffstr (FIFO status register) bit define
11953895Smckusick */
12053895Smckusick #define	R5_FIE		0x80
12153895Smckusick #define	R5_FIF		0x10
12253895Smckusick #define	R5_FIFOREM	0x1f
12353895Smckusick 
12453895Smckusick /*	sc_idenr (scsi identify register) bit define
12553895Smckusick */
12653895Smckusick #define	R6_OID_MASK	0x07
12753895Smckusick #define	R6_SID_MASK	0xe0
12853895Smckusick #define	R6_TID_MASK	0xe0
12953895Smckusick 
13053895Smckusick /*	sc_intok1 (interrupt enable register 1) bit define
13153895Smckusick */
13253895Smckusick #define	Ra_STO		0x10
13353895Smckusick #define	Ra_RSL		8
13453895Smckusick #define	Ra_SWA		4
13553895Smckusick #define	Ra_SWOA		2
13653895Smckusick #define	Ra_ARBF		1
13753895Smckusick 
13853895Smckusick /*	sc_intok2 (interrupt enable register 2) bit define
13953895Smckusick */
14053895Smckusick #define	Rb_FNC		0x80
14153895Smckusick #define	Rb_DCNT		0x40
14253895Smckusick #define	Rb_SRST		0x20
14353895Smckusick #define	Rb_PHC		0x10
14453895Smckusick #define	Rb_DATN		8
14553895Smckusick #define	Rb_DPE		4
14653895Smckusick #define	Rb_SPE		2
14753895Smckusick #define	Rb_RMSG		1
14853895Smckusick 
14953895Smckusick /*	sc_moder (mode register) bit define
15053895Smckusick */
15153895Smckusick #define	Rc_HDPE		0x80
15253895Smckusick #define	Rc_HSPE		0x40
15353895Smckusick #define	Rc_HATN		0x20
15453895Smckusick #define	Rc_TMSL		0x10
15553895Smckusick #define	Rc_SPHI		8
15653895Smckusick #define	Rc_BDMA		1
15753895Smckusick 
15853895Smckusick /*	sc_syncr (synchronous transfer control register) bit define
15953895Smckusick */
16053895Smckusick #define	Rd_TPD_MASK	0xf0
16153895Smckusick #define	Rd_TOF_MASK	0x0f
16253895Smckusick #define	MIN_TP		62		/* minimum transfer period 4ns * 25 */
16353895Smckusick #define	MAX_OFFSET	15
16453895Smckusick 
16553895Smckusick /*	sc_busconr (scsi bus control register) bit define
16653895Smckusick */
16753895Smckusick #define	Re_ABSY		0x80
16853895Smckusick #define	Re_ASEL		0x40
16953895Smckusick #define	Re_AMSG		0x20
17053895Smckusick #define	Re_ACD		0x10
17153895Smckusick #define	Re_AIO		8
17253895Smckusick #define	Re_AREQ		4
17353895Smckusick #define	Re_AACK		2
17453895Smckusick #define	Re_AATN		1
17553895Smckusick 
17653895Smckusick /*	sc_ioptr (I/O port) bit define
17753895Smckusick */
17853895Smckusick #define	Rf_PCN_MASK	0xf0
17953895Smckusick # define	Rf_PCN3		0x80
18053895Smckusick # define	Rf_PCN2		0x40
18153895Smckusick # define	Rf_PCN1		0x20
18253895Smckusick # define	Rf_PCN0		0x10
18353895Smckusick #define	Rf_PRT_MASK	0x0f
18453895Smckusick # define	Rf_PRT3		8
18553895Smckusick # define	Rf_PRT2		4
18653895Smckusick # define	Rf_PRT1		2
18753895Smckusick # define	Rf_PRT0		1
18853895Smckusick 
18953895Smckusick 
19053895Smckusick /*
19153895Smckusick  *		CXD1185Q commands
19253895Smckusick  */
19353895Smckusick /*	category 0
19453895Smckusick */
19553895Smckusick #define	SCMD_NOP	0x00
19653895Smckusick #define	SCMD_CHIP_RST	0x01
19753895Smckusick #define	SCMD_AST_RST	0x02
19853895Smckusick #define	SCMD_FLSH_FIFO	0x03
19953895Smckusick #define	SCMD_AST_CTRL	0x04
20053895Smckusick #define	SCMD_NGT_CTRL	0x05
20153895Smckusick #define	SCMD_AST_DATA	0x06
20253895Smckusick #define	SCMD_NGT_DATA	0x07
20353895Smckusick 
20453895Smckusick /*	category 1
20553895Smckusick */
20653895Smckusick #define	SCMD_RESEL	0x40
20753895Smckusick #define	SCMD_SEL	0x41
20853895Smckusick #define	SCMD_SEL_ATN	0x42
20953895Smckusick #define	SCMD_ENB_SEL	0x43
21053895Smckusick #define	SCMD_DIS_SEL	0x44
21153895Smckusick 
21253895Smckusick /*	category 2
21353895Smckusick */
21453895Smckusick #define	SCMD_SEND_MES	0x80
21553895Smckusick #define	SCMD_SEND_STAT	0x81
21653895Smckusick #define	SCMD_SEND_DATA	0x82
21753895Smckusick #define	SCMD_DISCONNECT	0x83
21853895Smckusick #define	SCMD_RCV_MOUT	0x84
21953895Smckusick #define	SCMD_RCV_CMD	0x85
22053895Smckusick #define	SCMD_RCV_DATA	0x86
22153895Smckusick 
22253895Smckusick /*	category 3
22353895Smckusick */
22453895Smckusick #define	SCMD_TR_INFO	0xc0
22553895Smckusick #define	SCMD_TR_PAD	0xc1
22653895Smckusick #define	SCMD_NGT_ACK	0xc2
22753895Smckusick #define	SCMD_AST_ATN	0xc3
22853895Smckusick #define	SCMD_NGT_ATN	0xc4
22953895Smckusick 
23053895Smckusick 
23153895Smckusick /*
23253895Smckusick  *		scsi parameter definition
23353895Smckusick  */
23453895Smckusick /* 	SCSI bus ID
23553895Smckusick */
23653895Smckusick #define	SC_OWNID	0x7
23753895Smckusick #define	SC_TG_SHIFT	5
23853895Smckusick 
23953895Smckusick /*	scsi bus phase
24053895Smckusick */
24153895Smckusick #define	SC_PMASK		(R4_MMSG|R4_MCD|R4_MIO)
24253895Smckusick # define	DAT_OUT		0
24353895Smckusick # define	DAT_IN				R4_MIO
24453895Smckusick # define	COM_OUT			 R4_MCD
24553895Smckusick # define	STAT_IN			(R4_MCD|R4_MIO)
24653895Smckusick # define	MES_OUT		(R4_MMSG|R4_MCD)
24753895Smckusick # define	MES_IN		(R4_MMSG|R4_MCD|R4_MIO)
24853895Smckusick 
24953895Smckusick /*	scsi command types define
25053895Smckusick */
25153895Smckusick #define	CMD_TYPEMASK	0xe0
25253895Smckusick # define	CMD_T0		0		/*  6 byte commands */
25353895Smckusick # define	CMD_T1		0x20		/* 10 byte commands */
25453895Smckusick # define	CMD_T5		0xa0		/* 12 byte commands */
25553895Smckusick # define	CMD_T6		0xc0
25653895Smckusick # define	CMD_T7		0xe0
25753895Smckusick 
25853895Smckusick #define MAXNSCSI	1
259