11722SN/A/* $OpenBSD: atareg.h,v 1.12 2004/09/24 07:15:22 grange Exp $ */ 21722SN/A/* $NetBSD: atareg.h,v 1.5 1999/01/18 20:06:24 bouyer Exp $ */ 31722SN/A 41722SN/A/* 51722SN/A * Copyright (c) 1998, 2001 Manuel Bouyer. 61722SN/A * 71722SN/A * Redistribution and use in source and binary forms, with or without 81722SN/A * modification, are permitted provided that the following conditions 91722SN/A * are met: 101722SN/A * 1. Redistributions of source code must retain the above copyright 111722SN/A * notice, this list of conditions and the following disclaimer. 121722SN/A * 2. Redistributions in binary form must reproduce the above copyright 131722SN/A * notice, this list of conditions and the following disclaimer in the 141722SN/A * documentation and/or other materials provided with the distribution. 151722SN/A * 3. All advertising materials mentioning features or use of this software 161722SN/A * must display the following acknowledgement: 171722SN/A * This product includes software developed by Manuel Bouyer. 181722SN/A * 4. The name of the author may not be used to endorse or promote products 191722SN/A * derived from this software without specific prior written permission. 201722SN/A * 211722SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221722SN/A * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231722SN/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241722SN/A * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251722SN/A * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261722SN/A * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271722SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281722SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291722SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301722SN/A * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311722SN/A */ 321722SN/A 331722SN/A#ifndef _DEV_ATA_ATAREG_H_ 341722SN/A#define _DEV_ATA_ATAREG_H_ 351722SN/A 368902SN/A#if defined(__linux__) 371809SN/A#include <endian.h> 3811264Sandreas.sandberg@arm.com 393918SN/A#elif defined(__sun) 403603SN/A#include <sys/isa_defs.h> 4111264Sandreas.sandberg@arm.com 421809SN/A#else 431809SN/A#include <machine/endian.h> 4411264Sandreas.sandberg@arm.com 451809SN/A#endif 461809SN/A 473603SN/A#ifdef LITTLE_ENDIAN 481722SN/A#define ATA_BYTE_ORDER LITTLE_ENDIAN 493603SN/A#elif defined(BIG_ENDIAN) 503603SN/A#define ATA_BYTE_ORDER BIG_ENDIAN 513603SN/A#elif defined(_LITTLE_ENDIAN) 523603SN/A#define ATA_BYTE_ORDER 1 533603SN/A#define LITTLE_ENDIAN 1 543603SN/A#elif defined(_BIG_ENDIAN) 553603SN/A#define ATA_BYTE_ORDER 0 563603SN/A#define LITTLE_ENDIAN 1 573603SN/A#else 583603SN/A#error "No endianess defined" 593603SN/A#endif 601809SN/A 611722SN/A/* 621722SN/A * Drive parameter structure for ATA/ATAPI. 631722SN/A * Bit fields: WDC_* : common to ATA/ATAPI 641722SN/A * ATA_* : ATA only 651722SN/A * ATAPI_* : ATAPI only. 661722SN/A */ 671722SN/Astruct ataparams { 681722SN/A /* drive info */ 691722SN/A uint16_t atap_config; /* 0: general configuration */ 701722SN/A#define WDC_CFG_ATAPI_MASK 0xc000 711722SN/A#define WDC_CFG_ATAPI 0x8000 721722SN/A#define ATA_CFG_REMOVABLE 0x0080 731722SN/A#define ATA_CFG_FIXED 0x0040 741722SN/A#define ATAPI_CFG_TYPE_MASK 0x1f00 751722SN/A#define ATAPI_CFG_TYPE(x) (((x) & ATAPI_CFG_TYPE_MASK) >> 8) 761722SN/A#define ATAPI_CFG_TYPE_DIRECT 0x00 771722SN/A#define ATAPI_CFG_TYPE_SEQUENTIAL 0x01 781722SN/A#define ATAPI_CFG_TYPE_CDROM 0x05 791722SN/A#define ATAPI_CFG_TYPE_OPTICAL 0x07 801722SN/A#define ATAPI_CFG_TYPE_NODEVICE 0x1F 811722SN/A#define ATAPI_CFG_REMOV 0x0080 821722SN/A#define ATAPI_CFG_DRQ_MASK 0x0060 831722SN/A#define ATAPI_CFG_STD_DRQ 0x0000 841722SN/A#define ATAPI_CFG_IRQ_DRQ 0x0020 851722SN/A#define ATAPI_CFG_ACCEL_DRQ 0x0040 861722SN/A#define ATAPI_CFG_CMD_MASK 0x0003 871722SN/A#define ATAPI_CFG_CMD_12 0x0000 881722SN/A#define ATAPI_CFG_CMD_16 0x0001 891722SN/A/* words 1-9 are ATA only */ 901722SN/A uint16_t atap_cylinders; /* 1: # of non-removable cylinders */ 911722SN/A uint16_t __reserved1; 921722SN/A uint16_t atap_heads; /* 3: # of heads */ 931722SN/A uint16_t __retired1[2]; /* 4-5: # of unform. bytes/track */ 941722SN/A uint16_t atap_sectors; /* 6: # of sectors */ 951722SN/A uint16_t __retired2[3]; 961722SN/A 971722SN/A uint8_t atap_serial[20]; /* 10-19: serial number */ 981722SN/A uint16_t __retired3[2]; 991722SN/A uint16_t __obsolete1; 1001722SN/A uint8_t atap_revision[8]; /* 23-26: firmware revision */ 1011722SN/A uint8_t atap_model[40]; /* 27-46: model number */ 1021722SN/A uint16_t atap_multi; /* 47: maximum sectors per irq (ATA) */ 1031722SN/A uint16_t __reserved2; 1041722SN/A uint8_t atap_vendor; /* 49: vendor */ 1051722SN/A uint8_t atap_capabilities1; /* 49: capability flags */ 1061722SN/A#define WDC_CAP_IORDY 0x0800 1071722SN/A#define WDC_CAP_IORDY_DSBL 0x0400 1081722SN/A#define WDC_CAP_LBA 0x0200 1091722SN/A#define WDC_CAP_DMA 0x0100 1101722SN/A#define ATA_CAP_STBY 0x2000 1111722SN/A#define ATAPI_CAP_INTERL_DMA 0x8000 1121722SN/A#define ATAPI_CAP_CMD_QUEUE 0x4000 1131722SN/A#define ATAPI_CAP_OVERLP 0x2000 1141722SN/A#define ATAPI_CAP_ATA_RST 0x1000 1151722SN/A uint16_t atap_capabilities2; /* 50: capability flags (ATA) */ 1161722SN/A#if ATA_BYTE_ORDER == LITTLE_ENDIAN 1171722SN/A uint8_t __junk2; 1181722SN/A uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */ 1191722SN/A uint8_t __junk3; 1201722SN/A uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */ 1211722SN/A#else 1221722SN/A uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */ 1231722SN/A uint8_t __junk2; 1241722SN/A uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */ 1251722SN/A uint8_t __junk3; 1261722SN/A#endif 1271722SN/A uint16_t atap_extensions; /* 53: extensions supported */ 1281722SN/A#define WDC_EXT_UDMA_MODES 0x0004 1291722SN/A#define WDC_EXT_MODES 0x0002 1301722SN/A#define WDC_EXT_GEOM 0x0001 1311722SN/A/* words 54-62 are ATA only */ 1321722SN/A uint16_t atap_curcylinders; /* 54: current logical cylinders */ 1331722SN/A uint16_t atap_curheads; /* 55: current logical heads */ 1341722SN/A uint16_t atap_cursectors; /* 56: current logical sectors/tracks */ 1351722SN/A uint16_t atap_curcapacity[2]; /* 57-58: current capacity */ 1361722SN/A uint8_t atap_curmulti; /* 59: current multi-sector setting */ 1371722SN/A uint8_t atap_curmulti_valid; /* 59: current multi-sector setting */ 1381722SN/A#define WDC_MULTI_VALID 0x0100 1391722SN/A#define WDC_MULTI_MASK 0x00ff 1401722SN/A uint32_t atap_capacity; /* 60-61: total capacity (LBA only) */ 1411722SN/A uint16_t __retired4; 1421722SN/A#if ATA_BYTE_ORDER == LITTLE_ENDIAN 1431722SN/A uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */ 1441722SN/A uint8_t atap_dmamode_act; /* multiword DMA mode active */ 1451722SN/A uint8_t atap_piomode_supp; /* 64: PIO mode supported */ 1461722SN/A uint8_t __junk4; 1471722SN/A#else 1481722SN/A uint8_t atap_dmamode_act; /* multiword DMA mode active */ 1491722SN/A uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */ 1501722SN/A uint8_t __junk4; 1511722SN/A uint8_t atap_piomode_supp; /* 64: PIO mode supported */ 1521722SN/A#endif 1531722SN/A uint16_t atap_dmatiming_mimi; /* 65: minimum DMA cycle time */ 1541722SN/A uint16_t atap_dmatiming_recom; /* 66: recommended DMA cycle time */ 1551722SN/A uint16_t atap_piotiming; /* 67: mini PIO cycle time without FC */ 1561722SN/A uint16_t atap_piotiming_iordy; /* 68: mini PIO cycle time with IORDY FC */ 1571722SN/A uint16_t __reserved3[2]; 1581722SN/A/* words 71-72 are ATAPI only */ 1591722SN/A uint16_t atap_pkt_br; /* 71: time (ns) to bus release */ 1601722SN/A uint16_t atap_pkt_bsyclr; /* 72: tme to clear BSY after service */ 1611722SN/A uint16_t __reserved4[2]; 1621722SN/A uint16_t atap_queuedepth; /* 75: */ 1631722SN/A#define WDC_QUEUE_DEPTH_MASK 0x1f 1641722SN/A uint16_t atap_sata_caps; /* 76: SATA capabilities */ 1651722SN/A#define SATA_SIGNAL_GEN1 0x0002 /* SATA Gen-1 signaling speed */ 1661722SN/A#define SATA_SIGNAL_GEN2 0x0004 /* SATA Gen-2 signaling speed */ 1671722SN/A#define SATA_NATIVE_CMDQ 0x0100 /* native command queuing */ 1681722SN/A#define SATA_HOST_PWR_MGMT 0x0200 /* power management (host) */ 1691722SN/A uint16_t atap_sata_reserved; /* 77: reserved */ 1701722SN/A uint16_t atap_sata_features_supp;/* 78: SATA features supported */ 1711722SN/A#define SATA_NONZERO_OFFSETS 0x0002 /* non-zero buffer offsets */ 1721722SN/A#define SATA_DMA_SETUP_AUTO 0x0004 /* DMA setup auto-activate */ 1731722SN/A#define SATA_DRIVE_PWR_MGMT 0x0008 /* power management (device) */ 1741722SN/A uint16_t atap_sata_features_en; /* 79: SATA features enabled */ 1751722SN/A uint16_t atap_ata_major; /* 80: Major version number */ 1761722SN/A#define WDC_VER_ATA1 0x0002 1771722SN/A#define WDC_VER_ATA2 0x0004 1781722SN/A#define WDC_VER_ATA3 0x0008 1791722SN/A#define WDC_VER_ATA4 0x0010 1801722SN/A#define WDC_VER_ATA5 0x0020 1811722SN/A#define WDC_VER_ATA6 0x0040 1821722SN/A#define WDC_VER_ATA7 0x0080 1831722SN/A#define WDC_VER_ATA8 0x0100 1841722SN/A#define WDC_VER_ATA9 0x0200 1851722SN/A#define WDC_VER_ATA10 0x0400 1861722SN/A#define WDC_VER_ATA11 0x0800 1871722SN/A#define WDC_VER_ATA12 0x1000 1881722SN/A#define WDC_VER_ATA13 0x2000 1891722SN/A#define WDC_VER_ATA14 0x4000 1901722SN/A uint16_t atap_ata_minor; /* 81: Minor version number */ 1911722SN/A uint16_t atap_cmd_set1; /* 82: command set supported */ 1921722SN/A#define WDC_CMD1_NOP 0x4000 1931722SN/A#define WDC_CMD1_RB 0x2000 1941722SN/A#define WDC_CMD1_WB 0x1000 1951722SN/A#define WDC_CMD1_HPA 0x0400 1961722SN/A#define WDC_CMD1_DVRST 0x0200 1971722SN/A#define WDC_CMD1_SRV 0x0100 1981722SN/A#define WDC_CMD1_RLSE 0x0080 1991722SN/A#define WDC_CMD1_AHEAD 0x0040 2001722SN/A#define WDC_CMD1_CACHE 0x0020 2011722SN/A#define WDC_CMD1_PKT 0x0010 2021722SN/A#define WDC_CMD1_PM 0x0008 2031722SN/A#define WDC_CMD1_REMOV 0x0004 2041722SN/A#define WDC_CMD1_SEC 0x0002 2051722SN/A#define WDC_CMD1_SMART 0x0001 2061722SN/A uint16_t atap_cmd_set2; /* 83: command set supported */ 2071722SN/A#define ATAPI_CMD2_FCE 0x2000 /* Flush Cache Ext supported */ 2081722SN/A#define ATAPI_CMD2_FC 0x1000 /* Flush Cache supported */ 2091722SN/A#define ATAPI_CMD2_DCO 0x0800 /* Device Configuration Overlay supported */ 2101722SN/A#define ATAPI_CMD2_48AD 0x0400 /* 48bit address supported */ 2111722SN/A#define ATAPI_CMD2_AAM 0x0200 /* Automatic Acoustic Management supported */ 2121722SN/A#define ATAPI_CMD2_SM 0x0100 /* Set Max security extension supported */ 2131722SN/A#define ATAPI_CMD2_SF 0x0040 /* Set Features subcommand required */ 2141722SN/A#define ATAPI_CMD2_PUIS 0x0020 /* Power up in standby supported */ 2151722SN/A#define WDC_CMD2_RMSN 0x0010 2161722SN/A#define ATA_CMD2_APM 0x0008 2171722SN/A#define ATA_CMD2_CFA 0x0004 2181722SN/A#define ATA_CMD2_RWQ 0x0002 2191722SN/A#define WDC_CMD2_DM 0x0001 /* Download Microcode supported */ 2201722SN/A uint16_t atap_cmd_ext; /* 84: command/features supp. ext. */ 2211722SN/A#define ATAPI_CMDE_MSER 0x0004 /* Media serial number supported */ 2221722SN/A#define ATAPI_CMDE_TEST 0x0002 /* SMART self-test supported */ 2231722SN/A#define ATAPI_CMDE_SLOG 0x0001 /* SMART error logging supported */ 2241722SN/A uint16_t atap_cmd1_en; /* 85: cmd/features enabled */ 2251722SN/A/* bits are the same as atap_cmd_set1 */ 2261722SN/A uint16_t atap_cmd2_en; /* 86: cmd/features enabled */ 2271722SN/A/* bits are the same as atap_cmd_set2 */ 2281722SN/A uint16_t atap_cmd_def; /* 87: cmd/features default */ 2291722SN/A/* bits are NOT the same as atap_cmd_ext */ 2301722SN/A#if ATA_BYTE_ORDER == LITTLE_ENDIAN 2311722SN/A uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */ 2321722SN/A uint8_t atap_udmamode_act; /* Ultra-DMA mode active */ 2331722SN/A#else 2341722SN/A uint8_t atap_udmamode_act; /* Ultra-DMA mode active */ 2351722SN/A uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */ 2361722SN/A#endif 2371722SN/A/* 89-92 are ATA-only */ 2381722SN/A uint16_t atap_seu_time; /* 89: Sec. Erase Unit compl. time */ 2391722SN/A uint16_t atap_eseu_time; /* 90: Enhanced SEU compl. time */ 2401722SN/A uint16_t atap_apm_val; /* 91: current APM value */ 2411722SN/A uint16_t atap_mpasswd_rev; /* 92: Master Password revision */ 2421722SN/A uint16_t atap_hwreset_res; /* 93: Hardware reset value */ 2431722SN/A#define ATA_HWRES_CBLID 0x2000 /* CBLID above Vih */ 2441722SN/A#define ATA_HWRES_D1_PDIAG 0x0800 /* Device 1 PDIAG detect OK */ 2451722SN/A#define ATA_HWRES_D1_CSEL 0x0400 /* Device 1 used CSEL for address */ 2461722SN/A#define ATA_HWRES_D1_JUMP 0x0200 /* Device 1 jumpered to address */ 2471722SN/A#define ATA_HWRES_D0_SEL 0x0040 /* Device 0 responds when Dev 1 selected */ 2481722SN/A#define ATA_HWRES_D0_DASP 0x0020 /* Device 0 DASP detect OK */ 2491722SN/A#define ATA_HWRES_D0_PDIAG 0x0010 /* Device 0 PDIAG detect OK */ 2501722SN/A#define ATA_HWRES_D0_DIAG 0x0008 /* Device 0 diag OK */ 2511722SN/A#define ATA_HWRES_D0_CSEL 0x0004 /* Device 0 used CSEL for address */ 2521722SN/A#define ATA_HWRES_D0_JUMP 0x0002 /* Device 0 jumpered to address */ 2531722SN/A#if ATA_BYTE_ORDER == LITTLE_ENDIAN 2541722SN/A uint8_t atap_acoustic_val; /* 94: Current acoustic level */ 2551722SN/A uint8_t atap_acoustic_def; /* recommended level */ 2561722SN/A#else 2571722SN/A uint8_t atap_acoustic_def; /* recommended level */ 2581722SN/A uint8_t atap_acoustic_val; /* 94: Current acoustic level */ 2591722SN/A#endif 2601722SN/A uint16_t __reserved6[5]; /* 95-99: reserved */ 2611722SN/A uint16_t atap_max_lba[4]; /* 100-103: Max. user LBA add */ 2621722SN/A uint16_t __reserved7[23]; /* 104-126: reserved */ 2631722SN/A uint16_t atap_rmsn_supp; /* 127: remov. media status notif. */ 2641722SN/A#define WDC_RMSN_SUPP_MASK 0x0003 2651722SN/A#define WDC_RMSN_SUPP 0x0001 2661722SN/A uint16_t atap_sec_st; /* 128: security status */ 2671722SN/A#define WDC_SEC_LEV_MAX 0x0100 2681722SN/A#define WDC_SEC_ESE_SUPP 0x0020 2691722SN/A#define WDC_SEC_EXP 0x0010 2701722SN/A#define WDC_SEC_FROZEN 0x0008 2711722SN/A#define WDC_SEC_LOCKED 0x0004 2721722SN/A#define WDC_SEC_EN 0x0002 2731722SN/A#define WDC_SEC_SUPP 0x0001 2741722SN/A uint16_t __reserved8[31]; /* 129-159: vendor specific */ 2751722SN/A uint16_t atap_cfa_power; /* 160: CFA powermode */ 2761722SN/A#define ATAPI_CFA_MAX_MASK 0x0FFF 2771722SN/A#define ATAPI_CFA_MODE1_DIS 0x1000 /* CFA Mode 1 Disabled */ 2781722SN/A#define ATAPI_CFA_MODE1_REQ 0x2000 /* CFA Mode 1 Required */ 2791722SN/A#define ATAPI_CFA_WORD160 0x8000 /* Word 160 supported */ 2801722SN/A uint16_t __reserved9[15]; /* 161-175: reserved for CFA */ 2811722SN/A uint8_t atap_media_serial[60]; /* 176-205: media serial number */ 2821722SN/A uint16_t __reserved10[49]; /* 206-254: reserved */ 2831722SN/A#if ATA_BYTE_ORDER == LITTLE_ENDIAN 2841722SN/A uint8_t atap_signature; /* 255: Signature */ 2851722SN/A uint8_t atap_checksum; /* Checksum */ 2861722SN/A#else 2871722SN/A uint8_t atap_checksum; /* Checksum */ 2881722SN/A uint8_t atap_signature; /* 255: Signature */ 2891722SN/A#endif 2901722SN/A}; 2911722SN/A 2921722SN/A#undef ATA_BYTE_ORDER 2931722SN/A#endif /* !_DEV_ATA_ATAREG_H_ */ 294