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.h322
1 files changed, 103 insertions, 219 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9a6a41e7079f..1e4409937ec3 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -27,25 +27,10 @@
27#include <asm/semaphore.h> 27#include <asm/semaphore.h>
28#include <asm/mutex.h> 28#include <asm/mutex.h>
29 29
30/****************************************************************************** 30#if defined(CRIS) || defined(FRV)
31 * IDE driver configuration options (play with these as desired): 31# define SUPPORT_VLB_SYNC 0
32 * 32#else
33 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary 33# define SUPPORT_VLB_SYNC 1
34 */
35#define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */
36
37#ifndef SUPPORT_SLOW_DATA_PORTS /* 1 to support slow data ports */
38#define SUPPORT_SLOW_DATA_PORTS 1 /* 0 to reduce kernel size */
39#endif
40#ifndef SUPPORT_VLB_SYNC /* 1 to support weird 32-bit chips */
41#define SUPPORT_VLB_SYNC 1 /* 0 to reduce kernel size */
42#endif
43#ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */
44#define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */
45#endif
46
47#ifndef DISABLE_IRQ_NOSYNC
48#define DISABLE_IRQ_NOSYNC 0
49#endif 34#endif
50 35
51/* 36/*
@@ -55,10 +40,6 @@
55 40
56#define IDE_NO_IRQ (-1) 41#define IDE_NO_IRQ (-1)
57 42
58/*
59 * "No user-serviceable parts" beyond this point :)
60 *****************************************************************************/
61
62typedef unsigned char byte; /* used everywhere */ 43typedef unsigned char byte; /* used everywhere */
63 44
64/* 45/*
@@ -103,8 +84,6 @@ typedef unsigned char byte; /* used everywhere */
103#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET 84#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
104#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET 85#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
105 86
106#define IDE_CONTROL_OFFSET_HOB (7)
107
108#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) 87#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
109#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) 88#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
110#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) 89#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
@@ -327,47 +306,16 @@ static inline void ide_init_hwif_ports(hw_regs_t *hw,
327typedef union { 306typedef union {
328 unsigned all : 8; 307 unsigned all : 8;
329 struct { 308 struct {
330#if defined(__LITTLE_ENDIAN_BITFIELD)
331 unsigned set_geometry : 1; 309 unsigned set_geometry : 1;
332 unsigned recalibrate : 1; 310 unsigned recalibrate : 1;
333 unsigned set_multmode : 1; 311 unsigned set_multmode : 1;
334 unsigned set_tune : 1; 312 unsigned set_tune : 1;
335 unsigned serviced : 1; 313 unsigned serviced : 1;
336 unsigned reserved : 3; 314 unsigned reserved : 3;
337#elif defined(__BIG_ENDIAN_BITFIELD)
338 unsigned reserved : 3;
339 unsigned serviced : 1;
340 unsigned set_tune : 1;
341 unsigned set_multmode : 1;
342 unsigned recalibrate : 1;
343 unsigned set_geometry : 1;
344#else
345#error "Please fix <asm/byteorder.h>"
346#endif
347 } b; 315 } b;
348} special_t; 316} special_t;
349 317
350/* 318/*
351 * ATA DATA Register Special.
352 * ATA NSECTOR Count Register().
353 * ATAPI Byte Count Register.
354 */
355typedef union {
356 unsigned all :16;
357 struct {
358#if defined(__LITTLE_ENDIAN_BITFIELD)
359 unsigned low :8; /* LSB */
360 unsigned high :8; /* MSB */
361#elif defined(__BIG_ENDIAN_BITFIELD)
362 unsigned high :8; /* MSB */
363 unsigned low :8; /* LSB */
364#else
365#error "Please fix <asm/byteorder.h>"
366#endif
367 } b;
368} ata_nsector_t, ata_data_t, atapi_bcount_t;
369
370/*
371 * ATA-IDE Select Register, aka Device-Head 319 * ATA-IDE Select Register, aka Device-Head
372 * 320 *
373 * head : always zeros here 321 * head : always zeros here
@@ -398,131 +346,6 @@ typedef union {
398} select_t, ata_select_t; 346} select_t, ata_select_t;
399 347
400/* 348/*
401 * The ATA-IDE Status Register.
402 * The ATAPI Status Register.
403 *
404 * check : Error occurred
405 * idx : Index Error
406 * corr : Correctable error occurred
407 * drq : Data is request by the device
408 * dsc : Disk Seek Complete : ata
409 * : Media access command finished : atapi
410 * df : Device Fault : ata
411 * : Reserved : atapi
412 * drdy : Ready, Command Mode Capable : ata
413 * : Ignored for ATAPI commands : atapi
414 * bsy : Disk is Busy
415 * : The device has access to the command block
416 */
417typedef union {
418 unsigned all :8;
419 struct {
420#if defined(__LITTLE_ENDIAN_BITFIELD)
421 unsigned check :1;
422 unsigned idx :1;
423 unsigned corr :1;
424 unsigned drq :1;
425 unsigned dsc :1;
426 unsigned df :1;
427 unsigned drdy :1;
428 unsigned bsy :1;
429#elif defined(__BIG_ENDIAN_BITFIELD)
430 unsigned bsy :1;
431 unsigned drdy :1;
432 unsigned df :1;
433 unsigned dsc :1;
434 unsigned drq :1;
435 unsigned corr :1;
436 unsigned idx :1;
437 unsigned check :1;
438#else
439#error "Please fix <asm/byteorder.h>"
440#endif
441 } b;
442} ata_status_t, atapi_status_t;
443
444/*
445 * ATAPI Feature Register
446 *
447 * dma : Using DMA or PIO
448 * reserved321 : Reserved
449 * reserved654 : Reserved (Tag Type)
450 * reserved7 : Reserved
451 */
452typedef union {
453 unsigned all :8;
454 struct {
455#if defined(__LITTLE_ENDIAN_BITFIELD)
456 unsigned dma :1;
457 unsigned reserved321 :3;
458 unsigned reserved654 :3;
459 unsigned reserved7 :1;
460#elif defined(__BIG_ENDIAN_BITFIELD)
461 unsigned reserved7 :1;
462 unsigned reserved654 :3;
463 unsigned reserved321 :3;
464 unsigned dma :1;
465#else
466#error "Please fix <asm/byteorder.h>"
467#endif
468 } b;
469} atapi_feature_t;
470
471/*
472 * ATAPI Interrupt Reason Register.
473 *
474 * cod : Information transferred is command (1) or data (0)
475 * io : The device requests us to read (1) or write (0)
476 * reserved : Reserved
477 */
478typedef union {
479 unsigned all :8;
480 struct {
481#if defined(__LITTLE_ENDIAN_BITFIELD)
482 unsigned cod :1;
483 unsigned io :1;
484 unsigned reserved :6;
485#elif defined(__BIG_ENDIAN_BITFIELD)
486 unsigned reserved :6;
487 unsigned io :1;
488 unsigned cod :1;
489#else
490#error "Please fix <asm/byteorder.h>"
491#endif
492 } b;
493} atapi_ireason_t;
494
495/*
496 * The ATAPI error register.
497 *
498 * ili : Illegal Length Indication
499 * eom : End Of Media Detected
500 * abrt : Aborted command - As defined by ATA
501 * mcr : Media Change Requested - As defined by ATA
502 * sense_key : Sense key of the last failed packet command
503 */
504typedef union {
505 unsigned all :8;
506 struct {
507#if defined(__LITTLE_ENDIAN_BITFIELD)
508 unsigned ili :1;
509 unsigned eom :1;
510 unsigned abrt :1;
511 unsigned mcr :1;
512 unsigned sense_key :4;
513#elif defined(__BIG_ENDIAN_BITFIELD)
514 unsigned sense_key :4;
515 unsigned mcr :1;
516 unsigned abrt :1;
517 unsigned eom :1;
518 unsigned ili :1;
519#else
520#error "Please fix <asm/byteorder.h>"
521#endif
522 } b;
523} atapi_error_t;
524
525/*
526 * Status returned from various ide_ functions 349 * Status returned from various ide_ functions
527 */ 350 */
528typedef enum { 351typedef enum {
@@ -701,8 +524,6 @@ typedef struct hwif_s {
701 void (*pre_reset)(ide_drive_t *); 524 void (*pre_reset)(ide_drive_t *);
702 /* routine to reset controller after a disk reset */ 525 /* routine to reset controller after a disk reset */
703 void (*resetproc)(ide_drive_t *); 526 void (*resetproc)(ide_drive_t *);
704 /* special interrupt handling for shared pci interrupts */
705 void (*intrproc)(ide_drive_t *);
706 /* special host masking for drive selection */ 527 /* special host masking for drive selection */
707 void (*maskproc)(ide_drive_t *, int); 528 void (*maskproc)(ide_drive_t *, int);
708 /* check host's drive quirk list */ 529 /* check host's drive quirk list */
@@ -766,7 +587,6 @@ typedef struct hwif_s {
766 int rqsize; /* max sectors per request */ 587 int rqsize; /* max sectors per request */
767 int irq; /* our irq number */ 588 int irq; /* our irq number */
768 589
769 unsigned long dma_master; /* reference base addr dmabase */
770 unsigned long dma_base; /* base addr for dma ports */ 590 unsigned long dma_base; /* base addr for dma ports */
771 unsigned long dma_command; /* dma command register */ 591 unsigned long dma_command; /* dma command register */
772 unsigned long dma_vendor1; /* dma vendor 1 register */ 592 unsigned long dma_vendor1; /* dma vendor 1 register */
@@ -806,7 +626,6 @@ typedef struct hwif_s {
806/* 626/*
807 * internal ide interrupt handler type 627 * internal ide interrupt handler type
808 */ 628 */
809typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *);
810typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); 629typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
811typedef int (ide_expiry_t)(ide_drive_t *); 630typedef int (ide_expiry_t)(ide_drive_t *);
812 631
@@ -1020,7 +839,8 @@ int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
1020 839
1021extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry); 840extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry);
1022 841
1023extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *); 842void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int,
843 ide_expiry_t *);
1024 844
1025ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); 845ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
1026 846
@@ -1062,52 +882,114 @@ extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
1062 */ 882 */
1063extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *); 883extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);
1064 884
885enum {
886 IDE_TFLAG_LBA48 = (1 << 0),
887 IDE_TFLAG_NO_SELECT_MASK = (1 << 1),
888 IDE_TFLAG_FLAGGED = (1 << 2),
889 IDE_TFLAG_OUT_DATA = (1 << 3),
890 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
891 IDE_TFLAG_OUT_HOB_NSECT = (1 << 5),
892 IDE_TFLAG_OUT_HOB_LBAL = (1 << 6),
893 IDE_TFLAG_OUT_HOB_LBAM = (1 << 7),
894 IDE_TFLAG_OUT_HOB_LBAH = (1 << 8),
895 IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
896 IDE_TFLAG_OUT_HOB_NSECT |
897 IDE_TFLAG_OUT_HOB_LBAL |
898 IDE_TFLAG_OUT_HOB_LBAM |
899 IDE_TFLAG_OUT_HOB_LBAH,
900 IDE_TFLAG_OUT_FEATURE = (1 << 9),
901 IDE_TFLAG_OUT_NSECT = (1 << 10),
902 IDE_TFLAG_OUT_LBAL = (1 << 11),
903 IDE_TFLAG_OUT_LBAM = (1 << 12),
904 IDE_TFLAG_OUT_LBAH = (1 << 13),
905 IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
906 IDE_TFLAG_OUT_NSECT |
907 IDE_TFLAG_OUT_LBAL |
908 IDE_TFLAG_OUT_LBAM |
909 IDE_TFLAG_OUT_LBAH,
910 IDE_TFLAG_OUT_DEVICE = (1 << 14),
911 IDE_TFLAG_WRITE = (1 << 15),
912 IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16),
913 IDE_TFLAG_IN_DATA = (1 << 17),
914 IDE_TFLAG_CUSTOM_HANDLER = (1 << 18),
915 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19),
916 IDE_TFLAG_IN_HOB_FEATURE = (1 << 20),
917 IDE_TFLAG_IN_HOB_NSECT = (1 << 21),
918 IDE_TFLAG_IN_HOB_LBAL = (1 << 22),
919 IDE_TFLAG_IN_HOB_LBAM = (1 << 23),
920 IDE_TFLAG_IN_HOB_LBAH = (1 << 24),
921 IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
922 IDE_TFLAG_IN_HOB_LBAM |
923 IDE_TFLAG_IN_HOB_LBAH,
924 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
925 IDE_TFLAG_IN_HOB_NSECT |
926 IDE_TFLAG_IN_HOB_LBA,
927 IDE_TFLAG_IN_NSECT = (1 << 25),
928 IDE_TFLAG_IN_LBAL = (1 << 26),
929 IDE_TFLAG_IN_LBAM = (1 << 27),
930 IDE_TFLAG_IN_LBAH = (1 << 28),
931 IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
932 IDE_TFLAG_IN_LBAM |
933 IDE_TFLAG_IN_LBAH,
934 IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
935 IDE_TFLAG_IN_LBA,
936 IDE_TFLAG_IN_DEVICE = (1 << 29),
937};
938
939struct ide_taskfile {
940 u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */
941
942 u8 hob_feature; /* 1-5: additional data to support LBA48 */
943 u8 hob_nsect;
944 u8 hob_lbal;
945 u8 hob_lbam;
946 u8 hob_lbah;
947
948 u8 data; /* 6: low data byte (for TASKFILE IOCTL) */
949
950 union { /*  7: */
951 u8 error; /* read: error */
952 u8 feature; /* write: feature */
953 };
954
955 u8 nsect; /* 8: number of sectors */
956 u8 lbal; /* 9: LBA low */
957 u8 lbam; /* 10: LBA mid */
958 u8 lbah; /* 11: LBA high */
959
960 u8 device; /* 12: device select */
961
962 union { /* 13: */
963 u8 status; /*  read: status  */
964 u8 command; /* write: command */
965 };
966};
967
1065typedef struct ide_task_s { 968typedef struct ide_task_s {
1066/* 969 union {
1067 * struct hd_drive_task_hdr tf; 970 struct ide_taskfile tf;
1068 * task_struct_t tf; 971 u8 tf_array[14];
1069 * struct hd_drive_hob_hdr hobf; 972 };
1070 * hob_struct_t hobf; 973 u32 tf_flags;
1071 */
1072 task_ioreg_t tfRegister[8];
1073 task_ioreg_t hobRegister[8];
1074 ide_reg_valid_t tf_out_flags;
1075 ide_reg_valid_t tf_in_flags;
1076 int data_phase; 974 int data_phase;
1077 int command_type;
1078 ide_pre_handler_t *prehandler;
1079 ide_handler_t *handler;
1080 struct request *rq; /* copy of request */ 975 struct request *rq; /* copy of request */
1081 void *special; /* valid_t generally */ 976 void *special; /* valid_t generally */
1082} ide_task_t; 977} ide_task_t;
1083 978
1084extern u32 ide_read_24(ide_drive_t *); 979void ide_tf_load(ide_drive_t *, ide_task_t *);
980void ide_tf_read(ide_drive_t *, ide_task_t *);
1085 981
1086extern void SELECT_DRIVE(ide_drive_t *); 982extern void SELECT_DRIVE(ide_drive_t *);
1087extern void SELECT_INTERRUPT(ide_drive_t *);
1088extern void SELECT_MASK(ide_drive_t *, int); 983extern void SELECT_MASK(ide_drive_t *, int);
1089extern void QUIRK_LIST(ide_drive_t *);
1090 984
1091extern int drive_is_ready(ide_drive_t *); 985extern int drive_is_ready(ide_drive_t *);
1092 986
1093/* 987void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
1094 * taskfile io for disks for now...and builds request from ide_ioctl
1095 */
1096extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1097
1098/*
1099 * Special Flagged Register Validation Caller
1100 */
1101extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);
1102 988
1103extern ide_startstop_t set_multmode_intr(ide_drive_t *); 989ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1104extern ide_startstop_t set_geometry_intr(ide_drive_t *);
1105extern ide_startstop_t recal_intr(ide_drive_t *);
1106extern ide_startstop_t task_no_data_intr(ide_drive_t *);
1107extern ide_startstop_t task_in_intr(ide_drive_t *);
1108extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
1109 990
1110extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *); 991int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16);
992int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);
1111 993
1112int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); 994int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
1113int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); 995int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
@@ -1212,6 +1094,7 @@ enum {
1212 IDE_HFLAG_IO_32BIT = (1 << 24), 1094 IDE_HFLAG_IO_32BIT = (1 << 24),
1213 /* unmask IRQs */ 1095 /* unmask IRQs */
1214 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1096 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1097 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1215}; 1098};
1216 1099
1217#ifdef CONFIG_BLK_DEV_OFFBOARD 1100#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1229,7 +1112,7 @@ struct ide_port_info {
1229 void (*fixup)(ide_hwif_t *); 1112 void (*fixup)(ide_hwif_t *);
1230 ide_pci_enablebit_t enablebits[2]; 1113 ide_pci_enablebit_t enablebits[2];
1231 hwif_chipset_t chipset; 1114 hwif_chipset_t chipset;
1232 unsigned int extra; 1115 u8 extra;
1233 u32 host_flags; 1116 u32 host_flags;
1234 u8 pio_mask; 1117 u8 pio_mask;
1235 u8 swdma_mask; 1118 u8 swdma_mask;
@@ -1356,6 +1239,7 @@ static inline int ide_dev_is_sata(struct hd_driveid *id)
1356 return 0; 1239 return 0;
1357} 1240}
1358 1241
1242u64 ide_get_lba_addr(struct ide_taskfile *, int);
1359u8 ide_dump_status(ide_drive_t *, const char *, u8); 1243u8 ide_dump_status(ide_drive_t *, const char *, u8);
1360 1244
1361typedef struct ide_pio_timings_s { 1245typedef struct ide_pio_timings_s {