vserver 1.9.3
[linux-2.6.git] / include / linux / ide.h
index aa2e86d..f6a3937 100644 (file)
 #ifndef OK_TO_RESET_CONTROLLER         /* 1 needed for good error recovery */
 #define OK_TO_RESET_CONTROLLER 1       /* 0 for use with AH2372A/B interface */
 #endif
-#ifndef FANCY_STATUS_DUMPS             /* 1 for human-readable drive errors */
-#define FANCY_STATUS_DUMPS     1       /* 0 to reduce kernel size */
-#endif
-
-#ifdef CONFIG_BLK_DEV_CMD640
-#if 0  /* change to 1 when debugging cmd640 problems */
-void cmd640_dump_regs (void);
-#define CMD640_DUMP_REGS cmd640_dump_regs() /* for debugging cmd640 chipset */
-#endif
-#endif  /* CONFIG_BLK_DEV_CMD640 */
 
 #ifndef DISABLE_IRQ_NOSYNC
 #define DISABLE_IRQ_NOSYNC     0
@@ -255,7 +245,7 @@ typedef enum {      ide_unknown,    ide_generic,    ide_pci,
                ide_pdc4030,    ide_rz1000,     ide_trm290,
                ide_cmd646,     ide_cy82c693,   ide_4drives,
                ide_pmac,       ide_etrax100,   ide_acorn,
-               ide_pc9800,     ide_forced
+               ide_forced
 } hwif_chipset_t;
 
 /*
@@ -305,20 +295,25 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
 
 #include <asm/ide.h>
 
+/* needed on alpha, x86/x86_64, ia64, mips, ppc32 and sh */
+#ifndef IDE_ARCH_OBSOLETE_DEFAULTS
+# define ide_default_io_base(index)    (0)
+# define ide_default_irq(base)         (0)
+# define ide_init_default_irq(base)    (0)
+#endif
+
 /*
  * ide_init_hwif_ports() is OBSOLETE and will be removed in 2.7 series.
- *
- * arm26, arm, h8300, m68k, m68knommu (broken) and i386-pc9800 (broken)
- * still have their own versions.
+ * New ports shouldn't define IDE_ARCH_OBSOLETE_INIT in <asm/ide.h>.
  */
