Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[pandora-kernel.git] / include / linux / ide.h
index 260e871..b846bc4 100644 (file)
@@ -178,6 +178,7 @@ typedef struct hw_regs_s {
        ide_ack_intr_t  *ack_intr;              /* acknowledge interrupt */
        hwif_chipset_t  chipset;
        struct device   *dev, *parent;
+       unsigned long   config;
 } hw_regs_t;
 
 void ide_init_port_data(struct hwif_s *, unsigned int);
@@ -210,7 +211,21 @@ static inline int __ide_default_irq(unsigned long base)
        return 0;
 }
 
+#if defined(CONFIG_ARM) || defined(CONFIG_FRV) || defined(CONFIG_M68K) || \
+    defined(CONFIG_MIPS) || defined(CONFIG_MN10300) || defined(CONFIG_PARISC) \
+    || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
 #include <asm/ide.h>
+#else
+#include <asm-generic/ide_iops.h>
+#endif
+
+#ifndef MAX_HWIFS
+#if defined(CONFIG_BLACKFIN) || defined(CONFIG_H8300) || defined(CONFIG_XTENSA)
+# define MAX_HWIFS     1
+#else
+# define MAX_HWIFS     10
+#endif
+#endif
 
 #if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED)
 #undef MAX_HWIFS
@@ -307,7 +322,65 @@ struct ide_acpi_drive_link;
 struct ide_acpi_hwif_link;
 #endif
 
