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.h353
1 files changed, 228 insertions, 125 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9918772bf274..b846bc44a27e 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);
@@ -189,7 +196,36 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
189 hw->io_ports.ctl_addr = ctl_addr; 196 hw->io_ports.ctl_addr = ctl_addr;
190} 197}
191 198
199/* for IDE PCI controllers in legacy mode, temporary */
200static inline int __ide_default_irq(unsigned long base)
201{
202 switch (base) {
203#ifdef CONFIG_IA64
204 case 0x1f0: return isa_irq_to_vector(14);
205 case 0x170: return isa_irq_to_vector(15);
206#else
207 case 0x1f0: return 14;
208 case 0x170: return 15;
209#endif
210 }
211 return 0;
212}
213
214#if defined(CONFIG_ARM) || defined(CONFIG_FRV) || defined(CONFIG_M68K) || \
215 defined(CONFIG_MIPS) || defined(CONFIG_MN10300) || defined(CONFIG_PARISC) \
216 || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
192#include <asm/ide.h> 217#include <asm/ide.h>
218#else
219#include <asm-generic/ide_iops.h>
220#endif
221
222#ifndef MAX_HWIFS
223#if defined(CONFIG_BLACKFIN) || defined(CONFIG_H8300) || defined(CONFIG_XTENSA)
224# define MAX_HWIFS 1
225#else
226# define MAX_HWIFS 10
227#endif
228#endif
193 229
194#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED) 230#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED)
195#undef MAX_HWIFS 231#undef MAX_HWIFS
@@ -286,7 +322,65 @@ struct ide_acpi_drive_link;
286struct ide_acpi_hwif_link; 322struct ide_acpi_hwif_link;
287#endif 323#endif
288 324
289typedef struct ide_drive_s { 325/* ATAPI device flags */
326enum {
327 IDE_AFLAG_DRQ_INTERRUPT = (1 << 0),
328 IDE_AFLAG_MEDIA_CHANGED = (1 << 1),
329
330 /* ide-cd */
331 /* Drive cannot lock the door. */
332 IDE_AFLAG_NO_DOORLOCK = (1 << 2),
333 /* Drive cannot eject the disc. */
334 IDE_AFLAG_NO_EJECT = (1 << 3),
335 /* Drive is a pre ATAPI 1.2 drive. */
336 IDE_AFLAG_PRE_ATAPI12 = (1 << 4),
337 /* TOC addresses are in BCD. */
338 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5),
339 /* TOC track numbers are in BCD. */
340 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6),
341 /*
342 * Drive does not provide data in multiples of SECTOR_SIZE
343 * when more than one interrupt is needed.
344 */
345 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7),
346 /* Seeking in progress. */
347 IDE_AFLAG_SEEKING = (1 << 8),
348 /* Saved TOC information is current. */
349 IDE_AFLAG_TOC_VALID = (1 << 9),
350 /* We think that the drive door is locked. */
351 IDE_AFLAG_DOOR_LOCKED = (1 << 10),
352 /* SET_CD_SPEED command is unsupported. */
353 IDE_AFLAG_NO_SPEED_SELECT = (1 << 11),
354 IDE_AFLAG_VERTOS_300_SSD = (1 << 12),
355 IDE_AFLAG_VERTOS_600_ESD = (1 << 13),
356 IDE_AFLAG_SANYO_3CD = (1 << 14),
357 IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15),
358 IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16),
359 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17),
360
361 /* ide-floppy */
362 /* Format in progress */
363 IDE_AFLAG_FORMAT_IN_PROGRESS = (1 << 18),
364 /* Avoid commands not supported in Clik drive */
365 IDE_AFLAG_CLIK_DRIVE = (1 << 19),
366 /* Requires BH algorithm for packets */
367 IDE_AFLAG_ZIP_DRIVE = (1 << 20),
368
369 /* ide-tape */
370 IDE_AFLAG_IGNORE_DSC = (1 << 21),
371 /* 0 When the tape position is unknown */
372 IDE_AFLAG_ADDRESS_VALID = (1 << 22),
373 /* Device already opened */
374 IDE_AFLAG_BUSY = (1 << 23),
375 /* Attempt to auto-detect the current user block size */
376 IDE_AFLAG_DETECT_BS = (1 << 24),
377 /* Currently on a filemark */
378 IDE_AFLAG_FILEMARK = (1 << 25),
379 /* 0 = no tape is loaded, so we don't rewind after ejecting */
380 IDE_AFLAG_MEDIUM_PRESENT = (1 << 26)
381};
382
383struct ide_drive_s {
290 char name[4]; /* drive name, such as "hda" */ 384 char name[4]; /* drive name, such as "hda" */
291 char driver_req[10]; /* requests specific driver */ 385 char driver_req[10]; /* requests specific driver */
292 386
@@ -334,7 +428,6 @@ typedef struct ide_drive_s {
334 unsigned nodma : 1; /* disallow DMA */ 428 unsigned nodma : 1; /* disallow DMA */
335 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ 429 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
336 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ 430 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
337 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */
338 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ 431 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */
339 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ 432 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */
340 unsigned post_reset : 1; 433 unsigned post_reset : 1;
@@ -349,7 +442,6 @@ typedef struct ide_drive_s {
349 u8 wcache; /* status of write cache */ 442 u8 wcache; /* status of write cache */
350 u8 acoustic; /* acoustic management */ 443 u8 acoustic; /* acoustic management */
351 u8 media; /* disk, cdrom, tape, floppy, ... */ 444 u8 media; /* disk, cdrom, tape, floppy, ... */
352 u8 ctl; /* "normal" value for Control register */
353 u8 ready_stat; /* min status value for drive ready */ 445 u8 ready_stat; /* min status value for drive ready */
354 u8 mult_count; /* current multiple sector setting */ 446 u8 mult_count; /* current multiple sector setting */
355 u8 mult_req; /* requested multiple sector setting */ 447 u8 mult_req; /* requested multiple sector setting */
@@ -380,7 +472,14 @@ typedef struct ide_drive_s {
380 struct list_head list; 472 struct list_head list;
381 struct device gendev; 473 struct device gendev;
382 struct completion gendev_rel_comp; /* to deal with device release() */ 474 struct completion gendev_rel_comp; /* to deal with device release() */
383} ide_drive_t; 475
476 /* callback for packet commands */
477 void (*pc_callback)(struct ide_drive_s *);
478
479 unsigned long atapi_flags;
480};
481
482typedef struct ide_drive_s ide_drive_t;
384 483
385#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) 484#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
386 485
@@ -388,11 +487,31 @@ typedef struct ide_drive_s {
388 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) 487 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
389#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) 488#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
390 489
490struct ide_task_s;
391struct ide_port_info; 491struct ide_port_info;
392 492
493struct ide_tp_ops {
494 void (*exec_command)(struct hwif_s *, u8);
495 u8 (*read_status)(struct hwif_s *);
496 u8 (*read_altstatus)(struct hwif_s *);
497 u8 (*read_sff_dma_status)(struct hwif_s *);
498
499 void (*set_irq)(struct hwif_s *, int);
500
501 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
502 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
503
504 void (*input_data)(ide_drive_t *, struct request *, void *,
505 unsigned int);
506 void (*output_data)(ide_drive_t *, struct request *, void *,
507 unsigned int);
508};
509
510extern const struct ide_tp_ops default_tp_ops;
511
393struct ide_port_ops { 512struct ide_port_ops {
394 /* host specific initialization of devices on a port */ 513 /* host specific initialization of a device */
395 void (*port_init_devs)(struct hwif_s *); 514 void (*init_dev)(ide_drive_t *);
396 /* routine to program host for PIO mode */ 515 /* routine to program host for PIO mode */
397 void (*set_pio_mode)(ide_drive_t *, const u8); 516 void (*set_pio_mode)(ide_drive_t *, const u8);
398 /* routine to program host for DMA mode */ 517 /* routine to program host for DMA mode */
@@ -427,7 +546,7 @@ struct ide_dma_ops {
427 void (*dma_timeout)(struct ide_drive_s *); 546 void (*dma_timeout)(struct ide_drive_s *);
428}; 547};
429 548
430struct ide_task_s; 549struct ide_host;
431 550
432typedef struct hwif_s { 551typedef struct hwif_s {
433 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 552 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
@@ -435,6 +554,8 @@ typedef struct hwif_s {
435 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ 554 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
436 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 555 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
437 556
557 struct ide_host *host;
558
438 char name[6]; /* name of interface, eg. "ide0" */ 559 char name[6]; /* name of interface, eg. "ide0" */
439 560
440 struct ide_io_ports io_ports; 561 struct ide_io_ports io_ports;
@@ -466,22 +587,12 @@ typedef struct hwif_s {
466 587
467 void (*rw_disk)(ide_drive_t *, struct request *); 588 void (*rw_disk)(ide_drive_t *, struct request *);
468 589
590 const struct ide_tp_ops *tp_ops;
469 const struct ide_port_ops *port_ops; 591 const struct ide_port_ops *port_ops;
470 const struct ide_dma_ops *dma_ops; 592 const struct ide_dma_ops *dma_ops;
471 593
472 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
473 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
474
475 void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
476 void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
477
478 void (*ide_dma_clear_irq)(ide_drive_t *drive); 594 void (*ide_dma_clear_irq)(ide_drive_t *drive);
479 595
480 void (*OUTB)(u8 addr, unsigned long port);
481 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
482
483 u8 (*INB)(unsigned long port);
484
485 /* dma physical region descriptor table (cpu view) */ 596 /* dma physical region descriptor table (cpu view) */
486 unsigned int *dmatable_cpu; 597 unsigned int *dmatable_cpu;
487 /* dma physical region descriptor table (dma view) */ 598 /* dma physical region descriptor table (dma view) */
@@ -504,8 +615,6 @@ typedef struct hwif_s {
504 int irq; /* our irq number */ 615 int irq; /* our irq number */
505 616
506 unsigned long dma_base; /* base addr for dma ports */ 617 unsigned long dma_base; /* base addr for dma ports */
507 unsigned long dma_command; /* dma command register */
508 unsigned long dma_status; /* dma status register */
509 618
510 unsigned long config_data; /* for use by chipset-specific code */ 619 unsigned long config_data; /* for use by chipset-specific code */
511 unsigned long select_data; /* for use by chipset-specific code */ 620 unsigned long select_data; /* for use by chipset-specific code */
@@ -517,7 +626,6 @@ typedef struct hwif_s {
517 unsigned serialized : 1; /* serialized all channel operation */ 626 unsigned serialized : 1; /* serialized all channel operation */
518 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 627 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
519 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 628 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
520 unsigned mmio : 1; /* host uses MMIO */
521 629
522 struct device gendev; 630 struct device gendev;
523 struct device *portdev; 631 struct device *portdev;
@@ -533,6 +641,14 @@ typedef struct hwif_s {
533#endif 641#endif
534} ____cacheline_internodealigned_in_smp ide_hwif_t; 642} ____cacheline_internodealigned_in_smp ide_hwif_t;
535 643
644struct ide_host {
645 ide_hwif_t *ports[MAX_HWIFS];
646 unsigned int n_ports;
647 struct device *dev[2];
648 unsigned long host_flags;
649 void *host_priv;
650};
651
536/* 652/*
537 * internal ide interrupt handler type 653 * internal ide interrupt handler type
538 */ 654 */
@@ -552,8 +668,6 @@ typedef struct hwgroup_s {
552 unsigned int sleeping : 1; 668 unsigned int sleeping : 1;
553 /* BOOL: polling active & poll_timeout field valid */ 669 /* BOOL: polling active & poll_timeout field valid */
554 unsigned int polling : 1; 670 unsigned int polling : 1;
555 /* BOOL: in a polling reset situation. Must not trigger another reset yet */
556 unsigned int resetting : 1;
557 671
558 /* current drive */ 672 /* current drive */
559 ide_drive_t *drive; 673 ide_drive_t *drive;
@@ -589,12 +703,11 @@ enum {
589 PC_FLAG_SUPPRESS_ERROR = (1 << 1), 703 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
590 PC_FLAG_WAIT_FOR_DSC = (1 << 2), 704 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
591 PC_FLAG_DMA_OK = (1 << 3), 705 PC_FLAG_DMA_OK = (1 << 3),
592 PC_FLAG_DMA_RECOMMENDED = (1 << 4), 706 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
593 PC_FLAG_DMA_IN_PROGRESS = (1 << 5), 707 PC_FLAG_DMA_ERROR = (1 << 5),
594 PC_FLAG_DMA_ERROR = (1 << 6), 708 PC_FLAG_WRITING = (1 << 6),
595 PC_FLAG_WRITING = (1 << 7),
596 /* command timed out */ 709 /* command timed out */
597 PC_FLAG_TIMEDOUT = (1 << 8), 710 PC_FLAG_TIMEDOUT = (1 << 7),
598}; 711};
599 712
600struct ide_atapi_pc { 713struct ide_atapi_pc {
@@ -627,8 +740,6 @@ struct ide_atapi_pc {
627 * to change/removal later. 740 * to change/removal later.
628 */ 741 */
629 u8 pc_buf[256]; 742 u8 pc_buf[256];
630 void (*idefloppy_callback) (ide_drive_t *);
631 ide_startstop_t (*idetape_callback) (ide_drive_t *);
632 743
633 /* idetape only */ 744 /* idetape only */
634 struct idetape_bh *bh; 745 struct idetape_bh *bh;
@@ -772,7 +883,6 @@ struct ide_driver_s {
772 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 883 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
773 int (*end_request)(ide_drive_t *, int, int); 884 int (*end_request)(ide_drive_t *, int, int);
774 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 885 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
775 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
776 struct device_driver gen_driver; 886 struct device_driver gen_driver;
777 int (*probe)(ide_drive_t *); 887 int (*probe)(ide_drive_t *);
778 void (*remove)(ide_drive_t *); 888 void (*remove)(ide_drive_t *);
@@ -785,34 +895,14 @@ struct ide_driver_s {
785 895
786#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 896#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
787 897
788int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 898int ide_device_get(ide_drive_t *);
899void ide_device_put(ide_drive_t *);
789 900
790/* 901int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
791 * ide_hwifs[] is the master data structure used to keep track
792 * of just about everything in ide.c. Whenever possible, routines
793 * should be using pointers to a drive (ide_drive_t *) or
794 * pointers to a hwif (ide_hwif_t *), rather than indexing this
795 * structure directly (the allocation/layout may change!).
796 *
797 */
798#ifndef _IDE_C
799extern ide_hwif_t ide_hwifs[]; /* master data repository */
800#endif
801extern int ide_noacpi;
802extern int ide_acpigtf;
803extern int ide_acpionboot;
804extern int noautodma;
805 902
806extern int ide_vlb_clk; 903extern int ide_vlb_clk;
807extern int ide_pci_clk; 904extern int ide_pci_clk;
808 905
809ide_hwif_t *ide_find_port_slot(const struct ide_port_info *);
810
811static inline ide_hwif_t *ide_find_port(void)
812{
813 return ide_find_port_slot(NULL);
814}
815
816extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 906extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
817int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 907int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
818 int uptodate, int nr_sectors); 908 int uptodate, int nr_sectors);
@@ -830,10 +920,6 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
830 920
831ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 921ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
832 922
833ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
834
835extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
836
837extern void ide_fix_driveid(struct hd_driveid *); 923extern void ide_fix_driveid(struct hd_driveid *);
838 924
839extern void ide_fixstring(u8 *, const int, const int); 925extern void ide_fixstring(u8 *, const int, const int);
@@ -842,25 +928,12 @@ int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
842 928
843extern ide_startstop_t ide_do_reset (ide_drive_t *); 929extern ide_startstop_t ide_do_reset (ide_drive_t *);
844 930
845extern void ide_init_drive_cmd (struct request *rq); 931extern void ide_do_drive_cmd(ide_drive_t *, struct request *);
846
847/*
848 * "action" parameter type for ide_do_drive_cmd() below.
849 */
850typedef enum {
851 ide_wait, /* insert rq at end of list, and wait for it */
852 ide_preempt, /* insert rq in front of current request */
853 ide_head_wait, /* insert rq in front of current request and wait for it */
854 ide_end /* insert rq at end of list, but don't wait for it */
855} ide_action_t;
856
857extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
858 932
859extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 933extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
860 934
861enum { 935enum {
862 IDE_TFLAG_LBA48 = (1 << 0), 936 IDE_TFLAG_LBA48 = (1 << 0),
863 IDE_TFLAG_NO_SELECT_MASK = (1 << 1),
864 IDE_TFLAG_FLAGGED = (1 << 2), 937 IDE_TFLAG_FLAGGED = (1 << 2),
865 IDE_TFLAG_OUT_DATA = (1 << 3), 938 IDE_TFLAG_OUT_DATA = (1 << 3),
866 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), 939 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
@@ -900,6 +973,7 @@ enum {
900 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | 973 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
901 IDE_TFLAG_IN_HOB_NSECT | 974 IDE_TFLAG_IN_HOB_NSECT |
902 IDE_TFLAG_IN_HOB_LBA, 975 IDE_TFLAG_IN_HOB_LBA,
976 IDE_TFLAG_IN_FEATURE = (1 << 1),
903 IDE_TFLAG_IN_NSECT = (1 << 25), 977 IDE_TFLAG_IN_NSECT = (1 << 25),
904 IDE_TFLAG_IN_LBAL = (1 << 26), 978 IDE_TFLAG_IN_LBAL = (1 << 26),
905 IDE_TFLAG_IN_LBAM = (1 << 27), 979 IDE_TFLAG_IN_LBAM = (1 << 27),
@@ -964,12 +1038,40 @@ typedef struct ide_task_s {
964 1038
965void ide_tf_dump(const char *, struct ide_taskfile *); 1039void ide_tf_dump(const char *, struct ide_taskfile *);
966 1040
1041void ide_exec_command(ide_hwif_t *, u8);
1042u8 ide_read_status(ide_hwif_t *);
1043u8 ide_read_altstatus(ide_hwif_t *);
1044u8 ide_read_sff_dma_status(ide_hwif_t *);
1045
1046void ide_set_irq(ide_hwif_t *, int);
1047
1048void ide_tf_load(ide_drive_t *, ide_task_t *);
1049void ide_tf_read(ide_drive_t *, ide_task_t *);
1050
1051void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
1052void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
1053
967extern void SELECT_DRIVE(ide_drive_t *); 1054extern void SELECT_DRIVE(ide_drive_t *);
1055void SELECT_MASK(ide_drive_t *, int);
1056
1057u8 ide_read_error(ide_drive_t *);
1058void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *);
968 1059
969extern int drive_is_ready(ide_drive_t *); 1060extern int drive_is_ready(ide_drive_t *);
970 1061
971void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 1062void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
972 1063
1064ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
1065 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
1066 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
1067 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
1068 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
1069 int));
1070ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *,
1071 ide_handler_t *, unsigned int, ide_expiry_t *);
1072ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
1073 ide_handler_t *, unsigned int, ide_expiry_t *);
1074
973ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1075ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
974 1076
975void task_end_request(ide_drive_t *, struct request *, u8); 1077void task_end_request(ide_drive_t *, struct request *, u8);
@@ -981,8 +1083,6 @@ int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
981int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); 1083int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
982int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); 1084int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
983 1085
984extern int system_bus_clock(void);
985
986extern int ide_driveid_update(ide_drive_t *); 1086extern int ide_driveid_update(ide_drive_t *);
987extern int ide_config_drive_speed(ide_drive_t *, u8); 1087extern int ide_config_drive_speed(ide_drive_t *, u8);
988extern u8 eighty_ninty_three (ide_drive_t *); 1088extern u8 eighty_ninty_three (ide_drive_t *);
@@ -1006,12 +1106,15 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
1006#define ide_pci_register_driver(d) pci_register_driver(d) 1106#define ide_pci_register_driver(d) pci_register_driver(d)
1007#endif 1107#endif
1008 1108
1009void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); 1109void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int,
1110 hw_regs_t *, hw_regs_t **);
1010void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1111void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1011 1112
1012#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1113#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1013int ide_pci_set_master(struct pci_dev *, const char *); 1114int ide_pci_set_master(struct pci_dev *, const char *);
1014unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); 1115unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
1116extern const struct ide_dma_ops sff_dma_ops;
1117int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *);
1015int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1118int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
1016#else 1119#else
1017static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, 1120static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
@@ -1021,10 +1124,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1021} 1124}
1022#endif 1125#endif
1023 1126
1024extern void default_hwif_iops(ide_hwif_t *);
1025extern void default_hwif_mmiops(ide_hwif_t *);
1026extern void default_hwif_transport(ide_hwif_t *);
1027
1028typedef struct ide_pci_enablebit_s { 1127typedef struct ide_pci_enablebit_s {
1029 u8 reg; /* byte pci reg holding the enable-bit */ 1128 u8 reg; /* byte pci reg holding the enable-bit */
1030 u8 mask; /* mask to isolate the enable-bit */ 1129 u8 mask; /* mask to isolate the enable-bit */
@@ -1087,7 +1186,6 @@ enum {
1087 IDE_HFLAG_IO_32BIT = (1 << 24), 1186 IDE_HFLAG_IO_32BIT = (1 << 24),
1088 /* unmask IRQs */ 1187 /* unmask IRQs */
1089 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1188 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1090 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1091 /* serialize ports if DMA is possible (for sl82c105) */ 1189 /* serialize ports if DMA is possible (for sl82c105) */
1092 IDE_HFLAG_SERIALIZE_DMA = (1 << 27), 1190 IDE_HFLAG_SERIALIZE_DMA = (1 << 27),
1093 /* force host out of "simplex" mode */ 1191 /* force host out of "simplex" mode */
@@ -1098,8 +1196,6 @@ enum {
1098 IDE_HFLAG_NO_IO_32BIT = (1 << 30), 1196 IDE_HFLAG_NO_IO_32BIT = (1 << 30),
1099 /* never unmask IRQs */ 1197 /* never unmask IRQs */
1100 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), 1198 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31),
1101 /* host uses VDMA (disabled for now) */
1102 IDE_HFLAG_VDMA = 0,
1103}; 1199};
1104 1200
1105#ifdef CONFIG_BLK_DEV_OFFBOARD 1201#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1110,12 +1206,13 @@ enum {
1110 1206
1111struct ide_port_info { 1207struct ide_port_info {
1112 char *name; 1208 char *name;
1113 unsigned int (*init_chipset)(struct pci_dev *, const char *); 1209 unsigned int (*init_chipset)(struct pci_dev *);
1114 void (*init_iops)(ide_hwif_t *); 1210 void (*init_iops)(ide_hwif_t *);
1115 void (*init_hwif)(ide_hwif_t *); 1211 void (*init_hwif)(ide_hwif_t *);
1116 int (*init_dma)(ide_hwif_t *, 1212 int (*init_dma)(ide_hwif_t *,
1117 const struct ide_port_info *); 1213 const struct ide_port_info *);
1118 1214
1215 const struct ide_tp_ops *tp_ops;
1119 const struct ide_port_ops *port_ops; 1216 const struct ide_port_ops *port_ops;
1120 const struct ide_dma_ops *dma_ops; 1217 const struct ide_dma_ops *dma_ops;
1121 1218
@@ -1128,8 +1225,10 @@ struct ide_port_info {
1128 u8 udma_mask; 1225 u8 udma_mask;
1129}; 1226};
1130 1227
1131int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *); 1228int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
1132int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *); 1229int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
1230 const struct ide_port_info *, void *);
1231void ide_pci_remove(struct pci_dev *);
1133 1232
1134void ide_map_sg(ide_drive_t *, struct request *); 1233void ide_map_sg(ide_drive_t *, struct request *);
1135void ide_init_sg_cmd(ide_drive_t *, struct request *); 1234void ide_init_sg_cmd(ide_drive_t *, struct request *);
@@ -1169,7 +1268,6 @@ void ide_destroy_dmatable(ide_drive_t *);
1169extern int ide_build_dmatable(ide_drive_t *, struct request *); 1268extern int ide_build_dmatable(ide_drive_t *, struct request *);
1170int ide_allocate_dma_engine(ide_hwif_t *); 1269int ide_allocate_dma_engine(ide_hwif_t *);
1171void ide_release_dma_engine(ide_hwif_t *); 1270void ide_release_dma_engine(ide_hwif_t *);
1172void ide_setup_dma(ide_hwif_t *, unsigned long);
1173 1271
1174void ide_dma_host_set(ide_drive_t *, int); 1272void ide_dma_host_set(ide_drive_t *, int);
1175extern int ide_dma_setup(ide_drive_t *); 1273extern int ide_dma_setup(ide_drive_t *);
@@ -1223,8 +1321,14 @@ void ide_undecoded_slave(ide_drive_t *);
1223 1321
1224void ide_port_apply_params(ide_hwif_t *); 1322void ide_port_apply_params(ide_hwif_t *);
1225 1323
1226int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1324struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **);
1227int ide_device_add(u8 idx[4], const struct ide_port_info *); 1325struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
1326void ide_host_free(struct ide_host *);
1327int ide_host_register(struct ide_host *, const struct ide_port_info *,
1328 hw_regs_t **);
1329int ide_host_add(const struct ide_port_info *, hw_regs_t **,
1330 struct ide_host **);
1331void ide_host_remove(struct ide_host *);
1228int ide_legacy_device_add(const struct ide_port_info *, unsigned long); 1332int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
1229void ide_port_unregister_devices(ide_hwif_t *); 1333void ide_port_unregister_devices(ide_hwif_t *);
1230void ide_port_scan(ide_hwif_t *); 1334void ide_port_scan(ide_hwif_t *);
@@ -1264,16 +1368,43 @@ static inline int ide_dev_is_sata(struct hd_driveid *id)
1264u64 ide_get_lba_addr(struct ide_taskfile *, int); 1368u64 ide_get_lba_addr(struct ide_taskfile *, int);
1265u8 ide_dump_status(ide_drive_t *, const char *, u8); 1369u8 ide_dump_status(ide_drive_t *, const char *, u8);
1266 1370
1267typedef struct ide_pio_timings_s { 1371struct ide_timing {
1268 int setup_time; /* Address setup (ns) minimum */ 1372 u8 mode;
1269 int active_time; /* Active pulse (ns) minimum */ 1373 u8 setup; /* t1 */
1270 int cycle_time; /* Cycle time (ns) minimum = */ 1374 u16 act8b; /* t2 for 8-bit io */
1271 /* active + recovery (+ setup for some chips) */ 1375 u16 rec8b; /* t2i for 8-bit io */
1272} ide_pio_timings_t; 1376 u16 cyc8b; /* t0 for 8-bit io */
1377 u16 active; /* t2 or tD */
1378 u16 recover; /* t2i or tK */
1379 u16 cycle; /* t0 */
1380 u16 udma; /* t2CYCTYP/2 */
1381};
1382
1383enum {
1384 IDE_TIMING_SETUP = (1 << 0),
1385 IDE_TIMING_ACT8B = (1 << 1),
1386 IDE_TIMING_REC8B = (1 << 2),
1387 IDE_TIMING_CYC8B = (1 << 3),
1388 IDE_TIMING_8BIT = IDE_TIMING_ACT8B | IDE_TIMING_REC8B |
1389 IDE_TIMING_CYC8B,
1390 IDE_TIMING_ACTIVE = (1 << 4),
1391 IDE_TIMING_RECOVER = (1 << 5),
1392 IDE_TIMING_CYCLE = (1 << 6),
1393 IDE_TIMING_UDMA = (1 << 7),
1394 IDE_TIMING_ALL = IDE_TIMING_SETUP | IDE_TIMING_8BIT |
1395 IDE_TIMING_ACTIVE | IDE_TIMING_RECOVER |
1396 IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
1397};
1398
1399struct ide_timing *ide_timing_find_mode(u8);
1400u16 ide_pio_cycle_time(ide_drive_t *, u8);
1401void ide_timing_merge(struct ide_timing *, struct ide_timing *,
1402 struct ide_timing *, unsigned int);
1403int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1404
1405int ide_scan_pio_blacklist(char *);
1273 1406
1274unsigned int ide_pio_cycle_time(ide_drive_t *, u8);
1275u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8); 1407u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
1276extern const ide_pio_timings_t ide_pio_timings[6];
1277 1408
1278int ide_set_pio_mode(ide_drive_t *, u8); 1409int ide_set_pio_mode(ide_drive_t *, u8);
1279int ide_set_dma_mode(ide_drive_t *, u8); 1410int ide_set_dma_mode(ide_drive_t *, u8);
@@ -1329,32 +1460,4 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1329 1460
1330 return &hwif->drives[(drive->dn ^ 1) & 1]; 1461 return &hwif->drives[(drive->dn ^ 1) & 1];
1331} 1462}
1332
1333static inline void ide_set_irq(ide_drive_t *drive, int on)
1334{
1335 ide_hwif_t *hwif = drive->hwif;
1336
1337 hwif->OUTB(drive->ctl | (on ? 0 : 2), hwif->io_ports.ctl_addr);
1338}
1339
1340static inline u8 ide_read_status(ide_drive_t *drive)
1341{
1342 ide_hwif_t *hwif = drive->hwif;
1343
1344 return hwif->INB(hwif->io_ports.status_addr);
1345}
1346
1347static inline u8 ide_read_altstatus(ide_drive_t *drive)
1348{
1349 ide_hwif_t *hwif = drive->hwif;
1350
1351 return hwif->INB(hwif->io_ports.ctl_addr);
1352}
1353
1354static inline u8 ide_read_error(ide_drive_t *drive)
1355{
1356 ide_hwif_t *hwif = drive->hwif;
1357
1358 return hwif->INB(hwif->io_ports.error_addr);
1359}
1360#endif /* _IDE_H */ 1463#endif /* _IDE_H */