diff options
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 184 |
1 files changed, 115 insertions, 69 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 124033cb5e9b..4374c4277780 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <linux/workqueue.h> | 35 | #include <linux/workqueue.h> |
| 36 | #include <scsi/scsi_host.h> | 36 | #include <scsi/scsi_host.h> |
| 37 | #include <linux/acpi.h> | 37 | #include <linux/acpi.h> |
| 38 | #include <linux/cdrom.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 |
| @@ -143,10 +144,11 @@ enum { | |||
| 143 | ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ | 144 | ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ |
| 144 | ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ | 145 | ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ |
| 145 | ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ | 146 | ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ |
| 146 | ATA_DFLAG_INIT_MASK = (1 << 16) - 1, | 147 | ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ |
| 148 | ATA_DFLAG_INIT_MASK = (1 << 24) - 1, | ||
| 147 | 149 | ||
| 148 | ATA_DFLAG_DETACH = (1 << 16), | 150 | ATA_DFLAG_DETACH = (1 << 24), |
| 149 | ATA_DFLAG_DETACHED = (1 << 17), | 151 | ATA_DFLAG_DETACHED = (1 << 25), |
| 150 | 152 | ||
| 151 | ATA_DEV_UNKNOWN = 0, /* unknown device */ | 153 | ATA_DEV_UNKNOWN = 0, /* unknown device */ |
| 152 | ATA_DEV_ATA = 1, /* ATA device */ | 154 | ATA_DEV_ATA = 1, /* ATA device */ |
| @@ -217,9 +219,7 @@ enum { | |||
| 217 | 219 | ||
| 218 | /* struct ata_queued_cmd flags */ | 220 | /* struct ata_queued_cmd flags */ |
| 219 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ | 221 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ |
| 220 | ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */ | 222 | ATA_QCFLAG_DMAMAP = (1 << 1), /* SG table is DMA mapped */ |
| 221 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ | ||
| 222 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | ||
| 223 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ | 223 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
| 224 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ | 224 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ |
| 225 | ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ | 225 | ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ |
| @@ -266,19 +266,15 @@ enum { | |||
| 266 | PORT_DISABLED = 2, | 266 | PORT_DISABLED = 2, |
| 267 | 267 | ||
| 268 | /* encoding various smaller bitmaps into a single | 268 | /* encoding various smaller bitmaps into a single |
| 269 | * unsigned int bitmap | 269 | * unsigned long bitmap |
| 270 | */ | 270 | */ |
| 271 | ATA_BITS_PIO = 7, | 271 | ATA_NR_PIO_MODES = 7, |
| 272 | ATA_BITS_MWDMA = 5, | 272 | ATA_NR_MWDMA_MODES = 5, |
| 273 | ATA_BITS_UDMA = 8, | 273 | ATA_NR_UDMA_MODES = 8, |
| 274 | 274 | ||
| 275 | ATA_SHIFT_PIO = 0, | 275 | ATA_SHIFT_PIO = 0, |
| 276 | ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_BITS_PIO, | 276 | ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES, |
| 277 | ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_BITS_MWDMA, | 277 | ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES, |
| 278 | |||
| 279 | ATA_MASK_PIO = ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO, | ||
| 280 | ATA_MASK_MWDMA = ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA, | ||
| 281 | ATA_MASK_UDMA = ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA, | ||
| 282 | 278 | ||
| 283 | /* size of buffer to pad xfers ending on unaligned boundaries */ | 279 | /* size of buffer to pad xfers ending on unaligned boundaries */ |
| 284 | ATA_DMA_PAD_SZ = 4, | 280 | ATA_DMA_PAD_SZ = 4, |
| @@ -349,6 +345,21 @@ enum { | |||
| 349 | ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ | 345 | ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ |
| 350 | ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ | 346 | ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ |
| 351 | ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */ | 347 | ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */ |
| 348 | |||
| 349 | /* ATAPI command types */ | ||
| 350 | ATAPI_READ = 0, /* READs */ | ||
| 351 | ATAPI_WRITE = 1, /* WRITEs */ | ||
| 352 | ATAPI_READ_CD = 2, /* READ CD [MSF] */ | ||
| 353 | ATAPI_MISC = 3, /* the rest */ | ||
| 354 | }; | ||
| 355 | |||
| 356 | enum ata_xfer_mask { | ||
| 357 | ATA_MASK_PIO = ((1LU << ATA_NR_PIO_MODES) - 1) | ||
| 358 | << ATA_SHIFT_PIO, | ||
| 359 | ATA_MASK_MWDMA = ((1LU << ATA_NR_MWDMA_MODES) - 1) | ||
| 360 | << ATA_SHIFT_MWDMA, | ||
| 361 | ATA_MASK_UDMA = ((1LU << ATA_NR_UDMA_MODES) - 1) | ||
| 362 | << ATA_SHIFT_UDMA, | ||
| 352 | }; | 363 | }; |
| 353 | 364 | ||
| 354 | enum hsm_task_states { | 365 | enum hsm_task_states { |
| @@ -447,7 +458,7 @@ struct ata_queued_cmd { | |||
| 447 | unsigned int tag; | 458 | unsigned int tag; |
| 448 | unsigned int n_elem; | 459 | unsigned int n_elem; |
| 449 | unsigned int n_iter; | 460 | unsigned int n_iter; |
| 450 | unsigned int orig_n_elem; | 461 | unsigned int mapped_n_elem; |
| 451 | 462 | ||
| 452 | int dma_dir; | 463 | int dma_dir; |
| 453 | 464 | ||
| @@ -455,17 +466,18 @@ struct ata_queued_cmd { | |||
| 455 | unsigned int sect_size; | 466 | unsigned int sect_size; |
| 456 | 467 | ||
| 457 | unsigned int nbytes; | 468 | unsigned int nbytes; |
| 469 | unsigned int raw_nbytes; | ||
| 458 | unsigned int curbytes; | 470 | unsigned int curbytes; |
| 459 | 471 | ||
| 460 | struct scatterlist *cursg; | 472 | struct scatterlist *cursg; |
| 461 | unsigned int cursg_ofs; | 473 | unsigned int cursg_ofs; |
| 462 | 474 | ||
| 475 | struct scatterlist *last_sg; | ||
| 476 | struct scatterlist saved_last_sg; | ||
| 463 | struct scatterlist sgent; | 477 | struct scatterlist sgent; |
| 464 | struct scatterlist pad_sgent; | 478 | struct scatterlist extra_sg[2]; |
| 465 | void *buf_virt; | ||
| 466 | 479 | ||
| 467 | /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ | 480 | struct scatterlist *sg; |
| 468 | struct scatterlist *__sg; | ||
| 469 | 481 | ||
| 470 | unsigned int err_mask; | 482 | unsigned int err_mask; |
| 471 | struct ata_taskfile result_tf; | 483 | struct ata_taskfile result_tf; |
| @@ -482,7 +494,7 @@ struct ata_port_stats { | |||
| 482 | }; | 494 | }; |
| 483 | 495 | ||
| 484 | struct ata_ering_entry { | 496 | struct ata_ering_entry { |
| 485 | int is_io; | 497 | unsigned int eflags; |
| 486 | unsigned int err_mask; | 498 | unsigned int err_mask; |
| 487 | u64 timestamp; | 499 | u64 timestamp; |
| 488 | }; | 500 | }; |
| @@ -522,9 +534,9 @@ struct ata_device { | |||
| 522 | unsigned int cdb_len; | 534 | unsigned int cdb_len; |
| 523 | 535 | ||
| 524 | /* per-dev xfer mask */ | 536 | /* per-dev xfer mask */ |
| 525 | unsigned int pio_mask; | 537 | unsigned long pio_mask; |
| 526 | unsigned int mwdma_mask; | 538 | unsigned long mwdma_mask; |
| 527 | unsigned int udma_mask; | 539 | unsigned long udma_mask; |
| 528 | 540 | ||
| 529 | /* for CHS addressing */ | 541 | /* for CHS addressing */ |
| 530 | u16 cylinders; /* Number of cylinders */ | 542 | u16 cylinders; /* Number of cylinders */ |
| @@ -560,6 +572,8 @@ struct ata_eh_context { | |||
| 560 | int tries[ATA_MAX_DEVICES]; | 572 | int tries[ATA_MAX_DEVICES]; |
| 561 | unsigned int classes[ATA_MAX_DEVICES]; | 573 | unsigned int classes[ATA_MAX_DEVICES]; |
| 562 | unsigned int did_probe_mask; | 574 | unsigned int did_probe_mask; |
| 575 | unsigned int saved_ncq_enabled; | ||
| 576 | u8 saved_xfer_mode[ATA_MAX_DEVICES]; | ||
| 563 | }; | 577 | }; |
| 564 | 578 | ||
| 565 | struct ata_acpi_drive | 579 | struct ata_acpi_drive |
| @@ -686,7 +700,8 @@ struct ata_port_operations { | |||
| 686 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | 700 | void (*bmdma_setup) (struct ata_queued_cmd *qc); |
| 687 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 701 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
| 688 | 702 | ||
| 689 | void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); | 703 | unsigned int (*data_xfer) (struct ata_device *dev, unsigned char *buf, |
| 704 | unsigned int buflen, int rw); | ||
| 690 | 705 | ||
| 691 | int (*qc_defer) (struct ata_queued_cmd *qc); | 706 | int (*qc_defer) (struct ata_queued_cmd *qc); |
| 692 | void (*qc_prep) (struct ata_queued_cmd *qc); | 707 | void (*qc_prep) (struct ata_queued_cmd *qc); |
| @@ -832,8 +847,6 @@ extern int ata_busy_sleep(struct ata_port *ap, | |||
| 832 | unsigned long timeout_pat, unsigned long timeout); | 847 | unsigned long timeout_pat, unsigned long timeout); |
| 833 | extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline); | 848 | extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline); |
| 834 | extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline); | 849 | extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline); |
| 835 | extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn, | ||
| 836 | void *data, unsigned long delay); | ||
| 837 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | 850 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, |
| 838 | unsigned long interval_msec, | 851 | unsigned long interval_msec, |
| 839 | unsigned long timeout_msec); | 852 | unsigned long timeout_msec); |
| @@ -848,6 +861,16 @@ extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | |||
| 848 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, | 861 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, |
| 849 | u8 pmp, int is_cmd, u8 *fis); | 862 | u8 pmp, int is_cmd, u8 *fis); |
| 850 | extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); | 863 | extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); |
| 864 | extern unsigned long ata_pack_xfermask(unsigned long pio_mask, | ||
| 865 | unsigned long mwdma_mask, unsigned long udma_mask); | ||
| 866 | extern void ata_unpack_xfermask(unsigned long xfer_mask, | ||
| 867 | unsigned long *pio_mask, unsigned long *mwdma_mask, | ||
| 868 | unsigned long *udma_mask); | ||
| 869 | extern u8 ata_xfer_mask2mode(unsigned long xfer_mask); | ||
| 870 | extern unsigned long ata_xfer_mode2mask(u8 xfer_mode); | ||
| 871 | extern int ata_xfer_mode2shift(unsigned long xfer_mode); | ||
| 872 | extern const char *ata_mode_string(unsigned long xfer_mask); | ||
| 873 | extern unsigned long ata_id_xfermask(const u16 *id); | ||
| 851 | extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); | 874 | extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); |
| 852 | extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); | 875 | extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); |
| 853 | extern u8 ata_check_status(struct ata_port *ap); | 876 | extern u8 ata_check_status(struct ata_port *ap); |
| @@ -856,17 +879,15 @@ extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) | |||
| 856 | extern int ata_port_start(struct ata_port *ap); | 879 | extern int ata_port_start(struct ata_port *ap); |
| 857 | extern int ata_sff_port_start(struct ata_port *ap); | 880 | extern int ata_sff_port_start(struct ata_port *ap); |
| 858 | extern irqreturn_t ata_interrupt(int irq, void *dev_instance); | 881 | extern irqreturn_t ata_interrupt(int irq, void *dev_instance); |
| 859 | extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, | 882 | extern unsigned int ata_data_xfer(struct ata_device *dev, |
| 860 | unsigned int buflen, int write_data); | 883 | unsigned char *buf, unsigned int buflen, int rw); |
| 861 | extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, | 884 | extern unsigned int ata_data_xfer_noirq(struct ata_device *dev, |
| 862 | unsigned int buflen, int write_data); | 885 | unsigned char *buf, unsigned int buflen, int rw); |
| 863 | extern int ata_std_qc_defer(struct ata_queued_cmd *qc); | 886 | extern int ata_std_qc_defer(struct ata_queued_cmd *qc); |
| 864 | extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); | 887 | extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); |
| 865 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 888 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
| 866 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); | 889 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); |
| 867 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 890 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); |
| 868 | extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, | ||
| 869 | unsigned int buflen); | ||
| 870 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 891 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
| 871 | unsigned int n_elem); | 892 | unsigned int n_elem); |
| 872 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); | 893 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); |
| @@ -875,7 +896,6 @@ extern void ata_id_string(const u16 *id, unsigned char *s, | |||
| 875 | unsigned int ofs, unsigned int len); | 896 | unsigned int ofs, unsigned int len); |
| 876 | extern void ata_id_c_string(const u16 *id, unsigned char *s, | 897 | extern void ata_id_c_string(const u16 *id, unsigned char *s, |
| 877 | unsigned int ofs, unsigned int len); | 898 | unsigned int ofs, unsigned int len); |
| 878 | extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown); | ||
| 879 | extern void ata_bmdma_setup(struct ata_queued_cmd *qc); | 899 | extern void ata_bmdma_setup(struct ata_queued_cmd *qc); |
| 880 | extern void ata_bmdma_start(struct ata_queued_cmd *qc); | 900 | extern void ata_bmdma_start(struct ata_queued_cmd *qc); |
| 881 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | 901 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); |
| @@ -910,6 +930,7 @@ extern u8 ata_irq_on(struct ata_port *ap); | |||
| 910 | extern int ata_cable_40wire(struct ata_port *ap); | 930 | extern int ata_cable_40wire(struct ata_port *ap); |
| 911 | extern int ata_cable_80wire(struct ata_port *ap); | 931 | extern int ata_cable_80wire(struct ata_port *ap); |
| 912 | extern int ata_cable_sata(struct ata_port *ap); | 932 | extern int ata_cable_sata(struct ata_port *ap); |
| 933 | extern int ata_cable_ignore(struct ata_port *ap); | ||
| 913 | extern int ata_cable_unknown(struct ata_port *ap); | 934 | extern int ata_cable_unknown(struct ata_port *ap); |
| 914 | 935 | ||
| 915 | /* | 936 | /* |
| @@ -917,11 +938,13 @@ extern int ata_cable_unknown(struct ata_port *ap); | |||
| 917 | */ | 938 | */ |
| 918 | 939 | ||
| 919 | extern unsigned int ata_pio_need_iordy(const struct ata_device *); | 940 | extern unsigned int ata_pio_need_iordy(const struct ata_device *); |
| 941 | extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode); | ||
| 920 | extern int ata_timing_compute(struct ata_device *, unsigned short, | 942 | extern int ata_timing_compute(struct ata_device *, unsigned short, |
| 921 | struct ata_timing *, int, int); | 943 | struct ata_timing *, int, int); |
| 922 | extern void ata_timing_merge(const struct ata_timing *, | 944 | extern void ata_timing_merge(const struct ata_timing *, |
| 923 | const struct ata_timing *, struct ata_timing *, | 945 | const struct ata_timing *, struct ata_timing *, |
| 924 | unsigned int); | 946 | unsigned int); |
| 947 | extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle); | ||
| 925 | 948 | ||
| 926 | enum { | 949 | enum { |
| 927 | ATA_TIMING_SETUP = (1 << 0), | 950 | ATA_TIMING_SETUP = (1 << 0), |
| @@ -948,15 +971,40 @@ static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) | |||
| 948 | return &ap->__acpi_init_gtm; | 971 | return &ap->__acpi_init_gtm; |
| 949 | return NULL; | 972 | return NULL; |
| 950 | } | 973 | } |
| 951 | extern int ata_acpi_cbl_80wire(struct ata_port *ap); | ||
| 952 | int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); | 974 | int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); |
| 953 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); | 975 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); |
| 976 | unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, | ||
| 977 | const struct ata_acpi_gtm *gtm); | ||
| 978 | int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm); | ||
| 954 | #else | 979 | #else |
| 955 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) | 980 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) |
| 956 | { | 981 | { |
| 957 | return NULL; | 982 | return NULL; |
| 958 | } | 983 | } |
| 959 | static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } | 984 | |
| 985 | static inline int ata_acpi_stm(const struct ata_port *ap, | ||
| 986 | struct ata_acpi_gtm *stm) | ||
| 987 | { | ||
| 988 | return -ENOSYS; | ||
| 989 | } | ||
| 990 | |||
| 991 | static inline int ata_acpi_gtm(const struct ata_port *ap, | ||
| 992 | struct ata_acpi_gtm *stm) | ||
| 993 | { | ||
| 994 | return -ENOSYS; | ||
| 995 | } | ||
| 996 | |||
| 997 | static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev, | ||
| 998 | const struct ata_acpi_gtm *gtm) | ||
| 999 | { | ||
| 1000 | return 0; | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | static inline int ata_acpi_cbl_80wire(struct ata_port *ap, | ||
| 1004 | const struct ata_acpi_gtm *gtm) | ||
| 1005 | { | ||
| 1006 | return 0; | ||
| 1007 | } | ||
| 960 | #endif | 1008 | #endif |
| 961 | 1009 | ||
| 962 | #ifdef CONFIG_PCI | 1010 | #ifdef CONFIG_PCI |
| @@ -985,8 +1033,12 @@ extern int ata_pci_init_bmdma(struct ata_host *host); | |||
| 985 | extern int ata_pci_prepare_sff_host(struct pci_dev *pdev, | 1033 | extern int ata_pci_prepare_sff_host(struct pci_dev *pdev, |
| 986 | const struct ata_port_info * const * ppi, | 1034 | const struct ata_port_info * const * ppi, |
| 987 | struct ata_host **r_host); | 1035 | struct ata_host **r_host); |
| 1036 | extern int ata_pci_activate_sff_host(struct ata_host *host, | ||
| 1037 | irq_handler_t irq_handler, | ||
| 1038 | struct scsi_host_template *sht); | ||
| 988 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); | 1039 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); |
| 989 | extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); | 1040 | extern unsigned long ata_pci_default_filter(struct ata_device *dev, |
| 1041 | unsigned long xfer_mask); | ||
| 990 | #endif /* CONFIG_PCI */ | 1042 | #endif /* CONFIG_PCI */ |
| 991 | 1043 | ||
| 992 | /* | 1044 | /* |
| @@ -1074,35 +1126,6 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, | |||
| 1074 | const char *name); | 1126 | const char *name); |
| 1075 | #endif | 1127 | #endif |
| 1076 | 1128 | ||
| 1077 | /* | ||
| 1078 | * qc helpers | ||
| 1079 | */ | ||
| 1080 | static inline struct scatterlist * | ||
| 1081 | ata_qc_first_sg(struct ata_queued_cmd *qc) | ||
| 1082 | { | ||
| 1083 | qc->n_iter = 0; | ||
| 1084 | if (qc->n_elem) | ||
| 1085 | return qc->__sg; | ||
| 1086 | if (qc->pad_len) | ||
| 1087 | return &qc->pad_sgent; | ||
| 1088 | return NULL; | ||
| 1089 | } | ||
| 1090 | |||
| 1091 | static inline struct scatterlist * | ||
| 1092 | ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc) | ||
| 1093 | { | ||
| 1094 | if (sg == &qc->pad_sgent) | ||
| 1095 | return NULL; | ||
| 1096 | if (++qc->n_iter < qc->n_elem) | ||
| 1097 | return sg_next(sg); | ||
| 1098 | if (qc->pad_len) | ||
| 1099 | return &qc->pad_sgent; | ||
| 1100 | return NULL; | ||
| 1101 | } | ||
| 1102 | |||
| 1103 | #define ata_for_each_sg(sg, qc) \ | ||
| 1104 | for (sg = ata_qc_first_sg(qc); sg; sg = ata_qc_next_sg(sg, qc)) | ||
| 1105 | |||
| 1106 | static inline unsigned int ata_tag_valid(unsigned int tag) | 1129 | static inline unsigned int ata_tag_valid(unsigned int tag) |
| 1107 | { | 1130 | { |
| 1108 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 1131 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
| @@ -1337,15 +1360,17 @@ static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) | |||
| 1337 | static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | 1360 | static inline void ata_qc_reinit(struct ata_queued_cmd *qc) |
| 1338 | { | 1361 | { |
| 1339 | qc->dma_dir = DMA_NONE; | 1362 | qc->dma_dir = DMA_NONE; |
| 1340 | qc->__sg = NULL; | 1363 | qc->sg = NULL; |
| 1341 | qc->flags = 0; | 1364 | qc->flags = 0; |
| 1342 | qc->cursg = NULL; | 1365 | qc->cursg = NULL; |
| 1343 | qc->cursg_ofs = 0; | 1366 | qc->cursg_ofs = 0; |
| 1344 | qc->nbytes = qc->curbytes = 0; | 1367 | qc->nbytes = qc->raw_nbytes = qc->curbytes = 0; |
| 1345 | qc->n_elem = 0; | 1368 | qc->n_elem = 0; |
| 1369 | qc->mapped_n_elem = 0; | ||
| 1346 | qc->n_iter = 0; | 1370 | qc->n_iter = 0; |
| 1347 | qc->err_mask = 0; | 1371 | qc->err_mask = 0; |
| 1348 | qc->pad_len = 0; | 1372 | qc->pad_len = 0; |
| 1373 | qc->last_sg = NULL; | ||
| 1349 | qc->sect_size = ATA_SECT_SIZE; | 1374 | qc->sect_size = ATA_SECT_SIZE; |
| 1350 | 1375 | ||
| 1351 | ata_tf_init(qc->dev, &qc->tf); | 1376 | ata_tf_init(qc->dev, &qc->tf); |
| @@ -1362,6 +1387,27 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) | |||
| 1362 | ata_id_has_flush_ext(dev->id); | 1387 | ata_id_has_flush_ext(dev->id); |
| 1363 | } | 1388 | } |
| 1364 | 1389 | ||
| 1390 | static inline int atapi_cmd_type(u8 opcode) | ||
| 1391 | { | ||
| 1392 | switch (opcode) { | ||
| 1393 | case GPCMD_READ_10: | ||
| 1394 | case GPCMD_READ_12: | ||
| 1395 | return ATAPI_READ; | ||
| 1396 | |||
| 1397 | case GPCMD_WRITE_10: | ||
| 1398 | case GPCMD_WRITE_12: | ||
| 1399 | case GPCMD_WRITE_AND_VERIFY_10: | ||
| 1400 | return ATAPI_WRITE; | ||
| 1401 | |||
| 1402 | case GPCMD_READ_CD: | ||
| 1403 | case GPCMD_READ_CD_MSF: | ||
| 1404 | return ATAPI_READ_CD; | ||
| 1405 | |||
| 1406 | default: | ||
| 1407 | return ATAPI_MISC; | ||
| 1408 | } | ||
| 1409 | } | ||
| 1410 | |||
| 1365 | static inline unsigned int ac_err_mask(u8 status) | 1411 | static inline unsigned int ac_err_mask(u8 status) |
| 1366 | { | 1412 | { |
| 1367 | if (status & (ATA_BUSY | ATA_DRQ)) | 1413 | if (status & (ATA_BUSY | ATA_DRQ)) |
