xref: /onnv-gate/usr/src/uts/sun/sys/dada/adapters/atapi.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (c) 1996 Sun Microsystems, Inc.  All Rights Reserved.
3*0Sstevel@tonic-gate  */
4*0Sstevel@tonic-gate 
5*0Sstevel@tonic-gate #ifndef	_ATAPI_H
6*0Sstevel@tonic-gate #define	_ATAPI_H
7*0Sstevel@tonic-gate 
8*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
9*0Sstevel@tonic-gate 
10*0Sstevel@tonic-gate #ifdef	__cplusplus
11*0Sstevel@tonic-gate extern "C" {
12*0Sstevel@tonic-gate #endif
13*0Sstevel@tonic-gate 
14*0Sstevel@tonic-gate #include <sys/scsi/scsi.h>
15*0Sstevel@tonic-gate 
16*0Sstevel@tonic-gate /*
17*0Sstevel@tonic-gate  * Additional atapi status bits (redefinitions)
18*0Sstevel@tonic-gate  */
19*0Sstevel@tonic-gate #define	ATE_ILI		0x01    /* Illegal length indication		*/
20*0Sstevel@tonic-gate #define	ATE_EOM		0x02	/* End of media detected		*/
21*0Sstevel@tonic-gate #define	ATE_MCR		0x08	/* Media change requested		*/
22*0Sstevel@tonic-gate #define	ATS_SERVICE	0x10	/* overlap operation needs service	*/
23*0Sstevel@tonic-gate #define	ATS_SENSE_KEY	0xf0	/* 4 bit sense key -see ata_sense_table */
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate #define	ATS_SENSE_KEY_SHIFT 4	/* shift to get to ATS_SENSE_KEY	*/
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*
28*0Sstevel@tonic-gate  * Status bits from ATAPI Interrupt reason register (AT_COUNT) register
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate #define	ATI_COD		0x01    /* Command or Data			*/
31*0Sstevel@tonic-gate #define	ATI_IO		0x02    /* IO direction 			*/
32*0Sstevel@tonic-gate #define	ATI_RELEASE	0x04	/* Release for ATAPI overlap		*/
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate /* ATAPI feature reg definitions */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #define	ATF_OVERLAP	0x02
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate /*
39*0Sstevel@tonic-gate  * ATAPI commands.
40*0Sstevel@tonic-gate  */
41*0Sstevel@tonic-gate #define	ATC_PI_SRESET	0x08    /* ATAPI soft reset			*/
42*0Sstevel@tonic-gate #define	ATC_PI_ID_DEV	0xa1	/* ATAPI identify device		*/
43*0Sstevel@tonic-gate #define	ATC_PI_PKT	0xa0	/* ATAPI packet command 		*/
44*0Sstevel@tonic-gate #define	ATC_PI_SERVICE	0xa2	/* ATAPI overlap service command	*/
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate /*
47*0Sstevel@tonic-gate  * ATAPI IDENTIFY_DRIVE configuration word
48*0Sstevel@tonic-gate  */
49*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_PKT_SZ   0x3
50*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_PKT_12B  0x0
51*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_PKT_16B  0x1
52*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_DRQ_TYPE 0x60
53*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_DRQ_INTR 0x20
54*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_DEV_TYPE 0x0f00
55*0Sstevel@tonic-gate #define	ATAPI_ID_CFG_DEV_SHFT 8
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate /*
58*0Sstevel@tonic-gate  * ATAPI IDENTIFY_DRIVE capabilities word
59*0Sstevel@tonic-gate  */
60*0Sstevel@tonic-gate #define	ATAPI_ID_CAP_DMA	0x0100
61*0Sstevel@tonic-gate #define	ATAPI_ID_CAP_OVERLAP	0x2000
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /*
64*0Sstevel@tonic-gate  * ATAPI SET FEATURE commands
65*0Sstevel@tonic-gate  */
66*0Sstevel@tonic-gate #define	ATAPI_FEAT_RELEASE_INTR		0x5d
67*0Sstevel@tonic-gate #define	ATAPI_FEAT_SERVICE_INTR		0x5e
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate /*
70*0Sstevel@tonic-gate  * ATAPI bits
71*0Sstevel@tonic-gate  */
72*0Sstevel@tonic-gate #define	ATAPI_SIG_HI	0xeb		/* in high cylinder register	*/
73*0Sstevel@tonic-gate #define	ATAPI_SIG_LO	0x14		/* in low cylinder register	*/
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate #define	ATAPIDRV(X)  ((X)->ad_flags & AD_ATAPI)
76*0Sstevel@tonic-gate #define	ATAPIPKT(X)  ((X)->ap_flags & AP_ATAPI)
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate #define	ATAPI_SECTOR_SIZE	2048
79*0Sstevel@tonic-gate #define	ATAPI_MAX_BYTES_PER_DRQ	0xf800 /* 16 bits - 2KB  ie 62KB */
80*0Sstevel@tonic-gate #define	ATAPI_HEADS		64
81*0Sstevel@tonic-gate #define	ATAPI_SECTORS_PER_TRK   32
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate /*
84*0Sstevel@tonic-gate  * Useful macros
85*0Sstevel@tonic-gate  */
86*0Sstevel@tonic-gate #define	TRAN2CTL(tran)	((struct ata_controller *)((tran)->tran_hba_private))
87*0Sstevel@tonic-gate #define	ADDR2CTL(ap)	(TRAN2CTL(ADDR2TRAN(ap)))
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate #define	SPKT2APKT(spkt)	(GCMD2APKT(PKTP2GCMDP(spkt)))
90*0Sstevel@tonic-gate #define	APKT2SPKT(apkt)	(GCMDP2PKTP(APKT2GCMD(apkt)))
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate #define	SADR2CHNO(ap)	(((ap)->a_target > 1) ? 1 : 0)
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate /*
96*0Sstevel@tonic-gate  * public function prototypes
97*0Sstevel@tonic-gate  */
98*0Sstevel@tonic-gate int atapi_init(struct ata_controller *ata_ctlp);
99*0Sstevel@tonic-gate void atapi_destroy(struct ata_controller *ata_ctlp);
100*0Sstevel@tonic-gate int atapi_init_drive(struct ata_drive *ata_drvp);
101*0Sstevel@tonic-gate void atapi_destroy_drive(struct ata_drive *ata_drvp);
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate int atapi_id(ddi_acc_handle_t handle, uint8_t *ioaddr, ushort_t *buf);
104*0Sstevel@tonic-gate int atapi_signature(ddi_acc_handle_t handle, uint8_t *ioaddr);
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate int atapi_reset_drive(struct ata_drive *ata_drvp);
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate int atapi_ccballoc(gtgt_t  *gtgtp, gcmd_t *gcmdp, int cmdlen,
109*0Sstevel@tonic-gate 		int statuslen, int tgtlen, int ccblen);
110*0Sstevel@tonic-gate void atapi_ccbfree(gcmd_t *gcmdp);
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate #ifdef DSC_OVERLAP_SUPPORT
113*0Sstevel@tonic-gate void atapi_dsc_poll(struct ata_drive *ata_drvp);
114*0Sstevel@tonic-gate #endif
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate #ifdef	__cplusplus
117*0Sstevel@tonic-gate }
118*0Sstevel@tonic-gate #endif
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate #endif /* _ATAPI_H */
121