diff options
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r-- | include/linux/ide.h | 1130 |
1 files changed, 692 insertions, 438 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index 4726126f5a59..54525be4b5f8 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 |
@@ -178,6 +193,7 @@ typedef struct hw_regs_s { | |||
178 | ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ | 193 | ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ |
179 | hwif_chipset_t chipset; | 194 | hwif_chipset_t chipset; |
180 | struct device *dev, *parent; | 195 | struct device *dev, *parent; |
196 | unsigned long config; | ||
181 | } hw_regs_t; | 197 | } hw_regs_t; |
182 | 198 | ||
183 | void ide_init_port_data(struct hwif_s *, unsigned int); | 199 | void ide_init_port_data(struct hwif_s *, unsigned int); |
@@ -210,13 +226,16 @@ static inline int __ide_default_irq(unsigned long base) | |||
210 | return 0; | 226 | return 0; |
211 | } | 227 | } |
212 | 228 | ||
229 | #if defined(CONFIG_ARM) || defined(CONFIG_FRV) || defined(CONFIG_M68K) || \ | ||
230 | defined(CONFIG_MIPS) || defined(CONFIG_MN10300) || defined(CONFIG_PARISC) \ | ||
231 | || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || defined(CONFIG_SPARC64) | ||
213 | #include <asm/ide.h> | 232 | #include <asm/ide.h> |
214 | 233 | #else | |
215 | #if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED) | 234 | #include <asm-generic/ide_iops.h> |
216 | #undef MAX_HWIFS | ||
217 | #define MAX_HWIFS CONFIG_IDE_MAX_HWIFS | ||
218 | #endif | 235 | #endif |
219 | 236 | ||
237 | #define MAX_HWIFS 10 | ||
238 | |||
220 | /* Currently only m68k, apus and m8xx need it */ | 239 | /* Currently only m68k, apus and m8xx need it */ |
221 | #ifndef IDE_ARCH_ACK_INTR | 240 | #ifndef IDE_ARCH_ACK_INTR |
222 | # define ide_ack_intr(hwif) (1) | 241 | # define ide_ack_intr(hwif) (1) |
@@ -245,8 +264,6 @@ static inline int __ide_default_irq(unsigned long base) | |||
245 | * set_geometry : respecify drive geometry | 264 | * set_geometry : respecify drive geometry |
246 | * recalibrate : seek to cyl 0 | 265 | * recalibrate : seek to cyl 0 |
247 | * set_multmode : set multmode count | 266 | * set_multmode : set multmode count |
248 | * set_tune : tune interface for drive | ||
249 | * serviced : service command | ||
250 | * reserved : unused | 267 | * reserved : unused |
251 | */ | 268 | */ |
252 | typedef union { | 269 | typedef union { |
@@ -255,43 +272,11 @@ typedef union { | |||
255 | unsigned set_geometry : 1; | 272 | unsigned set_geometry : 1; |
256 | unsigned recalibrate : 1; | 273 | unsigned recalibrate : 1; |
257 | unsigned set_multmode : 1; | 274 | unsigned set_multmode : 1; |
258 | unsigned set_tune : 1; | 275 | unsigned reserved : 5; |
259 | unsigned serviced : 1; | ||
260 | unsigned reserved : 3; | ||
261 | } b; | 276 | } b; |
262 | } special_t; | 277 | } special_t; |
263 | 278 | ||
264 | /* | 279 | /* |
265 | * ATA-IDE Select Register, aka Device-Head | ||
266 | * | ||
267 | * head : always zeros here | ||
268 | * unit : drive select number: 0/1 | ||
269 | * bit5 : always 1 | ||
270 | * lba : using LBA instead of CHS | ||
271 | * bit7 : always 1 | ||
272 | */ | ||
273 | typedef union { | ||
274 | unsigned all : 8; | ||
275 | struct { | ||
276 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
277 | unsigned head : 4; | ||
278 | unsigned unit : 1; | ||
279 | unsigned bit5 : 1; | ||
280 | unsigned lba : 1; | ||
281 | unsigned bit7 : 1; | ||
282 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
283 | unsigned bit7 : 1; | ||
284 | unsigned lba : 1; | ||
285 | unsigned bit5 : 1; | ||
286 | unsigned unit : 1; | ||
287 | unsigned head : 4; | ||
288 | #else | ||
289 | #error "Please fix <asm/byteorder.h>" | ||
290 | #endif | ||
291 | } b; | ||
292 | } select_t, ata_select_t; | ||
293 | |||
294 | /* | ||
295 | * Status returned from various ide_ functions | 280 | * Status returned from various ide_ functions |
296 | */ | 281 | */ |
297 | typedef enum { | 282 | typedef enum { |
@@ -299,15 +284,318 @@ typedef enum { | |||
299 | ide_started, /* a drive operation was started, handler was set */ | 284 | ide_started, /* a drive operation was started, handler was set */ |
300 | } ide_startstop_t; | 285 | } ide_startstop_t; |
301 | 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; | ||
302 | struct ide_driver_s; | 457 | struct ide_driver_s; |
303 | struct ide_settings_s; | ||
304 | 458 | ||
305 | #ifdef CONFIG_BLK_DEV_IDEACPI | 459 | #ifdef CONFIG_BLK_DEV_IDEACPI |
306 | struct ide_acpi_drive_link; | 460 | struct ide_acpi_drive_link; |
307 | struct ide_acpi_hwif_link; | 461 | struct ide_acpi_hwif_link; |
308 | #endif | 462 | #endif |
309 | 463 | ||
310 | typedef struct ide_drive_s { | 464 | struct ide_drive_s; |
465 | |||
466 | struct ide_disk_ops { | ||
467 | int (*check)(struct ide_drive_s *, const char *); | ||
468 | int (*get_capacity)(struct ide_drive_s *); | ||
469 | void (*setup)(struct ide_drive_s *); | ||
470 | void (*flush)(struct ide_drive_s *); | ||
471 | int (*init_media)(struct ide_drive_s *, struct gendisk *); | ||
472 | int (*set_doorlock)(struct ide_drive_s *, struct gendisk *, | ||
473 | int); | ||
474 | ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *, | ||
475 | sector_t); | ||
476 | int (*end_request)(struct ide_drive_s *, int, int); | ||
477 | int (*ioctl)(struct ide_drive_s *, struct block_device *, | ||
478 | fmode_t, unsigned int, unsigned long); | ||
479 | }; | ||
480 | |||
481 | /* ATAPI device flags */ | ||
482 | enum { | ||
483 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), | ||
484 | |||
485 | /* ide-cd */ | ||
486 | /* Drive cannot eject the disc. */ | ||
487 | IDE_AFLAG_NO_EJECT = (1 << 3), | ||
488 | /* Drive is a pre ATAPI 1.2 drive. */ | ||
489 | IDE_AFLAG_PRE_ATAPI12 = (1 << 4), | ||
490 | /* TOC addresses are in BCD. */ | ||
491 | IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5), | ||
492 | /* TOC track numbers are in BCD. */ | ||
493 | IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6), | ||
494 | /* | ||
495 | * Drive does not provide data in multiples of SECTOR_SIZE | ||
496 | * when more than one interrupt is needed. | ||
497 | */ | ||
498 | IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), | ||
499 | /* Seeking in progress. */ | ||
500 | IDE_AFLAG_SEEKING = (1 << 8), | ||
501 | /* Saved TOC information is current. */ | ||
502 | IDE_AFLAG_TOC_VALID = (1 << 9), | ||
503 | /* We think that the drive door is locked. */ | ||
504 | IDE_AFLAG_DOOR_LOCKED = (1 << 10), | ||
505 | /* SET_CD_SPEED command is unsupported. */ | ||
506 | IDE_AFLAG_NO_SPEED_SELECT = (1 << 11), | ||
507 | IDE_AFLAG_VERTOS_300_SSD = (1 << 12), | ||
508 | IDE_AFLAG_VERTOS_600_ESD = (1 << 13), | ||
509 | IDE_AFLAG_SANYO_3CD = (1 << 14), | ||
510 | IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15), | ||
511 | IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16), | ||
512 | IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), | ||
513 | |||
514 | /* ide-floppy */ | ||
515 | /* Avoid commands not supported in Clik drive */ | ||
516 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), | ||
517 | /* Requires BH algorithm for packets */ | ||
518 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), | ||
519 | /* Supports format progress report */ | ||
520 | IDE_AFLAG_SRFP = (1 << 22), | ||
521 | |||
522 | /* ide-tape */ | ||
523 | IDE_AFLAG_IGNORE_DSC = (1 << 23), | ||
524 | /* 0 When the tape position is unknown */ | ||
525 | IDE_AFLAG_ADDRESS_VALID = (1 << 24), | ||
526 | /* Device already opened */ | ||
527 | IDE_AFLAG_BUSY = (1 << 25), | ||
528 | /* Attempt to auto-detect the current user block size */ | ||
529 | IDE_AFLAG_DETECT_BS = (1 << 26), | ||
530 | /* Currently on a filemark */ | ||
531 | IDE_AFLAG_FILEMARK = (1 << 27), | ||
532 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | ||
533 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), | ||
534 | |||
535 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), | ||
536 | }; | ||
537 | |||
538 | /* device flags */ | ||
539 | enum { | ||
540 | /* restore settings after device reset */ | ||
541 | IDE_DFLAG_KEEP_SETTINGS = (1 << 0), | ||
542 | /* device is using DMA for read/write */ | ||
543 | IDE_DFLAG_USING_DMA = (1 << 1), | ||
544 | /* okay to unmask other IRQs */ | ||
545 | IDE_DFLAG_UNMASK = (1 << 2), | ||
546 | /* don't attempt flushes */ | ||
547 | IDE_DFLAG_NOFLUSH = (1 << 3), | ||
548 | /* DSC overlap */ | ||
549 | IDE_DFLAG_DSC_OVERLAP = (1 << 4), | ||
550 | /* give potential excess bandwidth */ | ||
551 | IDE_DFLAG_NICE1 = (1 << 5), | ||
552 | /* device is physically present */ | ||
553 | IDE_DFLAG_PRESENT = (1 << 6), | ||
554 | /* device ejected hint */ | ||
555 | IDE_DFLAG_DEAD = (1 << 7), | ||
556 | /* id read from device (synthetic if not set) */ | ||
557 | IDE_DFLAG_ID_READ = (1 << 8), | ||
558 | IDE_DFLAG_NOPROBE = (1 << 9), | ||
559 | /* need to do check_media_change() */ | ||
560 | IDE_DFLAG_REMOVABLE = (1 << 10), | ||
561 | /* needed for removable devices */ | ||
562 | IDE_DFLAG_ATTACH = (1 << 11), | ||
563 | IDE_DFLAG_FORCED_GEOM = (1 << 12), | ||
564 | /* disallow setting unmask bit */ | ||
565 | IDE_DFLAG_NO_UNMASK = (1 << 13), | ||
566 | /* disallow enabling 32-bit I/O */ | ||
567 | IDE_DFLAG_NO_IO_32BIT = (1 << 14), | ||
568 | /* for removable only: door lock/unlock works */ | ||
569 | IDE_DFLAG_DOORLOCKING = (1 << 15), | ||
570 | /* disallow DMA */ | ||
571 | IDE_DFLAG_NODMA = (1 << 16), | ||
572 | /* powermanagment told us not to do anything, so sleep nicely */ | ||
573 | IDE_DFLAG_BLOCKED = (1 << 17), | ||
574 | /* ide-scsi emulation */ | ||
575 | IDE_DFLAG_SCSI = (1 << 18), | ||
576 | /* sleeping & sleep field valid */ | ||
577 | IDE_DFLAG_SLEEPING = (1 << 19), | ||
578 | IDE_DFLAG_POST_RESET = (1 << 20), | ||
579 | IDE_DFLAG_UDMA33_WARNED = (1 << 21), | ||
580 | IDE_DFLAG_LBA48 = (1 << 22), | ||
581 | /* status of write cache */ | ||
582 | IDE_DFLAG_WCACHE = (1 << 23), | ||
583 | /* used for ignoring ATA_DF */ | ||
584 | IDE_DFLAG_NOWERR = (1 << 24), | ||
585 | /* retrying in PIO */ | ||
586 | IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), | ||
587 | IDE_DFLAG_LBA = (1 << 26), | ||
588 | /* don't unload heads */ | ||
589 | IDE_DFLAG_NO_UNLOAD = (1 << 27), | ||
590 | /* heads unloaded, please don't reset port */ | ||
591 | IDE_DFLAG_PARKED = (1 << 28), | ||
592 | IDE_DFLAG_MEDIA_CHANGED = (1 << 29), | ||
593 | /* write protect */ | ||
594 | IDE_DFLAG_WP = (1 << 30), | ||
595 | IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 31), | ||
596 | }; | ||
597 | |||
598 | struct ide_drive_s { | ||
311 | char name[4]; /* drive name, such as "hda" */ | 599 | char name[4]; /* drive name, such as "hda" */ |
312 | char driver_req[10]; /* requests specific driver */ | 600 | char driver_req[10]; /* requests specific driver */ |
313 | 601 | ||
@@ -316,73 +604,49 @@ typedef struct ide_drive_s { | |||
316 | struct request *rq; /* current request */ | 604 | struct request *rq; /* current request */ |
317 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | 605 | struct ide_drive_s *next; /* circular list of hwgroup drives */ |
318 | void *driver_data; /* extra driver data */ | 606 | void *driver_data; /* extra driver data */ |
319 | struct hd_driveid *id; /* drive model identification info */ | 607 | u16 *id; /* identification info */ |
320 | #ifdef CONFIG_IDE_PROC_FS | 608 | #ifdef CONFIG_IDE_PROC_FS |
321 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 609 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
322 | struct ide_settings_s *settings;/* /proc/ide/ drive settings */ | 610 | const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ |
323 | #endif | 611 | #endif |
324 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ | 612 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ |
325 | 613 | ||
614 | const struct ide_disk_ops *disk_ops; | ||
615 | |||
616 | unsigned long dev_flags; | ||
617 | |||
326 | unsigned long sleep; /* sleep until this time */ | 618 | unsigned long sleep; /* sleep until this time */ |
327 | unsigned long service_start; /* time we started last request */ | 619 | unsigned long service_start; /* time we started last request */ |
328 | unsigned long service_time; /* service time of last request */ | 620 | unsigned long service_time; /* service time of last request */ |
329 | unsigned long timeout; /* max time to wait for irq */ | 621 | unsigned long timeout; /* max time to wait for irq */ |
330 | 622 | ||
331 | special_t special; /* special action flags */ | 623 | special_t special; /* special action flags */ |
332 | select_t select; /* basic drive/head select reg value */ | ||
333 | 624 | ||
334 | u8 keep_settings; /* restore settings after drive reset */ | 625 | u8 select; /* basic drive/head select reg value */ |
335 | u8 using_dma; /* disk is using dma for read/write */ | ||
336 | u8 retry_pio; /* retrying dma capable host in pio */ | 626 | u8 retry_pio; /* retrying dma capable host in pio */ |
337 | u8 state; /* retry state */ | ||
338 | u8 waiting_for_dma; /* dma currently in progress */ | 627 | u8 waiting_for_dma; /* dma currently in progress */ |
339 | u8 unmask; /* okay to unmask other irqs */ | 628 | u8 dma; /* atapi dma flag */ |
340 | u8 noflush; /* don't attempt flushes */ | 629 | |
341 | u8 dsc_overlap; /* DSC overlap */ | ||
342 | u8 nice1; /* give potential excess bandwidth */ | ||
343 | |||
344 | unsigned present : 1; /* drive is physically present */ | ||
345 | unsigned dead : 1; /* device ejected hint */ | ||
346 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ | ||
347 | unsigned noprobe : 1; /* from: hdx=noprobe */ | ||
348 | unsigned removable : 1; /* 1 if need to do check_media_change */ | ||
349 | unsigned attach : 1; /* needed for removable devices */ | ||
350 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ | ||
351 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | ||
352 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | ||
353 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ | ||
354 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | ||
355 | unsigned nodma : 1; /* disallow DMA */ | ||
356 | unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ | ||
357 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ | ||
358 | unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */ | ||
359 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ | ||
360 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ | ||
361 | unsigned post_reset : 1; | ||
362 | unsigned udma33_warned : 1; | ||
363 | |||
364 | u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
365 | u8 quirk_list; /* considered quirky, set for a specific host */ | 630 | u8 quirk_list; /* considered quirky, set for a specific host */ |
366 | u8 init_speed; /* transfer rate set at boot */ | 631 | u8 init_speed; /* transfer rate set at boot */ |
367 | u8 current_speed; /* current transfer rate set */ | 632 | u8 current_speed; /* current transfer rate set */ |
368 | u8 desired_speed; /* desired transfer rate set */ | 633 | u8 desired_speed; /* desired transfer rate set */ |
369 | u8 dn; /* now wide spread use */ | 634 | u8 dn; /* now wide spread use */ |
370 | u8 wcache; /* status of write cache */ | ||
371 | u8 acoustic; /* acoustic management */ | 635 | u8 acoustic; /* acoustic management */ |
372 | u8 media; /* disk, cdrom, tape, floppy, ... */ | 636 | u8 media; /* disk, cdrom, tape, floppy, ... */ |
373 | u8 ready_stat; /* min status value for drive ready */ | 637 | u8 ready_stat; /* min status value for drive ready */ |
374 | u8 mult_count; /* current multiple sector setting */ | 638 | u8 mult_count; /* current multiple sector setting */ |
375 | u8 mult_req; /* requested multiple sector setting */ | 639 | u8 mult_req; /* requested multiple sector setting */ |
376 | u8 tune_req; /* requested drive tuning setting */ | ||
377 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ | 640 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ |
378 | u8 bad_wstat; /* used for ignoring WRERR_STAT */ | 641 | u8 bad_wstat; /* used for ignoring ATA_DF */ |
379 | u8 nowerr; /* used for ignoring WRERR_STAT */ | ||
380 | u8 sect0; /* offset of first sector for DM6:DDO */ | ||
381 | u8 head; /* "real" number of heads */ | 642 | u8 head; /* "real" number of heads */ |
382 | u8 sect; /* "real" sectors per track */ | 643 | u8 sect; /* "real" sectors per track */ |
383 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ | 644 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ |
384 | u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ | 645 | u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ |
385 | 646 | ||
647 | /* delay this long before sending packet command */ | ||
648 | u8 pc_delay; | ||
649 | |||
386 | unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ | 650 | unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ |
387 | unsigned int cyl; /* "real" number of cyls */ | 651 | unsigned int cyl; /* "real" number of cyls */ |
388 | unsigned int drive_data; /* used by set_pio_mode/selectproc */ | 652 | unsigned int drive_data; /* used by set_pio_mode/selectproc */ |
@@ -394,41 +658,93 @@ typedef struct ide_drive_s { | |||
394 | 658 | ||
395 | int lun; /* logical unit */ | 659 | int lun; /* logical unit */ |
396 | int crc_count; /* crc counter to reduce drive speed */ | 660 | int crc_count; /* crc counter to reduce drive speed */ |
661 | |||
662 | unsigned long debug_mask; /* debugging levels switch */ | ||
663 | |||
397 | #ifdef CONFIG_BLK_DEV_IDEACPI | 664 | #ifdef CONFIG_BLK_DEV_IDEACPI |
398 | struct ide_acpi_drive_link *acpidata; | 665 | struct ide_acpi_drive_link *acpidata; |
399 | #endif | 666 | #endif |
400 | struct list_head list; | 667 | struct list_head list; |
401 | struct device gendev; | 668 | struct device gendev; |
402 | struct completion gendev_rel_comp; /* to deal with device release() */ | 669 | struct completion gendev_rel_comp; /* to deal with device release() */ |
403 | } ide_drive_t; | ||
404 | 670 | ||
405 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) | 671 | /* current packet command */ |
672 | struct ide_atapi_pc *pc; | ||
673 | |||
674 | /* callback for packet commands */ | ||
675 | void (*pc_callback)(struct ide_drive_s *, int); | ||
676 | |||
677 | void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *); | ||
678 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, | ||
679 | unsigned int, int); | ||
680 | |||
681 | unsigned long atapi_flags; | ||
682 | |||
683 | struct ide_atapi_pc request_sense_pc; | ||
684 | struct request request_sense_rq; | ||
685 | }; | ||
686 | |||
687 | typedef struct ide_drive_s ide_drive_t; | ||
688 | |||
689 | #define to_ide_device(dev) container_of(dev, ide_drive_t, gendev) | ||
406 | 690 | ||
407 | #define IDE_CHIPSET_PCI_MASK \ | 691 | #define to_ide_drv(obj, cont_type) \ |
408 | ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) | 692 | container_of(obj, struct cont_type, kref) |
409 | #define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) | 693 | |
694 | #define ide_drv_g(disk, cont_type) \ | ||
695 | container_of((disk)->private_data, struct cont_type, driver) | ||
410 | 696 | ||
411 | struct ide_port_info; | 697 | struct ide_port_info; |
412 | 698 | ||
699 | struct ide_tp_ops { | ||
700 | void (*exec_command)(struct hwif_s *, u8); | ||
701 | u8 (*read_status)(struct hwif_s *); | ||
702 | u8 (*read_altstatus)(struct hwif_s *); | ||
703 | u8 (*read_sff_dma_status)(struct hwif_s *); | ||
704 | |||
705 | void (*set_irq)(struct hwif_s *, int); | ||
706 | |||
707 | void (*tf_load)(ide_drive_t *, struct ide_task_s *); | ||
708 | void (*tf_read)(ide_drive_t *, struct ide_task_s *); | ||
709 | |||
710 | void (*input_data)(ide_drive_t *, struct request *, void *, | ||
711 | unsigned int); | ||
712 | void (*output_data)(ide_drive_t *, struct request *, void *, | ||
713 | unsigned int); | ||
714 | }; | ||
715 | |||
716 | extern const struct ide_tp_ops default_tp_ops; | ||
717 | |||
718 | /** | ||
719 | * struct ide_port_ops - IDE port operations | ||
720 | * | ||
721 | * @init_dev: host specific initialization of a device | ||
722 | * @set_pio_mode: routine to program host for PIO mode | ||
723 | * @set_dma_mode: routine to program host for DMA mode | ||
724 | * @selectproc: tweaks hardware to select drive | ||
725 | * @reset_poll: chipset polling based on hba specifics | ||
726 | * @pre_reset: chipset specific changes to default for device-hba resets | ||
727 | * @resetproc: routine to reset controller after a disk reset | ||
728 | * @maskproc: special host masking for drive selection | ||
729 | * @quirkproc: check host's drive quirk list | ||
730 | * @clear_irq: clear IRQ | ||
731 | * | ||
732 | * @mdma_filter: filter MDMA modes | ||
733 | * @udma_filter: filter UDMA modes | ||
734 | * | ||
735 | * @cable_detect: detect cable type | ||
736 | */ | ||
413 | struct ide_port_ops { | 737 | struct ide_port_ops { |
414 | /* host specific initialization of a device */ | ||
415 | void (*init_dev)(ide_drive_t *); | 738 | void (*init_dev)(ide_drive_t *); |
416 | /* routine to program host for PIO mode */ | ||
417 | void (*set_pio_mode)(ide_drive_t *, const u8); | 739 | void (*set_pio_mode)(ide_drive_t *, const u8); |
418 | /* routine to program host for DMA mode */ | ||
419 | void (*set_dma_mode)(ide_drive_t *, const u8); | 740 | void (*set_dma_mode)(ide_drive_t *, const u8); |
420 | /* tweaks hardware to select drive */ | ||
421 | void (*selectproc)(ide_drive_t *); | 741 | void (*selectproc)(ide_drive_t *); |
422 | /* chipset polling based on hba specifics */ | ||
423 | int (*reset_poll)(ide_drive_t *); | 742 | int (*reset_poll)(ide_drive_t *); |
424 | /* chipset specific changes to default for device-hba resets */ | ||
425 | void (*pre_reset)(ide_drive_t *); | 743 | void (*pre_reset)(ide_drive_t *); |
426 | /* routine to reset controller after a disk reset */ | ||
427 | void (*resetproc)(ide_drive_t *); | 744 | void (*resetproc)(ide_drive_t *); |
428 | /* special host masking for drive selection */ | ||
429 | void (*maskproc)(ide_drive_t *, int); | 745 | void (*maskproc)(ide_drive_t *, int); |
430 | /* check host's drive quirk list */ | ||
431 | void (*quirkproc)(ide_drive_t *); | 746 | void (*quirkproc)(ide_drive_t *); |
747 | void (*clear_irq)(ide_drive_t *); | ||
432 | 748 | ||
433 | u8 (*mdma_filter)(ide_drive_t *); | 749 | u8 (*mdma_filter)(ide_drive_t *); |
434 | u8 (*udma_filter)(ide_drive_t *); | 750 | u8 (*udma_filter)(ide_drive_t *); |
@@ -447,7 +763,7 @@ struct ide_dma_ops { | |||
447 | void (*dma_timeout)(struct ide_drive_s *); | 763 | void (*dma_timeout)(struct ide_drive_s *); |
448 | }; | 764 | }; |
449 | 765 | ||
450 | struct ide_task_s; | 766 | struct ide_host; |
451 | 767 | ||
452 | typedef struct hwif_s { | 768 | typedef struct hwif_s { |
453 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ | 769 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ |
@@ -455,6 +771,8 @@ typedef struct hwif_s { | |||
455 | struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ | 771 | struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ |
456 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 772 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
457 | 773 | ||
774 | struct ide_host *host; | ||
775 | |||
458 | char name[6]; /* name of interface, eg. "ide0" */ | 776 | char name[6]; /* name of interface, eg. "ide0" */ |
459 | 777 | ||
460 | struct ide_io_ports io_ports; | 778 | struct ide_io_ports io_ports; |
@@ -466,7 +784,6 @@ typedef struct hwif_s { | |||
466 | u8 major; /* our major number */ | 784 | u8 major; /* our major number */ |
467 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 785 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
468 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ | 786 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ |
469 | u8 bus_state; /* power state of the IDE bus */ | ||
470 | 787 | ||
471 | u32 host_flags; | 788 | u32 host_flags; |
472 | 789 | ||
@@ -486,26 +803,20 @@ typedef struct hwif_s { | |||
486 | 803 | ||
487 | void (*rw_disk)(ide_drive_t *, struct request *); | 804 | void (*rw_disk)(ide_drive_t *, struct request *); |
488 | 805 | ||
806 | const struct ide_tp_ops *tp_ops; | ||
489 | const struct ide_port_ops *port_ops; | 807 | const struct ide_port_ops *port_ops; |
490 | const struct ide_dma_ops *dma_ops; | 808 | const struct ide_dma_ops *dma_ops; |
491 | 809 | ||
492 | void (*tf_load)(ide_drive_t *, struct ide_task_s *); | ||
493 | void (*tf_read)(ide_drive_t *, struct ide_task_s *); | ||
494 | |||
495 | void (*input_data)(ide_drive_t *, struct request *, void *, unsigned); | ||
496 | void (*output_data)(ide_drive_t *, struct request *, void *, unsigned); | ||
497 | |||
498 | void (*ide_dma_clear_irq)(ide_drive_t *drive); | ||
499 | |||
500 | void (*OUTB)(u8 addr, unsigned long port); | ||
501 | void (*OUTBSYNC)(struct hwif_s *hwif, u8 addr, unsigned long port); | ||
502 | |||
503 | u8 (*INB)(unsigned long port); | ||
504 | |||
505 | /* dma physical region descriptor table (cpu view) */ | 810 | /* dma physical region descriptor table (cpu view) */ |
506 | unsigned int *dmatable_cpu; | 811 | unsigned int *dmatable_cpu; |
507 | /* dma physical region descriptor table (dma view) */ | 812 | /* dma physical region descriptor table (dma view) */ |
508 | dma_addr_t dmatable_dma; | 813 | dma_addr_t dmatable_dma; |
814 | |||
815 | /* maximum number of PRD table entries */ | ||
816 | int prd_max_nents; | ||
817 | /* PRD entry size in bytes */ | ||
818 | int prd_ent_size; | ||
819 | |||
509 | /* Scatter-gather list used to build the above */ | 820 | /* Scatter-gather list used to build the above */ |
510 | struct scatterlist *sg_table; | 821 | struct scatterlist *sg_table; |
511 | int sg_max_nents; /* Maximum number of entries in it */ | 822 | int sg_max_nents; /* Maximum number of entries in it */ |
@@ -515,6 +826,8 @@ typedef struct hwif_s { | |||
515 | /* data phase of the active command (currently only valid for PIO/DMA) */ | 826 | /* data phase of the active command (currently only valid for PIO/DMA) */ |
516 | int data_phase; | 827 | int data_phase; |
517 | 828 | ||
829 | struct ide_task_s task; /* current command */ | ||
830 | |||
518 | unsigned int nsect; | 831 | unsigned int nsect; |
519 | unsigned int nleft; | 832 | unsigned int nleft; |
520 | struct scatterlist *cursg; | 833 | struct scatterlist *cursg; |
@@ -524,8 +837,6 @@ typedef struct hwif_s { | |||
524 | int irq; /* our irq number */ | 837 | int irq; /* our irq number */ |
525 | 838 | ||
526 | unsigned long dma_base; /* base addr for dma ports */ | 839 | unsigned long dma_base; /* base addr for dma ports */ |
527 | unsigned long dma_command; /* dma command register */ | ||
528 | unsigned long dma_status; /* dma status register */ | ||
529 | 840 | ||
530 | unsigned long config_data; /* for use by chipset-specific code */ | 841 | unsigned long config_data; /* for use by chipset-specific code */ |
531 | unsigned long select_data; /* for use by chipset-specific code */ | 842 | unsigned long select_data; /* for use by chipset-specific code */ |
@@ -545,13 +856,22 @@ typedef struct hwif_s { | |||
545 | 856 | ||
546 | void *hwif_data; /* extra hwif data */ | 857 | void *hwif_data; /* extra hwif data */ |
547 | 858 | ||
548 | unsigned dma; | ||
549 | |||
550 | #ifdef CONFIG_BLK_DEV_IDEACPI | 859 | #ifdef CONFIG_BLK_DEV_IDEACPI |
551 | struct ide_acpi_hwif_link *acpidata; | 860 | struct ide_acpi_hwif_link *acpidata; |
552 | #endif | 861 | #endif |
553 | } ____cacheline_internodealigned_in_smp ide_hwif_t; | 862 | } ____cacheline_internodealigned_in_smp ide_hwif_t; |
554 | 863 | ||
864 | #define MAX_HOST_PORTS 4 | ||
865 | |||
866 | struct ide_host { | ||
867 | ide_hwif_t *ports[MAX_HOST_PORTS]; | ||
868 | unsigned int n_ports; | ||
869 | struct device *dev[2]; | ||
870 | unsigned int (*init_chipset)(struct pci_dev *); | ||
871 | unsigned long host_flags; | ||
872 | void *host_priv; | ||
873 | }; | ||
874 | |||
555 | /* | 875 | /* |
556 | * internal ide interrupt handler type | 876 | * internal ide interrupt handler type |
557 | */ | 877 | */ |
@@ -595,106 +915,116 @@ typedef struct ide_driver_s ide_driver_t; | |||
595 | 915 | ||
596 | extern struct mutex ide_setting_mtx; | 916 | extern struct mutex ide_setting_mtx; |
597 | 917 | ||
598 | int set_io_32bit(ide_drive_t *, int); | 918 | /* |
599 | int set_pio_mode(ide_drive_t *, int); | 919 | * configurable drive settings |
600 | int set_using_dma(ide_drive_t *, int); | 920 | */ |
601 | 921 | ||
602 | /* ATAPI packet command flags */ | 922 | #define DS_SYNC (1 << 0) |
603 | enum { | 923 | |
604 | /* set when an error is considered normal - no retry (ide-tape) */ | 924 | struct ide_devset { |
605 | PC_FLAG_ABORT = (1 << 0), | 925 | int (*get)(ide_drive_t *); |
606 | PC_FLAG_SUPPRESS_ERROR = (1 << 1), | 926 | int (*set)(ide_drive_t *, int); |
607 | PC_FLAG_WAIT_FOR_DSC = (1 << 2), | 927 | unsigned int flags; |
608 | PC_FLAG_DMA_OK = (1 << 3), | ||
609 | PC_FLAG_DMA_IN_PROGRESS = (1 << 4), | ||
610 | PC_FLAG_DMA_ERROR = (1 << 5), | ||
611 | PC_FLAG_WRITING = (1 << 6), | ||
612 | /* command timed out */ | ||
613 | PC_FLAG_TIMEDOUT = (1 << 7), | ||
614 | PC_FLAG_ZIP_DRIVE = (1 << 8), | ||
615 | PC_FLAG_DRQ_INTERRUPT = (1 << 9), | ||
616 | }; | 928 | }; |
617 | 929 | ||
618 | struct ide_atapi_pc { | 930 | #define __DEVSET(_flags, _get, _set) { \ |
619 | /* actual packet bytes */ | 931 | .flags = _flags, \ |
620 | u8 c[12]; | 932 | .get = _get, \ |
621 | /* incremented on each retry */ | 933 | .set = _set, \ |
622 | int retries; | 934 | } |
623 | int error; | ||
624 | 935 | ||
625 | /* bytes to transfer */ | 936 | #define ide_devset_get(name, field) \ |
626 | int req_xfer; | 937 | static int get_##name(ide_drive_t *drive) \ |
627 | /* bytes actually transferred */ | 938 | { \ |
628 | int xferred; | 939 | return drive->field; \ |
940 | } | ||
629 | 941 | ||
630 | /* data buffer */ | 942 | #define ide_devset_set(name, field) \ |
631 | u8 *buf; | 943 | static int set_##name(ide_drive_t *drive, int arg) \ |
632 | /* current buffer position */ | 944 | { \ |
633 | u8 *cur_pos; | 945 | drive->field = arg; \ |
634 | int buf_size; | 946 | return 0; \ |
635 | /* missing/available data on the current buffer */ | 947 | } |
636 | int b_count; | ||
637 | 948 | ||
638 | /* the corresponding request */ | 949 | #define ide_devset_get_flag(name, flag) \ |
639 | struct request *rq; | 950 | static int get_##name(ide_drive_t *drive) \ |
951 | { \ | ||
952 | return !!(drive->dev_flags & flag); \ | ||
953 | } | ||
640 | 954 | ||
641 | unsigned long flags; | 955 | #define ide_devset_set_flag(name, flag) \ |
956 | static int set_##name(ide_drive_t *drive, int arg) \ | ||
957 | { \ | ||
958 | if (arg) \ | ||
959 | drive->dev_flags |= flag; \ | ||
960 | else \ | ||
961 | drive->dev_flags &= ~flag; \ | ||
962 | return 0; \ | ||
963 | } | ||
642 | 964 | ||
643 | /* | 965 | #define __IDE_DEVSET(_name, _flags, _get, _set) \ |
644 | * those are more or less driver-specific and some of them are subject | 966 | const struct ide_devset ide_devset_##_name = \ |
645 | * to change/removal later. | 967 | __DEVSET(_flags, _get, _set) |
646 | */ | ||
647 | u8 pc_buf[256]; | ||
648 | 968 | ||
649 | void (*callback)(ide_drive_t *); | 969 | #define IDE_DEVSET(_name, _flags, _get, _set) \ |
970 | static __IDE_DEVSET(_name, _flags, _get, _set) | ||
650 | 971 | ||
651 | /* idetape only */ | 972 | #define ide_devset_rw(_name, _func) \ |
652 | struct idetape_bh *bh; | 973 | IDE_DEVSET(_name, 0, get_##_func, set_##_func) |
653 | char *b_data; | ||
654 | 974 | ||
655 | /* idescsi only for now */ | 975 | #define ide_devset_w(_name, _func) \ |
656 | struct scatterlist *sg; | 976 | IDE_DEVSET(_name, 0, NULL, set_##_func) |
657 | unsigned int sg_cnt; | ||
658 | 977 | ||
659 | struct scsi_cmnd *scsi_cmd; | 978 | #define ide_ext_devset_rw(_name, _func) \ |
660 | void (*done) (struct scsi_cmnd *); | 979 | __IDE_DEVSET(_name, 0, get_##_func, set_##_func) |
661 | 980 | ||
662 | unsigned long timeout; | 981 | #define ide_ext_devset_rw_sync(_name, _func) \ |
663 | }; | 982 | __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) |
983 | |||
984 | #define ide_decl_devset(_name) \ | ||
985 | extern const struct ide_devset ide_devset_##_name | ||
986 | |||
987 | ide_decl_devset(io_32bit); | ||
988 | ide_decl_devset(keepsettings); | ||
989 | ide_decl_devset(pio_mode); | ||
990 | ide_decl_devset(unmaskirq); | ||
991 | ide_decl_devset(using_dma); | ||
664 | 992 | ||
665 | #ifdef CONFIG_IDE_PROC_FS | 993 | #ifdef CONFIG_IDE_PROC_FS |
666 | /* | 994 | /* |
667 | * configurable drive settings | 995 | * /proc/ide interface |
668 | */ | 996 | */ |
669 | 997 | ||
670 | #define TYPE_INT 0 | 998 | #define ide_devset_rw_field(_name, _field) \ |
671 | #define TYPE_BYTE 1 | 999 | ide_devset_get(_name, _field); \ |
672 | #define TYPE_SHORT 2 | 1000 | ide_devset_set(_name, _field); \ |
1001 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
1002 | |||
1003 | #define ide_devset_rw_flag(_name, _field) \ | ||
1004 | ide_devset_get_flag(_name, _field); \ | ||
1005 | ide_devset_set_flag(_name, _field); \ | ||
1006 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
1007 | |||
1008 | struct ide_proc_devset { | ||
1009 | const char *name; | ||
1010 | const struct ide_devset *setting; | ||
1011 | int min, max; | ||
1012 | int (*mulf)(ide_drive_t *); | ||
1013 | int (*divf)(ide_drive_t *); | ||
1014 | }; | ||
673 | 1015 | ||
674 | #define SETTING_READ (1 << 0) | 1016 | #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ |
675 | #define SETTING_WRITE (1 << 1) | 1017 | .name = __stringify(_name), \ |
676 | #define SETTING_RW (SETTING_READ | SETTING_WRITE) | 1018 | .setting = &ide_devset_##_name, \ |
1019 | .min = _min, \ | ||
1020 | .max = _max, \ | ||
1021 | .mulf = _mulf, \ | ||
1022 | .divf = _divf, \ | ||
1023 | } | ||
677 | 1024 | ||
678 | typedef int (ide_procset_t)(ide_drive_t *, int); | 1025 | #define IDE_PROC_DEVSET(_name, _min, _max) \ |
679 | typedef struct ide_settings_s { | 1026 | __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) |
680 | char *name; | ||
681 | int rw; | ||
682 | int data_type; | ||
683 | int min; | ||
684 | int max; | ||
685 | int mul_factor; | ||
686 | int div_factor; | ||
687 | void *data; | ||
688 | ide_procset_t *set; | ||
689 | int auto_remove; | ||
690 | struct ide_settings_s *next; | ||
691 | } ide_settings_t; | ||
692 | |||
693 | int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set); | ||
694 | 1027 | ||
695 | /* | ||
696 | * /proc/ide interface | ||
697 | */ | ||
698 | typedef struct { | 1028 | typedef struct { |
699 | const char *name; | 1029 | const char *name; |
700 | mode_t mode; | 1030 | mode_t mode; |
@@ -711,8 +1041,6 @@ void ide_proc_unregister_port(ide_hwif_t *); | |||
711 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 1041 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); |
712 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 1042 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); |
713 | 1043 | ||
714 | void ide_add_generic_settings(ide_drive_t *); | ||
715 | |||
716 | read_proc_t proc_ide_read_capacity; | 1044 | read_proc_t proc_ide_read_capacity; |
717 | read_proc_t proc_ide_read_geometry; | 1045 | read_proc_t proc_ide_read_geometry; |
718 | 1046 | ||
@@ -740,41 +1068,58 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | |||
740 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 1068 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
741 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1069 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
742 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1070 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
743 | static inline void ide_add_generic_settings(ide_drive_t *drive) { ; } | ||
744 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 1071 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
745 | #endif | 1072 | #endif |
746 | 1073 | ||
1074 | enum { | ||
1075 | /* enter/exit functions */ | ||
1076 | IDE_DBG_FUNC = (1 << 0), | ||
1077 | /* sense key/asc handling */ | ||
1078 | IDE_DBG_SENSE = (1 << 1), | ||
1079 | /* packet commands handling */ | ||
1080 | IDE_DBG_PC = (1 << 2), | ||
1081 | /* request handling */ | ||
1082 | IDE_DBG_RQ = (1 << 3), | ||
1083 | /* driver probing/setup */ | ||
1084 | IDE_DBG_PROBE = (1 << 4), | ||
1085 | }; | ||
1086 | |||
1087 | /* DRV_NAME has to be defined in the driver before using the macro below */ | ||
1088 | #define __ide_debug_log(lvl, fmt, args...) \ | ||
1089 | { \ | ||
1090 | if (unlikely(drive->debug_mask & lvl)) \ | ||
1091 | printk(KERN_INFO DRV_NAME ": " fmt, ## args); \ | ||
1092 | } | ||
1093 | |||
747 | /* | 1094 | /* |
748 | * Power Management step value (rq->pm->pm_step). | 1095 | * Power Management state machine (rq->pm->pm_step). |
749 | * | ||
750 | * The step value starts at 0 (ide_pm_state_start_suspend) for a | ||
751 | * suspend operation or 1000 (ide_pm_state_start_resume) for a | ||
752 | * resume operation. | ||
753 | * | 1096 | * |
754 | * For each step, the core calls the subdriver start_power_step() first. | 1097 | * For each step, the core calls ide_start_power_step() first. |
755 | * This can return: | 1098 | * This can return: |
756 | * - ide_stopped : In this case, the core calls us back again unless | 1099 | * - ide_stopped : In this case, the core calls us back again unless |
757 | * step have been set to ide_power_state_completed. | 1100 | * step have been set to ide_power_state_completed. |
758 | * - ide_started : In this case, the channel is left busy until an | 1101 | * - ide_started : In this case, the channel is left busy until an |
759 | * async event (interrupt) occurs. | 1102 | * async event (interrupt) occurs. |
760 | * Typically, start_power_step() will issue a taskfile request with | 1103 | * Typically, ide_start_power_step() will issue a taskfile request with |
761 | * do_rw_taskfile(). | 1104 | * do_rw_taskfile(). |
762 | * | 1105 | * |
763 | * Upon reception of the interrupt, the core will call complete_power_step() | 1106 | * Upon reception of the interrupt, the core will call ide_complete_power_step() |
764 | * with the error code if any. This routine should update the step value | 1107 | * with the error code if any. This routine should update the step value |
765 | * and return. It should not start a new request. The core will call | 1108 | * and return. It should not start a new request. The core will call |
766 | * start_power_step for the new step value, unless step have been set to | 1109 | * ide_start_power_step() for the new step value, unless step have been |
767 | * ide_power_state_completed. | 1110 | * set to IDE_PM_COMPLETED. |
768 | * | ||
769 | * Subdrivers are expected to define their own additional power | ||
770 | * steps from 1..999 for suspend and from 1001..1999 for resume, | ||
771 | * other values are reserved for future use. | ||
772 | */ | 1111 | */ |
773 | |||
774 | enum { | 1112 | enum { |
775 | ide_pm_state_completed = -1, | 1113 | IDE_PM_START_SUSPEND, |
776 | ide_pm_state_start_suspend = 0, | 1114 | IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND, |
777 | ide_pm_state_start_resume = 1000, | 1115 | IDE_PM_STANDBY, |
1116 | |||
1117 | IDE_PM_START_RESUME, | ||
1118 | IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME, | ||
1119 | IDE_PM_IDLE, | ||
1120 | IDE_PM_RESTORE_DMA, | ||
1121 | |||
1122 | IDE_PM_COMPLETED, | ||
778 | }; | 1123 | }; |
779 | 1124 | ||
780 | /* | 1125 | /* |
@@ -785,8 +1130,6 @@ enum { | |||
785 | */ | 1130 | */ |
786 | struct ide_driver_s { | 1131 | struct ide_driver_s { |
787 | const char *version; | 1132 | const char *version; |
788 | u8 media; | ||
789 | unsigned supports_dsc_overlap : 1; | ||
790 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 1133 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
791 | int (*end_request)(ide_drive_t *, int, int); | 1134 | int (*end_request)(ide_drive_t *, int, int); |
792 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | 1135 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); |
@@ -796,23 +1139,29 @@ struct ide_driver_s { | |||
796 | void (*resume)(ide_drive_t *); | 1139 | void (*resume)(ide_drive_t *); |
797 | void (*shutdown)(ide_drive_t *); | 1140 | void (*shutdown)(ide_drive_t *); |
798 | #ifdef CONFIG_IDE_PROC_FS | 1141 | #ifdef CONFIG_IDE_PROC_FS |
799 | ide_proc_entry_t *proc; | 1142 | ide_proc_entry_t * (*proc_entries)(ide_drive_t *); |
1143 | const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *); | ||
800 | #endif | 1144 | #endif |
801 | }; | 1145 | }; |
802 | 1146 | ||
803 | #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) | 1147 | #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) |
804 | 1148 | ||
805 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); | 1149 | int ide_device_get(ide_drive_t *); |
1150 | void ide_device_put(ide_drive_t *); | ||
806 | 1151 | ||
807 | extern int ide_vlb_clk; | 1152 | struct ide_ioctl_devset { |
808 | extern int ide_pci_clk; | 1153 | unsigned int get_ioctl; |
1154 | unsigned int set_ioctl; | ||
1155 | const struct ide_devset *setting; | ||
1156 | }; | ||
809 | 1157 | ||
810 | ide_hwif_t *ide_find_port_slot(const struct ide_port_info *); | 1158 | int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int, |
1159 | unsigned long, const struct ide_ioctl_devset *); | ||
811 | 1160 | ||
812 | static inline ide_hwif_t *ide_find_port(void) | 1161 | int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned long); |
813 | { | 1162 | |
814 | return ide_find_port_slot(NULL); | 1163 | extern int ide_vlb_clk; |
815 | } | 1164 | extern int ide_pci_clk; |
816 | 1165 | ||
817 | extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); | 1166 | extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); |
818 | int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, | 1167 | int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, |
@@ -831,140 +1180,90 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | |||
831 | 1180 | ||
832 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); | 1181 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); |
833 | 1182 | ||
834 | extern void ide_fix_driveid(struct hd_driveid *); | 1183 | void ide_fix_driveid(u16 *); |
835 | 1184 | ||
836 | extern void ide_fixstring(u8 *, const int, const int); | 1185 | extern void ide_fixstring(u8 *, const int, const int); |
837 | 1186 | ||
1187 | int ide_busy_sleep(ide_hwif_t *, unsigned long, int); | ||
1188 | |||
838 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); | 1189 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); |
839 | 1190 | ||
840 | extern ide_startstop_t ide_do_reset (ide_drive_t *); | 1191 | extern ide_startstop_t ide_do_reset (ide_drive_t *); |
841 | 1192 | ||
1193 | extern int ide_devset_execute(ide_drive_t *drive, | ||
1194 | const struct ide_devset *setting, int arg); | ||
1195 | |||
842 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); | 1196 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); |
843 | 1197 | ||
844 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); | 1198 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); |
845 | 1199 | ||
846 | enum { | 1200 | void ide_tf_dump(const char *, struct ide_taskfile *); |
847 | IDE_TFLAG_LBA48 = (1 << 0), | ||
848 | IDE_TFLAG_FLAGGED = (1 << 2), | ||
849 | IDE_TFLAG_OUT_DATA = (1 << 3), | ||
850 | IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), | ||
851 | IDE_TFLAG_OUT_HOB_NSECT = (1 << 5), | ||
852 | IDE_TFLAG_OUT_HOB_LBAL = (1 << 6), | ||
853 | IDE_TFLAG_OUT_HOB_LBAM = (1 << 7), | ||
854 | IDE_TFLAG_OUT_HOB_LBAH = (1 << 8), | ||
855 | IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE | | ||
856 | IDE_TFLAG_OUT_HOB_NSECT | | ||
857 | IDE_TFLAG_OUT_HOB_LBAL | | ||
858 | IDE_TFLAG_OUT_HOB_LBAM | | ||
859 | IDE_TFLAG_OUT_HOB_LBAH, | ||
860 | IDE_TFLAG_OUT_FEATURE = (1 << 9), | ||
861 | IDE_TFLAG_OUT_NSECT = (1 << 10), | ||
862 | IDE_TFLAG_OUT_LBAL = (1 << 11), | ||
863 | IDE_TFLAG_OUT_LBAM = (1 << 12), | ||
864 | IDE_TFLAG_OUT_LBAH = (1 << 13), | ||
865 | IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE | | ||
866 | IDE_TFLAG_OUT_NSECT | | ||
867 | IDE_TFLAG_OUT_LBAL | | ||
868 | IDE_TFLAG_OUT_LBAM | | ||
869 | IDE_TFLAG_OUT_LBAH, | ||
870 | IDE_TFLAG_OUT_DEVICE = (1 << 14), | ||
871 | IDE_TFLAG_WRITE = (1 << 15), | ||
872 | IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), | ||
873 | IDE_TFLAG_IN_DATA = (1 << 17), | ||
874 | IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), | ||
875 | IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), | ||
876 | IDE_TFLAG_IN_HOB_FEATURE = (1 << 20), | ||
877 | IDE_TFLAG_IN_HOB_NSECT = (1 << 21), | ||
878 | IDE_TFLAG_IN_HOB_LBAL = (1 << 22), | ||
879 | IDE_TFLAG_IN_HOB_LBAM = (1 << 23), | ||
880 | IDE_TFLAG_IN_HOB_LBAH = (1 << 24), | ||
881 | IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL | | ||
882 | IDE_TFLAG_IN_HOB_LBAM | | ||
883 | IDE_TFLAG_IN_HOB_LBAH, | ||
884 | IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | | ||
885 | IDE_TFLAG_IN_HOB_NSECT | | ||
886 | IDE_TFLAG_IN_HOB_LBA, | ||
887 | IDE_TFLAG_IN_NSECT = (1 << 25), | ||
888 | IDE_TFLAG_IN_LBAL = (1 << 26), | ||
889 | IDE_TFLAG_IN_LBAM = (1 << 27), | ||
890 | IDE_TFLAG_IN_LBAH = (1 << 28), | ||
891 | IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL | | ||
892 | IDE_TFLAG_IN_LBAM | | ||
893 | IDE_TFLAG_IN_LBAH, | ||
894 | IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT | | ||
895 | IDE_TFLAG_IN_LBA, | ||
896 | IDE_TFLAG_IN_DEVICE = (1 << 29), | ||
897 | IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB | | ||
898 | IDE_TFLAG_IN_HOB, | ||
899 | IDE_TFLAG_TF = IDE_TFLAG_OUT_TF | | ||
900 | IDE_TFLAG_IN_TF, | ||
901 | IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE | | ||
902 | IDE_TFLAG_IN_DEVICE, | ||
903 | /* force 16-bit I/O operations */ | ||
904 | IDE_TFLAG_IO_16BIT = (1 << 30), | ||
905 | /* ide_task_t was allocated using kmalloc() */ | ||
906 | IDE_TFLAG_DYN = (1 << 31), | ||
907 | }; | ||
908 | |||
909 | struct ide_taskfile { | ||
910 | u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ | ||
911 | |||
912 | u8 hob_feature; /* 1-5: additional data to support LBA48 */ | ||
913 | u8 hob_nsect; | ||
914 | u8 hob_lbal; | ||
915 | u8 hob_lbam; | ||
916 | u8 hob_lbah; | ||
917 | |||
918 | u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ | ||
919 | |||
920 | union { /* Â 7: */ | ||
921 | u8 error; /* read: error */ | ||
922 | u8 feature; /* write: feature */ | ||
923 | }; | ||
924 | 1201 | ||
925 | u8 nsect; /* 8: number of sectors */ | 1202 | void ide_exec_command(ide_hwif_t *, u8); |
926 | u8 lbal; /* 9: LBA low */ | 1203 | u8 ide_read_status(ide_hwif_t *); |
927 | u8 lbam; /* 10: LBA mid */ | 1204 | u8 ide_read_altstatus(ide_hwif_t *); |
928 | u8 lbah; /* 11: LBA high */ | 1205 | u8 ide_read_sff_dma_status(ide_hwif_t *); |
929 | 1206 | ||
930 | u8 device; /* 12: device select */ | 1207 | void ide_set_irq(ide_hwif_t *, int); |
931 | 1208 | ||
932 | union { /* 13: */ | 1209 | void ide_tf_load(ide_drive_t *, ide_task_t *); |
933 | u8 status; /*  read: status  */ | 1210 | void ide_tf_read(ide_drive_t *, ide_task_t *); |
934 | u8 command; /* write: command */ | ||
935 | }; | ||
936 | }; | ||
937 | 1211 | ||
938 | typedef struct ide_task_s { | 1212 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); |
939 | union { | 1213 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); |
940 | struct ide_taskfile tf; | ||
941 | u8 tf_array[14]; | ||
942 | }; | ||
943 | u32 tf_flags; | ||
944 | int data_phase; | ||
945 | struct request *rq; /* copy of request */ | ||
946 | void *special; /* valid_t generally */ | ||
947 | } ide_task_t; | ||
948 | 1214 | ||
949 | void ide_tf_dump(const char *, struct ide_taskfile *); | 1215 | int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int); |
950 | 1216 | ||
951 | extern void SELECT_DRIVE(ide_drive_t *); | 1217 | extern void SELECT_DRIVE(ide_drive_t *); |
952 | void SELECT_MASK(ide_drive_t *, int); | 1218 | void SELECT_MASK(ide_drive_t *, int); |
953 | 1219 | ||
1220 | u8 ide_read_error(ide_drive_t *); | ||
1221 | void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *); | ||
1222 | |||
954 | extern int drive_is_ready(ide_drive_t *); | 1223 | extern int drive_is_ready(ide_drive_t *); |
955 | 1224 | ||
956 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | 1225 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); |
957 | 1226 | ||
958 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 1227 | int ide_check_atapi_device(ide_drive_t *, const char *); |
959 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1228 | |
960 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1229 | void ide_init_pc(struct ide_atapi_pc *); |
961 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 1230 | |
962 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, | 1231 | /* Disk head parking */ |
963 | int)); | 1232 | extern wait_queue_head_t ide_park_wq; |
964 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | 1233 | ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, |
965 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1234 | char *buf); |
966 | ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, | 1235 | ssize_t ide_park_store(struct device *dev, struct device_attribute *attr, |
967 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1236 | const char *buf, size_t len); |
1237 | |||
1238 | /* | ||
1239 | * Special requests for ide-tape block device strategy routine. | ||
1240 | * | ||
1241 | * In order to service a character device command, we add special requests to | ||
1242 | * the tail of our block device request queue and wait for their completion. | ||
1243 | */ | ||
1244 | enum { | ||
1245 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ | ||
1246 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ | ||
1247 | REQ_IDETAPE_READ = (1 << 2), | ||
1248 | REQ_IDETAPE_WRITE = (1 << 3), | ||
1249 | }; | ||
1250 | |||
1251 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); | ||
1252 | |||
1253 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); | ||
1254 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); | ||
1255 | int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); | ||
1256 | void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); | ||
1257 | void ide_retry_pc(ide_drive_t *, struct gendisk *); | ||
1258 | |||
1259 | static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) | ||
1260 | { | ||
1261 | return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); | ||
1262 | } | ||
1263 | |||
1264 | int ide_scsi_expiry(ide_drive_t *); | ||
1265 | |||
1266 | ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); | ||
968 | 1267 | ||
969 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); | 1268 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); |
970 | 1269 | ||
@@ -974,8 +1273,6 @@ int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); | |||
974 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); | 1273 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); |
975 | 1274 | ||
976 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); | 1275 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); |
977 | int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
978 | int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
979 | 1276 | ||
980 | extern int ide_driveid_update(ide_drive_t *); | 1277 | extern int ide_driveid_update(ide_drive_t *); |
981 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 1278 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
@@ -986,7 +1283,6 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); | |||
986 | 1283 | ||
987 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); | 1284 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); |
988 | 1285 | ||
989 | extern int ide_spin_wait_hwgroup(ide_drive_t *); | ||
990 | extern void ide_timer_expiry(unsigned long); | 1286 | extern void ide_timer_expiry(unsigned long); |
991 | extern irqreturn_t ide_intr(int irq, void *dev_id); | 1287 | extern irqreturn_t ide_intr(int irq, void *dev_id); |
992 | extern void do_ide_request(struct request_queue *); | 1288 | extern void do_ide_request(struct request_queue *); |
@@ -1000,12 +1296,14 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o | |||
1000 | #define ide_pci_register_driver(d) pci_register_driver(d) | 1296 | #define ide_pci_register_driver(d) pci_register_driver(d) |
1001 | #endif | 1297 | #endif |
1002 | 1298 | ||
1003 | void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); | 1299 | void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, |
1300 | hw_regs_t *, hw_regs_t **); | ||
1004 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); | 1301 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); |
1005 | 1302 | ||
1006 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 1303 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
1007 | int ide_pci_set_master(struct pci_dev *, const char *); | 1304 | int ide_pci_set_master(struct pci_dev *, const char *); |
1008 | unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); | 1305 | unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); |
1306 | int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *); | ||
1009 | int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | 1307 | int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); |
1010 | #else | 1308 | #else |
1011 | static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, | 1309 | static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, |
@@ -1015,10 +1313,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, | |||
1015 | } | 1313 | } |
1016 | #endif | 1314 | #endif |
1017 | 1315 | ||
1018 | extern void default_hwif_iops(ide_hwif_t *); | ||
1019 | extern void default_hwif_mmiops(ide_hwif_t *); | ||
1020 | extern void default_hwif_transport(ide_hwif_t *); | ||
1021 | |||
1022 | typedef struct ide_pci_enablebit_s { | 1316 | typedef struct ide_pci_enablebit_s { |
1023 | u8 reg; /* byte pci reg holding the enable-bit */ | 1317 | u8 reg; /* byte pci reg holding the enable-bit */ |
1024 | u8 mask; /* mask to isolate the enable-bit */ | 1318 | u8 mask; /* mask to isolate the enable-bit */ |
@@ -1081,7 +1375,6 @@ enum { | |||
1081 | IDE_HFLAG_IO_32BIT = (1 << 24), | 1375 | IDE_HFLAG_IO_32BIT = (1 << 24), |
1082 | /* unmask IRQs */ | 1376 | /* unmask IRQs */ |
1083 | IDE_HFLAG_UNMASK_IRQS = (1 << 25), | 1377 | IDE_HFLAG_UNMASK_IRQS = (1 << 25), |
1084 | IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), | ||
1085 | /* serialize ports if DMA is possible (for sl82c105) */ | 1378 | /* serialize ports if DMA is possible (for sl82c105) */ |
1086 | IDE_HFLAG_SERIALIZE_DMA = (1 << 27), | 1379 | IDE_HFLAG_SERIALIZE_DMA = (1 << 27), |
1087 | /* force host out of "simplex" mode */ | 1380 | /* force host out of "simplex" mode */ |
@@ -1092,8 +1385,6 @@ enum { | |||
1092 | IDE_HFLAG_NO_IO_32BIT = (1 << 30), | 1385 | IDE_HFLAG_NO_IO_32BIT = (1 << 30), |
1093 | /* never unmask IRQs */ | 1386 | /* never unmask IRQs */ |
1094 | IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), | 1387 | IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), |
1095 | /* host uses VDMA (disabled for now) */ | ||
1096 | IDE_HFLAG_VDMA = 0, | ||
1097 | }; | 1388 | }; |
1098 | 1389 | ||
1099 | #ifdef CONFIG_BLK_DEV_OFFBOARD | 1390 | #ifdef CONFIG_BLK_DEV_OFFBOARD |
@@ -1104,12 +1395,13 @@ enum { | |||
1104 | 1395 | ||
1105 | struct ide_port_info { | 1396 | struct ide_port_info { |
1106 | char *name; | 1397 | char *name; |
1107 | unsigned int (*init_chipset)(struct pci_dev *, const char *); | 1398 | unsigned int (*init_chipset)(struct pci_dev *); |
1108 | void (*init_iops)(ide_hwif_t *); | 1399 | void (*init_iops)(ide_hwif_t *); |
1109 | void (*init_hwif)(ide_hwif_t *); | 1400 | void (*init_hwif)(ide_hwif_t *); |
1110 | int (*init_dma)(ide_hwif_t *, | 1401 | int (*init_dma)(ide_hwif_t *, |
1111 | const struct ide_port_info *); | 1402 | const struct ide_port_info *); |
1112 | 1403 | ||
1404 | const struct ide_tp_ops *tp_ops; | ||
1113 | const struct ide_port_ops *port_ops; | 1405 | const struct ide_port_ops *port_ops; |
1114 | const struct ide_dma_ops *dma_ops; | 1406 | const struct ide_dma_ops *dma_ops; |
1115 | 1407 | ||
@@ -1122,8 +1414,18 @@ struct ide_port_info { | |||
1122 | u8 udma_mask; | 1414 | u8 udma_mask; |
1123 | }; | 1415 | }; |
1124 | 1416 | ||
1125 | int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *); | 1417 | int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *); |
1126 | int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *); | 1418 | int ide_pci_init_two(struct pci_dev *, struct pci_dev *, |
1419 | const struct ide_port_info *, void *); | ||
1420 | void ide_pci_remove(struct pci_dev *); | ||
1421 | |||
1422 | #ifdef CONFIG_PM | ||
1423 | int ide_pci_suspend(struct pci_dev *, pm_message_t); | ||
1424 | int ide_pci_resume(struct pci_dev *); | ||
1425 | #else | ||
1426 | #define ide_pci_suspend NULL | ||
1427 | #define ide_pci_resume NULL | ||
1428 | #endif | ||
1127 | 1429 | ||
1128 | void ide_map_sg(ide_drive_t *, struct request *); | 1430 | void ide_map_sg(ide_drive_t *, struct request *); |
1129 | void ide_init_sg_cmd(ide_drive_t *, struct request *); | 1431 | void ide_init_sg_cmd(ide_drive_t *, struct request *); |
@@ -1136,9 +1438,10 @@ struct drive_list_entry { | |||
1136 | const char *id_firmware; | 1438 | const char *id_firmware; |
1137 | }; | 1439 | }; |
1138 | 1440 | ||
1139 | int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *); | 1441 | int ide_in_drive_list(u16 *, const struct drive_list_entry *); |
1140 | 1442 | ||
1141 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1443 | #ifdef CONFIG_BLK_DEV_IDEDMA |
1444 | int ide_dma_good_drive(ide_drive_t *); | ||
1142 | int __ide_dma_bad_drive(ide_drive_t *); | 1445 | int __ide_dma_bad_drive(ide_drive_t *); |
1143 | int ide_id_dma_bug(ide_drive_t *); | 1446 | int ide_id_dma_bug(ide_drive_t *); |
1144 | 1447 | ||
@@ -1156,25 +1459,29 @@ int ide_set_dma(ide_drive_t *); | |||
1156 | void ide_check_dma_crc(ide_drive_t *); | 1459 | void ide_check_dma_crc(ide_drive_t *); |
1157 | ide_startstop_t ide_dma_intr(ide_drive_t *); | 1460 | ide_startstop_t ide_dma_intr(ide_drive_t *); |
1158 | 1461 | ||
1462 | int ide_allocate_dma_engine(ide_hwif_t *); | ||
1463 | void ide_release_dma_engine(ide_hwif_t *); | ||
1464 | |||
1159 | int ide_build_sglist(ide_drive_t *, struct request *); | 1465 | int ide_build_sglist(ide_drive_t *, struct request *); |
1160 | void ide_destroy_dmatable(ide_drive_t *); | 1466 | void ide_destroy_dmatable(ide_drive_t *); |
1161 | 1467 | ||
1162 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 1468 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
1469 | int config_drive_for_dma(ide_drive_t *); | ||
1163 | extern int ide_build_dmatable(ide_drive_t *, struct request *); | 1470 | extern int ide_build_dmatable(ide_drive_t *, struct request *); |
1164 | int ide_allocate_dma_engine(ide_hwif_t *); | ||
1165 | void ide_release_dma_engine(ide_hwif_t *); | ||
1166 | void ide_setup_dma(ide_hwif_t *, unsigned long); | ||
1167 | |||
1168 | void ide_dma_host_set(ide_drive_t *, int); | 1471 | void ide_dma_host_set(ide_drive_t *, int); |
1169 | extern int ide_dma_setup(ide_drive_t *); | 1472 | extern int ide_dma_setup(ide_drive_t *); |
1170 | void ide_dma_exec_cmd(ide_drive_t *, u8); | 1473 | void ide_dma_exec_cmd(ide_drive_t *, u8); |
1171 | extern void ide_dma_start(ide_drive_t *); | 1474 | extern void ide_dma_start(ide_drive_t *); |
1172 | extern int __ide_dma_end(ide_drive_t *); | 1475 | int ide_dma_end(ide_drive_t *); |
1173 | int ide_dma_test_irq(ide_drive_t *); | 1476 | int ide_dma_test_irq(ide_drive_t *); |
1174 | extern void ide_dma_lost_irq(ide_drive_t *); | 1477 | extern const struct ide_dma_ops sff_dma_ops; |
1175 | extern void ide_dma_timeout(ide_drive_t *); | 1478 | #else |
1479 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | ||
1176 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 1480 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
1177 | 1481 | ||
1482 | void ide_dma_lost_irq(ide_drive_t *); | ||
1483 | void ide_dma_timeout(ide_drive_t *); | ||
1484 | |||
1178 | #else | 1485 | #else |
1179 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } | 1486 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } |
1180 | static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } | 1487 | static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } |
@@ -1185,11 +1492,8 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; } | |||
1185 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } | 1492 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } |
1186 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } | 1493 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } |
1187 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | 1494 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } |
1188 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | ||
1189 | |||
1190 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF | ||
1191 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } | 1495 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } |
1192 | #endif | 1496 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
1193 | 1497 | ||
1194 | #ifdef CONFIG_BLK_DEV_IDEACPI | 1498 | #ifdef CONFIG_BLK_DEV_IDEACPI |
1195 | extern int ide_acpi_exec_tfs(ide_drive_t *drive); | 1499 | extern int ide_acpi_exec_tfs(ide_drive_t *drive); |
@@ -1217,8 +1521,13 @@ void ide_undecoded_slave(ide_drive_t *); | |||
1217 | 1521 | ||
1218 | void ide_port_apply_params(ide_hwif_t *); | 1522 | void ide_port_apply_params(ide_hwif_t *); |
1219 | 1523 | ||
1220 | int ide_device_add_all(u8 *idx, const struct ide_port_info *); | 1524 | struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); |
1221 | int ide_device_add(u8 idx[4], const struct ide_port_info *); | 1525 | void ide_host_free(struct ide_host *); |
1526 | int ide_host_register(struct ide_host *, const struct ide_port_info *, | ||
1527 | hw_regs_t **); | ||
1528 | int ide_host_add(const struct ide_port_info *, hw_regs_t **, | ||
1529 | struct ide_host **); | ||
1530 | void ide_host_remove(struct ide_host *); | ||
1222 | int ide_legacy_device_add(const struct ide_port_info *, unsigned long); | 1531 | int ide_legacy_device_add(const struct ide_port_info *, unsigned long); |
1223 | void ide_port_unregister_devices(ide_hwif_t *); | 1532 | void ide_port_unregister_devices(ide_hwif_t *); |
1224 | void ide_port_scan(ide_hwif_t *); | 1533 | void ide_port_scan(ide_hwif_t *); |
@@ -1237,24 +1546,6 @@ const char *ide_xfer_verbose(u8 mode); | |||
1237 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); | 1546 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); |
1238 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); | 1547 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); |
1239 | 1548 | ||
1240 | static inline int ide_dev_has_iordy(struct hd_driveid *id) | ||
1241 | { | ||
1242 | return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0; | ||
1243 | } | ||
1244 | |||
1245 | static inline int ide_dev_is_sata(struct hd_driveid *id) | ||
1246 | { | ||
1247 | /* | ||
1248 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
1249 | * verifying that word 80 by casting it to a signed type -- | ||
1250 | * this trick allows us to filter out the reserved values of | ||
1251 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
1252 | */ | ||
1253 | if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020) | ||
1254 | return 1; | ||
1255 | return 0; | ||
1256 | } | ||
1257 | |||
1258 | u64 ide_get_lba_addr(struct ide_taskfile *, int); | 1549 | u64 ide_get_lba_addr(struct ide_taskfile *, int); |
1259 | u8 ide_dump_status(ide_drive_t *, const char *, u8); | 1550 | u8 ide_dump_status(ide_drive_t *, const char *, u8); |
1260 | 1551 | ||
@@ -1326,13 +1617,6 @@ extern struct mutex ide_cfg_mtx; | |||
1326 | extern struct bus_type ide_bus_type; | 1617 | extern struct bus_type ide_bus_type; |
1327 | extern struct class *ide_port_class; | 1618 | extern struct class *ide_port_class; |
1328 | 1619 | ||
1329 | /* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ | ||
1330 | #define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) | ||
1331 | |||
1332 | /* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */ | ||
1333 | #define ide_id_has_flush_cache_ext(id) \ | ||
1334 | (((id)->cfs_enable_2 & 0x2400) == 0x2400) | ||
1335 | |||
1336 | static inline void ide_dump_identify(u8 *id) | 1620 | static inline void ide_dump_identify(u8 *id) |
1337 | { | 1621 | { |
1338 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); | 1622 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); |
@@ -1340,43 +1624,13 @@ static inline void ide_dump_identify(u8 *id) | |||
1340 | 1624 | ||
1341 | static inline int hwif_to_node(ide_hwif_t *hwif) | 1625 | static inline int hwif_to_node(ide_hwif_t *hwif) |
1342 | { | 1626 | { |
1343 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1627 | return hwif->dev ? dev_to_node(hwif->dev) : -1; |
1344 | return hwif->dev ? pcibus_to_node(dev->bus) : -1; | ||
1345 | } | ||
1346 | |||
1347 | static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive) | ||
1348 | { | ||
1349 | ide_hwif_t *hwif = HWIF(drive); | ||
1350 | |||
1351 | return &hwif->drives[(drive->dn ^ 1) & 1]; | ||
1352 | } | ||
1353 | |||
1354 | static inline void ide_set_irq(ide_drive_t *drive, int on) | ||
1355 | { | ||
1356 | ide_hwif_t *hwif = drive->hwif; | ||
1357 | |||
1358 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | (on ? 0 : 2), | ||
1359 | hwif->io_ports.ctl_addr); | ||
1360 | } | ||
1361 | |||
1362 | static inline u8 ide_read_status(ide_drive_t *drive) | ||
1363 | { | ||
1364 | ide_hwif_t *hwif = drive->hwif; | ||
1365 | |||
1366 | return hwif->INB(hwif->io_ports.status_addr); | ||
1367 | } | ||
1368 | |||
1369 | static inline u8 ide_read_altstatus(ide_drive_t *drive) | ||
1370 | { | ||
1371 | ide_hwif_t *hwif = drive->hwif; | ||
1372 | |||
1373 | return hwif->INB(hwif->io_ports.ctl_addr); | ||
1374 | } | 1628 | } |
1375 | 1629 | ||
1376 | static inline u8 ide_read_error(ide_drive_t *drive) | 1630 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) |
1377 | { | 1631 | { |
1378 | ide_hwif_t *hwif = drive->hwif; | 1632 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; |
1379 | 1633 | ||
1380 | return hwif->INB(hwif->io_ports.error_addr); | 1634 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; |
1381 | } | 1635 | } |
1382 | #endif /* _IDE_H */ | 1636 | #endif /* _IDE_H */ |