add upper-32-bits macro
[safe/jmp/linux-2.6] / include / linux / ide.h
index e74ee4f..df4e6a5 100644 (file)
@@ -6,7 +6,6 @@
  *  Copyright (C) 1994-2002  Linus Torvalds & authors
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/hdreg.h>
 #include <linux/bio.h>
 #include <linux/device.h>
 #include <linux/pci.h>
+#include <linux/completion.h>
+#ifdef CONFIG_BLK_DEV_IDEACPI
+#include <acpi/acpi.h>
+#endif
 #include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
 
-/*
- * This is the multiple IDE interface driver, as evolved from hd.c.
- * It supports up to four IDE interfaces, on one or more IRQs (usually 14 & 15).
- * There can be up to two drives per interface, as per the ATA-2 spec.
- *
- * Primary i/f:    ide0: major=3;  (hda)         minor=0; (hdb)         minor=64
- * Secondary i/f:  ide1: major=22; (hdc or hd1a) minor=0; (hdd or hd1b) minor=64
- * Tertiary i/f:   ide2: major=33; (hde)         minor=0; (hdf)         minor=64
- * Quaternary i/f: ide3: major=34; (hdg)         minor=0; (hdh)         minor=64
- */
-
 /******************************************************************************
  * IDE driver configuration options (play with these as desired):
  *
@@ -193,11 +185,6 @@ typedef unsigned char      byte;   /* used everywhere */
 #define WAIT_CMD       (10*HZ) /* 10sec  - maximum wait for an IRQ to happen */
 #define WAIT_MIN_SLEEP (2*HZ/100)      /* 20msec - minimum sleep time */
 
-#define HOST(hwif,chipset)                                     \
-{                                                              \
-       return ((hwif)->chipset == chipset) ? 1 : 0;            \
-}
-
 /*
  * Check for an interrupt and acknowledge the interrupt status
  */
