aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ide.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r--include/linux/ide.h308
1 files changed, 185 insertions, 123 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index eddb6daadf4a..d67ccca2b964 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -139,6 +139,12 @@ struct ide_io_ports {
139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ 139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */
140 140
141/* 141/*
142 * Op codes for special requests to be handled by ide_special_rq().
143 * Values should be in the range of 0x20 to 0x3f.
144 */
145#define REQ_DRIVE_RESET 0x20
146
147/*
142 * Check for an interrupt and acknowledge the interrupt status 148 * Check for an interrupt and acknowledge the interrupt status
143 */ 149 */
144struct hwif_s; 150struct hwif_s;
@@ -171,7 +177,8 @@ typedef struct hw_regs_s {
171 int irq; /* our irq number */ 177 int irq; /* our irq number */
172 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ 178 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
173 hwif_chipset_t chipset; 179 hwif_chipset_t chipset;
174 struct device *dev; 180 struct device *dev, *parent;
181 unsigned long config;
175} hw_regs_t; 182} hw_regs_t;
176 183
177void ide_init_port_data(struct hwif_s *, unsigned int); 184void ide_init_port_data(struct hwif_s *, unsigned int);
@@ -301,7 +308,65 @@ struct ide_acpi_drive_link;
301struct ide_acpi_hwif_link; 308struct ide_acpi_hwif_link;
302#endif 309#endif
303 310
304typedef struct ide_drive_s { 311/* ATAPI device flags */
312enum {
313 IDE_AFLAG_DRQ_INTERRUPT = (1 << 0),
314 IDE_AFLAG_MEDIA_CHANGED = (1 << 1),
315
316 /* ide-cd */
317 /* Drive cannot lock the door. */
318 IDE_AFLAG_NO_DOORLOCK = (1 << 2),
319 /* Drive cannot eject the disc. */
320 IDE_AFLAG_NO_EJECT = (1 << 3),
321 /* Drive is a pre ATAPI 1.2 drive. */
322 IDE_AFLAG_PRE_ATAPI12 = (1 << 4),
323 /* TOC addresses are in BCD. */
324 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5),
325 /* TOC track numbers are in BCD. */
326 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6),
327 /*
328 * Drive does not provide data in multiples of SECTOR_SIZE
329 * when more than one interrupt is needed.
330 */
331 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7),
332 /* Seeking in progress. */
333 IDE_AFLAG_SEEKING = (1 << 8),
334 /* Saved TOC information is current. */
335 IDE_AFLAG_TOC_VALID = (1 << 9),
336 /* We think that the drive door is locked. */
337 IDE_AFLAG_DOOR_LOCKED = (1 << 10),
338 /* SET_CD_SPEED command is unsupported. */
339 IDE_AFLAG_NO_SPEED_SELECT = (1 << 11),
340 IDE_AFLAG_VERTOS_300_SSD = (1 << 12),
341 IDE_AFLAG_VERTOS_600_ESD = (1 << 13),
342 IDE_AFLAG_SANYO_3CD = (1 << 14),
343 IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15),
344 IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16),
345 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17),
346
347 /* ide-floppy */
348 /* Format in progress */
349 IDE_AFLAG_FORMAT_IN_PROGRESS = (1 << 18),
350 /* Avoid commands not supported in Clik drive */
351 IDE_AFLAG_CLIK_DRIVE = (1 << 19),
352 /* Requires BH algorithm for packets */
353 IDE_AFLAG_ZIP_DRIVE = (1 << 20),
354
355 /* ide-tape */
356 IDE_AFLAG_IGNORE_DSC = (1 << 21),
357 /* 0 When the tape position is unknown */
358 IDE_AFLAG_ADDRESS_VALID = (1 << 22),
359 /* Device already opened */
360 IDE_AFLAG_BUSY = (1 << 23),
361 /* Attempt to auto-detect the current user block size */
362 IDE_AFLAG_DETECT_BS = (1 << 24),
363 /* Currently on a filemark */
364 IDE_AFLAG_FILEMARK = (1 << 25),
365 /* 0 = no tape is loaded, so we don't rewind after ejecting */
366 IDE_AFLAG_MEDIUM_PRESENT = (1 << 26)
367};
368
369struct ide_drive_s {
305 char name[4]; /* drive name, such as "hda" */ 370 char name[4]; /* drive name, such as "hda" */
306 char driver_req[10]; /* requests specific driver */ 371 char driver_req[10]; /* requests specific driver */
307 372
@@ -349,7 +414,6 @@ typedef struct ide_drive_s {
349 unsigned nodma : 1; /* disallow DMA */ 414 unsigned nodma : 1; /* disallow DMA */
350 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ 415 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
351 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ 416 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
352 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */
353 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ 417 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */
354 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ 418 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */
355 unsigned post_reset : 1; 419 unsigned post_reset : 1;
@@ -364,7 +428,6 @@ typedef struct ide_drive_s {
364 u8 wcache; /* status of write cache */ 428 u8 wcache; /* status of write cache */
365 u8 acoustic; /* acoustic management */ 429 u8 acoustic; /* acoustic management */
366 u8 media; /* disk, cdrom, tape, floppy, ... */ 430 u8 media; /* disk, cdrom, tape, floppy, ... */
367 u8 ctl; /* "normal" value for Control register */
368 u8 ready_stat; /* min status value for drive ready */ 431 u8 ready_stat; /* min status value for drive ready */
369 u8 mult_count; /* current multiple sector setting */ 432 u8 mult_count; /* current multiple sector setting */
370 u8 mult_req; /* requested multiple sector setting */ 433 u8 mult_req; /* requested multiple sector setting */
@@ -395,7 +458,14 @@ typedef struct ide_drive_s {
395 struct list_head list; 458 struct list_head list;
396 struct device gendev; 459 struct device gendev;
397 struct completion gendev_rel_comp; /* to deal with device release() */ 460 struct completion gendev_rel_comp; /* to deal with device release() */
398} ide_drive_t; 461
462 /* callback for packet commands */
463 void (*pc_callback)(struct ide_drive_s *);
464
465 unsigned long atapi_flags;
466};
467
468typedef struct ide_drive_s ide_drive_t;
399 469
400#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) 470#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
401 471
@@ -403,11 +473,31 @@ typedef struct ide_drive_s {
403 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) 473 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
404#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) 474#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
405 475
476struct ide_task_s;
406struct ide_port_info; 477struct ide_port_info;
407 478
479struct ide_tp_ops {
480 void (*exec_command)(struct hwif_s *, u8);
481 u8 (*read_status)(struct hwif_s *);
482 u8 (*read_altstatus)(struct hwif_s *);
483 u8 (*read_sff_dma_status)(struct hwif_s *);
484
485 void (*set_irq)(struct hwif_s *, int);
486
487 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
488 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
489
490 void (*input_data)(ide_drive_t *, struct request *, void *,
491 unsigned int);
492 void (*output_data)(ide_drive_t *, struct request *, void *,
493 unsigned int);
494};
495
496extern const struct ide_tp_ops default_tp_ops;
497
408struct ide_port_ops { 498struct ide_port_ops {
409 /* host specific initialization of devices on a port */ 499 /* host specific initialization of a device */
410 void (*port_init_devs)(struct hwif_s *); 500 void (*init_dev)(ide_drive_t *);
411 /* routine to program host for PIO mode */ 501 /* routine to program host for PIO mode */
412 void (*set_pio_mode)(ide_drive_t *, const u8); 502 void (*set_pio_mode)(ide_drive_t *, const u8);
413 /* routine to program host for DMA mode */ 503 /* routine to program host for DMA mode */
@@ -442,8 +532,6 @@ struct ide_dma_ops {
442 void (*dma_timeout)(struct ide_drive_s *); 532 void (*dma_timeout)(struct ide_drive_s *);
443}; 533};
444 534
445struct ide_task_s;
446
447typedef struct hwif_s { 535typedef struct hwif_s {
448 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 536 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
449 struct hwif_s *mate; /* other hwif from same PCI chip */ 537 struct hwif_s *mate; /* other hwif from same PCI chip */
@@ -481,22 +569,12 @@ typedef struct hwif_s {
481 569
482 void (*rw_disk)(ide_drive_t *, struct request *); 570 void (*rw_disk)(ide_drive_t *, struct request *);
483 571
572 const struct ide_tp_ops *tp_ops;
484 const struct ide_port_ops *port_ops; 573 const struct ide_port_ops *port_ops;
485 const struct ide_dma_ops *dma_ops; 574 const struct ide_dma_ops *dma_ops;
486 575
487 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
488 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
489
490 void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
491 void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
492
493 void (*ide_dma_clear_irq)(ide_drive_t *drive); 576 void (*ide_dma_clear_irq)(ide_drive_t *drive);
494 577
495 void (*OUTB)(u8 addr, unsigned long port);
496 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
497
498 u8 (*INB)(unsigned long port);
499
500 /* dma physical region descriptor table (cpu view) */ 578 /* dma physical region descriptor table (cpu view) */
501 unsigned int *dmatable_cpu; 579 unsigned int *dmatable_cpu;
502 /* dma physical region descriptor table (dma view) */ 580 /* dma physical region descriptor table (dma view) */
@@ -519,8 +597,6 @@ typedef struct hwif_s {
519 int irq; /* our irq number */ 597 int irq; /* our irq number */
520 598
521 unsigned long dma_base; /* base addr for dma ports */ 599 unsigned long dma_base; /* base addr for dma ports */
522 unsigned long dma_command; /* dma command register */
523 unsigned long dma_status; /* dma status register */
524 600
525 unsigned long config_data; /* for use by chipset-specific code */ 601 unsigned long config_data; /* for use by chipset-specific code */
526 unsigned long select_data; /* for use by chipset-specific code */ 602 unsigned long select_data; /* for use by chipset-specific code */
@@ -532,7 +608,6 @@ typedef struct hwif_s {
532 unsigned serialized : 1; /* serialized all channel operation */ 608 unsigned serialized : 1; /* serialized all channel operation */
533 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 609 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
534 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 610 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
535 unsigned mmio : 1; /* host uses MMIO */
536 611
537 struct device gendev; 612 struct device gendev;
538 struct device *portdev; 613 struct device *portdev;
@@ -548,6 +623,11 @@ typedef struct hwif_s {
548#endif 623#endif
549} ____cacheline_internodealigned_in_smp ide_hwif_t; 624} ____cacheline_internodealigned_in_smp ide_hwif_t;
550 625
626struct ide_host {
627 ide_hwif_t *ports[MAX_HWIFS];
628 unsigned int n_ports;
629};
630
551/* 631/*
552 * internal ide interrupt handler type 632 * internal ide interrupt handler type
553 */ 633 */
@@ -567,8 +647,6 @@ typedef struct hwgroup_s {
567 unsigned int sleeping : 1; 647 unsigned int sleeping : 1;
568 /* BOOL: polling active & poll_timeout field valid */ 648 /* BOOL: polling active & poll_timeout field valid */
569 unsigned int polling : 1; 649 unsigned int polling : 1;
570 /* BOOL: in a polling reset situation. Must not trigger another reset yet */
571 unsigned int resetting : 1;
572 650
573 /* current drive */ 651 /* current drive */
574 ide_drive_t *drive; 652 ide_drive_t *drive;
@@ -604,12 +682,11 @@ enum {
604 PC_FLAG_SUPPRESS_ERROR = (1 << 1), 682 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
605 PC_FLAG_WAIT_FOR_DSC = (1 << 2), 683 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
606 PC_FLAG_DMA_OK = (1 << 3), 684 PC_FLAG_DMA_OK = (1 << 3),
607 PC_FLAG_DMA_RECOMMENDED = (1 << 4), 685 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
608 PC_FLAG_DMA_IN_PROGRESS = (1 << 5), 686 PC_FLAG_DMA_ERROR = (1 << 5),
609 PC_FLAG_DMA_ERROR = (1 << 6), 687 PC_FLAG_WRITING = (1 << 6),
610 PC_FLAG_WRITING = (1 << 7),
611 /* command timed out */ 688 /* command timed out */
612 PC_FLAG_TIMEDOUT = (1 << 8), 689 PC_FLAG_TIMEDOUT = (1 << 7),
613}; 690};
614 691
615struct ide_atapi_pc { 692struct ide_atapi_pc {
@@ -642,8 +719,6 @@ struct ide_atapi_pc {
642 * to change/removal later. 719 * to change/removal later.
643 */ 720 */
644 u8 pc_buf[256]; 721 u8 pc_buf[256];
645 void (*idefloppy_callback) (ide_drive_t *);
646 ide_startstop_t (*idetape_callback) (ide_drive_t *);
647 722
648 /* idetape only */ 723 /* idetape only */
649 struct idetape_bh *bh; 724 struct idetape_bh *bh;
@@ -787,7 +862,6 @@ struct ide_driver_s {
787 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 862 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
788 int (*end_request)(ide_drive_t *, int, int); 863 int (*end_request)(ide_drive_t *, int, int);
789 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 864 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
790 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
791 struct device_driver gen_driver; 865 struct device_driver gen_driver;
792 int (*probe)(ide_drive_t *); 866 int (*probe)(ide_drive_t *);
793 void (*remove)(ide_drive_t *); 867 void (*remove)(ide_drive_t *);
@@ -802,32 +876,9 @@ struct ide_driver_s {
802 876
803int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 877int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
804 878
805/*
806 * ide_hwifs[] is the master data structure used to keep track
807 * of just about everything in ide.c. Whenever possible, routines
808 * should be using pointers to a drive (ide_drive_t *) or
809 * pointers to a hwif (ide_hwif_t *), rather than indexing this
810 * structure directly (the allocation/layout may change!).
811 *
812 */
813#ifndef _IDE_C
814extern ide_hwif_t ide_hwifs[]; /* master data repository */
815#endif
816extern int ide_noacpi;
817extern int ide_acpigtf;
818extern int ide_acpionboot;
819extern int noautodma;
820
821extern int ide_vlb_clk; 879extern int ide_vlb_clk;
822extern int ide_pci_clk; 880extern int ide_pci_clk;
823 881
824ide_hwif_t *ide_find_port_slot(const struct ide_port_info *);
825
826static inline ide_hwif_t *ide_find_port(void)
827{
828 return ide_find_port_slot(NULL);
829}
830
831extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 882extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
832int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 883int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
833 int uptodate, int nr_sectors); 884 int uptodate, int nr_sectors);
@@ -845,10 +896,6 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
845 896
846ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 897ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
847 898
848ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
849
850extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
851
852extern void ide_fix_driveid(struct hd_driveid *); 899extern void ide_fix_driveid(struct hd_driveid *);
853 900
854extern void ide_fixstring(u8 *, const int, const int); 901extern void ide_fixstring(u8 *, const int, const int);
@@ -857,25 +904,12 @@ int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
857 904
858extern ide_startstop_t ide_do_reset (ide_drive_t *); 905extern ide_startstop_t ide_do_reset (ide_drive_t *);
859 906
860extern void ide_init_drive_cmd (struct request *rq); 907extern void ide_do_drive_cmd(ide_drive_t *, struct request *);
861
862/*
863 * "action" parameter type for ide_do_drive_cmd() below.
864 */
865typedef enum {
866 ide_wait, /* insert rq at end of list, and wait for it */
867 ide_preempt, /* insert rq in front of current request */
868 ide_head_wait, /* insert rq in front of current request and wait for it */
869 ide_end /* insert rq at end of list, but don't wait for it */
870} ide_action_t;
871
872extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
873 908
874extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 909extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
875 910
876enum { 911enum {
877 IDE_TFLAG_LBA48 = (1 << 0), 912 IDE_TFLAG_LBA48 = (1 << 0),
878 IDE_TFLAG_NO_SELECT_MASK = (1 << 1),
879 IDE_TFLAG_FLAGGED = (1 << 2), 913 IDE_TFLAG_FLAGGED = (1 << 2),
880 IDE_TFLAG_OUT_DATA = (1 << 3), 914 IDE_TFLAG_OUT_DATA = (1 << 3),
881 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), 915 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
@@ -915,6 +949,7 @@ enum {
915 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | 949 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
916 IDE_TFLAG_IN_HOB_NSECT | 950 IDE_TFLAG_IN_HOB_NSECT |
917 IDE_TFLAG_IN_HOB_LBA, 951 IDE_TFLAG_IN_HOB_LBA,
952 IDE_TFLAG_IN_FEATURE = (1 << 1),
918 IDE_TFLAG_IN_NSECT = (1 << 25), 953 IDE_TFLAG_IN_NSECT = (1 << 25),
919 IDE_TFLAG_IN_LBAL = (1 << 26), 954 IDE_TFLAG_IN_LBAL = (1 << 26),
920 IDE_TFLAG_IN_LBAM = (1 << 27), 955 IDE_TFLAG_IN_LBAM = (1 << 27),
@@ -979,12 +1014,40 @@ typedef struct ide_task_s {
979 1014
980void ide_tf_dump(const char *, struct ide_taskfile *); 1015void ide_tf_dump(const char *, struct ide_taskfile *);
981 1016
1017void ide_exec_command(ide_hwif_t *, u8);
1018u8 ide_read_status(ide_hwif_t *);
1019u8 ide_read_altstatus(ide_hwif_t *);
1020u8 ide_read_sff_dma_status(ide_hwif_t *);
1021
1022void ide_set_irq(ide_hwif_t *, int);
1023
1024void ide_tf_load(ide_drive_t *, ide_task_t *);
1025void ide_tf_read(ide_drive_t *, ide_task_t *);
1026
1027void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
1028void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
1029
982extern void SELECT_DRIVE(ide_drive_t *); 1030extern void SELECT_DRIVE(ide_drive_t *);
1031void SELECT_MASK(ide_drive_t *, int);
1032
1033u8 ide_read_error(ide_drive_t *);
1034void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *);
983 1035
984extern int drive_is_ready(ide_drive_t *); 1036extern int drive_is_ready(ide_drive_t *);
985 1037
986void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 1038void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
987 1039
1040ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
1041 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
1042 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
1043 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
1044 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
1045 int));
1046ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *,
1047 ide_handler_t *, unsigned int, ide_expiry_t *);
1048ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
1049 ide_handler_t *, unsigned int, ide_expiry_t *);
1050
988ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1051ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
989 1052
990void task_end_request(ide_drive_t *, struct request *, u8); 1053void task_end_request(ide_drive_t *, struct request *, u8);
@@ -996,8 +1059,6 @@ int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
996int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); 1059int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
997int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); 1060int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
998 1061
999extern int system_bus_clock(void);
1000
1001extern int ide_driveid_update(ide_drive_t *); 1062extern int ide_driveid_update(ide_drive_t *);
1002extern int ide_config_drive_speed(ide_drive_t *, u8); 1063extern int ide_config_drive_speed(ide_drive_t *, u8);
1003extern u8 eighty_ninty_three (ide_drive_t *); 1064extern u8 eighty_ninty_three (ide_drive_t *);
@@ -1021,12 +1082,15 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
1021#define ide_pci_register_driver(d) pci_register_driver(d) 1082#define ide_pci_register_driver(d) pci_register_driver(d)
1022#endif 1083#endif
1023 1084
1024void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); 1085void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int,
1086 hw_regs_t *, hw_regs_t **);
1025void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1087void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1026 1088
1027#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1089#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1028int ide_pci_set_master(struct pci_dev *, const char *); 1090int ide_pci_set_master(struct pci_dev *, const char *);
1029unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); 1091unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
1092extern const struct ide_dma_ops sff_dma_ops;
1093int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *);
1030int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1094int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
1031#else 1095#else
1032static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, 1096static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
@@ -1036,10 +1100,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1036} 1100}
1037#endif 1101#endif
1038 1102
1039extern void default_hwif_iops(ide_hwif_t *);
1040extern void default_hwif_mmiops(ide_hwif_t *);
1041extern void default_hwif_transport(ide_hwif_t *);
1042
1043typedef struct ide_pci_enablebit_s { 1103typedef struct ide_pci_enablebit_s {
1044 u8 reg; /* byte pci reg holding the enable-bit */ 1104 u8 reg; /* byte pci reg holding the enable-bit */
1045 u8 mask; /* mask to isolate the enable-bit */ 1105 u8 mask; /* mask to isolate the enable-bit */
@@ -1102,7 +1162,6 @@ enum {
1102 IDE_HFLAG_IO_32BIT = (1 << 24), 1162 IDE_HFLAG_IO_32BIT = (1 << 24),
1103 /* unmask IRQs */ 1163 /* unmask IRQs */
1104 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1164 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1105 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1106 /* serialize ports if DMA is possible (for sl82c105) */ 1165 /* serialize ports if DMA is possible (for sl82c105) */
1107 IDE_HFLAG_SERIALIZE_DMA = (1 << 27), 1166 IDE_HFLAG_SERIALIZE_DMA = (1 << 27),
1108 /* force host out of "simplex" mode */ 1167 /* force host out of "simplex" mode */
@@ -1113,8 +1172,6 @@ enum {
1113 IDE_HFLAG_NO_IO_32BIT = (1 << 30), 1172 IDE_HFLAG_NO_IO_32BIT = (1 << 30),
1114 /* never unmask IRQs */ 1173 /* never unmask IRQs */
1115 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), 1174 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31),
1116 /* host uses VDMA (disabled for now) */
1117 IDE_HFLAG_VDMA = 0,
1118}; 1175};
1119 1176
1120#ifdef CONFIG_BLK_DEV_OFFBOARD 1177#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1131,6 +1188,7 @@ struct ide_port_info {
1131 int (*init_dma)(ide_hwif_t *, 1188 int (*init_dma)(ide_hwif_t *,
1132 const struct ide_port_info *); 1189 const struct ide_port_info *);
1133 1190
1191 const struct ide_tp_ops *tp_ops;
1134 const struct ide_port_ops *port_ops; 1192 const struct ide_port_ops *port_ops;
1135 const struct ide_dma_ops *dma_ops; 1193 const struct ide_dma_ops *dma_ops;
1136 1194
@@ -1184,7 +1242,6 @@ void ide_destroy_dmatable(ide_drive_t *);
1184extern int ide_build_dmatable(ide_drive_t *, struct request *); 1242extern int ide_build_dmatable(ide_drive_t *, struct request *);
1185int ide_allocate_dma_engine(ide_hwif_t *); 1243int ide_allocate_dma_engine(ide_hwif_t *);
1186void ide_release_dma_engine(ide_hwif_t *); 1244void ide_release_dma_engine(ide_hwif_t *);
1187void ide_setup_dma(ide_hwif_t *, unsigned long);
1188 1245
1189void ide_dma_host_set(ide_drive_t *, int); 1246void ide_dma_host_set(ide_drive_t *, int);
1190extern int ide_dma_setup(ide_drive_t *); 1247extern int ide_dma_setup(ide_drive_t *);
@@ -1238,8 +1295,14 @@ void ide_undecoded_slave(ide_drive_t *);
1238 1295
1239void ide_port_apply_params(ide_hwif_t *); 1296void ide_port_apply_params(ide_hwif_t *);
1240 1297
1241int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1298struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **);
1242int ide_device_add(u8 idx[4], const struct ide_port_info *); 1299struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
1300void ide_host_free(struct ide_host *);
1301int ide_host_register(struct ide_host *, const struct ide_port_info *,
1302 hw_regs_t **);
1303int ide_host_add(const struct ide_port_info *, hw_regs_t **,
1304 struct ide_host **);
1305void ide_host_remove(struct ide_host *);
1243int ide_legacy_device_add(const struct ide_port_info *, unsigned long); 1306int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
1244void ide_port_unregister_devices(ide_hwif_t *); 1307void ide_port_unregister_devices(ide_hwif_t *);
1245void ide_port_scan(ide_hwif_t *); 1308void ide_port_scan(ide_hwif_t *);
@@ -1279,16 +1342,43 @@ static inline int ide_dev_is_sata(struct hd_driveid *id)
1279u64 ide_get_lba_addr(struct ide_taskfile *, int); 1342u64 ide_get_lba_addr(struct ide_taskfile *, int);
1280u8 ide_dump_status(ide_drive_t *, const char *, u8); 1343u8 ide_dump_status(ide_drive_t *, const char *, u8);
1281 1344
1282typedef struct ide_pio_timings_s { 1345struct ide_timing {
1283 int setup_time; /* Address setup (ns) minimum */ 1346 u8 mode;
1284 int active_time; /* Active pulse (ns) minimum */ 1347 u8 setup; /* t1 */
1285 int cycle_time; /* Cycle time (ns) minimum = */ 1348 u16 act8b; /* t2 for 8-bit io */
1286 /* active + recovery (+ setup for some chips) */ 1349 u16 rec8b; /* t2i for 8-bit io */
1287} ide_pio_timings_t; 1350 u16 cyc8b; /* t0 for 8-bit io */
1351 u16 active; /* t2 or tD */
1352 u16 recover; /* t2i or tK */
1353 u16 cycle; /* t0 */
1354 u16 udma; /* t2CYCTYP/2 */
1355};
1356
1357enum {
1358 IDE_TIMING_SETUP = (1 << 0),
1359 IDE_TIMING_ACT8B = (1 << 1),
1360 IDE_TIMING_REC8B = (1 << 2),
1361 IDE_TIMING_CYC8B = (1 << 3),
1362 IDE_TIMING_8BIT = IDE_TIMING_ACT8B | IDE_TIMING_REC8B |
1363 IDE_TIMING_CYC8B,
1364 IDE_TIMING_ACTIVE = (1 << 4),
1365 IDE_TIMING_RECOVER = (1 << 5),
1366 IDE_TIMING_CYCLE = (1 << 6),
1367 IDE_TIMING_UDMA = (1 << 7),
1368 IDE_TIMING_ALL = IDE_TIMING_SETUP | IDE_TIMING_8BIT |
1369 IDE_TIMING_ACTIVE | IDE_TIMING_RECOVER |
1370 IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
1371};
1372
1373struct ide_timing *ide_timing_find_mode(u8);
1374u16 ide_pio_cycle_time(ide_drive_t *, u8);
1375void ide_timing_merge(struct ide_timing *, struct ide_timing *,
1376 struct ide_timing *, unsigned int);
1377int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1378
1379int ide_scan_pio_blacklist(char *);
1288 1380
1289unsigned int ide_pio_cycle_time(ide_drive_t *, u8);
1290u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8); 1381u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
1291extern const ide_pio_timings_t ide_pio_timings[6];
1292 1382
1293int ide_set_pio_mode(ide_drive_t *, u8); 1383int ide_set_pio_mode(ide_drive_t *, u8);
1294int ide_set_dma_mode(ide_drive_t *, u8); 1384int ide_set_dma_mode(ide_drive_t *, u8);
@@ -1344,32 +1434,4 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1344 1434
1345 return &hwif->drives[(drive->dn ^ 1) & 1]; 1435 return &hwif->drives[(drive->dn ^ 1) & 1];
1346} 1436}
1347
1348static inline void ide_set_irq(ide_drive_t *drive, int on)
1349{
1350 ide_hwif_t *hwif = drive->hwif;
1351
1352 hwif->OUTB(drive->ctl | (on ? 0 : 2), hwif->io_ports.ctl_addr);
1353}
1354
1355static inline u8 ide_read_status(ide_drive_t *drive)
1356{
1357 ide_hwif_t *hwif = drive->hwif;
1358
1359 return hwif->INB(hwif->io_ports.status_addr);
1360}
1361
1362static inline u8 ide_read_altstatus(ide_drive_t *drive)
1363{
1364 ide_hwif_t *hwif = drive->hwif;
1365
1366 return hwif->INB(hwif->io_ports.ctl_addr);
1367}
1368
1369static inline u8 ide_read_error(ide_drive_t *drive)
1370{
1371 ide_hwif_t *hwif = drive->hwif;
1372
1373 return hwif->INB(hwif->io_ports.error_addr);
1374}
1375#endif /* _IDE_H */ 1437#endif /* _IDE_H */