diff options
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r-- | include/linux/ide.h | 906 |
1 files changed, 533 insertions, 373 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index 87c12ed96954..c47e371554c1 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/ioport.h> | 10 | #include <linux/ioport.h> |
11 | #include <linux/hdreg.h> | 11 | #include <linux/ata.h> |
12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
13 | #include <linux/proc_fs.h> | 13 | #include <linux/proc_fs.h> |
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | #include <linux/completion.h> | 19 | #include <linux/completion.h> |
20 | #include <linux/pm.h> | ||
20 | #ifdef CONFIG_BLK_DEV_IDEACPI | 21 | #ifdef CONFIG_BLK_DEV_IDEACPI |
21 | #include <acpi/acpi.h> | 22 | #include <acpi/acpi.h> |
22 | #endif | 23 | #endif |
@@ -47,12 +48,6 @@ typedef unsigned char byte; /* used everywhere */ | |||
47 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ | 48 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ |
48 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ | 49 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ |
49 | 50 | ||
50 | /* | ||
51 | * state flags | ||
52 | */ | ||
53 | |||
54 | #define DMA_PIO_RETRY 1 /* retrying in PIO */ | ||
55 | |||
56 | #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) | 51 | #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) |
57 | #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) | 52 | #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) |
58 | 53 | ||
@@ -87,12 +82,13 @@ struct ide_io_ports { | |||
87 | }; | 82 | }; |
88 | 83 | ||
89 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) | 84 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) |
90 | #define BAD_R_STAT (BUSY_STAT | ERR_STAT) | ||
91 | #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT) | ||
92 | #define BAD_STAT (BAD_R_STAT | DRQ_STAT) | ||
93 | #define DRIVE_READY (READY_STAT | SEEK_STAT) | ||
94 | 85 | ||
95 | #define BAD_CRC (ABRT_ERR | ICRC_ERR) | 86 | #define BAD_R_STAT (ATA_BUSY | ATA_ERR) |
87 | #define BAD_W_STAT (BAD_R_STAT | ATA_DF) | ||
88 | #define BAD_STAT (BAD_R_STAT | ATA_DRQ) | ||
89 | #define DRIVE_READY (ATA_DRDY | ATA_DSC) | ||
90 | |||
91 | #define BAD_CRC (ATA_ABORTED | ATA_ICRC) | ||
96 | 92 | ||
97 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ | 93 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ |
98 | 94 | ||
@@ -125,24 +121,43 @@ struct ide_io_ports { | |||
125 | #define PARTN_BITS 6 /* number of minor dev bits for partitions */ | 121 | #define PARTN_BITS 6 /* number of minor dev bits for partitions */ |
126 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ | 122 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ |
127 | #define SECTOR_SIZE 512 | 123 | #define SECTOR_SIZE 512 |
128 | #define SECTOR_WORDS (SECTOR_SIZE / 4) /* number of 32bit words per sector */ | 124 | |
129 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) | 125 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) |
130 | 126 | ||
131 | /* | 127 | /* |
132 | * Timeouts for various operations: | 128 | * Timeouts for various operations: |
133 | */ | 129 | */ |
134 | #define WAIT_DRQ (HZ/10) /* 100msec - spec allows up to 20ms */ | 130 | enum { |
135 | #define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */ | 131 | /* spec allows up to 20ms */ |
136 | #define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?), if all ATAPI CD is closed at boot */ | 132 | WAIT_DRQ = HZ / 10, /* 100ms */ |
137 | #define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */ | 133 | /* some laptops are very slow */ |
138 | #define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */ | 134 | WAIT_READY = 5 * HZ, /* 5s */ |
139 | #define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ | 135 | /* should be less than 3ms (?), if all ATAPI CD is closed at boot */ |
136 | WAIT_PIDENTIFY = 10 * HZ, /* 10s */ | ||
137 | /* worst case when spinning up */ | ||
138 | WAIT_WORSTCASE = 30 * HZ, /* 30s */ | ||
139 | /* maximum wait for an IRQ to happen */ | ||
140 | WAIT_CMD = 10 * HZ, /* 10s */ | ||
141 | /* Some drives require a longer IRQ timeout. */ | ||
142 | WAIT_FLOPPY_CMD = 50 * HZ, /* 50s */ | ||
143 | /* | ||
144 | * Some drives (for example, Seagate STT3401A Travan) require a very | ||
145 | * long timeout, because they don't return an interrupt or clear their | ||
146 | * BSY bit until after the command completes (even retension commands). | ||
147 | */ | ||
148 | WAIT_TAPE_CMD = 900 * HZ, /* 900s */ | ||
149 | /* minimum sleep time */ | ||
150 | WAIT_MIN_SLEEP = HZ / 50, /* 20ms */ | ||
151 | }; | ||
140 | 152 | ||
141 | /* | 153 | /* |
142 | * Op codes for special requests to be handled by ide_special_rq(). | 154 | * Op codes for special requests to be handled by ide_special_rq(). |
143 | * Values should be in the range of 0x20 to 0x3f. | 155 | * Values should be in the range of 0x20 to 0x3f. |
144 | */ | 156 | */ |
145 | #define REQ_DRIVE_RESET 0x20 | 157 | #define REQ_DRIVE_RESET 0x20 |
158 | #define REQ_DEVSET_EXEC 0x21 | ||
159 | #define REQ_PARK_HEADS 0x22 | ||
160 | #define REQ_UNPARK_HEADS 0x23 | ||
146 | 161 | ||
147 | /* | 162 | /* |
148 | * Check for an interrupt and acknowledge the interrupt status | 163 | * Check for an interrupt and acknowledge the interrupt status |
@@ -249,8 +264,6 @@ static inline int __ide_default_irq(unsigned long base) | |||
249 | * set_geometry : respecify drive geometry | 264 | * set_geometry : respecify drive geometry |
250 | * recalibrate : seek to cyl 0 | 265 | * recalibrate : seek to cyl 0 |
251 | * set_multmode : set multmode count | 266 | * set_multmode : set multmode count |
252 | * set_tune : tune interface for drive | ||
253 | * serviced : service command | ||
254 | * reserved : unused | 267 | * reserved : unused |
255 | */ | 268 | */ |
256 | typedef union { | 269 | typedef union { |
@@ -259,43 +272,11 @@ typedef union { | |||
259 | unsigned set_geometry : 1; | 272 | unsigned set_geometry : 1; |
260 | unsigned recalibrate : 1; | 273 | unsigned recalibrate : 1; |
261 | unsigned set_multmode : 1; | 274 | unsigned set_multmode : 1; |
262 | unsigned set_tune : 1; | 275 | unsigned reserved : 5; |
263 | unsigned serviced : 1; | ||
264 | unsigned reserved : 3; | ||
265 | } b; | 276 | } b; |
266 | } special_t; | 277 | } special_t; |
267 | 278 | ||
268 | /* | 279 | /* |
269 | * ATA-IDE Select Register, aka Device-Head | ||
270 | * | ||
271 | * head : always zeros here | ||
272 | * unit : drive select number: 0/1 | ||
273 | * bit5 : always 1 | ||
274 | * lba : using LBA instead of CHS | ||
275 | * bit7 : always 1 | ||
276 | */ | ||
277 | typedef union { | ||
278 | unsigned all : 8; | ||
279 | struct { | ||
280 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
281 | unsigned head : 4; | ||
282 | unsigned unit : 1; | ||
283 | unsigned bit5 : 1; | ||
284 | unsigned lba : 1; | ||
285 | unsigned bit7 : 1; | ||
286 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
287 | unsigned bit7 : 1; | ||
288 | unsigned lba : 1; | ||
289 | unsigned bit5 : 1; | ||
290 | unsigned unit : 1; | ||
291 | unsigned head : 4; | ||
292 | #else | ||
293 | #error "Please fix <asm/byteorder.h>" | ||
294 | #endif | ||
295 | } b; | ||
296 | } select_t, ata_select_t; | ||
297 | |||
298 | /* | ||
299 | * Status returned from various ide_ functions | 280 | * Status returned from various ide_ functions |
300 | */ | 281 | */ |
301 | typedef enum { | 282 | typedef enum { |
@@ -303,8 +284,177 @@ typedef enum { | |||
303 | ide_started, /* a drive operation was started, handler was set */ | 284 | ide_started, /* a drive operation was started, handler was set */ |
304 | } ide_startstop_t; | 285 | } ide_startstop_t; |
305 | 286 | ||
287 | enum { | ||
288 | IDE_TFLAG_LBA48 = (1 << 0), | ||
289 | IDE_TFLAG_FLAGGED = (1 << 2), | ||
290 | IDE_TFLAG_OUT_DATA = (1 << 3), | ||
291 | IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), | ||
292 | IDE_TFLAG_OUT_HOB_NSECT = (1 << 5), | ||
293 | IDE_TFLAG_OUT_HOB_LBAL = (1 << 6), | ||
294 | IDE_TFLAG_OUT_HOB_LBAM = (1 << 7), | ||
295 | IDE_TFLAG_OUT_HOB_LBAH = (1 << 8), | ||
296 | IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE | | ||
297 | IDE_TFLAG_OUT_HOB_NSECT | | ||
298 | IDE_TFLAG_OUT_HOB_LBAL | | ||
299 | IDE_TFLAG_OUT_HOB_LBAM | | ||
300 | IDE_TFLAG_OUT_HOB_LBAH, | ||
301 | IDE_TFLAG_OUT_FEATURE = (1 << 9), | ||
302 | IDE_TFLAG_OUT_NSECT = (1 << 10), | ||
303 | IDE_TFLAG_OUT_LBAL = (1 << 11), | ||
304 | IDE_TFLAG_OUT_LBAM = (1 << 12), | ||
305 | IDE_TFLAG_OUT_LBAH = (1 << 13), | ||
306 | IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE | | ||
307 | IDE_TFLAG_OUT_NSECT | | ||
308 | IDE_TFLAG_OUT_LBAL | | ||
309 | IDE_TFLAG_OUT_LBAM | | ||
310 | IDE_TFLAG_OUT_LBAH, | ||
311 | IDE_TFLAG_OUT_DEVICE = (1 << 14), | ||
312 | IDE_TFLAG_WRITE = (1 << 15), | ||
313 | IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), | ||
314 | IDE_TFLAG_IN_DATA = (1 << 17), | ||
315 | IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), | ||
316 | IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), | ||
317 | IDE_TFLAG_IN_HOB_FEATURE = (1 << 20), | ||
318 | IDE_TFLAG_IN_HOB_NSECT = (1 << 21), | ||
319 | IDE_TFLAG_IN_HOB_LBAL = (1 << 22), | ||
320 | IDE_TFLAG_IN_HOB_LBAM = (1 << 23), | ||
321 | IDE_TFLAG_IN_HOB_LBAH = (1 << 24), | ||
322 | IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL | | ||
323 | IDE_TFLAG_IN_HOB_LBAM | | ||
324 | IDE_TFLAG_IN_HOB_LBAH, | ||
325 | IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | | ||
326 | IDE_TFLAG_IN_HOB_NSECT | | ||
327 | IDE_TFLAG_IN_HOB_LBA, | ||
328 | IDE_TFLAG_IN_FEATURE = (1 << 1), | ||
329 | IDE_TFLAG_IN_NSECT = (1 << 25), | ||
330 | IDE_TFLAG_IN_LBAL = (1 << 26), | ||
331 | IDE_TFLAG_IN_LBAM = (1 << 27), | ||
332 | IDE_TFLAG_IN_LBAH = (1 << 28), | ||
333 | IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL | | ||
334 | IDE_TFLAG_IN_LBAM | | ||
335 | IDE_TFLAG_IN_LBAH, | ||
336 | IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT | | ||
337 | IDE_TFLAG_IN_LBA, | ||
338 | IDE_TFLAG_IN_DEVICE = (1 << 29), | ||
339 | IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB | | ||
340 | IDE_TFLAG_IN_HOB, | ||
341 | IDE_TFLAG_TF = IDE_TFLAG_OUT_TF | | ||
342 | IDE_TFLAG_IN_TF, | ||
343 | IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE | | ||
344 | IDE_TFLAG_IN_DEVICE, | ||
345 | /* force 16-bit I/O operations */ | ||
346 | IDE_TFLAG_IO_16BIT = (1 << 30), | ||
347 | /* ide_task_t was allocated using kmalloc() */ | ||
348 | IDE_TFLAG_DYN = (1 << 31), | ||
349 | }; | ||
350 | |||
351 | struct ide_taskfile { | ||
352 | u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ | ||
353 | |||
354 | u8 hob_feature; /* 1-5: additional data to support LBA48 */ | ||
355 | u8 hob_nsect; | ||
356 | u8 hob_lbal; | ||
357 | u8 hob_lbam; | ||
358 | u8 hob_lbah; | ||
359 | |||
360 | u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ | ||
361 | |||
362 | union { /* Â 7: */ | ||
363 | u8 error; /* read: error */ | ||
364 | u8 feature; /* write: feature */ | ||
365 | }; | ||
366 | |||
367 | u8 nsect; /* 8: number of sectors */ | ||
368 | u8 lbal; /* 9: LBA low */ | ||
369 | u8 lbam; /* 10: LBA mid */ | ||
370 | u8 lbah; /* 11: LBA high */ | ||
371 | |||
372 | u8 device; /* 12: device select */ | ||
373 | |||
374 | union { /* 13: */ | ||
375 | u8 status; /*  read: status  */ | ||
376 | u8 command; /* write: command */ | ||
377 | }; | ||
378 | }; | ||
379 | |||
380 | typedef struct ide_task_s { | ||
381 | union { | ||
382 | struct ide_taskfile tf; | ||
383 | u8 tf_array[14]; | ||
384 | }; | ||
385 | u32 tf_flags; | ||
386 | int data_phase; | ||
387 | struct request *rq; /* copy of request */ | ||
388 | void *special; /* valid_t generally */ | ||
389 | } ide_task_t; | ||
390 | |||
391 | /* ATAPI packet command flags */ | ||
392 | enum { | ||
393 | /* set when an error is considered normal - no retry (ide-tape) */ | ||
394 | PC_FLAG_ABORT = (1 << 0), | ||
395 | PC_FLAG_SUPPRESS_ERROR = (1 << 1), | ||
396 | PC_FLAG_WAIT_FOR_DSC = (1 << 2), | ||
397 | PC_FLAG_DMA_OK = (1 << 3), | ||
398 | PC_FLAG_DMA_IN_PROGRESS = (1 << 4), | ||
399 | PC_FLAG_DMA_ERROR = (1 << 5), | ||
400 | PC_FLAG_WRITING = (1 << 6), | ||
401 | /* command timed out */ | ||
402 | PC_FLAG_TIMEDOUT = (1 << 7), | ||
403 | }; | ||
404 | |||
405 | /* | ||
406 | * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. | ||
407 | * This is used for several packet commands (not for READ/WRITE commands). | ||
408 | */ | ||
409 | #define IDE_PC_BUFFER_SIZE 256 | ||
410 | |||
411 | struct ide_atapi_pc { | ||
412 | /* actual packet bytes */ | ||
413 | u8 c[12]; | ||
414 | /* incremented on each retry */ | ||
415 | int retries; | ||
416 | int error; | ||
417 | |||
418 | /* bytes to transfer */ | ||
419 | int req_xfer; | ||
420 | /* bytes actually transferred */ | ||
421 | int xferred; | ||
422 | |||
423 | /* data buffer */ | ||
424 | u8 *buf; | ||
425 | /* current buffer position */ | ||
426 | u8 *cur_pos; | ||
427 | int buf_size; | ||
428 | /* missing/available data on the current buffer */ | ||
429 | int b_count; | ||
430 | |||
431 | /* the corresponding request */ | ||
432 | struct request *rq; | ||
433 | |||
434 | unsigned long flags; | ||
435 | |||
436 | /* | ||
437 | * those are more or less driver-specific and some of them are subject | ||
438 | * to change/removal later. | ||
439 | */ | ||
440 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; | ||
441 | |||
442 | /* idetape only */ | ||
443 | struct idetape_bh *bh; | ||
444 | char *b_data; | ||
445 | |||
446 | /* idescsi only for now */ | ||
447 | struct scatterlist *sg; | ||
448 | unsigned int sg_cnt; | ||
449 | |||
450 | struct scsi_cmnd *scsi_cmd; | ||
451 | void (*done) (struct scsi_cmnd *); | ||
452 | |||
453 | unsigned long timeout; | ||
454 | }; | ||
455 | |||
456 | struct ide_devset; | ||
306 | struct ide_driver_s; | 457 | struct ide_driver_s; |
307 | struct ide_settings_s; | ||
308 | 458 | ||
309 | #ifdef CONFIG_BLK_DEV_IDEACPI | 459 | #ifdef CONFIG_BLK_DEV_IDEACPI |
310 | struct ide_acpi_drive_link; | 460 | struct ide_acpi_drive_link; |
@@ -315,10 +465,10 @@ struct ide_acpi_hwif_link; | |||
315 | enum { | 465 | enum { |
316 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), | 466 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), |
317 | IDE_AFLAG_MEDIA_CHANGED = (1 << 1), | 467 | IDE_AFLAG_MEDIA_CHANGED = (1 << 1), |
318 | |||
319 | /* ide-cd */ | ||
320 | /* Drive cannot lock the door. */ | 468 | /* Drive cannot lock the door. */ |
321 | IDE_AFLAG_NO_DOORLOCK = (1 << 2), | 469 | IDE_AFLAG_NO_DOORLOCK = (1 << 2), |
470 | |||
471 | /* ide-cd */ | ||
322 | /* Drive cannot eject the disc. */ | 472 | /* Drive cannot eject the disc. */ |
323 | IDE_AFLAG_NO_EJECT = (1 << 3), | 473 | IDE_AFLAG_NO_EJECT = (1 << 3), |
324 | /* Drive is a pre ATAPI 1.2 drive. */ | 474 | /* Drive is a pre ATAPI 1.2 drive. */ |
@@ -354,19 +504,81 @@ enum { | |||
354 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), | 504 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), |
355 | /* Requires BH algorithm for packets */ | 505 | /* Requires BH algorithm for packets */ |
356 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), | 506 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), |
507 | /* Write protect */ | ||
508 | IDE_AFLAG_WP = (1 << 21), | ||
509 | /* Supports format progress report */ | ||
510 | IDE_AFLAG_SRFP = (1 << 22), | ||
357 | 511 | ||
358 | /* ide-tape */ | 512 | /* ide-tape */ |
359 | IDE_AFLAG_IGNORE_DSC = (1 << 21), | 513 | IDE_AFLAG_IGNORE_DSC = (1 << 23), |
360 | /* 0 When the tape position is unknown */ | 514 | /* 0 When the tape position is unknown */ |
361 | IDE_AFLAG_ADDRESS_VALID = (1 << 22), | 515 | IDE_AFLAG_ADDRESS_VALID = (1 << 24), |
362 | /* Device already opened */ | 516 | /* Device already opened */ |
363 | IDE_AFLAG_BUSY = (1 << 23), | 517 | IDE_AFLAG_BUSY = (1 << 25), |
364 | /* Attempt to auto-detect the current user block size */ | 518 | /* Attempt to auto-detect the current user block size */ |
365 | IDE_AFLAG_DETECT_BS = (1 << 24), | 519 | IDE_AFLAG_DETECT_BS = (1 << 26), |
366 | /* Currently on a filemark */ | 520 | /* Currently on a filemark */ |
367 | IDE_AFLAG_FILEMARK = (1 << 25), | 521 | IDE_AFLAG_FILEMARK = (1 << 27), |
368 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | 522 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ |
369 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 26) | 523 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), |
524 | |||
525 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), | ||
526 | }; | ||
527 | |||
528 | /* device flags */ | ||
529 | enum { | ||
530 | /* restore settings after device reset */ | ||
531 | IDE_DFLAG_KEEP_SETTINGS = (1 << 0), | ||
532 | /* device is using DMA for read/write */ | ||
533 | IDE_DFLAG_USING_DMA = (1 << 1), | ||
534 | /* okay to unmask other IRQs */ | ||
535 | IDE_DFLAG_UNMASK = (1 << 2), | ||
536 | /* don't attempt flushes */ | ||
537 | IDE_DFLAG_NOFLUSH = (1 << 3), | ||
538 | /* DSC overlap */ | ||
539 | IDE_DFLAG_DSC_OVERLAP = (1 << 4), | ||
540 | /* give potential excess bandwidth */ | ||
541 | IDE_DFLAG_NICE1 = (1 << 5), | ||
542 | /* device is physically present */ | ||
543 | IDE_DFLAG_PRESENT = (1 << 6), | ||
544 | /* device ejected hint */ | ||
545 | IDE_DFLAG_DEAD = (1 << 7), | ||
546 | /* id read from device (synthetic if not set) */ | ||
547 | IDE_DFLAG_ID_READ = (1 << 8), | ||
548 | IDE_DFLAG_NOPROBE = (1 << 9), | ||
549 | /* need to do check_media_change() */ | ||
550 | IDE_DFLAG_REMOVABLE = (1 << 10), | ||
551 | /* needed for removable devices */ | ||
552 | IDE_DFLAG_ATTACH = (1 << 11), | ||
553 | IDE_DFLAG_FORCED_GEOM = (1 << 12), | ||
554 | /* disallow setting unmask bit */ | ||
555 | IDE_DFLAG_NO_UNMASK = (1 << 13), | ||
556 | /* disallow enabling 32-bit I/O */ | ||
557 | IDE_DFLAG_NO_IO_32BIT = (1 << 14), | ||
558 | /* for removable only: door lock/unlock works */ | ||
559 | IDE_DFLAG_DOORLOCKING = (1 << 15), | ||
560 | /* disallow DMA */ | ||
561 | IDE_DFLAG_NODMA = (1 << 16), | ||
562 | /* powermanagment told us not to do anything, so sleep nicely */ | ||
563 | IDE_DFLAG_BLOCKED = (1 << 17), | ||
564 | /* ide-scsi emulation */ | ||
565 | IDE_DFLAG_SCSI = (1 << 18), | ||
566 | /* sleeping & sleep field valid */ | ||
567 | IDE_DFLAG_SLEEPING = (1 << 19), | ||
568 | IDE_DFLAG_POST_RESET = (1 << 20), | ||
569 | IDE_DFLAG_UDMA33_WARNED = (1 << 21), | ||
570 | IDE_DFLAG_LBA48 = (1 << 22), | ||
571 | /* status of write cache */ | ||
572 | IDE_DFLAG_WCACHE = (1 << 23), | ||
573 | /* used for ignoring ATA_DF */ | ||
574 | IDE_DFLAG_NOWERR = (1 << 24), | ||
575 | /* retrying in PIO */ | ||
576 | IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), | ||
577 | IDE_DFLAG_LBA = (1 << 26), | ||
578 | /* don't unload heads */ | ||
579 | IDE_DFLAG_NO_UNLOAD = (1 << 27), | ||
580 | /* heads unloaded, please don't reset port */ | ||
581 | IDE_DFLAG_PARKED = (1 << 28) | ||
370 | }; | 582 | }; |
371 | 583 | ||
372 | struct ide_drive_s { | 584 | struct ide_drive_s { |
@@ -378,72 +590,47 @@ struct ide_drive_s { | |||
378 | struct request *rq; /* current request */ | 590 | struct request *rq; /* current request */ |
379 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | 591 | struct ide_drive_s *next; /* circular list of hwgroup drives */ |
380 | void *driver_data; /* extra driver data */ | 592 | void *driver_data; /* extra driver data */ |
381 | struct hd_driveid *id; /* drive model identification info */ | 593 | u16 *id; /* identification info */ |
382 | #ifdef CONFIG_IDE_PROC_FS | 594 | #ifdef CONFIG_IDE_PROC_FS |
383 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 595 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
384 | struct ide_settings_s *settings;/* /proc/ide/ drive settings */ | 596 | const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ |
385 | #endif | 597 | #endif |
386 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ | 598 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ |
387 | 599 | ||
600 | unsigned long dev_flags; | ||
601 | |||
388 | unsigned long sleep; /* sleep until this time */ | 602 | unsigned long sleep; /* sleep until this time */ |
389 | unsigned long service_start; /* time we started last request */ | 603 | unsigned long service_start; /* time we started last request */ |
390 | unsigned long service_time; /* service time of last request */ | 604 | unsigned long service_time; /* service time of last request */ |
391 | unsigned long timeout; /* max time to wait for irq */ | 605 | unsigned long timeout; /* max time to wait for irq */ |
392 | 606 | ||
393 | special_t special; /* special action flags */ | 607 | special_t special; /* special action flags */ |
394 | select_t select; /* basic drive/head select reg value */ | ||
395 | 608 | ||
396 | u8 keep_settings; /* restore settings after drive reset */ | 609 | u8 select; /* basic drive/head select reg value */ |
397 | u8 using_dma; /* disk is using dma for read/write */ | ||
398 | u8 retry_pio; /* retrying dma capable host in pio */ | 610 | u8 retry_pio; /* retrying dma capable host in pio */ |
399 | u8 state; /* retry state */ | ||
400 | u8 waiting_for_dma; /* dma currently in progress */ | 611 | u8 waiting_for_dma; /* dma currently in progress */ |
401 | u8 unmask; /* okay to unmask other irqs */ | 612 | u8 dma; /* atapi dma flag */ |
402 | u8 noflush; /* don't attempt flushes */ | 613 | |
403 | u8 dsc_overlap; /* DSC overlap */ | ||
404 | u8 nice1; /* give potential excess bandwidth */ | ||
405 | |||
406 | unsigned present : 1; /* drive is physically present */ | ||
407 | unsigned dead : 1; /* device ejected hint */ | ||
408 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ | ||
409 | unsigned noprobe : 1; /* from: hdx=noprobe */ | ||
410 | unsigned removable : 1; /* 1 if need to do check_media_change */ | ||
411 | unsigned attach : 1; /* needed for removable devices */ | ||
412 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ | ||
413 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | ||
414 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | ||
415 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ | ||
416 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | ||
417 | unsigned nodma : 1; /* disallow DMA */ | ||
418 | unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ | ||
419 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ | ||
420 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ | ||
421 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ | ||
422 | unsigned post_reset : 1; | ||
423 | unsigned udma33_warned : 1; | ||
424 | |||
425 | u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
426 | u8 quirk_list; /* considered quirky, set for a specific host */ | 614 | u8 quirk_list; /* considered quirky, set for a specific host */ |
427 | u8 init_speed; /* transfer rate set at boot */ | 615 | u8 init_speed; /* transfer rate set at boot */ |
428 | u8 current_speed; /* current transfer rate set */ | 616 | u8 current_speed; /* current transfer rate set */ |
429 | u8 desired_speed; /* desired transfer rate set */ | 617 | u8 desired_speed; /* desired transfer rate set */ |
430 | u8 dn; /* now wide spread use */ | 618 | u8 dn; /* now wide spread use */ |
431 | u8 wcache; /* status of write cache */ | ||
432 | u8 acoustic; /* acoustic management */ | 619 | u8 acoustic; /* acoustic management */ |
433 | u8 media; /* disk, cdrom, tape, floppy, ... */ | 620 | u8 media; /* disk, cdrom, tape, floppy, ... */ |
434 | u8 ready_stat; /* min status value for drive ready */ | 621 | u8 ready_stat; /* min status value for drive ready */ |
435 | u8 mult_count; /* current multiple sector setting */ | 622 | u8 mult_count; /* current multiple sector setting */ |
436 | u8 mult_req; /* requested multiple sector setting */ | 623 | u8 mult_req; /* requested multiple sector setting */ |
437 | u8 tune_req; /* requested drive tuning setting */ | ||
438 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ | 624 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ |
439 | u8 bad_wstat; /* used for ignoring WRERR_STAT */ | 625 | u8 bad_wstat; /* used for ignoring ATA_DF */ |
440 | u8 nowerr; /* used for ignoring WRERR_STAT */ | ||
441 | u8 sect0; /* offset of first sector for DM6:DDO */ | ||
442 | u8 head; /* "real" number of heads */ | 626 | u8 head; /* "real" number of heads */ |
443 | u8 sect; /* "real" sectors per track */ | 627 | u8 sect; /* "real" sectors per track */ |
444 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ | 628 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ |
445 | u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ | 629 | u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ |
446 | 630 | ||
631 | /* delay this long before sending packet command */ | ||
632 | u8 pc_delay; | ||
633 | |||
447 | unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ | 634 | unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ |
448 | unsigned int cyl; /* "real" number of cyls */ | 635 | unsigned int cyl; /* "real" number of cyls */ |
449 | unsigned int drive_data; /* used by set_pio_mode/selectproc */ | 636 | unsigned int drive_data; /* used by set_pio_mode/selectproc */ |
@@ -455,6 +642,9 @@ struct ide_drive_s { | |||
455 | 642 | ||
456 | int lun; /* logical unit */ | 643 | int lun; /* logical unit */ |
457 | int crc_count; /* crc counter to reduce drive speed */ | 644 | int crc_count; /* crc counter to reduce drive speed */ |
645 | |||
646 | unsigned long debug_mask; /* debugging levels switch */ | ||
647 | |||
458 | #ifdef CONFIG_BLK_DEV_IDEACPI | 648 | #ifdef CONFIG_BLK_DEV_IDEACPI |
459 | struct ide_acpi_drive_link *acpidata; | 649 | struct ide_acpi_drive_link *acpidata; |
460 | #endif | 650 | #endif |
@@ -462,21 +652,32 @@ struct ide_drive_s { | |||
462 | struct device gendev; | 652 | struct device gendev; |
463 | struct completion gendev_rel_comp; /* to deal with device release() */ | 653 | struct completion gendev_rel_comp; /* to deal with device release() */ |
464 | 654 | ||
655 | /* current packet command */ | ||
656 | struct ide_atapi_pc *pc; | ||
657 | |||
465 | /* callback for packet commands */ | 658 | /* callback for packet commands */ |
466 | void (*pc_callback)(struct ide_drive_s *); | 659 | void (*pc_callback)(struct ide_drive_s *, int); |
660 | |||
661 | void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *); | ||
662 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, | ||
663 | unsigned int, int); | ||
467 | 664 | ||
468 | unsigned long atapi_flags; | 665 | unsigned long atapi_flags; |
666 | |||
667 | struct ide_atapi_pc request_sense_pc; | ||
668 | struct request request_sense_rq; | ||
469 | }; | 669 | }; |
470 | 670 | ||
471 | typedef struct ide_drive_s ide_drive_t; | 671 | typedef struct ide_drive_s ide_drive_t; |
472 | 672 | ||
473 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) | 673 | #define to_ide_device(dev) container_of(dev, ide_drive_t, gendev) |
474 | 674 | ||
475 | #define IDE_CHIPSET_PCI_MASK \ | 675 | #define to_ide_drv(obj, cont_type) \ |
476 | ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) | 676 | container_of(obj, struct cont_type, kref) |
477 | #define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) | 677 | |
678 | #define ide_drv_g(disk, cont_type) \ | ||
679 | container_of((disk)->private_data, struct cont_type, driver) | ||
478 | 680 | ||
479 | struct ide_task_s; | ||
480 | struct ide_port_info; | 681 | struct ide_port_info; |
481 | 682 | ||
482 | struct ide_tp_ops { | 683 | struct ide_tp_ops { |
@@ -510,6 +711,7 @@ extern const struct ide_tp_ops default_tp_ops; | |||
510 | * @resetproc: routine to reset controller after a disk reset | 711 | * @resetproc: routine to reset controller after a disk reset |
511 | * @maskproc: special host masking for drive selection | 712 | * @maskproc: special host masking for drive selection |
512 | * @quirkproc: check host's drive quirk list | 713 | * @quirkproc: check host's drive quirk list |
714 | * @clear_irq: clear IRQ | ||
513 | * | 715 | * |
514 | * @mdma_filter: filter MDMA modes | 716 | * @mdma_filter: filter MDMA modes |
515 | * @udma_filter: filter UDMA modes | 717 | * @udma_filter: filter UDMA modes |
@@ -526,6 +728,7 @@ struct ide_port_ops { | |||
526 | void (*resetproc)(ide_drive_t *); | 728 | void (*resetproc)(ide_drive_t *); |
527 | void (*maskproc)(ide_drive_t *, int); | 729 | void (*maskproc)(ide_drive_t *, int); |
528 | void (*quirkproc)(ide_drive_t *); | 730 | void (*quirkproc)(ide_drive_t *); |
731 | void (*clear_irq)(ide_drive_t *); | ||
529 | 732 | ||
530 | u8 (*mdma_filter)(ide_drive_t *); | 733 | u8 (*mdma_filter)(ide_drive_t *); |
531 | u8 (*udma_filter)(ide_drive_t *); | 734 | u8 (*udma_filter)(ide_drive_t *); |
@@ -565,7 +768,6 @@ typedef struct hwif_s { | |||
565 | u8 major; /* our major number */ | 768 | u8 major; /* our major number */ |
566 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 769 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
567 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ | 770 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ |
568 | u8 bus_state; /* power state of the IDE bus */ | ||
569 | 771 | ||
570 | u32 host_flags; | 772 | u32 host_flags; |
571 | 773 | ||
@@ -589,12 +791,16 @@ typedef struct hwif_s { | |||
589 | const struct ide_port_ops *port_ops; | 791 | const struct ide_port_ops *port_ops; |
590 | const struct ide_dma_ops *dma_ops; | 792 | const struct ide_dma_ops *dma_ops; |
591 | 793 | ||
592 | void (*ide_dma_clear_irq)(ide_drive_t *drive); | ||
593 | |||
594 | /* dma physical region descriptor table (cpu view) */ | 794 | /* dma physical region descriptor table (cpu view) */ |
595 | unsigned int *dmatable_cpu; | 795 | unsigned int *dmatable_cpu; |
596 | /* dma physical region descriptor table (dma view) */ | 796 | /* dma physical region descriptor table (dma view) */ |
597 | dma_addr_t dmatable_dma; | 797 | dma_addr_t dmatable_dma; |
798 | |||
799 | /* maximum number of PRD table entries */ | ||
800 | int prd_max_nents; | ||
801 | /* PRD entry size in bytes */ | ||
802 | int prd_ent_size; | ||
803 | |||
598 | /* Scatter-gather list used to build the above */ | 804 | /* Scatter-gather list used to build the above */ |
599 | struct scatterlist *sg_table; | 805 | struct scatterlist *sg_table; |
600 | int sg_max_nents; /* Maximum number of entries in it */ | 806 | int sg_max_nents; /* Maximum number of entries in it */ |
@@ -604,6 +810,8 @@ typedef struct hwif_s { | |||
604 | /* data phase of the active command (currently only valid for PIO/DMA) */ | 810 | /* data phase of the active command (currently only valid for PIO/DMA) */ |
605 | int data_phase; | 811 | int data_phase; |
606 | 812 | ||
813 | struct ide_task_s task; /* current command */ | ||
814 | |||
607 | unsigned int nsect; | 815 | unsigned int nsect; |
608 | unsigned int nleft; | 816 | unsigned int nleft; |
609 | struct scatterlist *cursg; | 817 | struct scatterlist *cursg; |
@@ -632,17 +840,18 @@ typedef struct hwif_s { | |||
632 | 840 | ||
633 | void *hwif_data; /* extra hwif data */ | 841 | void *hwif_data; /* extra hwif data */ |
634 | 842 | ||
635 | unsigned dma; | ||
636 | |||
637 | #ifdef CONFIG_BLK_DEV_IDEACPI | 843 | #ifdef CONFIG_BLK_DEV_IDEACPI |
638 | struct ide_acpi_hwif_link *acpidata; | 844 | struct ide_acpi_hwif_link *acpidata; |
639 | #endif | 845 | #endif |
640 | } ____cacheline_internodealigned_in_smp ide_hwif_t; | 846 | } ____cacheline_internodealigned_in_smp ide_hwif_t; |
641 | 847 | ||
848 | #define MAX_HOST_PORTS 4 | ||
849 | |||
642 | struct ide_host { | 850 | struct ide_host { |
643 | ide_hwif_t *ports[MAX_HWIFS]; | 851 | ide_hwif_t *ports[MAX_HOST_PORTS]; |
644 | unsigned int n_ports; | 852 | unsigned int n_ports; |
645 | struct device *dev[2]; | 853 | struct device *dev[2]; |
854 | unsigned int (*init_chipset)(struct pci_dev *); | ||
646 | unsigned long host_flags; | 855 | unsigned long host_flags; |
647 | void *host_priv; | 856 | void *host_priv; |
648 | }; | 857 | }; |
@@ -690,102 +899,116 @@ typedef struct ide_driver_s ide_driver_t; | |||
690 | 899 | ||
691 | extern struct mutex ide_setting_mtx; | 900 | extern struct mutex ide_setting_mtx; |
692 | 901 | ||
693 | int set_io_32bit(ide_drive_t *, int); | 902 | /* |
694 | int set_pio_mode(ide_drive_t *, int); | 903 | * configurable drive settings |
695 | int set_using_dma(ide_drive_t *, int); | 904 | */ |
696 | 905 | ||
697 | /* ATAPI packet command flags */ | 906 | #define DS_SYNC (1 << 0) |
698 | enum { | 907 | |
699 | /* set when an error is considered normal - no retry (ide-tape) */ | 908 | struct ide_devset { |
700 | PC_FLAG_ABORT = (1 << 0), | 909 | int (*get)(ide_drive_t *); |
701 | PC_FLAG_SUPPRESS_ERROR = (1 << 1), | 910 | int (*set)(ide_drive_t *, int); |
702 | PC_FLAG_WAIT_FOR_DSC = (1 << 2), | 911 | unsigned int flags; |
703 | PC_FLAG_DMA_OK = (1 << 3), | ||
704 | PC_FLAG_DMA_IN_PROGRESS = (1 << 4), | ||
705 | PC_FLAG_DMA_ERROR = (1 << 5), | ||
706 | PC_FLAG_WRITING = (1 << 6), | ||
707 | /* command timed out */ | ||
708 | PC_FLAG_TIMEDOUT = (1 << 7), | ||
709 | }; | 912 | }; |
710 | 913 | ||
711 | struct ide_atapi_pc { | 914 | #define __DEVSET(_flags, _get, _set) { \ |
712 | /* actual packet bytes */ | 915 | .flags = _flags, \ |
713 | u8 c[12]; | 916 | .get = _get, \ |
714 | /* incremented on each retry */ | 917 | .set = _set, \ |
715 | int retries; | 918 | } |
716 | int error; | ||
717 | 919 | ||
718 | /* bytes to transfer */ | 920 | #define ide_devset_get(name, field) \ |
719 | int req_xfer; | 921 | static int get_##name(ide_drive_t *drive) \ |
720 | /* bytes actually transferred */ | 922 | { \ |
721 | int xferred; | 923 | return drive->field; \ |
924 | } | ||
722 | 925 | ||
723 | /* data buffer */ | 926 | #define ide_devset_set(name, field) \ |
724 | u8 *buf; | 927 | static int set_##name(ide_drive_t *drive, int arg) \ |
725 | /* current buffer position */ | 928 | { \ |
726 | u8 *cur_pos; | 929 | drive->field = arg; \ |
727 | int buf_size; | 930 | return 0; \ |
728 | /* missing/available data on the current buffer */ | 931 | } |
729 | int b_count; | ||
730 | 932 | ||
731 | /* the corresponding request */ | 933 | #define ide_devset_get_flag(name, flag) \ |
732 | struct request *rq; | 934 | static int get_##name(ide_drive_t *drive) \ |
935 | { \ | ||
936 | return !!(drive->dev_flags & flag); \ | ||
937 | } | ||
733 | 938 | ||
734 | unsigned long flags; | 939 | #define ide_devset_set_flag(name, flag) \ |
940 | static int set_##name(ide_drive_t *drive, int arg) \ | ||
941 | { \ | ||
942 | if (arg) \ | ||
943 | drive->dev_flags |= flag; \ | ||
944 | else \ | ||
945 | drive->dev_flags &= ~flag; \ | ||
946 | return 0; \ | ||
947 | } | ||
735 | 948 | ||
736 | /* | 949 | #define __IDE_DEVSET(_name, _flags, _get, _set) \ |
737 | * those are more or less driver-specific and some of them are subject | 950 | const struct ide_devset ide_devset_##_name = \ |
738 | * to change/removal later. | 951 | __DEVSET(_flags, _get, _set) |
739 | */ | ||
740 | u8 pc_buf[256]; | ||
741 | 952 | ||
742 | /* idetape only */ | 953 | #define IDE_DEVSET(_name, _flags, _get, _set) \ |
743 | struct idetape_bh *bh; | 954 | static __IDE_DEVSET(_name, _flags, _get, _set) |
744 | char *b_data; | ||
745 | 955 | ||
746 | /* idescsi only for now */ | 956 | #define ide_devset_rw(_name, _func) \ |
747 | struct scatterlist *sg; | 957 | IDE_DEVSET(_name, 0, get_##_func, set_##_func) |
748 | unsigned int sg_cnt; | ||
749 | 958 | ||
750 | struct scsi_cmnd *scsi_cmd; | 959 | #define ide_devset_w(_name, _func) \ |
751 | void (*done) (struct scsi_cmnd *); | 960 | IDE_DEVSET(_name, 0, NULL, set_##_func) |
752 | 961 | ||
753 | unsigned long timeout; | 962 | #define ide_ext_devset_rw(_name, _func) \ |
754 | }; | 963 | __IDE_DEVSET(_name, 0, get_##_func, set_##_func) |
964 | |||
965 | #define ide_ext_devset_rw_sync(_name, _func) \ | ||
966 | __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | ||
967 | |||
968 | #define ide_decl_devset(_name) \ | ||
969 | extern const struct ide_devset ide_devset_##_name | ||
970 | |||
971 | ide_decl_devset(io_32bit); | ||
972 | ide_decl_devset(keepsettings); | ||
973 | ide_decl_devset(pio_mode); | ||
974 | ide_decl_devset(unmaskirq); | ||
975 | ide_decl_devset(using_dma); | ||
755 | 976 | ||
756 | #ifdef CONFIG_IDE_PROC_FS | 977 | #ifdef CONFIG_IDE_PROC_FS |
757 | /* | 978 | /* |
758 | * configurable drive settings | 979 | * /proc/ide interface |
759 | */ | 980 | */ |
760 | 981 | ||
761 | #define TYPE_INT 0 | 982 | #define ide_devset_rw_field(_name, _field) \ |
762 | #define TYPE_BYTE 1 | 983 | ide_devset_get(_name, _field); \ |
763 | #define TYPE_SHORT 2 | 984 | ide_devset_set(_name, _field); \ |
985 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
986 | |||
987 | #define ide_devset_rw_flag(_name, _field) \ | ||
988 | ide_devset_get_flag(_name, _field); \ | ||
989 | ide_devset_set_flag(_name, _field); \ | ||
990 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
991 | |||
992 | struct ide_proc_devset { | ||
993 | const char *name; | ||
994 | const struct ide_devset *setting; | ||
995 | int min, max; | ||
996 | int (*mulf)(ide_drive_t *); | ||
997 | int (*divf)(ide_drive_t *); | ||
998 | }; | ||
764 | 999 | ||
765 | #define SETTING_READ (1 << 0) | 1000 | #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ |
766 | #define SETTING_WRITE (1 << 1) | 1001 | .name = __stringify(_name), \ |
767 | #define SETTING_RW (SETTING_READ | SETTING_WRITE) | 1002 | .setting = &ide_devset_##_name, \ |
1003 | .min = _min, \ | ||
1004 | .max = _max, \ | ||
1005 | .mulf = _mulf, \ | ||
1006 | .divf = _divf, \ | ||
1007 | } | ||
768 | 1008 | ||
769 | typedef int (ide_procset_t)(ide_drive_t *, int); | 1009 | #define IDE_PROC_DEVSET(_name, _min, _max) \ |
770 | typedef struct ide_settings_s { | 1010 | __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) |
771 | char *name; | ||
772 | int rw; | ||
773 | int data_type; | ||
774 | int min; | ||
775 | int max; | ||
776 | int mul_factor; | ||
777 | int div_factor; | ||
778 | void *data; | ||
779 | ide_procset_t *set; | ||
780 | int auto_remove; | ||
781 | struct ide_settings_s *next; | ||
782 | } ide_settings_t; | ||
783 | |||
784 | int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set); | ||
785 | 1011 | ||
786 | /* | ||
787 | * /proc/ide interface | ||
788 | */ | ||
789 | typedef struct { | 1012 | typedef struct { |
790 | const char *name; | 1013 | const char *name; |
791 | mode_t mode; | 1014 | mode_t mode; |
@@ -802,8 +1025,6 @@ void ide_proc_unregister_port(ide_hwif_t *); | |||
802 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 1025 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); |
803 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 1026 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); |
804 | 1027 | ||
805 | void ide_add_generic_settings(ide_drive_t *); | ||
806 | |||
807 | read_proc_t proc_ide_read_capacity; | 1028 | read_proc_t proc_ide_read_capacity; |
808 | read_proc_t proc_ide_read_geometry; | 1029 | read_proc_t proc_ide_read_geometry; |
809 | 1030 | ||
@@ -831,41 +1052,58 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | |||
831 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 1052 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
832 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1053 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
833 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1054 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
834 | static inline void ide_add_generic_settings(ide_drive_t *drive) { ; } | ||
835 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 1055 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
836 | #endif | 1056 | #endif |
837 | 1057 | ||
1058 | enum { | ||
1059 | /* enter/exit functions */ | ||
1060 | IDE_DBG_FUNC = (1 << 0), | ||
1061 | /* sense key/asc handling */ | ||
1062 | IDE_DBG_SENSE = (1 << 1), | ||
1063 | /* packet commands handling */ | ||
1064 | IDE_DBG_PC = (1 << 2), | ||
1065 | /* request handling */ | ||
1066 | IDE_DBG_RQ = (1 << 3), | ||
1067 | /* driver probing/setup */ | ||
1068 | IDE_DBG_PROBE = (1 << 4), | ||
1069 | }; | ||
1070 | |||
1071 | /* DRV_NAME has to be defined in the driver before using the macro below */ | ||
1072 | #define __ide_debug_log(lvl, fmt, args...) \ | ||
1073 | { \ | ||
1074 | if (unlikely(drive->debug_mask & lvl)) \ | ||
1075 | printk(KERN_INFO DRV_NAME ": " fmt, ## args); \ | ||
1076 | } | ||
1077 | |||
838 | /* | 1078 | /* |
839 | * Power Management step value (rq->pm->pm_step). | 1079 | * Power Management state machine (rq->pm->pm_step). |
840 | * | ||
841 | * The step value starts at 0 (ide_pm_state_start_suspend) for a | ||
842 | * suspend operation or 1000 (ide_pm_state_start_resume) for a | ||
843 | * resume operation. | ||
844 | * | 1080 | * |
845 | * For each step, the core calls the subdriver start_power_step() first. | 1081 | * For each step, the core calls ide_start_power_step() first. |
846 | * This can return: | 1082 | * This can return: |
847 | * - ide_stopped : In this case, the core calls us back again unless | 1083 | * - ide_stopped : In this case, the core calls us back again unless |
848 | * step have been set to ide_power_state_completed. | 1084 | * step have been set to ide_power_state_completed. |
849 | * - ide_started : In this case, the channel is left busy until an | 1085 | * - ide_started : In this case, the channel is left busy until an |
850 | * async event (interrupt) occurs. | 1086 | * async event (interrupt) occurs. |
851 | * Typically, start_power_step() will issue a taskfile request with | 1087 | * Typically, ide_start_power_step() will issue a taskfile request with |
852 | * do_rw_taskfile(). | 1088 | * do_rw_taskfile(). |
853 | * | 1089 | * |
854 | * Upon reception of the interrupt, the core will call complete_power_step() | 1090 | * Upon reception of the interrupt, the core will call ide_complete_power_step() |
855 | * with the error code if any. This routine should update the step value | 1091 | * with the error code if any. This routine should update the step value |
856 | * and return. It should not start a new request. The core will call | 1092 | * and return. It should not start a new request. The core will call |
857 | * start_power_step for the new step value, unless step have been set to | 1093 | * ide_start_power_step() for the new step value, unless step have been |
858 | * ide_power_state_completed. | 1094 | * set to IDE_PM_COMPLETED. |
859 | * | ||
860 | * Subdrivers are expected to define their own additional power | ||
861 | * steps from 1..999 for suspend and from 1001..1999 for resume, | ||
862 | * other values are reserved for future use. | ||
863 | */ | 1095 | */ |
864 | |||
865 | enum { | 1096 | enum { |
866 | ide_pm_state_completed = -1, | 1097 | IDE_PM_START_SUSPEND, |
867 | ide_pm_state_start_suspend = 0, | 1098 | IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND, |
868 | ide_pm_state_start_resume = 1000, | 1099 | IDE_PM_STANDBY, |
1100 | |||
1101 | IDE_PM_START_RESUME, | ||
1102 | IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME, | ||
1103 | IDE_PM_IDLE, | ||
1104 | IDE_PM_RESTORE_DMA, | ||
1105 | |||
1106 | IDE_PM_COMPLETED, | ||
869 | }; | 1107 | }; |
870 | 1108 | ||
871 | /* | 1109 | /* |
@@ -876,8 +1114,6 @@ enum { | |||
876 | */ | 1114 | */ |
877 | struct ide_driver_s { | 1115 | struct ide_driver_s { |
878 | const char *version; | 1116 | const char *version; |
879 | u8 media; | ||
880 | unsigned supports_dsc_overlap : 1; | ||
881 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 1117 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
882 | int (*end_request)(ide_drive_t *, int, int); | 1118 | int (*end_request)(ide_drive_t *, int, int); |
883 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | 1119 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); |
@@ -887,7 +1123,8 @@ struct ide_driver_s { | |||
887 | void (*resume)(ide_drive_t *); | 1123 | void (*resume)(ide_drive_t *); |
888 | void (*shutdown)(ide_drive_t *); | 1124 | void (*shutdown)(ide_drive_t *); |
889 | #ifdef CONFIG_IDE_PROC_FS | 1125 | #ifdef CONFIG_IDE_PROC_FS |
890 | ide_proc_entry_t *proc; | 1126 | ide_proc_entry_t *proc; |
1127 | const struct ide_proc_devset *settings; | ||
891 | #endif | 1128 | #endif |
892 | }; | 1129 | }; |
893 | 1130 | ||
@@ -896,7 +1133,17 @@ struct ide_driver_s { | |||
896 | int ide_device_get(ide_drive_t *); | 1133 | int ide_device_get(ide_drive_t *); |
897 | void ide_device_put(ide_drive_t *); | 1134 | void ide_device_put(ide_drive_t *); |
898 | 1135 | ||
899 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); | 1136 | struct ide_ioctl_devset { |
1137 | unsigned int get_ioctl; | ||
1138 | unsigned int set_ioctl; | ||
1139 | const struct ide_devset *setting; | ||
1140 | }; | ||
1141 | |||
1142 | int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int, | ||
1143 | unsigned long, const struct ide_ioctl_devset *); | ||
1144 | |||
1145 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, | ||
1146 | unsigned, unsigned long); | ||
900 | 1147 | ||
901 | extern int ide_vlb_clk; | 1148 | extern int ide_vlb_clk; |
902 | extern int ide_pci_clk; | 1149 | extern int ide_pci_clk; |
@@ -918,122 +1165,23 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | |||
918 | 1165 | ||
919 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); | 1166 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); |
920 | 1167 | ||
921 | extern void ide_fix_driveid(struct hd_driveid *); | 1168 | void ide_fix_driveid(u16 *); |
922 | 1169 | ||
923 | extern void ide_fixstring(u8 *, const int, const int); | 1170 | extern void ide_fixstring(u8 *, const int, const int); |
924 | 1171 | ||
1172 | int ide_busy_sleep(ide_hwif_t *, unsigned long, int); | ||
1173 | |||
925 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); | 1174 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); |
926 | 1175 | ||
927 | extern ide_startstop_t ide_do_reset (ide_drive_t *); | 1176 | extern ide_startstop_t ide_do_reset (ide_drive_t *); |
928 | 1177 | ||
1178 | extern int ide_devset_execute(ide_drive_t *drive, | ||
1179 | const struct ide_devset *setting, int arg); | ||
1180 | |||
929 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); | 1181 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); |
930 | 1182 | ||
931 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); | 1183 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); |
932 | 1184 | ||
933 | enum { | ||
934 | IDE_TFLAG_LBA48 = (1 << 0), | ||
935 | IDE_TFLAG_FLAGGED = (1 << 2), | ||
936 | IDE_TFLAG_OUT_DATA = (1 << 3), | ||
937 | IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), | ||
938 | IDE_TFLAG_OUT_HOB_NSECT = (1 << 5), | ||
939 | IDE_TFLAG_OUT_HOB_LBAL = (1 << 6), | ||
940 | IDE_TFLAG_OUT_HOB_LBAM = (1 << 7), | ||
941 | IDE_TFLAG_OUT_HOB_LBAH = (1 << 8), | ||
942 | IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE | | ||
943 | IDE_TFLAG_OUT_HOB_NSECT | | ||
944 | IDE_TFLAG_OUT_HOB_LBAL | | ||
945 | IDE_TFLAG_OUT_HOB_LBAM | | ||
946 | IDE_TFLAG_OUT_HOB_LBAH, | ||
947 | IDE_TFLAG_OUT_FEATURE = (1 << 9), | ||
948 | IDE_TFLAG_OUT_NSECT = (1 << 10), | ||
949 | IDE_TFLAG_OUT_LBAL = (1 << 11), | ||
950 | IDE_TFLAG_OUT_LBAM = (1 << 12), | ||
951 | IDE_TFLAG_OUT_LBAH = (1 << 13), | ||
952 | IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE | | ||
953 | IDE_TFLAG_OUT_NSECT | | ||
954 | IDE_TFLAG_OUT_LBAL | | ||
955 | IDE_TFLAG_OUT_LBAM | | ||
956 | IDE_TFLAG_OUT_LBAH, | ||
957 | IDE_TFLAG_OUT_DEVICE = (1 << 14), | ||
958 | IDE_TFLAG_WRITE = (1 << 15), | ||
959 | IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), | ||
960 | IDE_TFLAG_IN_DATA = (1 << 17), | ||
961 | IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), | ||
962 | IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), | ||
963 | IDE_TFLAG_IN_HOB_FEATURE = (1 << 20), | ||
964 | IDE_TFLAG_IN_HOB_NSECT = (1 << 21), | ||
965 | IDE_TFLAG_IN_HOB_LBAL = (1 << 22), | ||
966 | IDE_TFLAG_IN_HOB_LBAM = (1 << 23), | ||
967 | IDE_TFLAG_IN_HOB_LBAH = (1 << 24), | ||
968 | IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL | | ||
969 | IDE_TFLAG_IN_HOB_LBAM | | ||
970 | IDE_TFLAG_IN_HOB_LBAH, | ||
971 | IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | | ||
972 | IDE_TFLAG_IN_HOB_NSECT | | ||
973 | IDE_TFLAG_IN_HOB_LBA, | ||
974 | IDE_TFLAG_IN_FEATURE = (1 << 1), | ||
975 | IDE_TFLAG_IN_NSECT = (1 << 25), | ||
976 | IDE_TFLAG_IN_LBAL = (1 << 26), | ||
977 | IDE_TFLAG_IN_LBAM = (1 << 27), | ||
978 | IDE_TFLAG_IN_LBAH = (1 << 28), | ||
979 | IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL | | ||
980 | IDE_TFLAG_IN_LBAM | | ||
981 | IDE_TFLAG_IN_LBAH, | ||
982 | IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT | | ||
983 | IDE_TFLAG_IN_LBA, | ||
984 | IDE_TFLAG_IN_DEVICE = (1 << 29), | ||
985 | IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB | | ||
986 | IDE_TFLAG_IN_HOB, | ||
987 | IDE_TFLAG_TF = IDE_TFLAG_OUT_TF | | ||
988 | IDE_TFLAG_IN_TF, | ||
989 | IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE | | ||
990 | IDE_TFLAG_IN_DEVICE, | ||
991 | /* force 16-bit I/O operations */ | ||
992 | IDE_TFLAG_IO_16BIT = (1 << 30), | ||
993 | /* ide_task_t was allocated using kmalloc() */ | ||
994 | IDE_TFLAG_DYN = (1 << 31), | ||
995 | }; | ||
996 | |||
997 | struct ide_taskfile { | ||
998 | u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ | ||
999 | |||
1000 | u8 hob_feature; /* 1-5: additional data to support LBA48 */ | ||
1001 | u8 hob_nsect; | ||
1002 | u8 hob_lbal; | ||
1003 | u8 hob_lbam; | ||
1004 | u8 hob_lbah; | ||
1005 | |||
1006 | u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ | ||
1007 | |||
1008 | union { /* Â 7: */ | ||
1009 | u8 error; /* read: error */ | ||
1010 | u8 feature; /* write: feature */ | ||
1011 | }; | ||
1012 | |||
1013 | u8 nsect; /* 8: number of sectors */ | ||
1014 | u8 lbal; /* 9: LBA low */ | ||
1015 | u8 lbam; /* 10: LBA mid */ | ||
1016 | u8 lbah; /* 11: LBA high */ | ||
1017 | |||
1018 | u8 device; /* 12: device select */ | ||
1019 | |||
1020 | union { /* 13: */ | ||
1021 | u8 status; /*  read: status  */ | ||
1022 | u8 command; /* write: command */ | ||
1023 | }; | ||
1024 | }; | ||
1025 | |||
1026 | typedef struct ide_task_s { | ||
1027 | union { | ||
1028 | struct ide_taskfile tf; | ||
1029 | u8 tf_array[14]; | ||
1030 | }; | ||
1031 | u32 tf_flags; | ||
1032 | int data_phase; | ||
1033 | struct request *rq; /* copy of request */ | ||
1034 | void *special; /* valid_t generally */ | ||
1035 | } ide_task_t; | ||
1036 | |||
1037 | void ide_tf_dump(const char *, struct ide_taskfile *); | 1185 | void ide_tf_dump(const char *, struct ide_taskfile *); |
1038 | 1186 | ||
1039 | void ide_exec_command(ide_hwif_t *, u8); | 1187 | void ide_exec_command(ide_hwif_t *, u8); |
@@ -1049,6 +1197,8 @@ void ide_tf_read(ide_drive_t *, ide_task_t *); | |||
1049 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); | 1197 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); |
1050 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); | 1198 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); |
1051 | 1199 | ||
1200 | int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int); | ||
1201 | |||
1052 | extern void SELECT_DRIVE(ide_drive_t *); | 1202 | extern void SELECT_DRIVE(ide_drive_t *); |
1053 | void SELECT_MASK(ide_drive_t *, int); | 1203 | void SELECT_MASK(ide_drive_t *, int); |
1054 | 1204 | ||
@@ -1059,16 +1209,46 @@ extern int drive_is_ready(ide_drive_t *); | |||
1059 | 1209 | ||
1060 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | 1210 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); |
1061 | 1211 | ||
1062 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 1212 | int ide_check_atapi_device(ide_drive_t *, const char *); |
1063 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1213 | |
1064 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1214 | void ide_init_pc(struct ide_atapi_pc *); |
1065 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 1215 | |
1066 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, | 1216 | /* Disk head parking */ |
1067 | int)); | 1217 | extern wait_queue_head_t ide_park_wq; |
1068 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | 1218 | ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, |
1069 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1219 | char *buf); |
1070 | ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, | 1220 | ssize_t ide_park_store(struct device *dev, struct device_attribute *attr, |
1071 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1221 | const char *buf, size_t len); |
1222 | |||
1223 | /* | ||
1224 | * Special requests for ide-tape block device strategy routine. | ||
1225 | * | ||
1226 | * In order to service a character device command, we add special requests to | ||
1227 | * the tail of our block device request queue and wait for their completion. | ||
1228 | */ | ||
1229 | enum { | ||
1230 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ | ||
1231 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ | ||
1232 | REQ_IDETAPE_READ = (1 << 2), | ||
1233 | REQ_IDETAPE_WRITE = (1 << 3), | ||
1234 | }; | ||
1235 | |||
1236 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); | ||
1237 | |||
1238 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); | ||
1239 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); | ||
1240 | int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); | ||
1241 | void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); | ||
1242 | void ide_retry_pc(ide_drive_t *, struct gendisk *); | ||
1243 | |||
1244 | static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) | ||
1245 | { | ||
1246 | return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); | ||
1247 | } | ||
1248 | |||
1249 | int ide_scsi_expiry(ide_drive_t *); | ||
1250 | |||
1251 | ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); | ||
1072 | 1252 | ||
1073 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); | 1253 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); |
1074 | 1254 | ||
@@ -1078,8 +1258,6 @@ int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); | |||
1078 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); | 1258 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); |
1079 | 1259 | ||
1080 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); | 1260 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); |
1081 | int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
1082 | int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
1083 | 1261 | ||
1084 | extern int ide_driveid_update(ide_drive_t *); | 1262 | extern int ide_driveid_update(ide_drive_t *); |
1085 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 1263 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
@@ -1090,7 +1268,6 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); | |||
1090 | 1268 | ||
1091 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); | 1269 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); |
1092 | 1270 | ||
1093 | extern int ide_spin_wait_hwgroup(ide_drive_t *); | ||
1094 | extern void ide_timer_expiry(unsigned long); | 1271 | extern void ide_timer_expiry(unsigned long); |
1095 | extern irqreturn_t ide_intr(int irq, void *dev_id); | 1272 | extern irqreturn_t ide_intr(int irq, void *dev_id); |
1096 | extern void do_ide_request(struct request_queue *); | 1273 | extern void do_ide_request(struct request_queue *); |
@@ -1111,7 +1288,6 @@ void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); | |||
1111 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 1288 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
1112 | int ide_pci_set_master(struct pci_dev *, const char *); | 1289 | int ide_pci_set_master(struct pci_dev *, const char *); |
1113 | unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); | 1290 | unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); |
1114 | extern const struct ide_dma_ops sff_dma_ops; | ||
1115 | int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *); | 1291 | int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *); |
1116 | int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | 1292 | int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); |
1117 | #else | 1293 | #else |
@@ -1228,6 +1404,14 @@ int ide_pci_init_two(struct pci_dev *, struct pci_dev *, | |||
1228 | const struct ide_port_info *, void *); | 1404 | const struct ide_port_info *, void *); |
1229 | void ide_pci_remove(struct pci_dev *); | 1405 | void ide_pci_remove(struct pci_dev *); |
1230 | 1406 | ||
1407 | #ifdef CONFIG_PM | ||
1408 | int ide_pci_suspend(struct pci_dev *, pm_message_t); | ||
1409 | int ide_pci_resume(struct pci_dev *); | ||
1410 | #else | ||
1411 | #define ide_pci_suspend NULL | ||
1412 | #define ide_pci_resume NULL | ||
1413 | #endif | ||
1414 | |||
1231 | void ide_map_sg(ide_drive_t *, struct request *); | 1415 | void ide_map_sg(ide_drive_t *, struct request *); |
1232 | void ide_init_sg_cmd(ide_drive_t *, struct request *); | 1416 | void ide_init_sg_cmd(ide_drive_t *, struct request *); |
1233 | 1417 | ||
@@ -1239,9 +1423,10 @@ struct drive_list_entry { | |||
1239 | const char *id_firmware; | 1423 | const char *id_firmware; |
1240 | }; | 1424 | }; |
1241 | 1425 | ||
1242 | int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *); | 1426 | int ide_in_drive_list(u16 *, const struct drive_list_entry *); |
1243 | 1427 | ||
1244 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1428 | #ifdef CONFIG_BLK_DEV_IDEDMA |
1429 | int ide_dma_good_drive(ide_drive_t *); | ||
1245 | int __ide_dma_bad_drive(ide_drive_t *); | 1430 | int __ide_dma_bad_drive(ide_drive_t *); |
1246 | int ide_id_dma_bug(ide_drive_t *); | 1431 | int ide_id_dma_bug(ide_drive_t *); |
1247 | 1432 | ||
@@ -1259,24 +1444,29 @@ int ide_set_dma(ide_drive_t *); | |||
1259 | void ide_check_dma_crc(ide_drive_t *); | 1444 | void ide_check_dma_crc(ide_drive_t *); |
1260 | ide_startstop_t ide_dma_intr(ide_drive_t *); | 1445 | ide_startstop_t ide_dma_intr(ide_drive_t *); |
1261 | 1446 | ||
1447 | int ide_allocate_dma_engine(ide_hwif_t *); | ||
1448 | void ide_release_dma_engine(ide_hwif_t *); | ||
1449 | |||
1262 | int ide_build_sglist(ide_drive_t *, struct request *); | 1450 | int ide_build_sglist(ide_drive_t *, struct request *); |
1263 | void ide_destroy_dmatable(ide_drive_t *); | 1451 | void ide_destroy_dmatable(ide_drive_t *); |
1264 | 1452 | ||
1265 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 1453 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
1454 | int config_drive_for_dma(ide_drive_t *); | ||
1266 | extern int ide_build_dmatable(ide_drive_t *, struct request *); | 1455 | extern int ide_build_dmatable(ide_drive_t *, struct request *); |
1267 | int ide_allocate_dma_engine(ide_hwif_t *); | ||
1268 | void ide_release_dma_engine(ide_hwif_t *); | ||
1269 | |||
1270 | void ide_dma_host_set(ide_drive_t *, int); | 1456 | void ide_dma_host_set(ide_drive_t *, int); |
1271 | extern int ide_dma_setup(ide_drive_t *); | 1457 | extern int ide_dma_setup(ide_drive_t *); |
1272 | void ide_dma_exec_cmd(ide_drive_t *, u8); | 1458 | void ide_dma_exec_cmd(ide_drive_t *, u8); |
1273 | extern void ide_dma_start(ide_drive_t *); | 1459 | extern void ide_dma_start(ide_drive_t *); |
1274 | extern int __ide_dma_end(ide_drive_t *); | 1460 | int ide_dma_end(ide_drive_t *); |
1275 | int ide_dma_test_irq(ide_drive_t *); | 1461 | int ide_dma_test_irq(ide_drive_t *); |
1276 | extern void ide_dma_lost_irq(ide_drive_t *); | 1462 | extern const struct ide_dma_ops sff_dma_ops; |
1277 | extern void ide_dma_timeout(ide_drive_t *); | 1463 | #else |
1464 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | ||
1278 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 1465 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
1279 | 1466 | ||
1467 | void ide_dma_lost_irq(ide_drive_t *); | ||
1468 | void ide_dma_timeout(ide_drive_t *); | ||
1469 | |||
1280 | #else | 1470 | #else |
1281 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } | 1471 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } |
1282 | static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } | 1472 | static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } |
@@ -1287,11 +1477,8 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; } | |||
1287 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } | 1477 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } |
1288 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } | 1478 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } |
1289 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | 1479 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } |
1290 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | ||
1291 | |||
1292 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF | ||
1293 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } | 1480 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } |
1294 | #endif | 1481 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
1295 | 1482 | ||
1296 | #ifdef CONFIG_BLK_DEV_IDEACPI | 1483 | #ifdef CONFIG_BLK_DEV_IDEACPI |
1297 | extern int ide_acpi_exec_tfs(ide_drive_t *drive); | 1484 | extern int ide_acpi_exec_tfs(ide_drive_t *drive); |
@@ -1319,7 +1506,6 @@ void ide_undecoded_slave(ide_drive_t *); | |||
1319 | 1506 | ||
1320 | void ide_port_apply_params(ide_hwif_t *); | 1507 | void ide_port_apply_params(ide_hwif_t *); |
1321 | 1508 | ||
1322 | struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **); | ||
1323 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); | 1509 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); |
1324 | void ide_host_free(struct ide_host *); | 1510 | void ide_host_free(struct ide_host *); |
1325 | int ide_host_register(struct ide_host *, const struct ide_port_info *, | 1511 | int ide_host_register(struct ide_host *, const struct ide_port_info *, |
@@ -1345,24 +1531,6 @@ const char *ide_xfer_verbose(u8 mode); | |||
1345 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); | 1531 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); |
1346 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); | 1532 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); |
1347 | 1533 | ||
1348 | static inline int ide_dev_has_iordy(struct hd_driveid *id) | ||
1349 | { | ||
1350 | return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0; | ||
1351 | } | ||
1352 | |||
1353 | static inline int ide_dev_is_sata(struct hd_driveid *id) | ||
1354 | { | ||
1355 | /* | ||
1356 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
1357 | * verifying that word 80 by casting it to a signed type -- | ||
1358 | * this trick allows us to filter out the reserved values of | ||
1359 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
1360 | */ | ||
1361 | if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020) | ||
1362 | return 1; | ||
1363 | return 0; | ||
1364 | } | ||
1365 | |||
1366 | u64 ide_get_lba_addr(struct ide_taskfile *, int); | 1534 | u64 ide_get_lba_addr(struct ide_taskfile *, int); |
1367 | u8 ide_dump_status(ide_drive_t *, const char *, u8); | 1535 | u8 ide_dump_status(ide_drive_t *, const char *, u8); |
1368 | 1536 | ||
@@ -1434,13 +1602,6 @@ extern struct mutex ide_cfg_mtx; | |||
1434 | extern struct bus_type ide_bus_type; | 1602 | extern struct bus_type ide_bus_type; |
1435 | extern struct class *ide_port_class; | 1603 | extern struct class *ide_port_class; |
1436 | 1604 | ||
1437 | /* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ | ||
1438 | #define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) | ||
1439 | |||
1440 | /* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */ | ||
1441 | #define ide_id_has_flush_cache_ext(id) \ | ||
1442 | (((id)->cfs_enable_2 & 0x2400) == 0x2400) | ||
1443 | |||
1444 | static inline void ide_dump_identify(u8 *id) | 1605 | static inline void ide_dump_identify(u8 *id) |
1445 | { | 1606 | { |
1446 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); | 1607 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); |
@@ -1448,14 +1609,13 @@ static inline void ide_dump_identify(u8 *id) | |||
1448 | 1609 | ||
1449 | static inline int hwif_to_node(ide_hwif_t *hwif) | 1610 | static inline int hwif_to_node(ide_hwif_t *hwif) |
1450 | { | 1611 | { |
1451 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1612 | return hwif->dev ? dev_to_node(hwif->dev) : -1; |
1452 | return hwif->dev ? pcibus_to_node(dev->bus) : -1; | ||
1453 | } | 1613 | } |
1454 | 1614 | ||
1455 | static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive) | 1615 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) |
1456 | { | 1616 | { |
1457 | ide_hwif_t *hwif = HWIF(drive); | 1617 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; |
1458 | 1618 | ||
1459 | return &hwif->drives[(drive->dn ^ 1) & 1]; | 1619 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; |
1460 | } | 1620 | } |
1461 | #endif /* _IDE_H */ | 1621 | #endif /* _IDE_H */ |