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.h418
1 files changed, 193 insertions, 225 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index fe235b65207e..ff65fffb078f 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -26,7 +26,7 @@
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/mutex.h> 27#include <asm/mutex.h>
28 28
29#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) 29#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
30# define SUPPORT_VLB_SYNC 0 30# define SUPPORT_VLB_SYNC 0
31#else 31#else
32# define SUPPORT_VLB_SYNC 1 32# define SUPPORT_VLB_SYNC 1
@@ -40,6 +40,13 @@
40#define ERROR_RESET 3 /* Reset controller every 4th retry */ 40#define ERROR_RESET 3 /* Reset controller every 4th retry */
41#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ 41#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
42 42
43/* Error codes returned in rq->errors to the higher part of the driver. */
44enum {
45 IDE_DRV_ERROR_GENERAL = 101,
46 IDE_DRV_ERROR_FILEMARK = 102,
47 IDE_DRV_ERROR_EOD = 103,
48};
49
43/* 50/*
44 * Definitions for accessing IDE controller registers 51 * Definitions for accessing IDE controller registers
45 */ 52 */
@@ -193,42 +200,8 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
193 hw->io_ports.ctl_addr = ctl_addr; 200 hw->io_ports.ctl_addr = ctl_addr;
194} 201}
195 202
196/* for IDE PCI controllers in legacy mode, temporary */
197static inline int __ide_default_irq(unsigned long base)
198{
199 switch (base) {
200#ifdef CONFIG_IA64
201 case 0x1f0: return isa_irq_to_vector(14);
202 case 0x170: return isa_irq_to_vector(15);
203#else
204 case 0x1f0: return 14;
205 case 0x170: return 15;
206#endif
207 }
208 return 0;
209}
210
211#if defined(CONFIG_ARM) || defined(CONFIG_FRV) || defined(CONFIG_M68K) || \
212 defined(CONFIG_MIPS) || defined(CONFIG_MN10300) || defined(CONFIG_PARISC) \
213 || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
214#include <asm/ide.h>
215#else
216#include <asm-generic/ide_iops.h>
217#endif
218
219#define MAX_HWIFS 10 203#define MAX_HWIFS 10
220 204
221/* Currently only m68k, apus and m8xx need it */
222#ifndef IDE_ARCH_ACK_INTR
223# define ide_ack_intr(hwif) (1)
224#endif
225
226/* Currently only Atari needs it */
227#ifndef IDE_ARCH_LOCK
228# define ide_release_lock() do {} while (0)
229# define ide_get_lock(hdlr, data) do {} while (0)
230#endif /* IDE_ARCH_LOCK */
231
232/* 205/*
233 * Now for the data we need to maintain per-drive: ide_drive_t 206 * Now for the data we need to maintain per-drive: ide_drive_t
234 */ 207 */
@@ -267,108 +240,92 @@ typedef enum {
267} ide_startstop_t; 240} ide_startstop_t;
268 241
269enum { 242enum {
243 IDE_VALID_ERROR = (1 << 1),
244 IDE_VALID_FEATURE = IDE_VALID_ERROR,
245 IDE_VALID_NSECT = (1 << 2),
246 IDE_VALID_LBAL = (1 << 3),
247 IDE_VALID_LBAM = (1 << 4),
248 IDE_VALID_LBAH = (1 << 5),
249 IDE_VALID_DEVICE = (1 << 6),
250 IDE_VALID_LBA = IDE_VALID_LBAL |
251 IDE_VALID_LBAM |
252 IDE_VALID_LBAH,
253 IDE_VALID_OUT_TF = IDE_VALID_FEATURE |
254 IDE_VALID_NSECT |
255 IDE_VALID_LBA,
256 IDE_VALID_IN_TF = IDE_VALID_NSECT |
257 IDE_VALID_LBA,
258 IDE_VALID_OUT_HOB = IDE_VALID_OUT_TF,
259 IDE_VALID_IN_HOB = IDE_VALID_ERROR |
260 IDE_VALID_NSECT |
261 IDE_VALID_LBA,
262};
263
264enum {
270 IDE_TFLAG_LBA48 = (1 << 0), 265 IDE_TFLAG_LBA48 = (1 << 0),
271 IDE_TFLAG_FLAGGED = (1 << 2), 266 IDE_TFLAG_WRITE = (1 << 1),
272 IDE_TFLAG_OUT_DATA = (1 << 3), 267 IDE_TFLAG_CUSTOM_HANDLER = (1 << 2),
273 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), 268 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 3),
274 IDE_TFLAG_OUT_HOB_NSECT = (1 << 5),
275 IDE_TFLAG_OUT_HOB_LBAL = (1 << 6),
276 IDE_TFLAG_OUT_HOB_LBAM = (1 << 7),
277 IDE_TFLAG_OUT_HOB_LBAH = (1 << 8),
278 IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
279 IDE_TFLAG_OUT_HOB_NSECT |
280 IDE_TFLAG_OUT_HOB_LBAL |
281 IDE_TFLAG_OUT_HOB_LBAM |
282 IDE_TFLAG_OUT_HOB_LBAH,
283 IDE_TFLAG_OUT_FEATURE = (1 << 9),
284 IDE_TFLAG_OUT_NSECT = (1 << 10),
285 IDE_TFLAG_OUT_LBAL = (1 << 11),
286 IDE_TFLAG_OUT_LBAM = (1 << 12),
287 IDE_TFLAG_OUT_LBAH = (1 << 13),
288 IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
289 IDE_TFLAG_OUT_NSECT |
290 IDE_TFLAG_OUT_LBAL |
291 IDE_TFLAG_OUT_LBAM |
292 IDE_TFLAG_OUT_LBAH,
293 IDE_TFLAG_OUT_DEVICE = (1 << 14),
294 IDE_TFLAG_WRITE = (1 << 15),
295 IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16),
296 IDE_TFLAG_IN_DATA = (1 << 17),
297 IDE_TFLAG_CUSTOM_HANDLER = (1 << 18),
298 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19),
299 IDE_TFLAG_IN_HOB_FEATURE = (1 << 20),
300 IDE_TFLAG_IN_HOB_NSECT = (1 << 21),
301 IDE_TFLAG_IN_HOB_LBAL = (1 << 22),
302 IDE_TFLAG_IN_HOB_LBAM = (1 << 23),
303 IDE_TFLAG_IN_HOB_LBAH = (1 << 24),
304 IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
305 IDE_TFLAG_IN_HOB_LBAM |
306 IDE_TFLAG_IN_HOB_LBAH,
307 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
308 IDE_TFLAG_IN_HOB_NSECT |
309 IDE_TFLAG_IN_HOB_LBA,
310 IDE_TFLAG_IN_FEATURE = (1 << 1),
311 IDE_TFLAG_IN_NSECT = (1 << 25),
312 IDE_TFLAG_IN_LBAL = (1 << 26),
313 IDE_TFLAG_IN_LBAM = (1 << 27),
314 IDE_TFLAG_IN_LBAH = (1 << 28),
315 IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
316 IDE_TFLAG_IN_LBAM |
317 IDE_TFLAG_IN_LBAH,
318 IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
319 IDE_TFLAG_IN_LBA,
320 IDE_TFLAG_IN_DEVICE = (1 << 29),
321 IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB |
322 IDE_TFLAG_IN_HOB,
323 IDE_TFLAG_TF = IDE_TFLAG_OUT_TF |
324 IDE_TFLAG_IN_TF,
325 IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE |
326 IDE_TFLAG_IN_DEVICE,
327 /* force 16-bit I/O operations */ 269 /* force 16-bit I/O operations */
328 IDE_TFLAG_IO_16BIT = (1 << 30), 270 IDE_TFLAG_IO_16BIT = (1 << 4),
329 /* ide_task_t was allocated using kmalloc() */ 271 /* struct ide_cmd was allocated using kmalloc() */
330 IDE_TFLAG_DYN = (1 << 31), 272 IDE_TFLAG_DYN = (1 << 5),
273 IDE_TFLAG_FS = (1 << 6),
274 IDE_TFLAG_MULTI_PIO = (1 << 7),
331}; 275};
332 276
333struct ide_taskfile { 277enum {
334 u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ 278 IDE_FTFLAG_FLAGGED = (1 << 0),
279 IDE_FTFLAG_SET_IN_FLAGS = (1 << 1),
280 IDE_FTFLAG_OUT_DATA = (1 << 2),
281 IDE_FTFLAG_IN_DATA = (1 << 3),
282};
335 283
336 u8 hob_feature; /* 1-5: additional data to support LBA48 */ 284struct ide_taskfile {
337 u8 hob_nsect; 285 u8 data; /* 0: data byte (for TASKFILE ioctl) */
338 u8 hob_lbal; 286 union { /* 1: */
339 u8 hob_lbam; 287 u8 error; /* read: error */
340 u8 hob_lbah; 288 u8 feature; /* write: feature */
289 };
290 u8 nsect; /* 2: number of sectors */
291 u8 lbal; /* 3: LBA low */
292 u8 lbam; /* 4: LBA mid */
293 u8 lbah; /* 5: LBA high */
294 u8 device; /* 6: device select */
295 union { /* 7: */
296 u8 status; /* read: status */
297 u8 command; /* write: command */
298 };
299};
341 300
342 u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ 301struct ide_cmd {
302 struct ide_taskfile tf;
303 struct ide_taskfile hob;
304 struct {
305 struct {
306 u8 tf;
307 u8 hob;
308 } out, in;
309 } valid;
343 310
344 union { /*  7: */ 311 u8 tf_flags;
345 u8 error; /* read: error */ 312 u8 ftf_flags; /* for TASKFILE ioctl */
346 u8 feature; /* write: feature */ 313 int protocol;
347 };
348 314
349 u8 nsect; /* 8: number of sectors */ 315 int sg_nents; /* number of sg entries */
350 u8 lbal; /* 9: LBA low */ 316 int orig_sg_nents;
351 u8 lbam; /* 10: LBA mid */ 317 int sg_dma_direction; /* DMA transfer direction */
352 u8 lbah; /* 11: LBA high */
353 318
354 u8 device; /* 12: device select */ 319 unsigned int nbytes;
320 unsigned int nleft;
321 unsigned int last_xfer_len;
355 322
356 union { /* 13: */ 323 struct scatterlist *cursg;
357 u8 status; /*  read: status  */ 324 unsigned int cursg_ofs;
358 u8 command; /* write: command */
359 };
360};
361 325
362typedef struct ide_task_s {
363 union {
364 struct ide_taskfile tf;
365 u8 tf_array[14];
366 };
367 u32 tf_flags;
368 int data_phase;
369 struct request *rq; /* copy of request */ 326 struct request *rq; /* copy of request */
370 void *special; /* valid_t generally */ 327 void *special; /* valid_t generally */
371} ide_task_t; 328};
372 329
373/* ATAPI packet command flags */ 330/* ATAPI packet command flags */
374enum { 331enum {
@@ -380,15 +337,13 @@ enum {
380 PC_FLAG_DMA_IN_PROGRESS = (1 << 4), 337 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
381 PC_FLAG_DMA_ERROR = (1 << 5), 338 PC_FLAG_DMA_ERROR = (1 << 5),
382 PC_FLAG_WRITING = (1 << 6), 339 PC_FLAG_WRITING = (1 << 6),
383 /* command timed out */
384 PC_FLAG_TIMEDOUT = (1 << 7),
385}; 340};
386 341
387/* 342/*
388 * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. 343 * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes.
389 * This is used for several packet commands (not for READ/WRITE commands). 344 * This is used for several packet commands (not for READ/WRITE commands).
390 */ 345 */
391#define IDE_PC_BUFFER_SIZE 256 346#define IDE_PC_BUFFER_SIZE 64
392#define ATAPI_WAIT_PC (60 * HZ) 347#define ATAPI_WAIT_PC (60 * HZ)
393 348
394struct ide_atapi_pc { 349struct ide_atapi_pc {
@@ -426,9 +381,6 @@ struct ide_atapi_pc {
426 struct idetape_bh *bh; 381 struct idetape_bh *bh;
427 char *b_data; 382 char *b_data;
428 383
429 struct scatterlist *sg;
430 unsigned int sg_cnt;
431
432 unsigned long timeout; 384 unsigned long timeout;
433}; 385};
434 386
@@ -452,7 +404,6 @@ struct ide_disk_ops {
452 int); 404 int);
453 ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *, 405 ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *,
454 sector_t); 406 sector_t);
455 int (*end_request)(struct ide_drive_s *, int, int);
456 int (*ioctl)(struct ide_drive_s *, struct block_device *, 407 int (*ioctl)(struct ide_drive_s *, struct block_device *,
457 fmode_t, unsigned int, unsigned long); 408 fmode_t, unsigned int, unsigned long);
458}; 409};
@@ -470,11 +421,6 @@ enum {
470 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3), 421 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3),
471 /* TOC track numbers are in BCD. */ 422 /* TOC track numbers are in BCD. */
472 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4), 423 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4),
473 /*
474 * Drive does not provide data in multiples of SECTOR_SIZE
475 * when more than one interrupt is needed.
476 */
477 IDE_AFLAG_LIMIT_NFRAMES = (1 << 5),
478 /* Saved TOC information is current. */ 424 /* Saved TOC information is current. */
479 IDE_AFLAG_TOC_VALID = (1 << 6), 425 IDE_AFLAG_TOC_VALID = (1 << 6),
480 /* We think that the drive door is locked. */ 426 /* We think that the drive door is locked. */
@@ -528,8 +474,6 @@ enum {
528 IDE_DFLAG_NICE1 = (1 << 5), 474 IDE_DFLAG_NICE1 = (1 << 5),
529 /* device is physically present */ 475 /* device is physically present */
530 IDE_DFLAG_PRESENT = (1 << 6), 476 IDE_DFLAG_PRESENT = (1 << 6),
531 /* device ejected hint */
532 IDE_DFLAG_DEAD = (1 << 7),
533 /* id read from device (synthetic if not set) */ 477 /* id read from device (synthetic if not set) */
534 IDE_DFLAG_ID_READ = (1 << 8), 478 IDE_DFLAG_ID_READ = (1 << 8),
535 IDE_DFLAG_NOPROBE = (1 << 9), 479 IDE_DFLAG_NOPROBE = (1 << 9),
@@ -621,7 +565,7 @@ struct ide_drive_s {
621 565
622 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 566 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
623 unsigned int cyl; /* "real" number of cyls */ 567 unsigned int cyl; /* "real" number of cyls */
624 unsigned int drive_data; /* used by set_pio_mode/selectproc */ 568 unsigned int drive_data; /* used by set_pio_mode/dev_select() */
625 unsigned int failures; /* current failure count */ 569 unsigned int failures; /* current failure count */
626 unsigned int max_failures; /* maximum allowed failure count */ 570 unsigned int max_failures; /* maximum allowed failure count */
627 u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */ 571 u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */
@@ -643,8 +587,11 @@ struct ide_drive_s {
643 /* current packet command */ 587 /* current packet command */
644 struct ide_atapi_pc *pc; 588 struct ide_atapi_pc *pc;
645 589
590 /* last failed packet command */
591 struct ide_atapi_pc *failed_pc;
592
646 /* callback for packet commands */ 593 /* callback for packet commands */
647 void (*pc_callback)(struct ide_drive_s *, int); 594 int (*pc_callback)(struct ide_drive_s *, int);
648 595
649 void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *); 596 void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *);
650 int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, 597 int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *,
@@ -674,16 +621,16 @@ struct ide_tp_ops {
674 void (*exec_command)(struct hwif_s *, u8); 621 void (*exec_command)(struct hwif_s *, u8);
675 u8 (*read_status)(struct hwif_s *); 622 u8 (*read_status)(struct hwif_s *);
676 u8 (*read_altstatus)(struct hwif_s *); 623 u8 (*read_altstatus)(struct hwif_s *);
624 void (*write_devctl)(struct hwif_s *, u8);
677 625
678 void (*set_irq)(struct hwif_s *, int); 626 void (*dev_select)(ide_drive_t *);
679 627 void (*tf_load)(ide_drive_t *, struct ide_taskfile *, u8);
680 void (*tf_load)(ide_drive_t *, struct ide_task_s *); 628 void (*tf_read)(ide_drive_t *, struct ide_taskfile *, u8);
681 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
682 629
683 void (*input_data)(ide_drive_t *, struct request *, void *, 630 void (*input_data)(ide_drive_t *, struct ide_cmd *,
684 unsigned int); 631 void *, unsigned int);
685 void (*output_data)(ide_drive_t *, struct request *, void *, 632 void (*output_data)(ide_drive_t *, struct ide_cmd *,
686 unsigned int); 633 void *, unsigned int);
687}; 634};
688 635
689extern const struct ide_tp_ops default_tp_ops; 636extern const struct ide_tp_ops default_tp_ops;
@@ -694,7 +641,6 @@ extern const struct ide_tp_ops default_tp_ops;
694 * @init_dev: host specific initialization of a device 641 * @init_dev: host specific initialization of a device
695 * @set_pio_mode: routine to program host for PIO mode 642 * @set_pio_mode: routine to program host for PIO mode
696 * @set_dma_mode: routine to program host for DMA mode 643 * @set_dma_mode: routine to program host for DMA mode
697 * @selectproc: tweaks hardware to select drive
698 * @reset_poll: chipset polling based on hba specifics 644 * @reset_poll: chipset polling based on hba specifics
699 * @pre_reset: chipset specific changes to default for device-hba resets 645 * @pre_reset: chipset specific changes to default for device-hba resets
700 * @resetproc: routine to reset controller after a disk reset 646 * @resetproc: routine to reset controller after a disk reset
@@ -711,7 +657,6 @@ struct ide_port_ops {
711 void (*init_dev)(ide_drive_t *); 657 void (*init_dev)(ide_drive_t *);
712 void (*set_pio_mode)(ide_drive_t *, const u8); 658 void (*set_pio_mode)(ide_drive_t *, const u8);
713 void (*set_dma_mode)(ide_drive_t *, const u8); 659 void (*set_dma_mode)(ide_drive_t *, const u8);
714 void (*selectproc)(ide_drive_t *);
715 int (*reset_poll)(ide_drive_t *); 660 int (*reset_poll)(ide_drive_t *);
716 void (*pre_reset)(ide_drive_t *); 661 void (*pre_reset)(ide_drive_t *);
717 void (*resetproc)(ide_drive_t *); 662 void (*resetproc)(ide_drive_t *);
@@ -727,13 +672,15 @@ struct ide_port_ops {
727 672
728struct ide_dma_ops { 673struct ide_dma_ops {
729 void (*dma_host_set)(struct ide_drive_s *, int); 674 void (*dma_host_set)(struct ide_drive_s *, int);
730 int (*dma_setup)(struct ide_drive_s *); 675 int (*dma_setup)(struct ide_drive_s *, struct ide_cmd *);
731 void (*dma_exec_cmd)(struct ide_drive_s *, u8);
732 void (*dma_start)(struct ide_drive_s *); 676 void (*dma_start)(struct ide_drive_s *);
733 int (*dma_end)(struct ide_drive_s *); 677 int (*dma_end)(struct ide_drive_s *);
734 int (*dma_test_irq)(struct ide_drive_s *); 678 int (*dma_test_irq)(struct ide_drive_s *);
735 void (*dma_lost_irq)(struct ide_drive_s *); 679 void (*dma_lost_irq)(struct ide_drive_s *);
736 void (*dma_timeout)(struct ide_drive_s *); 680 /* below ones are optional */
681 int (*dma_check)(struct ide_drive_s *, struct ide_cmd *);
682 int (*dma_timer_expiry)(struct ide_drive_s *);
683 void (*dma_clear)(struct ide_drive_s *);
737 /* 684 /*
738 * The following method is optional and only required to be 685 * The following method is optional and only required to be
739 * implemented for the SFF-8038i compatible controllers. 686 * implemented for the SFF-8038i compatible controllers.
@@ -796,18 +743,8 @@ typedef struct hwif_s {
796 /* Scatter-gather list used to build the above */ 743 /* Scatter-gather list used to build the above */
797 struct scatterlist *sg_table; 744 struct scatterlist *sg_table;
798 int sg_max_nents; /* Maximum number of entries in it */ 745 int sg_max_nents; /* Maximum number of entries in it */
799 int sg_nents; /* Current number of entries in it */
800 int sg_dma_direction; /* dma transfer direction */
801 746
802 /* data phase of the active command (currently only valid for PIO/DMA) */ 747 struct ide_cmd cmd; /* current command */
803 int data_phase;
804
805 struct ide_task_s task; /* current command */
806
807 unsigned int nsect;
808 unsigned int nleft;
809 struct scatterlist *cursg;
810 unsigned int cursg_ofs;
811 748
812 int rqsize; /* max sectors per request */ 749 int rqsize; /* max sectors per request */
813 int irq; /* our irq number */ 750 int irq; /* our irq number */
@@ -865,8 +802,18 @@ struct ide_host {
865 ide_hwif_t *ports[MAX_HOST_PORTS + 1]; 802 ide_hwif_t *ports[MAX_HOST_PORTS + 1];
866 unsigned int n_ports; 803 unsigned int n_ports;
867 struct device *dev[2]; 804 struct device *dev[2];
868 unsigned int (*init_chipset)(struct pci_dev *); 805
806 int (*init_chipset)(struct pci_dev *);
807
808 void (*get_lock)(irq_handler_t, void *);
809 void (*release_lock)(void);
810
811 irq_handler_t irq_handler;
812
869 unsigned long host_flags; 813 unsigned long host_flags;
814
815 int irq_flags;
816
870 void *host_priv; 817 void *host_priv;
871 ide_hwif_t *cur_port; /* for hosts requiring serialization */ 818 ide_hwif_t *cur_port; /* for hosts requiring serialization */
872 819
@@ -883,7 +830,7 @@ typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
883typedef int (ide_expiry_t)(ide_drive_t *); 830typedef int (ide_expiry_t)(ide_drive_t *);
884 831
885/* used by ide-cd, ide-floppy, etc. */ 832/* used by ide-cd, ide-floppy, etc. */
886typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); 833typedef void (xfer_func_t)(ide_drive_t *, struct ide_cmd *, void *, unsigned);
887 834
888extern struct mutex ide_setting_mtx; 835extern struct mutex ide_setting_mtx;
889 836
@@ -1059,10 +1006,11 @@ enum {
1059}; 1006};
1060 1007
1061/* DRV_NAME has to be defined in the driver before using the macro below */ 1008/* DRV_NAME has to be defined in the driver before using the macro below */
1062#define __ide_debug_log(lvl, fmt, args...) \ 1009#define __ide_debug_log(lvl, fmt, args...) \
1063{ \ 1010{ \
1064 if (unlikely(drive->debug_mask & lvl)) \ 1011 if (unlikely(drive->debug_mask & lvl)) \
1065 printk(KERN_INFO DRV_NAME ": " fmt, ## args); \ 1012 printk(KERN_INFO DRV_NAME ": %s: " fmt "\n", \
1013 __func__, ## args); \
1066} 1014}
1067 1015
1068/* 1016/*
@@ -1101,7 +1049,7 @@ int generic_ide_resume(struct device *);
1101 1049
1102void ide_complete_power_step(ide_drive_t *, struct request *); 1050void ide_complete_power_step(ide_drive_t *, struct request *);
1103ide_startstop_t ide_start_power_step(ide_drive_t *, struct request *); 1051ide_startstop_t ide_start_power_step(ide_drive_t *, struct request *);
1104void ide_complete_pm_request(ide_drive_t *, struct request *); 1052void ide_complete_pm_rq(ide_drive_t *, struct request *);
1105void ide_check_pm_state(ide_drive_t *, struct request *); 1053void ide_check_pm_state(ide_drive_t *, struct request *);
1106 1054
1107/* 1055/*
@@ -1113,7 +1061,6 @@ void ide_check_pm_state(ide_drive_t *, struct request *);
1113struct ide_driver { 1061struct ide_driver {
1114 const char *version; 1062 const char *version;
1115 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 1063 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
1116 int (*end_request)(ide_drive_t *, int, int);
1117 struct device_driver gen_driver; 1064 struct device_driver gen_driver;
1118 int (*probe)(ide_drive_t *); 1065 int (*probe)(ide_drive_t *);
1119 void (*remove)(ide_drive_t *); 1066 void (*remove)(ide_drive_t *);
@@ -1144,16 +1091,15 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l
1144extern int ide_vlb_clk; 1091extern int ide_vlb_clk;
1145extern int ide_pci_clk; 1092extern int ide_pci_clk;
1146 1093
1147extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 1094unsigned int ide_rq_bytes(struct request *);
1148int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 1095int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int);
1149 int uptodate, int nr_sectors); 1096void ide_kill_rq(ide_drive_t *, struct request *);
1150 1097
1151extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry); 1098void __ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int);
1099void ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int);
1152 1100
1153void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int, 1101void ide_execute_command(ide_drive_t *, struct ide_cmd *, ide_handler_t *,
1154 ide_expiry_t *); 1102 unsigned int);
1155
1156void ide_execute_pkt_cmd(ide_drive_t *);
1157 1103
1158void ide_pad_transfer(ide_drive_t *, int, int); 1104void ide_pad_transfer(ide_drive_t *, int, int);
1159 1105
@@ -1167,41 +1113,37 @@ int ide_busy_sleep(ide_hwif_t *, unsigned long, int);
1167 1113
1168int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 1114int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
1169 1115
1116ide_startstop_t ide_do_park_unpark(ide_drive_t *, struct request *);
1117ide_startstop_t ide_do_devset(ide_drive_t *, struct request *);
1118
1170extern ide_startstop_t ide_do_reset (ide_drive_t *); 1119extern ide_startstop_t ide_do_reset (ide_drive_t *);
1171 1120
1172extern int ide_devset_execute(ide_drive_t *drive, 1121extern int ide_devset_execute(ide_drive_t *drive,
1173 const struct ide_devset *setting, int arg); 1122 const struct ide_devset *setting, int arg);
1174 1123
1175extern void ide_do_drive_cmd(ide_drive_t *, struct request *); 1124void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8);
1125int ide_complete_rq(ide_drive_t *, int, unsigned int);
1176 1126
1177extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 1127void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd);
1178 1128void ide_tf_dump(const char *, struct ide_cmd *);
1179void ide_tf_dump(const char *, struct ide_taskfile *);
1180 1129
1181void ide_exec_command(ide_hwif_t *, u8); 1130void ide_exec_command(ide_hwif_t *, u8);
1182u8 ide_read_status(ide_hwif_t *); 1131u8 ide_read_status(ide_hwif_t *);
1183u8 ide_read_altstatus(ide_hwif_t *); 1132u8 ide_read_altstatus(ide_hwif_t *);
1133void ide_write_devctl(ide_hwif_t *, u8);
1184 1134
1185void ide_set_irq(ide_hwif_t *, int); 1135void ide_dev_select(ide_drive_t *);
1186 1136void ide_tf_load(ide_drive_t *, struct ide_taskfile *, u8);
1187void ide_tf_load(ide_drive_t *, ide_task_t *); 1137void ide_tf_read(ide_drive_t *, struct ide_taskfile *, u8);
1188void ide_tf_read(ide_drive_t *, ide_task_t *);
1189 1138
1190void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); 1139void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
1191void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); 1140void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
1192 1141
1193int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int);
1194
1195extern void SELECT_DRIVE(ide_drive_t *);
1196void SELECT_MASK(ide_drive_t *, int); 1142void SELECT_MASK(ide_drive_t *, int);
1197 1143
1198u8 ide_read_error(ide_drive_t *); 1144u8 ide_read_error(ide_drive_t *);
1199void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *); 1145void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *);
1200 1146
1201extern int drive_is_ready(ide_drive_t *);
1202
1203void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
1204
1205int ide_check_atapi_device(ide_drive_t *, const char *); 1147int ide_check_atapi_device(ide_drive_t *, const char *);
1206 1148
1207void ide_init_pc(struct ide_atapi_pc *); 1149void ide_init_pc(struct ide_atapi_pc *);
@@ -1238,16 +1180,20 @@ int ide_cd_expiry(ide_drive_t *);
1238 1180
1239int ide_cd_get_xferlen(struct request *); 1181int ide_cd_get_xferlen(struct request *);
1240 1182
1241ide_startstop_t ide_issue_pc(ide_drive_t *); 1183ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_cmd *);
1184
1185ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *);
1242 1186
1243ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1187void ide_pio_bytes(ide_drive_t *, struct ide_cmd *, unsigned int, unsigned int);
1244 1188
1245void task_end_request(ide_drive_t *, struct request *, u8); 1189void ide_finish_cmd(ide_drive_t *, struct ide_cmd *, u8);
1246 1190
1247int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); 1191int ide_raw_taskfile(ide_drive_t *, struct ide_cmd *, u8 *, u16);
1248int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); 1192int ide_no_data_taskfile(ide_drive_t *, struct ide_cmd *);
1249 1193
1250int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); 1194int ide_taskfile_ioctl(ide_drive_t *, unsigned long);
1195
1196int ide_dev_read_id(ide_drive_t *, u8, u16 *);
1251 1197
1252extern int ide_driveid_update(ide_drive_t *); 1198extern int ide_driveid_update(ide_drive_t *);
1253extern int ide_config_drive_speed(ide_drive_t *, u8); 1199extern int ide_config_drive_speed(ide_drive_t *, u8);
@@ -1278,7 +1224,7 @@ static inline int ide_pci_is_in_compatibility_mode(struct pci_dev *dev)
1278 return 0; 1224 return 0;
1279} 1225}
1280 1226
1281void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, 1227void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *,
1282 hw_regs_t *, hw_regs_t **); 1228 hw_regs_t *, hw_regs_t **);
1283void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1229void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1284 1230
@@ -1347,10 +1293,10 @@ enum {
1347 IDE_HFLAG_ERROR_STOPS_FIFO = (1 << 19), 1293 IDE_HFLAG_ERROR_STOPS_FIFO = (1 << 19),
1348 /* serialize ports */ 1294 /* serialize ports */
1349 IDE_HFLAG_SERIALIZE = (1 << 20), 1295 IDE_HFLAG_SERIALIZE = (1 << 20),
1350 /* use legacy IRQs */ 1296 /* host is DTC2278 */
1351 IDE_HFLAG_LEGACY_IRQS = (1 << 21), 1297 IDE_HFLAG_DTC2278 = (1 << 21),
1352 /* force use of legacy IRQs */ 1298 /* 4 devices on a single set of I/O ports */
1353 IDE_HFLAG_FORCE_LEGACY_IRQS = (1 << 22), 1299 IDE_HFLAG_4DRIVES = (1 << 22),
1354 /* host is TRM290 */ 1300 /* host is TRM290 */
1355 IDE_HFLAG_TRM290 = (1 << 23), 1301 IDE_HFLAG_TRM290 = (1 << 23),
1356 /* use 32-bit I/O ops */ 1302 /* use 32-bit I/O ops */
@@ -1378,7 +1324,12 @@ enum {
1378 1324
1379struct ide_port_info { 1325struct ide_port_info {
1380 char *name; 1326 char *name;
1381 unsigned int (*init_chipset)(struct pci_dev *); 1327
1328 int (*init_chipset)(struct pci_dev *);
1329
1330 void (*get_lock)(irq_handler_t, void *);
1331 void (*release_lock)(void);
1332
1382 void (*init_iops)(ide_hwif_t *); 1333 void (*init_iops)(ide_hwif_t *);
1383 void (*init_hwif)(ide_hwif_t *); 1334 void (*init_hwif)(ide_hwif_t *);
1384 int (*init_dma)(ide_hwif_t *, 1335 int (*init_dma)(ide_hwif_t *,
@@ -1395,6 +1346,9 @@ struct ide_port_info {
1395 u16 max_sectors; /* if < than the default one */ 1346 u16 max_sectors; /* if < than the default one */
1396 1347
1397 u32 host_flags; 1348 u32 host_flags;
1349
1350 int irq_flags;
1351
1398 u8 pio_mask; 1352 u8 pio_mask;
1399 u8 swdma_mask; 1353 u8 swdma_mask;
1400 u8 mwdma_mask; 1354 u8 mwdma_mask;
@@ -1414,8 +1368,8 @@ int ide_pci_resume(struct pci_dev *);
1414#define ide_pci_resume NULL 1368#define ide_pci_resume NULL
1415#endif 1369#endif
1416 1370
1417void ide_map_sg(ide_drive_t *, struct request *); 1371void ide_map_sg(ide_drive_t *, struct ide_cmd *);
1418void ide_init_sg_cmd(ide_drive_t *, struct request *); 1372void ide_init_sg_cmd(struct ide_cmd *, unsigned int);
1419 1373
1420#define BAD_DMA_DRIVE 0 1374#define BAD_DMA_DRIVE 0
1421#define GOOD_DMA_DRIVE 1 1375#define GOOD_DMA_DRIVE 1
@@ -1449,18 +1403,18 @@ ide_startstop_t ide_dma_intr(ide_drive_t *);
1449int ide_allocate_dma_engine(ide_hwif_t *); 1403int ide_allocate_dma_engine(ide_hwif_t *);
1450void ide_release_dma_engine(ide_hwif_t *); 1404void ide_release_dma_engine(ide_hwif_t *);
1451 1405
1452int ide_build_sglist(ide_drive_t *, struct request *); 1406int ide_dma_prepare(ide_drive_t *, struct ide_cmd *);
1453void ide_destroy_dmatable(ide_drive_t *); 1407void ide_dma_unmap_sg(ide_drive_t *, struct ide_cmd *);
1454 1408
1455#ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1409#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
1456int config_drive_for_dma(ide_drive_t *); 1410int config_drive_for_dma(ide_drive_t *);
1457extern int ide_build_dmatable(ide_drive_t *, struct request *); 1411int ide_build_dmatable(ide_drive_t *, struct ide_cmd *);
1458void ide_dma_host_set(ide_drive_t *, int); 1412void ide_dma_host_set(ide_drive_t *, int);
1459extern int ide_dma_setup(ide_drive_t *); 1413int ide_dma_setup(ide_drive_t *, struct ide_cmd *);
1460void ide_dma_exec_cmd(ide_drive_t *, u8);
1461extern void ide_dma_start(ide_drive_t *); 1414extern void ide_dma_start(ide_drive_t *);
1462int ide_dma_end(ide_drive_t *); 1415int ide_dma_end(ide_drive_t *);
1463int ide_dma_test_irq(ide_drive_t *); 1416int ide_dma_test_irq(ide_drive_t *);
1417int ide_dma_sff_timer_expiry(ide_drive_t *);
1464u8 ide_dma_sff_read_status(ide_hwif_t *); 1418u8 ide_dma_sff_read_status(ide_hwif_t *);
1465extern const struct ide_dma_ops sff_dma_ops; 1419extern const struct ide_dma_ops sff_dma_ops;
1466#else 1420#else
@@ -1468,7 +1422,7 @@ static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
1468#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 1422#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */
1469 1423
1470void ide_dma_lost_irq(ide_drive_t *); 1424void ide_dma_lost_irq(ide_drive_t *);
1471void ide_dma_timeout(ide_drive_t *); 1425ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int);
1472 1426
1473#else 1427#else
1474static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } 1428static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }
@@ -1480,21 +1434,29 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; }
1480static inline void ide_dma_verbose(ide_drive_t *drive) { ; } 1434static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1481static inline int ide_set_dma(ide_drive_t *drive) { return 1; } 1435static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
1482static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } 1436static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1437static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
1438static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
1483static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1439static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
1440static inline int ide_dma_prepare(ide_drive_t *drive,
1441 struct ide_cmd *cmd) { return 1; }
1442static inline void ide_dma_unmap_sg(ide_drive_t *drive,
1443 struct ide_cmd *cmd) { ; }
1484#endif /* CONFIG_BLK_DEV_IDEDMA */ 1444#endif /* CONFIG_BLK_DEV_IDEDMA */
1485 1445
1486#ifdef CONFIG_BLK_DEV_IDEACPI 1446#ifdef CONFIG_BLK_DEV_IDEACPI
1447int ide_acpi_init(void);
1487extern int ide_acpi_exec_tfs(ide_drive_t *drive); 1448extern int ide_acpi_exec_tfs(ide_drive_t *drive);
1488extern void ide_acpi_get_timing(ide_hwif_t *hwif); 1449extern void ide_acpi_get_timing(ide_hwif_t *hwif);
1489extern void ide_acpi_push_timing(ide_hwif_t *hwif); 1450extern void ide_acpi_push_timing(ide_hwif_t *hwif);
1490extern void ide_acpi_init(ide_hwif_t *hwif); 1451void ide_acpi_init_port(ide_hwif_t *);
1491void ide_acpi_port_init_devices(ide_hwif_t *); 1452void ide_acpi_port_init_devices(ide_hwif_t *);
1492extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); 1453extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
1493#else 1454#else
1455static inline int ide_acpi_init(void) { return 0; }
1494static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } 1456static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
1495static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } 1457static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
1496static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } 1458static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
1497static inline void ide_acpi_init(ide_hwif_t *hwif) { ; } 1459static inline void ide_acpi_init_port(ide_hwif_t *hwif) { ; }
1498static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; } 1460static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; }
1499static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} 1461static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
1500#endif 1462#endif
@@ -1528,11 +1490,9 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
1528 hwif->hwif_data = data; 1490 hwif->hwif_data = data;
1529} 1491}
1530 1492
1531const char *ide_xfer_verbose(u8 mode);
1532extern void ide_toggle_bounce(ide_drive_t *drive, int on); 1493extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1533extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1534 1494
1535u64 ide_get_lba_addr(struct ide_taskfile *, int); 1495u64 ide_get_lba_addr(struct ide_cmd *, int);
1536u8 ide_dump_status(ide_drive_t *, const char *, u8); 1496u8 ide_dump_status(ide_drive_t *, const char *, u8);
1537 1497
1538struct ide_timing { 1498struct ide_timing {
@@ -1569,14 +1529,18 @@ void ide_timing_merge(struct ide_timing *, struct ide_timing *,
1569 struct ide_timing *, unsigned int); 1529 struct ide_timing *, unsigned int);
1570int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int); 1530int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1571 1531
1532#ifdef CONFIG_IDE_XFER_MODE
1572int ide_scan_pio_blacklist(char *); 1533int ide_scan_pio_blacklist(char *);
1573 1534const char *ide_xfer_verbose(u8);
1574u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8); 1535u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
1575
1576int ide_set_pio_mode(ide_drive_t *, u8); 1536int ide_set_pio_mode(ide_drive_t *, u8);
1577int ide_set_dma_mode(ide_drive_t *, u8); 1537int ide_set_dma_mode(ide_drive_t *, u8);
1578
1579void ide_set_pio(ide_drive_t *, u8); 1538void ide_set_pio(ide_drive_t *, u8);
1539int ide_set_xfer_rate(ide_drive_t *, u8);
1540#else
1541static inline void ide_set_pio(ide_drive_t *drive, u8 pio) { ; }
1542static inline int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) { return -1; }
1543#endif
1580 1544
1581static inline void ide_set_max_pio(ide_drive_t *drive) 1545static inline void ide_set_max_pio(ide_drive_t *drive)
1582{ 1546{
@@ -1609,6 +1573,10 @@ static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
1609#define ide_port_for_each_dev(i, dev, port) \ 1573#define ide_port_for_each_dev(i, dev, port) \
1610 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) 1574 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
1611 1575
1576#define ide_port_for_each_present_dev(i, dev, port) \
1577 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) \
1578 if ((dev)->dev_flags & IDE_DFLAG_PRESENT)
1579
1612#define ide_host_for_each_port(i, port, host) \ 1580#define ide_host_for_each_port(i, port, host) \
1613 for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++) 1581 for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++)
1614 1582