aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/libata.h379
1 files changed, 190 insertions, 189 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 01c233303aee..673f34b256ba 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -349,6 +349,22 @@ enum {
349 ATAPI_READ_CD = 2, /* READ CD [MSF] */ 349 ATAPI_READ_CD = 2, /* READ CD [MSF] */
350 ATAPI_PASS_THRU = 3, /* SAT pass-thru */ 350 ATAPI_PASS_THRU = 3, /* SAT pass-thru */
351 ATAPI_MISC = 4, /* the rest */ 351 ATAPI_MISC = 4, /* the rest */
352
353 /* Timing constants */
354 ATA_TIMING_SETUP = (1 << 0),
355 ATA_TIMING_ACT8B = (1 << 1),
356 ATA_TIMING_REC8B = (1 << 2),
357 ATA_TIMING_CYC8B = (1 << 3),
358 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B |
359 ATA_TIMING_CYC8B,
360 ATA_TIMING_ACTIVE = (1 << 4),
361 ATA_TIMING_RECOVER = (1 << 5),
362 ATA_TIMING_CYCLE = (1 << 6),
363 ATA_TIMING_UDMA = (1 << 7),
364 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
365 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
366 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
367 ATA_TIMING_CYCLE | ATA_TIMING_UDMA,
352}; 368};
353 369
354enum ata_xfer_mask { 370enum ata_xfer_mask {
@@ -779,6 +795,9 @@ struct ata_timing {
779 795
780#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin) 796#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin)
781 797
798/*
799 * Core layer - drivers/ata/libata-core.c
800 */
782extern const unsigned long sata_deb_timing_normal[]; 801extern const unsigned long sata_deb_timing_normal[];
783extern const unsigned long sata_deb_timing_hotplug[]; 802extern const unsigned long sata_deb_timing_hotplug[];
784extern const unsigned long sata_deb_timing_long[]; 803extern const unsigned long sata_deb_timing_long[];
@@ -802,22 +821,14 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
802 821
803extern void sata_print_link_status(struct ata_link *link); 822extern void sata_print_link_status(struct ata_link *link);
804extern void ata_port_probe(struct ata_port *); 823extern void ata_port_probe(struct ata_port *);
805extern void ata_bus_reset(struct ata_port *ap);
806extern int sata_set_spd(struct ata_link *link); 824extern int sata_set_spd(struct ata_link *link);
807extern int sata_link_debounce(struct ata_link *link, 825extern int sata_link_debounce(struct ata_link *link,
808 const unsigned long *params, unsigned long deadline); 826 const unsigned long *params, unsigned long deadline);
809extern int sata_link_resume(struct ata_link *link, const unsigned long *params, 827extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
810 unsigned long deadline); 828 unsigned long deadline);
811extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
812extern int ata_std_softreset(struct ata_link *link, unsigned int *classes,
813 unsigned long deadline);
814extern int sata_link_hardreset(struct ata_link *link, 829extern int sata_link_hardreset(struct ata_link *link,
815 const unsigned long *timing, unsigned long deadline); 830 const unsigned long *timing, unsigned long deadline);
816extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
817 unsigned long deadline);
818extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
819extern void ata_port_disable(struct ata_port *); 831extern void ata_port_disable(struct ata_port *);
820extern void ata_std_ports(struct ata_ioports *ioaddr);
821 832
822extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 833extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
823extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 834extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
@@ -843,7 +854,6 @@ extern void ata_sas_port_stop(struct ata_port *ap);
843extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); 854extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
844extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 855extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
845 struct ata_port *ap); 856 struct ata_port *ap);
846extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
847extern int sata_scr_valid(struct ata_link *link); 857extern int sata_scr_valid(struct ata_link *link);
848extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 858extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
849extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 859extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
@@ -855,21 +865,9 @@ extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
855extern void ata_host_resume(struct ata_host *host); 865extern void ata_host_resume(struct ata_host *host);
856#endif 866#endif
857extern int ata_ratelimit(void); 867extern int ata_ratelimit(void);
858extern int ata_busy_sleep(struct ata_port *ap,
859 unsigned long timeout_pat, unsigned long timeout);
860extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline);
861extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
862extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 868extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
863 unsigned long interval_msec, 869 unsigned long interval_msec,
864 unsigned long timeout_msec); 870 unsigned long timeout_msec);
865extern unsigned int ata_dev_try_classify(struct ata_device *dev, int present,
866 u8 *r_err);
867
868/*
869 * Default driver ops implementations
870 */
871extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
872extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
873extern int atapi_cmd_type(u8 opcode); 871extern int atapi_cmd_type(u8 opcode);
874extern void ata_tf_to_fis(const struct ata_taskfile *tf, 872extern void ata_tf_to_fis(const struct ata_taskfile *tf,
875 u8 pmp, int is_cmd, u8 *fis); 873 u8 pmp, int is_cmd, u8 *fis);
@@ -885,22 +883,9 @@ extern int ata_xfer_mode2shift(unsigned long xfer_mode);
885extern const char *ata_mode_string(unsigned long xfer_mask); 883extern const char *ata_mode_string(unsigned long xfer_mask);
886extern unsigned long ata_id_xfermask(const u16 *id); 884extern unsigned long ata_id_xfermask(const u16 *id);
887extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); 885extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
888extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
889extern u8 ata_check_status(struct ata_port *ap);
890extern u8 ata_altstatus(struct ata_port *ap);
891extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
892extern int ata_port_start(struct ata_port *ap); 886extern int ata_port_start(struct ata_port *ap);
893extern int ata_sff_port_start(struct ata_port *ap);
894extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
895extern unsigned int ata_data_xfer(struct ata_device *dev,
896 unsigned char *buf, unsigned int buflen, int rw);
897extern unsigned int ata_data_xfer_noirq(struct ata_device *dev,
898 unsigned char *buf, unsigned int buflen, int rw);
899extern int ata_std_qc_defer(struct ata_queued_cmd *qc); 887extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
900extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
901extern void ata_qc_prep(struct ata_queued_cmd *qc);
902extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 888extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
903extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
904extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 889extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
905 unsigned int n_elem); 890 unsigned int n_elem);
906extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 891extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
@@ -909,18 +894,7 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
909 unsigned int ofs, unsigned int len); 894 unsigned int ofs, unsigned int len);
910extern void ata_id_c_string(const u16 *id, unsigned char *s, 895extern void ata_id_c_string(const u16 *id, unsigned char *s,
911 unsigned int ofs, unsigned int len); 896 unsigned int ofs, unsigned int len);
912extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
913extern void ata_bmdma_start(struct ata_queued_cmd *qc);
914extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
915extern u8 ata_bmdma_status(struct ata_port *ap);
916extern void ata_bmdma_irq_clear(struct ata_port *ap);
917extern void ata_noop_irq_clear(struct ata_port *ap); 897extern void ata_noop_irq_clear(struct ata_port *ap);
918extern void ata_bmdma_freeze(struct ata_port *ap);
919extern void ata_bmdma_thaw(struct ata_port *ap);
920extern void ata_bmdma_error_handler(struct ata_port *ap);
921extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
922extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
923 u8 status, int in_wq);
924extern void ata_qc_complete(struct ata_queued_cmd *qc); 898extern void ata_qc_complete(struct ata_queued_cmd *qc);
925extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active, 899extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
926 void (*finish_qc)(struct ata_queued_cmd *)); 900 void (*finish_qc)(struct ata_queued_cmd *));
@@ -935,7 +909,6 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
935 int queue_depth); 909 int queue_depth);
936extern struct ata_device *ata_dev_pair(struct ata_device *adev); 910extern struct ata_device *ata_dev_pair(struct ata_device *adev);
937extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 911extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
938extern u8 ata_irq_on(struct ata_port *ap);
939 912
940extern int ata_cable_40wire(struct ata_port *ap); 913extern int ata_cable_40wire(struct ata_port *ap);
941extern int ata_cable_80wire(struct ata_port *ap); 914extern int ata_cable_80wire(struct ata_port *ap);
@@ -943,10 +916,7 @@ extern int ata_cable_sata(struct ata_port *ap);
943extern int ata_cable_ignore(struct ata_port *ap); 916extern int ata_cable_ignore(struct ata_port *ap);
944extern int ata_cable_unknown(struct ata_port *ap); 917extern int ata_cable_unknown(struct ata_port *ap);
945 918
946/* 919/* Timing helpers */
947 * Timing helpers
948 */
949
950extern unsigned int ata_pio_need_iordy(const struct ata_device *); 920extern unsigned int ata_pio_need_iordy(const struct ata_device *);
951extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode); 921extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
952extern int ata_timing_compute(struct ata_device *, unsigned short, 922extern int ata_timing_compute(struct ata_device *, unsigned short,
@@ -956,24 +926,31 @@ extern void ata_timing_merge(const struct ata_timing *,
956 unsigned int); 926 unsigned int);
957extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle); 927extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle);
958 928
959enum { 929/* PCI */
960 ATA_TIMING_SETUP = (1 << 0), 930#ifdef CONFIG_PCI
961 ATA_TIMING_ACT8B = (1 << 1), 931struct pci_dev;
962 ATA_TIMING_REC8B = (1 << 2), 932
963 ATA_TIMING_CYC8B = (1 << 3), 933struct pci_bits {
964 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B | 934 unsigned int reg; /* PCI config register to read */
965 ATA_TIMING_CYC8B, 935 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
966 ATA_TIMING_ACTIVE = (1 << 4), 936 unsigned long mask;
967 ATA_TIMING_RECOVER = (1 << 5), 937 unsigned long val;
968 ATA_TIMING_CYCLE = (1 << 6),
969 ATA_TIMING_UDMA = (1 << 7),
970 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
971 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
972 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
973 ATA_TIMING_CYCLE | ATA_TIMING_UDMA,
974}; 938};
975 939
976/* libata-acpi.c */ 940extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
941extern void ata_pci_remove_one(struct pci_dev *pdev);
942
943#ifdef CONFIG_PM
944extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
945extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
946extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
947extern int ata_pci_device_resume(struct pci_dev *pdev);
948#endif /* CONFIG_PM */
949#endif /* CONFIG_PCI */
950
951/*
952 * ACPI - drivers/ata/libata-acpi.c
953 */
977#ifdef CONFIG_ATA_ACPI 954#ifdef CONFIG_ATA_ACPI
978static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 955static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
979{ 956{
@@ -1017,43 +994,8 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
1017} 994}
1018#endif 995#endif
1019 996
1020#ifdef CONFIG_PCI
1021struct pci_dev;
1022
1023extern int ata_pci_init_one(struct pci_dev *pdev,
1024 const struct ata_port_info * const * ppi,
1025 struct scsi_host_template *sht, void *host_priv);
1026extern void ata_pci_remove_one(struct pci_dev *pdev);
1027#ifdef CONFIG_PM
1028extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
1029extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
1030extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
1031extern int ata_pci_device_resume(struct pci_dev *pdev);
1032#endif
1033extern int ata_pci_clear_simplex(struct pci_dev *pdev);
1034
1035struct pci_bits {
1036 unsigned int reg; /* PCI config register to read */
1037 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
1038 unsigned long mask;
1039 unsigned long val;
1040};
1041
1042extern int ata_pci_init_sff_host(struct ata_host *host);
1043extern int ata_pci_init_bmdma(struct ata_host *host);
1044extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
1045 const struct ata_port_info * const * ppi,
1046 struct ata_host **r_host);
1047extern int ata_pci_activate_sff_host(struct ata_host *host,
1048 irq_handler_t irq_handler,
1049 struct scsi_host_template *sht);
1050extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
1051extern unsigned long ata_pci_default_filter(struct ata_device *dev,
1052 unsigned long xfer_mask);
1053#endif /* CONFIG_PCI */
1054
1055/* 997/*
1056 * PMP 998 * PMP - drivers/ata/libata-pmp.c
1057 */ 999 */
1058extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc); 1000extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
1059extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline); 1001extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline);
@@ -1063,7 +1005,7 @@ extern void sata_pmp_std_postreset(struct ata_link *link, unsigned int *class);
1063extern void sata_pmp_error_handler(struct ata_port *ap); 1005extern void sata_pmp_error_handler(struct ata_port *ap);
1064 1006
1065/* 1007/*
1066 * EH 1008 * EH - drivers/ata/libata-eh.c
1067 */ 1009 */
1068extern void ata_port_schedule_eh(struct ata_port *ap); 1010extern void ata_port_schedule_eh(struct ata_port *ap);
1069extern int ata_link_abort(struct ata_link *link); 1011extern int ata_link_abort(struct ata_link *link);
@@ -1106,8 +1048,6 @@ extern void ata_std_error_handler(struct ata_port *ap);
1106extern const struct ata_port_operations ata_base_port_ops; 1048extern const struct ata_port_operations ata_base_port_ops;
1107extern const struct ata_port_operations sata_port_ops; 1049extern const struct ata_port_operations sata_port_ops;
1108extern const struct ata_port_operations sata_pmp_port_ops; 1050extern const struct ata_port_operations sata_pmp_port_ops;
1109extern const struct ata_port_operations ata_sff_port_ops;
1110extern const struct ata_port_operations ata_bmdma_port_ops;
1111 1051
1112#define ATA_BASE_SHT(drv_name) \ 1052#define ATA_BASE_SHT(drv_name) \
1113 .module = THIS_MODULE, \ 1053 .module = THIS_MODULE, \
@@ -1124,17 +1064,6 @@ extern const struct ata_port_operations ata_bmdma_port_ops;
1124 .slave_destroy = ata_scsi_slave_destroy, \ 1064 .slave_destroy = ata_scsi_slave_destroy, \
1125 .bios_param = ata_std_bios_param 1065 .bios_param = ata_std_bios_param
1126 1066
1127/* PIO only, sg_tablesize and dma_boundary limits can be removed */
1128#define ATA_PIO_SHT(drv_name) \
1129 ATA_BASE_SHT(drv_name), \
1130 .sg_tablesize = LIBATA_MAX_PRD, \
1131 .dma_boundary = ATA_DMA_BOUNDARY
1132
1133#define ATA_BMDMA_SHT(drv_name) \
1134 ATA_BASE_SHT(drv_name), \
1135 .sg_tablesize = LIBATA_MAX_PRD, \
1136 .dma_boundary = ATA_DMA_BOUNDARY
1137
1138#define ATA_NCQ_SHT(drv_name) \ 1067#define ATA_NCQ_SHT(drv_name) \
1139 ATA_BASE_SHT(drv_name), \ 1068 ATA_BASE_SHT(drv_name), \
1140 .change_queue_depth = ata_scsi_change_queue_depth 1069 .change_queue_depth = ata_scsi_change_queue_depth
@@ -1287,11 +1216,6 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1287 for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \ 1216 for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \
1288 (dev) >= (link)->device || ((dev) = NULL); (dev)--) 1217 (dev) >= (link)->device || ((dev) = NULL); (dev)--)
1289 1218
1290static inline u8 ata_chk_status(struct ata_port *ap)
1291{
1292 return ap->ops->check_status(ap);
1293}
1294
1295/** 1219/**
1296 * ata_ncq_enabled - Test whether NCQ is enabled 1220 * ata_ncq_enabled - Test whether NCQ is enabled
1297 * @dev: ATA device to test for 1221 * @dev: ATA device to test for
@@ -1308,74 +1232,6 @@ static inline int ata_ncq_enabled(struct ata_device *dev)
1308 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; 1232 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
1309} 1233}
1310 1234
1311/**
1312 * ata_pause - Flush writes and pause 400 nanoseconds.
1313 * @ap: Port to wait for.
1314 *
1315 * LOCKING:
1316 * Inherited from caller.
1317 */
1318
1319static inline void ata_pause(struct ata_port *ap)
1320{
1321 ata_altstatus(ap);
1322 ndelay(400);
1323}
1324
1325
1326/**
1327 * ata_busy_wait - Wait for a port status register
1328 * @ap: Port to wait for.
1329 * @bits: bits that must be clear
1330 * @max: number of 10uS waits to perform
1331 *
1332 * Waits up to max*10 microseconds for the selected bits in the port's
1333 * status register to be cleared.
1334 * Returns final value of status register.
1335 *
1336 * LOCKING:
1337 * Inherited from caller.
1338 */
1339
1340static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
1341 unsigned int max)
1342{
1343 u8 status;
1344
1345 do {
1346 udelay(10);
1347 status = ata_chk_status(ap);
1348 max--;
1349 } while (status != 0xff && (status & bits) && (max > 0));
1350
1351 return status;
1352}
1353
1354
1355/**
1356 * ata_wait_idle - Wait for a port to be idle.
1357 * @ap: Port to wait for.
1358 *
1359 * Waits up to 10ms for port's BUSY and DRQ signals to clear.
1360 * Returns final value of status register.
1361 *
1362 * LOCKING:
1363 * Inherited from caller.
1364 */
1365
1366static inline u8 ata_wait_idle(struct ata_port *ap)
1367{
1368 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
1369
1370#ifdef ATA_DEBUG
1371 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
1372 ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n",
1373 status);
1374#endif
1375
1376 return status;
1377}
1378
1379static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) 1235static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
1380{ 1236{
1381 qc->tf.ctl |= ATA_NIEN; 1237 qc->tf.ctl |= ATA_NIEN;
@@ -1468,4 +1324,149 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1468 return *(struct ata_port **)&host->hostdata[0]; 1324 return *(struct ata_port **)&host->hostdata[0];
1469} 1325}
1470 1326
1327/**************************************************************************
1328 * SFF - drivers/ata/libata-sff.c
1329 */
1330extern const struct ata_port_operations ata_sff_port_ops;
1331extern const struct ata_port_operations ata_bmdma_port_ops;
1332
1333/* PIO only, sg_tablesize and dma_boundary limits can be removed */
1334#define ATA_PIO_SHT(drv_name) \
1335 ATA_BASE_SHT(drv_name), \
1336 .sg_tablesize = LIBATA_MAX_PRD, \
1337 .dma_boundary = ATA_DMA_BOUNDARY
1338
1339#define ATA_BMDMA_SHT(drv_name) \
1340 ATA_BASE_SHT(drv_name), \
1341 .sg_tablesize = LIBATA_MAX_PRD, \
1342 .dma_boundary = ATA_DMA_BOUNDARY
1343
1344extern void ata_qc_prep(struct ata_queued_cmd *qc);
1345extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
1346extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
1347extern u8 ata_check_status(struct ata_port *ap);
1348extern u8 ata_altstatus(struct ata_port *ap);
1349extern int ata_busy_sleep(struct ata_port *ap,
1350 unsigned long timeout_pat, unsigned long timeout);
1351extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
1352extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
1353extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
1354extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
1355extern unsigned int ata_data_xfer(struct ata_device *dev,
1356 unsigned char *buf, unsigned int buflen, int rw);
1357extern unsigned int ata_data_xfer_noirq(struct ata_device *dev,
1358 unsigned char *buf, unsigned int buflen, int rw);
1359extern u8 ata_irq_on(struct ata_port *ap);
1360extern void ata_bmdma_irq_clear(struct ata_port *ap);
1361extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1362 u8 status, int in_wq);
1363extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
1364extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
1365extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
1366extern void ata_bmdma_freeze(struct ata_port *ap);
1367extern void ata_bmdma_thaw(struct ata_port *ap);
1368extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
1369extern unsigned int ata_dev_try_classify(struct ata_device *dev, int present,
1370 u8 *r_err);
1371extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline);
1372extern int ata_std_softreset(struct ata_link *link, unsigned int *classes,
1373 unsigned long deadline);
1374extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
1375 unsigned long deadline);
1376extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
1377extern void ata_bmdma_error_handler(struct ata_port *ap);
1378extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
1379extern int ata_sff_port_start(struct ata_port *ap);
1380extern void ata_std_ports(struct ata_ioports *ioaddr);
1381extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
1382extern void ata_bmdma_start(struct ata_queued_cmd *qc);
1383extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
1384extern u8 ata_bmdma_status(struct ata_port *ap);
1385extern void ata_bus_reset(struct ata_port *ap);
1386
1387#ifdef CONFIG_PCI
1388extern int ata_pci_clear_simplex(struct pci_dev *pdev);
1389extern unsigned long ata_pci_default_filter(struct ata_device *dev,
1390 unsigned long xfer_mask);
1391extern int ata_pci_init_bmdma(struct ata_host *host);
1392extern int ata_pci_init_sff_host(struct ata_host *host);
1393extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
1394 const struct ata_port_info * const * ppi,
1395 struct ata_host **r_host);
1396extern int ata_pci_activate_sff_host(struct ata_host *host,
1397 irq_handler_t irq_handler,
1398 struct scsi_host_template *sht);
1399extern int ata_pci_init_one(struct pci_dev *pdev,
1400 const struct ata_port_info * const * ppi,
1401 struct scsi_host_template *sht, void *host_priv);
1402#endif /* CONFIG_PCI */
1403
1404static inline u8 ata_chk_status(struct ata_port *ap)
1405{
1406 return ap->ops->check_status(ap);
1407}
1408
1409/**
1410 * ata_pause - Flush writes and pause 400 nanoseconds.
1411 * @ap: Port to wait for.
1412 *
1413 * LOCKING:
1414 * Inherited from caller.
1415 */
1416static inline void ata_pause(struct ata_port *ap)
1417{
1418 ata_altstatus(ap);
1419 ndelay(400);
1420}
1421
1422/**
1423 * ata_busy_wait - Wait for a port status register
1424 * @ap: Port to wait for.
1425 * @bits: bits that must be clear
1426 * @max: number of 10uS waits to perform
1427 *
1428 * Waits up to max*10 microseconds for the selected bits in the port's
1429 * status register to be cleared.
1430 * Returns final value of status register.
1431 *
1432 * LOCKING:
1433 * Inherited from caller.
1434 */
1435static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
1436 unsigned int max)
1437{
1438 u8 status;
1439
1440 do {
1441 udelay(10);
1442 status = ata_chk_status(ap);
1443 max--;
1444 } while (status != 0xff && (status & bits) && (max > 0));
1445
1446 return status;
1447}
1448
1449/**
1450 * ata_wait_idle - Wait for a port to be idle.
1451 * @ap: Port to wait for.
1452 *
1453 * Waits up to 10ms for port's BUSY and DRQ signals to clear.
1454 * Returns final value of status register.
1455 *
1456 * LOCKING:
1457 * Inherited from caller.
1458 */
1459static inline u8 ata_wait_idle(struct ata_port *ap)
1460{
1461 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
1462
1463#ifdef ATA_DEBUG
1464 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
1465 ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n",
1466 status);
1467#endif
1468
1469 return status;
1470}
1471
1471#endif /* __LINUX_LIBATA_H__ */ 1472#endif /* __LINUX_LIBATA_H__ */