Merge branch 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
[safe/jmp/linux-2.6] / include / linux / ide.h
index d3035f2..867cb68 100644 (file)
@@ -26,6 +26,9 @@
 #include <asm/io.h>
 #include <asm/mutex.h>
 
+/* for request_sense */
+#include <linux/cdrom.h>
+
 #if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
 # define SUPPORT_VLB_SYNC 0
 #else
@@ -240,65 +243,38 @@ typedef enum {
 } ide_startstop_t;
 
 enum {
+       IDE_VALID_ERROR                 = (1 << 1),
+       IDE_VALID_FEATURE               = IDE_VALID_ERROR,
+       IDE_VALID_NSECT                 = (1 << 2),
+       IDE_VALID_LBAL                  = (1 << 3),
+       IDE_VALID_LBAM                  = (1 << 4),
+       IDE_VALID_LBAH                  = (1 << 5),
+       IDE_VALID_DEVICE                = (1 << 6),
+       IDE_VALID_LBA                   = IDE_VALID_LBAL |
+                                         IDE_VALID_LBAM |
+                                         IDE_VALID_LBAH,
+       IDE_VALID_OUT_TF                = IDE_VALID_FEATURE |
+                                         IDE_VALID_NSECT |
+                                         IDE_VALID_LBA,
+       IDE_VALID_IN_TF                 = IDE_VALID_NSECT |
+                                         IDE_VALID_LBA,
+       IDE_VALID_OUT_HOB               = IDE_VALID_OUT_TF,
+       IDE_VALID_IN_HOB                = IDE_VALID_ERROR |
+                                         IDE_VALID_NSECT |
+                                         IDE_VALID_LBA,
+};
+
+enum {
        IDE_TFLAG_LBA48                 = (1 << 0),
-       IDE_TFLAG_OUT_HOB_FEATURE       = (1 << 1),
-       IDE_TFLAG_OUT_HOB_NSECT         = (1 << 2),
-       IDE_TFLAG_OUT_HOB_LBAL          = (1 << 3),
-       IDE_TFLAG_OUT_HOB_LBAM          = (1 << 4),
-       IDE_TFLAG_OUT_HOB_LBAH          = (1 << 5),
-       IDE_TFLAG_OUT_HOB               = IDE_TFLAG_OUT_HOB_FEATURE |
-                                         IDE_TFLAG_OUT_HOB_NSECT |
-                                         IDE_TFLAG_OUT_HOB_LBAL |
-                                         IDE_TFLAG_OUT_HOB_LBAM |
-                                         IDE_TFLAG_OUT_HOB_LBAH,
-       IDE_TFLAG_OUT_FEATURE           = (1 << 6),
-       IDE_TFLAG_OUT_NSECT             = (1 << 7),
-       IDE_TFLAG_OUT_LBAL              = (1 << 8),
-       IDE_TFLAG_OUT_LBAM              = (1 << 9),
-       IDE_TFLAG_OUT_LBAH              = (1 << 10),
-       IDE_TFLAG_OUT_TF                = IDE_TFLAG_OUT_FEATURE |
-                                         IDE_TFLAG_OUT_NSECT |
-                                         IDE_TFLAG_OUT_LBAL |
-                                         IDE_TFLAG_OUT_LBAM |
-                                         IDE_TFLAG_OUT_LBAH,
-       IDE_TFLAG_OUT_DEVICE            = (1 << 11),
-       IDE_TFLAG_WRITE                 = (1 << 12),
-       IDE_TFLAG_CUSTOM_HANDLER        = (1 << 13),
-       IDE_TFLAG_DMA_PIO_FALLBACK      = (1 << 14),
-       IDE_TFLAG_IN_HOB_FEATURE        = (1 << 15),
-       IDE_TFLAG_IN_HOB_NSECT          = (1 << 16),
-       IDE_TFLAG_IN_HOB_LBAL           = (1 << 17),
-       IDE_TFLAG_IN_HOB_LBAM           = (1 << 18),
-       IDE_TFLAG_IN_HOB_LBAH           = (1 << 19),
-       IDE_TFLAG_IN_HOB_LBA            = IDE_TFLAG_IN_HOB_LBAL |
-                                         IDE_TFLAG_IN_HOB_LBAM |
-                                         IDE_TFLAG_IN_HOB_LBAH,
-       IDE_TFLAG_IN_HOB                = IDE_TFLAG_IN_HOB_FEATURE |
-                                         IDE_TFLAG_IN_HOB_NSECT |
-                                         IDE_TFLAG_IN_HOB_LBA,
-       IDE_TFLAG_IN_FEATURE            = (1 << 20),
-       IDE_TFLAG_IN_NSECT              = (1 << 21),
-       IDE_TFLAG_IN_LBAL               = (1 << 22),
-       IDE_TFLAG_IN_LBAM               = (1 << 23),
-       IDE_TFLAG_IN_LBAH               = (1 << 24),
-       IDE_TFLAG_IN_LBA                = IDE_TFLAG_IN_LBAL |
-                                         IDE_TFLAG_IN_LBAM |
-                                         IDE_TFLAG_IN_LBAH,
-       IDE_TFLAG_IN_TF                 = IDE_TFLAG_IN_NSECT |
-                                         IDE_TFLAG_IN_LBA,
-       IDE_TFLAG_IN_DEVICE             = (1 << 25),
-       IDE_TFLAG_HOB                   = IDE_TFLAG_OUT_HOB |
-                                         IDE_TFLAG_IN_HOB,
-       IDE_TFLAG_TF                    = IDE_TFLAG_OUT_TF |
-                                         IDE_TFLAG_IN_TF,
-       IDE_TFLAG_DEVICE                = IDE_TFLAG_OUT_DEVICE |
-                                         IDE_TFLAG_IN_DEVICE,
+       IDE_TFLAG_WRITE                 = (1 << 1),
+       IDE_TFLAG_CUSTOM_HANDLER        = (1 << 2),
+       IDE_TFLAG_DMA_PIO_FALLBACK      = (1 << 3),
        /* force 16-bit I/O operations */
-       IDE_TFLAG_IO_16BIT              = (1 << 26),
+       IDE_TFLAG_IO_16BIT              = (1 << 4),
        /* struct ide_cmd was allocated using kmalloc() */
-       IDE_TFLAG_DYN                   = (1 << 27),
-       IDE_TFLAG_FS                    = (1 << 28),
-       IDE_TFLAG_MULTI_PIO             = (1 << 29),
+       IDE_TFLAG_DYN                   = (1 << 5),
+       IDE_TFLAG_FS                    = (1 << 6),
+       IDE_TFLAG_MULTI_PIO             = (1 << 7),
 };
 
 enum {
@@ -309,41 +285,34 @@ enum {
 };
 
 struct ide_taskfile {
-       u8      hob_data;       /*  0: high data byte (for TASKFILE IOCTL) */
-
-       u8      hob_feature;    /*  1-5: additional data to support LBA48 */
-       u8      hob_nsect;
-       u8      hob_lbal;
-       u8      hob_lbam;
-       u8      hob_lbah;
-
-       u8      data;           /*  6: low data byte (for TASKFILE IOCTL) */
-
-       union {                 /*  7: */
-               u8 error;       /*   read:  error */
-               u8 feature;     /*  write: feature */
+       u8      data;           /* 0: data byte (for TASKFILE ioctl) */
+       union {                 /* 1: */
+               u8 error;       /*  read: error */
+               u8 feature;     /* write: feature */
        };
-
-       u8      nsect;          /*  8: number of sectors */
-       u8      lbal;           /*  9: LBA low */
-       u8      lbam;           /* 10: LBA mid */
-       u8      lbah;           /* 11: LBA high */
-
-       u8      device;         /* 12: device select */
-
-       union {                 /* 13: */
-               u8 status;      /*  read: status  */
+       u8      nsect;          /* 2: number of sectors */
+       u8      lbal;           /* 3: LBA low */
+       u8      lbam;           /* 4: LBA mid */
+       u8      lbah;           /* 5: LBA high */
+       u8      device;         /* 6: device select */
+       union {                 /* 7: */
+               u8 status;      /*  read: status */
                u8 command;     /* write: command */
        };
 };
 
 struct ide_cmd {
-       union {
-               struct ide_taskfile     tf;
-               u8                      tf_array[14];
-       };
+       struct ide_taskfile     tf;
+       struct ide_taskfile     hob;
+       struct {
+               struct {
+                       u8              tf;
+                       u8              hob;
+               } out, in;
+       } valid;
+
+       u8                      tf_flags;
        u8                      ftf_flags;      /* for TASKFILE ioctl */
-       u32                     tf_flags;
        int                     protocol;
 
        int                     sg_nents;         /* number of sg entries */
@@ -358,7 +327,6 @@ struct ide_cmd {
        unsigned int            cursg_ofs;
 
        struct request          *rq;            /* copy of request */
-       void                    *special;       /* valid_t generally */
 };
 
 /* ATAPI packet command flags */
@@ -377,7 +345,7 @@ enum {
  * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes.
  * This is used for several packet commands (not for READ/WRITE commands).
  */
-#define IDE_PC_BUFFER_SIZE     256
+#define IDE_PC_BUFFER_SIZE     64
 #define ATAPI_WAIT_PC          (60 * HZ)
 
 struct ide_atapi_pc {
@@ -394,11 +362,7 @@ struct ide_atapi_pc {
 
        /* data buffer */
        u8 *buf;
-       /* current buffer position */
-       u8 *cur_pos;
        int buf_size;
-       /* missing/available data on the current buffer */
-       int b_count;
 
        /* the corresponding request */
        struct request *rq;
@@ -411,13 +375,6 @@ struct ide_atapi_pc {
         */
        u8 pc_buf[IDE_PC_BUFFER_SIZE];
 
-       /* idetape only */
-       struct idetape_bh *bh;
-       char *b_data;
-
-       struct scatterlist *sg;
-       unsigned int sg_cnt;
-
        unsigned long timeout;
 };
 
@@ -602,7 +559,7 @@ struct ide_drive_s {
 
        unsigned int    bios_cyl;       /* BIOS/fdisk/LILO number of cyls */
        unsigned int    cyl;            /* "real" number of cyls */
-       unsigned int    drive_data;     /* used by set_pio_mode/selectproc */
+       unsigned int    drive_data;     /* used by set_pio_mode/dev_select() */
        unsigned int    failures;       /* current failure count */
        unsigned int    max_failures;   /* maximum allowed failure count */
        u64             probed_capacity;/* initial reported media capacity (ide-cd only currently) */
@@ -630,16 +587,16 @@ struct ide_drive_s {
        /* callback for packet commands */
        int  (*pc_callback)(struct ide_drive_s *, int);
 
-       void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *);
-       int  (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *,
-                             unsigned int, int);
-
        ide_startstop_t (*irq_handler)(struct ide_drive_s *);
 
        unsigned long atapi_flags;
 
        struct ide_atapi_pc request_sense_pc;
-       struct request request_sense_rq;
+
+       /* current sense rq and buffer */
+       bool sense_rq_armed;
+       struct request sense_rq;
+       struct request_sense sense_data;
 };
 
 typedef struct ide_drive_s ide_drive_t;
@@ -658,11 +615,11 @@ struct ide_tp_ops {
        void    (*exec_command)(struct hwif_s *, u8);
        u8      (*read_status)(struct hwif_s *);
        u8      (*read_altstatus)(struct hwif_s *);
+       void    (*write_devctl)(struct hwif_s *, u8);
 
-       void    (*set_irq)(struct hwif_s *, int);
-
-       void    (*tf_load)(ide_drive_t *, struct ide_cmd *);
-       void    (*tf_read)(ide_drive_t *, struct ide_cmd *);
+       void    (*dev_select)(ide_drive_t *);
+       void    (*tf_load)(ide_drive_t *, struct ide_taskfile *, u8);
+       void    (*tf_read)(ide_drive_t *, struct ide_taskfile *, u8);
 
        void    (*input_data)(ide_drive_t *, struct ide_cmd *,
                              void *, unsigned int);
@@ -678,7 +635,6 @@ extern const struct ide_tp_ops default_tp_ops;
  * @init_dev:          host specific initialization of a device
  * @set_pio_mode:      routine to program host for PIO mode
  * @set_dma_mode:      routine to program host for DMA mode
- * @selectproc:                tweaks hardware to select drive
  * @reset_poll:                chipset polling based on hba specifics
  * @pre_reset:         chipset specific changes to default for device-hba resets
  * @resetproc:         routine to reset controller after a disk reset
@@ -695,7 +651,6 @@ struct ide_port_ops {
        void    (*init_dev)(ide_drive_t *);
        void    (*set_pio_mode)(ide_drive_t *, const u8);
        void    (*set_dma_mode)(ide_drive_t *, const u8);
-       void    (*selectproc)(ide_drive_t *);
        int     (*reset_poll)(ide_drive_t *);
        void    (*pre_reset)(ide_drive_t *);
        void    (*resetproc)(ide_drive_t *);
@@ -717,6 +672,7 @@ struct ide_dma_ops {
        int     (*dma_test_irq)(struct ide_drive_s *);
        void    (*dma_lost_irq)(struct ide_drive_s *);
        /* below ones are optional */
+       int     (*dma_check)(struct ide_drive_s *, struct ide_cmd *);
        int     (*dma_timer_expiry)(struct ide_drive_s *);
        void    (*dma_clear)(struct ide_drive_s *);
        /*
@@ -1147,7 +1103,7 @@ void ide_fix_driveid(u16 *);
 
 extern void ide_fixstring(u8 *, const int, const int);
 
-int ide_busy_sleep(ide_hwif_t *, unsigned long, int);
+int ide_busy_sleep(ide_drive_t *, unsigned long, int);
 
 int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
 
@@ -1162,23 +1118,21 @@ extern int ide_devset_execute(ide_drive_t *drive,
 void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8);
 int ide_complete_rq(ide_drive_t *, int, unsigned int);
 
-void ide_tf_dump(const char *, struct ide_taskfile *);
+void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd);
+void ide_tf_dump(const char *, struct ide_cmd *);
 
 void ide_exec_command(ide_hwif_t *, u8);
 u8 ide_read_status(ide_hwif_t *);
 u8 ide_read_altstatus(ide_hwif_t *);
+void ide_write_devctl(ide_hwif_t *, u8);
 
-void ide_set_irq(ide_hwif_t *, int);
-
-void ide_tf_load(ide_drive_t *, struct ide_cmd *);
-void ide_tf_read(ide_drive_t *, struct ide_cmd *);
+void ide_dev_select(ide_drive_t *);
+void ide_tf_load(ide_drive_t *, struct ide_taskfile *, u8);
+void ide_tf_read(ide_drive_t *, struct ide_taskfile *, u8);
 
 void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
 void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
 
-int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int);
-
-extern void SELECT_DRIVE(ide_drive_t *);
 void SELECT_MASK(ide_drive_t *, int);
 
 u8 ide_read_error(ide_drive_t *);
@@ -1214,7 +1168,10 @@ int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
 int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
 int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
 void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
-void ide_retry_pc(ide_drive_t *, struct gendisk *);
+void ide_retry_pc(ide_drive_t *drive);
+
+void ide_prep_sense(ide_drive_t *drive, struct request *rq);
+int ide_queue_sense_rq(ide_drive_t *drive, void *special);
 
 int ide_cd_expiry(ide_drive_t *);
 
@@ -1443,8 +1400,8 @@ ide_startstop_t ide_dma_intr(ide_drive_t *);
 int ide_allocate_dma_engine(ide_hwif_t *);
 void ide_release_dma_engine(ide_hwif_t *);
 
-int ide_build_sglist(ide_drive_t *, struct ide_cmd *);
-void ide_destroy_dmatable(ide_drive_t *);
+int ide_dma_prepare(ide_drive_t *, struct ide_cmd *);
+void ide_dma_unmap_sg(ide_drive_t *, struct ide_cmd *);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_SFF
 int config_drive_for_dma(ide_drive_t *);
@@ -1477,8 +1434,10 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
 static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
 static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
 static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
-static inline int ide_build_sglist(ide_drive_t *drive,
-                                  struct ide_cmd *cmd) { return 0; }
+static inline int ide_dma_prepare(ide_drive_t *drive,
+                                 struct ide_cmd *cmd) { return 1; }
+static inline void ide_dma_unmap_sg(ide_drive_t *drive,
+                                   struct ide_cmd *cmd) { ; }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
 #ifdef CONFIG_BLK_DEV_IDEACPI
@@ -1530,7 +1489,7 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
 
 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
 
-u64 ide_get_lba_addr(struct ide_taskfile *, int);
+u64 ide_get_lba_addr(struct ide_cmd *, int);
 u8 ide_dump_status(ide_drive_t *, const char *, u8);
 
 struct ide_timing {