ide: add struct ide_port_ops (take 2)
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / ide.h
index 3b691cce00e1a74535ca33bc242cfebec0b0c611..b594f04a67f40b0efc94ac346dccf0d9c0323e6e 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/semaphore.h>
 #include <asm/mutex.h>
 
 #if defined(CONFIG_CRIS) || defined(CONFIG_FRV)
@@ -171,7 +170,6 @@ typedef struct hw_regs_s {
        struct device   *dev;
 } hw_regs_t;
 
-struct hwif_s * ide_find_port(unsigned long);
 void ide_init_port_data(struct hwif_s *, unsigned int);
 void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
 
@@ -194,13 +192,6 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
 #define MAX_HWIFS      CONFIG_IDE_MAX_HWIFS
 #endif
 
-/* 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
-
 /* Currently only m68k, apus and m8xx need it */
 #ifndef IDE_ARCH_ACK_INTR
 # define ide_ack_intr(hwif) (1)
@@ -396,6 +387,32 @@ typedef struct ide_drive_s {
 
 struct ide_port_info;
 
+struct ide_port_ops {
+       /* host specific initialization of devices on a port */
+       void    (*port_init_devs)(struct hwif_s *);
+       /* routine to program host for PIO mode */
+       void    (*set_pio_mode)(ide_drive_t *, const u8);
+       /* routine to program host for DMA mode */
+       void    (*set_dma_mode)(ide_drive_t *, const u8);
+       /* tweaks hardware to select drive */
+       void    (*selectproc)(ide_drive_t *);
+       /* chipset polling based on hba specifics */
+       int     (*reset_poll)(ide_drive_t *);
+       /* chipset specific changes to default for device-hba resets */
+       void    (*pre_reset)(ide_drive_t *);
+       /* routine to reset controller after a disk reset */
+       void    (*resetproc)(ide_drive_t *);
+       /* special host masking for drive selection */
+       void    (*maskproc)(ide_drive_t *, int);
+       /* check host's drive quirk list */
+       void    (*quirkproc)(ide_drive_t *);
+
+       u8      (*mdma_filter)(ide_drive_t *);
+       u8      (*udma_filter)(ide_drive_t *);
+
+       u8      (*cable_detect)(struct hwif_s *);
+};
+
 typedef struct hwif_s {
        struct hwif_s *next;            /* for linked-list in ide_hwgroup_t */
        struct hwif_s *mate;            /* other hwif from same PCI chip */
@@ -435,32 +452,7 @@ typedef struct hwif_s {
 
        void (*rw_disk)(ide_drive_t *, struct request *);
 
-#if 0
-       ide_hwif_ops_t  *hwifops;
-#else
-       /* host specific initialization of devices on a port */
-       void    (*port_init_devs)(struct hwif_s *);
-       /* routine to program host for PIO mode */
-       void    (*set_pio_mode)(ide_drive_t *, const u8);
-       /* routine to program host for DMA mode */
-       void    (*set_dma_mode)(ide_drive_t *, const u8);
-       /* tweaks hardware to select drive */
-       void    (*selectproc)(ide_drive_t *);
-       /* chipset polling based on hba specifics */
-       int     (*reset_poll)(ide_drive_t *);
-       /* chipset specific changes to default for device-hba resets */
-       void    (*pre_reset)(ide_drive_t *);
-       /* routine to reset controller after a disk reset */
-       void    (*resetproc)(ide_drive_t *);
-       /* special host masking for drive selection */
-       void    (*maskproc)(ide_drive_t *, int);
-       /* check host's drive quirk list */
-       void    (*quirkproc)(ide_drive_t *);
-#endif
-       u8 (*mdma_filter)(ide_drive_t *);
-       u8 (*udma_filter)(ide_drive_t *);
-
-       u8 (*cable_detect)(struct hwif_s *);
+       const struct ide_port_ops       *port_ops;
 
        void (*ata_input_data)(ide_drive_t *, void *, u32);
        void (*ata_output_data)(ide_drive_t *, void *, u32);
@@ -530,7 +522,6 @@ typedef struct hwif_s {
        unsigned        reset      : 1; /* reset after probe */
        unsigned        sg_mapped  : 1; /* sg_table and sg_nents are ready */
        unsigned        mmio       : 1; /* host uses MMIO */
-       unsigned        straight8  : 1; /* Alan's straight 8 check */
 
        struct device           gendev;
        struct device           *portdev;
@@ -595,6 +586,68 @@ int set_io_32bit(ide_drive_t *, int);
 int set_pio_mode(ide_drive_t *, int);
 int set_using_dma(ide_drive_t *, int);
 
+/* ATAPI packet command flags */
+enum {
+       /* set when an error is considered normal - no retry (ide-tape) */
+       PC_FLAG_ABORT                   = (1 << 0),
+       PC_FLAG_SUPPRESS_ERROR          = (1 << 1),
+       PC_FLAG_WAIT_FOR_DSC            = (1 << 2),
+       PC_FLAG_DMA_OK                  = (1 << 3),
+       PC_FLAG_DMA_RECOMMENDED         = (1 << 4),
+       PC_FLAG_DMA_IN_PROGRESS         = (1 << 5),
+       PC_FLAG_DMA_ERROR               = (1 << 6),
+       PC_FLAG_WRITING                 = (1 << 7),
+       /* command timed out */
+       PC_FLAG_TIMEDOUT                = (1 << 8),
+};
+
+struct ide_atapi_pc {
+       /* actual packet bytes */
+       u8 c[12];
+       /* incremented on each retry */
+       int retries;
+       int error;
+
+       /* bytes to transfer */
+       int req_xfer;
+       /* bytes actually transferred */
+       int xferred;
+
+       /* 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;
+
+       unsigned long flags;
+
+       /*
+        * those are more or less driver-specific and some of them are subject
+        * to change/removal later.
+        */
+       u8 pc_buf[256];
+       void (*idefloppy_callback) (ide_drive_t *);
+       ide_startstop_t (*idetape_callback) (ide_drive_t *);
+
+       /* idetape only */
+       struct idetape_bh *bh;
+       char *b_data;
+
+       /* idescsi only for now */
+       struct scatterlist *sg;
+       unsigned int sg_cnt;
+
+       struct scsi_cmnd *scsi_cmd;
+       void (*done) (struct scsi_cmnd *);
+
+       unsigned long timeout;
+};
+
 #ifdef CONFIG_IDE_PROC_FS
 /*
  * configurable drive settings
@@ -755,6 +808,13 @@ extern     ide_hwif_t      ide_hwifs[];            /* master data repository */
 #endif
 extern int noautodma;
 
+ide_hwif_t *ide_find_port_slot(const struct ide_port_info *);
+
+static inline ide_hwif_t *ide_find_port(void)
+{
+       return ide_find_port_slot(NULL);
+}
+
 extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
 int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
                             int uptodate, int nr_sectors);
@@ -973,8 +1033,8 @@ enum {
        IDE_HFLAG_SINGLE                = (1 << 1),
        /* don't use legacy PIO blacklist */
        IDE_HFLAG_PIO_NO_BLACKLIST      = (1 << 2),
-       /* don't use conservative PIO "downgrade" */
-       IDE_HFLAG_PIO_NO_DOWNGRADE      = (1 << 3),
+       /* set for the second port of QD65xx */
+       IDE_HFLAG_QD_2ND_PORT           = (1 << 3),
        /* use PIO8/9 for prefetch off/on */
        IDE_HFLAG_ABUSE_PREFETCH        = (1 << 4),
        /* use PIO6/7 for fast-devsel off/on */
@@ -996,8 +1056,8 @@ enum {
        IDE_HFLAG_VDMA                  = (1 << 11),
        /* ATAPI DMA is unsupported */
        IDE_HFLAG_NO_ATAPI_DMA          = (1 << 12),
-       /* set if host is a "bootable" controller */
-       IDE_HFLAG_BOOTABLE              = (1 << 13),
+       /* set if host is a "non-bootable" controller */
+       IDE_HFLAG_NON_BOOTABLE          = (1 << 13),
        /* host doesn't support DMA */
        IDE_HFLAG_NO_DMA                = (1 << 14),
        /* check if host is PCI IDE device before allowing DMA */
@@ -1025,8 +1085,6 @@ enum {
        /* unmask IRQs */
        IDE_HFLAG_UNMASK_IRQS           = (1 << 25),
        IDE_HFLAG_ABUSE_SET_DMA_MODE    = (1 << 26),
-       /* host is CY82C693 */
-       IDE_HFLAG_CY82C693              = (1 << 27),
        /* force host out of "simplex" mode */
        IDE_HFLAG_CLEAR_SIMPLEX         = (1 << 28),
        /* DSC overlap is unsupported */
@@ -1038,9 +1096,9 @@ enum {
 };
 
 #ifdef CONFIG_BLK_DEV_OFFBOARD
-# define IDE_HFLAG_OFF_BOARD   IDE_HFLAG_BOOTABLE
-#else
 # define IDE_HFLAG_OFF_BOARD   0
+#else
+# define IDE_HFLAG_OFF_BOARD   IDE_HFLAG_NON_BOOTABLE
 #endif
 
 struct ide_port_info {
@@ -1049,6 +1107,9 @@ struct ide_port_info {
        void                    (*init_iops)(ide_hwif_t *);
        void                    (*init_hwif)(ide_hwif_t *);
        void                    (*init_dma)(ide_hwif_t *, unsigned long);
+
+       const struct ide_port_ops       *port_ops;
+
        ide_pci_enablebit_t     enablebits[2];
        hwif_chipset_t          chipset;
        u8                      extra;