^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * libata.h - helper library for ATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2003-2004 Jeff Garzik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * libata documentation is available via 'make {ps|pdf}docs',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * as Documentation/driver-api/libata.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef __LIBATA_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define __LIBATA_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define DRV_NAME "libata"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define DRV_VERSION "3.00" /* must be exactly four chars */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* libata-core.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* flags for ata_dev_read_id() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) ATA_READID_POSTRESET = (1 << 0), /* reading ID after reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* selector for ata_down_xfermask_limit() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ATA_DNXFER_PIO = 0, /* speed down PIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ATA_DNXFER_DMA = 1, /* speed down DMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) ATA_DNXFER_40C = 2, /* apply 40c cable limit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ATA_DNXFER_FORCE_PIO = 3, /* force PIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ATA_DNXFER_FORCE_PIO0 = 4, /* force PIO0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ATA_DNXFER_QUIET = (1 << 31),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern atomic_t ata_print_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) extern int atapi_passthru16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern int libata_fua;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) extern int libata_noacpi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) extern int libata_allow_tpm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) extern const struct device_type ata_port_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #ifdef CONFIG_ATA_FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) extern void ata_force_cbl(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static inline void ata_force_cbl(struct ata_port *ap) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) u64 block, u32 n_block, unsigned int tf_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned int tag, int class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) extern unsigned ata_exec_internal(struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct ata_taskfile *tf, const u8 *cdb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int dma_dir, void *buf, unsigned int buflen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned long timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) extern unsigned ata_exec_internal_sg(struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct ata_taskfile *tf, const u8 *cdb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int dma_dir, struct scatterlist *sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned int n_elem, unsigned long timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) extern int ata_wait_ready(struct ata_link *link, unsigned long deadline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int (*check_ready)(struct ata_link *link));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned int flags, u16 *id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned int readid_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) extern int ata_dev_configure(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) extern unsigned int ata_dev_set_feature(struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u8 enable, u8 feature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) extern void ata_qc_free(struct ata_queued_cmd *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern void ata_qc_issue(struct ata_queued_cmd *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern void __ata_qc_complete(struct ata_queued_cmd *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) extern int atapi_check_dma(struct ata_queued_cmd *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) extern bool ata_phys_link_online(struct ata_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) extern bool ata_phys_link_offline(struct ata_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) extern void ata_dev_init(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) extern int sata_link_init_spd(struct ata_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) extern struct ata_port *ata_port_alloc(struct ata_host *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) extern const char *sata_spd_string(unsigned int spd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) extern int ata_port_probe(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) extern void __ata_port_probe(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) u8 page, void *buf, unsigned int sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define to_ata_port(d) container_of(d, struct ata_port, tdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /* libata-sata.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #ifdef CONFIG_SATA_HOST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int ata_sas_allocate_tag(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) void ata_sas_free_tag(unsigned int tag, struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static inline int ata_sas_allocate_tag(struct ata_port *ap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static inline void ata_sas_free_tag(unsigned int tag, struct ata_port *ap) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* libata-acpi.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #ifdef CONFIG_ATA_ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) extern unsigned int ata_acpi_gtf_filter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) extern void ata_acpi_dissociate(struct ata_host *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) extern int ata_acpi_on_suspend(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) extern void ata_acpi_on_resume(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) extern int ata_acpi_on_devcfg(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) extern void ata_acpi_on_disable(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) extern void ata_acpi_bind_port(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) extern void ata_acpi_bind_dev(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static inline void ata_acpi_dissociate(struct ata_host *host) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static inline void ata_acpi_on_resume(struct ata_port *ap) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline void ata_acpi_on_disable(struct ata_device *dev) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static inline void ata_acpi_set_state(struct ata_port *ap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) pm_message_t state) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline void ata_acpi_bind_port(struct ata_port *ap) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static inline void ata_acpi_bind_dev(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* libata-scsi.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) extern struct ata_device *ata_scsi_find_dev(struct ata_port *ap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) const struct scsi_device *scsidev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) extern int ata_scsi_add_hosts(struct ata_host *host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct scsi_host_template *sht);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) extern int ata_scsi_offline_dev(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) extern void ata_scsi_set_sense(struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) extern void ata_scsi_set_sense_information(struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct scsi_cmnd *cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) const struct ata_taskfile *tf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) extern void ata_scsi_media_change_notify(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) extern void ata_scsi_hotplug(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) extern void ata_scsi_dev_rescan(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) extern int ata_bus_probe(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) unsigned int id, u64 lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) void ata_scsi_sdev_config(struct scsi_device *sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void ata_scsi_dump_cdb(struct ata_port *ap, struct scsi_cmnd *cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /* libata-eh.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) extern void ata_eh_acquire(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) extern void ata_eh_release(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) extern void ata_scsi_error(struct Scsi_Host *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) extern void ata_eh_fastdrain_timerfn(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) extern void ata_dev_disable(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) extern void ata_eh_detach_dev(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) unsigned int action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) extern void ata_eh_done(struct ata_link *link, struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) unsigned int action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) extern void ata_eh_autopsy(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) const char *ata_get_cmd_descript(u8 command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) extern void ata_eh_report(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) extern int ata_eh_reset(struct ata_link *link, int classify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ata_reset_fn_t hardreset, ata_postreset_fn_t postreset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) extern int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) extern int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ata_postreset_fn_t postreset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct ata_link **r_failed_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) extern void ata_eh_finish(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) extern int ata_ering_map(struct ata_ering *ering,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int (*map_fn)(struct ata_ering_entry *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) void *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) extern unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) extern unsigned int atapi_eh_request_sense(struct ata_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u8 *sense_buf, u8 dfl_sense_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* libata-pmp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #ifdef CONFIG_SATA_PMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) extern int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) extern int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) extern int sata_pmp_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) unsigned hints);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) extern int sata_pmp_attach(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #else /* CONFIG_SATA_PMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static inline int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static inline int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline int sata_pmp_set_lpm(struct ata_link *link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) enum ata_lpm_policy policy, unsigned hints)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static inline int sata_pmp_attach(struct ata_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #endif /* CONFIG_SATA_PMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* libata-sff.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #ifdef CONFIG_ATA_SFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) extern void ata_sff_flush_pio_task(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) extern void ata_sff_port_init(struct ata_port *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) extern int ata_sff_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) extern void ata_sff_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #else /* CONFIG_ATA_SFF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static inline void ata_sff_flush_pio_task(struct ata_port *ap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static inline void ata_sff_port_init(struct ata_port *ap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static inline int ata_sff_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static inline void ata_sff_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #endif /* CONFIG_ATA_SFF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /* libata-zpodd.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) #ifdef CONFIG_SATA_ZPODD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) void zpodd_init(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) void zpodd_exit(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static inline bool zpodd_dev_enabled(struct ata_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return dev->zpodd != NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) void zpodd_on_suspend(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) bool zpodd_zpready(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void zpodd_enable_run_wake(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) void zpodd_disable_run_wake(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) void zpodd_post_poweron(struct ata_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #else /* CONFIG_SATA_ZPODD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static inline void zpodd_init(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static inline void zpodd_exit(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static inline bool zpodd_dev_enabled(struct ata_device *dev) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static inline void zpodd_on_suspend(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static inline bool zpodd_zpready(struct ata_device *dev) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static inline void zpodd_enable_run_wake(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static inline void zpodd_disable_run_wake(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static inline void zpodd_post_poweron(struct ata_device *dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #endif /* CONFIG_SATA_ZPODD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #endif /* __LIBATA_H__ */