xref: /openbmc/u-boot/include/scsi.h (revision e85390dc1d9c3c942c11bbf003e6c10a73e25ed6)
1*e85390dcSwdenk /*
2*e85390dcSwdenk  * (C) Copyright 2001
3*e85390dcSwdenk  * Denis Peter, MPL AG Switzerland
4*e85390dcSwdenk  *
5*e85390dcSwdenk  * See file CREDITS for list of people who contributed to this
6*e85390dcSwdenk  * project.
7*e85390dcSwdenk  *
8*e85390dcSwdenk  * This program is free software; you can redistribute it and/or
9*e85390dcSwdenk  * modify it under the terms of the GNU General Public License as
10*e85390dcSwdenk  * published by the Free Software Foundation; either version 2 of
11*e85390dcSwdenk  * the License, or (at your option) any later version.
12*e85390dcSwdenk  *
13*e85390dcSwdenk  * This program is distributed in the hope that it will be useful,
14*e85390dcSwdenk  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e85390dcSwdenk  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*e85390dcSwdenk  * GNU General Public License for more details.
17*e85390dcSwdenk  *
18*e85390dcSwdenk  * You should have received a copy of the GNU General Public License
19*e85390dcSwdenk  * along with this program; if not, write to the Free Software
20*e85390dcSwdenk  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21*e85390dcSwdenk  * MA 02111-1307 USA
22*e85390dcSwdenk  *
23*e85390dcSwdenk  */
24*e85390dcSwdenk  #ifndef _SCSI_H
25*e85390dcSwdenk  #define _SCSI_H
26*e85390dcSwdenk 
27*e85390dcSwdenk typedef struct SCSI_cmd_block{
28*e85390dcSwdenk 	unsigned char		cmd[16];					/* command				   */
29*e85390dcSwdenk 	unsigned char		sense_buf[64];		/* for request sense */
30*e85390dcSwdenk 	unsigned char		status;						/* SCSI Status			 */
31*e85390dcSwdenk 	unsigned char		target;						/* Target ID				 */
32*e85390dcSwdenk 	unsigned char		lun;							/* Target LUN        */
33*e85390dcSwdenk 	unsigned char		cmdlen;						/* command len				*/
34*e85390dcSwdenk 	unsigned long		datalen;					/* Total data length	*/
35*e85390dcSwdenk 	unsigned char	*	pdata; 						/* pointer to data		*/
36*e85390dcSwdenk 	unsigned char		msgout[12];				/* Messge out buffer (NOT USED) */
37*e85390dcSwdenk 	unsigned char		msgin[12];				/* Message in buffer	*/
38*e85390dcSwdenk 	unsigned char		sensecmdlen;			/* Sense command len	*/
39*e85390dcSwdenk 	unsigned long		sensedatalen;			/* Sense data len			*/
40*e85390dcSwdenk 	unsigned char		sensecmd[6];			/* Sense command			*/
41*e85390dcSwdenk 	unsigned long		contr_stat;				/* Controller Status	*/
42*e85390dcSwdenk 	unsigned long		trans_bytes;			/* tranfered bytes		*/
43*e85390dcSwdenk 
44*e85390dcSwdenk 	unsigned int		priv;
45*e85390dcSwdenk }ccb;
46*e85390dcSwdenk 
47*e85390dcSwdenk /*-----------------------------------------------------------
48*e85390dcSwdenk **
49*e85390dcSwdenk **	SCSI  constants.
50*e85390dcSwdenk **
51*e85390dcSwdenk **-----------------------------------------------------------
52*e85390dcSwdenk */
53*e85390dcSwdenk 
54*e85390dcSwdenk /*
55*e85390dcSwdenk **	Messages
56*e85390dcSwdenk */
57*e85390dcSwdenk 
58*e85390dcSwdenk #define	M_COMPLETE	(0x00)
59*e85390dcSwdenk #define	M_EXTENDED	(0x01)
60*e85390dcSwdenk #define	M_SAVE_DP	(0x02)
61*e85390dcSwdenk #define	M_RESTORE_DP	(0x03)
62*e85390dcSwdenk #define	M_DISCONNECT	(0x04)
63*e85390dcSwdenk #define	M_ID_ERROR	(0x05)
64*e85390dcSwdenk #define	M_ABORT		(0x06)
65*e85390dcSwdenk #define	M_REJECT	(0x07)
66*e85390dcSwdenk #define	M_NOOP		(0x08)
67*e85390dcSwdenk #define	M_PARITY	(0x09)
68*e85390dcSwdenk #define	M_LCOMPLETE	(0x0a)
69*e85390dcSwdenk #define	M_FCOMPLETE	(0x0b)
70*e85390dcSwdenk #define	M_RESET		(0x0c)
71*e85390dcSwdenk #define	M_ABORT_TAG	(0x0d)
72*e85390dcSwdenk #define	M_CLEAR_QUEUE	(0x0e)
73*e85390dcSwdenk #define	M_INIT_REC	(0x0f)
74*e85390dcSwdenk #define	M_REL_REC	(0x10)
75*e85390dcSwdenk #define	M_TERMINATE	(0x11)
76*e85390dcSwdenk #define	M_SIMPLE_TAG	(0x20)
77*e85390dcSwdenk #define	M_HEAD_TAG	(0x21)
78*e85390dcSwdenk #define	M_ORDERED_TAG	(0x22)
79*e85390dcSwdenk #define	M_IGN_RESIDUE	(0x23)
80*e85390dcSwdenk #define	M_IDENTIFY   	(0x80)
81*e85390dcSwdenk 
82*e85390dcSwdenk #define	M_X_MODIFY_DP	(0x00)
83*e85390dcSwdenk #define	M_X_SYNC_REQ	(0x01)
84*e85390dcSwdenk #define	M_X_WIDE_REQ	(0x03)
85*e85390dcSwdenk #define	M_X_PPR_REQ	(0x04)
86*e85390dcSwdenk 
87*e85390dcSwdenk 
88*e85390dcSwdenk /*
89*e85390dcSwdenk **	Status
90*e85390dcSwdenk */
91*e85390dcSwdenk 
92*e85390dcSwdenk #define	S_GOOD		(0x00)
93*e85390dcSwdenk #define	S_CHECK_COND	(0x02)
94*e85390dcSwdenk #define	S_COND_MET	(0x04)
95*e85390dcSwdenk #define	S_BUSY		(0x08)
96*e85390dcSwdenk #define	S_INT		(0x10)
97*e85390dcSwdenk #define	S_INT_COND_MET	(0x14)
98*e85390dcSwdenk #define	S_CONFLICT	(0x18)
99*e85390dcSwdenk #define	S_TERMINATED	(0x20)
100*e85390dcSwdenk #define	S_QUEUE_FULL	(0x28)
101*e85390dcSwdenk #define	S_ILLEGAL	(0xff)
102*e85390dcSwdenk #define	S_SENSE		(0x80)
103*e85390dcSwdenk 
104*e85390dcSwdenk /*
105*e85390dcSwdenk  * Sense_keys
106*e85390dcSwdenk  */
107*e85390dcSwdenk 
108*e85390dcSwdenk #define SENSE_NO_SENSE				0x0
109*e85390dcSwdenk #define SENSE_RECOVERED_ERROR	0x1
110*e85390dcSwdenk #define SENSE_NOT_READY				0x2
111*e85390dcSwdenk #define SENSE_MEDIUM_ERROR		0x3
112*e85390dcSwdenk #define SENSE_HARDWARE_ERROR	0x4
113*e85390dcSwdenk #define SENSE_ILLEGAL_REQUEST	0x5
114*e85390dcSwdenk #define SENSE_UNIT_ATTENTION	0x6
115*e85390dcSwdenk #define SENSE_DATA_PROTECT		0x7
116*e85390dcSwdenk #define SENSE_BLANK_CHECK			0x8
117*e85390dcSwdenk #define SENSE_VENDOR_SPECIFIC	0x9
118*e85390dcSwdenk #define SENSE_COPY_ABORTED		0xA
119*e85390dcSwdenk #define SENSE_ABORTED_COMMAND	0xB
120*e85390dcSwdenk #define SENSE_VOLUME_OVERFLOW	0xD
121*e85390dcSwdenk #define SENSE_MISCOMPARE			0xE
122*e85390dcSwdenk 
123*e85390dcSwdenk 
124*e85390dcSwdenk #define SCSI_CHANGE_DEF	0x40		/* Change Definition (Optional) */
125*e85390dcSwdenk #define SCSI_COMPARE		0x39		/* Compare (O) */
126*e85390dcSwdenk #define SCSI_COPY			0x18		/* Copy (O) */
127*e85390dcSwdenk #define SCSI_COP_VERIFY	0x3A		/* Copy and Verify (O) */
128*e85390dcSwdenk #define SCSI_INQUIRY		0x12		/* Inquiry (MANDATORY) */
129*e85390dcSwdenk #define SCSI_LOG_SELECT	0x4C		/* Log Select (O) */
130*e85390dcSwdenk #define SCSI_LOG_SENSE	0x4D		/* Log Sense (O) */
131*e85390dcSwdenk #define SCSI_MODE_SEL6	0x15		/* Mode Select 6-byte (Device Specific) */
132*e85390dcSwdenk #define SCSI_MODE_SEL10	0x55		/* Mode Select 10-byte (Device Specific) */
133*e85390dcSwdenk #define SCSI_MODE_SEN6	0x1A		/* Mode Sense 6-byte (Device Specific) */
134*e85390dcSwdenk #define SCSI_MODE_SEN10	0x5A		/* Mode Sense 10-byte (Device Specific) */
135*e85390dcSwdenk #define SCSI_READ_BUFF	0x3C		/* Read Buffer (O) */
136*e85390dcSwdenk #define SCSI_REQ_SENSE	0x03		/* Request Sense (MANDATORY) */
137*e85390dcSwdenk #define SCSI_SEND_DIAG	0x1D		/* Send Diagnostic (O) */
138*e85390dcSwdenk #define SCSI_TST_U_RDY	0x00		/* Test Unit Ready (MANDATORY) */
139*e85390dcSwdenk #define SCSI_WRITE_BUFF	0x3B		/* Write Buffer (O) */
140*e85390dcSwdenk /***************************************************************************
141*e85390dcSwdenk  *			  %%% Commands Unique to Direct Access Devices %%%
142*e85390dcSwdenk  ***************************************************************************/
143*e85390dcSwdenk #define SCSI_COMPARE		0x39		/* Compare (O) */
144*e85390dcSwdenk #define SCSI_FORMAT		0x04		/* Format Unit (MANDATORY) */
145*e85390dcSwdenk #define SCSI_LCK_UN_CAC	0x36		/* Lock Unlock Cache (O) */
146*e85390dcSwdenk #define SCSI_PREFETCH	0x34		/* Prefetch (O) */
147*e85390dcSwdenk #define SCSI_MED_REMOVL	0x1E		/* Prevent/Allow medium Removal (O) */
148*e85390dcSwdenk #define SCSI_READ6		0x08		/* Read 6-byte (MANDATORY) */
149*e85390dcSwdenk #define SCSI_READ10		0x28		/* Read 10-byte (MANDATORY) */
150*e85390dcSwdenk #define SCSI_RD_CAPAC	0x25		/* Read Capacity (MANDATORY) */
151*e85390dcSwdenk #define SCSI_RD_DEFECT	0x37		/* Read Defect Data (O) */
152*e85390dcSwdenk #define SCSI_READ_LONG	0x3E		/* Read Long (O) */
153*e85390dcSwdenk #define SCSI_REASS_BLK	0x07		/* Reassign Blocks (O) */
154*e85390dcSwdenk #define SCSI_RCV_DIAG	0x1C		/* Receive Diagnostic Results (O) */
155*e85390dcSwdenk #define SCSI_RELEASE	0x17		/* Release Unit (MANDATORY) */
156*e85390dcSwdenk #define SCSI_REZERO		0x01		/* Rezero Unit (O) */
157*e85390dcSwdenk #define SCSI_SRCH_DAT_E	0x31		/* Search Data Equal (O) */
158*e85390dcSwdenk #define SCSI_SRCH_DAT_H	0x30		/* Search Data High (O) */
159*e85390dcSwdenk #define SCSI_SRCH_DAT_L	0x32		/* Search Data Low (O) */
160*e85390dcSwdenk #define SCSI_SEEK6		0x0B		/* Seek 6-Byte (O) */
161*e85390dcSwdenk #define SCSI_SEEK10		0x2B		/* Seek 10-Byte (O) */
162*e85390dcSwdenk #define SCSI_SEND_DIAG	0x1D		/* Send Diagnostics (MANDATORY) */
163*e85390dcSwdenk #define SCSI_SET_LIMIT	0x33		/* Set Limits (O) */
164*e85390dcSwdenk #define SCSI_START_STP	0x1B		/* Start/Stop Unit (O) */
165*e85390dcSwdenk #define SCSI_SYNC_CACHE	0x35		/* Synchronize Cache (O) */
166*e85390dcSwdenk #define SCSI_VERIFY		0x2F		/* Verify (O) */
167*e85390dcSwdenk #define SCSI_WRITE6		0x0A		/* Write 6-Byte (MANDATORY) */
168*e85390dcSwdenk #define SCSI_WRITE10	0x2A		/* Write 10-Byte (MANDATORY) */
169*e85390dcSwdenk #define SCSI_WRT_VERIFY	0x2E		/* Write and Verify (O) */
170*e85390dcSwdenk #define SCSI_WRITE_LONG	0x3F		/* Write Long (O) */
171*e85390dcSwdenk #define SCSI_WRITE_SAME	0x41		/* Write Same (O) */
172*e85390dcSwdenk 
173*e85390dcSwdenk 
174*e85390dcSwdenk /****************************************************************************
175*e85390dcSwdenk  * decleration of functions which have to reside in the LowLevel Part Driver
176*e85390dcSwdenk  */
177*e85390dcSwdenk 
178*e85390dcSwdenk void scsi_print_error(ccb *pccb);
179*e85390dcSwdenk int scsi_exec(ccb *pccb);
180*e85390dcSwdenk void scsi_bus_reset(void);
181*e85390dcSwdenk void scsi_low_level_init(int busdevfunc);
182*e85390dcSwdenk 
183*e85390dcSwdenk 
184*e85390dcSwdenk /***************************************************************************
185*e85390dcSwdenk  * functions residing inside cmd_scsi.c
186*e85390dcSwdenk  */
187*e85390dcSwdenk void scsi_init(void);
188*e85390dcSwdenk 
189*e85390dcSwdenk 
190*e85390dcSwdenk 
191*e85390dcSwdenk #define SCSI_IDENTIFY					0xC0  /* not used */
192*e85390dcSwdenk 
193*e85390dcSwdenk /* Hardware errors  */
194*e85390dcSwdenk #define SCSI_SEL_TIME_OUT			 0x00000101	 /* Selection time out */
195*e85390dcSwdenk #define SCSI_HNS_TIME_OUT			 0x00000102  /* Handshake */
196*e85390dcSwdenk #define SCSI_MA_TIME_OUT	 		 0x00000103  /* Phase error */
197*e85390dcSwdenk #define SCSI_UNEXP_DIS				 0x00000104  /* unexpected disconnect */
198*e85390dcSwdenk 
199*e85390dcSwdenk #define SCSI_INT_STATE				 0x00010000  /* unknown Interrupt number is stored in 16 LSB */
200*e85390dcSwdenk 
201*e85390dcSwdenk 
202*e85390dcSwdenk 
203*e85390dcSwdenk #ifndef TRUE
204*e85390dcSwdenk #define TRUE 1
205*e85390dcSwdenk #endif
206*e85390dcSwdenk #ifndef FALSE
207*e85390dcSwdenk #define FALSE 0
208*e85390dcSwdenk #endif
209*e85390dcSwdenk 
210*e85390dcSwdenk 
211*e85390dcSwdenk 
212*e85390dcSwdenk 
213*e85390dcSwdenk 
214*e85390dcSwdenk #endif /* _SCSI_H */
215*e85390dcSwdenk 
216