Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[pandora-kernel.git] / include / linux / libata.h
index 3cfdb5f..bc3b6fc 100644 (file)
@@ -28,9 +28,8 @@
 
 #include <linux/delay.h>
 #include <linux/interrupt.h>
-#include <linux/pci.h>
 #include <linux/dma-mapping.h>
-#include <asm/scatterlist.h>
+#include <linux/scatterlist.h>
 #include <linux/io.h>
 #include <linux/ata.h>
 #include <linux/workqueue.h>
@@ -107,12 +106,6 @@ static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
 /* defines only for the constants which don't work well as enums */
 #define ATA_TAG_POISON         0xfafbfcfdU
 
-/* move to PCI layer? */
-static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
-{
-       return &pdev->dev;
-}
-
 enum {
        /* various global constants */
        LIBATA_MAX_PRD          = ATA_MAX_PRD / 2,
@@ -210,6 +203,7 @@ enum {
        ATA_PFLAG_UNLOADING     = (1 << 5), /* module is unloading */
        ATA_PFLAG_SCSI_HOTPLUG  = (1 << 6), /* SCSI hotplug scheduled */
        ATA_PFLAG_INITIALIZING  = (1 << 7), /* being initialized, don't touch */
+       ATA_PFLAG_RESETTING     = (1 << 8), /* reset in progress */
 
        ATA_PFLAG_SUSPENDED     = (1 << 17), /* port is suspended (power) */
        ATA_PFLAG_PM_PENDING    = (1 << 18), /* PM operation pending */
@@ -331,6 +325,12 @@ enum {
        ATA_HORKAGE_BROKEN_HPA  = (1 << 4),     /* Broken HPA */
        ATA_HORKAGE_SKIP_PM     = (1 << 5),     /* Skip PM operations */
        ATA_HORKAGE_HPA_SIZE    = (1 << 6),     /* native size off by one */
+
+        /* DMA mask for user DMA control: User visible values; DO NOT 
+           renumber */
+       ATA_DMA_MASK_ATA        = (1 << 0),     /* DMA on ATA Disk */
+       ATA_DMA_MASK_ATAPI      = (1 << 1),     /* DMA on ATAPI */
+       ATA_DMA_MASK_CFA        = (1 << 2),     /* DMA on CF Card */
 };
 
 enum hsm_task_states {
@@ -416,6 +416,7 @@ struct ata_queued_cmd {
        unsigned long           flags;          /* ATA_QCFLAG_xxx */
        unsigned int            tag;
        unsigned int            n_elem;
+       unsigned int            n_iter;
        unsigned int            orig_n_elem;
 
        int                     dma_dir;
@@ -426,7 +427,7 @@ struct ata_queued_cmd {
        unsigned int            nbytes;
        unsigned int            curbytes;
 
-       unsigned int            cursg;
+       struct scatterlist      *cursg;
        unsigned int            cursg_ofs;
 
        struct scatterlist      sgent;
@@ -662,8 +663,6 @@ struct ata_port_operations {
        /* port multiplier */
        void (*pmp_attach) (struct ata_port *ap);
        void (*pmp_detach) (struct ata_port *ap);
-       int (*pmp_read) (struct ata_device *dev, int pmp, int reg, u32 *r_val);
-       int (*pmp_write) (struct ata_device *dev, int pmp, int reg, u32 val);
 
        /* Error handlers.  ->error_handler overrides ->eng_timeout and
         * indicates that new-style EH is in place.
@@ -761,18 +760,7 @@ extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
 extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
 extern void ata_port_disable(struct ata_port *);
 extern void ata_std_ports(struct ata_ioports *ioaddr);
-#ifdef CONFIG_PCI
-extern int ata_pci_init_one (struct pci_dev *pdev,
-                            const struct ata_port_info * const * ppi);
-extern void ata_pci_remove_one (struct pci_dev *pdev);
-#ifdef CONFIG_PM
-extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
-extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
-extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
-extern int ata_pci_device_resume(struct pci_dev *pdev);
-#endif
-extern int ata_pci_clear_simplex(struct pci_dev *pdev);
-#endif /* CONFIG_PCI */
+
 extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
 extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
                        const struct ata_port_info * const * ppi, int n_ports);
@@ -923,11 +911,26 @@ enum {
 /* libata-acpi.c */
 #ifdef CONFIG_ATA_ACPI
 extern int ata_acpi_cbl_80wire(struct ata_port *ap);
+int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm);
+int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *stm);
 #else
 static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; }
 #endif
 
 #ifdef CONFIG_PCI
+struct pci_dev;
+
+extern int ata_pci_init_one (struct pci_dev *pdev,
+                            const struct ata_port_info * const * ppi);
+extern void ata_pci_remove_one (struct pci_dev *pdev);
+#ifdef CONFIG_PM
+extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
+extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
+extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
+extern int ata_pci_device_resume(struct pci_dev *pdev);
+#endif
+extern int ata_pci_clear_simplex(struct pci_dev *pdev);
+
 struct pci_bits {
        unsigned int            reg;    /* PCI config register to read */
        unsigned int            width;  /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
@@ -947,12 +950,7 @@ extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long);
 /*
  * PMP
  */
-extern void sata_pmp_read_init_tf(struct ata_taskfile *tf,
-                                 struct ata_device *dev, int pmp, int reg);
-extern u32 sata_pmp_read_val(const struct ata_taskfile *tf);
-extern void sata_pmp_write_init_tf(struct ata_taskfile *tf,
-                                  struct ata_device *dev,
-                                  int pmp, int reg, u32 val);
+extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
 extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline);
 extern int sata_pmp_std_hardreset(struct ata_link *link, unsigned int *class,
                                  unsigned long deadline);
@@ -1039,21 +1037,10 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
 /*
  * qc helpers
  */
-static inline int
-ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc)
-{
-       if (sg == &qc->pad_sgent)
-               return 1;
-       if (qc->pad_len)
-               return 0;
-       if (((sg - qc->__sg) + 1) == qc->n_elem)
-               return 1;
-       return 0;
-}
-
 static inline struct scatterlist *
 ata_qc_first_sg(struct ata_queued_cmd *qc)
 {
+       qc->n_iter = 0;
        if (qc->n_elem)
                return qc->__sg;
        if (qc->pad_len)
@@ -1066,8 +1053,8 @@ ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
 {
        if (sg == &qc->pad_sgent)
                return NULL;
-       if (++sg - qc->__sg < qc->n_elem)
-               return sg;
+       if (++qc->n_iter < qc->n_elem)
+               return sg_next(sg);
        if (qc->pad_len)
                return &qc->pad_sgent;
        return NULL;
@@ -1312,9 +1299,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
        qc->dma_dir = DMA_NONE;
        qc->__sg = NULL;
        qc->flags = 0;
-       qc->cursg = qc->cursg_ofs = 0;
+       qc->cursg = NULL;
+       qc->cursg_ofs = 0;
        qc->nbytes = qc->curbytes = 0;
        qc->n_elem = 0;
+       qc->n_iter = 0;
        qc->err_mask = 0;
        qc->pad_len = 0;
        qc->sect_size = ATA_SECT_SIZE;