diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/ata.h | 116 | ||||
-rw-r--r-- | include/linux/libata.h | 320 |
2 files changed, 338 insertions, 98 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index c043c1ccf1c5..a4f373f8b798 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -230,6 +230,12 @@ enum { | |||
230 | 230 | ||
231 | SETFEATURES_SPINUP = 0x07, /* Spin-up drive */ | 231 | SETFEATURES_SPINUP = 0x07, /* Spin-up drive */ |
232 | 232 | ||
233 | SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */ | ||
234 | SETFEATURES_SATA_DISABLE = 0x90, /* Disable use of SATA feature */ | ||
235 | |||
236 | /* SETFEATURE Sector counts for SATA features */ | ||
237 | SATA_AN = 0x05, /* Asynchronous Notification */ | ||
238 | |||
233 | /* ATAPI stuff */ | 239 | /* ATAPI stuff */ |
234 | ATAPI_PKT_DMA = (1 << 0), | 240 | ATAPI_PKT_DMA = (1 << 0), |
235 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: | 241 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: |
@@ -281,6 +287,15 @@ enum { | |||
281 | SERR_PROTOCOL = (1 << 10), /* protocol violation */ | 287 | SERR_PROTOCOL = (1 << 10), /* protocol violation */ |
282 | SERR_INTERNAL = (1 << 11), /* host internal error */ | 288 | SERR_INTERNAL = (1 << 11), /* host internal error */ |
283 | SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */ | 289 | SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */ |
290 | SERR_PHY_INT_ERR = (1 << 17), /* PHY internal error */ | ||
291 | SERR_COMM_WAKE = (1 << 18), /* Comm wake */ | ||
292 | SERR_10B_8B_ERR = (1 << 19), /* 10b to 8b decode error */ | ||
293 | SERR_DISPARITY = (1 << 20), /* Disparity */ | ||
294 | SERR_CRC = (1 << 21), /* CRC error */ | ||
295 | SERR_HANDSHAKE = (1 << 22), /* Handshake error */ | ||
296 | SERR_LINK_SEQ_ERR = (1 << 23), /* Link sequence error */ | ||
297 | SERR_TRANS_ST_ERROR = (1 << 24), /* Transport state trans. error */ | ||
298 | SERR_UNRECOG_FIS = (1 << 25), /* Unrecognized FIS */ | ||
284 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ | 299 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ |
285 | 300 | ||
286 | /* struct ata_taskfile flags */ | 301 | /* struct ata_taskfile flags */ |
@@ -341,24 +356,17 @@ struct ata_taskfile { | |||
341 | }; | 356 | }; |
342 | 357 | ||
343 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) | 358 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) |
344 | #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) | ||
345 | #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) | ||
346 | #define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10)) | ||
347 | #define ata_id_has_fua(id) ((id)[84] & (1 << 6)) | ||
348 | #define ata_id_has_flush(id) ((id)[83] & (1 << 12)) | ||
349 | #define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13)) | ||
350 | #define ata_id_has_lba48(id) ((id)[83] & (1 << 10)) | ||
351 | #define ata_id_has_hpa(id) ((id)[82] & (1 << 10)) | ||
352 | #define ata_id_has_wcache(id) ((id)[82] & (1 << 5)) | ||
353 | #define ata_id_has_pm(id) ((id)[82] & (1 << 3)) | ||
354 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) | 359 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) |
355 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) | 360 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) |
356 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) | 361 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) |
357 | #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) | 362 | #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) |
358 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) | 363 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) |
359 | #define ata_id_has_dword_io(id) ((id)[50] & (1 << 0)) | 364 | #define ata_id_has_dword_io(id) ((id)[48] & (1 << 0)) |
365 | #define ata_id_has_atapi_AN(id) \ | ||
366 | ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ | ||
367 | ((id)[78] & (1 << 5)) ) | ||
360 | #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) | 368 | #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) |
361 | #define ata_id_has_iordy(id) ((id)[49] & (1 << 9)) | 369 | #define ata_id_has_iordy(id) ((id)[49] & (1 << 11)) |
362 | #define ata_id_u32(id,n) \ | 370 | #define ata_id_u32(id,n) \ |
363 | (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) | 371 | (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) |
364 | #define ata_id_u64(id,n) \ | 372 | #define ata_id_u64(id,n) \ |
@@ -369,6 +377,90 @@ struct ata_taskfile { | |||
369 | 377 | ||
370 | #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) | 378 | #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) |
371 | 379 | ||
380 | static inline int ata_id_has_fua(const u16 *id) | ||
381 | { | ||
382 | if ((id[84] & 0xC000) != 0x4000) | ||
383 | return 0; | ||
384 | return id[84] & (1 << 6); | ||
385 | } | ||
386 | |||
387 | static inline int ata_id_has_flush(const u16 *id) | ||
388 | { | ||
389 | if ((id[83] & 0xC000) != 0x4000) | ||
390 | return 0; | ||
391 | return id[83] & (1 << 12); | ||
392 | } | ||
393 | |||
394 | static inline int ata_id_has_flush_ext(const u16 *id) | ||
395 | { | ||
396 | if ((id[83] & 0xC000) != 0x4000) | ||
397 | return 0; | ||
398 | return id[83] & (1 << 13); | ||
399 | } | ||
400 | |||
401 | static inline int ata_id_has_lba48(const u16 *id) | ||
402 | { | ||
403 | if ((id[83] & 0xC000) != 0x4000) | ||
404 | return 0; | ||
405 | return id[83] & (1 << 10); | ||
406 | } | ||
407 | |||
408 | static inline int ata_id_hpa_enabled(const u16 *id) | ||
409 | { | ||
410 | /* Yes children, word 83 valid bits cover word 82 data */ | ||
411 | if ((id[83] & 0xC000) != 0x4000) | ||
412 | return 0; | ||
413 | /* And 87 covers 85-87 */ | ||
414 | if ((id[87] & 0xC000) != 0x4000) | ||
415 | return 0; | ||
416 | /* Check command sets enabled as well as supported */ | ||
417 | if ((id[85] & ( 1 << 10)) == 0) | ||
418 | return 0; | ||
419 | return id[82] & (1 << 10); | ||
420 | } | ||
421 | |||
422 | static inline int ata_id_has_wcache(const u16 *id) | ||
423 | { | ||
424 | /* Yes children, word 83 valid bits cover word 82 data */ | ||
425 | if ((id[83] & 0xC000) != 0x4000) | ||
426 | return 0; | ||
427 | return id[82] & (1 << 5); | ||
428 | } | ||
429 | |||
430 | static inline int ata_id_has_pm(const u16 *id) | ||
431 | { | ||
432 | if ((id[83] & 0xC000) != 0x4000) | ||
433 | return 0; | ||
434 | return id[82] & (1 << 3); | ||
435 | } | ||
436 | |||
437 | static inline int ata_id_rahead_enabled(const u16 *id) | ||
438 | { | ||
439 | if ((id[87] & 0xC000) != 0x4000) | ||
440 | return 0; | ||
441 | return id[85] & (1 << 6); | ||
442 | } | ||
443 | |||
444 | static inline int ata_id_wcache_enabled(const u16 *id) | ||
445 | { | ||
446 | if ((id[87] & 0xC000) != 0x4000) | ||
447 | return 0; | ||
448 | return id[85] & (1 << 5); | ||
449 | } | ||
450 | |||
451 | /** | ||
452 | * ata_id_major_version - get ATA level of drive | ||
453 | * @id: Identify data | ||
454 | * | ||
455 | * Caveats: | ||
456 | * ATA-1 considers identify optional | ||
457 | * ATA-2 introduces mandatory identify | ||
458 | * ATA-3 introduces word 80 and accurate reporting | ||
459 | * | ||
460 | * The practical impact of this is that ata_id_major_version cannot | ||
461 | * reliably report on drives below ATA3. | ||
462 | */ | ||
463 | |||
372 | static inline unsigned int ata_id_major_version(const u16 *id) | 464 | static inline unsigned int ata_id_major_version(const u16 *id) |
373 | { | 465 | { |
374 | unsigned int mver; | 466 | unsigned int mver; |
diff --git a/include/linux/libata.h b/include/linux/libata.h index a67bb9075e9b..229a9ff9f924 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/pci.h> | ||
32 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
33 | #include <asm/scatterlist.h> | 32 | #include <asm/scatterlist.h> |
34 | #include <linux/io.h> | 33 | #include <linux/io.h> |
@@ -107,12 +106,6 @@ static inline u32 ata_msg_init(int dval, int default_msg_enable_bits) | |||
107 | /* defines only for the constants which don't work well as enums */ | 106 | /* defines only for the constants which don't work well as enums */ |
108 | #define ATA_TAG_POISON 0xfafbfcfdU | 107 | #define ATA_TAG_POISON 0xfafbfcfdU |
109 | 108 | ||
110 | /* move to PCI layer? */ | ||
111 | static inline struct device *pci_dev_to_dev(struct pci_dev *pdev) | ||
112 | { | ||
113 | return &pdev->dev; | ||
114 | } | ||
115 | |||
116 | enum { | 109 | enum { |
117 | /* various global constants */ | 110 | /* various global constants */ |
118 | LIBATA_MAX_PRD = ATA_MAX_PRD / 2, | 111 | LIBATA_MAX_PRD = ATA_MAX_PRD / 2, |
@@ -139,11 +132,12 @@ enum { | |||
139 | ATA_DFLAG_FLUSH_EXT = (1 << 4), /* do FLUSH_EXT instead of FLUSH */ | 132 | ATA_DFLAG_FLUSH_EXT = (1 << 4), /* do FLUSH_EXT instead of FLUSH */ |
140 | ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ | 133 | ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ |
141 | ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ | 134 | ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ |
142 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, | 135 | ATA_DFLAG_AN = (1 << 7), /* AN configured */ |
136 | ATA_DFLAG_CFG_MASK = (1 << 12) - 1, | ||
143 | 137 | ||
144 | ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ | 138 | ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ |
145 | ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ | 139 | ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ |
146 | ATA_DFLAG_SPUNDOWN = (1 << 10), /* XXX: for spindown_compat */ | 140 | ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ |
147 | ATA_DFLAG_INIT_MASK = (1 << 16) - 1, | 141 | ATA_DFLAG_INIT_MASK = (1 << 16) - 1, |
148 | 142 | ||
149 | ATA_DFLAG_DETACH = (1 << 16), | 143 | ATA_DFLAG_DETACH = (1 << 16), |
@@ -154,7 +148,22 @@ enum { | |||
154 | ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */ | 148 | ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */ |
155 | ATA_DEV_ATAPI = 3, /* ATAPI device */ | 149 | ATA_DEV_ATAPI = 3, /* ATAPI device */ |
156 | ATA_DEV_ATAPI_UNSUP = 4, /* ATAPI device (unsupported) */ | 150 | ATA_DEV_ATAPI_UNSUP = 4, /* ATAPI device (unsupported) */ |
157 | ATA_DEV_NONE = 5, /* no device */ | 151 | ATA_DEV_PMP = 5, /* SATA port multiplier */ |
152 | ATA_DEV_PMP_UNSUP = 6, /* SATA port multiplier (unsupported) */ | ||
153 | ATA_DEV_SEMB = 7, /* SEMB */ | ||
154 | ATA_DEV_SEMB_UNSUP = 8, /* SEMB (unsupported) */ | ||
155 | ATA_DEV_NONE = 9, /* no device */ | ||
156 | |||
157 | /* struct ata_link flags */ | ||
158 | ATA_LFLAG_HRST_TO_RESUME = (1 << 0), /* hardreset to resume link */ | ||
159 | ATA_LFLAG_SKIP_D2H_BSY = (1 << 1), /* can't wait for the first D2H | ||
160 | * Register FIS clearing BSY */ | ||
161 | ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ | ||
162 | ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ | ||
163 | ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ | ||
164 | ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB, | ||
165 | ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ | ||
166 | ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ | ||
158 | 167 | ||
159 | /* struct ata_port flags */ | 168 | /* struct ata_port flags */ |
160 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ | 169 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ |
@@ -170,13 +179,12 @@ enum { | |||
170 | ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD | 179 | ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD |
171 | * doesn't handle PIO interrupts */ | 180 | * doesn't handle PIO interrupts */ |
172 | ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */ | 181 | ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */ |
173 | ATA_FLAG_HRST_TO_RESUME = (1 << 11), /* hardreset to resume phy */ | ||
174 | ATA_FLAG_SKIP_D2H_BSY = (1 << 12), /* can't wait for the first D2H | ||
175 | * Register FIS clearing BSY */ | ||
176 | ATA_FLAG_DEBUGMSG = (1 << 13), | 182 | ATA_FLAG_DEBUGMSG = (1 << 13), |
177 | ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ | 183 | ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ |
178 | ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */ | 184 | ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */ |
179 | ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ | 185 | ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ |
186 | ATA_FLAG_AN = (1 << 18), /* controller supports AN */ | ||
187 | ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ | ||
180 | 188 | ||
181 | /* The following flag belongs to ap->pflags but is kept in | 189 | /* The following flag belongs to ap->pflags but is kept in |
182 | * ap->flags because it's referenced in many LLDs and will be | 190 | * ap->flags because it's referenced in many LLDs and will be |
@@ -195,6 +203,7 @@ enum { | |||
195 | ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ | 203 | ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ |
196 | ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ | 204 | ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ |
197 | ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */ | 205 | ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */ |
206 | ATA_PFLAG_RESETTING = (1 << 8), /* reset in progress */ | ||
198 | 207 | ||
199 | ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ | 208 | ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ |
200 | ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ | 209 | ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ |
@@ -207,6 +216,7 @@ enum { | |||
207 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 216 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
208 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ | 217 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
209 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ | 218 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ |
219 | ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ | ||
210 | 220 | ||
211 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ | 221 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ |
212 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ | 222 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ |
@@ -263,6 +273,10 @@ enum { | |||
263 | /* ering size */ | 273 | /* ering size */ |
264 | ATA_ERING_SIZE = 32, | 274 | ATA_ERING_SIZE = 32, |
265 | 275 | ||
276 | /* return values for ->qc_defer */ | ||
277 | ATA_DEFER_LINK = 1, | ||
278 | ATA_DEFER_PORT = 2, | ||
279 | |||
266 | /* desc_len for ata_eh_info and context */ | 280 | /* desc_len for ata_eh_info and context */ |
267 | ATA_EH_DESC_LEN = 80, | 281 | ATA_EH_DESC_LEN = 80, |
268 | 282 | ||
@@ -270,6 +284,7 @@ enum { | |||
270 | ATA_EH_REVALIDATE = (1 << 0), | 284 | ATA_EH_REVALIDATE = (1 << 0), |
271 | ATA_EH_SOFTRESET = (1 << 1), | 285 | ATA_EH_SOFTRESET = (1 << 1), |
272 | ATA_EH_HARDRESET = (1 << 2), | 286 | ATA_EH_HARDRESET = (1 << 2), |
287 | ATA_EH_ENABLE_LINK = (1 << 3), | ||
273 | 288 | ||
274 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | 289 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, |
275 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, | 290 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, |
@@ -289,12 +304,16 @@ enum { | |||
289 | ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, | 304 | ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, |
290 | ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK, | 305 | ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK, |
291 | 306 | ||
292 | /* max repeat if error condition is still set after ->error_handler */ | 307 | /* max tries if error condition is still set after ->error_handler */ |
293 | ATA_EH_MAX_REPEAT = 5, | 308 | ATA_EH_MAX_TRIES = 5, |
294 | 309 | ||
295 | /* how hard are we gonna try to probe/recover devices */ | 310 | /* how hard are we gonna try to probe/recover devices */ |
296 | ATA_PROBE_MAX_TRIES = 3, | 311 | ATA_PROBE_MAX_TRIES = 3, |
297 | ATA_EH_DEV_TRIES = 3, | 312 | ATA_EH_DEV_TRIES = 3, |
313 | ATA_EH_PMP_TRIES = 5, | ||
314 | ATA_EH_PMP_LINK_TRIES = 3, | ||
315 | |||
316 | SATA_PMP_SCR_TIMEOUT = 250, | ||
298 | 317 | ||
299 | /* Horkage types. May be set by libata or controller on drives | 318 | /* Horkage types. May be set by libata or controller on drives |
300 | (some horkage may be drive/controller pair dependant */ | 319 | (some horkage may be drive/controller pair dependant */ |
@@ -304,6 +323,14 @@ enum { | |||
304 | ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ | 323 | ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ |
305 | ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */ | 324 | ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */ |
306 | ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ | 325 | ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ |
326 | ATA_HORKAGE_SKIP_PM = (1 << 5), /* Skip PM operations */ | ||
327 | ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ | ||
328 | |||
329 | /* DMA mask for user DMA control: User visible values; DO NOT | ||
330 | renumber */ | ||
331 | ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ | ||
332 | ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ | ||
333 | ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */ | ||
307 | }; | 334 | }; |
308 | 335 | ||
309 | enum hsm_task_states { | 336 | enum hsm_task_states { |
@@ -333,14 +360,15 @@ enum ata_completion_errors { | |||
333 | struct scsi_device; | 360 | struct scsi_device; |
334 | struct ata_port_operations; | 361 | struct ata_port_operations; |
335 | struct ata_port; | 362 | struct ata_port; |
363 | struct ata_link; | ||
336 | struct ata_queued_cmd; | 364 | struct ata_queued_cmd; |
337 | 365 | ||
338 | /* typedefs */ | 366 | /* typedefs */ |
339 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 367 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
340 | typedef int (*ata_prereset_fn_t)(struct ata_port *ap, unsigned long deadline); | 368 | typedef int (*ata_prereset_fn_t)(struct ata_link *link, unsigned long deadline); |
341 | typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes, | 369 | typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes, |
342 | unsigned long deadline); | 370 | unsigned long deadline); |
343 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); | 371 | typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); |
344 | 372 | ||
345 | struct ata_ioports { | 373 | struct ata_ioports { |
346 | void __iomem *cmd_addr; | 374 | void __iomem *cmd_addr; |
@@ -363,8 +391,6 @@ struct ata_ioports { | |||
363 | struct ata_host { | 391 | struct ata_host { |
364 | spinlock_t lock; | 392 | spinlock_t lock; |
365 | struct device *dev; | 393 | struct device *dev; |
366 | unsigned long irq; | ||
367 | unsigned long irq2; | ||
368 | void __iomem * const *iomap; | 394 | void __iomem * const *iomap; |
369 | unsigned int n_ports; | 395 | unsigned int n_ports; |
370 | void *private_data; | 396 | void *private_data; |
@@ -436,7 +462,7 @@ struct ata_ering { | |||
436 | }; | 462 | }; |
437 | 463 | ||
438 | struct ata_device { | 464 | struct ata_device { |
439 | struct ata_port *ap; | 465 | struct ata_link *link; |
440 | unsigned int devno; /* 0 or 1 */ | 466 | unsigned int devno; /* 0 or 1 */ |
441 | unsigned long flags; /* ATA_DFLAG_xxx */ | 467 | unsigned long flags; /* ATA_DFLAG_xxx */ |
442 | unsigned int horkage; /* List of broken features */ | 468 | unsigned int horkage; /* List of broken features */ |
@@ -447,7 +473,12 @@ struct ata_device { | |||
447 | /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ | 473 | /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ |
448 | u64 n_sectors; /* size of device, if ATA */ | 474 | u64 n_sectors; /* size of device, if ATA */ |
449 | unsigned int class; /* ATA_DEV_xxx */ | 475 | unsigned int class; /* ATA_DEV_xxx */ |
450 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ | 476 | |
477 | union { | ||
478 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ | ||
479 | u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */ | ||
480 | }; | ||
481 | |||
451 | u8 pio_mode; | 482 | u8 pio_mode; |
452 | u8 dma_mode; | 483 | u8 dma_mode; |
453 | u8 xfer_mode; | 484 | u8 xfer_mode; |
@@ -510,6 +541,27 @@ struct ata_acpi_gtm { | |||
510 | u32 flags; | 541 | u32 flags; |
511 | } __packed; | 542 | } __packed; |
512 | 543 | ||
544 | struct ata_link { | ||
545 | struct ata_port *ap; | ||
546 | int pmp; /* port multiplier port # */ | ||
547 | |||
548 | unsigned int active_tag; /* active tag on this link */ | ||
549 | u32 sactive; /* active NCQ commands */ | ||
550 | |||
551 | unsigned int flags; /* ATA_LFLAG_xxx */ | ||
552 | |||
553 | unsigned int hw_sata_spd_limit; | ||
554 | unsigned int sata_spd_limit; | ||
555 | unsigned int sata_spd; /* current SATA PHY speed */ | ||
556 | |||
557 | /* record runtime error info, protected by host_set lock */ | ||
558 | struct ata_eh_info eh_info; | ||
559 | /* EH context */ | ||
560 | struct ata_eh_context eh_context; | ||
561 | |||
562 | struct ata_device device[ATA_MAX_DEVICES]; | ||
563 | }; | ||
564 | |||
513 | struct ata_port { | 565 | struct ata_port { |
514 | struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ | 566 | struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ |
515 | const struct ata_port_operations *ops; | 567 | const struct ata_port_operations *ops; |
@@ -533,23 +585,17 @@ struct ata_port { | |||
533 | unsigned int mwdma_mask; | 585 | unsigned int mwdma_mask; |
534 | unsigned int udma_mask; | 586 | unsigned int udma_mask; |
535 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 587 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
536 | unsigned int hw_sata_spd_limit; | ||
537 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | ||
538 | unsigned int sata_spd; /* current SATA PHY speed */ | ||
539 | |||
540 | /* record runtime error info, protected by host lock */ | ||
541 | struct ata_eh_info eh_info; | ||
542 | /* EH context owned by EH */ | ||
543 | struct ata_eh_context eh_context; | ||
544 | |||
545 | struct ata_device device[ATA_MAX_DEVICES]; | ||
546 | 588 | ||
547 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; | 589 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; |
548 | unsigned long qc_allocated; | 590 | unsigned long qc_allocated; |
549 | unsigned int qc_active; | 591 | unsigned int qc_active; |
592 | int nr_active_links; /* #links with active qcs */ | ||
593 | |||
594 | struct ata_link link; /* host default link */ | ||
550 | 595 | ||
551 | unsigned int active_tag; | 596 | int nr_pmp_links; /* nr of available PMP links */ |
552 | u32 sactive; | 597 | struct ata_link *pmp_link; /* array of PMP links */ |
598 | struct ata_link *excl_link; /* for PMP qc exclusion */ | ||
553 | 599 | ||
554 | struct ata_port_stats stats; | 600 | struct ata_port_stats stats; |
555 | struct ata_host *host; | 601 | struct ata_host *host; |
@@ -565,6 +611,7 @@ struct ata_port { | |||
565 | u32 msg_enable; | 611 | u32 msg_enable; |
566 | struct list_head eh_done_q; | 612 | struct list_head eh_done_q; |
567 | wait_queue_head_t eh_wait_q; | 613 | wait_queue_head_t eh_wait_q; |
614 | int eh_tries; | ||
568 | 615 | ||
569 | pm_message_t pm_mesg; | 616 | pm_message_t pm_mesg; |
570 | int *pm_result; | 617 | int *pm_result; |
@@ -582,8 +629,6 @@ struct ata_port { | |||
582 | }; | 629 | }; |
583 | 630 | ||
584 | struct ata_port_operations { | 631 | struct ata_port_operations { |
585 | void (*port_disable) (struct ata_port *); | ||
586 | |||
587 | void (*dev_config) (struct ata_device *); | 632 | void (*dev_config) (struct ata_device *); |
588 | 633 | ||
589 | void (*set_piomode) (struct ata_port *, struct ata_device *); | 634 | void (*set_piomode) (struct ata_port *, struct ata_device *); |
@@ -599,7 +644,7 @@ struct ata_port_operations { | |||
599 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 644 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
600 | 645 | ||
601 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ | 646 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ |
602 | int (*set_mode) (struct ata_port *ap, struct ata_device **r_failed_dev); | 647 | int (*set_mode) (struct ata_link *link, struct ata_device **r_failed_dev); |
603 | 648 | ||
604 | int (*cable_detect) (struct ata_port *ap); | 649 | int (*cable_detect) (struct ata_port *ap); |
605 | 650 | ||
@@ -610,9 +655,14 @@ struct ata_port_operations { | |||
610 | 655 | ||
611 | void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); | 656 | void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); |
612 | 657 | ||
658 | int (*qc_defer) (struct ata_queued_cmd *qc); | ||
613 | void (*qc_prep) (struct ata_queued_cmd *qc); | 659 | void (*qc_prep) (struct ata_queued_cmd *qc); |
614 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); | 660 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
615 | 661 | ||
662 | /* port multiplier */ | ||
663 | void (*pmp_attach) (struct ata_port *ap); | ||
664 | void (*pmp_detach) (struct ata_port *ap); | ||
665 | |||
616 | /* Error handlers. ->error_handler overrides ->eng_timeout and | 666 | /* Error handlers. ->error_handler overrides ->eng_timeout and |
617 | * indicates that new-style EH is in place. | 667 | * indicates that new-style EH is in place. |
618 | */ | 668 | */ |
@@ -626,7 +676,6 @@ struct ata_port_operations { | |||
626 | irq_handler_t irq_handler; | 676 | irq_handler_t irq_handler; |
627 | void (*irq_clear) (struct ata_port *); | 677 | void (*irq_clear) (struct ata_port *); |
628 | u8 (*irq_on) (struct ata_port *); | 678 | u8 (*irq_on) (struct ata_port *); |
629 | u8 (*irq_ack) (struct ata_port *ap, unsigned int chk_drq); | ||
630 | 679 | ||
631 | int (*scr_read) (struct ata_port *ap, unsigned int sc_reg, u32 *val); | 680 | int (*scr_read) (struct ata_port *ap, unsigned int sc_reg, u32 *val); |
632 | int (*scr_write) (struct ata_port *ap, unsigned int sc_reg, u32 val); | 681 | int (*scr_write) (struct ata_port *ap, unsigned int sc_reg, u32 val); |
@@ -646,6 +695,7 @@ struct ata_port_operations { | |||
646 | struct ata_port_info { | 695 | struct ata_port_info { |
647 | struct scsi_host_template *sht; | 696 | struct scsi_host_template *sht; |
648 | unsigned long flags; | 697 | unsigned long flags; |
698 | unsigned long link_flags; | ||
649 | unsigned long pio_mask; | 699 | unsigned long pio_mask; |
650 | unsigned long mwdma_mask; | 700 | unsigned long mwdma_mask; |
651 | unsigned long udma_mask; | 701 | unsigned long udma_mask; |
@@ -689,38 +739,27 @@ static inline int ata_port_is_dummy(struct ata_port *ap) | |||
689 | return ap->ops == &ata_dummy_port_ops; | 739 | return ap->ops == &ata_dummy_port_ops; |
690 | } | 740 | } |
691 | 741 | ||
692 | extern void sata_print_link_status(struct ata_port *ap); | 742 | extern void sata_print_link_status(struct ata_link *link); |
693 | extern void ata_port_probe(struct ata_port *); | 743 | extern void ata_port_probe(struct ata_port *); |
694 | extern void __sata_phy_reset(struct ata_port *ap); | 744 | extern void __sata_phy_reset(struct ata_port *ap); |
695 | extern void sata_phy_reset(struct ata_port *ap); | 745 | extern void sata_phy_reset(struct ata_port *ap); |
696 | extern void ata_bus_reset(struct ata_port *ap); | 746 | extern void ata_bus_reset(struct ata_port *ap); |
697 | extern int sata_set_spd(struct ata_port *ap); | 747 | extern int sata_set_spd(struct ata_link *link); |
698 | extern int sata_phy_debounce(struct ata_port *ap, const unsigned long *param, | 748 | extern int sata_link_debounce(struct ata_link *link, |
699 | unsigned long deadline); | 749 | const unsigned long *params, unsigned long deadline); |
700 | extern int sata_phy_resume(struct ata_port *ap, const unsigned long *param, | 750 | extern int sata_link_resume(struct ata_link *link, const unsigned long *params, |
701 | unsigned long deadline); | 751 | unsigned long deadline); |
702 | extern int ata_std_prereset(struct ata_port *ap, unsigned long deadline); | 752 | extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); |
703 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes, | 753 | extern int ata_std_softreset(struct ata_link *link, unsigned int *classes, |
704 | unsigned long deadline); | 754 | unsigned long deadline); |
705 | extern int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing, | 755 | extern int sata_link_hardreset(struct ata_link *link, |
706 | unsigned long deadline); | 756 | const unsigned long *timing, unsigned long deadline); |
707 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class, | 757 | extern int sata_std_hardreset(struct ata_link *link, unsigned int *class, |
708 | unsigned long deadline); | 758 | unsigned long deadline); |
709 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 759 | extern void ata_std_postreset(struct ata_link *link, unsigned int *classes); |
710 | extern void ata_port_disable(struct ata_port *); | 760 | extern void ata_port_disable(struct ata_port *); |
711 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 761 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
712 | #ifdef CONFIG_PCI | 762 | |
713 | extern int ata_pci_init_one (struct pci_dev *pdev, | ||
714 | const struct ata_port_info * const * ppi); | ||
715 | extern void ata_pci_remove_one (struct pci_dev *pdev); | ||
716 | #ifdef CONFIG_PM | ||
717 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
718 | extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); | ||
719 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
720 | extern int ata_pci_device_resume(struct pci_dev *pdev); | ||
721 | #endif | ||
722 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | ||
723 | #endif /* CONFIG_PCI */ | ||
724 | extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); | 763 | extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); |
725 | extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, | 764 | extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, |
726 | const struct ata_port_info * const * ppi, int n_ports); | 765 | const struct ata_port_info * const * ppi, int n_ports); |
@@ -746,12 +785,12 @@ extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); | |||
746 | extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), | 785 | extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), |
747 | struct ata_port *ap); | 786 | struct ata_port *ap); |
748 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 787 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
749 | extern int sata_scr_valid(struct ata_port *ap); | 788 | extern int sata_scr_valid(struct ata_link *link); |
750 | extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val); | 789 | extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); |
751 | extern int sata_scr_write(struct ata_port *ap, int reg, u32 val); | 790 | extern int sata_scr_write(struct ata_link *link, int reg, u32 val); |
752 | extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); | 791 | extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val); |
753 | extern int ata_port_online(struct ata_port *ap); | 792 | extern int ata_link_online(struct ata_link *link); |
754 | extern int ata_port_offline(struct ata_port *ap); | 793 | extern int ata_link_offline(struct ata_link *link); |
755 | #ifdef CONFIG_PM | 794 | #ifdef CONFIG_PM |
756 | extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); | 795 | extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); |
757 | extern void ata_host_resume(struct ata_host *host); | 796 | extern void ata_host_resume(struct ata_host *host); |
@@ -765,7 +804,8 @@ extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn, | |||
765 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | 804 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, |
766 | unsigned long interval_msec, | 805 | unsigned long interval_msec, |
767 | unsigned long timeout_msec); | 806 | unsigned long timeout_msec); |
768 | extern unsigned int ata_dev_try_classify(struct ata_port *, unsigned int, u8 *); | 807 | extern unsigned int ata_dev_try_classify(struct ata_device *dev, int present, |
808 | u8 *r_err); | ||
769 | 809 | ||
770 | /* | 810 | /* |
771 | * Default driver ops implementations | 811 | * Default driver ops implementations |
@@ -787,6 +827,7 @@ extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, | |||
787 | unsigned int buflen, int write_data); | 827 | unsigned int buflen, int write_data); |
788 | extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, | 828 | extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, |
789 | unsigned int buflen, int write_data); | 829 | unsigned int buflen, int write_data); |
830 | extern int ata_std_qc_defer(struct ata_queued_cmd *qc); | ||
790 | extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); | 831 | extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); |
791 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 832 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
792 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); | 833 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); |
@@ -830,11 +871,8 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev); | |||
830 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, | 871 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, |
831 | int queue_depth); | 872 | int queue_depth); |
832 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); | 873 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); |
833 | extern int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); | 874 | extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); |
834 | extern u8 ata_irq_on(struct ata_port *ap); | 875 | extern u8 ata_irq_on(struct ata_port *ap); |
835 | extern u8 ata_dummy_irq_on(struct ata_port *ap); | ||
836 | extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq); | ||
837 | extern u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq); | ||
838 | 876 | ||
839 | extern int ata_cable_40wire(struct ata_port *ap); | 877 | extern int ata_cable_40wire(struct ata_port *ap); |
840 | extern int ata_cable_80wire(struct ata_port *ap); | 878 | extern int ata_cable_80wire(struct ata_port *ap); |
@@ -869,8 +907,29 @@ enum { | |||
869 | ATA_TIMING_CYCLE | ATA_TIMING_UDMA, | 907 | ATA_TIMING_CYCLE | ATA_TIMING_UDMA, |
870 | }; | 908 | }; |
871 | 909 | ||
910 | /* libata-acpi.c */ | ||
911 | #ifdef CONFIG_ATA_ACPI | ||
912 | extern int ata_acpi_cbl_80wire(struct ata_port *ap); | ||
913 | int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm); | ||
914 | int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *stm); | ||
915 | #else | ||
916 | static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } | ||
917 | #endif | ||
872 | 918 | ||
873 | #ifdef CONFIG_PCI | 919 | #ifdef CONFIG_PCI |
920 | struct pci_dev; | ||
921 | |||
922 | extern int ata_pci_init_one (struct pci_dev *pdev, | ||
923 | const struct ata_port_info * const * ppi); | ||
924 | extern void ata_pci_remove_one (struct pci_dev *pdev); | ||
925 | #ifdef CONFIG_PM | ||
926 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
927 | extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); | ||
928 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
929 | extern int ata_pci_device_resume(struct pci_dev *pdev); | ||
930 | #endif | ||
931 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | ||
932 | |||
874 | struct pci_bits { | 933 | struct pci_bits { |
875 | unsigned int reg; /* PCI config register to read */ | 934 | unsigned int reg; /* PCI config register to read */ |
876 | unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */ | 935 | unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */ |
@@ -888,13 +947,29 @@ extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); | |||
888 | #endif /* CONFIG_PCI */ | 947 | #endif /* CONFIG_PCI */ |
889 | 948 | ||
890 | /* | 949 | /* |
950 | * PMP | ||
951 | */ | ||
952 | extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc); | ||
953 | extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline); | ||
954 | extern int sata_pmp_std_hardreset(struct ata_link *link, unsigned int *class, | ||
955 | unsigned long deadline); | ||
956 | extern void sata_pmp_std_postreset(struct ata_link *link, unsigned int *class); | ||
957 | extern void sata_pmp_do_eh(struct ata_port *ap, | ||
958 | ata_prereset_fn_t prereset, ata_reset_fn_t softreset, | ||
959 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset, | ||
960 | ata_prereset_fn_t pmp_prereset, ata_reset_fn_t pmp_softreset, | ||
961 | ata_reset_fn_t pmp_hardreset, ata_postreset_fn_t pmp_postreset); | ||
962 | |||
963 | /* | ||
891 | * EH | 964 | * EH |
892 | */ | 965 | */ |
893 | extern void ata_eng_timeout(struct ata_port *ap); | 966 | extern void ata_eng_timeout(struct ata_port *ap); |
894 | 967 | ||
895 | extern void ata_port_schedule_eh(struct ata_port *ap); | 968 | extern void ata_port_schedule_eh(struct ata_port *ap); |
969 | extern int ata_link_abort(struct ata_link *link); | ||
896 | extern int ata_port_abort(struct ata_port *ap); | 970 | extern int ata_port_abort(struct ata_port *ap); |
897 | extern int ata_port_freeze(struct ata_port *ap); | 971 | extern int ata_port_freeze(struct ata_port *ap); |
972 | extern int sata_async_notification(struct ata_port *ap); | ||
898 | 973 | ||
899 | extern void ata_eh_freeze_port(struct ata_port *ap); | 974 | extern void ata_eh_freeze_port(struct ata_port *ap); |
900 | extern void ata_eh_thaw_port(struct ata_port *ap); | 975 | extern void ata_eh_thaw_port(struct ata_port *ap); |
@@ -912,14 +987,25 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
912 | #define ata_port_printk(ap, lv, fmt, args...) \ | 987 | #define ata_port_printk(ap, lv, fmt, args...) \ |
913 | printk(lv"ata%u: "fmt, (ap)->print_id , ##args) | 988 | printk(lv"ata%u: "fmt, (ap)->print_id , ##args) |
914 | 989 | ||
990 | #define ata_link_printk(link, lv, fmt, args...) do { \ | ||
991 | if ((link)->ap->nr_pmp_links) \ | ||
992 | printk(lv"ata%u.%02u: "fmt, (link)->ap->print_id, \ | ||
993 | (link)->pmp , ##args); \ | ||
994 | else \ | ||
995 | printk(lv"ata%u: "fmt, (link)->ap->print_id , ##args); \ | ||
996 | } while(0) | ||
997 | |||
915 | #define ata_dev_printk(dev, lv, fmt, args...) \ | 998 | #define ata_dev_printk(dev, lv, fmt, args...) \ |
916 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->print_id, (dev)->devno , ##args) | 999 | printk(lv"ata%u.%02u: "fmt, (dev)->link->ap->print_id, \ |
1000 | (dev)->link->pmp + (dev)->devno , ##args) | ||
917 | 1001 | ||
918 | /* | 1002 | /* |
919 | * ata_eh_info helpers | 1003 | * ata_eh_info helpers |
920 | */ | 1004 | */ |
921 | extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...); | 1005 | extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) |
922 | extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...); | 1006 | __attribute__ ((format (printf, 2, 3))); |
1007 | extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) | ||
1008 | __attribute__ ((format (printf, 2, 3))); | ||
923 | extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); | 1009 | extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); |
924 | 1010 | ||
925 | static inline void ata_ehi_schedule_probe(struct ata_eh_info *ehi) | 1011 | static inline void ata_ehi_schedule_probe(struct ata_eh_info *ehi) |
@@ -933,10 +1019,21 @@ static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | |||
933 | { | 1019 | { |
934 | ata_ehi_schedule_probe(ehi); | 1020 | ata_ehi_schedule_probe(ehi); |
935 | ehi->flags |= ATA_EHI_HOTPLUGGED; | 1021 | ehi->flags |= ATA_EHI_HOTPLUGGED; |
1022 | ehi->action |= ATA_EH_ENABLE_LINK; | ||
936 | ehi->err_mask |= AC_ERR_ATA_BUS; | 1023 | ehi->err_mask |= AC_ERR_ATA_BUS; |
937 | } | 1024 | } |
938 | 1025 | ||
939 | /* | 1026 | /* |
1027 | * port description helpers | ||
1028 | */ | ||
1029 | extern void ata_port_desc(struct ata_port *ap, const char *fmt, ...) | ||
1030 | __attribute__ ((format (printf, 2, 3))); | ||
1031 | #ifdef CONFIG_PCI | ||
1032 | extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, | ||
1033 | const char *name); | ||
1034 | #endif | ||
1035 | |||
1036 | /* | ||
940 | * qc helpers | 1037 | * qc helpers |
941 | */ | 1038 | */ |
942 | static inline int | 1039 | static inline int |
@@ -991,12 +1088,14 @@ static inline unsigned int ata_tag_internal(unsigned int tag) | |||
991 | */ | 1088 | */ |
992 | static inline unsigned int ata_class_enabled(unsigned int class) | 1089 | static inline unsigned int ata_class_enabled(unsigned int class) |
993 | { | 1090 | { |
994 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 1091 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI || |
1092 | class == ATA_DEV_PMP || class == ATA_DEV_SEMB; | ||
995 | } | 1093 | } |
996 | 1094 | ||
997 | static inline unsigned int ata_class_disabled(unsigned int class) | 1095 | static inline unsigned int ata_class_disabled(unsigned int class) |
998 | { | 1096 | { |
999 | return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP; | 1097 | return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP || |
1098 | class == ATA_DEV_PMP_UNSUP || class == ATA_DEV_SEMB_UNSUP; | ||
1000 | } | 1099 | } |
1001 | 1100 | ||
1002 | static inline unsigned int ata_class_absent(unsigned int class) | 1101 | static inline unsigned int ata_class_absent(unsigned int class) |
@@ -1020,15 +1119,62 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev) | |||
1020 | } | 1119 | } |
1021 | 1120 | ||
1022 | /* | 1121 | /* |
1023 | * port helpers | 1122 | * link helpers |
1024 | */ | 1123 | */ |
1025 | static inline int ata_port_max_devices(const struct ata_port *ap) | 1124 | static inline int ata_is_host_link(const struct ata_link *link) |
1125 | { | ||
1126 | return link == &link->ap->link; | ||
1127 | } | ||
1128 | |||
1129 | static inline int ata_link_max_devices(const struct ata_link *link) | ||
1026 | { | 1130 | { |
1027 | if (ap->flags & ATA_FLAG_SLAVE_POSS) | 1131 | if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS) |
1028 | return 2; | 1132 | return 2; |
1029 | return 1; | 1133 | return 1; |
1030 | } | 1134 | } |
1031 | 1135 | ||
1136 | static inline int ata_link_active(struct ata_link *link) | ||
1137 | { | ||
1138 | return ata_tag_valid(link->active_tag) || link->sactive; | ||
1139 | } | ||
1140 | |||
1141 | static inline struct ata_link *ata_port_first_link(struct ata_port *ap) | ||
1142 | { | ||
1143 | if (ap->nr_pmp_links) | ||
1144 | return ap->pmp_link; | ||
1145 | return &ap->link; | ||
1146 | } | ||
1147 | |||
1148 | static inline struct ata_link *ata_port_next_link(struct ata_link *link) | ||
1149 | { | ||
1150 | struct ata_port *ap = link->ap; | ||
1151 | |||
1152 | if (link == &ap->link) { | ||
1153 | if (!ap->nr_pmp_links) | ||
1154 | return NULL; | ||
1155 | return ap->pmp_link; | ||
1156 | } | ||
1157 | |||
1158 | if (++link - ap->pmp_link < ap->nr_pmp_links) | ||
1159 | return link; | ||
1160 | return NULL; | ||
1161 | } | ||
1162 | |||
1163 | #define __ata_port_for_each_link(lk, ap) \ | ||
1164 | for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk)) | ||
1165 | |||
1166 | #define ata_port_for_each_link(link, ap) \ | ||
1167 | for ((link) = ata_port_first_link(ap); (link); \ | ||
1168 | (link) = ata_port_next_link(link)) | ||
1169 | |||
1170 | #define ata_link_for_each_dev(dev, link) \ | ||
1171 | for ((dev) = (link)->device; \ | ||
1172 | (dev) < (link)->device + ata_link_max_devices(link) || ((dev) = NULL); \ | ||
1173 | (dev)++) | ||
1174 | |||
1175 | #define ata_link_for_each_dev_reverse(dev, link) \ | ||
1176 | for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \ | ||
1177 | (dev) >= (link)->device || ((dev) = NULL); (dev)--) | ||
1032 | 1178 | ||
1033 | static inline u8 ata_chk_status(struct ata_port *ap) | 1179 | static inline u8 ata_chk_status(struct ata_port *ap) |
1034 | { | 1180 | { |
@@ -1110,9 +1256,11 @@ static inline u8 ata_wait_idle(struct ata_port *ap) | |||
1110 | { | 1256 | { |
1111 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 1257 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
1112 | 1258 | ||
1259 | #ifdef ATA_DEBUG | ||
1113 | if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) | 1260 | if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) |
1114 | DPRINTK("ATA: abnormal status 0x%X on port 0x%p\n", | 1261 | ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n", |
1115 | status, ap->ioaddr.status_addr); | 1262 | status); |
1263 | #endif | ||
1116 | 1264 | ||
1117 | return status; | 1265 | return status; |
1118 | } | 1266 | } |
@@ -1149,7 +1297,7 @@ static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) | |||
1149 | { | 1297 | { |
1150 | memset(tf, 0, sizeof(*tf)); | 1298 | memset(tf, 0, sizeof(*tf)); |
1151 | 1299 | ||
1152 | tf->ctl = dev->ap->ctl; | 1300 | tf->ctl = dev->link->ap->ctl; |
1153 | if (dev->devno == 0) | 1301 | if (dev->devno == 0) |
1154 | tf->device = ATA_DEVICE_OBS; | 1302 | tf->device = ATA_DEVICE_OBS; |
1155 | else | 1303 | else |