@@ -236,8 +223,9 @@ typedef struct hw_regs_s {
 /*
  * Register new hardware with ide
  */
-int ide_register_hw(hw_regs_t *hw, struct hwif_s **hwifp);
-int ide_register_hw_with_fixup(hw_regs_t *, struct hwif_s **, void (*)(struct hwif_s *));
+int ide_register_hw(hw_regs_t *, int, struct hwif_s **);
+int ide_register_hw_with_fixup(hw_regs_t *, int, struct hwif_s **,
+                              void (*)(struct hwif_s *));
 
 /*
  * Set up hw_regs_t structure before calling ide_register_hw (optional)
@@ -267,7 +255,8 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
 
 #include <asm/ide.h>
 
-#ifndef MAX_HWIFS
+#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED)
+#undef MAX_HWIFS
 #define MAX_HWIFS      CONFIG_IDE_MAX_HWIFS
 #endif
 
@@ -391,45 +380,6 @@ typedef union {
 } ata_nsector_t, ata_data_t, atapi_bcount_t, ata_index_t;
 
 /*
- * ATA-IDE Error Register
- *
- * mark                : Bad address mark
- * tzero       : Couldn't find track 0
- * abrt                : Aborted Command
- * mcr         : Media Change Request
- * id          : ID field not found
- * mce         : Media Change Event
- * ecc         : Uncorrectable ECC error
- * bdd         : dual meaing
- */
-typedef union {
-       unsigned all                    :8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               unsigned mark           :1;
-               unsigned tzero          :1;
-               unsigned abrt           :1;
-               unsigned mcr            :1;
-               unsigned id             :1;
-               unsigned mce            :1;
-               unsigned ecc            :1;
-               unsigned bdd            :1;
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               unsigned bdd            :1;
-               unsigned ecc            :1;
-               unsigned mce            :1;
-               unsigned id             :1;
-               unsigned mcr            :1;
-               unsigned abrt           :1;
-               unsigned tzero          :1;
-               unsigned mark           :1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} ata_error_t;
-
-/*
  * ATA-IDE Select Register, aka Device-Head
  *
  * head                : always zeros here
@@ -504,39 +454,6 @@ typedef union {
 } ata_status_t, atapi_status_t;
 
 /*
- * ATA-IDE Control Register
- *
- * bit0                : Should be set to zero
- * nIEN                : device INTRQ to host
- * SRST                : host soft reset bit
- * bit3                : ATA-2 thingy, Should be set to 1
- * reserved456 : Reserved
- * HOB         : 48-bit address ordering, High Ordered Bit
- */
-typedef union {
-       unsigned all                    : 8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               unsigned bit0           : 1;
-               unsigned nIEN           : 1;
-               unsigned SRST           : 1;
-               unsigned bit3           : 1;
-               unsigned reserved456    : 3;
-               unsigned HOB            : 1;
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               unsigned HOB            : 1;
-               unsigned reserved456    : 3;
-               unsigned bit3           : 1;
-               unsigned SRST           : 1;
-               unsigned nIEN           : 1;
-               unsigned bit0           : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} ata_control_t;
-
-/*
  * ATAPI Feature Register
  *
  * dma         : Using DMA or PIO
@@ -618,39 +535,6 @@ typedef union {
 } atapi_error_t;
 
 /*
- * ATAPI floppy Drive Select Register
- *
- * sam_lun     : Logical unit number
- * reserved3   : Reserved
- * drv         : The responding drive will be drive 0 (0) or drive 1 (1)
- * one5                : Should be set to 1
- * reserved6   : Reserved
- * one7                : Should be set to 1
- */
-typedef union {
-       unsigned all                    :8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               unsigned sam_lun        :3;
-               unsigned reserved3      :1;
-               unsigned drv            :1;
-               unsigned one5           :1;
-               unsigned reserved6      :1;
-               unsigned one7           :1;
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               unsigned one7           :1;
-               unsigned reserved6      :1;
-               unsigned one5           :1;
-               unsigned drv            :1;
-               unsigned reserved3      :1;
-               unsigned sam_lun        :3;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_select_t;
-
-/*
  * Status returned from various ide_ functions
  */
 typedef enum {
@@ -661,6 +545,11 @@ typedef enum {
 struct ide_driver_s;
 struct ide_settings_s;
 
+#ifdef CONFIG_BLK_DEV_IDEACPI
+struct ide_acpi_drive_link;
+struct ide_acpi_hwif_link;
+#endif
+
 typedef struct ide_drive_s {
        char            name[4];        /* drive name, such as "hda" */
         char            driver_req[10];        /* requests specific driver */
@@ -671,10 +560,10 @@ typedef struct ide_drive_s {
        struct ide_drive_s      *next;  /* circular list of hwgroup drives */
        void            *driver_data;   /* extra driver data */
        struct hd_driveid       *id;    /* drive model identification info */
+#ifdef CONFIG_IDE_PROC_FS
        struct proc_dir_entry *proc;    /* /proc/ide/ directory entry */
        struct ide_settings_s *settings;/* /proc/ide/ drive settings */
-       char            devfs_name[64]; /* devfs crap */
-
+#endif
        struct hwif_s           *hwif;  /* actually (ide_hwif_t *) */
 
        unsigned long sleep;            /* sleep until this time */
@@ -693,6 +582,7 @@ typedef struct ide_drive_s {
        u8      waiting_for_dma;        /* dma currently in progress */
        u8      unmask;                 /* okay to unmask other irqs */
        u8      bswap;                  /* byte swap data */
+       u8      noflush;                /* don't attempt flushes */
        u8      dsc_overlap;            /* DSC overlap */
        u8      nice1;                  /* give potential excess bandwidth */
 
@@ -702,7 +592,6 @@ typedef struct ide_drive_s {
        unsigned noprobe        : 1;    /* from:  hdx=noprobe */
        unsigned removable      : 1;    /* 1 if need to do check_media_change */
        unsigned attach         : 1;    /* needed for removable devices */
-       unsigned is_flash       : 1;    /* 1 if probed as flash */
        unsigned forced_geom    : 1;    /* 1 if hdx=c,h,s was given at boot */
        unsigned no_unmask      : 1;    /* disallow setting unmask bit */
        unsigned no_io_32bit    : 1;    /* disallow enabling 32bit I/O */
@@ -714,20 +603,16 @@ 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 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 */
        unsigned sleeping       : 1;    /* 1=sleeping & sleep field valid */
        unsigned post_reset     : 1;
+       unsigned udma33_warned  : 1;
 
+       u8      addressing;     /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */
         u8     quirk_list;     /* considered quirky, set for a specific host */
         u8     init_speed;     /* transfer rate set at boot */
-        u8     pio_speed;      /* unused by core, used by some drivers for fallback from DMA */
         u8     current_speed;  /* current transfer rate set */
+       u8      desired_speed;  /* desired transfer rate set */
         u8     dn;             /* now wide spread use */
         u8     wcache;         /* status of write cache */
        u8      acoustic;       /* acoustic management */
@@ -749,17 +634,20 @@ typedef 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;     /* use by tuneproc/selectproc */
-       unsigned int    usage;          /* current "open()" count for drive */
        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) */
 
        u64             capacity64;     /* total number of sectors */
 
        int             lun;            /* logical unit */
        int             crc_count;      /* crc counter to reduce drive speed */
+#ifdef CONFIG_BLK_DEV_IDEACPI
+       struct ide_acpi_drive_link *acpidata;
+#endif
        struct list_head list;
        struct device   gendev;
-       struct semaphore gendev_rel_sem;        /* to deal with device release() */
+       struct completion gendev_rel_comp;      /* to deal with device release() */
 } ide_drive_t;
 
 #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
@@ -827,11 +715,8 @@ typedef struct hwif_s {
        int     (*quirkproc)(ide_drive_t *);
        /* driver soft-power interface */
        int     (*busproc)(ide_drive_t *, int);
-//     /* host rate limiter */
-//     u8      (*ratemask)(ide_drive_t *);
-//     /* device rate limiter */
-//     u8      (*ratefilter)(ide_drive_t *, u8);
 #endif
+       u8 (*udma_filter)(ide_drive_t *);
 
        void (*ata_input_data)(ide_drive_t *, void *, u32);
        void (*ata_output_data)(ide_drive_t *, void *, u32);
@@ -845,23 +730,22 @@ typedef struct hwif_s {
        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);
+       void (*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);
+       void (*ide_dma_clear_irq)(ide_drive_t *drive);
+       void (*dma_host_on)(ide_drive_t *drive);
+       void (*dma_host_off)(ide_drive_t *drive);
        int (*ide_dma_lostirq)(ide_drive_t *drive);
        int (*ide_dma_timeout)(ide_drive_t *drive);
 
        void (*OUTB)(u8 addr, unsigned long port);
        void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
        void (*OUTW)(u16 addr, unsigned long port);
-       void (*OUTL)(u32 addr, unsigned long port);
        void (*OUTSW)(unsigned long port, void *addr, u32 count);
        void (*OUTSL)(unsigned long port, void *addr, u32 count);
 
        u8  (*INB)(unsigned long port);
        u16 (*INW)(unsigned long port);
-       u32 (*INL)(unsigned long port);
        void (*INSW)(unsigned long port, void *addr, u32 count);
        void (*INSL)(unsigned long port, void *addr, u32 count);
 
@@ -883,7 +767,6 @@ typedef struct hwif_s {
        unsigned int cursg;
        unsigned int cursg_ofs;
 
-       int             mmio;           /* hosts iomio (0) or custom (2) select */
        int             rqsize;         /* max sectors per request */
        int             irq;            /* our irq number */
 
@@ -894,12 +777,13 @@ typedef struct hwif_s {
        unsigned long   dma_status;     /* dma status register */
        unsigned long   dma_vendor3;    /* dma vendor 3 register */
        unsigned long   dma_prdtable;   /* actual prd table address */
-       unsigned long   dma_base2;      /* extended base addr for dma ports */
 
-       unsigned        dma_extra;      /* extra addr for dma ports */
        unsigned long   config_data;    /* for use by chipset-specific code */
        unsigned long   select_data;    /* for use by chipset-specific code */
 
+       unsigned long   extra_base;     /* extra addr for dma ports */
+       unsigned        extra_ports;    /* number of extra dma ports */
+
        unsigned        noprobe    : 1; /* don't probe for this interface */
        unsigned        present    : 1; /* this interface exists */
        unsigned        hold       : 1; /* this interface is always present */
@@ -910,19 +794,23 @@ typedef struct hwif_s {
        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 */
        unsigned        sg_mapped  : 1; /* sg_table and sg_nents are ready */
+       unsigned        no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */
+       unsigned        err_stops_fifo : 1; /* 1=data FIFO is cleared by an error */
+       unsigned        mmio       : 1; /* host uses MMIO */
 
        struct device   gendev;
-       struct semaphore gendev_rel_sem; /* To deal with device release() */
+       struct completion gendev_rel_comp; /* To deal with device release() */
 
        void            *hwif_data;     /* extra hwif data */
 
        unsigned dma;
 
-       void (*led_act)(void *data, int rw);
-} ____cacheline_maxaligned_in_smp ide_hwif_t;
+#ifdef CONFIG_BLK_DEV_IDEACPI
+       struct ide_acpi_hwif_link *acpidata;
+#endif
+} ____cacheline_internodealigned_in_smp ide_hwif_t;
 
 /*
  *  internal ide interrupt handler type
@@ -942,6 +830,9 @@ typedef struct hwgroup_s {
        unsigned int sleeping   : 1;
                /* BOOL: polling active & poll_timeout field valid */
        unsigned int polling    : 1;
+               /* BOOL: in a polling reset situation. Must not trigger another reset yet */
+       unsigned int resetting  : 1;
+
                /* current drive */
        ide_drive_t *drive;
                /* ptr to current hwif in linked-list */
@@ -964,20 +855,28 @@ typedef struct hwgroup_s {
        int (*expiry)(ide_drive_t *);
                /* ide_system_bus_speed */
        int pio_clock;
+       int req_gen;
+       int req_gen_timer;
 
        unsigned char cmd_buf[4];
 } ide_hwgroup_t;
 
-/* structure attached to the request for IDE_TASK_CMDS */
+typedef struct ide_driver_s ide_driver_t;
 
+extern struct semaphore ide_setting_sem;
+
+int set_io_32bit(ide_drive_t *, int);
+int set_pio_mode(ide_drive_t *, int);
+int set_using_dma(ide_drive_t *, int);
+
+#ifdef CONFIG_IDE_PROC_FS
 /*
  * configurable drive settings
  */
 
 #define TYPE_INT       0
-#define TYPE_INTA      1
-#define TYPE_BYTE      2
-#define TYPE_SHORT     3
+#define TYPE_BYTE      1
+#define TYPE_SHORT     2
 
 #define SETTING_READ   (1 << 0)
 #define SETTING_WRITE  (1 << 1)
@@ -987,8 +886,6 @@ typedef int (ide_procset_t)(ide_drive_t *, int);
 typedef struct ide_settings_s {
        char                    *name;
        int                     rw;
-       int                     read_ioctl;
-       int                     write_ioctl;
        int                     data_type;
        int                     min;
        int                     max;
@@ -1000,12 +897,7 @@ typedef struct ide_settings_s {
        struct ide_settings_s   *next;
 } ide_settings_t;
 
-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 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);
-extern void ide_add_generic_settings(ide_drive_t *drive);
+int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set);
 
 /*
  * /proc/ide interface
@@ -1017,15 +909,15 @@ typedef struct {
        write_proc_t    *write_proc;
 } ide_proc_entry_t;
 
-#ifdef CONFIG_PROC_FS
-extern struct proc_dir_entry *proc_ide_root;
+void proc_ide_create(void);
+void proc_ide_destroy(void);
+void ide_proc_register_port(ide_hwif_t *);
+void ide_proc_unregister_port(ide_hwif_t *);
+void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
+void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
+
+void ide_add_generic_settings(ide_drive_t *);
 
-extern void proc_ide_create(void);
-extern void proc_ide_destroy(void);
-extern void create_proc_ide_interfaces(void);
-void destroy_proc_ide_interface(ide_hwif_t *);
-extern void ide_add_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *, void *);
-extern void ide_remove_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *);
 read_proc_t proc_ide_read_capacity;
 read_proc_t proc_ide_read_geometry;
 
@@ -1049,8 +941,13 @@ void ide_pci_create_host_proc(const char *, get_info_t *);
        return len;                     \
 }
 #else
-static inline void create_proc_ide_interfaces(void) { ; }
-static inline void destroy_proc_ide_interface(ide_hwif_t *hwif) { ; }
+static inline void proc_ide_create(void) { ; }
+static inline void proc_ide_destroy(void) { ; }
+static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; }
+static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
+static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
+static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
+static inline void ide_add_generic_settings(ide_drive_t *drive) { ; }
 #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
 #endif
 
@@ -1093,7 +990,7 @@ enum {
  * The gendriver.owner field should be set to the module owner of this driver.
  * The gendriver.name field should be set to the name of this driver
  */
-typedef struct ide_driver_s {
+struct ide_driver_s {
        const char                      *version;
        u8                              media;
        unsigned supports_dsc_overlap   : 1;
@@ -1101,12 +998,16 @@ typedef struct ide_driver_s {
        int             (*end_request)(ide_drive_t *, int, int);
        ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
        ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
-       int             (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
-       ide_proc_entry_t        *proc;
-       void            (*ata_prebuilder)(ide_drive_t *);
-       void            (*atapi_prebuilder)(ide_drive_t *);
        struct device_driver    gen_driver;
-} ide_driver_t;
+       int             (*probe)(ide_drive_t *);
+       void            (*remove)(ide_drive_t *);
+       void            (*shutdown)(ide_drive_t *);
+#ifdef CONFIG_IDE_PROC_FS
+       ide_proc_entry_t        *proc;
+#endif
+};
+
+#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
 
 int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
 
@@ -1124,7 +1025,8 @@ extern    ide_hwif_t      ide_hwifs[];            /* master data repository */
 extern int noautodma;
 
 extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
-extern int __ide_end_request (ide_drive_t *drive, struct request *rq, int uptodate, int nrsecs);
+int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
+                            int uptodate, int nr_sectors);
 
 /*
  * This is used on exit from the driver to designate the next irq handler
@@ -1201,7 +1103,6 @@ extern u64 ide_get_error_location(ide_drive_t *, char *);
  */
 typedef enum {
        ide_wait,       /* insert rq at end of list, and wait for it */
-       ide_next,       /* insert rq immediately after current request */
        ide_preempt,    /* insert rq in front of current request */
        ide_head_wait,  /* insert rq in front of current request and wait for it */
        ide_end         /* insert rq at end of list, but don't wait for it */
@@ -1297,18 +1198,21 @@ extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);
 
 extern int ide_spin_wait_hwgroup(ide_drive_t *);
 extern void ide_timer_expiry(unsigned long);
-extern irqreturn_t ide_intr(int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t ide_intr(int irq, void *dev_id);
 extern void do_ide_request(request_queue_t *);
-extern void ide_init_subdrivers(void);
 
 void ide_init_disk(struct gendisk *, ide_drive_t *);
 
 extern int ideprobe_init(void);
 
+#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
 extern void ide_scan_pcibus(int scan_direction) __init;
-extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner);
-#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE)
-extern void ide_pci_unregister_driver(struct pci_driver *driver);
+extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name);
+#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)
+#else
+#define ide_pci_register_driver(d) pci_register_driver(d)
+#endif
+
 void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *);
 extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);
 
@@ -1316,9 +1220,6 @@ extern void default_hwif_iops(ide_hwif_t *);
 extern void default_hwif_mmiops(ide_hwif_t *);
 extern void default_hwif_transport(ide_hwif_t *);
 
-void ide_register_subdriver(ide_drive_t *, ide_driver_t *);
-void ide_unregister_subdriver(ide_drive_t *, ide_driver_t *);
-
 #define ON_BOARD               1
 #define NEVER_BOARD            0
 
@@ -1341,7 +1242,6 @@ typedef struct ide_pci_enablebit_s {
 enum {
        /* Uses ISA control ports not PCI ones. */
        IDEPCI_FLAG_ISA_PORTS           = (1 << 0),
-       IDEPCI_FLAG_FORCE_PDC           = (1 << 1),
 };
 
 typedef struct ide_pci_device_s {
@@ -1360,6 +1260,7 @@ typedef struct ide_pci_device_s {
        unsigned int            extra;
        struct ide_pci_device_s *next;
        u8                      flags;
+       u8                      udma_mask;
 } ide_pci_device_t;
 
 extern int ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
@@ -1372,11 +1273,20 @@ void ide_init_sg_cmd(ide_drive_t *, struct request *);
 #define GOOD_DMA_DRIVE         1
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
+struct drive_list_entry {
+       const char *id_model;
+       const char *id_firmware;
+};
+
+int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *);
 int __ide_dma_bad_drive(ide_drive_t *);
 int __ide_dma_good_drive(ide_drive_t *);
 int ide_use_dma(ide_drive_t *);
-int __ide_dma_off(ide_drive_t *);
+u8 ide_max_dma_mode(ide_drive_t *);
+int ide_tune_dma(ide_drive_t *);
+void ide_dma_off(ide_drive_t *);
 void ide_dma_verbose(ide_drive_t *);
+int ide_set_dma(ide_drive_t *);
 ide_startstop_t ide_dma_intr(ide_drive_t *);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
@@ -1386,9 +1296,9 @@ extern void ide_destroy_dmatable(ide_drive_t *);
 extern int ide_release_dma(ide_hwif_t *);
 extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);
 
-extern int __ide_dma_host_off(ide_drive_t *);
-extern int __ide_dma_off_quietly(ide_drive_t *);
-extern int __ide_dma_host_on(ide_drive_t *);
+void ide_dma_host_off(ide_drive_t *);
+void ide_dma_off_quietly(ide_drive_t *);
+void ide_dma_host_on(ide_drive_t *);
 extern int __ide_dma_on(ide_drive_t *);
 extern int __ide_dma_check(ide_drive_t *);
 extern int ide_dma_setup(ide_drive_t *);
@@ -1400,14 +1310,29 @@ extern int __ide_dma_timeout(ide_drive_t *);
 
 #else
 static inline int ide_use_dma(ide_drive_t *drive) { return 0; }
-static inline int __ide_dma_off(ide_drive_t *drive) { return 0; }
+static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; }
+static inline int ide_tune_dma(ide_drive_t *drive) { return 0; }
+static inline void ide_dma_off(ide_drive_t *drive) { ; }
 static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
+static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
 #ifndef CONFIG_BLK_DEV_IDEDMA_PCI
 static inline void ide_release_dma(ide_hwif_t *drive) {;}
 #endif
 
+#ifdef CONFIG_BLK_DEV_IDEACPI
+extern int ide_acpi_exec_tfs(ide_drive_t *drive);
+extern void ide_acpi_get_timing(ide_hwif_t *hwif);
+extern void ide_acpi_push_timing(ide_hwif_t *hwif);
+extern void ide_acpi_init(ide_hwif_t *hwif);
+#else
+static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
+static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
+static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
+static inline void ide_acpi_init(ide_hwif_t *hwif) { ; }
+#endif
+
 extern int ide_hwif_request_regions(ide_hwif_t *hwif);
 extern void ide_hwif_release_regions(ide_hwif_t* hwif);
 extern void ide_unregister (unsigned int index);
@@ -1431,26 +1356,26 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
 }
 
 /* ide-lib.c */
-extern u8 ide_dma_speed(ide_drive_t *drive, u8 mode);
-extern u8 ide_rate_filter(u8 mode, u8 speed); 
+u8 ide_rate_filter(ide_drive_t *, u8);
 extern int ide_dma_enable(ide_drive_t *drive);
 extern char *ide_xfer_verbose(u8 xfer_rate);
 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
+int ide_use_fast_pio(ide_drive_t *);
 
 u8 ide_dump_status(ide_drive_t *, const char *, u8);
 
 typedef struct ide_pio_timings_s {
        int     setup_time;     /* Address setup (ns) minimum */
        int     active_time;    /* Active pulse (ns) minimum */
-       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
+       int     cycle_time;     /* Cycle time (ns) minimum = */
+                               /* active + recovery (+ setup for some chips) */
 } ide_pio_timings_t;
 
 typedef struct ide_pio_data_s {
        u8 pio_mode;
        u8 use_iordy;
        u8 overridden;
-       u8 blacklisted;
        unsigned int cycle_time;
 } ide_pio_data_t;
 
@@ -1473,7 +1398,7 @@ extern struct semaphore ide_cfg_sem;
  * ide_drive_t->hwif: constant, no locking
  */
 
-#define local_irq_set(flags)   do { local_save_flags((flags)); local_irq_enable(); } while (0)
+#define local_irq_set(flags)   do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0)
 
 extern struct bus_type ide_bus_type;