diff options
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index f24e4bb94760..d1b21668be6e 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -91,7 +91,7 @@ enum { | |||
91 | ATA_SHT_EMULATED = 1, | 91 | ATA_SHT_EMULATED = 1, |
92 | ATA_SHT_CMD_PER_LUN = 1, | 92 | ATA_SHT_CMD_PER_LUN = 1, |
93 | ATA_SHT_THIS_ID = -1, | 93 | ATA_SHT_THIS_ID = -1, |
94 | ATA_SHT_USE_CLUSTERING = 0, | 94 | ATA_SHT_USE_CLUSTERING = 1, |
95 | 95 | ||
96 | /* struct ata_device stuff */ | 96 | /* struct ata_device stuff */ |
97 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ | 97 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ |
@@ -205,7 +205,7 @@ struct ata_ioports { | |||
205 | struct ata_probe_ent { | 205 | struct ata_probe_ent { |
206 | struct list_head node; | 206 | struct list_head node; |
207 | struct device *dev; | 207 | struct device *dev; |
208 | struct ata_port_operations *port_ops; | 208 | const struct ata_port_operations *port_ops; |
209 | Scsi_Host_Template *sht; | 209 | Scsi_Host_Template *sht; |
210 | struct ata_ioports port[ATA_MAX_PORTS]; | 210 | struct ata_ioports port[ATA_MAX_PORTS]; |
211 | unsigned int n_ports; | 211 | unsigned int n_ports; |
@@ -228,7 +228,7 @@ struct ata_host_set { | |||
228 | void __iomem *mmio_base; | 228 | void __iomem *mmio_base; |
229 | unsigned int n_ports; | 229 | unsigned int n_ports; |
230 | void *private_data; | 230 | void *private_data; |
231 | struct ata_port_operations *ops; | 231 | const struct ata_port_operations *ops; |
232 | struct ata_port * ports[0]; | 232 | struct ata_port * ports[0]; |
233 | }; | 233 | }; |
234 | 234 | ||
@@ -297,7 +297,7 @@ struct ata_device { | |||
297 | 297 | ||
298 | struct ata_port { | 298 | struct ata_port { |
299 | struct Scsi_Host *host; /* our co-allocated scsi host */ | 299 | struct Scsi_Host *host; /* our co-allocated scsi host */ |
300 | struct ata_port_operations *ops; | 300 | const struct ata_port_operations *ops; |
301 | unsigned long flags; /* ATA_FLAG_xxx */ | 301 | unsigned long flags; /* ATA_FLAG_xxx */ |
302 | unsigned int id; /* unique id req'd by scsi midlyr */ | 302 | unsigned int id; /* unique id req'd by scsi midlyr */ |
303 | unsigned int port_no; /* unique port #; from zero */ | 303 | unsigned int port_no; /* unique port #; from zero */ |
@@ -344,10 +344,10 @@ struct ata_port_operations { | |||
344 | void (*set_piomode) (struct ata_port *, struct ata_device *); | 344 | void (*set_piomode) (struct ata_port *, struct ata_device *); |
345 | void (*set_dmamode) (struct ata_port *, struct ata_device *); | 345 | void (*set_dmamode) (struct ata_port *, struct ata_device *); |
346 | 346 | ||
347 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); | 347 | void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf); |
348 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | 348 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); |
349 | 349 | ||
350 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | 350 | void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf); |
351 | u8 (*check_status)(struct ata_port *ap); | 351 | u8 (*check_status)(struct ata_port *ap); |
352 | u8 (*check_altstatus)(struct ata_port *ap); | 352 | u8 (*check_altstatus)(struct ata_port *ap); |
353 | u8 (*check_err)(struct ata_port *ap); | 353 | u8 (*check_err)(struct ata_port *ap); |
@@ -388,9 +388,22 @@ struct ata_port_info { | |||
388 | unsigned long pio_mask; | 388 | unsigned long pio_mask; |
389 | unsigned long mwdma_mask; | 389 | unsigned long mwdma_mask; |
390 | unsigned long udma_mask; | 390 | unsigned long udma_mask; |
391 | struct ata_port_operations *port_ops; | 391 | const struct ata_port_operations *port_ops; |
392 | }; | 392 | }; |
393 | 393 | ||
394 | struct ata_timing { | ||
395 | unsigned short mode; /* ATA mode */ | ||
396 | unsigned short setup; /* t1 */ | ||
397 | unsigned short act8b; /* t2 for 8-bit I/O */ | ||
398 | unsigned short rec8b; /* t2i for 8-bit I/O */ | ||
399 | unsigned short cyc8b; /* t0 for 8-bit I/O */ | ||
400 | unsigned short active; /* t2 or tD */ | ||
401 | unsigned short recover; /* t2i or tK */ | ||
402 | unsigned short cycle; /* t0 */ | ||
403 | unsigned short udma; /* t2CYCTYP/2 */ | ||
404 | }; | ||
405 | |||
406 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | ||
394 | 407 | ||
395 | extern void ata_port_probe(struct ata_port *); | 408 | extern void ata_port_probe(struct ata_port *); |
396 | extern void __sata_phy_reset(struct ata_port *ap); | 409 | extern void __sata_phy_reset(struct ata_port *ap); |
@@ -403,7 +416,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i | |||
403 | unsigned int n_ports); | 416 | unsigned int n_ports); |
404 | extern void ata_pci_remove_one (struct pci_dev *pdev); | 417 | extern void ata_pci_remove_one (struct pci_dev *pdev); |
405 | #endif /* CONFIG_PCI */ | 418 | #endif /* CONFIG_PCI */ |
406 | extern int ata_device_add(struct ata_probe_ent *ent); | 419 | extern int ata_device_add(const struct ata_probe_ent *ent); |
407 | extern void ata_host_set_remove(struct ata_host_set *host_set); | 420 | extern void ata_host_set_remove(struct ata_host_set *host_set); |
408 | extern int ata_scsi_detect(Scsi_Host_Template *sht); | 421 | extern int ata_scsi_detect(Scsi_Host_Template *sht); |
409 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 422 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
@@ -416,16 +429,16 @@ extern int ata_ratelimit(void); | |||
416 | /* | 429 | /* |
417 | * Default driver ops implementations | 430 | * Default driver ops implementations |
418 | */ | 431 | */ |
419 | extern void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf); | 432 | extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); |
420 | extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 433 | extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
421 | extern void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp); | 434 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp); |
422 | extern void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf); | 435 | extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); |
423 | extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device); | 436 | extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device); |
424 | extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); | 437 | extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); |
425 | extern u8 ata_check_status(struct ata_port *ap); | 438 | extern u8 ata_check_status(struct ata_port *ap); |
426 | extern u8 ata_altstatus(struct ata_port *ap); | 439 | extern u8 ata_altstatus(struct ata_port *ap); |
427 | extern u8 ata_chk_err(struct ata_port *ap); | 440 | extern u8 ata_chk_err(struct ata_port *ap); |
428 | extern void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf); | 441 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
429 | extern int ata_port_start (struct ata_port *ap); | 442 | extern int ata_port_start (struct ata_port *ap); |
430 | extern void ata_port_stop (struct ata_port *ap); | 443 | extern void ata_port_stop (struct ata_port *ap); |
431 | extern void ata_host_stop (struct ata_host_set *host_set); | 444 | extern void ata_host_stop (struct ata_host_set *host_set); |
@@ -436,8 +449,8 @@ extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, | |||
436 | unsigned int buflen); | 449 | unsigned int buflen); |
437 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 450 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
438 | unsigned int n_elem); | 451 | unsigned int n_elem); |
439 | extern unsigned int ata_dev_classify(struct ata_taskfile *tf); | 452 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); |
440 | extern void ata_dev_id_string(u16 *id, unsigned char *s, | 453 | extern void ata_dev_id_string(const u16 *id, unsigned char *s, |
441 | unsigned int ofs, unsigned int len); | 454 | unsigned int ofs, unsigned int len); |
442 | extern void ata_dev_config(struct ata_port *ap, unsigned int i); | 455 | extern void ata_dev_config(struct ata_port *ap, unsigned int i); |
443 | extern void ata_bmdma_setup (struct ata_queued_cmd *qc); | 456 | extern void ata_bmdma_setup (struct ata_queued_cmd *qc); |
@@ -454,6 +467,32 @@ extern int ata_std_bios_param(struct scsi_device *sdev, | |||
454 | sector_t capacity, int geom[]); | 467 | sector_t capacity, int geom[]); |
455 | extern int ata_scsi_slave_config(struct scsi_device *sdev); | 468 | extern int ata_scsi_slave_config(struct scsi_device *sdev); |
456 | 469 | ||
470 | /* | ||
471 | * Timing helpers | ||
472 | */ | ||
473 | extern int ata_timing_compute(struct ata_device *, unsigned short, | ||
474 | struct ata_timing *, int, int); | ||
475 | extern void ata_timing_merge(const struct ata_timing *, | ||
476 | const struct ata_timing *, struct ata_timing *, | ||
477 | unsigned int); | ||
478 | |||
479 | enum { | ||
480 | ATA_TIMING_SETUP = (1 << 0), | ||
481 | ATA_TIMING_ACT8B = (1 << 1), | ||
482 | ATA_TIMING_REC8B = (1 << 2), | ||
483 | ATA_TIMING_CYC8B = (1 << 3), | ||
484 | ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B | | ||
485 | ATA_TIMING_CYC8B, | ||
486 | ATA_TIMING_ACTIVE = (1 << 4), | ||
487 | ATA_TIMING_RECOVER = (1 << 5), | ||
488 | ATA_TIMING_CYCLE = (1 << 6), | ||
489 | ATA_TIMING_UDMA = (1 << 7), | ||
490 | ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B | | ||
491 | ATA_TIMING_REC8B | ATA_TIMING_CYC8B | | ||
492 | ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER | | ||
493 | ATA_TIMING_CYCLE | ATA_TIMING_UDMA, | ||
494 | }; | ||
495 | |||
457 | 496 | ||
458 | #ifdef CONFIG_PCI | 497 | #ifdef CONFIG_PCI |
459 | struct pci_bits { | 498 | struct pci_bits { |
@@ -466,7 +505,7 @@ struct pci_bits { | |||
466 | extern void ata_pci_host_stop (struct ata_host_set *host_set); | 505 | extern void ata_pci_host_stop (struct ata_host_set *host_set); |
467 | extern struct ata_probe_ent * | 506 | extern struct ata_probe_ent * |
468 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); | 507 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); |
469 | extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits); | 508 | extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); |
470 | 509 | ||
471 | #endif /* CONFIG_PCI */ | 510 | #endif /* CONFIG_PCI */ |
472 | 511 | ||
@@ -476,7 +515,7 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
476 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 515 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
477 | } | 516 | } |
478 | 517 | ||
479 | static inline unsigned int ata_dev_present(struct ata_device *dev) | 518 | static inline unsigned int ata_dev_present(const struct ata_device *dev) |
480 | { | 519 | { |
481 | return ((dev->class == ATA_DEV_ATA) || | 520 | return ((dev->class == ATA_DEV_ATA) || |
482 | (dev->class == ATA_DEV_ATAPI)); | 521 | (dev->class == ATA_DEV_ATAPI)); |
@@ -675,7 +714,7 @@ static inline unsigned int sata_dev_present(struct ata_port *ap) | |||
675 | return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; | 714 | return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; |
676 | } | 715 | } |
677 | 716 | ||
678 | static inline int ata_try_flush_cache(struct ata_device *dev) | 717 | static inline int ata_try_flush_cache(const struct ata_device *dev) |
679 | { | 718 | { |
680 | return ata_id_wcache_enabled(dev->id) || | 719 | return ata_id_wcache_enabled(dev->id) || |
681 | ata_id_has_flush(dev->id) || | 720 | ata_id_has_flush(dev->id) || |