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