diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 17:15:06 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 17:15:06 -0400 |
| commit | 7591103c08abade60aeddb432ed0686ddd0de1c6 (patch) | |
| tree | 523343b43b0c420666da18c64e1e9f21ff63dea5 /include/linux | |
| parent | 2be4ff2f084842839b041b793ed6237e8d1d315a (diff) | |
| parent | 9c6102d446985bca9c426cb2d9b478ed21d2b024 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (66 commits)
ata: Add documentation for hard disk shock protection interface (v3)
ide: Implement disk shock protection support (v4)
ide-cd: fix printk format warning
piix: add Hercules EC-900 mini-notebook to ich_laptop short cable list
ide-atapi: assign taskfile flags per device type
ide-cd: move cdrom_info.dma to ide_drive_t.dma
ide: add ide_drive_t.dma flag
ide-cd: add a debug_mask module parameter
ide-cd: convert driver to new ide debugging macro (v3)
ide: move SFF DMA code to ide-dma-sff.c
ide: cleanup ide-dma.c
ide: cleanup ide_build_dmatable()
ide: remove needless includes from ide-dma.c
ide: switch to DMA-mapping API part #2
ide: make ide_dma_timeout() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n
ide: make ide_dma_lost_irq() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n
ide: __ide_dma_end() -> ide_dma_end()
pmac: remove needless pmac_ide_destroy_dmatable() wrapper
pmac: remove superfluous pmif == NULL checks
ide: Two fixes regarding memory allocation
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ide.h | 653 |
1 files changed, 361 insertions, 292 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index a9d82d6e6bdd..c47e371554c1 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
| @@ -48,12 +48,6 @@ typedef unsigned char byte; /* used everywhere */ | |||
| 48 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ | 48 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ |
| 49 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ | 49 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ |
| 50 | 50 | ||
| 51 | /* | ||
| 52 | * state flags | ||
| 53 | */ | ||
| 54 | |||
| 55 | #define DMA_PIO_RETRY 1 /* retrying in PIO */ | ||
| 56 | |||
| 57 | #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) | 51 | #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) |
| 58 | #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) | 52 | #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) |
| 59 | 53 | ||
| @@ -162,6 +156,8 @@ enum { | |||
| 162 | */ | 156 | */ |
| 163 | #define REQ_DRIVE_RESET 0x20 | 157 | #define REQ_DRIVE_RESET 0x20 |
| 164 | #define REQ_DEVSET_EXEC 0x21 | 158 | #define REQ_DEVSET_EXEC 0x21 |
| 159 | #define REQ_PARK_HEADS 0x22 | ||
| 160 | #define REQ_UNPARK_HEADS 0x23 | ||
| 165 | 161 | ||
| 166 | /* | 162 | /* |
| 167 | * Check for an interrupt and acknowledge the interrupt status | 163 | * Check for an interrupt and acknowledge the interrupt status |
| @@ -268,8 +264,6 @@ static inline int __ide_default_irq(unsigned long base) | |||
| 268 | * set_geometry : respecify drive geometry | 264 | * set_geometry : respecify drive geometry |
| 269 | * recalibrate : seek to cyl 0 | 265 | * recalibrate : seek to cyl 0 |
| 270 | * set_multmode : set multmode count | 266 | * set_multmode : set multmode count |
| 271 | * set_tune : tune interface for drive | ||
| 272 | * serviced : service command | ||
| 273 | * reserved : unused | 267 | * reserved : unused |
| 274 | */ | 268 | */ |
| 275 | typedef union { | 269 | typedef union { |
| @@ -278,43 +272,11 @@ typedef union { | |||
| 278 | unsigned set_geometry : 1; | 272 | unsigned set_geometry : 1; |
| 279 | unsigned recalibrate : 1; | 273 | unsigned recalibrate : 1; |
| 280 | unsigned set_multmode : 1; | 274 | unsigned set_multmode : 1; |
| 281 | unsigned set_tune : 1; | 275 | unsigned reserved : 5; |
| 282 | unsigned serviced : 1; | ||
| 283 | unsigned reserved : 3; | ||
| 284 | } b; | 276 | } b; |
| 285 | } special_t; | 277 | } special_t; |
| 286 | 278 | ||
| 287 | /* | 279 | /* |
| 288 | * ATA-IDE Select Register, aka Device-Head | ||
| 289 | * | ||
| 290 | * head : always zeros here | ||
| 291 | * unit : drive select number: 0/1 | ||
| 292 | * bit5 : always 1 | ||
| 293 | * lba : using LBA instead of CHS | ||
| 294 | * bit7 : always 1 | ||
| 295 | */ | ||
| 296 | typedef union { | ||
| 297 | unsigned all : 8; | ||
| 298 | struct { | ||
| 299 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 300 | unsigned head : 4; | ||
| 301 | unsigned unit : 1; | ||
| 302 | unsigned bit5 : 1; | ||
| 303 | unsigned lba : 1; | ||
| 304 | unsigned bit7 : 1; | ||
| 305 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 306 | unsigned bit7 : 1; | ||
| 307 | unsigned lba : 1; | ||
| 308 | unsigned bit5 : 1; | ||
| 309 | unsigned unit : 1; | ||
| 310 | unsigned head : 4; | ||
| 311 | #else | ||
| 312 | #error "Please fix <asm/byteorder.h>" | ||
| 313 | #endif | ||
| 314 | } b; | ||
| 315 | } select_t, ata_select_t; | ||
| 316 | |||
| 317 | /* | ||
| 318 | * Status returned from various ide_ functions | 280 | * Status returned from various ide_ functions |
| 319 | */ | 281 | */ |
| 320 | typedef enum { | 282 | typedef enum { |
| @@ -322,6 +284,175 @@ typedef enum { | |||
| 322 | ide_started, /* a drive operation was started, handler was set */ | 284 | ide_started, /* a drive operation was started, handler was set */ |
| 323 | } ide_startstop_t; | 285 | } ide_startstop_t; |
| 324 | 286 | ||
| 287 | enum { | ||
| 288 | IDE_TFLAG_LBA48 = (1 << 0), | ||
| 289 | IDE_TFLAG_FLAGGED = (1 << 2), | ||
| 290 | IDE_TFLAG_OUT_DATA = (1 << 3), | ||
| 291 | IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), | ||
| 292 | IDE_TFLAG_OUT_HOB_NSECT = (1 << 5), | ||
| 293 | IDE_TFLAG_OUT_HOB_LBAL = (1 << 6), | ||
| 294 | IDE_TFLAG_OUT_HOB_LBAM = (1 << 7), | ||
| 295 | IDE_TFLAG_OUT_HOB_LBAH = (1 << 8), | ||
| 296 | IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE | | ||
| 297 | IDE_TFLAG_OUT_HOB_NSECT | | ||
| 298 | IDE_TFLAG_OUT_HOB_LBAL | | ||
| 299 | IDE_TFLAG_OUT_HOB_LBAM | | ||
| 300 | IDE_TFLAG_OUT_HOB_LBAH, | ||
| 301 | IDE_TFLAG_OUT_FEATURE = (1 << 9), | ||
| 302 | IDE_TFLAG_OUT_NSECT = (1 << 10), | ||
| 303 | IDE_TFLAG_OUT_LBAL = (1 << 11), | ||
| 304 | IDE_TFLAG_OUT_LBAM = (1 << 12), | ||
| 305 | IDE_TFLAG_OUT_LBAH = (1 << 13), | ||
| 306 | IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE | | ||
| 307 | IDE_TFLAG_OUT_NSECT | | ||
| 308 | IDE_TFLAG_OUT_LBAL | | ||
| 309 | IDE_TFLAG_OUT_LBAM | | ||
| 310 | IDE_TFLAG_OUT_LBAH, | ||
| 311 | IDE_TFLAG_OUT_DEVICE = (1 << 14), | ||
| 312 | IDE_TFLAG_WRITE = (1 << 15), | ||
| 313 | IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), | ||
| 314 | IDE_TFLAG_IN_DATA = (1 << 17), | ||
| 315 | IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), | ||
| 316 | IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), | ||
| 317 | IDE_TFLAG_IN_HOB_FEATURE = (1 << 20), | ||
| 318 | IDE_TFLAG_IN_HOB_NSECT = (1 << 21), | ||
| 319 | IDE_TFLAG_IN_HOB_LBAL = (1 << 22), | ||
| 320 | IDE_TFLAG_IN_HOB_LBAM = (1 << 23), | ||
| 321 | IDE_TFLAG_IN_HOB_LBAH = (1 << 24), | ||
| 322 | IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL | | ||
| 323 | IDE_TFLAG_IN_HOB_LBAM | | ||
| 324 | IDE_TFLAG_IN_HOB_LBAH, | ||
| 325 | IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | | ||
| 326 | IDE_TFLAG_IN_HOB_NSECT | | ||
| 327 | IDE_TFLAG_IN_HOB_LBA, | ||
| 328 | IDE_TFLAG_IN_FEATURE = (1 << 1), | ||
| 329 | IDE_TFLAG_IN_NSECT = (1 << 25), | ||
| 330 | IDE_TFLAG_IN_LBAL = (1 << 26), | ||
| 331 | IDE_TFLAG_IN_LBAM = (1 << 27), | ||
| 332 | IDE_TFLAG_IN_LBAH = (1 << 28), | ||
| 333 | IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL | | ||
| 334 | IDE_TFLAG_IN_LBAM | | ||
| 335 | IDE_TFLAG_IN_LBAH, | ||
| 336 | IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT | | ||
| 337 | IDE_TFLAG_IN_LBA, | ||
| 338 | IDE_TFLAG_IN_DEVICE = (1 << 29), | ||
| 339 | IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB | | ||
| 340 | IDE_TFLAG_IN_HOB, | ||
| 341 | IDE_TFLAG_TF = IDE_TFLAG_OUT_TF | | ||
| 342 | IDE_TFLAG_IN_TF, | ||
| 343 | IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE | | ||
| 344 | IDE_TFLAG_IN_DEVICE, | ||
| 345 | /* force 16-bit I/O operations */ | ||
| 346 | IDE_TFLAG_IO_16BIT = (1 << 30), | ||
| 347 | /* ide_task_t was allocated using kmalloc() */ | ||
| 348 | IDE_TFLAG_DYN = (1 << 31), | ||
| 349 | }; | ||
| 350 | |||
| 351 | struct ide_taskfile { | ||
| 352 | u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ | ||
| 353 | |||
| 354 | u8 hob_feature; /* 1-5: additional data to support LBA48 */ | ||
| 355 | u8 hob_nsect; | ||
| 356 | u8 hob_lbal; | ||
| 357 | u8 hob_lbam; | ||
| 358 | u8 hob_lbah; | ||
| 359 | |||
| 360 | u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ | ||
| 361 | |||
| 362 | union { /* 7: */ | ||
| 363 | u8 error; /* read: error */ | ||
| 364 | u8 feature; /* write: feature */ | ||
| 365 | }; | ||
| 366 | |||
| 367 | u8 nsect; /* 8: number of sectors */ | ||
| 368 | u8 lbal; /* 9: LBA low */ | ||
| 369 | u8 lbam; /* 10: LBA mid */ | ||
| 370 | u8 lbah; /* 11: LBA high */ | ||
| 371 | |||
| 372 | u8 device; /* 12: device select */ | ||
| 373 | |||
| 374 | union { /* 13: */ | ||
| 375 | u8 status; /* read: status */ | ||
| 376 | u8 command; /* write: command */ | ||
| 377 | }; | ||
| 378 | }; | ||
| 379 | |||
| 380 | typedef struct ide_task_s { | ||
| 381 | union { | ||
| 382 | struct ide_taskfile tf; | ||
| 383 | u8 tf_array[14]; | ||
| 384 | }; | ||
| 385 | u32 tf_flags; | ||
| 386 | int data_phase; | ||
| 387 | struct request *rq; /* copy of request */ | ||
| 388 | void *special; /* valid_t generally */ | ||
| 389 | } ide_task_t; | ||
| 390 | |||
| 391 | /* ATAPI packet command flags */ | ||
| 392 | enum { | ||
| 393 | /* set when an error is considered normal - no retry (ide-tape) */ | ||
| 394 | PC_FLAG_ABORT = (1 << 0), | ||
| 395 | PC_FLAG_SUPPRESS_ERROR = (1 << 1), | ||
| 396 | PC_FLAG_WAIT_FOR_DSC = (1 << 2), | ||
| 397 | PC_FLAG_DMA_OK = (1 << 3), | ||
| 398 | PC_FLAG_DMA_IN_PROGRESS = (1 << 4), | ||
| 399 | PC_FLAG_DMA_ERROR = (1 << 5), | ||
| 400 | PC_FLAG_WRITING = (1 << 6), | ||
| 401 | /* command timed out */ | ||
| 402 | PC_FLAG_TIMEDOUT = (1 << 7), | ||
| 403 | }; | ||
| 404 | |||
| 405 | /* | ||
| 406 | * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. | ||
| 407 | * This is used for several packet commands (not for READ/WRITE commands). | ||
| 408 | */ | ||
| 409 | #define IDE_PC_BUFFER_SIZE 256 | ||
| 410 | |||
| 411 | struct ide_atapi_pc { | ||
| 412 | /* actual packet bytes */ | ||
| 413 | u8 c[12]; | ||
| 414 | /* incremented on each retry */ | ||
| 415 | int retries; | ||
| 416 | int error; | ||
| 417 | |||
| 418 | /* bytes to transfer */ | ||
| 419 | int req_xfer; | ||
| 420 | /* bytes actually transferred */ | ||
| 421 | int xferred; | ||
| 422 | |||
| 423 | /* data buffer */ | ||
| 424 | u8 *buf; | ||
| 425 | /* current buffer position */ | ||
| 426 | u8 *cur_pos; | ||
| 427 | int buf_size; | ||
| 428 | /* missing/available data on the current buffer */ | ||
| 429 | int b_count; | ||
| 430 | |||
| 431 | /* the corresponding request */ | ||
| 432 | struct request *rq; | ||
| 433 | |||
| 434 | unsigned long flags; | ||
| 435 | |||
| 436 | /* | ||
| 437 | * those are more or less driver-specific and some of them are subject | ||
| 438 | * to change/removal later. | ||
| 439 | */ | ||
| 440 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; | ||
| 441 | |||
| 442 | /* idetape only */ | ||
| 443 | struct idetape_bh *bh; | ||
| 444 | char *b_data; | ||
| 445 | |||
| 446 | /* idescsi only for now */ | ||
| 447 | struct scatterlist *sg; | ||
| 448 | unsigned int sg_cnt; | ||
| 449 | |||
| 450 | struct scsi_cmnd *scsi_cmd; | ||
| 451 | void (*done) (struct scsi_cmnd *); | ||
| 452 | |||
| 453 | unsigned long timeout; | ||
| 454 | }; | ||
| 455 | |||
| 325 | struct ide_devset; | 456 | struct ide_devset; |
| 326 | struct ide_driver_s; | 457 | struct ide_driver_s; |
| 327 | 458 | ||
| @@ -394,6 +525,62 @@ enum { | |||
| 394 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), | 525 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), |
| 395 | }; | 526 | }; |
| 396 | 527 | ||
| 528 | /* device flags */ | ||
| 529 | enum { | ||
| 530 | /* restore settings after device reset */ | ||
| 531 | IDE_DFLAG_KEEP_SETTINGS = (1 << 0), | ||
| 532 | /* device is using DMA for read/write */ | ||
| 533 | IDE_DFLAG_USING_DMA = (1 << 1), | ||
| 534 | /* okay to unmask other IRQs */ | ||
| 535 | IDE_DFLAG_UNMASK = (1 << 2), | ||
| 536 | /* don't attempt flushes */ | ||
| 537 | IDE_DFLAG_NOFLUSH = (1 << 3), | ||
| 538 | /* DSC overlap */ | ||
| 539 | IDE_DFLAG_DSC_OVERLAP = (1 << 4), | ||
| 540 | /* give potential excess bandwidth */ | ||
| 541 | IDE_DFLAG_NICE1 = (1 << 5), | ||
| 542 | /* device is physically present */ | ||
| 543 | IDE_DFLAG_PRESENT = (1 << 6), | ||
| 544 | /* device ejected hint */ | ||
| 545 | IDE_DFLAG_DEAD = (1 << 7), | ||
| 546 | /* id read from device (synthetic if not set) */ | ||
| 547 | IDE_DFLAG_ID_READ = (1 << 8), | ||
| 548 | IDE_DFLAG_NOPROBE = (1 << 9), | ||
| 549 | /* need to do check_media_change() */ | ||
| 550 | IDE_DFLAG_REMOVABLE = (1 << 10), | ||
| 551 | /* needed for removable devices */ | ||
| 552 | IDE_DFLAG_ATTACH = (1 << 11), | ||
| 553 | IDE_DFLAG_FORCED_GEOM = (1 << 12), | ||
| 554 | /* disallow setting unmask bit */ | ||
| 555 | IDE_DFLAG_NO_UNMASK = (1 << 13), | ||
| 556 | /* disallow enabling 32-bit I/O */ | ||
| 557 | IDE_DFLAG_NO_IO_32BIT = (1 << 14), | ||
| 558 | /* for removable only: door lock/unlock works */ | ||
| 559 | IDE_DFLAG_DOORLOCKING = (1 << 15), | ||
| 560 | /* disallow DMA */ | ||
| 561 | IDE_DFLAG_NODMA = (1 << 16), | ||
| 562 | /* powermanagment told us not to do anything, so sleep nicely */ | ||
| 563 | IDE_DFLAG_BLOCKED = (1 << 17), | ||
| 564 | /* ide-scsi emulation */ | ||
| 565 | IDE_DFLAG_SCSI = (1 << 18), | ||
| 566 | /* sleeping & sleep field valid */ | ||
| 567 | IDE_DFLAG_SLEEPING = (1 << 19), | ||
| 568 | IDE_DFLAG_POST_RESET = (1 << 20), | ||
| 569 | IDE_DFLAG_UDMA33_WARNED = (1 << 21), | ||
| 570 | IDE_DFLAG_LBA48 = (1 << 22), | ||
| 571 | /* status of write cache */ | ||
| 572 | IDE_DFLAG_WCACHE = (1 << 23), | ||
| 573 | /* used for ignoring ATA_DF */ | ||
| 574 | IDE_DFLAG_NOWERR = (1 << 24), | ||
| 575 | /* retrying in PIO */ | ||
| 576 | IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), | ||
| 577 | IDE_DFLAG_LBA = (1 << 26), | ||
| 578 | /* don't unload heads */ | ||
| 579 | IDE_DFLAG_NO_UNLOAD = (1 << 27), | ||
| 580 | /* heads unloaded, please don't reset port */ | ||
| 581 | IDE_DFLAG_PARKED = (1 << 28) | ||
| 582 | }; | ||
| 583 | |||
| 397 | struct ide_drive_s { | 584 | struct ide_drive_s { |
| 398 | char name[4]; /* drive name, such as "hda" */ | 585 | char name[4]; /* drive name, such as "hda" */ |
| 399 | char driver_req[10]; /* requests specific driver */ | 586 | char driver_req[10]; /* requests specific driver */ |
| @@ -410,43 +597,19 @@ struct ide_drive_s { | |||
| 410 | #endif | 597 | #endif |
| 411 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ | 598 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ |
| 412 | 599 | ||
| 600 | unsigned long dev_flags; | ||
| 601 | |||
| 413 | unsigned long sleep; /* sleep until this time */ | 602 | unsigned long sleep; /* sleep until this time */ |
| 414 | unsigned long service_start; /* time we started last request */ | 603 | unsigned long service_start; /* time we started last request */ |
| 415 | unsigned long service_time; /* service time of last request */ | 604 | unsigned long service_time; /* service time of last request */ |
| 416 | unsigned long timeout; /* max time to wait for irq */ | 605 | unsigned long timeout; /* max time to wait for irq */ |
| 417 | 606 | ||
| 418 | special_t special; /* special action flags */ | 607 | special_t special; /* special action flags */ |
| 419 | select_t select; /* basic drive/head select reg value */ | ||
| 420 | 608 | ||
| 609 | u8 select; /* basic drive/head select reg value */ | ||
| 421 | u8 retry_pio; /* retrying dma capable host in pio */ | 610 | u8 retry_pio; /* retrying dma capable host in pio */ |
| 422 | u8 state; /* retry state */ | ||
| 423 | u8 waiting_for_dma; /* dma currently in progress */ | 611 | u8 waiting_for_dma; /* dma currently in progress */ |
| 424 | 612 | u8 dma; /* atapi dma flag */ | |
| 425 | unsigned keep_settings : 1; /* restore settings after drive reset */ | ||
| 426 | unsigned using_dma : 1; /* disk is using dma for read/write */ | ||
| 427 | unsigned unmask : 1; /* okay to unmask other irqs */ | ||
| 428 | unsigned noflush : 1; /* don't attempt flushes */ | ||
| 429 | unsigned dsc_overlap : 1; /* DSC overlap */ | ||
| 430 | unsigned nice1 : 1; /* give potential excess bandwidth */ | ||
| 431 | unsigned present : 1; /* drive is physically present */ | ||
| 432 | unsigned dead : 1; /* device ejected hint */ | ||
| 433 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ | ||
| 434 | unsigned noprobe : 1; /* from: hdx=noprobe */ | ||
| 435 | unsigned removable : 1; /* 1 if need to do check_media_change */ | ||
| 436 | unsigned attach : 1; /* needed for removable devices */ | ||
| 437 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ | ||
| 438 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | ||
| 439 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | ||
| 440 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | ||
| 441 | unsigned nodma : 1; /* disallow DMA */ | ||
| 442 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ | ||
| 443 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ | ||
| 444 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ | ||
| 445 | unsigned post_reset : 1; | ||
| 446 | unsigned udma33_warned : 1; | ||
| 447 | unsigned addressing : 2; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
| 448 | unsigned wcache : 1; /* status of write cache */ | ||
| 449 | unsigned nowerr : 1; /* used for ignoring ATA_DF */ | ||
| 450 | 613 | ||
| 451 | u8 quirk_list; /* considered quirky, set for a specific host */ | 614 | u8 quirk_list; /* considered quirky, set for a specific host */ |
| 452 | u8 init_speed; /* transfer rate set at boot */ | 615 | u8 init_speed; /* transfer rate set at boot */ |
| @@ -458,7 +621,6 @@ struct ide_drive_s { | |||
| 458 | u8 ready_stat; /* min status value for drive ready */ | 621 | u8 ready_stat; /* min status value for drive ready */ |
| 459 | u8 mult_count; /* current multiple sector setting */ | 622 | u8 mult_count; /* current multiple sector setting */ |
| 460 | u8 mult_req; /* requested multiple sector setting */ | 623 | u8 mult_req; /* requested multiple sector setting */ |
| 461 | u8 tune_req; /* requested drive tuning setting */ | ||
| 462 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ | 624 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ |
| 463 | u8 bad_wstat; /* used for ignoring ATA_DF */ | 625 | u8 bad_wstat; /* used for ignoring ATA_DF */ |
| 464 | u8 head; /* "real" number of heads */ | 626 | u8 head; /* "real" number of heads */ |
| @@ -466,6 +628,9 @@ struct ide_drive_s { | |||
| 466 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ | 628 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ |
| 467 | u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ | 629 | u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ |
| 468 | 630 | ||
| 631 | /* delay this long before sending packet command */ | ||
| 632 | u8 pc_delay; | ||
| 633 | |||
| 469 | unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ | 634 | unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ |
| 470 | unsigned int cyl; /* "real" number of cyls */ | 635 | unsigned int cyl; /* "real" number of cyls */ |
| 471 | unsigned int drive_data; /* used by set_pio_mode/selectproc */ | 636 | unsigned int drive_data; /* used by set_pio_mode/selectproc */ |
| @@ -477,6 +642,9 @@ struct ide_drive_s { | |||
| 477 | 642 | ||
| 478 | int lun; /* logical unit */ | 643 | int lun; /* logical unit */ |
| 479 | int crc_count; /* crc counter to reduce drive speed */ | 644 | int crc_count; /* crc counter to reduce drive speed */ |
| 645 | |||
| 646 | unsigned long debug_mask; /* debugging levels switch */ | ||
| 647 | |||
| 480 | #ifdef CONFIG_BLK_DEV_IDEACPI | 648 | #ifdef CONFIG_BLK_DEV_IDEACPI |
| 481 | struct ide_acpi_drive_link *acpidata; | 649 | struct ide_acpi_drive_link *acpidata; |
| 482 | #endif | 650 | #endif |
| @@ -484,17 +652,32 @@ struct ide_drive_s { | |||
| 484 | struct device gendev; | 652 | struct device gendev; |
| 485 | struct completion gendev_rel_comp; /* to deal with device release() */ | 653 | struct completion gendev_rel_comp; /* to deal with device release() */ |
| 486 | 654 | ||
| 655 | /* current packet command */ | ||
| 656 | struct ide_atapi_pc *pc; | ||
| 657 | |||
| 487 | /* callback for packet commands */ | 658 | /* callback for packet commands */ |
| 488 | void (*pc_callback)(struct ide_drive_s *); | 659 | void (*pc_callback)(struct ide_drive_s *, int); |
| 660 | |||
| 661 | void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *); | ||
| 662 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, | ||
| 663 | unsigned int, int); | ||
| 489 | 664 | ||
| 490 | unsigned long atapi_flags; | 665 | unsigned long atapi_flags; |
| 666 | |||
| 667 | struct ide_atapi_pc request_sense_pc; | ||
| 668 | struct request request_sense_rq; | ||
| 491 | }; | 669 | }; |
| 492 | 670 | ||
| 493 | typedef struct ide_drive_s ide_drive_t; | 671 | typedef struct ide_drive_s ide_drive_t; |
| 494 | 672 | ||
| 495 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) | 673 | #define to_ide_device(dev) container_of(dev, ide_drive_t, gendev) |
| 674 | |||
| 675 | #define to_ide_drv(obj, cont_type) \ | ||
| 676 | container_of(obj, struct cont_type, kref) | ||
| 677 | |||
| 678 | #define ide_drv_g(disk, cont_type) \ | ||
| 679 | container_of((disk)->private_data, struct cont_type, driver) | ||
| 496 | 680 | ||
| 497 | struct ide_task_s; | ||
| 498 | struct ide_port_info; | 681 | struct ide_port_info; |
| 499 | 682 | ||
| 500 | struct ide_tp_ops { | 683 | struct ide_tp_ops { |
| @@ -528,6 +711,7 @@ extern const struct ide_tp_ops default_tp_ops; | |||
| 528 | * @resetproc: routine to reset controller after a disk reset | 711 | * @resetproc: routine to reset controller after a disk reset |
| 529 | * @maskproc: special host masking for drive selection | 712 | * @maskproc: special host masking for drive selection |
| 530 | * @quirkproc: check host's drive quirk list | 713 | * @quirkproc: check host's drive quirk list |
| 714 | * @clear_irq: clear IRQ | ||
| 531 | * | 715 | * |
| 532 | * @mdma_filter: filter MDMA modes | 716 | * @mdma_filter: filter MDMA modes |
| 533 | * @udma_filter: filter UDMA modes | 717 | * @udma_filter: filter UDMA modes |
| @@ -544,6 +728,7 @@ struct ide_port_ops { | |||
| 544 | void (*resetproc)(ide_drive_t *); | 728 | void (*resetproc)(ide_drive_t *); |
| 545 | void (*maskproc)(ide_drive_t *, int); | 729 | void (*maskproc)(ide_drive_t *, int); |
| 546 | void (*quirkproc)(ide_drive_t *); | 730 | void (*quirkproc)(ide_drive_t *); |
| 731 | void (*clear_irq)(ide_drive_t *); | ||
| 547 | 732 | ||
| 548 | u8 (*mdma_filter)(ide_drive_t *); | 733 | u8 (*mdma_filter)(ide_drive_t *); |
| 549 | u8 (*udma_filter)(ide_drive_t *); | 734 | u8 (*udma_filter)(ide_drive_t *); |
| @@ -606,12 +791,16 @@ typedef struct hwif_s { | |||
| 606 | const struct ide_port_ops *port_ops; | 791 | const struct ide_port_ops *port_ops; |
| 607 | const struct ide_dma_ops *dma_ops; | 792 | const struct ide_dma_ops *dma_ops; |
| 608 | 793 | ||
| 609 | void (*ide_dma_clear_irq)(ide_drive_t *drive); | ||
| 610 | |||
| 611 | /* dma physical region descriptor table (cpu view) */ | 794 | /* dma physical region descriptor table (cpu view) */ |
| 612 | unsigned int *dmatable_cpu; | 795 | unsigned int *dmatable_cpu; |
| 613 | /* dma physical region descriptor table (dma view) */ | 796 | /* dma physical region descriptor table (dma view) */ |
| 614 | dma_addr_t dmatable_dma; | 797 | dma_addr_t dmatable_dma; |
| 798 | |||
| 799 | /* maximum number of PRD table entries */ | ||
| 800 | int prd_max_nents; | ||
| 801 | /* PRD entry size in bytes */ | ||
| 802 | int prd_ent_size; | ||
| 803 | |||
| 615 | /* Scatter-gather list used to build the above */ | 804 | /* Scatter-gather list used to build the above */ |
| 616 | struct scatterlist *sg_table; | 805 | struct scatterlist *sg_table; |
| 617 | int sg_max_nents; /* Maximum number of entries in it */ | 806 | int sg_max_nents; /* Maximum number of entries in it */ |
| @@ -621,6 +810,8 @@ typedef struct hwif_s { | |||
| 621 | /* data phase of the active command (currently only valid for PIO/DMA) */ | 810 | /* data phase of the active command (currently only valid for PIO/DMA) */ |
| 622 | int data_phase; | 811 | int data_phase; |
| 623 | 812 | ||
| 813 | struct ide_task_s task; /* current command */ | ||
| 814 | |||
| 624 | unsigned int nsect; | 815 | unsigned int nsect; |
| 625 | unsigned int nleft; | 816 | unsigned int nleft; |
| 626 | struct scatterlist *cursg; | 817 | struct scatterlist *cursg; |
| @@ -649,15 +840,15 @@ typedef struct hwif_s { | |||
| 649 | 840 | ||
| 650 | void *hwif_data; /* extra hwif data */ | 841 | void *hwif_data; /* extra hwif data */ |
| 651 | 842 | ||
| 652 | unsigned dma; | ||
| 653 | |||
| 654 | #ifdef CONFIG_BLK_DEV_IDEACPI | 843 | #ifdef CONFIG_BLK_DEV_IDEACPI |
| 655 | struct ide_acpi_hwif_link *acpidata; | 844 | struct ide_acpi_hwif_link *acpidata; |
| 656 | #endif | 845 | #endif |
| 657 | } ____cacheline_internodealigned_in_smp ide_hwif_t; | 846 | } ____cacheline_internodealigned_in_smp ide_hwif_t; |
| 658 | 847 | ||
| 848 | #define MAX_HOST_PORTS 4 | ||
| 849 | |||
| 659 | struct ide_host { | 850 | struct ide_host { |
| 660 | ide_hwif_t *ports[MAX_HWIFS]; | 851 | ide_hwif_t *ports[MAX_HOST_PORTS]; |
| 661 | unsigned int n_ports; | 852 | unsigned int n_ports; |
| 662 | struct device *dev[2]; | 853 | struct device *dev[2]; |
| 663 | unsigned int (*init_chipset)(struct pci_dev *); | 854 | unsigned int (*init_chipset)(struct pci_dev *); |
| @@ -739,6 +930,22 @@ static int set_##name(ide_drive_t *drive, int arg) \ | |||
| 739 | return 0; \ | 930 | return 0; \ |
| 740 | } | 931 | } |
| 741 | 932 | ||
| 933 | #define ide_devset_get_flag(name, flag) \ | ||
| 934 | static int get_##name(ide_drive_t *drive) \ | ||
| 935 | { \ | ||
| 936 | return !!(drive->dev_flags & flag); \ | ||
| 937 | } | ||
| 938 | |||
| 939 | #define ide_devset_set_flag(name, flag) \ | ||
| 940 | static int set_##name(ide_drive_t *drive, int arg) \ | ||
| 941 | { \ | ||
| 942 | if (arg) \ | ||
| 943 | drive->dev_flags |= flag; \ | ||
| 944 | else \ | ||
| 945 | drive->dev_flags &= ~flag; \ | ||
| 946 | return 0; \ | ||
| 947 | } | ||
| 948 | |||
| 742 | #define __IDE_DEVSET(_name, _flags, _get, _set) \ | 949 | #define __IDE_DEVSET(_name, _flags, _get, _set) \ |
| 743 | const struct ide_devset ide_devset_##_name = \ | 950 | const struct ide_devset ide_devset_##_name = \ |
| 744 | __DEVSET(_flags, _get, _set) | 951 | __DEVSET(_flags, _get, _set) |
| @@ -752,8 +959,11 @@ IDE_DEVSET(_name, 0, get_##_func, set_##_func) | |||
| 752 | #define ide_devset_w(_name, _func) \ | 959 | #define ide_devset_w(_name, _func) \ |
| 753 | IDE_DEVSET(_name, 0, NULL, set_##_func) | 960 | IDE_DEVSET(_name, 0, NULL, set_##_func) |
| 754 | 961 | ||
| 755 | #define ide_devset_rw_sync(_name, _func) \ | 962 | #define ide_ext_devset_rw(_name, _func) \ |
| 756 | IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | 963 | __IDE_DEVSET(_name, 0, get_##_func, set_##_func) |
| 964 | |||
| 965 | #define ide_ext_devset_rw_sync(_name, _func) \ | ||
| 966 | __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | ||
| 757 | 967 | ||
| 758 | #define ide_decl_devset(_name) \ | 968 | #define ide_decl_devset(_name) \ |
| 759 | extern const struct ide_devset ide_devset_##_name | 969 | extern const struct ide_devset ide_devset_##_name |
| @@ -764,71 +974,6 @@ ide_decl_devset(pio_mode); | |||
| 764 | ide_decl_devset(unmaskirq); | 974 | ide_decl_devset(unmaskirq); |
| 765 | ide_decl_devset(using_dma); | 975 | ide_decl_devset(using_dma); |
| 766 | 976 | ||
| 767 | /* ATAPI packet command flags */ | ||
| 768 | enum { | ||
| 769 | /* set when an error is considered normal - no retry (ide-tape) */ | ||
| 770 | PC_FLAG_ABORT = (1 << 0), | ||
| 771 | PC_FLAG_SUPPRESS_ERROR = (1 << 1), | ||
| 772 | PC_FLAG_WAIT_FOR_DSC = (1 << 2), | ||
| 773 | PC_FLAG_DMA_OK = (1 << 3), | ||
| 774 | PC_FLAG_DMA_IN_PROGRESS = (1 << 4), | ||
| 775 | PC_FLAG_DMA_ERROR = (1 << 5), | ||
| 776 | PC_FLAG_WRITING = (1 << 6), | ||
| 777 | /* command timed out */ | ||
| 778 | PC_FLAG_TIMEDOUT = (1 << 7), | ||
| 779 | }; | ||
| 780 | |||
| 781 | /* | ||
| 782 | * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. | ||
| 783 | * This is used for several packet commands (not for READ/WRITE commands). | ||
| 784 | */ | ||
| 785 | #define IDE_PC_BUFFER_SIZE 256 | ||
| 786 | |||
| 787 | struct ide_atapi_pc { | ||
| 788 | /* actual packet bytes */ | ||
| 789 | u8 c[12]; | ||
| 790 | /* incremented on each retry */ | ||
| 791 | int retries; | ||
| 792 | int error; | ||
| 793 | |||
| 794 | /* bytes to transfer */ | ||
| 795 | int req_xfer; | ||
| 796 | /* bytes actually transferred */ | ||
| 797 | int xferred; | ||
| 798 | |||
| 799 | /* data buffer */ | ||
| 800 | u8 *buf; | ||
| 801 | /* current buffer position */ | ||
| 802 | u8 *cur_pos; | ||
| 803 | int buf_size; | ||
| 804 | /* missing/available data on the current buffer */ | ||
| 805 | int b_count; | ||
| 806 | |||
| 807 | /* the corresponding request */ | ||
| 808 | struct request *rq; | ||
| 809 | |||
| 810 | unsigned long flags; | ||
| 811 | |||
| 812 | /* | ||
| 813 | * those are more or less driver-specific and some of them are subject | ||
| 814 | * to change/removal later. | ||
| 815 | */ | ||
| 816 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; | ||
| 817 | |||
| 818 | /* idetape only */ | ||
| 819 | struct idetape_bh *bh; | ||
| 820 | char *b_data; | ||
| 821 | |||
| 822 | /* idescsi only for now */ | ||
| 823 | struct scatterlist *sg; | ||
| 824 | unsigned int sg_cnt; | ||
| 825 | |||
| 826 | struct scsi_cmnd *scsi_cmd; | ||
| 827 | void (*done) (struct scsi_cmnd *); | ||
| 828 | |||
| 829 | unsigned long timeout; | ||
| 830 | }; | ||
| 831 | |||
| 832 | #ifdef CONFIG_IDE_PROC_FS | 977 | #ifdef CONFIG_IDE_PROC_FS |
| 833 | /* | 978 | /* |
| 834 | * /proc/ide interface | 979 | * /proc/ide interface |
| @@ -839,6 +984,11 @@ ide_devset_get(_name, _field); \ | |||
| 839 | ide_devset_set(_name, _field); \ | 984 | ide_devset_set(_name, _field); \ |
| 840 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | 985 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) |
| 841 | 986 | ||
| 987 | #define ide_devset_rw_flag(_name, _field) \ | ||
| 988 | ide_devset_get_flag(_name, _field); \ | ||
| 989 | ide_devset_set_flag(_name, _field); \ | ||
| 990 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
| 991 | |||
| 842 | struct ide_proc_devset { | 992 | struct ide_proc_devset { |
| 843 | const char *name; | 993 | const char *name; |
| 844 | const struct ide_devset *setting; | 994 | const struct ide_devset *setting; |
| @@ -905,37 +1055,55 @@ static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t * | |||
| 905 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 1055 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
| 906 | #endif | 1056 | #endif |
| 907 | 1057 | ||
| 1058 | enum { | ||
| 1059 | /* enter/exit functions */ | ||
| 1060 | IDE_DBG_FUNC = (1 << 0), | ||
| 1061 | /* sense key/asc handling */ | ||
| 1062 | IDE_DBG_SENSE = (1 << 1), | ||
| 1063 | /* packet commands handling */ | ||
| 1064 | IDE_DBG_PC = (1 << 2), | ||
| 1065 | /* request handling */ | ||
| 1066 | IDE_DBG_RQ = (1 << 3), | ||
| 1067 | /* driver probing/setup */ | ||
| 1068 | IDE_DBG_PROBE = (1 << 4), | ||
| 1069 | }; | ||
| 1070 | |||
| 1071 | /* DRV_NAME has to be defined in the driver before using the macro below */ | ||
| 1072 | #define __ide_debug_log(lvl, fmt, args...) \ | ||
| 1073 | { \ | ||
| 1074 | if (unlikely(drive->debug_mask & lvl)) \ | ||
| 1075 | printk(KERN_INFO DRV_NAME ": " fmt, ## args); \ | ||
| 1076 | } | ||
| 1077 | |||
| 908 | /* | 1078 | /* |
| 909 | * Power Management step value (rq->pm->pm_step). | 1079 | * Power Management state machine (rq->pm->pm_step). |
| 910 | * | ||
| 911 | * The step value starts at 0 (ide_pm_state_start_suspend) for a | ||
| 912 | * suspend operation or 1000 (ide_pm_state_start_resume) for a | ||
| 913 | * resume operation. | ||
| 914 | * | 1080 | * |
| 915 | * For each step, the core calls the subdriver start_power_step() first. | 1081 | * For each step, the core calls ide_start_power_step() first. |
| 916 | * This can return: | 1082 | * This can return: |
| 917 | * - ide_stopped : In this case, the core calls us back again unless | 1083 | * - ide_stopped : In this case, the core calls us back again unless |
| 918 | * step have been set to ide_power_state_completed. | 1084 | * step have been set to ide_power_state_completed. |
| 919 | * - ide_started : In this case, the channel is left busy until an | 1085 | * - ide_started : In this case, the channel is left busy until an |
| 920 | * async event (interrupt) occurs. | 1086 | * async event (interrupt) occurs. |
| 921 | * Typically, start_power_step() will issue a taskfile request with | 1087 | * Typically, ide_start_power_step() will issue a taskfile request with |
| 922 | * do_rw_taskfile(). | 1088 | * do_rw_taskfile(). |
| 923 | * | 1089 | * |
| 924 | * Upon reception of the interrupt, the core will call complete_power_step() | 1090 | * Upon reception of the interrupt, the core will call ide_complete_power_step() |
| 925 | * with the error code if any. This routine should update the step value | 1091 | * with the error code if any. This routine should update the step value |
| 926 | * and return. It should not start a new request. The core will call | 1092 | * and return. It should not start a new request. The core will call |
| 927 | * start_power_step for the new step value, unless step have been set to | 1093 | * ide_start_power_step() for the new step value, unless step have been |
| 928 | * ide_power_state_completed. | 1094 | * set to IDE_PM_COMPLETED. |
| 929 | * | ||
| 930 | * Subdrivers are expected to define their own additional power | ||
| 931 | * steps from 1..999 for suspend and from 1001..1999 for resume, | ||
| 932 | * other values are reserved for future use. | ||
| 933 | */ | 1095 | */ |
| 934 | |||
| 935 | enum { | 1096 | enum { |
| 936 | ide_pm_state_completed = -1, | 1097 | IDE_PM_START_SUSPEND, |
| 937 | ide_pm_state_start_suspend = 0, | 1098 | IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND, |
| 938 | ide_pm_state_start_resume = 1000, | 1099 | IDE_PM_STANDBY, |
| 1100 | |||
| 1101 | IDE_PM_START_RESUME, | ||
| 1102 | IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME, | ||
| 1103 | IDE_PM_IDLE, | ||
| 1104 | IDE_PM_RESTORE_DMA, | ||
| 1105 | |||
| 1106 | IDE_PM_COMPLETED, | ||
| 939 | }; | 1107 | }; |
| 940 | 1108 | ||
| 941 | /* | 1109 | /* |
| @@ -946,7 +1114,6 @@ enum { | |||
| 946 | */ | 1114 | */ |
| 947 | struct ide_driver_s { | 1115 | struct ide_driver_s { |
| 948 | const char *version; | 1116 | const char *version; |
| 949 | u8 media; | ||
| 950 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 1117 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
| 951 | int (*end_request)(ide_drive_t *, int, int); | 1118 | int (*end_request)(ide_drive_t *, int, int); |
| 952 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | 1119 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); |
| @@ -1015,110 +1182,6 @@ extern void ide_do_drive_cmd(ide_drive_t *, struct request *); | |||
| 1015 | 1182 | ||
| 1016 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); | 1183 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); |
| 1017 | 1184 | ||
| 1018 | enum { | ||
| 1019 | IDE_TFLAG_LBA48 = (1 << 0), | ||
| 1020 | IDE_TFLAG_FLAGGED = (1 << 2), | ||
| 1021 | IDE_TFLAG_OUT_DATA = (1 << 3), | ||
| 1022 | IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), | ||
| 1023 | IDE_TFLAG_OUT_HOB_NSECT = (1 << 5), | ||
| 1024 | IDE_TFLAG_OUT_HOB_LBAL = (1 << 6), | ||
| 1025 | IDE_TFLAG_OUT_HOB_LBAM = (1 << 7), | ||
| 1026 | IDE_TFLAG_OUT_HOB_LBAH = (1 << 8), | ||
| 1027 | IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE | | ||
| 1028 | IDE_TFLAG_OUT_HOB_NSECT | | ||
| 1029 | IDE_TFLAG_OUT_HOB_LBAL | | ||
| 1030 | IDE_TFLAG_OUT_HOB_LBAM | | ||
| 1031 | IDE_TFLAG_OUT_HOB_LBAH, | ||
| 1032 | IDE_TFLAG_OUT_FEATURE = (1 << 9), | ||
| 1033 | IDE_TFLAG_OUT_NSECT = (1 << 10), | ||
| 1034 | IDE_TFLAG_OUT_LBAL = (1 << 11), | ||
| 1035 | IDE_TFLAG_OUT_LBAM = (1 << 12), | ||
| 1036 | IDE_TFLAG_OUT_LBAH = (1 << 13), | ||
| 1037 | IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE | | ||
| 1038 | IDE_TFLAG_OUT_NSECT | | ||
| 1039 | IDE_TFLAG_OUT_LBAL | | ||
| 1040 | IDE_TFLAG_OUT_LBAM | | ||
| 1041 | IDE_TFLAG_OUT_LBAH, | ||
| 1042 | IDE_TFLAG_OUT_DEVICE = (1 << 14), | ||
| 1043 | IDE_TFLAG_WRITE = (1 << 15), | ||
| 1044 | IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), | ||
| 1045 | IDE_TFLAG_IN_DATA = (1 << 17), | ||
| 1046 | IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), | ||
| 1047 | IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), | ||
| 1048 | IDE_TFLAG_IN_HOB_FEATURE = (1 << 20), | ||
| 1049 | IDE_TFLAG_IN_HOB_NSECT = (1 << 21), | ||
| 1050 | IDE_TFLAG_IN_HOB_LBAL = (1 << 22), | ||
| 1051 | IDE_TFLAG_IN_HOB_LBAM = (1 << 23), | ||
| 1052 | IDE_TFLAG_IN_HOB_LBAH = (1 << 24), | ||
| 1053 | IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL | | ||
| 1054 | IDE_TFLAG_IN_HOB_LBAM | | ||
| 1055 | IDE_TFLAG_IN_HOB_LBAH, | ||
| 1056 | IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | | ||
| 1057 | IDE_TFLAG_IN_HOB_NSECT | | ||
| 1058 | IDE_TFLAG_IN_HOB_LBA, | ||
| 1059 | IDE_TFLAG_IN_FEATURE = (1 << 1), | ||
| 1060 | IDE_TFLAG_IN_NSECT = (1 << 25), | ||
| 1061 | IDE_TFLAG_IN_LBAL = (1 << 26), | ||
| 1062 | IDE_TFLAG_IN_LBAM = (1 << 27), | ||
| 1063 | IDE_TFLAG_IN_LBAH = (1 << 28), | ||
| 1064 | IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL | | ||
| 1065 | IDE_TFLAG_IN_LBAM | | ||
| 1066 | IDE_TFLAG_IN_LBAH, | ||
| 1067 | IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT | | ||
| 1068 | IDE_TFLAG_IN_LBA, | ||
| 1069 | IDE_TFLAG_IN_DEVICE = (1 << 29), | ||
| 1070 | IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB | | ||
| 1071 | IDE_TFLAG_IN_HOB, | ||
| 1072 | IDE_TFLAG_TF = IDE_TFLAG_OUT_TF | | ||
| 1073 | IDE_TFLAG_IN_TF, | ||
| 1074 | IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE | | ||
| 1075 | IDE_TFLAG_IN_DEVICE, | ||
| 1076 | /* force 16-bit I/O operations */ | ||
| 1077 | IDE_TFLAG_IO_16BIT = (1 << 30), | ||
| 1078 | /* ide_task_t was allocated using kmalloc() */ | ||
| 1079 | IDE_TFLAG_DYN = (1 << 31), | ||
| 1080 | }; | ||
| 1081 | |||
| 1082 | struct ide_taskfile { | ||
| 1083 | u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ | ||
| 1084 | |||
| 1085 | u8 hob_feature; /* 1-5: additional data to support LBA48 */ | ||
| 1086 | u8 hob_nsect; | ||
| 1087 | u8 hob_lbal; | ||
| 1088 | u8 hob_lbam; | ||
| 1089 | u8 hob_lbah; | ||
| 1090 | |||
| 1091 | u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ | ||
| 1092 | |||
| 1093 | union { /* 7: */ | ||
| 1094 | u8 error; /* read: error */ | ||
| 1095 | u8 feature; /* write: feature */ | ||
| 1096 | }; | ||
| 1097 | |||
| 1098 | u8 nsect; /* 8: number of sectors */ | ||
| 1099 | u8 lbal; /* 9: LBA low */ | ||
| 1100 | u8 lbam; /* 10: LBA mid */ | ||
| 1101 | u8 lbah; /* 11: LBA high */ | ||
| 1102 | |||
| 1103 | u8 device; /* 12: device select */ | ||
| 1104 | |||
| 1105 | union { /* 13: */ | ||
| 1106 | u8 status; /* read: status */ | ||
| 1107 | u8 command; /* write: command */ | ||
| 1108 | }; | ||
| 1109 | }; | ||
| 1110 | |||
| 1111 | typedef struct ide_task_s { | ||
| 1112 | union { | ||
| 1113 | struct ide_taskfile tf; | ||
| 1114 | u8 tf_array[14]; | ||
| 1115 | }; | ||
| 1116 | u32 tf_flags; | ||
| 1117 | int data_phase; | ||
| 1118 | struct request *rq; /* copy of request */ | ||
| 1119 | void *special; /* valid_t generally */ | ||
| 1120 | } ide_task_t; | ||
| 1121 | |||
| 1122 | void ide_tf_dump(const char *, struct ide_taskfile *); | 1185 | void ide_tf_dump(const char *, struct ide_taskfile *); |
| 1123 | 1186 | ||
| 1124 | void ide_exec_command(ide_hwif_t *, u8); | 1187 | void ide_exec_command(ide_hwif_t *, u8); |
| @@ -1150,6 +1213,13 @@ int ide_check_atapi_device(ide_drive_t *, const char *); | |||
| 1150 | 1213 | ||
| 1151 | void ide_init_pc(struct ide_atapi_pc *); | 1214 | void ide_init_pc(struct ide_atapi_pc *); |
| 1152 | 1215 | ||
| 1216 | /* Disk head parking */ | ||
| 1217 | extern wait_queue_head_t ide_park_wq; | ||
| 1218 | ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, | ||
| 1219 | char *buf); | ||
| 1220 | ssize_t ide_park_store(struct device *dev, struct device_attribute *attr, | ||
| 1221 | const char *buf, size_t len); | ||
| 1222 | |||
| 1153 | /* | 1223 | /* |
| 1154 | * Special requests for ide-tape block device strategy routine. | 1224 | * Special requests for ide-tape block device strategy routine. |
| 1155 | * | 1225 | * |
| @@ -1163,24 +1233,22 @@ enum { | |||
| 1163 | REQ_IDETAPE_WRITE = (1 << 3), | 1233 | REQ_IDETAPE_WRITE = (1 << 3), |
| 1164 | }; | 1234 | }; |
| 1165 | 1235 | ||
| 1166 | void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *, | ||
| 1167 | struct request *); | ||
| 1168 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); | 1236 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); |
| 1169 | 1237 | ||
| 1170 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); | 1238 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); |
| 1171 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); | 1239 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); |
| 1172 | int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); | 1240 | int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); |
| 1241 | void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); | ||
| 1242 | void ide_retry_pc(ide_drive_t *, struct gendisk *); | ||
| 1243 | |||
| 1244 | static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) | ||
| 1245 | { | ||
| 1246 | return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | int ide_scsi_expiry(ide_drive_t *); | ||
| 1173 | 1250 | ||
| 1174 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 1251 | ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); |
| 1175 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | ||
| 1176 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | ||
| 1177 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | ||
| 1178 | int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, | ||
| 1179 | int)); | ||
| 1180 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | ||
| 1181 | ide_handler_t *, unsigned int, ide_expiry_t *); | ||
| 1182 | ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, | ||
| 1183 | ide_handler_t *, unsigned int, ide_expiry_t *); | ||
| 1184 | 1252 | ||
| 1185 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); | 1253 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); |
| 1186 | 1254 | ||
| @@ -1358,6 +1426,7 @@ struct drive_list_entry { | |||
| 1358 | int ide_in_drive_list(u16 *, const struct drive_list_entry *); | 1426 | int ide_in_drive_list(u16 *, const struct drive_list_entry *); |
| 1359 | 1427 | ||
| 1360 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1428 | #ifdef CONFIG_BLK_DEV_IDEDMA |
| 1429 | int ide_dma_good_drive(ide_drive_t *); | ||
| 1361 | int __ide_dma_bad_drive(ide_drive_t *); | 1430 | int __ide_dma_bad_drive(ide_drive_t *); |
| 1362 | int ide_id_dma_bug(ide_drive_t *); | 1431 | int ide_id_dma_bug(ide_drive_t *); |
| 1363 | 1432 | ||
| @@ -1375,25 +1444,29 @@ int ide_set_dma(ide_drive_t *); | |||
| 1375 | void ide_check_dma_crc(ide_drive_t *); | 1444 | void ide_check_dma_crc(ide_drive_t *); |
| 1376 | ide_startstop_t ide_dma_intr(ide_drive_t *); | 1445 | ide_startstop_t ide_dma_intr(ide_drive_t *); |
| 1377 | 1446 | ||
| 1447 | int ide_allocate_dma_engine(ide_hwif_t *); | ||
| 1448 | void ide_release_dma_engine(ide_hwif_t *); | ||
| 1449 | |||
| 1378 | int ide_build_sglist(ide_drive_t *, struct request *); | 1450 | int ide_build_sglist(ide_drive_t *, struct request *); |
| 1379 | void ide_destroy_dmatable(ide_drive_t *); | 1451 | void ide_destroy_dmatable(ide_drive_t *); |
| 1380 | 1452 | ||
| 1381 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 1453 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
| 1454 | int config_drive_for_dma(ide_drive_t *); | ||
| 1382 | extern int ide_build_dmatable(ide_drive_t *, struct request *); | 1455 | extern int ide_build_dmatable(ide_drive_t *, struct request *); |
| 1383 | int ide_allocate_dma_engine(ide_hwif_t *); | ||
| 1384 | void ide_release_dma_engine(ide_hwif_t *); | ||
| 1385 | |||
| 1386 | void ide_dma_host_set(ide_drive_t *, int); | 1456 | void ide_dma_host_set(ide_drive_t *, int); |
| 1387 | extern int ide_dma_setup(ide_drive_t *); | 1457 | extern int ide_dma_setup(ide_drive_t *); |
| 1388 | void ide_dma_exec_cmd(ide_drive_t *, u8); | 1458 | void ide_dma_exec_cmd(ide_drive_t *, u8); |
| 1389 | extern void ide_dma_start(ide_drive_t *); | 1459 | extern void ide_dma_start(ide_drive_t *); |
| 1390 | extern int __ide_dma_end(ide_drive_t *); | 1460 | int ide_dma_end(ide_drive_t *); |
| 1391 | int ide_dma_test_irq(ide_drive_t *); | 1461 | int ide_dma_test_irq(ide_drive_t *); |
| 1392 | extern void ide_dma_lost_irq(ide_drive_t *); | ||
| 1393 | extern void ide_dma_timeout(ide_drive_t *); | ||
| 1394 | extern const struct ide_dma_ops sff_dma_ops; | 1462 | extern const struct ide_dma_ops sff_dma_ops; |
| 1463 | #else | ||
| 1464 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | ||
| 1395 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 1465 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
| 1396 | 1466 | ||
| 1467 | void ide_dma_lost_irq(ide_drive_t *); | ||
| 1468 | void ide_dma_timeout(ide_drive_t *); | ||
| 1469 | |||
| 1397 | #else | 1470 | #else |
| 1398 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } | 1471 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } |
| 1399 | static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } | 1472 | static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } |
| @@ -1404,11 +1477,8 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; } | |||
| 1404 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } | 1477 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } |
| 1405 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } | 1478 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } |
| 1406 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | 1479 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } |
| 1407 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | ||
| 1408 | |||
| 1409 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF | ||
| 1410 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } | 1480 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } |
| 1411 | #endif | 1481 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
| 1412 | 1482 | ||
| 1413 | #ifdef CONFIG_BLK_DEV_IDEACPI | 1483 | #ifdef CONFIG_BLK_DEV_IDEACPI |
| 1414 | extern int ide_acpi_exec_tfs(ide_drive_t *drive); | 1484 | extern int ide_acpi_exec_tfs(ide_drive_t *drive); |
| @@ -1436,7 +1506,6 @@ void ide_undecoded_slave(ide_drive_t *); | |||
| 1436 | 1506 | ||
| 1437 | void ide_port_apply_params(ide_hwif_t *); | 1507 | void ide_port_apply_params(ide_hwif_t *); |
| 1438 | 1508 | ||
| 1439 | struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **); | ||
| 1440 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); | 1509 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); |
| 1441 | void ide_host_free(struct ide_host *); | 1510 | void ide_host_free(struct ide_host *); |
| 1442 | int ide_host_register(struct ide_host *, const struct ide_port_info *, | 1511 | int ide_host_register(struct ide_host *, const struct ide_port_info *, |
| @@ -1547,6 +1616,6 @@ static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) | |||
| 1547 | { | 1616 | { |
| 1548 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; | 1617 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; |
| 1549 | 1618 | ||
| 1550 | return peer->present ? peer : NULL; | 1619 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; |
| 1551 | } | 1620 | } |
| 1552 | #endif /* _IDE_H */ | 1621 | #endif /* _IDE_H */ |
