diff options
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r-- | include/linux/ide.h | 273 |
1 files changed, 122 insertions, 151 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index 010fb26a1579..3644f6323384 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -33,24 +33,13 @@ | |||
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * Used to indicate "no IRQ", should be a value that cannot be an IRQ | ||
37 | * number. | ||
38 | */ | ||
39 | |||
40 | #define IDE_NO_IRQ (-1) | ||
41 | |||
42 | typedef unsigned char byte; /* used everywhere */ | ||
43 | |||
44 | /* | ||
45 | * Probably not wise to fiddle with these | 36 | * Probably not wise to fiddle with these |
46 | */ | 37 | */ |
38 | #define IDE_DEFAULT_MAX_FAILURES 1 | ||
47 | #define ERROR_MAX 8 /* Max read/write errors per sector */ | 39 | #define ERROR_MAX 8 /* Max read/write errors per sector */ |
48 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ | 40 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ |
49 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ | 41 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ |
50 | 42 | ||
51 | #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) | ||
52 | #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) | ||
53 | |||
54 | /* | 43 | /* |
55 | * Definitions for accessing IDE controller registers | 44 | * Definitions for accessing IDE controller registers |
56 | */ | 45 | */ |
@@ -122,8 +111,6 @@ struct ide_io_ports { | |||
122 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ | 111 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ |
123 | #define SECTOR_SIZE 512 | 112 | #define SECTOR_SIZE 512 |
124 | 113 | ||
125 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) | ||
126 | |||
127 | /* | 114 | /* |
128 | * Timeouts for various operations: | 115 | * Timeouts for various operations: |
129 | */ | 116 | */ |
@@ -172,9 +159,7 @@ typedef int (ide_ack_intr_t)(struct hwif_s *); | |||
172 | enum { ide_unknown, ide_generic, ide_pci, | 159 | enum { ide_unknown, ide_generic, ide_pci, |
173 | ide_cmd640, ide_dtc2278, ide_ali14xx, | 160 | ide_cmd640, ide_dtc2278, ide_ali14xx, |
174 | ide_qd65xx, ide_umc8672, ide_ht6560b, | 161 | ide_qd65xx, ide_umc8672, ide_ht6560b, |
175 | ide_rz1000, ide_trm290, | 162 | ide_4drives, ide_pmac, ide_acorn, |
176 | ide_cmd646, ide_cy82c693, ide_4drives, | ||
177 | ide_pmac, ide_acorn, | ||
178 | ide_au1xxx, ide_palm3710 | 163 | ide_au1xxx, ide_palm3710 |
179 | }; | 164 | }; |
180 | 165 | ||
@@ -196,9 +181,6 @@ typedef struct hw_regs_s { | |||
196 | unsigned long config; | 181 | unsigned long config; |
197 | } hw_regs_t; | 182 | } hw_regs_t; |
198 | 183 | ||
199 | void ide_init_port_data(struct hwif_s *, unsigned int); | ||
200 | void ide_init_port_hw(struct hwif_s *, hw_regs_t *); | ||
201 | |||
202 | static inline void ide_std_init_ports(hw_regs_t *hw, | 184 | static inline void ide_std_init_ports(hw_regs_t *hw, |
203 | unsigned long io_addr, | 185 | unsigned long io_addr, |
204 | unsigned long ctl_addr) | 186 | unsigned long ctl_addr) |
@@ -407,6 +389,7 @@ enum { | |||
407 | * This is used for several packet commands (not for READ/WRITE commands). | 389 | * This is used for several packet commands (not for READ/WRITE commands). |
408 | */ | 390 | */ |
409 | #define IDE_PC_BUFFER_SIZE 256 | 391 | #define IDE_PC_BUFFER_SIZE 256 |
392 | #define ATAPI_WAIT_PC (60 * HZ) | ||
410 | 393 | ||
411 | struct ide_atapi_pc { | 394 | struct ide_atapi_pc { |
412 | /* actual packet bytes */ | 395 | /* actual packet bytes */ |
@@ -443,18 +426,14 @@ struct ide_atapi_pc { | |||
443 | struct idetape_bh *bh; | 426 | struct idetape_bh *bh; |
444 | char *b_data; | 427 | char *b_data; |
445 | 428 | ||
446 | /* idescsi only for now */ | ||
447 | struct scatterlist *sg; | 429 | struct scatterlist *sg; |
448 | unsigned int sg_cnt; | 430 | unsigned int sg_cnt; |
449 | 431 | ||
450 | struct scsi_cmnd *scsi_cmd; | ||
451 | void (*done) (struct scsi_cmnd *); | ||
452 | |||
453 | unsigned long timeout; | 432 | unsigned long timeout; |
454 | }; | 433 | }; |
455 | 434 | ||
456 | struct ide_devset; | 435 | struct ide_devset; |
457 | struct ide_driver_s; | 436 | struct ide_driver; |
458 | 437 | ||
459 | #ifdef CONFIG_BLK_DEV_IDEACPI | 438 | #ifdef CONFIG_BLK_DEV_IDEACPI |
460 | struct ide_acpi_drive_link; | 439 | struct ide_acpi_drive_link; |
@@ -484,55 +463,53 @@ enum { | |||
484 | 463 | ||
485 | /* ide-cd */ | 464 | /* ide-cd */ |
486 | /* Drive cannot eject the disc. */ | 465 | /* Drive cannot eject the disc. */ |
487 | IDE_AFLAG_NO_EJECT = (1 << 3), | 466 | IDE_AFLAG_NO_EJECT = (1 << 1), |
488 | /* Drive is a pre ATAPI 1.2 drive. */ | 467 | /* Drive is a pre ATAPI 1.2 drive. */ |
489 | IDE_AFLAG_PRE_ATAPI12 = (1 << 4), | 468 | IDE_AFLAG_PRE_ATAPI12 = (1 << 2), |
490 | /* TOC addresses are in BCD. */ | 469 | /* TOC addresses are in BCD. */ |
491 | IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5), | 470 | IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3), |
492 | /* TOC track numbers are in BCD. */ | 471 | /* TOC track numbers are in BCD. */ |
493 | IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6), | 472 | IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4), |
494 | /* | 473 | /* |
495 | * Drive does not provide data in multiples of SECTOR_SIZE | 474 | * Drive does not provide data in multiples of SECTOR_SIZE |
496 | * when more than one interrupt is needed. | 475 | * when more than one interrupt is needed. |
497 | */ | 476 | */ |
498 | IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), | 477 | IDE_AFLAG_LIMIT_NFRAMES = (1 << 5), |
499 | /* Seeking in progress. */ | ||
500 | IDE_AFLAG_SEEKING = (1 << 8), | ||
501 | /* Saved TOC information is current. */ | 478 | /* Saved TOC information is current. */ |
502 | IDE_AFLAG_TOC_VALID = (1 << 9), | 479 | IDE_AFLAG_TOC_VALID = (1 << 6), |
503 | /* We think that the drive door is locked. */ | 480 | /* We think that the drive door is locked. */ |
504 | IDE_AFLAG_DOOR_LOCKED = (1 << 10), | 481 | IDE_AFLAG_DOOR_LOCKED = (1 << 7), |
505 | /* SET_CD_SPEED command is unsupported. */ | 482 | /* SET_CD_SPEED command is unsupported. */ |
506 | IDE_AFLAG_NO_SPEED_SELECT = (1 << 11), | 483 | IDE_AFLAG_NO_SPEED_SELECT = (1 << 8), |
507 | IDE_AFLAG_VERTOS_300_SSD = (1 << 12), | 484 | IDE_AFLAG_VERTOS_300_SSD = (1 << 9), |
508 | IDE_AFLAG_VERTOS_600_ESD = (1 << 13), | 485 | IDE_AFLAG_VERTOS_600_ESD = (1 << 10), |
509 | IDE_AFLAG_SANYO_3CD = (1 << 14), | 486 | IDE_AFLAG_SANYO_3CD = (1 << 11), |
510 | IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15), | 487 | IDE_AFLAG_FULL_CAPS_PAGE = (1 << 12), |
511 | IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16), | 488 | IDE_AFLAG_PLAY_AUDIO_OK = (1 << 13), |
512 | IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), | 489 | IDE_AFLAG_LE_SPEED_FIELDS = (1 << 14), |
513 | 490 | ||
514 | /* ide-floppy */ | 491 | /* ide-floppy */ |
515 | /* Avoid commands not supported in Clik drive */ | 492 | /* Avoid commands not supported in Clik drive */ |
516 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), | 493 | IDE_AFLAG_CLIK_DRIVE = (1 << 15), |
517 | /* Requires BH algorithm for packets */ | 494 | /* Requires BH algorithm for packets */ |
518 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), | 495 | IDE_AFLAG_ZIP_DRIVE = (1 << 16), |
519 | /* Supports format progress report */ | 496 | /* Supports format progress report */ |
520 | IDE_AFLAG_SRFP = (1 << 22), | 497 | IDE_AFLAG_SRFP = (1 << 17), |
521 | 498 | ||
522 | /* ide-tape */ | 499 | /* ide-tape */ |
523 | IDE_AFLAG_IGNORE_DSC = (1 << 23), | 500 | IDE_AFLAG_IGNORE_DSC = (1 << 18), |
524 | /* 0 When the tape position is unknown */ | 501 | /* 0 When the tape position is unknown */ |
525 | IDE_AFLAG_ADDRESS_VALID = (1 << 24), | 502 | IDE_AFLAG_ADDRESS_VALID = (1 << 19), |
526 | /* Device already opened */ | 503 | /* Device already opened */ |
527 | IDE_AFLAG_BUSY = (1 << 25), | 504 | IDE_AFLAG_BUSY = (1 << 20), |
528 | /* Attempt to auto-detect the current user block size */ | 505 | /* Attempt to auto-detect the current user block size */ |
529 | IDE_AFLAG_DETECT_BS = (1 << 26), | 506 | IDE_AFLAG_DETECT_BS = (1 << 21), |
530 | /* Currently on a filemark */ | 507 | /* Currently on a filemark */ |
531 | IDE_AFLAG_FILEMARK = (1 << 27), | 508 | IDE_AFLAG_FILEMARK = (1 << 22), |
532 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | 509 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ |
533 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), | 510 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 23), |
534 | 511 | ||
535 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), | 512 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 24), |
536 | }; | 513 | }; |
537 | 514 | ||
538 | /* device flags */ | 515 | /* device flags */ |
@@ -571,28 +548,26 @@ enum { | |||
571 | IDE_DFLAG_NODMA = (1 << 16), | 548 | IDE_DFLAG_NODMA = (1 << 16), |
572 | /* powermanagment told us not to do anything, so sleep nicely */ | 549 | /* powermanagment told us not to do anything, so sleep nicely */ |
573 | IDE_DFLAG_BLOCKED = (1 << 17), | 550 | IDE_DFLAG_BLOCKED = (1 << 17), |
574 | /* ide-scsi emulation */ | ||
575 | IDE_DFLAG_SCSI = (1 << 18), | ||
576 | /* sleeping & sleep field valid */ | 551 | /* sleeping & sleep field valid */ |
577 | IDE_DFLAG_SLEEPING = (1 << 19), | 552 | IDE_DFLAG_SLEEPING = (1 << 18), |
578 | IDE_DFLAG_POST_RESET = (1 << 20), | 553 | IDE_DFLAG_POST_RESET = (1 << 19), |
579 | IDE_DFLAG_UDMA33_WARNED = (1 << 21), | 554 | IDE_DFLAG_UDMA33_WARNED = (1 << 20), |
580 | IDE_DFLAG_LBA48 = (1 << 22), | 555 | IDE_DFLAG_LBA48 = (1 << 21), |
581 | /* status of write cache */ | 556 | /* status of write cache */ |
582 | IDE_DFLAG_WCACHE = (1 << 23), | 557 | IDE_DFLAG_WCACHE = (1 << 22), |
583 | /* used for ignoring ATA_DF */ | 558 | /* used for ignoring ATA_DF */ |
584 | IDE_DFLAG_NOWERR = (1 << 24), | 559 | IDE_DFLAG_NOWERR = (1 << 23), |
585 | /* retrying in PIO */ | 560 | /* retrying in PIO */ |
586 | IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), | 561 | IDE_DFLAG_DMA_PIO_RETRY = (1 << 24), |
587 | IDE_DFLAG_LBA = (1 << 26), | 562 | IDE_DFLAG_LBA = (1 << 25), |
588 | /* don't unload heads */ | 563 | /* don't unload heads */ |
589 | IDE_DFLAG_NO_UNLOAD = (1 << 27), | 564 | IDE_DFLAG_NO_UNLOAD = (1 << 26), |
590 | /* heads unloaded, please don't reset port */ | 565 | /* heads unloaded, please don't reset port */ |
591 | IDE_DFLAG_PARKED = (1 << 28), | 566 | IDE_DFLAG_PARKED = (1 << 27), |
592 | IDE_DFLAG_MEDIA_CHANGED = (1 << 29), | 567 | IDE_DFLAG_MEDIA_CHANGED = (1 << 28), |
593 | /* write protect */ | 568 | /* write protect */ |
594 | IDE_DFLAG_WP = (1 << 30), | 569 | IDE_DFLAG_WP = (1 << 29), |
595 | IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 31), | 570 | IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 30), |
596 | }; | 571 | }; |
597 | 572 | ||
598 | struct ide_drive_s { | 573 | struct ide_drive_s { |
@@ -602,7 +577,6 @@ struct ide_drive_s { | |||
602 | struct request_queue *queue; /* request queue */ | 577 | struct request_queue *queue; /* request queue */ |
603 | 578 | ||
604 | struct request *rq; /* current request */ | 579 | struct request *rq; /* current request */ |
605 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | ||
606 | void *driver_data; /* extra driver data */ | 580 | void *driver_data; /* extra driver data */ |
607 | u16 *id; /* identification info */ | 581 | u16 *id; /* identification info */ |
608 | #ifdef CONFIG_IDE_PROC_FS | 582 | #ifdef CONFIG_IDE_PROC_FS |
@@ -616,8 +590,6 @@ struct ide_drive_s { | |||
616 | unsigned long dev_flags; | 590 | unsigned long dev_flags; |
617 | 591 | ||
618 | unsigned long sleep; /* sleep until this time */ | 592 | unsigned long sleep; /* sleep until this time */ |
619 | unsigned long service_start; /* time we started last request */ | ||
620 | unsigned long service_time; /* service time of last request */ | ||
621 | unsigned long timeout; /* max time to wait for irq */ | 593 | unsigned long timeout; /* max time to wait for irq */ |
622 | 594 | ||
623 | special_t special; /* special action flags */ | 595 | special_t special; /* special action flags */ |
@@ -678,6 +650,8 @@ struct ide_drive_s { | |||
678 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, | 650 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, |
679 | unsigned int, int); | 651 | unsigned int, int); |
680 | 652 | ||
653 | ide_startstop_t (*irq_handler)(struct ide_drive_s *); | ||
654 | |||
681 | unsigned long atapi_flags; | 655 | unsigned long atapi_flags; |
682 | 656 | ||
683 | struct ide_atapi_pc request_sense_pc; | 657 | struct ide_atapi_pc request_sense_pc; |
@@ -700,7 +674,6 @@ struct ide_tp_ops { | |||
700 | void (*exec_command)(struct hwif_s *, u8); | 674 | void (*exec_command)(struct hwif_s *, u8); |
701 | u8 (*read_status)(struct hwif_s *); | 675 | u8 (*read_status)(struct hwif_s *); |
702 | u8 (*read_altstatus)(struct hwif_s *); | 676 | u8 (*read_altstatus)(struct hwif_s *); |
703 | u8 (*read_sff_dma_status)(struct hwif_s *); | ||
704 | 677 | ||
705 | void (*set_irq)(struct hwif_s *, int); | 678 | void (*set_irq)(struct hwif_s *, int); |
706 | 679 | ||
@@ -761,14 +734,17 @@ struct ide_dma_ops { | |||
761 | int (*dma_test_irq)(struct ide_drive_s *); | 734 | int (*dma_test_irq)(struct ide_drive_s *); |
762 | void (*dma_lost_irq)(struct ide_drive_s *); | 735 | void (*dma_lost_irq)(struct ide_drive_s *); |
763 | void (*dma_timeout)(struct ide_drive_s *); | 736 | void (*dma_timeout)(struct ide_drive_s *); |
737 | /* | ||
738 | * The following method is optional and only required to be | ||
739 | * implemented for the SFF-8038i compatible controllers. | ||
740 | */ | ||
741 | u8 (*dma_sff_read_status)(struct hwif_s *); | ||
764 | }; | 742 | }; |
765 | 743 | ||
766 | struct ide_host; | 744 | struct ide_host; |
767 | 745 | ||
768 | typedef struct hwif_s { | 746 | typedef struct hwif_s { |
769 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ | ||
770 | struct hwif_s *mate; /* other hwif from same PCI chip */ | 747 | struct hwif_s *mate; /* other hwif from same PCI chip */ |
771 | struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ | ||
772 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 748 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
773 | 749 | ||
774 | struct ide_host *host; | 750 | struct ide_host *host; |
@@ -779,7 +755,7 @@ typedef struct hwif_s { | |||
779 | 755 | ||
780 | unsigned long sata_scr[SATA_NR_PORTS]; | 756 | unsigned long sata_scr[SATA_NR_PORTS]; |
781 | 757 | ||
782 | ide_drive_t drives[MAX_DRIVES]; /* drive info */ | 758 | ide_drive_t *devices[MAX_DRIVES + 1]; |
783 | 759 | ||
784 | u8 major; /* our major number */ | 760 | u8 major; /* our major number */ |
785 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 761 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
@@ -845,9 +821,7 @@ typedef struct hwif_s { | |||
845 | unsigned extra_ports; /* number of extra dma ports */ | 821 | unsigned extra_ports; /* number of extra dma ports */ |
846 | 822 | ||
847 | unsigned present : 1; /* this interface exists */ | 823 | unsigned present : 1; /* this interface exists */ |
848 | unsigned serialized : 1; /* serialized all channel operation */ | 824 | unsigned busy : 1; /* serializes devices on a port */ |
849 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ | ||
850 | unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ | ||
851 | 825 | ||
852 | struct device gendev; | 826 | struct device gendev; |
853 | struct device *portdev; | 827 | struct device *portdev; |
@@ -859,19 +833,49 @@ typedef struct hwif_s { | |||
859 | #ifdef CONFIG_BLK_DEV_IDEACPI | 833 | #ifdef CONFIG_BLK_DEV_IDEACPI |
860 | struct ide_acpi_hwif_link *acpidata; | 834 | struct ide_acpi_hwif_link *acpidata; |
861 | #endif | 835 | #endif |
836 | |||
837 | /* IRQ handler, if active */ | ||
838 | ide_startstop_t (*handler)(ide_drive_t *); | ||
839 | |||
840 | /* BOOL: polling active & poll_timeout field valid */ | ||
841 | unsigned int polling : 1; | ||
842 | |||
843 | /* current drive */ | ||
844 | ide_drive_t *cur_dev; | ||
845 | |||
846 | /* current request */ | ||
847 | struct request *rq; | ||
848 | |||
849 | /* failsafe timer */ | ||
850 | struct timer_list timer; | ||
851 | /* timeout value during long polls */ | ||
852 | unsigned long poll_timeout; | ||
853 | /* queried upon timeouts */ | ||
854 | int (*expiry)(ide_drive_t *); | ||
855 | |||
856 | int req_gen; | ||
857 | int req_gen_timer; | ||
858 | |||
859 | spinlock_t lock; | ||
862 | } ____cacheline_internodealigned_in_smp ide_hwif_t; | 860 | } ____cacheline_internodealigned_in_smp ide_hwif_t; |
863 | 861 | ||
864 | #define MAX_HOST_PORTS 4 | 862 | #define MAX_HOST_PORTS 4 |
865 | 863 | ||
866 | struct ide_host { | 864 | struct ide_host { |
867 | ide_hwif_t *ports[MAX_HOST_PORTS]; | 865 | ide_hwif_t *ports[MAX_HOST_PORTS + 1]; |
868 | unsigned int n_ports; | 866 | unsigned int n_ports; |
869 | struct device *dev[2]; | 867 | struct device *dev[2]; |
870 | unsigned int (*init_chipset)(struct pci_dev *); | 868 | unsigned int (*init_chipset)(struct pci_dev *); |
871 | unsigned long host_flags; | 869 | unsigned long host_flags; |
872 | void *host_priv; | 870 | void *host_priv; |
871 | ide_hwif_t *cur_port; /* for hosts requiring serialization */ | ||
872 | |||
873 | /* used for hosts requiring serialization */ | ||
874 | volatile long host_busy; | ||
873 | }; | 875 | }; |
874 | 876 | ||
877 | #define IDE_HOST_BUSY 0 | ||
878 | |||
875 | /* | 879 | /* |
876 | * internal ide interrupt handler type | 880 | * internal ide interrupt handler type |
877 | */ | 881 | */ |
@@ -881,38 +885,6 @@ typedef int (ide_expiry_t)(ide_drive_t *); | |||
881 | /* used by ide-cd, ide-floppy, etc. */ | 885 | /* used by ide-cd, ide-floppy, etc. */ |
882 | typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); | 886 | typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); |
883 | 887 | ||
884 | typedef struct hwgroup_s { | ||
885 | /* irq handler, if active */ | ||
886 | ide_startstop_t (*handler)(ide_drive_t *); | ||
887 | |||
888 | /* BOOL: protects all fields below */ | ||
889 | volatile int busy; | ||
890 | /* BOOL: wake us up on timer expiry */ | ||
891 | unsigned int sleeping : 1; | ||
892 | /* BOOL: polling active & poll_timeout field valid */ | ||
893 | unsigned int polling : 1; | ||
894 | |||
895 | /* current drive */ | ||
896 | ide_drive_t *drive; | ||
897 | /* ptr to current hwif in linked-list */ | ||
898 | ide_hwif_t *hwif; | ||
899 | |||
900 | /* current request */ | ||
901 | struct request *rq; | ||
902 | |||
903 | /* failsafe timer */ | ||
904 | struct timer_list timer; | ||
905 | /* timeout value during long polls */ | ||
906 | unsigned long poll_timeout; | ||
907 | /* queried upon timeouts */ | ||
908 | int (*expiry)(ide_drive_t *); | ||
909 | |||
910 | int req_gen; | ||
911 | int req_gen_timer; | ||
912 | } ide_hwgroup_t; | ||
913 | |||
914 | typedef struct ide_driver_s ide_driver_t; | ||
915 | |||
916 | extern struct mutex ide_setting_mtx; | 888 | extern struct mutex ide_setting_mtx; |
917 | 889 | ||
918 | /* | 890 | /* |
@@ -1038,8 +1010,8 @@ void ide_proc_register_port(ide_hwif_t *); | |||
1038 | void ide_proc_port_register_devices(ide_hwif_t *); | 1010 | void ide_proc_port_register_devices(ide_hwif_t *); |
1039 | void ide_proc_unregister_device(ide_drive_t *); | 1011 | void ide_proc_unregister_device(ide_drive_t *); |
1040 | void ide_proc_unregister_port(ide_hwif_t *); | 1012 | void ide_proc_unregister_port(ide_hwif_t *); |
1041 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 1013 | void ide_proc_register_driver(ide_drive_t *, struct ide_driver *); |
1042 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 1014 | void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *); |
1043 | 1015 | ||
1044 | read_proc_t proc_ide_read_capacity; | 1016 | read_proc_t proc_ide_read_capacity; |
1045 | read_proc_t proc_ide_read_geometry; | 1017 | read_proc_t proc_ide_read_geometry; |
@@ -1066,8 +1038,10 @@ static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } | |||
1066 | static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } | 1038 | static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } |
1067 | static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | 1039 | static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } |
1068 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 1040 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
1069 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1041 | static inline void ide_proc_register_driver(ide_drive_t *drive, |
1070 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1042 | struct ide_driver *driver) { ; } |
1043 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, | ||
1044 | struct ide_driver *driver) { ; } | ||
1071 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 1045 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
1072 | #endif | 1046 | #endif |
1073 | 1047 | ||
@@ -1122,17 +1096,24 @@ enum { | |||
1122 | IDE_PM_COMPLETED, | 1096 | IDE_PM_COMPLETED, |
1123 | }; | 1097 | }; |
1124 | 1098 | ||
1099 | int generic_ide_suspend(struct device *, pm_message_t); | ||
1100 | int generic_ide_resume(struct device *); | ||
1101 | |||
1102 | void ide_complete_power_step(ide_drive_t *, struct request *); | ||
1103 | ide_startstop_t ide_start_power_step(ide_drive_t *, struct request *); | ||
1104 | void ide_complete_pm_request(ide_drive_t *, struct request *); | ||
1105 | void ide_check_pm_state(ide_drive_t *, struct request *); | ||
1106 | |||
1125 | /* | 1107 | /* |
1126 | * Subdrivers support. | 1108 | * Subdrivers support. |
1127 | * | 1109 | * |
1128 | * The gendriver.owner field should be set to the module owner of this driver. | 1110 | * The gendriver.owner field should be set to the module owner of this driver. |
1129 | * The gendriver.name field should be set to the name of this driver | 1111 | * The gendriver.name field should be set to the name of this driver |
1130 | */ | 1112 | */ |
1131 | struct ide_driver_s { | 1113 | struct ide_driver { |
1132 | const char *version; | 1114 | const char *version; |
1133 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 1115 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
1134 | int (*end_request)(ide_drive_t *, int, int); | 1116 | int (*end_request)(ide_drive_t *, int, int); |
1135 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | ||
1136 | struct device_driver gen_driver; | 1117 | struct device_driver gen_driver; |
1137 | int (*probe)(ide_drive_t *); | 1118 | int (*probe)(ide_drive_t *); |
1138 | void (*remove)(ide_drive_t *); | 1119 | void (*remove)(ide_drive_t *); |
@@ -1144,7 +1125,7 @@ struct ide_driver_s { | |||
1144 | #endif | 1125 | #endif |
1145 | }; | 1126 | }; |
1146 | 1127 | ||
1147 | #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) | 1128 | #define to_ide_driver(drv) container_of(drv, struct ide_driver, gen_driver) |
1148 | 1129 | ||
1149 | int ide_device_get(ide_drive_t *); | 1130 | int ide_device_get(ide_drive_t *); |
1150 | void ide_device_put(ide_drive_t *); | 1131 | void ide_device_put(ide_drive_t *); |
@@ -1176,9 +1157,7 @@ void ide_execute_pkt_cmd(ide_drive_t *); | |||
1176 | 1157 | ||
1177 | void ide_pad_transfer(ide_drive_t *, int, int); | 1158 | void ide_pad_transfer(ide_drive_t *, int, int); |
1178 | 1159 | ||
1179 | ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | 1160 | ide_startstop_t ide_error(ide_drive_t *, const char *, u8); |
1180 | |||
1181 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); | ||
1182 | 1161 | ||
1183 | void ide_fix_driveid(u16 *); | 1162 | void ide_fix_driveid(u16 *); |
1184 | 1163 | ||
@@ -1202,7 +1181,6 @@ void ide_tf_dump(const char *, struct ide_taskfile *); | |||
1202 | void ide_exec_command(ide_hwif_t *, u8); | 1181 | void ide_exec_command(ide_hwif_t *, u8); |
1203 | u8 ide_read_status(ide_hwif_t *); | 1182 | u8 ide_read_status(ide_hwif_t *); |
1204 | u8 ide_read_altstatus(ide_hwif_t *); | 1183 | u8 ide_read_altstatus(ide_hwif_t *); |
1205 | u8 ide_read_sff_dma_status(ide_hwif_t *); | ||
1206 | 1184 | ||
1207 | void ide_set_irq(ide_hwif_t *, int); | 1185 | void ide_set_irq(ide_hwif_t *, int); |
1208 | 1186 | ||
@@ -1256,14 +1234,11 @@ int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); | |||
1256 | void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); | 1234 | void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); |
1257 | void ide_retry_pc(ide_drive_t *, struct gendisk *); | 1235 | void ide_retry_pc(ide_drive_t *, struct gendisk *); |
1258 | 1236 | ||
1259 | static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) | 1237 | int ide_cd_expiry(ide_drive_t *); |
1260 | { | ||
1261 | return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); | ||
1262 | } | ||
1263 | 1238 | ||
1264 | int ide_scsi_expiry(ide_drive_t *); | 1239 | int ide_cd_get_xferlen(struct request *); |
1265 | 1240 | ||
1266 | ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); | 1241 | ide_startstop_t ide_issue_pc(ide_drive_t *); |
1267 | 1242 | ||
1268 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); | 1243 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); |
1269 | 1244 | ||
@@ -1320,11 +1295,11 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, | |||
1320 | } | 1295 | } |
1321 | #endif | 1296 | #endif |
1322 | 1297 | ||
1323 | typedef struct ide_pci_enablebit_s { | 1298 | struct ide_pci_enablebit { |
1324 | u8 reg; /* byte pci reg holding the enable-bit */ | 1299 | u8 reg; /* byte pci reg holding the enable-bit */ |
1325 | u8 mask; /* mask to isolate the enable-bit */ | 1300 | u8 mask; /* mask to isolate the enable-bit */ |
1326 | u8 val; /* value of masked reg when "enabled" */ | 1301 | u8 val; /* value of masked reg when "enabled" */ |
1327 | } ide_pci_enablebit_t; | 1302 | }; |
1328 | 1303 | ||
1329 | enum { | 1304 | enum { |
1330 | /* Uses ISA control ports not PCI ones. */ | 1305 | /* Uses ISA control ports not PCI ones. */ |
@@ -1376,8 +1351,8 @@ enum { | |||
1376 | IDE_HFLAG_LEGACY_IRQS = (1 << 21), | 1351 | IDE_HFLAG_LEGACY_IRQS = (1 << 21), |
1377 | /* force use of legacy IRQs */ | 1352 | /* force use of legacy IRQs */ |
1378 | IDE_HFLAG_FORCE_LEGACY_IRQS = (1 << 22), | 1353 | IDE_HFLAG_FORCE_LEGACY_IRQS = (1 << 22), |
1379 | /* limit LBA48 requests to 256 sectors */ | 1354 | /* host is TRM290 */ |
1380 | IDE_HFLAG_RQSIZE_256 = (1 << 23), | 1355 | IDE_HFLAG_TRM290 = (1 << 23), |
1381 | /* use 32-bit I/O ops */ | 1356 | /* use 32-bit I/O ops */ |
1382 | IDE_HFLAG_IO_32BIT = (1 << 24), | 1357 | IDE_HFLAG_IO_32BIT = (1 << 24), |
1383 | /* unmask IRQs */ | 1358 | /* unmask IRQs */ |
@@ -1413,8 +1388,12 @@ struct ide_port_info { | |||
1413 | const struct ide_port_ops *port_ops; | 1388 | const struct ide_port_ops *port_ops; |
1414 | const struct ide_dma_ops *dma_ops; | 1389 | const struct ide_dma_ops *dma_ops; |
1415 | 1390 | ||
1416 | ide_pci_enablebit_t enablebits[2]; | 1391 | struct ide_pci_enablebit enablebits[2]; |
1392 | |||
1417 | hwif_chipset_t chipset; | 1393 | hwif_chipset_t chipset; |
1394 | |||
1395 | u16 max_sectors; /* if < than the default one */ | ||
1396 | |||
1418 | u32 host_flags; | 1397 | u32 host_flags; |
1419 | u8 pio_mask; | 1398 | u8 pio_mask; |
1420 | u8 swdma_mask; | 1399 | u8 swdma_mask; |
@@ -1482,6 +1461,7 @@ void ide_dma_exec_cmd(ide_drive_t *, u8); | |||
1482 | extern void ide_dma_start(ide_drive_t *); | 1461 | extern void ide_dma_start(ide_drive_t *); |
1483 | int ide_dma_end(ide_drive_t *); | 1462 | int ide_dma_end(ide_drive_t *); |
1484 | int ide_dma_test_irq(ide_drive_t *); | 1463 | int ide_dma_test_irq(ide_drive_t *); |
1464 | u8 ide_dma_sff_read_status(ide_hwif_t *); | ||
1485 | extern const struct ide_dma_ops sff_dma_ops; | 1465 | extern const struct ide_dma_ops sff_dma_ops; |
1486 | #else | 1466 | #else |
1487 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | 1467 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } |
@@ -1519,15 +1499,13 @@ static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; } | |||
1519 | static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} | 1499 | static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} |
1520 | #endif | 1500 | #endif |
1521 | 1501 | ||
1522 | void ide_remove_port_from_hwgroup(ide_hwif_t *); | ||
1523 | void ide_unregister(ide_hwif_t *); | ||
1524 | |||
1525 | void ide_register_region(struct gendisk *); | 1502 | void ide_register_region(struct gendisk *); |
1526 | void ide_unregister_region(struct gendisk *); | 1503 | void ide_unregister_region(struct gendisk *); |
1527 | 1504 | ||
1528 | void ide_undecoded_slave(ide_drive_t *); | 1505 | void ide_undecoded_slave(ide_drive_t *); |
1529 | 1506 | ||
1530 | void ide_port_apply_params(ide_hwif_t *); | 1507 | void ide_port_apply_params(ide_hwif_t *); |
1508 | int ide_sysfs_register_port(ide_hwif_t *); | ||
1531 | 1509 | ||
1532 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); | 1510 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); |
1533 | void ide_host_free(struct ide_host *); | 1511 | void ide_host_free(struct ide_host *); |
@@ -1605,23 +1583,9 @@ static inline void ide_set_max_pio(ide_drive_t *drive) | |||
1605 | ide_set_pio(drive, 255); | 1583 | ide_set_pio(drive, 255); |
1606 | } | 1584 | } |
1607 | 1585 | ||
1608 | extern spinlock_t ide_lock; | 1586 | char *ide_media_string(ide_drive_t *); |
1609 | extern struct mutex ide_cfg_mtx; | ||
1610 | /* | ||
1611 | * Structure locking: | ||
1612 | * | ||
1613 | * ide_cfg_mtx and ide_lock together protect changes to | ||
1614 | * ide_hwif_t->{next,hwgroup} | ||
1615 | * ide_drive_t->next | ||
1616 | * | ||
1617 | * ide_hwgroup_t->busy: ide_lock | ||
1618 | * ide_hwgroup_t->hwif: ide_lock | ||
1619 | * ide_hwif_t->mate: constant, no locking | ||
1620 | * ide_drive_t->hwif: constant, no locking | ||
1621 | */ | ||
1622 | |||
1623 | #define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0) | ||
1624 | 1587 | ||
1588 | extern struct device_attribute ide_dev_attrs[]; | ||
1625 | extern struct bus_type ide_bus_type; | 1589 | extern struct bus_type ide_bus_type; |
1626 | extern struct class *ide_port_class; | 1590 | extern struct class *ide_port_class; |
1627 | 1591 | ||
@@ -1637,8 +1601,15 @@ static inline int hwif_to_node(ide_hwif_t *hwif) | |||
1637 | 1601 | ||
1638 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) | 1602 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) |
1639 | { | 1603 | { |
1640 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; | 1604 | ide_drive_t *peer = drive->hwif->devices[(drive->dn ^ 1) & 1]; |
1641 | 1605 | ||
1642 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; | 1606 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; |
1643 | } | 1607 | } |
1608 | |||
1609 | #define ide_port_for_each_dev(i, dev, port) \ | ||
1610 | for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) | ||
1611 | |||
1612 | #define ide_host_for_each_port(i, port, host) \ | ||
1613 | for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++) | ||
1614 | |||
1644 | #endif /* _IDE_H */ | 1615 | #endif /* _IDE_H */ |