diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-18 11:38:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-18 11:38:06 -0400 |
commit | 8019aa946af5218bc4446c21e43cc19c9401ac68 (patch) | |
tree | 6681b73a560f5a4e4a4e8f97b3833a087a488439 /include/linux | |
parent | 73e3e6481f56b3b5b618671a8d32b19a35f84316 (diff) | |
parent | 48feb3c419508487becfb9ea3afcc54c3eac6d80 (diff) |
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (79 commits)
ata-acpi: don't call _GTF for disabled drive
sata_mv add temporary 3 second init delay for SiliconImage PMs
sata_mv remove redundant edma init code
sata_mv add basic port multiplier support
sata_mv fix SOC flags, enable NCQ on SOC
sata_mv disable hotplug for now
sata_mv cosmetics
sata_mv hardreset rework
[libata] improve Kconfig help text for new PMP, SFF options
libata: make EH fail gracefully if no reset method is available
libata: Be a bit more slack about early devices
libata: cable logic
libata: move link onlineness check out of softreset methods
libata: kill dead code paths in reset path
pata_scc: fix build breakage
libata: make PMP support optional
libata: implement PMP helpers
libata: separate PMP support code from core code
libata: make SFF support optional
libata: don't use ap->ioaddr in non-SFF drivers
...
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/libata.h | 718 |
1 files changed, 432 insertions, 286 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 37ee881c42ac..165734a2dd47 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -122,6 +122,8 @@ enum { | |||
122 | 122 | ||
123 | ATAPI_MAX_DRAIN = 16 << 10, | 123 | ATAPI_MAX_DRAIN = 16 << 10, |
124 | 124 | ||
125 | ATA_ALL_DEVICES = (1 << ATA_MAX_DEVICES) - 1, | ||
126 | |||
125 | ATA_SHT_EMULATED = 1, | 127 | ATA_SHT_EMULATED = 1, |
126 | ATA_SHT_CMD_PER_LUN = 1, | 128 | ATA_SHT_CMD_PER_LUN = 1, |
127 | ATA_SHT_THIS_ID = -1, | 129 | ATA_SHT_THIS_ID = -1, |
@@ -163,9 +165,6 @@ enum { | |||
163 | ATA_DEV_NONE = 9, /* no device */ | 165 | ATA_DEV_NONE = 9, /* no device */ |
164 | 166 | ||
165 | /* struct ata_link flags */ | 167 | /* struct ata_link flags */ |
166 | ATA_LFLAG_HRST_TO_RESUME = (1 << 0), /* hardreset to resume link */ | ||
167 | ATA_LFLAG_SKIP_D2H_BSY = (1 << 1), /* can't wait for the first D2H | ||
168 | * Register FIS clearing BSY */ | ||
169 | ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ | 168 | ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ |
170 | ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ | 169 | ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ |
171 | ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ | 170 | ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ |
@@ -225,6 +224,7 @@ enum { | |||
225 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ | 224 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ |
226 | ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ | 225 | ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ |
227 | ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */ | 226 | ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */ |
227 | ATA_QCFLAG_RETRY = (1 << 7), /* retry after failure */ | ||
228 | 228 | ||
229 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ | 229 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ |
230 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ | 230 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ |
@@ -249,6 +249,25 @@ enum { | |||
249 | */ | 249 | */ |
250 | ATA_TMOUT_FF_WAIT = 4 * HZ / 5, | 250 | ATA_TMOUT_FF_WAIT = 4 * HZ / 5, |
251 | 251 | ||
252 | /* Spec mandates to wait for ">= 2ms" before checking status | ||
253 | * after reset. We wait 150ms, because that was the magic | ||
254 | * delay used for ATAPI devices in Hale Landis's ATADRVR, for | ||
255 | * the period of time between when the ATA command register is | ||
256 | * written, and then status is checked. Because waiting for | ||
257 | * "a while" before checking status is fine, post SRST, we | ||
258 | * perform this magic delay here as well. | ||
259 | * | ||
260 | * Old drivers/ide uses the 2mS rule and then waits for ready. | ||
261 | */ | ||
262 | ATA_WAIT_AFTER_RESET_MSECS = 150, | ||
263 | |||
264 | /* If PMP is supported, we have to do follow-up SRST. As some | ||
265 | * PMPs don't send D2H Reg FIS after hardreset, LLDs are | ||
266 | * advised to wait only for the following duration before | ||
267 | * doing SRST. | ||
268 | */ | ||
269 | ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ, | ||
270 | |||
252 | /* ATA bus states */ | 271 | /* ATA bus states */ |
253 | BUS_UNKNOWN = 0, | 272 | BUS_UNKNOWN = 0, |
254 | BUS_DMA = 1, | 273 | BUS_DMA = 1, |
@@ -292,17 +311,16 @@ enum { | |||
292 | 311 | ||
293 | /* reset / recovery action types */ | 312 | /* reset / recovery action types */ |
294 | ATA_EH_REVALIDATE = (1 << 0), | 313 | ATA_EH_REVALIDATE = (1 << 0), |
295 | ATA_EH_SOFTRESET = (1 << 1), | 314 | ATA_EH_SOFTRESET = (1 << 1), /* meaningful only in ->prereset */ |
296 | ATA_EH_HARDRESET = (1 << 2), | 315 | ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */ |
316 | ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | ||
297 | ATA_EH_ENABLE_LINK = (1 << 3), | 317 | ATA_EH_ENABLE_LINK = (1 << 3), |
298 | ATA_EH_LPM = (1 << 4), /* link power management action */ | 318 | ATA_EH_LPM = (1 << 4), /* link power management action */ |
299 | 319 | ||
300 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | ||
301 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, | 320 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, |
302 | 321 | ||
303 | /* ata_eh_info->flags */ | 322 | /* ata_eh_info->flags */ |
304 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ | 323 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ |
305 | ATA_EHI_RESUME_LINK = (1 << 1), /* resume link (reset modifier) */ | ||
306 | ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ | 324 | ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ |
307 | ATA_EHI_QUIET = (1 << 3), /* be quiet */ | 325 | ATA_EHI_QUIET = (1 << 3), /* be quiet */ |
308 | 326 | ||
@@ -313,7 +331,6 @@ enum { | |||
313 | ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ | 331 | ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ |
314 | 332 | ||
315 | ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, | 333 | ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, |
316 | ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK, | ||
317 | 334 | ||
318 | /* max tries if error condition is still set after ->error_handler */ | 335 | /* max tries if error condition is still set after ->error_handler */ |
319 | ATA_EH_MAX_TRIES = 5, | 336 | ATA_EH_MAX_TRIES = 5, |
@@ -352,6 +369,22 @@ enum { | |||
352 | ATAPI_READ_CD = 2, /* READ CD [MSF] */ | 369 | ATAPI_READ_CD = 2, /* READ CD [MSF] */ |
353 | ATAPI_PASS_THRU = 3, /* SAT pass-thru */ | 370 | ATAPI_PASS_THRU = 3, /* SAT pass-thru */ |
354 | ATAPI_MISC = 4, /* the rest */ | 371 | ATAPI_MISC = 4, /* the rest */ |
372 | |||
373 | /* Timing constants */ | ||
374 | ATA_TIMING_SETUP = (1 << 0), | ||
375 | ATA_TIMING_ACT8B = (1 << 1), | ||
376 | ATA_TIMING_REC8B = (1 << 2), | ||
377 | ATA_TIMING_CYC8B = (1 << 3), | ||
378 | ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B | | ||
379 | ATA_TIMING_CYC8B, | ||
380 | ATA_TIMING_ACTIVE = (1 << 4), | ||
381 | ATA_TIMING_RECOVER = (1 << 5), | ||
382 | ATA_TIMING_CYCLE = (1 << 6), | ||
383 | ATA_TIMING_UDMA = (1 << 7), | ||
384 | ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B | | ||
385 | ATA_TIMING_REC8B | ATA_TIMING_CYC8B | | ||
386 | ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER | | ||
387 | ATA_TIMING_CYCLE | ATA_TIMING_UDMA, | ||
355 | }; | 388 | }; |
356 | 389 | ||
357 | enum ata_xfer_mask { | 390 | enum ata_xfer_mask { |
@@ -412,6 +445,7 @@ enum link_pm { | |||
412 | }; | 445 | }; |
413 | extern struct class_device_attribute class_device_attr_link_power_management_policy; | 446 | extern struct class_device_attribute class_device_attr_link_power_management_policy; |
414 | 447 | ||
448 | #ifdef CONFIG_ATA_SFF | ||
415 | struct ata_ioports { | 449 | struct ata_ioports { |
416 | void __iomem *cmd_addr; | 450 | void __iomem *cmd_addr; |
417 | void __iomem *data_addr; | 451 | void __iomem *data_addr; |
@@ -429,6 +463,7 @@ struct ata_ioports { | |||
429 | void __iomem *bmdma_addr; | 463 | void __iomem *bmdma_addr; |
430 | void __iomem *scr_addr; | 464 | void __iomem *scr_addr; |
431 | }; | 465 | }; |
466 | #endif /* CONFIG_ATA_SFF */ | ||
432 | 467 | ||
433 | struct ata_host { | 468 | struct ata_host { |
434 | spinlock_t lock; | 469 | spinlock_t lock; |
@@ -436,7 +471,7 @@ struct ata_host { | |||
436 | void __iomem * const *iomap; | 471 | void __iomem * const *iomap; |
437 | unsigned int n_ports; | 472 | unsigned int n_ports; |
438 | void *private_data; | 473 | void *private_data; |
439 | const struct ata_port_operations *ops; | 474 | struct ata_port_operations *ops; |
440 | unsigned long flags; | 475 | unsigned long flags; |
441 | #ifdef CONFIG_ATA_ACPI | 476 | #ifdef CONFIG_ATA_ACPI |
442 | acpi_handle acpi_handle; | 477 | acpi_handle acpi_handle; |
@@ -605,7 +640,7 @@ struct ata_link { | |||
605 | 640 | ||
606 | struct ata_port { | 641 | struct ata_port { |
607 | struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ | 642 | struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ |
608 | const struct ata_port_operations *ops; | 643 | struct ata_port_operations *ops; |
609 | spinlock_t *lock; | 644 | spinlock_t *lock; |
610 | unsigned long flags; /* ATA_FLAG_xxx */ | 645 | unsigned long flags; /* ATA_FLAG_xxx */ |
611 | unsigned int pflags; /* ATA_PFLAG_xxx */ | 646 | unsigned int pflags; /* ATA_PFLAG_xxx */ |
@@ -615,7 +650,9 @@ struct ata_port { | |||
615 | struct ata_prd *prd; /* our SG list */ | 650 | struct ata_prd *prd; /* our SG list */ |
616 | dma_addr_t prd_dma; /* and its DMA mapping */ | 651 | dma_addr_t prd_dma; /* and its DMA mapping */ |
617 | 652 | ||
653 | #ifdef CONFIG_ATA_SFF | ||
618 | struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ | 654 | struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ |
655 | #endif /* CONFIG_ATA_SFF */ | ||
619 | 656 | ||
620 | u8 ctl; /* cache of ATA control register */ | 657 | u8 ctl; /* cache of ATA control register */ |
621 | u8 last_ctl; /* Cache last written value */ | 658 | u8 last_ctl; /* Cache last written value */ |
@@ -667,81 +704,108 @@ struct ata_port { | |||
667 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | 704 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ |
668 | }; | 705 | }; |
669 | 706 | ||
670 | struct ata_port_operations { | 707 | /* The following initializer overrides a method to NULL whether one of |
671 | void (*dev_config) (struct ata_device *); | 708 | * its parent has the method defined or not. This is equivalent to |
672 | 709 | * ERR_PTR(-ENOENT). Unfortunately, ERR_PTR doesn't render a constant | |
673 | void (*set_piomode) (struct ata_port *, struct ata_device *); | 710 | * expression and thus can't be used as an initializer. |
674 | void (*set_dmamode) (struct ata_port *, struct ata_device *); | 711 | */ |
675 | unsigned long (*mode_filter) (struct ata_device *, unsigned long); | 712 | #define ATA_OP_NULL (void *)(unsigned long)(-ENOENT) |
676 | |||
677 | void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf); | ||
678 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | ||
679 | |||
680 | void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf); | ||
681 | u8 (*check_status)(struct ata_port *ap); | ||
682 | u8 (*check_altstatus)(struct ata_port *ap); | ||
683 | void (*dev_select)(struct ata_port *ap, unsigned int device); | ||
684 | |||
685 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ | ||
686 | int (*set_mode) (struct ata_link *link, struct ata_device **r_failed_dev); | ||
687 | |||
688 | int (*cable_detect) (struct ata_port *ap); | ||
689 | |||
690 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | ||
691 | |||
692 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | ||
693 | void (*bmdma_start) (struct ata_queued_cmd *qc); | ||
694 | |||
695 | unsigned int (*data_xfer) (struct ata_device *dev, unsigned char *buf, | ||
696 | unsigned int buflen, int rw); | ||
697 | |||
698 | int (*qc_defer) (struct ata_queued_cmd *qc); | ||
699 | void (*qc_prep) (struct ata_queued_cmd *qc); | ||
700 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); | ||
701 | |||
702 | /* port multiplier */ | ||
703 | void (*pmp_attach) (struct ata_port *ap); | ||
704 | void (*pmp_detach) (struct ata_port *ap); | ||
705 | 713 | ||
706 | /* Error handlers. ->error_handler overrides ->eng_timeout and | 714 | struct ata_port_operations { |
707 | * indicates that new-style EH is in place. | 715 | /* |
716 | * Command execution | ||
708 | */ | 717 | */ |
709 | void (*eng_timeout) (struct ata_port *ap); /* obsolete */ | 718 | int (*qc_defer)(struct ata_queued_cmd *qc); |
710 | 719 | int (*check_atapi_dma)(struct ata_queued_cmd *qc); | |
711 | void (*freeze) (struct ata_port *ap); | 720 | void (*qc_prep)(struct ata_queued_cmd *qc); |
712 | void (*thaw) (struct ata_port *ap); | 721 | unsigned int (*qc_issue)(struct ata_queued_cmd *qc); |
713 | void (*error_handler) (struct ata_port *ap); | 722 | bool (*qc_fill_rtf)(struct ata_queued_cmd *qc); |
714 | void (*post_internal_cmd) (struct ata_queued_cmd *qc); | 723 | |
715 | 724 | /* | |
716 | irq_handler_t irq_handler; | 725 | * Configuration and exception handling |
717 | void (*irq_clear) (struct ata_port *); | 726 | */ |
718 | u8 (*irq_on) (struct ata_port *); | 727 | int (*cable_detect)(struct ata_port *ap); |
719 | 728 | unsigned long (*mode_filter)(struct ata_device *dev, unsigned long xfer_mask); | |
720 | int (*scr_read) (struct ata_port *ap, unsigned int sc_reg, u32 *val); | 729 | void (*set_piomode)(struct ata_port *ap, struct ata_device *dev); |
721 | int (*scr_write) (struct ata_port *ap, unsigned int sc_reg, u32 val); | 730 | void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev); |
731 | int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev); | ||
732 | |||
733 | void (*dev_config)(struct ata_device *dev); | ||
734 | |||
735 | void (*freeze)(struct ata_port *ap); | ||
736 | void (*thaw)(struct ata_port *ap); | ||
737 | ata_prereset_fn_t prereset; | ||
738 | ata_reset_fn_t softreset; | ||
739 | ata_reset_fn_t hardreset; | ||
740 | ata_postreset_fn_t postreset; | ||
741 | ata_prereset_fn_t pmp_prereset; | ||
742 | ata_reset_fn_t pmp_softreset; | ||
743 | ata_reset_fn_t pmp_hardreset; | ||
744 | ata_postreset_fn_t pmp_postreset; | ||
745 | void (*error_handler)(struct ata_port *ap); | ||
746 | void (*post_internal_cmd)(struct ata_queued_cmd *qc); | ||
747 | |||
748 | /* | ||
749 | * Optional features | ||
750 | */ | ||
751 | int (*scr_read)(struct ata_port *ap, unsigned int sc_reg, u32 *val); | ||
752 | int (*scr_write)(struct ata_port *ap, unsigned int sc_reg, u32 val); | ||
753 | void (*pmp_attach)(struct ata_port *ap); | ||
754 | void (*pmp_detach)(struct ata_port *ap); | ||
755 | int (*enable_pm)(struct ata_port *ap, enum link_pm policy); | ||
756 | void (*disable_pm)(struct ata_port *ap); | ||
757 | |||
758 | /* | ||
759 | * Start, stop, suspend and resume | ||
760 | */ | ||
761 | int (*port_suspend)(struct ata_port *ap, pm_message_t mesg); | ||
762 | int (*port_resume)(struct ata_port *ap); | ||
763 | int (*port_start)(struct ata_port *ap); | ||
764 | void (*port_stop)(struct ata_port *ap); | ||
765 | void (*host_stop)(struct ata_host *host); | ||
766 | |||
767 | #ifdef CONFIG_ATA_SFF | ||
768 | /* | ||
769 | * SFF / taskfile oriented ops | ||
770 | */ | ||
771 | void (*sff_dev_select)(struct ata_port *ap, unsigned int device); | ||
772 | u8 (*sff_check_status)(struct ata_port *ap); | ||
773 | u8 (*sff_check_altstatus)(struct ata_port *ap); | ||
774 | void (*sff_tf_load)(struct ata_port *ap, const struct ata_taskfile *tf); | ||
775 | void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf); | ||
776 | void (*sff_exec_command)(struct ata_port *ap, | ||
777 | const struct ata_taskfile *tf); | ||
778 | unsigned int (*sff_data_xfer)(struct ata_device *dev, | ||
779 | unsigned char *buf, unsigned int buflen, int rw); | ||
780 | u8 (*sff_irq_on)(struct ata_port *); | ||
781 | void (*sff_irq_clear)(struct ata_port *); | ||
722 | 782 | ||
723 | int (*port_suspend) (struct ata_port *ap, pm_message_t mesg); | 783 | void (*bmdma_setup)(struct ata_queued_cmd *qc); |
724 | int (*port_resume) (struct ata_port *ap); | 784 | void (*bmdma_start)(struct ata_queued_cmd *qc); |
725 | int (*enable_pm) (struct ata_port *ap, enum link_pm policy); | 785 | void (*bmdma_stop)(struct ata_queued_cmd *qc); |
726 | void (*disable_pm) (struct ata_port *ap); | 786 | u8 (*bmdma_status)(struct ata_port *ap); |
727 | int (*port_start) (struct ata_port *ap); | 787 | #endif /* CONFIG_ATA_SFF */ |
728 | void (*port_stop) (struct ata_port *ap); | ||
729 | 788 | ||
730 | void (*host_stop) (struct ata_host *host); | 789 | /* |
790 | * Obsolete | ||
791 | */ | ||
792 | void (*phy_reset)(struct ata_port *ap); | ||
793 | void (*eng_timeout)(struct ata_port *ap); | ||
731 | 794 | ||
732 | void (*bmdma_stop) (struct ata_queued_cmd *qc); | 795 | /* |
733 | u8 (*bmdma_status) (struct ata_port *ap); | 796 | * ->inherits must be the last field and all the preceding |
797 | * fields must be pointers. | ||
798 | */ | ||
799 | const struct ata_port_operations *inherits; | ||
734 | }; | 800 | }; |
735 | 801 | ||
736 | struct ata_port_info { | 802 | struct ata_port_info { |
737 | struct scsi_host_template *sht; | ||
738 | unsigned long flags; | 803 | unsigned long flags; |
739 | unsigned long link_flags; | 804 | unsigned long link_flags; |
740 | unsigned long pio_mask; | 805 | unsigned long pio_mask; |
741 | unsigned long mwdma_mask; | 806 | unsigned long mwdma_mask; |
742 | unsigned long udma_mask; | 807 | unsigned long udma_mask; |
743 | const struct ata_port_operations *port_ops; | 808 | struct ata_port_operations *port_ops; |
744 | irq_handler_t irq_handler; | ||
745 | void *private_data; | 809 | void *private_data; |
746 | }; | 810 | }; |
747 | 811 | ||
@@ -759,11 +823,14 @@ struct ata_timing { | |||
759 | 823 | ||
760 | #define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin) | 824 | #define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin) |
761 | 825 | ||
826 | /* | ||
827 | * Core layer - drivers/ata/libata-core.c | ||
828 | */ | ||
762 | extern const unsigned long sata_deb_timing_normal[]; | 829 | extern const unsigned long sata_deb_timing_normal[]; |
763 | extern const unsigned long sata_deb_timing_hotplug[]; | 830 | extern const unsigned long sata_deb_timing_hotplug[]; |
764 | extern const unsigned long sata_deb_timing_long[]; | 831 | extern const unsigned long sata_deb_timing_long[]; |
765 | 832 | ||
766 | extern const struct ata_port_operations ata_dummy_port_ops; | 833 | extern struct ata_port_operations ata_dummy_port_ops; |
767 | extern const struct ata_port_info ata_dummy_port_info; | 834 | extern const struct ata_port_info ata_dummy_port_info; |
768 | 835 | ||
769 | static inline const unsigned long * | 836 | static inline const unsigned long * |
@@ -782,22 +849,21 @@ static inline int ata_port_is_dummy(struct ata_port *ap) | |||
782 | 849 | ||
783 | extern void sata_print_link_status(struct ata_link *link); | 850 | extern void sata_print_link_status(struct ata_link *link); |
784 | extern void ata_port_probe(struct ata_port *); | 851 | extern void ata_port_probe(struct ata_port *); |
785 | extern void ata_bus_reset(struct ata_port *ap); | ||
786 | extern int sata_set_spd(struct ata_link *link); | 852 | extern int sata_set_spd(struct ata_link *link); |
853 | extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); | ||
854 | extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, | ||
855 | int (*check_ready)(struct ata_link *link)); | ||
787 | extern int sata_link_debounce(struct ata_link *link, | 856 | extern int sata_link_debounce(struct ata_link *link, |
788 | const unsigned long *params, unsigned long deadline); | 857 | const unsigned long *params, unsigned long deadline); |
789 | extern int sata_link_resume(struct ata_link *link, const unsigned long *params, | 858 | extern int sata_link_resume(struct ata_link *link, const unsigned long *params, |
790 | unsigned long deadline); | 859 | unsigned long deadline); |
791 | extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); | ||
792 | extern int ata_std_softreset(struct ata_link *link, unsigned int *classes, | ||
793 | unsigned long deadline); | ||
794 | extern int sata_link_hardreset(struct ata_link *link, | 860 | extern int sata_link_hardreset(struct ata_link *link, |
795 | const unsigned long *timing, unsigned long deadline); | 861 | const unsigned long *timing, unsigned long deadline, |
862 | bool *online, int (*check_ready)(struct ata_link *)); | ||
796 | extern int sata_std_hardreset(struct ata_link *link, unsigned int *class, | 863 | extern int sata_std_hardreset(struct ata_link *link, unsigned int *class, |
797 | unsigned long deadline); | 864 | unsigned long deadline); |
798 | extern void ata_std_postreset(struct ata_link *link, unsigned int *classes); | 865 | extern void ata_std_postreset(struct ata_link *link, unsigned int *classes); |
799 | extern void ata_port_disable(struct ata_port *); | 866 | extern void ata_port_disable(struct ata_port *); |
800 | extern void ata_std_ports(struct ata_ioports *ioaddr); | ||
801 | 867 | ||
802 | extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); | 868 | extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); |
803 | extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, | 869 | extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, |
@@ -810,7 +876,7 @@ extern int ata_host_activate(struct ata_host *host, int irq, | |||
810 | struct scsi_host_template *sht); | 876 | struct scsi_host_template *sht); |
811 | extern void ata_host_detach(struct ata_host *host); | 877 | extern void ata_host_detach(struct ata_host *host); |
812 | extern void ata_host_init(struct ata_host *, struct device *, | 878 | extern void ata_host_init(struct ata_host *, struct device *, |
813 | unsigned long, const struct ata_port_operations *); | 879 | unsigned long, struct ata_port_operations *); |
814 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 880 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
815 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 881 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
816 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 882 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
@@ -823,7 +889,6 @@ extern void ata_sas_port_stop(struct ata_port *ap); | |||
823 | extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); | 889 | extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); |
824 | extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), | 890 | extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), |
825 | struct ata_port *ap); | 891 | struct ata_port *ap); |
826 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | ||
827 | extern int sata_scr_valid(struct ata_link *link); | 892 | extern int sata_scr_valid(struct ata_link *link); |
828 | extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); | 893 | extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); |
829 | extern int sata_scr_write(struct ata_link *link, int reg, u32 val); | 894 | extern int sata_scr_write(struct ata_link *link, int reg, u32 val); |
@@ -835,21 +900,9 @@ extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); | |||
835 | extern void ata_host_resume(struct ata_host *host); | 900 | extern void ata_host_resume(struct ata_host *host); |
836 | #endif | 901 | #endif |
837 | extern int ata_ratelimit(void); | 902 | extern int ata_ratelimit(void); |
838 | extern int ata_busy_sleep(struct ata_port *ap, | ||
839 | unsigned long timeout_pat, unsigned long timeout); | ||
840 | extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline); | ||
841 | extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline); | ||
842 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | 903 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, |
843 | unsigned long interval_msec, | 904 | unsigned long interval_msec, |
844 | unsigned long timeout_msec); | 905 | unsigned long timeout_msec); |
845 | extern unsigned int ata_dev_try_classify(struct ata_device *dev, int present, | ||
846 | u8 *r_err); | ||
847 | |||
848 | /* | ||
849 | * Default driver ops implementations | ||
850 | */ | ||
851 | extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); | ||
852 | extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | ||
853 | extern int atapi_cmd_type(u8 opcode); | 906 | extern int atapi_cmd_type(u8 opcode); |
854 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, | 907 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, |
855 | u8 pmp, int is_cmd, u8 *fis); | 908 | u8 pmp, int is_cmd, u8 *fis); |
@@ -864,23 +917,9 @@ extern unsigned long ata_xfer_mode2mask(u8 xfer_mode); | |||
864 | extern int ata_xfer_mode2shift(unsigned long xfer_mode); | 917 | extern int ata_xfer_mode2shift(unsigned long xfer_mode); |
865 | extern const char *ata_mode_string(unsigned long xfer_mask); | 918 | extern const char *ata_mode_string(unsigned long xfer_mask); |
866 | extern unsigned long ata_id_xfermask(const u16 *id); | 919 | extern unsigned long ata_id_xfermask(const u16 *id); |
867 | extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); | ||
868 | extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); | ||
869 | extern u8 ata_check_status(struct ata_port *ap); | ||
870 | extern u8 ata_altstatus(struct ata_port *ap); | ||
871 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | ||
872 | extern int ata_port_start(struct ata_port *ap); | 920 | extern int ata_port_start(struct ata_port *ap); |
873 | extern int ata_sff_port_start(struct ata_port *ap); | ||
874 | extern irqreturn_t ata_interrupt(int irq, void *dev_instance); | ||
875 | extern unsigned int ata_data_xfer(struct ata_device *dev, | ||
876 | unsigned char *buf, unsigned int buflen, int rw); | ||
877 | extern unsigned int ata_data_xfer_noirq(struct ata_device *dev, | ||
878 | unsigned char *buf, unsigned int buflen, int rw); | ||
879 | extern int ata_std_qc_defer(struct ata_queued_cmd *qc); | 921 | extern int ata_std_qc_defer(struct ata_queued_cmd *qc); |
880 | extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); | ||
881 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | ||
882 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); | 922 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); |
883 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); | ||
884 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 923 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
885 | unsigned int n_elem); | 924 | unsigned int n_elem); |
886 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); | 925 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); |
@@ -889,24 +928,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s, | |||
889 | unsigned int ofs, unsigned int len); | 928 | unsigned int ofs, unsigned int len); |
890 | extern void ata_id_c_string(const u16 *id, unsigned char *s, | 929 | extern void ata_id_c_string(const u16 *id, unsigned char *s, |
891 | unsigned int ofs, unsigned int len); | 930 | unsigned int ofs, unsigned int len); |
892 | extern void ata_bmdma_setup(struct ata_queued_cmd *qc); | ||
893 | extern void ata_bmdma_start(struct ata_queued_cmd *qc); | ||
894 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | ||
895 | extern u8 ata_bmdma_status(struct ata_port *ap); | ||
896 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | ||
897 | extern void ata_bmdma_freeze(struct ata_port *ap); | ||
898 | extern void ata_bmdma_thaw(struct ata_port *ap); | ||
899 | extern void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | ||
900 | ata_reset_fn_t softreset, | ||
901 | ata_reset_fn_t hardreset, | ||
902 | ata_postreset_fn_t postreset); | ||
903 | extern void ata_bmdma_error_handler(struct ata_port *ap); | ||
904 | extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc); | ||
905 | extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | ||
906 | u8 status, int in_wq); | ||
907 | extern void ata_qc_complete(struct ata_queued_cmd *qc); | 931 | extern void ata_qc_complete(struct ata_queued_cmd *qc); |
908 | extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active, | 932 | extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active); |
909 | void (*finish_qc)(struct ata_queued_cmd *)); | ||
910 | extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | 933 | extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, |
911 | void (*done)(struct scsi_cmnd *)); | 934 | void (*done)(struct scsi_cmnd *)); |
912 | extern int ata_std_bios_param(struct scsi_device *sdev, | 935 | extern int ata_std_bios_param(struct scsi_device *sdev, |
@@ -918,7 +941,6 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, | |||
918 | int queue_depth); | 941 | int queue_depth); |
919 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); | 942 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); |
920 | extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); | 943 | extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); |
921 | extern u8 ata_irq_on(struct ata_port *ap); | ||
922 | 944 | ||
923 | extern int ata_cable_40wire(struct ata_port *ap); | 945 | extern int ata_cable_40wire(struct ata_port *ap); |
924 | extern int ata_cable_80wire(struct ata_port *ap); | 946 | extern int ata_cable_80wire(struct ata_port *ap); |
@@ -926,10 +948,7 @@ extern int ata_cable_sata(struct ata_port *ap); | |||
926 | extern int ata_cable_ignore(struct ata_port *ap); | 948 | extern int ata_cable_ignore(struct ata_port *ap); |
927 | extern int ata_cable_unknown(struct ata_port *ap); | 949 | extern int ata_cable_unknown(struct ata_port *ap); |
928 | 950 | ||
929 | /* | 951 | /* Timing helpers */ |
930 | * Timing helpers | ||
931 | */ | ||
932 | |||
933 | extern unsigned int ata_pio_need_iordy(const struct ata_device *); | 952 | extern unsigned int ata_pio_need_iordy(const struct ata_device *); |
934 | extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode); | 953 | extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode); |
935 | extern int ata_timing_compute(struct ata_device *, unsigned short, | 954 | extern int ata_timing_compute(struct ata_device *, unsigned short, |
@@ -939,24 +958,31 @@ extern void ata_timing_merge(const struct ata_timing *, | |||
939 | unsigned int); | 958 | unsigned int); |
940 | extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle); | 959 | extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle); |
941 | 960 | ||
942 | enum { | 961 | /* PCI */ |
943 | ATA_TIMING_SETUP = (1 << 0), | 962 | #ifdef CONFIG_PCI |
944 | ATA_TIMING_ACT8B = (1 << 1), | 963 | struct pci_dev; |
945 | ATA_TIMING_REC8B = (1 << 2), | 964 | |
946 | ATA_TIMING_CYC8B = (1 << 3), | 965 | struct pci_bits { |
947 | ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B | | 966 | unsigned int reg; /* PCI config register to read */ |
948 | ATA_TIMING_CYC8B, | 967 | unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */ |
949 | ATA_TIMING_ACTIVE = (1 << 4), | 968 | unsigned long mask; |
950 | ATA_TIMING_RECOVER = (1 << 5), | 969 | unsigned long val; |
951 | ATA_TIMING_CYCLE = (1 << 6), | ||
952 | ATA_TIMING_UDMA = (1 << 7), | ||
953 | ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B | | ||
954 | ATA_TIMING_REC8B | ATA_TIMING_CYC8B | | ||
955 | ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER | | ||
956 | ATA_TIMING_CYCLE | ATA_TIMING_UDMA, | ||
957 | }; | 970 | }; |
958 | 971 | ||
959 | /* libata-acpi.c */ | 972 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); |
973 | extern void ata_pci_remove_one(struct pci_dev *pdev); | ||
974 | |||
975 | #ifdef CONFIG_PM | ||
976 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
977 | extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); | ||
978 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
979 | extern int ata_pci_device_resume(struct pci_dev *pdev); | ||
980 | #endif /* CONFIG_PM */ | ||
981 | #endif /* CONFIG_PCI */ | ||
982 | |||
983 | /* | ||
984 | * ACPI - drivers/ata/libata-acpi.c | ||
985 | */ | ||
960 | #ifdef CONFIG_ATA_ACPI | 986 | #ifdef CONFIG_ATA_ACPI |
961 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) | 987 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) |
962 | { | 988 | { |
@@ -1000,56 +1026,8 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap, | |||
1000 | } | 1026 | } |
1001 | #endif | 1027 | #endif |
1002 | 1028 | ||
1003 | #ifdef CONFIG_PCI | ||
1004 | struct pci_dev; | ||
1005 | |||
1006 | extern int ata_pci_init_one(struct pci_dev *pdev, | ||
1007 | const struct ata_port_info * const * ppi); | ||
1008 | extern void ata_pci_remove_one(struct pci_dev *pdev); | ||
1009 | #ifdef CONFIG_PM | ||
1010 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
1011 | extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); | ||
1012 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
1013 | extern int ata_pci_device_resume(struct pci_dev *pdev); | ||
1014 | #endif | ||
1015 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | ||
1016 | |||
1017 | struct pci_bits { | ||
1018 | unsigned int reg; /* PCI config register to read */ | ||
1019 | unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */ | ||
1020 | unsigned long mask; | ||
1021 | unsigned long val; | ||
1022 | }; | ||
1023 | |||
1024 | extern int ata_pci_init_sff_host(struct ata_host *host); | ||
1025 | extern int ata_pci_init_bmdma(struct ata_host *host); | ||
1026 | extern int ata_pci_prepare_sff_host(struct pci_dev *pdev, | ||
1027 | const struct ata_port_info * const * ppi, | ||
1028 | struct ata_host **r_host); | ||
1029 | extern int ata_pci_activate_sff_host(struct ata_host *host, | ||
1030 | irq_handler_t irq_handler, | ||
1031 | struct scsi_host_template *sht); | ||
1032 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); | ||
1033 | extern unsigned long ata_pci_default_filter(struct ata_device *dev, | ||
1034 | unsigned long xfer_mask); | ||
1035 | #endif /* CONFIG_PCI */ | ||
1036 | |||
1037 | /* | ||
1038 | * PMP | ||
1039 | */ | ||
1040 | extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc); | ||
1041 | extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline); | ||
1042 | extern int sata_pmp_std_hardreset(struct ata_link *link, unsigned int *class, | ||
1043 | unsigned long deadline); | ||
1044 | extern void sata_pmp_std_postreset(struct ata_link *link, unsigned int *class); | ||
1045 | extern void sata_pmp_do_eh(struct ata_port *ap, | ||
1046 | ata_prereset_fn_t prereset, ata_reset_fn_t softreset, | ||
1047 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset, | ||
1048 | ata_prereset_fn_t pmp_prereset, ata_reset_fn_t pmp_softreset, | ||
1049 | ata_reset_fn_t pmp_hardreset, ata_postreset_fn_t pmp_postreset); | ||
1050 | |||
1051 | /* | 1029 | /* |
1052 | * EH | 1030 | * EH - drivers/ata/libata-eh.c |
1053 | */ | 1031 | */ |
1054 | extern void ata_port_schedule_eh(struct ata_port *ap); | 1032 | extern void ata_port_schedule_eh(struct ata_port *ap); |
1055 | extern int ata_link_abort(struct ata_link *link); | 1033 | extern int ata_link_abort(struct ata_link *link); |
@@ -1066,6 +1044,92 @@ extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | |||
1066 | extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | 1044 | extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, |
1067 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 1045 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, |
1068 | ata_postreset_fn_t postreset); | 1046 | ata_postreset_fn_t postreset); |
1047 | extern void ata_std_error_handler(struct ata_port *ap); | ||
1048 | |||
1049 | /* | ||
1050 | * Base operations to inherit from and initializers for sht | ||
1051 | * | ||
1052 | * Operations | ||
1053 | * | ||
1054 | * base : Common to all libata drivers. | ||
1055 | * sata : SATA controllers w/ native interface. | ||
1056 | * pmp : SATA controllers w/ PMP support. | ||
1057 | * sff : SFF ATA controllers w/o BMDMA support. | ||
1058 | * bmdma : SFF ATA controllers w/ BMDMA support. | ||
1059 | * | ||
1060 | * sht initializers | ||
1061 | * | ||
1062 | * BASE : Common to all libata drivers. The user must set | ||
1063 | * sg_tablesize and dma_boundary. | ||
1064 | * PIO : SFF ATA controllers w/ only PIO support. | ||
1065 | * BMDMA : SFF ATA controllers w/ BMDMA support. sg_tablesize and | ||
1066 | * dma_boundary are set to BMDMA limits. | ||
1067 | * NCQ : SATA controllers supporting NCQ. The user must set | ||
1068 | * sg_tablesize, dma_boundary and can_queue. | ||
1069 | */ | ||
1070 | extern const struct ata_port_operations ata_base_port_ops; | ||
1071 | extern const struct ata_port_operations sata_port_ops; | ||
1072 | |||
1073 | #define ATA_BASE_SHT(drv_name) \ | ||
1074 | .module = THIS_MODULE, \ | ||
1075 | .name = drv_name, \ | ||
1076 | .ioctl = ata_scsi_ioctl, \ | ||
1077 | .queuecommand = ata_scsi_queuecmd, \ | ||
1078 | .can_queue = ATA_DEF_QUEUE, \ | ||
1079 | .this_id = ATA_SHT_THIS_ID, \ | ||
1080 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, \ | ||
1081 | .emulated = ATA_SHT_EMULATED, \ | ||
1082 | .use_clustering = ATA_SHT_USE_CLUSTERING, \ | ||
1083 | .proc_name = drv_name, \ | ||
1084 | .slave_configure = ata_scsi_slave_config, \ | ||
1085 | .slave_destroy = ata_scsi_slave_destroy, \ | ||
1086 | .bios_param = ata_std_bios_param | ||
1087 | |||
1088 | #define ATA_NCQ_SHT(drv_name) \ | ||
1089 | ATA_BASE_SHT(drv_name), \ | ||
1090 | .change_queue_depth = ata_scsi_change_queue_depth | ||
1091 | |||
1092 | /* | ||
1093 | * PMP helpers | ||
1094 | */ | ||
1095 | #ifdef CONFIG_SATA_PMP | ||
1096 | static inline bool sata_pmp_supported(struct ata_port *ap) | ||
1097 | { | ||
1098 | return ap->flags & ATA_FLAG_PMP; | ||
1099 | } | ||
1100 | |||
1101 | static inline bool sata_pmp_attached(struct ata_port *ap) | ||
1102 | { | ||
1103 | return ap->nr_pmp_links != 0; | ||
1104 | } | ||
1105 | |||
1106 | static inline int ata_is_host_link(const struct ata_link *link) | ||
1107 | { | ||
1108 | return link == &link->ap->link; | ||
1109 | } | ||
1110 | #else /* CONFIG_SATA_PMP */ | ||
1111 | static inline bool sata_pmp_supported(struct ata_port *ap) | ||
1112 | { | ||
1113 | return false; | ||
1114 | } | ||
1115 | |||
1116 | static inline bool sata_pmp_attached(struct ata_port *ap) | ||
1117 | { | ||
1118 | return false; | ||
1119 | } | ||
1120 | |||
1121 | static inline int ata_is_host_link(const struct ata_link *link) | ||
1122 | { | ||
1123 | return 1; | ||
1124 | } | ||
1125 | #endif /* CONFIG_SATA_PMP */ | ||
1126 | |||
1127 | static inline int sata_srst_pmp(struct ata_link *link) | ||
1128 | { | ||
1129 | if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) | ||
1130 | return SATA_PMP_CTRL_PORT; | ||
1131 | return link->pmp; | ||
1132 | } | ||
1069 | 1133 | ||
1070 | /* | 1134 | /* |
1071 | * printk helpers | 1135 | * printk helpers |
@@ -1074,7 +1138,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
1074 | printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) | 1138 | printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) |
1075 | 1139 | ||
1076 | #define ata_link_printk(link, lv, fmt, args...) do { \ | 1140 | #define ata_link_printk(link, lv, fmt, args...) do { \ |
1077 | if ((link)->ap->nr_pmp_links) \ | 1141 | if (sata_pmp_attached((link)->ap)) \ |
1078 | printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ | 1142 | printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ |
1079 | (link)->pmp , ##args); \ | 1143 | (link)->pmp , ##args); \ |
1080 | else \ | 1144 | else \ |
@@ -1094,18 +1158,11 @@ extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) | |||
1094 | __attribute__ ((format (printf, 2, 3))); | 1158 | __attribute__ ((format (printf, 2, 3))); |
1095 | extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); | 1159 | extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); |
1096 | 1160 | ||
1097 | static inline void ata_ehi_schedule_probe(struct ata_eh_info *ehi) | ||
1098 | { | ||
1099 | ehi->flags |= ATA_EHI_RESUME_LINK; | ||
1100 | ehi->action |= ATA_EH_SOFTRESET; | ||
1101 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; | ||
1102 | } | ||
1103 | |||
1104 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | 1161 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) |
1105 | { | 1162 | { |
1106 | ata_ehi_schedule_probe(ehi); | 1163 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; |
1107 | ehi->flags |= ATA_EHI_HOTPLUGGED; | 1164 | ehi->flags |= ATA_EHI_HOTPLUGGED; |
1108 | ehi->action |= ATA_EH_ENABLE_LINK; | 1165 | ehi->action |= ATA_EH_RESET | ATA_EH_ENABLE_LINK; |
1109 | ehi->err_mask |= AC_ERR_ATA_BUS; | 1166 | ehi->err_mask |= AC_ERR_ATA_BUS; |
1110 | } | 1167 | } |
1111 | 1168 | ||
@@ -1126,7 +1183,7 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
1126 | 1183 | ||
1127 | static inline unsigned int ata_tag_internal(unsigned int tag) | 1184 | static inline unsigned int ata_tag_internal(unsigned int tag) |
1128 | { | 1185 | { |
1129 | return tag == ATA_MAX_QUEUE - 1; | 1186 | return tag == ATA_TAG_INTERNAL; |
1130 | } | 1187 | } |
1131 | 1188 | ||
1132 | /* | 1189 | /* |
@@ -1167,11 +1224,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev) | |||
1167 | /* | 1224 | /* |
1168 | * link helpers | 1225 | * link helpers |
1169 | */ | 1226 | */ |
1170 | static inline int ata_is_host_link(const struct ata_link *link) | ||
1171 | { | ||
1172 | return link == &link->ap->link; | ||
1173 | } | ||
1174 | |||
1175 | static inline int ata_link_max_devices(const struct ata_link *link) | 1227 | static inline int ata_link_max_devices(const struct ata_link *link) |
1176 | { | 1228 | { |
1177 | if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS) | 1229 | if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS) |
@@ -1186,7 +1238,7 @@ static inline int ata_link_active(struct ata_link *link) | |||
1186 | 1238 | ||
1187 | static inline struct ata_link *ata_port_first_link(struct ata_port *ap) | 1239 | static inline struct ata_link *ata_port_first_link(struct ata_port *ap) |
1188 | { | 1240 | { |
1189 | if (ap->nr_pmp_links) | 1241 | if (sata_pmp_attached(ap)) |
1190 | return ap->pmp_link; | 1242 | return ap->pmp_link; |
1191 | return &ap->link; | 1243 | return &ap->link; |
1192 | } | 1244 | } |
@@ -1195,8 +1247,8 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link) | |||
1195 | { | 1247 | { |
1196 | struct ata_port *ap = link->ap; | 1248 | struct ata_port *ap = link->ap; |
1197 | 1249 | ||
1198 | if (link == &ap->link) { | 1250 | if (ata_is_host_link(link)) { |
1199 | if (!ap->nr_pmp_links) | 1251 | if (!sata_pmp_attached(ap)) |
1200 | return NULL; | 1252 | return NULL; |
1201 | return ap->pmp_link; | 1253 | return ap->pmp_link; |
1202 | } | 1254 | } |
@@ -1222,11 +1274,6 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link) | |||
1222 | for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \ | 1274 | for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \ |
1223 | (dev) >= (link)->device || ((dev) = NULL); (dev)--) | 1275 | (dev) >= (link)->device || ((dev) = NULL); (dev)--) |
1224 | 1276 | ||
1225 | static inline u8 ata_chk_status(struct ata_port *ap) | ||
1226 | { | ||
1227 | return ap->ops->check_status(ap); | ||
1228 | } | ||
1229 | |||
1230 | /** | 1277 | /** |
1231 | * ata_ncq_enabled - Test whether NCQ is enabled | 1278 | * ata_ncq_enabled - Test whether NCQ is enabled |
1232 | * @dev: ATA device to test for | 1279 | * @dev: ATA device to test for |
@@ -1243,74 +1290,6 @@ static inline int ata_ncq_enabled(struct ata_device *dev) | |||
1243 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; | 1290 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; |
1244 | } | 1291 | } |
1245 | 1292 | ||
1246 | /** | ||
1247 | * ata_pause - Flush writes and pause 400 nanoseconds. | ||
1248 | * @ap: Port to wait for. | ||
1249 | * | ||
1250 | * LOCKING: | ||
1251 | * Inherited from caller. | ||
1252 | */ | ||
1253 | |||
1254 | static inline void ata_pause(struct ata_port *ap) | ||
1255 | { | ||
1256 | ata_altstatus(ap); | ||
1257 | ndelay(400); | ||
1258 | } | ||
1259 | |||
1260 | |||
1261 | /** | ||
1262 | * ata_busy_wait - Wait for a port status register | ||
1263 | * @ap: Port to wait for. | ||
1264 | * @bits: bits that must be clear | ||
1265 | * @max: number of 10uS waits to perform | ||
1266 | * | ||
1267 | * Waits up to max*10 microseconds for the selected bits in the port's | ||
1268 | * status register to be cleared. | ||
1269 | * Returns final value of status register. | ||
1270 | * | ||
1271 | * LOCKING: | ||
1272 | * Inherited from caller. | ||
1273 | */ | ||
1274 | |||
1275 | static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, | ||
1276 | unsigned int max) | ||
1277 | { | ||
1278 | u8 status; | ||
1279 | |||
1280 | do { | ||
1281 | udelay(10); | ||
1282 | status = ata_chk_status(ap); | ||
1283 | max--; | ||
1284 | } while (status != 0xff && (status & bits) && (max > 0)); | ||
1285 | |||
1286 | return status; | ||
1287 | } | ||
1288 | |||
1289 | |||
1290 | /** | ||
1291 | * ata_wait_idle - Wait for a port to be idle. | ||
1292 | * @ap: Port to wait for. | ||
1293 | * | ||
1294 | * Waits up to 10ms for port's BUSY and DRQ signals to clear. | ||
1295 | * Returns final value of status register. | ||
1296 | * | ||
1297 | * LOCKING: | ||
1298 | * Inherited from caller. | ||
1299 | */ | ||
1300 | |||
1301 | static inline u8 ata_wait_idle(struct ata_port *ap) | ||
1302 | { | ||
1303 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | ||
1304 | |||
1305 | #ifdef ATA_DEBUG | ||
1306 | if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) | ||
1307 | ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n", | ||
1308 | status); | ||
1309 | #endif | ||
1310 | |||
1311 | return status; | ||
1312 | } | ||
1313 | |||
1314 | static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | 1293 | static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) |
1315 | { | 1294 | { |
1316 | qc->tf.ctl |= ATA_NIEN; | 1295 | qc->tf.ctl |= ATA_NIEN; |
@@ -1403,4 +1382,171 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | |||
1403 | return *(struct ata_port **)&host->hostdata[0]; | 1382 | return *(struct ata_port **)&host->hostdata[0]; |
1404 | } | 1383 | } |
1405 | 1384 | ||
1385 | |||
1386 | /************************************************************************** | ||
1387 | * PMP - drivers/ata/libata-pmp.c | ||
1388 | */ | ||
1389 | #ifdef CONFIG_SATA_PMP | ||
1390 | |||
1391 | extern const struct ata_port_operations sata_pmp_port_ops; | ||
1392 | |||
1393 | extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc); | ||
1394 | extern void sata_pmp_error_handler(struct ata_port *ap); | ||
1395 | |||
1396 | #else /* CONFIG_SATA_PMP */ | ||
1397 | |||
1398 | #define sata_pmp_port_ops sata_port_ops | ||
1399 | #define sata_pmp_qc_defer_cmd_switch ata_std_qc_defer | ||
1400 | #define sata_pmp_error_handler ata_std_error_handler | ||
1401 | |||
1402 | #endif /* CONFIG_SATA_PMP */ | ||
1403 | |||
1404 | |||
1405 | /************************************************************************** | ||
1406 | * SFF - drivers/ata/libata-sff.c | ||
1407 | */ | ||
1408 | #ifdef CONFIG_ATA_SFF | ||
1409 | |||
1410 | extern const struct ata_port_operations ata_sff_port_ops; | ||
1411 | extern const struct ata_port_operations ata_bmdma_port_ops; | ||
1412 | |||
1413 | /* PIO only, sg_tablesize and dma_boundary limits can be removed */ | ||
1414 | #define ATA_PIO_SHT(drv_name) \ | ||
1415 | ATA_BASE_SHT(drv_name), \ | ||
1416 | .sg_tablesize = LIBATA_MAX_PRD, \ | ||
1417 | .dma_boundary = ATA_DMA_BOUNDARY | ||
1418 | |||
1419 | #define ATA_BMDMA_SHT(drv_name) \ | ||
1420 | ATA_BASE_SHT(drv_name), \ | ||
1421 | .sg_tablesize = LIBATA_MAX_PRD, \ | ||
1422 | .dma_boundary = ATA_DMA_BOUNDARY | ||
1423 | |||
1424 | extern void ata_sff_qc_prep(struct ata_queued_cmd *qc); | ||
1425 | extern void ata_sff_dumb_qc_prep(struct ata_queued_cmd *qc); | ||
1426 | extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device); | ||
1427 | extern u8 ata_sff_check_status(struct ata_port *ap); | ||
1428 | extern u8 ata_sff_altstatus(struct ata_port *ap); | ||
1429 | extern int ata_sff_busy_sleep(struct ata_port *ap, | ||
1430 | unsigned long timeout_pat, unsigned long timeout); | ||
1431 | extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline); | ||
1432 | extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); | ||
1433 | extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | ||
1434 | extern void ata_sff_exec_command(struct ata_port *ap, | ||
1435 | const struct ata_taskfile *tf); | ||
1436 | extern unsigned int ata_sff_data_xfer(struct ata_device *dev, | ||
1437 | unsigned char *buf, unsigned int buflen, int rw); | ||
1438 | extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev, | ||
1439 | unsigned char *buf, unsigned int buflen, int rw); | ||
1440 | extern u8 ata_sff_irq_on(struct ata_port *ap); | ||
1441 | extern void ata_sff_irq_clear(struct ata_port *ap); | ||
1442 | extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | ||
1443 | u8 status, int in_wq); | ||
1444 | extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc); | ||
1445 | extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc); | ||
1446 | extern unsigned int ata_sff_host_intr(struct ata_port *ap, | ||
1447 | struct ata_queued_cmd *qc); | ||
1448 | extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance); | ||
1449 | extern void ata_sff_freeze(struct ata_port *ap); | ||
1450 | extern void ata_sff_thaw(struct ata_port *ap); | ||
1451 | extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline); | ||
1452 | extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present, | ||
1453 | u8 *r_err); | ||
1454 | extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask, | ||
1455 | unsigned long deadline); | ||
1456 | extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes, | ||
1457 | unsigned long deadline); | ||
1458 | extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class, | ||
1459 | unsigned long deadline); | ||
1460 | extern void ata_sff_postreset(struct ata_link *link, unsigned int *classes); | ||
1461 | extern void ata_sff_error_handler(struct ata_port *ap); | ||
1462 | extern void ata_sff_post_internal_cmd(struct ata_queued_cmd *qc); | ||
1463 | extern int ata_sff_port_start(struct ata_port *ap); | ||
1464 | extern void ata_sff_std_ports(struct ata_ioports *ioaddr); | ||
1465 | extern unsigned long ata_bmdma_mode_filter(struct ata_device *dev, | ||
1466 | unsigned long xfer_mask); | ||
1467 | extern void ata_bmdma_setup(struct ata_queued_cmd *qc); | ||
1468 | extern void ata_bmdma_start(struct ata_queued_cmd *qc); | ||
1469 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | ||
1470 | extern u8 ata_bmdma_status(struct ata_port *ap); | ||
1471 | extern void ata_bus_reset(struct ata_port *ap); | ||
1472 | |||
1473 | #ifdef CONFIG_PCI | ||
1474 | extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev); | ||
1475 | extern int ata_pci_bmdma_init(struct ata_host *host); | ||
1476 | extern int ata_pci_sff_init_host(struct ata_host *host); | ||
1477 | extern int ata_pci_sff_prepare_host(struct pci_dev *pdev, | ||
1478 | const struct ata_port_info * const * ppi, | ||
1479 | struct ata_host **r_host); | ||
1480 | extern int ata_pci_sff_activate_host(struct ata_host *host, | ||
1481 | irq_handler_t irq_handler, | ||
1482 | struct scsi_host_template *sht); | ||
1483 | extern int ata_pci_sff_init_one(struct pci_dev *pdev, | ||
1484 | const struct ata_port_info * const * ppi, | ||
1485 | struct scsi_host_template *sht, void *host_priv); | ||
1486 | #endif /* CONFIG_PCI */ | ||
1487 | |||
1488 | /** | ||
1489 | * ata_sff_pause - Flush writes and pause 400 nanoseconds. | ||
1490 | * @ap: Port to wait for. | ||
1491 | * | ||
1492 | * LOCKING: | ||
1493 | * Inherited from caller. | ||
1494 | */ | ||
1495 | static inline void ata_sff_pause(struct ata_port *ap) | ||
1496 | { | ||
1497 | ata_sff_altstatus(ap); | ||
1498 | ndelay(400); | ||
1499 | } | ||
1500 | |||
1501 | /** | ||
1502 | * ata_sff_busy_wait - Wait for a port status register | ||
1503 | * @ap: Port to wait for. | ||
1504 | * @bits: bits that must be clear | ||
1505 | * @max: number of 10uS waits to perform | ||
1506 | * | ||
1507 | * Waits up to max*10 microseconds for the selected bits in the port's | ||
1508 | * status register to be cleared. | ||
1509 | * Returns final value of status register. | ||
1510 | * | ||
1511 | * LOCKING: | ||
1512 | * Inherited from caller. | ||
1513 | */ | ||
1514 | static inline u8 ata_sff_busy_wait(struct ata_port *ap, unsigned int bits, | ||
1515 | unsigned int max) | ||
1516 | { | ||
1517 | u8 status; | ||
1518 | |||
1519 | do { | ||
1520 | udelay(10); | ||
1521 | status = ap->ops->sff_check_status(ap); | ||
1522 | max--; | ||
1523 | } while (status != 0xff && (status & bits) && (max > 0)); | ||
1524 | |||
1525 | return status; | ||
1526 | } | ||
1527 | |||
1528 | /** | ||
1529 | * ata_wait_idle - Wait for a port to be idle. | ||
1530 | * @ap: Port to wait for. | ||
1531 | * | ||
1532 | * Waits up to 10ms for port's BUSY and DRQ signals to clear. | ||
1533 | * Returns final value of status register. | ||
1534 | * | ||
1535 | * LOCKING: | ||
1536 | * Inherited from caller. | ||
1537 | */ | ||
1538 | static inline u8 ata_wait_idle(struct ata_port *ap) | ||
1539 | { | ||
1540 | u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | ||
1541 | |||
1542 | #ifdef ATA_DEBUG | ||
1543 | if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) | ||
1544 | ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n", | ||
1545 | status); | ||
1546 | #endif | ||
1547 | |||
1548 | return status; | ||
1549 | } | ||
1550 | #endif /* CONFIG_ATA_SFF */ | ||
1551 | |||
1406 | #endif /* __LINUX_LIBATA_H__ */ | 1552 | #endif /* __LINUX_LIBATA_H__ */ |