Home | History | Annotate | Line # | Download | only in ic
wdcreg.h revision 1.24
      1  1.24  christos /*	$NetBSD: wdcreg.h,v 1.24 2002/01/13 17:24:29 christos Exp $	*/
      2   1.7       cgd 
      3   1.1       cgd /*-
      4   1.1       cgd  * Copyright (c) 1991 The Regents of the University of California.
      5   1.1       cgd  * All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * This code is derived from software contributed to Berkeley by
      8   1.1       cgd  * William Jolitz.
      9   1.1       cgd  *
     10   1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11   1.1       cgd  * modification, are permitted provided that the following conditions
     12   1.1       cgd  * are met:
     13   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     19   1.1       cgd  *    must display the following acknowledgement:
     20   1.1       cgd  *	This product includes software developed by the University of
     21   1.1       cgd  *	California, Berkeley and its contributors.
     22   1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     23   1.1       cgd  *    may be used to endorse or promote products derived from this software
     24   1.1       cgd  *    without specific prior written permission.
     25   1.1       cgd  *
     26   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36   1.1       cgd  * SUCH DAMAGE.
     37   1.1       cgd  *
     38   1.7       cgd  *	@(#)wdreg.h	7.1 (Berkeley) 5/9/91
     39   1.1       cgd  */
     40   1.1       cgd 
     41   1.1       cgd /*
     42   1.1       cgd  * Disk Controller register definitions.
     43   1.1       cgd  */
     44   1.9   mycroft 
     45  1.15       cgd /* offsets of registers in the 'regular' register region */
     46  1.24  christos #define	wd_data			0	/* data register (R/W - 16 bits) */
     47  1.24  christos #define	wd_error		1	/* error register (R) */
     48  1.24  christos #define	wd_precomp		1	/* write precompensation (W) */
     49  1.24  christos #define	wd_features		1	/* features (W), same as wd_precomp */
     50  1.24  christos #define	wd_seccnt		2	/* sector count (R/W) */
     51  1.24  christos #define	wd_ireason		2	/* interrupt reason (R/W) (for atapi) */
     52  1.24  christos #define	wd_sector		3	/* first sector number (R/W) */
     53  1.24  christos #define	wd_cyl_lo		4	/* cylinder address, low byte (R/W) */
     54  1.24  christos #define	wd_cyl_hi		5	/* cylinder address, high byte (R/W) */
     55  1.24  christos #define	wd_sdh			6	/* sector size/drive/head (R/W) */
     56  1.24  christos #define	wd_command		7	/* command register (W)	*/
     57  1.24  christos #define	wd_status		7	/* immediate status (R)	*/
     58  1.24  christos #define	wd_lba_lo		3	/* lba address, low byte (RW) */
     59  1.24  christos #define	wd_lba_mi		4	/* lba address, middle byte (RW) */
     60  1.24  christos #define	wd_lba_hi		5	/* lba address, high byte (RW) */
     61  1.15       cgd 
     62  1.15       cgd /* offsets of registers in the auxiliary register region */
     63  1.24  christos #define	wd_aux_altsts		0	/* alternate fixed disk status (R) */
     64  1.24  christos #define	wd_aux_ctlr		0	/* fixed disk controller control (W) */
     65  1.24  christos #define  WDCTL_4BIT		 0x08	/* use four head bits (wd1003) */
     66  1.24  christos #define  WDCTL_RST		 0x04	/* reset the controller */
     67  1.24  christos #define  WDCTL_IDS		 0x02	/* disable controller interrupts */
     68  1.15       cgd #if 0 /* NOT MAPPED; fd uses this register on PCs */
     69  1.24  christos #define	wd_digin		1	/* disk controller input (R) */
     70  1.15       cgd #endif
     71   1.1       cgd 
     72   1.1       cgd /*
     73   1.9   mycroft  * Status bits.
     74   1.1       cgd  */
     75  1.24  christos #define	WDCS_BSY		0x80	/* busy */
     76  1.24  christos #define	WDCS_DRDY		0x40	/* drive ready */
     77  1.24  christos #define	WDCS_DWF		0x20	/* drive write fault */
     78  1.24  christos #define	WDCS_DSC		0x10	/* drive seek complete */
     79  1.24  christos #define	WDCS_DRQ		0x08	/* data request */
     80  1.24  christos #define	WDCS_CORR		0x04	/* corrected data */
     81  1.24  christos #define	WDCS_IDX		0x02	/* index */
     82  1.24  christos #define	WDCS_ERR		0x01	/* error */
     83  1.24  christos #define WDCS_BITS \
     84  1.24  christos     "\020\010bsy\007drdy\006dwf\005dsc\004drq\003corr\002idx\001err"
     85   1.1       cgd 
     86   1.9   mycroft /*
     87   1.9   mycroft  * Error bits.
     88   1.9   mycroft  */
     89  1.24  christos #define	WDCE_BBK		0x80	/* bad block detected */
     90  1.24  christos #define	WDCE_CRC		0x80	/* CRC error (Ultra-DMA only) */
     91  1.24  christos #define	WDCE_UNC		0x40	/* uncorrectable data error */
     92  1.24  christos #define	WDCE_MC			0x20	/* media changed */
     93  1.24  christos #define	WDCE_IDNF		0x10	/* id not found */
     94  1.24  christos #define	WDCE_MCR		0x08	/* media change requested */
     95  1.24  christos #define	WDCE_ABRT		0x04	/* aborted command */
     96  1.24  christos #define	WDCE_TK0NF		0x02	/* track 0 not found */
     97  1.24  christos #define	WDCE_AMNF		0x01	/* address mark not found */
     98   1.1       cgd 
     99   1.1       cgd /*
    100   1.1       cgd  * Commands for Disk Controller.
    101   1.1       cgd  */
    102  1.24  christos #define	WDCC_NOP		0x00	/* Always fail with "aborted command" */
    103  1.24  christos #define	WDCC_RECAL		0x10	/* disk restore code -- resets cntlr */
    104   1.9   mycroft 
    105  1.24  christos #define	WDCC_READ		0x20	/* disk read code */
    106  1.24  christos #define	WDCC_WRITE		0x30	/* disk write code */
    107  1.24  christos #define	 WDCC__LONG		 0x02	/* modifier -- access ecc bytes */
    108  1.24  christos #define	 WDCC__NORETRY		 0x01	/* modifier -- no retrys */
    109  1.24  christos 
    110  1.24  christos #define	WDCC_FORMAT		0x50	/* disk format code */
    111  1.24  christos #define	WDCC_DIAGNOSE		0x90	/* controller diagnostic */
    112  1.24  christos #define	WDCC_IDP		0x91	/* initialize drive parameters */
    113  1.24  christos 
    114  1.24  christos #define	WDCC_SMART		0xb0	/* Self Mon, Analysis, Reporting Tech */
    115  1.24  christos 
    116  1.24  christos #define	WDCC_READMULTI		0xc4	/* read multiple */
    117  1.24  christos #define	WDCC_WRITEMULTI		0xc5	/* write multiple */
    118  1.24  christos #define	WDCC_SETMULTI		0xc6	/* set multiple mode */
    119  1.24  christos 
    120  1.24  christos #define	WDCC_READDMA		0xc8	/* read with DMA */
    121  1.24  christos #define	WDCC_WRITEDMA		0xca	/* write with DMA */
    122  1.24  christos 
    123  1.24  christos #define	WDCC_ACKMC		0xdb	/* acknowledge media change */
    124  1.24  christos #define	WDCC_LOCK		0xde	/* lock drawer */
    125  1.24  christos #define	WDCC_UNLOCK		0xdf	/* unlock drawer */
    126  1.24  christos 
    127  1.24  christos #define	WDCC_FLUSHCACHE		0xe7	/* Flush cache */
    128  1.24  christos #define	WDCC_IDENTIFY		0xec	/* read parameters from controller */
    129  1.24  christos #define	SET_FEATURES		0xef	/* set features */
    130  1.24  christos 
    131  1.24  christos #define	WDCC_IDLE		0xe3	/* set idle timer & enter idle mode */
    132  1.24  christos #define	WDCC_IDLE_IMMED		0xe1	/* enter idle mode */
    133  1.24  christos #define	WDCC_SLEEP		0xe6	/* enter sleep mode */
    134  1.24  christos #define	WDCC_STANDBY		0xe2	/* set standby timer & enter standby */
    135  1.24  christos #define	WDCC_STANDBY_IMMED	0xe0	/* enter standby mode */
    136  1.24  christos #define	WDCC_CHECK_PWR		0xe5	/* check power mode */
    137  1.24  christos 
    138  1.24  christos /*
    139  1.24  christos  * Big Drive support
    140  1.24  christos  */
    141  1.24  christos #define	WDCC_READ_EXT		0x24	/* read 48-bit addressing */
    142  1.24  christos #define	WDCC_WRITE_EXT		0x34	/* write 48-bit addressing */
    143  1.24  christos 
    144  1.24  christos #define	WDCC_READMULTI_EXT	0x29	/* read multiple 48-bit addressing */
    145  1.24  christos #define	WDCC_WRITEMULTI_EXT	0x39	/* read multiple 48-bit addressing */
    146  1.24  christos 
    147  1.24  christos #define	WDCC_READDMA_EXT	0x25	/* read 48-bit addressing with DMA */
    148  1.24  christos #define	WDCC_WRITEDMA_EXT	0x35	/* write 48-bit addressing with DMA */
    149   1.1       cgd 
    150  1.23    castor /* Subcommands for SET_FEATURES (features register) */
    151  1.24  christos #define	WDSF_EN_WR_CACHE	0x02
    152  1.24  christos #define	WDSF_SET_MODE		0x03
    153  1.24  christos #define	WDSF_REASSIGN_EN	0x04
    154  1.24  christos #define	WDSF_RETRY_DS		0x33
    155  1.24  christos #define	WDSF_SET_CACHE_SGMT	0x54
    156  1.24  christos #define	WDSF_READAHEAD_DS	0x55
    157  1.24  christos #define	WDSF_POD_DS		0x66
    158  1.24  christos #define	WDSF_ECC_DS		0x77
    159  1.24  christos #define	WDSF_WRITE_CACHE_DS	0x82
    160  1.24  christos #define	WDSF_REASSIGN_DS	0x84
    161  1.24  christos #define	WDSF_ECC_EN		0x88
    162  1.24  christos #define	WDSF_RETRY_EN		0x99
    163  1.24  christos #define	WDSF_SET_CURRENT	0x9a
    164  1.24  christos #define	WDSF_READAHEAD_EN	0xaa
    165  1.24  christos #define	WDSF_PREFETCH_SET	0xab
    166  1.24  christos #define	WDSF_POD_EN		0xcc
    167  1.23    castor 
    168  1.23    castor /* Subcommands for SMART (features register) */
    169  1.24  christos #define	WDSM_RD_DATA		0xd0
    170  1.24  christos #define	WDSM_ATTR_AUTOSAVE_EN	0xd2
    171  1.24  christos #define	WDSM_SAVE_ATTR		0xd3
    172  1.24  christos #define	WDSM_EXEC_OFFL_IMM	0xd4
    173  1.24  christos #define	WDSM_ENABLE_OPS		0xd8
    174  1.24  christos #define	WDSM_DISABLE_OPS	0xd9
    175  1.24  christos #define	WDSM_STATUS		0xda
    176  1.23    castor 
    177  1.24  christos #define	WDSMART_CYL_LO		0x4f
    178  1.24  christos #define	WDSMART_CYL_HI		0xc2
    179  1.23    castor 
    180  1.18    bouyer 
    181  1.18    bouyer /* parameters uploaded to device/heads register */
    182  1.24  christos #define	WDSD_IBM		0xa0	/* forced to 512 byte sector, ecc */
    183  1.24  christos #define	WDSD_CHS		0x00	/* cylinder/head/sector addressing */
    184  1.24  christos #define	WDSD_LBA		0x40	/* logical block addressing */
    185  1.14    bouyer 
    186  1.14    bouyer /* Commands for ATAPI devices */
    187  1.24  christos #define	ATAPI_CHECK_POWER_MODE	0xe5
    188  1.24  christos #define	ATAPI_EXEC_DRIVE_DIAGS	0x90
    189  1.24  christos #define	ATAPI_IDLE_IMMEDIATE	0xe1
    190  1.24  christos #define	ATAPI_NOP		0x00
    191  1.24  christos #define	ATAPI_PKT_CMD		0xa0
    192  1.24  christos #define	ATAPI_IDENTIFY_DEVICE	0xa1
    193  1.24  christos #define	ATAPI_SOFT_RESET	0x08
    194  1.24  christos #define	ATAPI_SLEEP		0xe6
    195  1.24  christos #define	ATAPI_STANDBY_IMMEDIATE	0xe0
    196  1.18    bouyer 
    197  1.18    bouyer /* Bytes used by ATAPI_PACKET_COMMAND ( feature register) */
    198  1.24  christos #define	ATAPI_PKT_CMD_FTRE_DMA	0x01
    199  1.24  christos #define	ATAPI_PKT_CMD_FTRE_OVL	0x02
    200  1.14    bouyer 
    201  1.14    bouyer /* ireason */
    202  1.24  christos #define	WDCI_CMD		0x01	/* command(1) or data(0) */
    203  1.24  christos #define	WDCI_IN			0x02	/* transfer to(1) or from(0) the host */
    204  1.24  christos #define	WDCI_RELEASE		0x04	/* bus released until completion */
    205  1.24  christos 
    206  1.24  christos #define	PHASE_CMDOUT		(WDCS_DRQ | WDCI_CMD)
    207  1.24  christos #define	PHASE_DATAIN		(WDCS_DRQ | WDCI_IN)
    208  1.24  christos #define	PHASE_DATAOUT		(WDCS_DRQ)
    209  1.24  christos #define	PHASE_COMPLETED		(WDCI_IN | WDCI_CMD)
    210  1.24  christos #define	PHASE_ABORTED		(0)
    211