-typedef struct ide_drive_s {
+/* ATAPI device flags */
+enum {
+       IDE_AFLAG_DRQ_INTERRUPT         = (1 << 0),
+       IDE_AFLAG_MEDIA_CHANGED         = (1 << 1),
+
+       /* ide-cd */
+       /* Drive cannot lock the door. */
+       IDE_AFLAG_NO_DOORLOCK           = (1 << 2),
+       /* Drive cannot eject the disc. */
+       IDE_AFLAG_NO_EJECT              = (1 << 3),
+       /* Drive is a pre ATAPI 1.2 drive. */
+       IDE_AFLAG_PRE_ATAPI12           = (1 << 4),
+       /* TOC addresses are in BCD. */
+       IDE_AFLAG_TOCADDR_AS_BCD        = (1 << 5),
+       /* TOC track numbers are in BCD. */
+       IDE_AFLAG_TOCTRACKS_AS_BCD      = (1 << 6),
+       /*
+        * Drive does not provide data in multiples of SECTOR_SIZE
+        * when more than one interrupt is needed.
+        */
+       IDE_AFLAG_LIMIT_NFRAMES         = (1 << 7),
+       /* Seeking in progress. */
+       IDE_AFLAG_SEEKING               = (1 << 8),
+       /* Saved TOC information is current. */
+       IDE_AFLAG_TOC_VALID             = (1 << 9),
+       /* We think that the drive door is locked. */
+       IDE_AFLAG_DOOR_LOCKED           = (1 << 10),
+       /* SET_CD_SPEED command is unsupported. */
+       IDE_AFLAG_NO_SPEED_SELECT       = (1 << 11),
+       IDE_AFLAG_VERTOS_300_SSD        = (1 << 12),
+       IDE_AFLAG_VERTOS_600_ESD        = (1 << 13),
+       IDE_AFLAG_SANYO_3CD             = (1 << 14),
+       IDE_AFLAG_FULL_CAPS_PAGE        = (1 << 15),
+       IDE_AFLAG_PLAY_AUDIO_OK         = (1 << 16),
+       IDE_AFLAG_LE_SPEED_FIELDS       = (1 << 17),
+
+       /* ide-floppy */
+       /* Format in progress */
+       IDE_AFLAG_FORMAT_IN_PROGRESS    = (1 << 18),
+       /* Avoid commands not supported in Clik drive */
+       IDE_AFLAG_CLIK_DRIVE            = (1 << 19),
+       /* Requires BH algorithm for packets */
+       IDE_AFLAG_ZIP_DRIVE             = (1 << 20),
+
+       /* ide-tape */
+       IDE_AFLAG_IGNORE_DSC            = (1 << 21),
+       /* 0 When the tape position is unknown */
+       IDE_AFLAG_ADDRESS_VALID         = (1 << 22),
+       /* Device already opened */
+       IDE_AFLAG_BUSY                  = (1 << 23),
+       /* Attempt to auto-detect the current user block size */
+       IDE_AFLAG_DETECT_BS             = (1 << 24),
+       /* Currently on a filemark */
+       IDE_AFLAG_FILEMARK              = (1 << 25),
+       /* 0 = no tape is loaded, so we don't rewind after ejecting */
+       IDE_AFLAG_MEDIUM_PRESENT        = (1 << 26)
+};
+
+struct ide_drive_s {
        char            name[4];        /* drive name, such as "hda" */
         char            driver_req[10];        /* requests specific driver */
 
@@ -399,7 +472,14 @@ typedef struct ide_drive_s {
        struct list_head list;
        struct device   gendev;
        struct completion gendev_rel_comp;      /* to deal with device release() */
-} ide_drive_t;
+
+       /* callback for packet commands */
+       void (*pc_callback)(struct ide_drive_s *);
+
+       unsigned long atapi_flags;
+};
+
+typedef struct ide_drive_s ide_drive_t;
 
 #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
 
@@ -407,8 +487,28 @@ typedef struct ide_drive_s {
     ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
 #define IDE_CHIPSET_IS_PCI(c)  ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
 
+struct ide_task_s;
 struct ide_port_info;
 
+struct ide_tp_ops {
+       void    (*exec_command)(struct hwif_s *, u8);
+       u8      (*read_status)(struct hwif_s *);
+       u8      (*read_altstatus)(struct hwif_s *);
+       u8      (*read_sff_dma_status)(struct hwif_s *);
+
+       void    (*set_irq)(struct hwif_s *, int);
+
+       void    (*tf_load)(ide_drive_t *, struct ide_task_s *);
+       void    (*tf_read)(ide_drive_t *, struct ide_task_s *);
+
+       void    (*input_data)(ide_drive_t *, struct request *, void *,
+                             unsigned int);
+       void    (*output_data)(ide_drive_t *, struct request *, void *,
+                              unsigned int);
+};
+
+extern const struct ide_tp_ops default_tp_ops;
+
 struct ide_port_ops {
        /* host specific initialization of a device */
        void    (*init_dev)(ide_drive_t *);
@@ -446,7 +546,7 @@ struct ide_dma_ops {
        void    (*dma_timeout)(struct ide_drive_s *);
 };
 
-struct ide_task_s;
+struct ide_host;
 
 typedef struct hwif_s {
        struct hwif_s *next;            /* for linked-list in ide_hwgroup_t */
@@ -454,6 +554,8 @@ typedef struct hwif_s {
        struct hwgroup_s *hwgroup;      /* actually (ide_hwgroup_t *) */
        struct proc_dir_entry *proc;    /* /proc/ide/ directory entry */
 
+       struct ide_host *host;
+
        char name[6];                   /* name of interface, eg. "ide0" */
 
        struct ide_io_ports     io_ports;
@@ -485,22 +587,10 @@ typedef struct hwif_s {
 
        void (*rw_disk)(ide_drive_t *, struct request *);
 
+       const struct ide_tp_ops         *tp_ops;
        const struct ide_port_ops       *port_ops;
        const struct ide_dma_ops        *dma_ops;
 
-       void    (*exec_command)(struct hwif_s *, u8);
-       u8      (*read_status)(struct hwif_s *);
-       u8      (*read_altstatus)(struct hwif_s *);
-       u8      (*read_sff_dma_status)(struct hwif_s *);
-
-       void    (*set_irq)(struct hwif_s *, int);
-
-       void (*tf_load)(ide_drive_t *, struct ide_task_s *);
-       void (*tf_read)(ide_drive_t *, struct ide_task_s *);
-
-       void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
-       void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
-
        void (*ide_dma_clear_irq)(ide_drive_t *drive);
 
        /* dma physical region descriptor table (cpu view) */
@@ -551,6 +641,14 @@ typedef struct hwif_s {
 #endif
 } ____cacheline_internodealigned_in_smp ide_hwif_t;
 
+struct ide_host {
+       ide_hwif_t      *ports[MAX_HWIFS];
+       unsigned int    n_ports;
+       struct device   *dev[2];
+       unsigned long   host_flags;
+       void            *host_priv;
+};
+
 /*
  *  internal ide interrupt handler type
  */
@@ -610,8 +708,6 @@ enum {
        PC_FLAG_WRITING                 = (1 << 6),
        /* command timed out */
        PC_FLAG_TIMEDOUT                = (1 << 7),
-       PC_FLAG_ZIP_DRIVE               = (1 << 8),
-       PC_FLAG_DRQ_INTERRUPT           = (1 << 9),
 };
 
 struct ide_atapi_pc {
@@ -645,8 +741,6 @@ struct ide_atapi_pc {
         */
        u8 pc_buf[256];
 
-       void (*callback)(ide_drive_t *);
-
        /* idetape only */
        struct idetape_bh *bh;
        char *b_data;
@@ -801,18 +895,14 @@ struct ide_driver_s {
 
 #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
 
+int ide_device_get(ide_drive_t *);
+void ide_device_put(ide_drive_t *);
+
 int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
 
 extern int ide_vlb_clk;
 extern int ide_pci_clk;
 
-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);
@@ -948,6 +1038,19 @@ typedef struct ide_task_s {
 
 void ide_tf_dump(const char *, struct ide_taskfile *);
 
+void ide_exec_command(ide_hwif_t *, u8);
+u8 ide_read_status(ide_hwif_t *);
+u8 ide_read_altstatus(ide_hwif_t *);
+u8 ide_read_sff_dma_status(ide_hwif_t *);
+
+void ide_set_irq(ide_hwif_t *, int);
+
+void ide_tf_load(ide_drive_t *, ide_task_t *);
+void ide_tf_read(ide_drive_t *, ide_task_t *);
+
+void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
+void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
+
 extern void SELECT_DRIVE(ide_drive_t *);
 void SELECT_MASK(ide_drive_t *, int);
 
@@ -1004,7 +1107,7 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
 #endif
 
 void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int,
-                        u8 *, hw_regs_t *, hw_regs_t **);
+                        hw_regs_t *, hw_regs_t **);
 void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
@@ -1021,8 +1124,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
 }
 #endif
 
-extern void default_hwif_transport(ide_hwif_t *);
-
 typedef struct ide_pci_enablebit_s {
        u8      reg;    /* byte pci reg holding the enable-bit */
        u8      mask;   /* mask to isolate the enable-bit */
@@ -1105,12 +1206,13 @@ enum {
 
 struct ide_port_info {
        char                    *name;
-       unsigned int            (*init_chipset)(struct pci_dev *, const char *);
+       unsigned int            (*init_chipset)(struct pci_dev *);
        void                    (*init_iops)(ide_hwif_t *);
        void                    (*init_hwif)(ide_hwif_t *);
        int                     (*init_dma)(ide_hwif_t *,
                                            const struct ide_port_info *);
 
+       const struct ide_tp_ops         *tp_ops;
        const struct ide_port_ops       *port_ops;
        const struct ide_dma_ops        *dma_ops;
 
@@ -1123,8 +1225,10 @@ struct ide_port_info {
        u8                      udma_mask;
 };
 
-int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *);
-int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *);
+int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
+int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
+                    const struct ide_port_info *, void *);
+void ide_pci_remove(struct pci_dev *);
 
 void ide_map_sg(ide_drive_t *, struct request *);
 void ide_init_sg_cmd(ide_drive_t *, struct request *);
@@ -1217,8 +1321,14 @@ void ide_undecoded_slave(ide_drive_t *);
 
 void ide_port_apply_params(ide_hwif_t *);
 
-int ide_device_add_all(u8 *, const struct ide_port_info *, hw_regs_t **);
-int ide_device_add(u8 *, const struct ide_port_info *, hw_regs_t **);
+struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **);
+struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
+void ide_host_free(struct ide_host *);
+int ide_host_register(struct ide_host *, const struct ide_port_info *,
+                     hw_regs_t **);
+int ide_host_add(const struct ide_port_info *, hw_regs_t **,
+                struct ide_host **);
+void ide_host_remove(struct ide_host *);
 int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
 void ide_port_unregister_devices(ide_hwif_t *);
 void ide_port_scan(ide_hwif_t *);