aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ide.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r--include/linux/ide.h193
1 files changed, 77 insertions, 116 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index d5d832271f44..9fed365a598b 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -240,65 +240,38 @@ typedef enum {
240} ide_startstop_t; 240} ide_startstop_t;
241 241
242enum { 242enum {
243 IDE_VALID_ERROR = (1 << 1),
244 IDE_VALID_FEATURE = IDE_VALID_ERROR,
245 IDE_VALID_NSECT = (1 << 2),
246 IDE_VALID_LBAL = (1 << 3),
247 IDE_VALID_LBAM = (1 << 4),
248 IDE_VALID_LBAH = (1 << 5),
249 IDE_VALID_DEVICE = (1 << 6),
250 IDE_VALID_LBA = IDE_VALID_LBAL |
251 IDE_VALID_LBAM |
252 IDE_VALID_LBAH,
253 IDE_VALID_OUT_TF = IDE_VALID_FEATURE |
254 IDE_VALID_NSECT |
255 IDE_VALID_LBA,
256 IDE_VALID_IN_TF = IDE_VALID_NSECT |
257 IDE_VALID_LBA,
258 IDE_VALID_OUT_HOB = IDE_VALID_OUT_TF,
259 IDE_VALID_IN_HOB = IDE_VALID_ERROR |
260 IDE_VALID_NSECT |
261 IDE_VALID_LBA,
262};
263
264enum {
243 IDE_TFLAG_LBA48 = (1 << 0), 265 IDE_TFLAG_LBA48 = (1 << 0),
244 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 1), 266 IDE_TFLAG_WRITE = (1 << 1),
245 IDE_TFLAG_OUT_HOB_NSECT = (1 << 2), 267 IDE_TFLAG_CUSTOM_HANDLER = (1 << 2),
246 IDE_TFLAG_OUT_HOB_LBAL = (1 << 3), 268 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 3),
247 IDE_TFLAG_OUT_HOB_LBAM = (1 << 4),
248 IDE_TFLAG_OUT_HOB_LBAH = (1 << 5),
249 IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
250 IDE_TFLAG_OUT_HOB_NSECT |
251 IDE_TFLAG_OUT_HOB_LBAL |
252 IDE_TFLAG_OUT_HOB_LBAM |
253 IDE_TFLAG_OUT_HOB_LBAH,
254 IDE_TFLAG_OUT_FEATURE = (1 << 6),
255 IDE_TFLAG_OUT_NSECT = (1 << 7),
256 IDE_TFLAG_OUT_LBAL = (1 << 8),
257 IDE_TFLAG_OUT_LBAM = (1 << 9),
258 IDE_TFLAG_OUT_LBAH = (1 << 10),
259 IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
260 IDE_TFLAG_OUT_NSECT |
261 IDE_TFLAG_OUT_LBAL |
262 IDE_TFLAG_OUT_LBAM |
263 IDE_TFLAG_OUT_LBAH,
264 IDE_TFLAG_OUT_DEVICE = (1 << 11),
265 IDE_TFLAG_WRITE = (1 << 12),
266 IDE_TFLAG_CUSTOM_HANDLER = (1 << 13),
267 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 14),
268 IDE_TFLAG_IN_HOB_FEATURE = (1 << 15),
269 IDE_TFLAG_IN_HOB_NSECT = (1 << 16),
270 IDE_TFLAG_IN_HOB_LBAL = (1 << 17),
271 IDE_TFLAG_IN_HOB_LBAM = (1 << 18),
272 IDE_TFLAG_IN_HOB_LBAH = (1 << 19),
273 IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
274 IDE_TFLAG_IN_HOB_LBAM |
275 IDE_TFLAG_IN_HOB_LBAH,
276 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
277 IDE_TFLAG_IN_HOB_NSECT |
278 IDE_TFLAG_IN_HOB_LBA,
279 IDE_TFLAG_IN_FEATURE = (1 << 20),
280 IDE_TFLAG_IN_NSECT = (1 << 21),
281 IDE_TFLAG_IN_LBAL = (1 << 22),
282 IDE_TFLAG_IN_LBAM = (1 << 23),
283 IDE_TFLAG_IN_LBAH = (1 << 24),
284 IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
285 IDE_TFLAG_IN_LBAM |
286 IDE_TFLAG_IN_LBAH,
287 IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
288 IDE_TFLAG_IN_LBA,
289 IDE_TFLAG_IN_DEVICE = (1 << 25),
290 IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB |
291 IDE_TFLAG_IN_HOB,
292 IDE_TFLAG_TF = IDE_TFLAG_OUT_TF |
293 IDE_TFLAG_IN_TF,
294 IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE |
295 IDE_TFLAG_IN_DEVICE,
296 /* force 16-bit I/O operations */ 269 /* force 16-bit I/O operations */
297 IDE_TFLAG_IO_16BIT = (1 << 26), 270 IDE_TFLAG_IO_16BIT = (1 << 4),
298 /* struct ide_cmd was allocated using kmalloc() */ 271 /* struct ide_cmd was allocated using kmalloc() */
299 IDE_TFLAG_DYN = (1 << 27), 272 IDE_TFLAG_DYN = (1 << 5),
300 IDE_TFLAG_FS = (1 << 28), 273 IDE_TFLAG_FS = (1 << 6),
301 IDE_TFLAG_MULTI_PIO = (1 << 29), 274 IDE_TFLAG_MULTI_PIO = (1 << 7),
302}; 275};
303 276
304enum { 277enum {
@@ -309,41 +282,34 @@ enum {
309}; 282};
310 283
311struct ide_taskfile { 284struct ide_taskfile {
312 u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ 285 u8 data; /* 0: data byte (for TASKFILE ioctl) */
313 286 union { /* 1: */
314 u8 hob_feature; /* 1-5: additional data to support LBA48 */ 287 u8 error; /* read: error */
315 u8 hob_nsect; 288 u8 feature; /* write: feature */
316 u8 hob_lbal;
317 u8 hob_lbam;
318 u8 hob_lbah;
319
320 u8 data; /* 6: low data byte (for TASKFILE IOCTL) */
321
322 union { /*  7: */
323 u8 error; /* read: error */
324 u8 feature; /* write: feature */
325 }; 289 };
326 290 u8 nsect; /* 2: number of sectors */
327 u8 nsect; /* 8: number of sectors */ 291 u8 lbal; /* 3: LBA low */
328 u8 lbal; /* 9: LBA low */ 292 u8 lbam; /* 4: LBA mid */
329 u8 lbam; /* 10: LBA mid */ 293 u8 lbah; /* 5: LBA high */
330 u8 lbah; /* 11: LBA high */ 294 u8 device; /* 6: device select */
331 295 union { /* 7: */
332 u8 device; /* 12: device select */ 296 u8 status; /* read: status */
333
334 union { /* 13: */
335 u8 status; /*  read: status  */
336 u8 command; /* write: command */ 297 u8 command; /* write: command */
337 }; 298 };
338}; 299};
339 300
340struct ide_cmd { 301struct ide_cmd {
341 union { 302 struct ide_taskfile tf;
342 struct ide_taskfile tf; 303 struct ide_taskfile hob;
343 u8 tf_array[14]; 304 struct {
344 }; 305 struct {
306 u8 tf;
307 u8 hob;
308 } out, in;
309 } valid;
310
311 u8 tf_flags;
345 u8 ftf_flags; /* for TASKFILE ioctl */ 312 u8 ftf_flags; /* for TASKFILE ioctl */
346 u32 tf_flags;
347 int protocol; 313 int protocol;
348 314
349 int sg_nents; /* number of sg entries */ 315 int sg_nents; /* number of sg entries */
@@ -352,6 +318,8 @@ struct ide_cmd {
352 318
353 unsigned int nbytes; 319 unsigned int nbytes;
354 unsigned int nleft; 320 unsigned int nleft;
321 unsigned int last_xfer_len;
322
355 struct scatterlist *cursg; 323 struct scatterlist *cursg;
356 unsigned int cursg_ofs; 324 unsigned int cursg_ofs;
357 325
@@ -375,7 +343,7 @@ enum {
375 * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. 343 * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes.
376 * This is used for several packet commands (not for READ/WRITE commands). 344 * This is used for several packet commands (not for READ/WRITE commands).
377 */ 345 */
378#define IDE_PC_BUFFER_SIZE 256 346#define IDE_PC_BUFFER_SIZE 64
379#define ATAPI_WAIT_PC (60 * HZ) 347#define ATAPI_WAIT_PC (60 * HZ)
380 348
381struct ide_atapi_pc { 349struct ide_atapi_pc {
@@ -413,9 +381,6 @@ struct ide_atapi_pc {
413 struct idetape_bh *bh; 381 struct idetape_bh *bh;
414 char *b_data; 382 char *b_data;
415 383
416 struct scatterlist *sg;
417 unsigned int sg_cnt;
418
419 unsigned long timeout; 384 unsigned long timeout;
420}; 385};
421 386
@@ -456,11 +421,6 @@ enum {
456 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3), 421 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3),
457 /* TOC track numbers are in BCD. */ 422 /* TOC track numbers are in BCD. */
458 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4), 423 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4),
459 /*
460 * Drive does not provide data in multiples of SECTOR_SIZE
461 * when more than one interrupt is needed.
462 */
463 IDE_AFLAG_LIMIT_NFRAMES = (1 << 5),
464 /* Saved TOC information is current. */ 424 /* Saved TOC information is current. */
465 IDE_AFLAG_TOC_VALID = (1 << 6), 425 IDE_AFLAG_TOC_VALID = (1 << 6),
466 /* We think that the drive door is locked. */ 426 /* We think that the drive door is locked. */
@@ -605,7 +565,7 @@ struct ide_drive_s {
605 565
606 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 566 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
607 unsigned int cyl; /* "real" number of cyls */ 567 unsigned int cyl; /* "real" number of cyls */
608 unsigned int drive_data; /* used by set_pio_mode/selectproc */ 568 unsigned int drive_data; /* used by set_pio_mode/dev_select() */
609 unsigned int failures; /* current failure count */ 569 unsigned int failures; /* current failure count */
610 unsigned int max_failures; /* maximum allowed failure count */ 570 unsigned int max_failures; /* maximum allowed failure count */
611 u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */ 571 u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */
@@ -661,11 +621,11 @@ struct ide_tp_ops {
661 void (*exec_command)(struct hwif_s *, u8); 621 void (*exec_command)(struct hwif_s *, u8);
662 u8 (*read_status)(struct hwif_s *); 622 u8 (*read_status)(struct hwif_s *);
663 u8 (*read_altstatus)(struct hwif_s *); 623 u8 (*read_altstatus)(struct hwif_s *);
624 void (*write_devctl)(struct hwif_s *, u8);
664 625
665 void (*set_irq)(struct hwif_s *, int); 626 void (*dev_select)(ide_drive_t *);
666 627 void (*tf_load)(ide_drive_t *, struct ide_taskfile *, u8);
667 void (*tf_load)(ide_drive_t *, struct ide_cmd *); 628 void (*tf_read)(ide_drive_t *, struct ide_taskfile *, u8);
668 void (*tf_read)(ide_drive_t *, struct ide_cmd *);
669 629
670 void (*input_data)(ide_drive_t *, struct ide_cmd *, 630 void (*input_data)(ide_drive_t *, struct ide_cmd *,
671 void *, unsigned int); 631 void *, unsigned int);
@@ -681,7 +641,6 @@ extern const struct ide_tp_ops default_tp_ops;
681 * @init_dev: host specific initialization of a device 641 * @init_dev: host specific initialization of a device
682 * @set_pio_mode: routine to program host for PIO mode 642 * @set_pio_mode: routine to program host for PIO mode
683 * @set_dma_mode: routine to program host for DMA mode 643 * @set_dma_mode: routine to program host for DMA mode
684 * @selectproc: tweaks hardware to select drive
685 * @reset_poll: chipset polling based on hba specifics 644 * @reset_poll: chipset polling based on hba specifics
686 * @pre_reset: chipset specific changes to default for device-hba resets 645 * @pre_reset: chipset specific changes to default for device-hba resets
687 * @resetproc: routine to reset controller after a disk reset 646 * @resetproc: routine to reset controller after a disk reset
@@ -698,7 +657,6 @@ struct ide_port_ops {
698 void (*init_dev)(ide_drive_t *); 657 void (*init_dev)(ide_drive_t *);
699 void (*set_pio_mode)(ide_drive_t *, const u8); 658 void (*set_pio_mode)(ide_drive_t *, const u8);
700 void (*set_dma_mode)(ide_drive_t *, const u8); 659 void (*set_dma_mode)(ide_drive_t *, const u8);
701 void (*selectproc)(ide_drive_t *);
702 int (*reset_poll)(ide_drive_t *); 660 int (*reset_poll)(ide_drive_t *);
703 void (*pre_reset)(ide_drive_t *); 661 void (*pre_reset)(ide_drive_t *);
704 void (*resetproc)(ide_drive_t *); 662 void (*resetproc)(ide_drive_t *);
@@ -719,8 +677,10 @@ struct ide_dma_ops {
719 int (*dma_end)(struct ide_drive_s *); 677 int (*dma_end)(struct ide_drive_s *);
720 int (*dma_test_irq)(struct ide_drive_s *); 678 int (*dma_test_irq)(struct ide_drive_s *);
721 void (*dma_lost_irq)(struct ide_drive_s *); 679 void (*dma_lost_irq)(struct ide_drive_s *);
680 /* below ones are optional */
681 int (*dma_check)(struct ide_drive_s *, struct ide_cmd *);
722 int (*dma_timer_expiry)(struct ide_drive_s *); 682 int (*dma_timer_expiry)(struct ide_drive_s *);
723 void (*dma_timeout)(struct ide_drive_s *); 683 void (*dma_clear)(struct ide_drive_s *);
724 /* 684 /*
725 * The following method is optional and only required to be 685 * The following method is optional and only required to be
726 * implemented for the SFF-8038i compatible controllers. 686 * implemented for the SFF-8038i compatible controllers.
@@ -1149,7 +1109,7 @@ void ide_fix_driveid(u16 *);
1149 1109
1150extern void ide_fixstring(u8 *, const int, const int); 1110extern void ide_fixstring(u8 *, const int, const int);
1151 1111
1152int ide_busy_sleep(ide_hwif_t *, unsigned long, int); 1112int ide_busy_sleep(ide_drive_t *, unsigned long, int);
1153 1113
1154int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 1114int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
1155 1115
@@ -1164,23 +1124,21 @@ extern int ide_devset_execute(ide_drive_t *drive,
1164void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8); 1124void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8);
1165int ide_complete_rq(ide_drive_t *, int, unsigned int); 1125int ide_complete_rq(ide_drive_t *, int, unsigned int);
1166 1126
1167void ide_tf_dump(const char *, struct ide_taskfile *); 1127void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd);
1128void ide_tf_dump(const char *, struct ide_cmd *);
1168 1129
1169void ide_exec_command(ide_hwif_t *, u8); 1130void ide_exec_command(ide_hwif_t *, u8);
1170u8 ide_read_status(ide_hwif_t *); 1131u8 ide_read_status(ide_hwif_t *);
1171u8 ide_read_altstatus(ide_hwif_t *); 1132u8 ide_read_altstatus(ide_hwif_t *);
1133void ide_write_devctl(ide_hwif_t *, u8);
1172 1134
1173void ide_set_irq(ide_hwif_t *, int); 1135void ide_dev_select(ide_drive_t *);
1174 1136void ide_tf_load(ide_drive_t *, struct ide_taskfile *, u8);
1175void ide_tf_load(ide_drive_t *, struct ide_cmd *); 1137void ide_tf_read(ide_drive_t *, struct ide_taskfile *, u8);
1176void ide_tf_read(ide_drive_t *, struct ide_cmd *);
1177 1138
1178void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int); 1139void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
1179void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int); 1140void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
1180 1141
1181int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int);
1182
1183extern void SELECT_DRIVE(ide_drive_t *);
1184void SELECT_MASK(ide_drive_t *, int); 1142void SELECT_MASK(ide_drive_t *, int);
1185 1143
1186u8 ide_read_error(ide_drive_t *); 1144u8 ide_read_error(ide_drive_t *);
@@ -1226,6 +1184,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_cmd *);
1226 1184
1227ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *); 1185ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *);
1228 1186
1187void ide_pio_bytes(ide_drive_t *, struct ide_cmd *, unsigned int, unsigned int);
1188
1229void ide_finish_cmd(ide_drive_t *, struct ide_cmd *, u8); 1189void ide_finish_cmd(ide_drive_t *, struct ide_cmd *, u8);
1230 1190
1231int ide_raw_taskfile(ide_drive_t *, struct ide_cmd *, u8 *, u16); 1191int ide_raw_taskfile(ide_drive_t *, struct ide_cmd *, u8 *, u16);
@@ -1443,8 +1403,8 @@ ide_startstop_t ide_dma_intr(ide_drive_t *);
1443int ide_allocate_dma_engine(ide_hwif_t *); 1403int ide_allocate_dma_engine(ide_hwif_t *);
1444void ide_release_dma_engine(ide_hwif_t *); 1404void ide_release_dma_engine(ide_hwif_t *);
1445 1405
1446int ide_build_sglist(ide_drive_t *, struct ide_cmd *); 1406int ide_dma_prepare(ide_drive_t *, struct ide_cmd *);
1447void ide_destroy_dmatable(ide_drive_t *); 1407void ide_dma_unmap_sg(ide_drive_t *, struct ide_cmd *);
1448 1408
1449#ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1409#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
1450int config_drive_for_dma(ide_drive_t *); 1410int config_drive_for_dma(ide_drive_t *);
@@ -1462,7 +1422,6 @@ static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
1462#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 1422#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */
1463 1423
1464void ide_dma_lost_irq(ide_drive_t *); 1424void ide_dma_lost_irq(ide_drive_t *);
1465void ide_dma_timeout(ide_drive_t *);
1466ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int); 1425ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int);
1467 1426
1468#else 1427#else
@@ -1478,8 +1437,10 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1478static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; } 1437static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
1479static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; } 1438static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
1480static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1439static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
1481static inline int ide_build_sglist(ide_drive_t *drive, 1440static inline int ide_dma_prepare(ide_drive_t *drive,
1482 struct ide_cmd *cmd) { return 0; } 1441 struct ide_cmd *cmd) { return 1; }
1442static inline void ide_dma_unmap_sg(ide_drive_t *drive,
1443 struct ide_cmd *cmd) { ; }
1483#endif /* CONFIG_BLK_DEV_IDEDMA */ 1444#endif /* CONFIG_BLK_DEV_IDEDMA */
1484 1445
1485#ifdef CONFIG_BLK_DEV_IDEACPI 1446#ifdef CONFIG_BLK_DEV_IDEACPI
@@ -1531,7 +1492,7 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
1531 1492
1532extern void ide_toggle_bounce(ide_drive_t *drive, int on); 1493extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1533 1494
1534u64 ide_get_lba_addr(struct ide_taskfile *, int); 1495u64 ide_get_lba_addr(struct ide_cmd *, int);
1535u8 ide_dump_status(ide_drive_t *, const char *, u8); 1496u8 ide_dump_status(ide_drive_t *, const char *, u8);
1536 1497
1537struct ide_timing { 1498struct ide_timing {