summaryrefslogtreecommitdiff
path: root/firmware/export/ata.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/ata.h')
-rw-r--r--firmware/export/ata.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/firmware/export/ata.h b/firmware/export/ata.h
index 62c9467643..dfa73eebf5 100644
--- a/firmware/export/ata.h
+++ b/firmware/export/ata.h
@@ -101,7 +101,7 @@ struct ata_smart_values
101 unsigned char reserved_375_385[11]; 101 unsigned char reserved_375_385[11];
102 unsigned char vendor_specific_386_510[125]; 102 unsigned char vendor_specific_386_510[125];
103 unsigned char chksum; 103 unsigned char chksum;
104} __attribute__((packed)); 104} __attribute__((packed)) __attribute__((aligned(2)));
105 105
106/* Raw attribute value print formats */ 106/* Raw attribute value print formats */
107enum ata_attr_raw_format 107enum ata_attr_raw_format
@@ -140,8 +140,8 @@ bool ata_disk_is_active(void);
140int ata_soft_reset(void); 140int ata_soft_reset(void);
141int ata_init(void) STORAGE_INIT_ATTR; 141int ata_init(void) STORAGE_INIT_ATTR;
142void ata_close(void); 142void ata_close(void);
143int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); 143int ata_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
144int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); 144int ata_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
145void ata_spin(void); 145void ata_spin(void);
146#if (CONFIG_LED == LED_REAL) 146#if (CONFIG_LED == LED_REAL)
147void ata_set_led_enabled(bool enabled); 147void ata_set_led_enabled(bool enabled);
@@ -176,7 +176,6 @@ static inline int ata_disk_isssd(void)
176 0x0401 -> 0xffe == RPM 176 0x0401 -> 0xffe == RPM
177 All others reserved 177 All others reserved
178 178
179 Some CF cards return 0x0100 (ie byteswapped 0x0001) so accept either.
180 However, this is a relatively recent change, and we can't rely on it, 179 However, this is a relatively recent change, and we can't rely on it,
181 especially for the FC1307A CF->SD adapters! 180 especially for the FC1307A CF->SD adapters!
182 181
@@ -191,27 +190,26 @@ static inline int ata_disk_isssd(void)
191 However microdrives pose a problem as they support CFA but are not 190 However microdrives pose a problem as they support CFA but are not
192 SSD. 191 SSD.
193 192
193 Offset 163 shows CF Advanced timing modes; microdrives all seems to
194 report 0, but all others (including iFlash) report higher! This
195 is often present even when the "CFA supported" bit is 0.
196
194 Offset 160 b15 indicates support for CF+ power level 1, if not set 197 Offset 160 b15 indicates support for CF+ power level 1, if not set
195 then device is standard flash CF. However this is not foolproof 198 then device is standard flash CF. However this is not foolproof
196 as newer CF cards may support it for extra performance. 199 as newer CF cards (and those CF->SD adapters) may report this.
197
198 Offset 163 shows CF Advanced timing modes; microdrive seems to
199 report 0, but all others (including iFlash) report higher!
200
201 So if device support CFA _AND_ reports higher speeds modes, it is SSD.
202 200
203 */ 201 */
204 return ( (identify_info[217] == 0x0001 || identify_info[217] == 0x0100) /* "Solid state" rotational rate */ 202 return ( (identify_info[217] == 0x0001) /* "Solid state" rotational rate */
205 || ((identify_info[168] & 0x0f) >= 0x06) /* Explicit SSD form factors */ 203 || ((identify_info[168] & 0x0f) >= 0x06) /* Explicit SSD form factors */
206 || (identify_info[169] & (1<<0)) /* TRIM supported */ 204 || (identify_info[169] & (1<<0)) /* TRIM supported */
207 || ((identify_info[83] & (1<<2)) && /* CFA compliant */ 205 || (identify_info[163] > 0) /* CF Advanced timing modes */
208 (((identify_info[160] & (1<<15)) == 0) || /* CF level 0 */ 206 || ((identify_info[83] & (1<<2)) && /* CFA compliant */
209 (identify_info[163] > 0))) /* Advanced timing modes */ 207 ((identify_info[160] & (1<<15)) == 0)) /* CF power level 0 */
210 ); 208 );
211} 209}
212 210
213/* Returns 1 if the drive can be powered off safely */ 211/* Returns 1 if the drive supports power management commands */
214static inline int ata_disk_can_poweroff(void) 212static inline int ata_disk_can_sleep(void)
215{ 213{
216 unsigned short *identify_info = ata_get_identify(); 214 unsigned short *identify_info = ata_get_identify();
217 /* Only devices that claim to support PM can be safely powered off. 215 /* Only devices that claim to support PM can be safely powered off.
@@ -219,6 +217,8 @@ static inline int ata_disk_can_poweroff(void)
219 return (identify_info[82] & (1<<3) && identify_info[85] & (1<<3)); 217 return (identify_info[82] & (1<<3) && identify_info[85] & (1<<3));
220} 218}
221 219
220int ata_flush(void);
221
222#ifdef HAVE_ATA_DMA 222#ifdef HAVE_ATA_DMA
223/* Returns current DMA mode */ 223/* Returns current DMA mode */
224int ata_get_dma_mode(void); 224int ata_get_dma_mode(void);
@@ -233,4 +233,6 @@ int ata_read_smart(struct ata_smart_values*);
233#define STORAGE_CLOSE 233#define STORAGE_CLOSE
234#endif 234#endif
235 235
236#define ATA_IDENTIFY_WORDS 256
237
236#endif /* __ATA_H__ */ 238#endif /* __ATA_H__ */