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.h123
1 files changed, 76 insertions, 47 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index b870b20df43c..d8cfc72ea9c1 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -35,6 +35,7 @@
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
@@ -209,6 +210,7 @@ enum {
209 210
210 /* host set flags */ 211 /* host set flags */
211 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */ 212 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */
213 ATA_HOST_STARTED = (1 << 1), /* Host started */
212 214
213 /* various lengths of time */ 215 /* various lengths of time */
214 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 216 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */
@@ -280,11 +282,13 @@ enum {
280 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ 282 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */
281 ATA_EHI_QUIET = (1 << 3), /* be quiet */ 283 ATA_EHI_QUIET = (1 << 3), /* be quiet */
282 284
283 ATA_EHI_DID_RESET = (1 << 16), /* already reset this port */ 285 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */
284 ATA_EHI_PRINTINFO = (1 << 17), /* print configuration info */ 286 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
285 ATA_EHI_SETMODE = (1 << 18), /* configure transfer mode */ 287 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */
286 ATA_EHI_POST_SETMODE = (1 << 19), /* revaildating after setmode */ 288 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */
289 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */
287 290
291 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
288 ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK, 292 ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK,
289 293
290 /* max repeat if error condition is still set after ->error_handler */ 294 /* max repeat if error condition is still set after ->error_handler */
@@ -310,15 +314,17 @@ enum {
310 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */ 314 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */
311 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */ 315 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */
312 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ 316 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */
317 ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */
318 ATA_HORKAGE_DMA_RW_ONLY = (1 << 4), /* ATAPI DMA for RW only */
313}; 319};
314 320
315enum hsm_task_states { 321enum hsm_task_states {
316 HSM_ST_IDLE, /* no command on going */ 322 HSM_ST_IDLE, /* no command on going */
323 HSM_ST_FIRST, /* (waiting the device to)
324 write CDB or first data block */
317 HSM_ST, /* (waiting the device to) transfer data */ 325 HSM_ST, /* (waiting the device to) transfer data */
318 HSM_ST_LAST, /* (waiting the device to) complete command */ 326 HSM_ST_LAST, /* (waiting the device to) complete command */
319 HSM_ST_ERR, /* error */ 327 HSM_ST_ERR, /* error */
320 HSM_ST_FIRST, /* (waiting the device to)
321 write CDB or first data block */
322}; 328};
323 329
324enum ata_completion_errors { 330enum ata_completion_errors {
@@ -364,34 +370,6 @@ struct ata_ioports {
364 void __iomem *scr_addr; 370 void __iomem *scr_addr;
365}; 371};
366 372
367struct ata_probe_ent {
368 struct list_head node;
369 struct device *dev;
370 const struct ata_port_operations *port_ops;
371 struct scsi_host_template *sht;
372 struct ata_ioports port[ATA_MAX_PORTS];
373 unsigned int n_ports;
374 unsigned int dummy_port_mask;
375 unsigned int pio_mask;
376 unsigned int mwdma_mask;
377 unsigned int udma_mask;
378 unsigned long irq;
379 unsigned long irq2;
380 unsigned int irq_flags;
381 unsigned long port_flags;
382 unsigned long _host_flags;
383 void __iomem * const *iomap;
384 void *private_data;
385
386 /* port_info for the secondary port. Together with irq2, it's
387 * used to implement non-uniform secondary port. Currently,
388 * the only user is ata_piix combined mode. This workaround
389 * will be removed together with ata_probe_ent when init model
390 * is updated.
391 */
392 const struct ata_port_info *pinfo2;
393};
394
395struct ata_host { 373struct ata_host {
396 spinlock_t lock; 374 spinlock_t lock;
397 struct device *dev; 375 struct device *dev;
@@ -402,8 +380,7 @@ struct ata_host {
402 void *private_data; 380 void *private_data;
403 const struct ata_port_operations *ops; 381 const struct ata_port_operations *ops;
404 unsigned long flags; 382 unsigned long flags;
405 int simplex_claimed; /* Keep seperate in case we 383 struct ata_port *simplex_claimed; /* channel owning the DMA */
406 ever need to do this locked */
407 struct ata_port *ports[0]; 384 struct ata_port *ports[0];
408}; 385};
409 386
@@ -425,6 +402,7 @@ struct ata_queued_cmd {
425 int dma_dir; 402 int dma_dir;
426 403
427 unsigned int pad_len; 404 unsigned int pad_len;
405 unsigned int sect_size;
428 406
429 unsigned int nbytes; 407 unsigned int nbytes;
430 unsigned int curbytes; 408 unsigned int curbytes;
@@ -470,6 +448,7 @@ struct ata_device {
470 struct scsi_device *sdev; /* attached SCSI device */ 448 struct scsi_device *sdev; /* attached SCSI device */
471 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 449 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
472 u64 n_sectors; /* size of device, if ATA */ 450 u64 n_sectors; /* size of device, if ATA */
451 u64 n_sectors_boot; /* size of ATA device at startup */
473 unsigned int class; /* ATA_DEV_xxx */ 452 unsigned int class; /* ATA_DEV_xxx */
474 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ 453 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
475 u8 pio_mode; 454 u8 pio_mode;
@@ -494,7 +473,12 @@ struct ata_device {
494 473
495 /* error history */ 474 /* error history */
496 struct ata_ering ering; 475 struct ata_ering ering;
476 int spdn_cnt;
497 unsigned int horkage; /* List of broken features */ 477 unsigned int horkage; /* List of broken features */
478#ifdef CONFIG_SATA_ACPI
479 /* ACPI objects info */
480 acpi_handle obj_handle;
481#endif
498}; 482};
499 483
500/* Offset into struct ata_device. Fields above it are maintained 484/* Offset into struct ata_device. Fields above it are maintained
@@ -530,8 +514,8 @@ struct ata_port {
530 spinlock_t *lock; 514 spinlock_t *lock;
531 unsigned long flags; /* ATA_FLAG_xxx */ 515 unsigned long flags; /* ATA_FLAG_xxx */
532 unsigned int pflags; /* ATA_PFLAG_xxx */ 516 unsigned int pflags; /* ATA_PFLAG_xxx */
533 unsigned int id; /* unique id req'd by scsi midlyr */ 517 unsigned int print_id; /* user visible unique port ID */
534 unsigned int port_no; /* unique port #; from zero */ 518 unsigned int port_no; /* 0 based port no. inside the host */
535 519
536 struct ata_prd *prd; /* our SG list */ 520 struct ata_prd *prd; /* our SG list */
537 dma_addr_t prd_dma; /* and its DMA mapping */ 521 dma_addr_t prd_dma; /* and its DMA mapping */
@@ -590,11 +574,11 @@ struct ata_port {
590struct ata_port_operations { 574struct ata_port_operations {
591 void (*port_disable) (struct ata_port *); 575 void (*port_disable) (struct ata_port *);
592 576
593 void (*dev_config) (struct ata_port *, struct ata_device *); 577 void (*dev_config) (struct ata_device *);
594 578
595 void (*set_piomode) (struct ata_port *, struct ata_device *); 579 void (*set_piomode) (struct ata_port *, struct ata_device *);
596 void (*set_dmamode) (struct ata_port *, struct ata_device *); 580 void (*set_dmamode) (struct ata_port *, struct ata_device *);
597 unsigned long (*mode_filter) (const struct ata_port *, struct ata_device *, unsigned long); 581 unsigned long (*mode_filter) (struct ata_device *, unsigned long);
598 582
599 void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf); 583 void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf);
600 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); 584 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
@@ -609,6 +593,8 @@ struct ata_port_operations {
609 593
610 void (*post_set_mode) (struct ata_port *ap); 594 void (*post_set_mode) (struct ata_port *ap);
611 595
596 int (*cable_detect) (struct ata_port *ap);
597
612 int (*check_atapi_dma) (struct ata_queued_cmd *qc); 598 int (*check_atapi_dma) (struct ata_queued_cmd *qc);
613 599
614 void (*bmdma_setup) (struct ata_queued_cmd *qc); 600 void (*bmdma_setup) (struct ata_queued_cmd *qc);
@@ -657,6 +643,7 @@ struct ata_port_info {
657 unsigned long mwdma_mask; 643 unsigned long mwdma_mask;
658 unsigned long udma_mask; 644 unsigned long udma_mask;
659 const struct ata_port_operations *port_ops; 645 const struct ata_port_operations *port_ops;
646 irq_handler_t irq_handler;
660 void *private_data; 647 void *private_data;
661}; 648};
662 649
@@ -679,6 +666,7 @@ extern const unsigned long sata_deb_timing_hotplug[];
679extern const unsigned long sata_deb_timing_long[]; 666extern const unsigned long sata_deb_timing_long[];
680 667
681extern const struct ata_port_operations ata_dummy_port_ops; 668extern const struct ata_port_operations ata_dummy_port_ops;
669extern const struct ata_port_info ata_dummy_port_info;
682 670
683static inline const unsigned long * 671static inline const unsigned long *
684sata_ehc_deb_timing(struct ata_eh_context *ehc) 672sata_ehc_deb_timing(struct ata_eh_context *ehc)
@@ -694,6 +682,7 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
694 return ap->ops == &ata_dummy_port_ops; 682 return ap->ops == &ata_dummy_port_ops;
695} 683}
696 684
685extern void sata_print_link_status(struct ata_port *ap);
697extern void ata_port_probe(struct ata_port *); 686extern void ata_port_probe(struct ata_port *);
698extern void __sata_phy_reset(struct ata_port *ap); 687extern void __sata_phy_reset(struct ata_port *ap);
699extern void sata_phy_reset(struct ata_port *ap); 688extern void sata_phy_reset(struct ata_port *ap);
@@ -713,13 +702,23 @@ extern void ata_std_ports(struct ata_ioports *ioaddr);
713extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 702extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
714 unsigned int n_ports); 703 unsigned int n_ports);
715extern void ata_pci_remove_one (struct pci_dev *pdev); 704extern void ata_pci_remove_one (struct pci_dev *pdev);
705#ifdef CONFIG_PM
716extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); 706extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
717extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); 707extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
718extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 708extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
719extern int ata_pci_device_resume(struct pci_dev *pdev); 709extern int ata_pci_device_resume(struct pci_dev *pdev);
710#endif
720extern int ata_pci_clear_simplex(struct pci_dev *pdev); 711extern int ata_pci_clear_simplex(struct pci_dev *pdev);
721#endif /* CONFIG_PCI */ 712#endif /* CONFIG_PCI */
722extern int ata_device_add(const struct ata_probe_ent *ent); 713extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
714extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
715 const struct ata_port_info * const * ppi, int n_ports);
716extern int ata_host_start(struct ata_host *host);
717extern int ata_host_register(struct ata_host *host,
718 struct scsi_host_template *sht);
719extern int ata_host_activate(struct ata_host *host, int irq,
720 irq_handler_t irq_handler, unsigned long irq_flags,
721 struct scsi_host_template *sht);
723extern void ata_host_detach(struct ata_host *host); 722extern void ata_host_detach(struct ata_host *host);
724extern void ata_host_init(struct ata_host *, struct device *, 723extern void ata_host_init(struct ata_host *, struct device *,
725 unsigned long, const struct ata_port_operations *); 724 unsigned long, const struct ata_port_operations *);
@@ -742,10 +741,12 @@ extern int sata_scr_write(struct ata_port *ap, int reg, u32 val);
742extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); 741extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val);
743extern int ata_port_online(struct ata_port *ap); 742extern int ata_port_online(struct ata_port *ap);
744extern int ata_port_offline(struct ata_port *ap); 743extern int ata_port_offline(struct ata_port *ap);
744#ifdef CONFIG_PM
745extern int ata_scsi_device_resume(struct scsi_device *); 745extern int ata_scsi_device_resume(struct scsi_device *);
746extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg); 746extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg);
747extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 747extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
748extern void ata_host_resume(struct ata_host *host); 748extern void ata_host_resume(struct ata_host *host);
749#endif
749extern int ata_ratelimit(void); 750extern int ata_ratelimit(void);
750extern int ata_busy_sleep(struct ata_port *ap, 751extern int ata_busy_sleep(struct ata_port *ap,
751 unsigned long timeout_pat, unsigned long timeout); 752 unsigned long timeout_pat, unsigned long timeout);
@@ -754,6 +755,7 @@ extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn,
754extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 755extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
755 unsigned long interval_msec, 756 unsigned long interval_msec,
756 unsigned long timeout_msec); 757 unsigned long timeout_msec);
758extern unsigned int ata_dev_try_classify(struct ata_port *, unsigned int, u8 *);
757 759
758/* 760/*
759 * Default driver ops implementations 761 * Default driver ops implementations
@@ -781,10 +783,12 @@ extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
781extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 783extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
782 unsigned int n_elem); 784 unsigned int n_elem);
783extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 785extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
786extern void ata_dev_disable(struct ata_device *adev);
784extern void ata_id_string(const u16 *id, unsigned char *s, 787extern void ata_id_string(const u16 *id, unsigned char *s,
785 unsigned int ofs, unsigned int len); 788 unsigned int ofs, unsigned int len);
786extern void ata_id_c_string(const u16 *id, unsigned char *s, 789extern void ata_id_c_string(const u16 *id, unsigned char *s,
787 unsigned int ofs, unsigned int len); 790 unsigned int ofs, unsigned int len);
791extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown);
788extern unsigned long ata_device_blacklisted(const struct ata_device *dev); 792extern unsigned long ata_device_blacklisted(const struct ata_device *dev);
789extern void ata_bmdma_setup (struct ata_queued_cmd *qc); 793extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
790extern void ata_bmdma_start (struct ata_queued_cmd *qc); 794extern void ata_bmdma_start (struct ata_queued_cmd *qc);
@@ -814,11 +818,17 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
814extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, 818extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
815 int queue_depth); 819 int queue_depth);
816extern struct ata_device *ata_dev_pair(struct ata_device *adev); 820extern struct ata_device *ata_dev_pair(struct ata_device *adev);
821extern int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
817extern u8 ata_irq_on(struct ata_port *ap); 822extern u8 ata_irq_on(struct ata_port *ap);
818extern u8 ata_dummy_irq_on(struct ata_port *ap); 823extern u8 ata_dummy_irq_on(struct ata_port *ap);
819extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq); 824extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq);
820extern u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq); 825extern u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq);
821 826
827extern int ata_cable_40wire(struct ata_port *ap);
828extern int ata_cable_80wire(struct ata_port *ap);
829extern int ata_cable_sata(struct ata_port *ap);
830extern int ata_cable_unknown(struct ata_port *ap);
831
822/* 832/*
823 * Timing helpers 833 * Timing helpers
824 */ 834 */
@@ -856,10 +866,13 @@ struct pci_bits {
856 unsigned long val; 866 unsigned long val;
857}; 867};
858 868
859extern struct ata_probe_ent * 869extern int ata_pci_init_native_host(struct ata_host *host,
860ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); 870 unsigned int port_mask);
871extern int ata_pci_prepare_native_host(struct pci_dev *pdev,
872 const struct ata_port_info * const * ppi,
873 int n_ports, struct ata_host **r_host);
861extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 874extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
862extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); 875extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long);
863#endif /* CONFIG_PCI */ 876#endif /* CONFIG_PCI */
864 877
865/* 878/*
@@ -885,10 +898,10 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
885 * printk helpers 898 * printk helpers
886 */ 899 */
887#define ata_port_printk(ap, lv, fmt, args...) \ 900#define ata_port_printk(ap, lv, fmt, args...) \
888 printk(lv"ata%u: "fmt, (ap)->id , ##args) 901 printk(lv"ata%u: "fmt, (ap)->print_id , ##args)
889 902
890#define ata_dev_printk(dev, lv, fmt, args...) \ 903#define ata_dev_printk(dev, lv, fmt, args...) \
891 printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) 904 printk(lv"ata%u.%02u: "fmt, (dev)->ap->print_id, (dev)->devno , ##args)
892 905
893/* 906/*
894 * ata_eh_info helpers 907 * ata_eh_info helpers
@@ -1026,6 +1039,21 @@ static inline u8 ata_chk_status(struct ata_port *ap)
1026 return ap->ops->check_status(ap); 1039 return ap->ops->check_status(ap);
1027} 1040}
1028 1041
1042/**
1043 * ata_ncq_enabled - Test whether NCQ is enabled
1044 * @dev: ATA device to test for
1045 *
1046 * LOCKING:
1047 * spin_lock_irqsave(host lock)
1048 *
1049 * RETURNS:
1050 * 1 if NCQ is enabled for @dev, 0 otherwise.
1051 */
1052static inline int ata_ncq_enabled(struct ata_device *dev)
1053{
1054 return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
1055 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
1056}
1029 1057
1030/** 1058/**
1031 * ata_pause - Flush writes and pause 400 nanoseconds. 1059 * ata_pause - Flush writes and pause 400 nanoseconds.
@@ -1144,6 +1172,7 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1144 qc->n_elem = 0; 1172 qc->n_elem = 0;
1145 qc->err_mask = 0; 1173 qc->err_mask = 0;
1146 qc->pad_len = 0; 1174 qc->pad_len = 0;
1175 qc->sect_size = ATA_SECT_SIZE;
1147 1176
1148 ata_tf_init(qc->dev, &qc->tf); 1177 ata_tf_init(qc->dev, &qc->tf);
1149 1178
@@ -1191,7 +1220,7 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev)
1191 1220
1192static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) 1221static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1193{ 1222{
1194 return (struct ata_port *) &host->hostdata[0]; 1223 return *(struct ata_port **)&host->hostdata[0];
1195} 1224}
1196 1225
1197#endif /* __LINUX_LIBATA_H__ */ 1226#endif /* __LINUX_LIBATA_H__ */