diff options
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 137 |
1 files changed, 43 insertions, 94 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 91bb8ceef0b5..86762a9f52ba 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -31,10 +31,11 @@ | |||
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
33 | #include <asm/scatterlist.h> | 33 | #include <asm/scatterlist.h> |
34 | #include <asm/io.h> | 34 | #include <linux/io.h> |
35 | #include <linux/ata.h> | 35 | #include <linux/ata.h> |
36 | #include <linux/workqueue.h> | 36 | #include <linux/workqueue.h> |
37 | #include <scsi/scsi_host.h> | 37 | #include <scsi/scsi_host.h> |
38 | #include <linux/acpi.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Define if arch has non-standard setup. This is a _PCI_ standard | 41 | * Define if arch has non-standard setup. This is a _PCI_ standard |
@@ -54,8 +55,6 @@ | |||
54 | #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ | 55 | #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ |
55 | #undef ATA_IRQ_TRAP /* define to ack screaming irqs */ | 56 | #undef ATA_IRQ_TRAP /* define to ack screaming irqs */ |
56 | #undef ATA_NDEBUG /* define to disable quick runtime checks */ | 57 | #undef ATA_NDEBUG /* define to disable quick runtime checks */ |
57 | #define ATA_ENABLE_PATA /* define to enable PATA support in some | ||
58 | * low-level drivers */ | ||
59 | 58 | ||
60 | 59 | ||
61 | /* note: prints function name for you */ | 60 | /* note: prints function name for you */ |
@@ -109,10 +108,6 @@ static inline u32 ata_msg_init(int dval, int default_msg_enable_bits) | |||
109 | #define ATA_TAG_POISON 0xfafbfcfdU | 108 | #define ATA_TAG_POISON 0xfafbfcfdU |
110 | 109 | ||
111 | /* move to PCI layer? */ | 110 | /* move to PCI layer? */ |
112 | #define PCI_VDEVICE(vendor, device) \ | ||
113 | PCI_VENDOR_ID_##vendor, (device), \ | ||
114 | PCI_ANY_ID, PCI_ANY_ID, 0, 0 | ||
115 | |||
116 | static inline struct device *pci_dev_to_dev(struct pci_dev *pdev) | 111 | static inline struct device *pci_dev_to_dev(struct pci_dev *pdev) |
117 | { | 112 | { |
118 | return &pdev->dev; | 113 | return &pdev->dev; |
@@ -178,6 +173,7 @@ enum { | |||
178 | ATA_FLAG_DEBUGMSG = (1 << 13), | 173 | ATA_FLAG_DEBUGMSG = (1 << 13), |
179 | ATA_FLAG_SETXFER_POLLING= (1 << 14), /* use polling for SETXFER */ | 174 | ATA_FLAG_SETXFER_POLLING= (1 << 14), /* use polling for SETXFER */ |
180 | ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ | 175 | ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ |
176 | ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */ | ||
181 | 177 | ||
182 | /* The following flag belongs to ap->pflags but is kept in | 178 | /* The following flag belongs to ap->pflags but is kept in |
183 | * ap->flags because it's referenced in many LLDs and will be | 179 | * ap->flags because it's referenced in many LLDs and will be |
@@ -308,7 +304,7 @@ enum { | |||
308 | * most devices. | 304 | * most devices. |
309 | */ | 305 | */ |
310 | ATA_SPINUP_WAIT = 8000, | 306 | ATA_SPINUP_WAIT = 8000, |
311 | 307 | ||
312 | /* Horkage types. May be set by libata or controller on drives | 308 | /* Horkage types. May be set by libata or controller on drives |
313 | (some horkage may be drive/controller pair dependant */ | 309 | (some horkage may be drive/controller pair dependant */ |
314 | 310 | ||
@@ -352,21 +348,21 @@ typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes); | |||
352 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); | 348 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); |
353 | 349 | ||
354 | struct ata_ioports { | 350 | struct ata_ioports { |
355 | unsigned long cmd_addr; | 351 | void __iomem *cmd_addr; |
356 | unsigned long data_addr; | 352 | void __iomem *data_addr; |
357 | unsigned long error_addr; | 353 | void __iomem *error_addr; |
358 | unsigned long feature_addr; | 354 | void __iomem *feature_addr; |
359 | unsigned long nsect_addr; | 355 | void __iomem *nsect_addr; |
360 | unsigned long lbal_addr; | 356 | void __iomem *lbal_addr; |
361 | unsigned long lbam_addr; | 357 | void __iomem *lbam_addr; |
362 | unsigned long lbah_addr; | 358 | void __iomem *lbah_addr; |
363 | unsigned long device_addr; | 359 | void __iomem *device_addr; |
364 | unsigned long status_addr; | 360 | void __iomem *status_addr; |
365 | unsigned long command_addr; | 361 | void __iomem *command_addr; |
366 | unsigned long altstatus_addr; | 362 | void __iomem *altstatus_addr; |
367 | unsigned long ctl_addr; | 363 | void __iomem *ctl_addr; |
368 | unsigned long bmdma_addr; | 364 | void __iomem *bmdma_addr; |
369 | unsigned long scr_addr; | 365 | void __iomem *scr_addr; |
370 | }; | 366 | }; |
371 | 367 | ||
372 | struct ata_probe_ent { | 368 | struct ata_probe_ent { |
@@ -385,7 +381,7 @@ struct ata_probe_ent { | |||
385 | unsigned int irq_flags; | 381 | unsigned int irq_flags; |
386 | unsigned long port_flags; | 382 | unsigned long port_flags; |
387 | unsigned long _host_flags; | 383 | unsigned long _host_flags; |
388 | void __iomem *mmio_base; | 384 | void __iomem * const *iomap; |
389 | void *private_data; | 385 | void *private_data; |
390 | 386 | ||
391 | /* port_info for the secondary port. Together with irq2, it's | 387 | /* port_info for the secondary port. Together with irq2, it's |
@@ -402,7 +398,7 @@ struct ata_host { | |||
402 | struct device *dev; | 398 | struct device *dev; |
403 | unsigned long irq; | 399 | unsigned long irq; |
404 | unsigned long irq2; | 400 | unsigned long irq2; |
405 | void __iomem *mmio_base; | 401 | void __iomem * const *iomap; |
406 | unsigned int n_ports; | 402 | unsigned int n_ports; |
407 | void *private_data; | 403 | void *private_data; |
408 | const struct ata_port_operations *ops; | 404 | const struct ata_port_operations *ops; |
@@ -431,9 +427,6 @@ struct ata_queued_cmd { | |||
431 | 427 | ||
432 | unsigned int pad_len; | 428 | unsigned int pad_len; |
433 | 429 | ||
434 | unsigned int nsect; | ||
435 | unsigned int cursect; | ||
436 | |||
437 | unsigned int nbytes; | 430 | unsigned int nbytes; |
438 | unsigned int curbytes; | 431 | unsigned int curbytes; |
439 | 432 | ||
@@ -503,6 +496,10 @@ struct ata_device { | |||
503 | /* error history */ | 496 | /* error history */ |
504 | struct ata_ering ering; | 497 | struct ata_ering ering; |
505 | unsigned int horkage; /* List of broken features */ | 498 | unsigned int horkage; /* List of broken features */ |
499 | #ifdef CONFIG_SATA_ACPI | ||
500 | /* ACPI objects info */ | ||
501 | acpi_handle obj_handle; | ||
502 | #endif | ||
506 | }; | 503 | }; |
507 | 504 | ||
508 | /* Offset into struct ata_device. Fields above it are maintained | 505 | /* Offset into struct ata_device. Fields above it are maintained |
@@ -639,6 +636,8 @@ struct ata_port_operations { | |||
639 | 636 | ||
640 | irq_handler_t irq_handler; | 637 | irq_handler_t irq_handler; |
641 | void (*irq_clear) (struct ata_port *); | 638 | void (*irq_clear) (struct ata_port *); |
639 | u8 (*irq_on) (struct ata_port *); | ||
640 | u8 (*irq_ack) (struct ata_port *ap, unsigned int chk_drq); | ||
642 | 641 | ||
643 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); | 642 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); |
644 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | 643 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, |
@@ -720,20 +719,18 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i | |||
720 | unsigned int n_ports); | 719 | unsigned int n_ports); |
721 | extern void ata_pci_remove_one (struct pci_dev *pdev); | 720 | extern void ata_pci_remove_one (struct pci_dev *pdev); |
722 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); | 721 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); |
723 | extern void ata_pci_device_do_resume(struct pci_dev *pdev); | 722 | extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); |
724 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | 723 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); |
725 | extern int ata_pci_device_resume(struct pci_dev *pdev); | 724 | extern int ata_pci_device_resume(struct pci_dev *pdev); |
726 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | 725 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); |
727 | #endif /* CONFIG_PCI */ | 726 | #endif /* CONFIG_PCI */ |
728 | extern int ata_device_add(const struct ata_probe_ent *ent); | 727 | extern int ata_device_add(const struct ata_probe_ent *ent); |
729 | extern void ata_port_detach(struct ata_port *ap); | 728 | extern void ata_host_detach(struct ata_host *host); |
730 | extern void ata_host_init(struct ata_host *, struct device *, | 729 | extern void ata_host_init(struct ata_host *, struct device *, |
731 | unsigned long, const struct ata_port_operations *); | 730 | unsigned long, const struct ata_port_operations *); |
732 | extern void ata_host_remove(struct ata_host *host); | ||
733 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 731 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
734 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 732 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
735 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 733 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
736 | extern int ata_scsi_release(struct Scsi_Host *host); | ||
737 | extern void ata_sas_port_destroy(struct ata_port *); | 734 | extern void ata_sas_port_destroy(struct ata_port *); |
738 | extern struct ata_port *ata_sas_port_alloc(struct ata_host *, | 735 | extern struct ata_port *ata_sas_port_alloc(struct ata_host *, |
739 | struct ata_port_info *, struct Scsi_Host *); | 736 | struct ata_port_info *, struct Scsi_Host *); |
@@ -776,15 +773,11 @@ extern u8 ata_check_status(struct ata_port *ap); | |||
776 | extern u8 ata_altstatus(struct ata_port *ap); | 773 | extern u8 ata_altstatus(struct ata_port *ap); |
777 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | 774 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
778 | extern int ata_port_start (struct ata_port *ap); | 775 | extern int ata_port_start (struct ata_port *ap); |
779 | extern void ata_port_stop (struct ata_port *ap); | ||
780 | extern void ata_host_stop (struct ata_host *host); | ||
781 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance); | 776 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance); |
782 | extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, | 777 | extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, |
783 | unsigned int buflen, int write_data); | 778 | unsigned int buflen, int write_data); |
784 | extern void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, | 779 | extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, |
785 | unsigned int buflen, int write_data); | 780 | unsigned int buflen, int write_data); |
786 | extern void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, | ||
787 | unsigned int buflen, int write_data); | ||
788 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 781 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
789 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); | 782 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); |
790 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 783 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); |
@@ -826,6 +819,10 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev); | |||
826 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, | 819 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, |
827 | int queue_depth); | 820 | int queue_depth); |
828 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); | 821 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); |
822 | extern u8 ata_irq_on(struct ata_port *ap); | ||
823 | extern u8 ata_dummy_irq_on(struct ata_port *ap); | ||
824 | extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq); | ||
825 | extern u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq); | ||
829 | 826 | ||
830 | /* | 827 | /* |
831 | * Timing helpers | 828 | * Timing helpers |
@@ -864,7 +861,6 @@ struct pci_bits { | |||
864 | unsigned long val; | 861 | unsigned long val; |
865 | }; | 862 | }; |
866 | 863 | ||
867 | extern void ata_pci_host_stop (struct ata_host *host); | ||
868 | extern struct ata_probe_ent * | 864 | extern struct ata_probe_ent * |
869 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); | 865 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); |
870 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); | 866 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); |
@@ -1096,10 +1092,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap) | |||
1096 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 1092 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
1097 | 1093 | ||
1098 | if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) { | 1094 | if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) { |
1099 | unsigned long l = ap->ioaddr.status_addr; | ||
1100 | if (ata_msg_warn(ap)) | 1095 | if (ata_msg_warn(ap)) |
1101 | printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n", | 1096 | printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%p\n", |
1102 | status, l); | 1097 | status, ap->ioaddr.status_addr); |
1103 | } | 1098 | } |
1104 | 1099 | ||
1105 | return status; | 1100 | return status; |
@@ -1149,8 +1144,7 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
1149 | qc->dma_dir = DMA_NONE; | 1144 | qc->dma_dir = DMA_NONE; |
1150 | qc->__sg = NULL; | 1145 | qc->__sg = NULL; |
1151 | qc->flags = 0; | 1146 | qc->flags = 0; |
1152 | qc->cursect = qc->cursg = qc->cursg_ofs = 0; | 1147 | qc->cursg = qc->cursg_ofs = 0; |
1153 | qc->nsect = 0; | ||
1154 | qc->nbytes = qc->curbytes = 0; | 1148 | qc->nbytes = qc->curbytes = 0; |
1155 | qc->n_elem = 0; | 1149 | qc->n_elem = 0; |
1156 | qc->err_mask = 0; | 1150 | qc->err_mask = 0; |
@@ -1163,51 +1157,6 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
1163 | qc->result_tf.feature = 0; | 1157 | qc->result_tf.feature = 0; |
1164 | } | 1158 | } |
1165 | 1159 | ||
1166 | /** | ||
1167 | * ata_irq_ack - Acknowledge a device interrupt. | ||
1168 | * @ap: Port on which interrupts are enabled. | ||
1169 | * | ||
1170 | * Wait up to 10 ms for legacy IDE device to become idle (BUSY | ||
1171 | * or BUSY+DRQ clear). Obtain dma status and port status from | ||
1172 | * device. Clear the interrupt. Return port status. | ||
1173 | * | ||
1174 | * LOCKING: | ||
1175 | */ | ||
1176 | |||
1177 | static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | ||
1178 | { | ||
1179 | unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; | ||
1180 | u8 host_stat, post_stat, status; | ||
1181 | |||
1182 | status = ata_busy_wait(ap, bits, 1000); | ||
1183 | if (status & bits) | ||
1184 | if (ata_msg_err(ap)) | ||
1185 | printk(KERN_ERR "abnormal status 0x%X\n", status); | ||
1186 | |||
1187 | /* get controller status; clear intr, err bits */ | ||
1188 | if (ap->flags & ATA_FLAG_MMIO) { | ||
1189 | void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; | ||
1190 | host_stat = readb(mmio + ATA_DMA_STATUS); | ||
1191 | writeb(host_stat | ATA_DMA_INTR | ATA_DMA_ERR, | ||
1192 | mmio + ATA_DMA_STATUS); | ||
1193 | |||
1194 | post_stat = readb(mmio + ATA_DMA_STATUS); | ||
1195 | } else { | ||
1196 | host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | ||
1197 | outb(host_stat | ATA_DMA_INTR | ATA_DMA_ERR, | ||
1198 | ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | ||
1199 | |||
1200 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | ||
1201 | } | ||
1202 | |||
1203 | if (ata_msg_intr(ap)) | ||
1204 | printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", | ||
1205 | __FUNCTION__, | ||
1206 | host_stat, post_stat, status); | ||
1207 | |||
1208 | return status; | ||
1209 | } | ||
1210 | |||
1211 | static inline int ata_try_flush_cache(const struct ata_device *dev) | 1160 | static inline int ata_try_flush_cache(const struct ata_device *dev) |
1212 | { | 1161 | { |
1213 | return ata_id_wcache_enabled(dev->id) || | 1162 | return ata_id_wcache_enabled(dev->id) || |
@@ -1235,14 +1184,14 @@ static inline unsigned int __ac_err_mask(u8 status) | |||
1235 | static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev) | 1184 | static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev) |
1236 | { | 1185 | { |
1237 | ap->pad_dma = 0; | 1186 | ap->pad_dma = 0; |
1238 | ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, | 1187 | ap->pad = dmam_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, |
1239 | &ap->pad_dma, GFP_KERNEL); | 1188 | &ap->pad_dma, GFP_KERNEL); |
1240 | return (ap->pad == NULL) ? -ENOMEM : 0; | 1189 | return (ap->pad == NULL) ? -ENOMEM : 0; |
1241 | } | 1190 | } |
1242 | 1191 | ||
1243 | static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | 1192 | static inline void ata_pad_free(struct ata_port *ap, struct device *dev) |
1244 | { | 1193 | { |
1245 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | 1194 | dmam_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); |
1246 | } | 1195 | } |
1247 | 1196 | ||
1248 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | 1197 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) |