1 #ifndef CYGONCE_CF_ATA_H
2 #define CYGONCE_CF_ATA_H
3 //==========================================================================
7 // CompactFlash ATA interface definitions
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 2003 Savin Zlobec
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
49 //####DESCRIPTIONEND####
51 //==========================================================================
53 // -------------------------------------------------------------------------
54 // CF Error Register bits
56 #define CF_EREG_BBK (1<<7) // bad block detected
57 #define CF_EREG_UNC (1<<6) // uncorrectable error
58 #define CF_EREG_IDNF (1<<4) // req sector ID is in error or cannot be found
59 #define CF_EREG_ABORT (1<<2) // command aborted
60 #define CF_EREG_AMNF (1<<0) // general error
62 // -------------------------------------------------------------------------
63 // CF Status Register bits
65 #define CF_SREG_BUSY (1<<7) // busy (no other bits in this register are valid)
66 #define CF_SREG_RDY (1<<6) // ready to accept a command
67 #define CF_SREG_DWF (1<<5) // write fault has occurred
68 #define CF_SREG_DSC (1<<4) // card is ready
69 #define CF_SREG_DRQ (1<<3) // information req transfer to/from the host
70 // through the Data register
71 #define CF_SREG_CORR (1<<2) // correctable data error (data corrected)
72 #define CF_SREG_IDX (1<<1) // always 0
73 #define CF_SREG_ERR (1<<0) // command has ended in error (see error reg)
75 // -------------------------------------------------------------------------
76 // CF Device Control Register bits
78 #define CF_DREG_SWRST (1<<2) // soft reset
79 #define CF_DREG_IEN (1<<1) // interrupt enable (0 - enabled, 1 - disabled)
81 // -------------------------------------------------------------------------
84 // FR - Features register
85 // SC - Sector count register
86 // SN - Sector number register
87 // CY - Cylinder registers
88 // DH - Card/Drive/Head register
89 // LBA - Logical Block Address Mode Supported
91 // Y - The register contains a valid parameter for this command
92 // For the Drive/Head Register Y means both the CF Card and head
93 // parameters are used
94 // D - Only the CompactFlash Card parameter is valid and not the head parameter
96 // Note FR SC SN CY DH LBA
97 #define CF_ATA_CHECK_POWER_MODE_CMD 0xE5 // - - - - - D -
98 #define CF_ATA_EXE_DRIVE_DIAG_CMD 0x90 // - - - - - D -
99 #define CF_ATA_ERASE_SECTORS_CMD 0xC0 // 2 - Y Y Y Y Y
100 #define CF_ATA_FORMAT_TRACK_CMD 0x50 // - - Y - Y Y Y
101 #define CF_ATA_IDENTIFY_DRIVE_CMD 0xEC // - - - - - D -
102 #define CF_ATA_IDLE_CMD 0xE3 // - - Y - - D -
103 #define CF_ATA_IDLE_IMMEDIATE_CMD 0xE1 // - - - - - D -
104 #define CF_ATA_INIT_DRIVE_PARAMS_CMD 0x91 // - - Y - - Y -
105 #define CF_ATA_READ_BUFFER_CMD 0xE4 // - - - - - D -
106 #define CF_ATA_READ_MULTIPLE_CMD 0xC4 // - - Y Y Y Y Y
107 #define CF_ATA_READ_LONG_SECTOR_CMD 0x22 // - - - Y Y Y Y
108 #define CF_ATA_READ_SECTORS_CMD 0x20 // - - Y Y Y Y Y
109 #define CF_ATA_READ_VERIFY_SECTORS_CMD 0x40 // - - Y Y Y Y Y
110 #define CF_ATA_RECALIBRATE_CMD 0x10 // - - - - - D -
111 #define CF_ATA_REQUEST_SENSE_CMD 0x03 // 1 - - - - D -
112 #define CF_ATA_SEEK_CMD 0x70 // - - - Y Y Y Y
113 #define CF_ATA_SET_FEATURES_CMD 0xEF // - Y - - - D -
114 #define CF_ATA_SET_MULTIPLE_MODE_CMD 0xC6 // - - Y - - D -
115 #define CF_ATA_SET_SLEEP_MODE_CMD 0xE6 // - - - - - D -
116 #define CF_ATA_STAND_BY_CMD 0xE2 // - - - - - D -
117 #define CF_ATA_STAND_BY_IMMEDIATE_CMD 0xE0 // - - - - - D -
118 #define CF_ATA_TRANSLATE_SECTOR_CMD 0x87 // 1 - Y Y Y Y Y
119 #define CF_ATA_WEAR_LEVEL_CMD 0xF5 // 1 - - - - Y -
120 #define CF_ATA_WRITE_BUFFER_CMD 0xE8 // - - - - - D -
121 #define CF_ATA_WRITE_LONG_SECTOR_CMD 0x32 // - - - Y Y Y Y
122 #define CF_ATA_WRITE_MULTIPLE_CMD 0xC5 // - - Y Y Y Y Y
123 #define CF_ATA_WRITE_MULTIPLE_WO_ERASE_CMD 0xCD // 2 - Y Y Y Y Y
124 #define CF_ATA_WRITE_SECTORS_CMD 0x30 // - - Y Y Y Y Y
125 #define CF_ATA_WRITE_SECTORS_WO_ERASE_CMD 0x38 // 2 - Y Y Y Y Y
126 #define CF_ATA_WRITE_VERIFY_SECTORS_CMD 0x3C // - - Y Y Y Y Y
128 // Note 1 : These commands are not standard PC Card ATA commands but
129 // provide additional functionality
130 // Note 2 : These commands are not standard PC Card ATA commands and
131 // these features are no longer supported with the
132 // introduction of 256 Mbit flash technology. If one
133 // of these commands is issued, the sectors will be
134 // erased but there will be no net gain in write
135 // performance when using the Write Without Erase command.
137 // -------------------------------------------------------------------------
138 // CF ATA Identify drive command response
140 typedef struct cf_ata_identify_data_t
142 cyg_uint16 general_conf; // 00 : general configuration
143 cyg_uint16 num_cylinders; // 01 : number of cylinders (default CHS trans)
144 cyg_uint16 reserved0; // 02 : reserved
145 cyg_uint16 num_heads; // 03 : number of heads (default CHS trans)
146 cyg_uint16 num_ub_per_track; // 04 : number of unformatted bytes per track
147 cyg_uint16 num_ub_per_sector; // 05 : number of unformatted bytes per sector
148 cyg_uint16 num_sectors; // 06 : number of sectors per track (default CHS trans)
149 cyg_uint16 num_card_sectors[2]; // 07-08 : number of sectors per card
150 cyg_uint16 reserved1; // 09 : reserved
151 cyg_uint16 serial[10]; // 10-19 : serial number (string)
152 cyg_uint16 buffer_type; // 20 : buffer type (dual ported)
153 cyg_uint16 buffer_size; // 21 : buffer size in 512 increments
154 cyg_uint16 num_ECC_bytes; // 22 : number of ECC bytes passed on R/W Long cmds
155 cyg_uint16 firmware_rev[4]; // 23-26 : firmware revision (string)
156 cyg_uint16 model_num[20]; // 27-46 : model number (string)
157 cyg_uint16 rw_mult_support; // 47 : max number of sectors on R/W multiple cmds
158 cyg_uint16 reserved2; // 48 : reserved
159 cyg_uint16 capabilities; // 49 : LBA, DMA, IORDY support indicator
160 cyg_uint16 reserved3; // 50 : reserved
161 cyg_uint16 pio_xferc_timing; // 51 : PIO data transfer cycle timing mode
162 cyg_uint16 dma_xferc_timing; // 52 : single word DMA data transfer cycle timing mode
163 cyg_uint16 cur_field_validity; // 53 : words 54-58 validity (0 == not valid)
164 cyg_uint16 cur_cylinders; // 54 : number of current cylinders
165 cyg_uint16 cur_heads; // 55 : number of current heads
166 cyg_uint16 cur_spt; // 56 : number of current sectors per track
167 cyg_uint16 cur_capacity[2]; // 57-58 : current capacity in sectors
168 cyg_uint16 mult_sectors; // 59 : multiple sector setting
169 cyg_uint16 lba_total_sectors[2]; // 60-61 : total sectors in LBA mode
170 cyg_uint16 sw_dma; // 62 : single word DMA support
171 cyg_uint16 mw_dma; // 63 : multi word DMA support
172 cyg_uint16 apio_modes; // 64 : advanced PIO transfer mode supported
173 cyg_uint16 min_dma_timing; // 65 : minimum multiword DMA transfer cycle
174 cyg_uint16 rec_dma_timing; // 66 : recommended multiword DMA cycle
175 cyg_uint16 min_pio_timing; // 67 : min PIO transfer time without flow control
176 cyg_uint16 min_pio_iordy_timing; // 68 : min PIO transfer time with IORDY flow control
177 // cyg_uint16 reserved4[187]; // 69-255: reserved
178 } cf_ata_identify_data_t;
180 #endif // CYGONCE_CF_ATA_H
182 // -------------------------------------------------------------------------