ide_atareg.h revision 1722
1/* $OpenBSD: atareg.h,v 1.12 2004/09/24 07:15:22 grange Exp $ */ 2/* $NetBSD: atareg.h,v 1.5 1999/01/18 20:06:24 bouyer Exp $ */ 3 4/* 5 * Copyright (c) 1998, 2001 Manuel Bouyer. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Manuel Bouyer. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#ifndef _DEV_ATA_ATAREG_H_ 34#define _DEV_ATA_ATAREG_H_ 35 36#define ATA_BYTE_ORDER LITTLE_ENDIAN 37/* 38 * Drive parameter structure for ATA/ATAPI. 39 * Bit fields: WDC_* : common to ATA/ATAPI 40 * ATA_* : ATA only 41 * ATAPI_* : ATAPI only. 42 */ 43struct ataparams { 44 /* drive info */ 45 uint16_t atap_config; /* 0: general configuration */ 46#define WDC_CFG_ATAPI_MASK 0xc000 47#define WDC_CFG_ATAPI 0x8000 48#define ATA_CFG_REMOVABLE 0x0080 49#define ATA_CFG_FIXED 0x0040 50#define ATAPI_CFG_TYPE_MASK 0x1f00 51#define ATAPI_CFG_TYPE(x) (((x) & ATAPI_CFG_TYPE_MASK) >> 8) 52#define ATAPI_CFG_TYPE_DIRECT 0x00 53#define ATAPI_CFG_TYPE_SEQUENTIAL 0x01 54#define ATAPI_CFG_TYPE_CDROM 0x05 55#define ATAPI_CFG_TYPE_OPTICAL 0x07 56#define ATAPI_CFG_TYPE_NODEVICE 0x1F 57#define ATAPI_CFG_REMOV 0x0080 58#define ATAPI_CFG_DRQ_MASK 0x0060 59#define ATAPI_CFG_STD_DRQ 0x0000 60#define ATAPI_CFG_IRQ_DRQ 0x0020 61#define ATAPI_CFG_ACCEL_DRQ 0x0040 62#define ATAPI_CFG_CMD_MASK 0x0003 63#define ATAPI_CFG_CMD_12 0x0000 64#define ATAPI_CFG_CMD_16 0x0001 65/* words 1-9 are ATA only */ 66 uint16_t atap_cylinders; /* 1: # of non-removable cylinders */ 67 uint16_t __reserved1; 68 uint16_t atap_heads; /* 3: # of heads */ 69 uint16_t __retired1[2]; /* 4-5: # of unform. bytes/track */ 70 uint16_t atap_sectors; /* 6: # of sectors */ 71 uint16_t __retired2[3]; 72 73 uint8_t atap_serial[20]; /* 10-19: serial number */ 74 uint16_t __retired3[2]; 75 uint16_t __obsolete1; 76 uint8_t atap_revision[8]; /* 23-26: firmware revision */ 77 uint8_t atap_model[40]; /* 27-46: model number */ 78 uint16_t atap_multi; /* 47: maximum sectors per irq (ATA) */ 79 uint16_t __reserved2; 80 uint8_t atap_vendor; /* 49: vendor */ 81 uint8_t atap_capabilities1; /* 49: capability flags */ 82#define WDC_CAP_IORDY 0x0800 83#define WDC_CAP_IORDY_DSBL 0x0400 84#define WDC_CAP_LBA 0x0200 85#define WDC_CAP_DMA 0x0100 86#define ATA_CAP_STBY 0x2000 87#define ATAPI_CAP_INTERL_DMA 0x8000 88#define ATAPI_CAP_CMD_QUEUE 0x4000 89#define ATAPI_CAP_OVERLP 0x2000 90#define ATAPI_CAP_ATA_RST 0x1000 91 uint16_t atap_capabilities2; /* 50: capability flags (ATA) */ 92#if ATA_BYTE_ORDER == LITTLE_ENDIAN 93 uint8_t __junk2; 94 uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */ 95 uint8_t __junk3; 96 uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */ 97#else 98 uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */ 99 uint8_t __junk2; 100 uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */ 101 uint8_t __junk3; 102#endif 103 uint16_t atap_extensions; /* 53: extensions supported */ 104#define WDC_EXT_UDMA_MODES 0x0004 105#define WDC_EXT_MODES 0x0002 106#define WDC_EXT_GEOM 0x0001 107/* words 54-62 are ATA only */ 108 uint16_t atap_curcylinders; /* 54: current logical cylinders */ 109 uint16_t atap_curheads; /* 55: current logical heads */ 110 uint16_t atap_cursectors; /* 56: current logical sectors/tracks */ 111 uint16_t atap_curcapacity[2]; /* 57-58: current capacity */ 112 uint8_t atap_curmulti; /* 59: current multi-sector setting */ 113 uint8_t atap_curmulti_valid; /* 59: current multi-sector setting */ 114#define WDC_MULTI_VALID 0x0100 115#define WDC_MULTI_MASK 0x00ff 116 uint32_t atap_capacity; /* 60-61: total capacity (LBA only) */ 117 uint16_t __retired4; 118#if ATA_BYTE_ORDER == LITTLE_ENDIAN 119 uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */ 120 uint8_t atap_dmamode_act; /* multiword DMA mode active */ 121 uint8_t atap_piomode_supp; /* 64: PIO mode supported */ 122 uint8_t __junk4; 123#else 124 uint8_t atap_dmamode_act; /* multiword DMA mode active */ 125 uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */ 126 uint8_t __junk4; 127 uint8_t atap_piomode_supp; /* 64: PIO mode supported */ 128#endif 129 uint16_t atap_dmatiming_mimi; /* 65: minimum DMA cycle time */ 130 uint16_t atap_dmatiming_recom; /* 66: recommended DMA cycle time */ 131 uint16_t atap_piotiming; /* 67: mini PIO cycle time without FC */ 132 uint16_t atap_piotiming_iordy; /* 68: mini PIO cycle time with IORDY FC */ 133 uint16_t __reserved3[2]; 134/* words 71-72 are ATAPI only */ 135 uint16_t atap_pkt_br; /* 71: time (ns) to bus release */ 136 uint16_t atap_pkt_bsyclr; /* 72: tme to clear BSY after service */ 137 uint16_t __reserved4[2]; 138 uint16_t atap_queuedepth; /* 75: */ 139#define WDC_QUEUE_DEPTH_MASK 0x1f 140 uint16_t atap_sata_caps; /* 76: SATA capabilities */ 141#define SATA_SIGNAL_GEN1 0x0002 /* SATA Gen-1 signaling speed */ 142#define SATA_SIGNAL_GEN2 0x0004 /* SATA Gen-2 signaling speed */ 143#define SATA_NATIVE_CMDQ 0x0100 /* native command queuing */ 144#define SATA_HOST_PWR_MGMT 0x0200 /* power management (host) */ 145 uint16_t atap_sata_reserved; /* 77: reserved */ 146 uint16_t atap_sata_features_supp;/* 78: SATA features supported */ 147#define SATA_NONZERO_OFFSETS 0x0002 /* non-zero buffer offsets */ 148#define SATA_DMA_SETUP_AUTO 0x0004 /* DMA setup auto-activate */ 149#define SATA_DRIVE_PWR_MGMT 0x0008 /* power management (device) */ 150 uint16_t atap_sata_features_en; /* 79: SATA features enabled */ 151 uint16_t atap_ata_major; /* 80: Major version number */ 152#define WDC_VER_ATA1 0x0002 153#define WDC_VER_ATA2 0x0004 154#define WDC_VER_ATA3 0x0008 155#define WDC_VER_ATA4 0x0010 156#define WDC_VER_ATA5 0x0020 157#define WDC_VER_ATA6 0x0040 158#define WDC_VER_ATA7 0x0080 159#define WDC_VER_ATA8 0x0100 160#define WDC_VER_ATA9 0x0200 161#define WDC_VER_ATA10 0x0400 162#define WDC_VER_ATA11 0x0800 163#define WDC_VER_ATA12 0x1000 164#define WDC_VER_ATA13 0x2000 165#define WDC_VER_ATA14 0x4000 166 uint16_t atap_ata_minor; /* 81: Minor version number */ 167 uint16_t atap_cmd_set1; /* 82: command set supported */ 168#define WDC_CMD1_NOP 0x4000 169#define WDC_CMD1_RB 0x2000 170#define WDC_CMD1_WB 0x1000 171#define WDC_CMD1_HPA 0x0400 172#define WDC_CMD1_DVRST 0x0200 173#define WDC_CMD1_SRV 0x0100 174#define WDC_CMD1_RLSE 0x0080 175#define WDC_CMD1_AHEAD 0x0040 176#define WDC_CMD1_CACHE 0x0020 177#define WDC_CMD1_PKT 0x0010 178#define WDC_CMD1_PM 0x0008 179#define WDC_CMD1_REMOV 0x0004 180#define WDC_CMD1_SEC 0x0002 181#define WDC_CMD1_SMART 0x0001 182 uint16_t atap_cmd_set2; /* 83: command set supported */ 183#define ATAPI_CMD2_FCE 0x2000 /* Flush Cache Ext supported */ 184#define ATAPI_CMD2_FC 0x1000 /* Flush Cache supported */ 185#define ATAPI_CMD2_DCO 0x0800 /* Device Configuration Overlay supported */ 186#define ATAPI_CMD2_48AD 0x0400 /* 48bit address supported */ 187#define ATAPI_CMD2_AAM 0x0200 /* Automatic Acoustic Management supported */ 188#define ATAPI_CMD2_SM 0x0100 /* Set Max security extension supported */ 189#define ATAPI_CMD2_SF 0x0040 /* Set Features subcommand required */ 190#define ATAPI_CMD2_PUIS 0x0020 /* Power up in standby supported */ 191#define WDC_CMD2_RMSN 0x0010 192#define ATA_CMD2_APM 0x0008 193#define ATA_CMD2_CFA 0x0004 194#define ATA_CMD2_RWQ 0x0002 195#define WDC_CMD2_DM 0x0001 /* Download Microcode supported */ 196 uint16_t atap_cmd_ext; /* 84: command/features supp. ext. */ 197#define ATAPI_CMDE_MSER 0x0004 /* Media serial number supported */ 198#define ATAPI_CMDE_TEST 0x0002 /* SMART self-test supported */ 199#define ATAPI_CMDE_SLOG 0x0001 /* SMART error logging supported */ 200 uint16_t atap_cmd1_en; /* 85: cmd/features enabled */ 201/* bits are the same as atap_cmd_set1 */ 202 uint16_t atap_cmd2_en; /* 86: cmd/features enabled */ 203/* bits are the same as atap_cmd_set2 */ 204 uint16_t atap_cmd_def; /* 87: cmd/features default */ 205/* bits are NOT the same as atap_cmd_ext */ 206#if ATA_BYTE_ORDER == LITTLE_ENDIAN 207 uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */ 208 uint8_t atap_udmamode_act; /* Ultra-DMA mode active */ 209#else 210 uint8_t atap_udmamode_act; /* Ultra-DMA mode active */ 211 uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */ 212#endif 213/* 89-92 are ATA-only */ 214 uint16_t atap_seu_time; /* 89: Sec. Erase Unit compl. time */ 215 uint16_t atap_eseu_time; /* 90: Enhanced SEU compl. time */ 216 uint16_t atap_apm_val; /* 91: current APM value */ 217 uint16_t atap_mpasswd_rev; /* 92: Master Password revision */ 218 uint16_t atap_hwreset_res; /* 93: Hardware reset value */ 219#define ATA_HWRES_CBLID 0x2000 /* CBLID above Vih */ 220#define ATA_HWRES_D1_PDIAG 0x0800 /* Device 1 PDIAG detect OK */ 221#define ATA_HWRES_D1_CSEL 0x0400 /* Device 1 used CSEL for address */ 222#define ATA_HWRES_D1_JUMP 0x0200 /* Device 1 jumpered to address */ 223#define ATA_HWRES_D0_SEL 0x0040 /* Device 0 responds when Dev 1 selected */ 224#define ATA_HWRES_D0_DASP 0x0020 /* Device 0 DASP detect OK */ 225#define ATA_HWRES_D0_PDIAG 0x0010 /* Device 0 PDIAG detect OK */ 226#define ATA_HWRES_D0_DIAG 0x0008 /* Device 0 diag OK */ 227#define ATA_HWRES_D0_CSEL 0x0004 /* Device 0 used CSEL for address */ 228#define ATA_HWRES_D0_JUMP 0x0002 /* Device 0 jumpered to address */ 229#if ATA_BYTE_ORDER == LITTLE_ENDIAN 230 uint8_t atap_acoustic_val; /* 94: Current acoustic level */ 231 uint8_t atap_acoustic_def; /* recommended level */ 232#else 233 uint8_t atap_acoustic_def; /* recommended level */ 234 uint8_t atap_acoustic_val; /* 94: Current acoustic level */ 235#endif 236 uint16_t __reserved6[5]; /* 95-99: reserved */ 237 uint16_t atap_max_lba[4]; /* 100-103: Max. user LBA add */ 238 uint16_t __reserved7[23]; /* 104-126: reserved */ 239 uint16_t atap_rmsn_supp; /* 127: remov. media status notif. */ 240#define WDC_RMSN_SUPP_MASK 0x0003 241#define WDC_RMSN_SUPP 0x0001 242 uint16_t atap_sec_st; /* 128: security status */ 243#define WDC_SEC_LEV_MAX 0x0100 244#define WDC_SEC_ESE_SUPP 0x0020 245#define WDC_SEC_EXP 0x0010 246#define WDC_SEC_FROZEN 0x0008 247#define WDC_SEC_LOCKED 0x0004 248#define WDC_SEC_EN 0x0002 249#define WDC_SEC_SUPP 0x0001 250 uint16_t __reserved8[31]; /* 129-159: vendor specific */ 251 uint16_t atap_cfa_power; /* 160: CFA powermode */ 252#define ATAPI_CFA_MAX_MASK 0x0FFF 253#define ATAPI_CFA_MODE1_DIS 0x1000 /* CFA Mode 1 Disabled */ 254#define ATAPI_CFA_MODE1_REQ 0x2000 /* CFA Mode 1 Required */ 255#define ATAPI_CFA_WORD160 0x8000 /* Word 160 supported */ 256 uint16_t __reserved9[15]; /* 161-175: reserved for CFA */ 257 uint8_t atap_media_serial[60]; /* 176-205: media serial number */ 258 uint16_t __reserved10[49]; /* 206-254: reserved */ 259#if ATA_BYTE_ORDER == LITTLE_ENDIAN 260 uint8_t atap_signature; /* 255: Signature */ 261 uint8_t atap_checksum; /* Checksum */ 262#else 263 uint8_t atap_checksum; /* Checksum */ 264 uint8_t atap_signature; /* 255: Signature */ 265#endif 266}; 267 268#undef ATA_BYTE_ORDER 269#endif /* !_DEV_ATA_ATAREG_H_ */ 270