-#if !defined(CONFIG_ARM) && !defined(CONFIG_H8300) && !defined(CONFIG_M68K)
+#ifdef IDE_ARCH_OBSOLETE_INIT
 static inline void ide_init_hwif_ports(hw_regs_t *hw,
                                       unsigned long io_addr,
                                       unsigned long ctl_addr,
                                       int *irq)
 {
        if (!ctl_addr)
-               ide_std_init_ports(hw, io_addr, io_addr + 0x206);
+               ide_std_init_ports(hw, io_addr, ide_default_io_ctl(io_addr));
        else
                ide_std_init_ports(hw, io_addr, ctl_addr);
 
@@ -332,7 +327,16 @@ static inline void ide_init_hwif_ports(hw_regs_t *hw,
                ppc_ide_md.ide_init_hwif(hw, io_addr, ctl_addr, irq);
 #endif
 }
-#endif /* !ARM && !H8300 && !M68K */
+#else
+static inline void ide_init_hwif_ports(hw_regs_t *hw,
+                                      unsigned long io_addr,
+                                      unsigned long ctl_addr,
+                                      int *irq)
+{
+       if (io_addr || ctl_addr)
+               printk(KERN_WARNING "%s: must not be called\n", __FUNCTION__);
+}
+#endif /* IDE_ARCH_OBSOLETE_INIT */
 
 /* Currently only m68k, apus and m8xx need it */
 #ifndef IDE_ARCH_ACK_INTR
@@ -676,7 +680,6 @@ typedef union {
 typedef enum {
        ide_stopped,    /* no drive operation was started */
        ide_started,    /* a drive operation was started, handler was set */
-       ide_released,   /* as ide_started, but bus also released */
 } ide_startstop_t;
 
 struct ide_driver_s;
@@ -710,7 +713,6 @@ typedef struct ide_drive_s {
        u8      keep_settings;          /* restore settings after drive reset */
        u8      autodma;                /* device can safely use dma on host */
        u8      using_dma;              /* disk is using dma for read/write */
-       u8      using_tcq;              /* disk is using queueing */
        u8      retry_pio;              /* retrying dma capable host in pio */
        u8      state;                  /* retry state */
        u8      waiting_for_dma;        /* dma currently in progress */
@@ -737,14 +739,15 @@ typedef struct ide_drive_s {
        unsigned remap_0_to_1   : 1;    /* 0=noremap, 1=remap 0->1 (for EZDrive) */
        unsigned blocked        : 1;    /* 1=powermanagment told us not to do anything, so sleep nicely */
        unsigned vdma           : 1;    /* 1=doing PIO over DMA 0=doing normal DMA */
+       unsigned stroke         : 1;    /* from:  hdx=stroke */
        unsigned addressing;            /*      : 3;
                                         *  0=28-bit
                                         *  1=48-bit
                                         *  2=48-bit doing 28-bit
                                         *  3=64-bit
                                         */
+       unsigned scsi           : 1;    /* 0=default, 1=ide-scsi emulation */
 
-       u8      scsi;           /* 0=default, 1=skip current ide-subdriver for ide-scsi emulation */
         u8     quirk_list;     /* considered quirky, set for a specific host */
         u8     suspend_reset;  /* drive suspend mode flag, soft-reset recovers */
         u8     init_speed;     /* transfer rate set at boot */
@@ -767,7 +770,7 @@ typedef struct ide_drive_s {
        u8      sect;           /* "real" sectors per track */
        u8      bios_head;      /* BIOS/fdisk/LILO number of heads */
        u8      bios_sect;      /* BIOS/fdisk/LILO sectors per track */
-       u8      queue_depth;    /* max queue depth */
+       u8      doing_barrier;  /* state, 1=currently doing flush */
 
        unsigned int    bios_cyl;       /* BIOS/fdisk/LILO number of cyls */
        unsigned int    cyl;            /* "real" number of cyls */
@@ -786,31 +789,6 @@ typedef struct ide_drive_s {
        struct gendisk *disk;
 } ide_drive_t;
 
-typedef struct ide_pio_ops_s {
-       void (*ata_input_data)(ide_drive_t *, void *, u32);
-       void (*ata_output_data)(ide_drive_t *, void *, u32);
-
-       void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
-       void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
-} ide_pio_ops_t;
-
-typedef struct ide_dma_ops_s {
-       /* insert dma operations here! */
-       int (*ide_dma_read)(ide_drive_t *drive);
-       int (*ide_dma_write)(ide_drive_t *drive);
-       int (*ide_dma_begin)(ide_drive_t *drive);
-       int (*ide_dma_end)(ide_drive_t *drive);
-       int (*ide_dma_check)(ide_drive_t *drive);
-       int (*ide_dma_on)(ide_drive_t *drive);
-       int (*ide_dma_off_quietly)(ide_drive_t *drive);
-       int (*ide_dma_test_irq)(ide_drive_t *drive);
-       int (*ide_dma_host_on)(ide_drive_t *drive);
-       int (*ide_dma_host_off)(ide_drive_t *drive);
-       int (*ide_dma_verbose)(ide_drive_t *drive);
-       int (*ide_dma_lostirq)(ide_drive_t *drive);
-       int (*ide_dma_timeout)(ide_drive_t *drive);
-} ide_dma_ops_t;
-
 /*
  * mapping stuff, prepare for highmem...
  * 
@@ -821,30 +799,14 @@ typedef struct ide_dma_ops_s {
 #define ide_rq_offset(rq) \
        (((rq)->hard_cur_sectors - (rq)->current_nr_sectors) << 9)
 
-/*
- * taskfiles really should use hard_cur_sectors as well!
- */
-#define task_rq_offset(rq) \
-       (((rq)->nr_sectors - (rq)->current_nr_sectors) * SECTOR_SIZE)
-
 static inline void *ide_map_buffer(struct request *rq, unsigned long *flags)
 {
-       /*
-        * fs request
-        */
-       if (rq->bio)
-               return bio_kmap_irq(rq->bio, flags) + ide_rq_offset(rq);
-
-       /*
-        * task request
-        */
-       return rq->buffer + task_rq_offset(rq);
+       return bio_kmap_irq(rq->bio, flags) + ide_rq_offset(rq);
 }
 
 static inline void ide_unmap_buffer(struct request *rq, char *buffer, unsigned long *flags)
 {
-       if (rq->bio)
-               bio_kunmap_irq(buffer, flags);
+       bio_kunmap_irq(buffer, flags);
 }
 #endif /* !CONFIG_IDE_TASKFILE_IO */
 
@@ -919,15 +881,11 @@ typedef struct hwif_s {
 //     u8      (*ratefilter)(ide_drive_t *, u8);
 #endif
 
-#if 0
-       ide_pio_ops_t   *pioops;
-#else
        void (*ata_input_data)(ide_drive_t *, void *, u32);
        void (*ata_output_data)(ide_drive_t *, void *, u32);
 
        void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
        void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
-#endif
 
        int (*ide_dma_read)(ide_drive_t *drive);
        int (*ide_dma_write)(ide_drive_t *drive);
@@ -964,7 +922,9 @@ typedef struct hwif_s {
        struct scatterlist *sg_table;
        int sg_nents;                   /* Current number of entries in it */
        int sg_dma_direction;           /* dma transfer direction */
-       int sg_dma_active;              /* is it in use */
+
+       /* data phase of the active command (currently only valid for PIO/DMA) */
+       int             data_phase;
 
        int             mmio;           /* hosts iomio (0) or custom (2) select */
        int             rqsize;         /* max sectors per request */
@@ -992,6 +952,7 @@ typedef struct hwif_s {
        unsigned        autodma    : 1; /* auto-attempt using DMA at boot */
        unsigned        udma_four  : 1; /* 1=ATA-66 capable, 0=default */
        unsigned        no_lba48   : 1; /* 1 = cannot do LBA48 */
+       unsigned        no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */
        unsigned        no_dsc     : 1; /* 0 default, 1 dsc_overlap disabled */
        unsigned        auto_poll  : 1; /* supports nop auto-poll */
 
@@ -1081,7 +1042,6 @@ typedef struct ide_settings_s {
 
 extern struct semaphore ide_setting_sem;
 extern int ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set);
-extern void ide_remove_setting(ide_drive_t *drive, char *name);
 extern ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name);
 extern int ide_read_setting(ide_drive_t *t, ide_settings_t *setting);
 extern int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val);
@@ -1102,7 +1062,6 @@ extern struct proc_dir_entry *proc_ide_root;
 
 extern void proc_ide_create(void);
 extern void proc_ide_destroy(void);
-extern void destroy_proc_ide_device(ide_hwif_t *, ide_drive_t *);
 extern void destroy_proc_ide_drives(ide_hwif_t *);
 extern void create_proc_ide_interfaces(void);
 extern void ide_add_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *, void *);
@@ -1200,7 +1159,7 @@ typedef struct ide_driver_s {
 
 #define DRIVER(drive)          ((drive)->driver)
 
-extern int generic_ide_ioctl(struct block_device *, unsigned, unsigned long);
+extern int generic_ide_ioctl(struct file *, struct block_device *, unsigned, unsigned long);
 
 /*
  * ide_hwifs[] is the master data structure used to keep track
@@ -1298,6 +1257,11 @@ extern ide_startstop_t ide_do_reset (ide_drive_t *);
  */
 extern void ide_init_drive_cmd (struct request *rq);
 
+/*
+ * this function returns error location sector offset in case of a write error
+ */
+extern u64 ide_get_error_location(ide_drive_t *, char *);
+
 /*
  * "action" parameter type for ide_do_drive_cmd() below.
  */
@@ -1345,6 +1309,8 @@ extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
  */
 extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
 
+extern void try_to_flush_leftover_data(ide_drive_t *);
+
 /*
  * Issue ATA command and wait for completion.
  * Use for implementing commands in kernel
@@ -1403,42 +1369,32 @@ extern void atapi_output_bytes(ide_drive_t *, void *, u32);
 extern void taskfile_input_data(ide_drive_t *, void *, u32);
 extern void taskfile_output_data(ide_drive_t *, void *, u32);
 
-#ifdef CONFIG_IDE_TASKFILE_IO
-
 #define IDE_PIO_IN     0
 #define IDE_PIO_OUT    1
 
-static inline void task_sectors(ide_drive_t *drive, struct request *rq,
-                               unsigned nsect, int rw)
+static inline void __task_sectors(ide_drive_t *drive, char *buf,
+                                 unsigned nsect, unsigned rw)
 {
-       unsigned long flags;
-       unsigned int bio_rq;
-       char *buf;
-
-       /*
-        * bio_rq flag is needed because we can call
-        * rq_unmap_buffer() with rq->cbio == NULL
-        */
-       bio_rq = rq->cbio ? 1 : 0;
-
-       if (bio_rq)
-               buf = rq_map_buffer(rq, &flags);        /* fs request */
-       else
-               buf = rq->buffer + blk_rq_offset(rq);   /* task request */
-
        /*
         * IRQ can happen instantly after reading/writing
         * last sector of the datablock.
         */
-       process_that_request_first(rq, nsect);
-
        if (rw == IDE_PIO_OUT)
                taskfile_output_data(drive, buf, nsect * SECTOR_WORDS);
        else
                taskfile_input_data(drive, buf, nsect * SECTOR_WORDS);
+}
 
-       if (bio_rq)
-               rq_unmap_buffer(buf, &flags);
+#ifdef CONFIG_IDE_TASKFILE_IO
+static inline void task_bio_sectors(ide_drive_t *drive, struct request *rq,
+                                   unsigned nsect, unsigned rw)
+{
+       unsigned long flags;
+       char *buf = rq_map_buffer(rq, &flags);
+
+       process_that_request_first(rq, nsect);
+       __task_sectors(drive, buf, nsect, rw);
+       rq_unmap_buffer(buf, &flags);
 }
 #endif /* CONFIG_IDE_TASKFILE_IO */
 
@@ -1460,11 +1416,8 @@ extern ide_startstop_t set_geometry_intr(ide_drive_t *);
 extern ide_startstop_t recal_intr(ide_drive_t *);
 extern ide_startstop_t task_no_data_intr(ide_drive_t *);
 extern ide_startstop_t task_in_intr(ide_drive_t *);
-extern ide_startstop_t task_mulin_intr(ide_drive_t *);
 extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
 extern ide_startstop_t task_out_intr(ide_drive_t *);
-extern ide_startstop_t pre_task_mulout_intr(ide_drive_t *, struct request *);
-extern ide_startstop_t task_mulout_intr(ide_drive_t *);
 
 extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);
 
@@ -1472,7 +1425,6 @@ int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
 int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
 int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
 
-extern void ide_delay_50ms(void);
 extern int system_bus_clock(void);
 
 extern u8 ide_auto_reduce_xfer(ide_drive_t *);
@@ -1541,7 +1493,6 @@ int ide_replace_subdriver(ide_drive_t *drive, const char *driver);
 #define NODMA 0
 #define NOAUTODMA 1
 #define AUTODMA 2
-#define EOL 255
 
 typedef struct ide_pci_enablebit_s {
        u8      reg;    /* byte pci reg holding the enable-bit */
@@ -1549,9 +1500,15 @@ typedef struct ide_pci_enablebit_s {
        u8      val;    /* value of masked reg when "enabled" */
 } ide_pci_enablebit_t;
 
+enum {
+       /* Uses ISA control ports not PCI ones. */
+       IDEPCI_FLAG_ISA_PORTS           = (1 << 0),
+
+       IDEPCI_FLAG_FORCE_MASTER        = (1 << 1),
+       IDEPCI_FLAG_FORCE_PDC           = (1 << 2),
+};
+
 typedef struct ide_pci_device_s {
-       u16                     vendor;
-       u16                     device;
        char                    *name;
        void                    (*init_setup)(struct pci_dev *, struct ide_pci_device_s *);
        void                    (*init_setup_dma)(struct pci_dev *, struct ide_pci_device_s *, ide_hwif_t *);
@@ -1565,7 +1522,7 @@ typedef struct ide_pci_device_s {
        u8                      bootable;
        unsigned int            extra;
        struct ide_pci_device_s *next;
-       u8                      isa_ports;      /* Uses ISA control ports not PCI ones */
+       u8                      flags;
 } ide_pci_device_t;
 
 extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
@@ -1604,14 +1561,6 @@ extern int __ide_dma_lostirq(ide_drive_t *);
 extern int __ide_dma_timeout(ide_drive_t *);
 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
 
-#ifdef CONFIG_BLK_DEV_IDE_TCQ
-extern int __ide_dma_queued_on(ide_drive_t *drive);
-extern int __ide_dma_queued_off(ide_drive_t *drive);
-extern ide_startstop_t __ide_dma_queued_read(ide_drive_t *drive);
-extern ide_startstop_t __ide_dma_queued_write(ide_drive_t *drive);
-extern ide_startstop_t __ide_dma_queued_start(ide_drive_t *drive);
-#endif
-
 #else
 static inline int __ide_dma_off(ide_drive_t *drive) { return 0; }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
@@ -1680,28 +1629,13 @@ extern struct semaphore ide_cfg_sem;
 
 #define local_irq_set(flags)   do { local_save_flags((flags)); local_irq_enable(); } while (0)
 
-#define IDE_MAX_TAG    32
-#ifdef CONFIG_BLK_DEV_IDE_TCQ
-static inline int ata_pending_commands(ide_drive_t *drive)
-{
-       if (drive->using_tcq)
-               return blk_queue_tag_depth(drive->queue);
-
-       return 0;
-}
-
-static inline int ata_can_queue(ide_drive_t *drive)
-{
-       if (drive->using_tcq)
-               return blk_queue_tag_queue(drive->queue);
+extern struct bus_type ide_bus_type;
 
-       return 1;
-}
-#else
-#define ata_pending_commands(drive)    (0)
-#define ata_can_queue(drive)           (1)
-#endif
+/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */
+#define ide_id_has_flush_cache(id)     ((id)->cfs_enable_2 & 0x3000)
 
-extern struct bus_type ide_bus_type;
+/* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */
+#define ide_id_has_flush_cache_ext(id) \
+       (((id)->cfs_enable_2 & 0x2400) == 0x2400)
 
 #endif /* _IDE_H */