aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-28 12:29:23 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-28 12:29:23 -0400
commit7a9f8f93d2dad38f30fbc79d8a1e6517373aa4b6 (patch)
tree9116e5bde860d00685c5b6eee7be5ba9899aabb9 /include/linux/libata.h
parent972c26bdd6b58e7534473c4f7928584578cf43f4 (diff)
parent5fadd053d9bb4345ec6f405d24db4e7eb49cf81e (diff)
Merge branch 'master'
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h73
1 files changed, 56 insertions, 17 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index d3dfefefabec..5f17203520cb 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 */
@@ -206,7 +206,7 @@ struct ata_ioports {
206struct ata_probe_ent { 206struct ata_probe_ent {
207 struct list_head node; 207 struct list_head node;
208 struct device *dev; 208 struct device *dev;
209 struct ata_port_operations *port_ops; 209 const struct ata_port_operations *port_ops;
210 Scsi_Host_Template *sht; 210 Scsi_Host_Template *sht;
211 struct ata_ioports port[ATA_MAX_PORTS]; 211 struct ata_ioports port[ATA_MAX_PORTS];
212 unsigned int n_ports; 212 unsigned int n_ports;
@@ -229,7 +229,7 @@ struct ata_host_set {
229 void __iomem *mmio_base; 229 void __iomem *mmio_base;
230 unsigned int n_ports; 230 unsigned int n_ports;
231 void *private_data; 231 void *private_data;
232 struct ata_port_operations *ops; 232 const struct ata_port_operations *ops;
233 struct ata_port * ports[0]; 233 struct ata_port * ports[0];
234}; 234};
235 235
@@ -303,7 +303,7 @@ struct ata_device {
303 303
304struct ata_port { 304struct ata_port {
305 struct Scsi_Host *host; /* our co-allocated scsi host */ 305 struct Scsi_Host *host; /* our co-allocated scsi host */
306 struct ata_port_operations *ops; 306 const struct ata_port_operations *ops;
307 unsigned long flags; /* ATA_FLAG_xxx */ 307 unsigned long flags; /* ATA_FLAG_xxx */
308 unsigned int id; /* unique id req'd by scsi midlyr */ 308 unsigned int id; /* unique id req'd by scsi midlyr */
309 unsigned int port_no; /* unique port #; from zero */ 309 unsigned int port_no; /* unique port #; from zero */
@@ -353,10 +353,10 @@ struct ata_port_operations {
353 void (*set_piomode) (struct ata_port *, struct ata_device *); 353 void (*set_piomode) (struct ata_port *, struct ata_device *);
354 void (*set_dmamode) (struct ata_port *, struct ata_device *); 354 void (*set_dmamode) (struct ata_port *, struct ata_device *);
355 355
356 void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); 356 void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf);
357 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); 357 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
358 358
359 void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); 359 void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf);
360 u8 (*check_status)(struct ata_port *ap); 360 u8 (*check_status)(struct ata_port *ap);
361 u8 (*check_altstatus)(struct ata_port *ap); 361 u8 (*check_altstatus)(struct ata_port *ap);
362 u8 (*check_err)(struct ata_port *ap); 362 u8 (*check_err)(struct ata_port *ap);
@@ -397,9 +397,22 @@ struct ata_port_info {
397 unsigned long pio_mask; 397 unsigned long pio_mask;
398 unsigned long mwdma_mask; 398 unsigned long mwdma_mask;
399 unsigned long udma_mask; 399 unsigned long udma_mask;
400 struct ata_port_operations *port_ops; 400 const struct ata_port_operations *port_ops;
401}; 401};
402 402
403struct ata_timing {
404 unsigned short mode; /* ATA mode */
405 unsigned short setup; /* t1 */
406 unsigned short act8b; /* t2 for 8-bit I/O */
407 unsigned short rec8b; /* t2i for 8-bit I/O */
408 unsigned short cyc8b; /* t0 for 8-bit I/O */
409 unsigned short active; /* t2 or tD */
410 unsigned short recover; /* t2i or tK */
411 unsigned short cycle; /* t0 */
412 unsigned short udma; /* t2CYCTYP/2 */
413};
414
415#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin)
403 416
404extern void ata_port_probe(struct ata_port *); 417extern void ata_port_probe(struct ata_port *);
405extern void __sata_phy_reset(struct ata_port *ap); 418extern void __sata_phy_reset(struct ata_port *ap);
@@ -412,7 +425,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
412 unsigned int n_ports); 425 unsigned int n_ports);
413extern void ata_pci_remove_one (struct pci_dev *pdev); 426extern void ata_pci_remove_one (struct pci_dev *pdev);
414#endif /* CONFIG_PCI */ 427#endif /* CONFIG_PCI */
415extern int ata_device_add(struct ata_probe_ent *ent); 428extern int ata_device_add(const struct ata_probe_ent *ent);
416extern void ata_host_set_remove(struct ata_host_set *host_set); 429extern void ata_host_set_remove(struct ata_host_set *host_set);
417extern int ata_scsi_detect(Scsi_Host_Template *sht); 430extern int ata_scsi_detect(Scsi_Host_Template *sht);
418extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 431extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
@@ -425,16 +438,16 @@ extern int ata_ratelimit(void);
425/* 438/*
426 * Default driver ops implementations 439 * Default driver ops implementations
427 */ 440 */
428extern void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf); 441extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
429extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); 442extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
430extern void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp); 443extern void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp);
431extern void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf); 444extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
432extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device); 445extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device);
433extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); 446extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
434extern u8 ata_check_status(struct ata_port *ap); 447extern u8 ata_check_status(struct ata_port *ap);
435extern u8 ata_altstatus(struct ata_port *ap); 448extern u8 ata_altstatus(struct ata_port *ap);
436extern u8 ata_chk_err(struct ata_port *ap); 449extern u8 ata_chk_err(struct ata_port *ap);
437extern void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf); 450extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
438extern int ata_port_start (struct ata_port *ap); 451extern int ata_port_start (struct ata_port *ap);
439extern void ata_port_stop (struct ata_port *ap); 452extern void ata_port_stop (struct ata_port *ap);
440extern void ata_host_stop (struct ata_host_set *host_set); 453extern void ata_host_stop (struct ata_host_set *host_set);
@@ -445,8 +458,8 @@ extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
445 unsigned int buflen); 458 unsigned int buflen);
446extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 459extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
447 unsigned int n_elem); 460 unsigned int n_elem);
448extern unsigned int ata_dev_classify(struct ata_taskfile *tf); 461extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
449extern void ata_dev_id_string(u16 *id, unsigned char *s, 462extern void ata_dev_id_string(const u16 *id, unsigned char *s,
450 unsigned int ofs, unsigned int len); 463 unsigned int ofs, unsigned int len);
451extern void ata_dev_config(struct ata_port *ap, unsigned int i); 464extern void ata_dev_config(struct ata_port *ap, unsigned int i);
452extern void ata_bmdma_setup (struct ata_queued_cmd *qc); 465extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
@@ -463,6 +476,32 @@ extern int ata_std_bios_param(struct scsi_device *sdev,
463 sector_t capacity, int geom[]); 476 sector_t capacity, int geom[]);
464extern int ata_scsi_slave_config(struct scsi_device *sdev); 477extern int ata_scsi_slave_config(struct scsi_device *sdev);
465 478
479/*
480 * Timing helpers
481 */
482extern int ata_timing_compute(struct ata_device *, unsigned short,
483 struct ata_timing *, int, int);
484extern void ata_timing_merge(const struct ata_timing *,
485 const struct ata_timing *, struct ata_timing *,
486 unsigned int);
487
488enum {
489 ATA_TIMING_SETUP = (1 << 0),
490 ATA_TIMING_ACT8B = (1 << 1),
491 ATA_TIMING_REC8B = (1 << 2),
492 ATA_TIMING_CYC8B = (1 << 3),
493 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B |
494 ATA_TIMING_CYC8B,
495 ATA_TIMING_ACTIVE = (1 << 4),
496 ATA_TIMING_RECOVER = (1 << 5),
497 ATA_TIMING_CYCLE = (1 << 6),
498 ATA_TIMING_UDMA = (1 << 7),
499 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
500 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
501 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
502 ATA_TIMING_CYCLE | ATA_TIMING_UDMA,
503};
504
466 505
467#ifdef CONFIG_PCI 506#ifdef CONFIG_PCI
468struct pci_bits { 507struct pci_bits {
@@ -475,7 +514,7 @@ struct pci_bits {
475extern void ata_pci_host_stop (struct ata_host_set *host_set); 514extern void ata_pci_host_stop (struct ata_host_set *host_set);
476extern struct ata_probe_ent * 515extern struct ata_probe_ent *
477ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); 516ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
478extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits); 517extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
479 518
480#endif /* CONFIG_PCI */ 519#endif /* CONFIG_PCI */
481 520
@@ -510,7 +549,7 @@ static inline unsigned int ata_tag_valid(unsigned int tag)
510 return (tag < ATA_MAX_QUEUE) ? 1 : 0; 549 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
511} 550}
512 551
513static inline unsigned int ata_dev_present(struct ata_device *dev) 552static inline unsigned int ata_dev_present(const struct ata_device *dev)
514{ 553{
515 return ((dev->class == ATA_DEV_ATA) || 554 return ((dev->class == ATA_DEV_ATA) ||
516 (dev->class == ATA_DEV_ATAPI)); 555 (dev->class == ATA_DEV_ATAPI));
@@ -709,7 +748,7 @@ static inline unsigned int sata_dev_present(struct ata_port *ap)
709 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; 748 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0;
710} 749}
711 750
712static inline int ata_try_flush_cache(struct ata_device *dev) 751static inline int ata_try_flush_cache(const struct ata_device *dev)
713{ 752{
714 return ata_id_wcache_enabled(dev->id) || 753 return ata_id_wcache_enabled(dev->id) ||
715 ata_id_has_flush(dev->id) || 754 ata_id_has_flush(dev->id) ||