aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h131
1 files changed, 37 insertions, 94 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 91bb8ceef0b5..596e0c18887d 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -31,7 +31,7 @@
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>
@@ -54,8 +54,6 @@
54#undef ATA_VERBOSE_DEBUG /* yet more debugging output */ 54#undef ATA_VERBOSE_DEBUG /* yet more debugging output */
55#undef ATA_IRQ_TRAP /* define to ack screaming irqs */ 55#undef ATA_IRQ_TRAP /* define to ack screaming irqs */
56#undef ATA_NDEBUG /* define to disable quick runtime checks */ 56#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 57
60 58
61/* note: prints function name for you */ 59/* note: prints function name for you */
@@ -109,10 +107,6 @@ static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
109#define ATA_TAG_POISON 0xfafbfcfdU 107#define ATA_TAG_POISON 0xfafbfcfdU
110 108
111/* move to PCI layer? */ 109/* 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
116static inline struct device *pci_dev_to_dev(struct pci_dev *pdev) 110static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
117{ 111{
118 return &pdev->dev; 112 return &pdev->dev;
@@ -308,7 +302,7 @@ enum {
308 * most devices. 302 * most devices.
309 */ 303 */
310 ATA_SPINUP_WAIT = 8000, 304 ATA_SPINUP_WAIT = 8000,
311 305
312 /* Horkage types. May be set by libata or controller on drives 306 /* Horkage types. May be set by libata or controller on drives
313 (some horkage may be drive/controller pair dependant */ 307 (some horkage may be drive/controller pair dependant */
314 308
@@ -352,21 +346,21 @@ typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes);
352typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); 346typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes);
353 347
354struct ata_ioports { 348struct ata_ioports {
355 unsigned long cmd_addr; 349 void __iomem *cmd_addr;
356 unsigned long data_addr; 350 void __iomem *data_addr;
357 unsigned long error_addr; 351 void __iomem *error_addr;
358 unsigned long feature_addr; 352 void __iomem *feature_addr;
359 unsigned long nsect_addr; 353 void __iomem *nsect_addr;
360 unsigned long lbal_addr; 354 void __iomem *lbal_addr;
361 unsigned long lbam_addr; 355 void __iomem *lbam_addr;
362 unsigned long lbah_addr; 356 void __iomem *lbah_addr;
363 unsigned long device_addr; 357 void __iomem *device_addr;
364 unsigned long status_addr; 358 void __iomem *status_addr;
365 unsigned long command_addr; 359 void __iomem *command_addr;
366 unsigned long altstatus_addr; 360 void __iomem *altstatus_addr;
367 unsigned long ctl_addr; 361 void __iomem *ctl_addr;
368 unsigned long bmdma_addr; 362 void __iomem *bmdma_addr;
369 unsigned long scr_addr; 363 void __iomem *scr_addr;
370}; 364};
371 365
372struct ata_probe_ent { 366struct ata_probe_ent {
@@ -385,7 +379,7 @@ struct ata_probe_ent {
385 unsigned int irq_flags; 379 unsigned int irq_flags;
386 unsigned long port_flags; 380 unsigned long port_flags;
387 unsigned long _host_flags; 381 unsigned long _host_flags;
388 void __iomem *mmio_base; 382 void __iomem * const *iomap;
389 void *private_data; 383 void *private_data;
390 384
391 /* port_info for the secondary port. Together with irq2, it's 385 /* port_info for the secondary port. Together with irq2, it's
@@ -402,7 +396,7 @@ struct ata_host {
402 struct device *dev; 396 struct device *dev;
403 unsigned long irq; 397 unsigned long irq;
404 unsigned long irq2; 398 unsigned long irq2;
405 void __iomem *mmio_base; 399 void __iomem * const *iomap;
406 unsigned int n_ports; 400 unsigned int n_ports;
407 void *private_data; 401 void *private_data;
408 const struct ata_port_operations *ops; 402 const struct ata_port_operations *ops;
@@ -431,9 +425,6 @@ struct ata_queued_cmd {
431 425
432 unsigned int pad_len; 426 unsigned int pad_len;
433 427
434 unsigned int nsect;
435 unsigned int cursect;
436
437 unsigned int nbytes; 428 unsigned int nbytes;
438 unsigned int curbytes; 429 unsigned int curbytes;
439 430
@@ -639,6 +630,8 @@ struct ata_port_operations {
639 630
640 irq_handler_t irq_handler; 631 irq_handler_t irq_handler;
641 void (*irq_clear) (struct ata_port *); 632 void (*irq_clear) (struct ata_port *);
633 u8 (*irq_on) (struct ata_port *);
634 u8 (*irq_ack) (struct ata_port *ap, unsigned int chk_drq);
642 635
643 u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); 636 u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
644 void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, 637 void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
@@ -720,20 +713,18 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
720 unsigned int n_ports); 713 unsigned int n_ports);
721extern void ata_pci_remove_one (struct pci_dev *pdev); 714extern void ata_pci_remove_one (struct pci_dev *pdev);
722extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); 715extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
723extern void ata_pci_device_do_resume(struct pci_dev *pdev); 716extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
724extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 717extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
725extern int ata_pci_device_resume(struct pci_dev *pdev); 718extern int ata_pci_device_resume(struct pci_dev *pdev);
726extern int ata_pci_clear_simplex(struct pci_dev *pdev); 719extern int ata_pci_clear_simplex(struct pci_dev *pdev);
727#endif /* CONFIG_PCI */ 720#endif /* CONFIG_PCI */
728extern int ata_device_add(const struct ata_probe_ent *ent); 721extern int ata_device_add(const struct ata_probe_ent *ent);
729extern void ata_port_detach(struct ata_port *ap); 722extern void ata_host_detach(struct ata_host *host);
730extern void ata_host_init(struct ata_host *, struct device *, 723extern void ata_host_init(struct ata_host *, struct device *,
731 unsigned long, const struct ata_port_operations *); 724 unsigned long, const struct ata_port_operations *);
732extern void ata_host_remove(struct ata_host *host);
733extern int ata_scsi_detect(struct scsi_host_template *sht); 725extern int ata_scsi_detect(struct scsi_host_template *sht);
734extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 726extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
735extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 727extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
736extern int ata_scsi_release(struct Scsi_Host *host);
737extern void ata_sas_port_destroy(struct ata_port *); 728extern void ata_sas_port_destroy(struct ata_port *);
738extern struct ata_port *ata_sas_port_alloc(struct ata_host *, 729extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
739 struct ata_port_info *, struct Scsi_Host *); 730 struct ata_port_info *, struct Scsi_Host *);
@@ -776,15 +767,11 @@ extern u8 ata_check_status(struct ata_port *ap);
776extern u8 ata_altstatus(struct ata_port *ap); 767extern u8 ata_altstatus(struct ata_port *ap);
777extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); 768extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
778extern int ata_port_start (struct ata_port *ap); 769extern int ata_port_start (struct ata_port *ap);
779extern void ata_port_stop (struct ata_port *ap);
780extern void ata_host_stop (struct ata_host *host);
781extern irqreturn_t ata_interrupt (int irq, void *dev_instance); 770extern irqreturn_t ata_interrupt (int irq, void *dev_instance);
782extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, 771extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf,
783 unsigned int buflen, int write_data); 772 unsigned int buflen, int write_data);
784extern void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, 773extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
785 unsigned int buflen, int write_data); 774 unsigned int buflen, int write_data);
786extern void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
787 unsigned int buflen, int write_data);
788extern void ata_qc_prep(struct ata_queued_cmd *qc); 775extern void ata_qc_prep(struct ata_queued_cmd *qc);
789extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 776extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
790extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); 777extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
@@ -826,6 +813,10 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
826extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, 813extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
827 int queue_depth); 814 int queue_depth);
828extern struct ata_device *ata_dev_pair(struct ata_device *adev); 815extern struct ata_device *ata_dev_pair(struct ata_device *adev);
816extern u8 ata_irq_on(struct ata_port *ap);
817extern u8 ata_dummy_irq_on(struct ata_port *ap);
818extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq);
819extern u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq);
829 820
830/* 821/*
831 * Timing helpers 822 * Timing helpers
@@ -864,7 +855,6 @@ struct pci_bits {
864 unsigned long val; 855 unsigned long val;
865}; 856};
866 857
867extern void ata_pci_host_stop (struct ata_host *host);
868extern struct ata_probe_ent * 858extern struct ata_probe_ent *
869ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); 859ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
870extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 860extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
@@ -1096,10 +1086,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
1096 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 1086 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
1097 1087
1098 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) { 1088 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) {
1099 unsigned long l = ap->ioaddr.status_addr;
1100 if (ata_msg_warn(ap)) 1089 if (ata_msg_warn(ap))
1101 printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n", 1090 printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%p\n",
1102 status, l); 1091 status, ap->ioaddr.status_addr);
1103 } 1092 }
1104 1093
1105 return status; 1094 return status;
@@ -1149,8 +1138,7 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1149 qc->dma_dir = DMA_NONE; 1138 qc->dma_dir = DMA_NONE;
1150 qc->__sg = NULL; 1139 qc->__sg = NULL;
1151 qc->flags = 0; 1140 qc->flags = 0;
1152 qc->cursect = qc->cursg = qc->cursg_ofs = 0; 1141 qc->cursg = qc->cursg_ofs = 0;
1153 qc->nsect = 0;
1154 qc->nbytes = qc->curbytes = 0; 1142 qc->nbytes = qc->curbytes = 0;
1155 qc->n_elem = 0; 1143 qc->n_elem = 0;
1156 qc->err_mask = 0; 1144 qc->err_mask = 0;
@@ -1163,51 +1151,6 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1163 qc->result_tf.feature = 0; 1151 qc->result_tf.feature = 0;
1164} 1152}
1165 1153
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
1177static 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
1211static inline int ata_try_flush_cache(const struct ata_device *dev) 1154static inline int ata_try_flush_cache(const struct ata_device *dev)
1212{ 1155{
1213 return ata_id_wcache_enabled(dev->id) || 1156 return ata_id_wcache_enabled(dev->id) ||
@@ -1235,14 +1178,14 @@ static inline unsigned int __ac_err_mask(u8 status)
1235static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev) 1178static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev)
1236{ 1179{
1237 ap->pad_dma = 0; 1180 ap->pad_dma = 0;
1238 ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, 1181 ap->pad = dmam_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ,
1239 &ap->pad_dma, GFP_KERNEL); 1182 &ap->pad_dma, GFP_KERNEL);
1240 return (ap->pad == NULL) ? -ENOMEM : 0; 1183 return (ap->pad == NULL) ? -ENOMEM : 0;
1241} 1184}
1242 1185
1243static inline void ata_pad_free(struct ata_port *ap, struct device *dev) 1186static inline void ata_pad_free(struct ata_port *ap, struct device *dev)
1244{ 1187{
1245 dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); 1188 dmam_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
1246} 1189}
1247 1190
1248static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) 1191static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)