Blame view

drivers/ata/libata.h 9.9 KB
c82ee6d3b   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
af36d7f0d   Jeff Garzik   [libata] license ...
3
4
5
6
7
   *  libata.h - helper library for ATA
   *
   *  Copyright 2003-2004 Red Hat, Inc.  All rights reserved.
   *  Copyright 2003-2004 Jeff Garzik
   *
af36d7f0d   Jeff Garzik   [libata] license ...
8
   *  libata documentation is available via 'make {ps|pdf}docs',
9bb9a39ce   Mauro Carvalho Chehab   ata: update refer...
9
   *  as Documentation/driver-api/libata.rst
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
13
14
15
   */
  
  #ifndef __LIBATA_H__
  #define __LIBATA_H__
  
  #define DRV_NAME	"libata"
633273a3e   Tejun Heo   libata-pmp: hook ...
16
  #define DRV_VERSION	"3.00"	/* must be exactly four chars */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
  /* libata-core.c */
bff046476   Tejun Heo   [PATCH] libata: c...
19
20
21
  enum {
  	/* flags for ata_dev_read_id() */
  	ATA_READID_POSTRESET	= (1 << 0), /* reading ID after reset */
458337dbb   Tejun Heo   libata: improve a...
22
23
24
25
26
27
28
  
  	/* selector for ata_down_xfermask_limit() */
  	ATA_DNXFER_PIO		= 0,	/* speed down PIO */
  	ATA_DNXFER_DMA		= 1,	/* speed down DMA */
  	ATA_DNXFER_40C		= 2,	/* apply 40c cable limit */
  	ATA_DNXFER_FORCE_PIO	= 3,	/* force PIO */
  	ATA_DNXFER_FORCE_PIO0	= 4,	/* force PIO0 */
458337dbb   Tejun Heo   libata: improve a...
29
30
  
  	ATA_DNXFER_QUIET	= (1 << 31),
bff046476   Tejun Heo   [PATCH] libata: c...
31
  };
85d6725b7   Dan Williams   libata: make ata_...
32
  extern atomic_t ata_print_id;
baf4fdfaa   Mark Lord   libata: add suppo...
33
  extern int atapi_passthru16;
c3c013a2c   Jeff Garzik   [libata] Disable FUA
34
  extern int libata_fua;
d7d0dad62   Jeff Garzik   [libata] Disable ...
35
  extern int libata_noacpi;
ae8d4ee7f   Alan Cox   libata: Disable A...
36
  extern int libata_allow_tpm;
8df82c13a   Bhumika Goyal   libata: make ata_...
37
  extern const struct device_type ata_port_type;
b1c72916a   Tejun Heo   libata: implement...
38
  extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
332673257   Tejun Heo   libata: implement...
39
  extern void ata_force_cbl(struct ata_port *ap);
a5987e0a1   Tejun Heo   libata: make ata_...
40
41
  extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
  extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
12cb5ce10   Shaohua Li   libata: use blk t...
42
  extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
bd056d7ee   Tejun Heo   [PATCH] libata: s...
43
44
  extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
  			   u64 block, u32 n_block, unsigned int tf_flags,
8e061784b   Adam Manzanares   ata: Enabling ATA...
45
  			   unsigned int tag, int class);
cffd1ee99   Hannes Reinecke   libata: sanitize ...
46
47
  extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
  			     struct ata_device *dev);
3373efd89   Tejun Heo   [PATCH] libata: u...
48
  extern unsigned ata_exec_internal(struct ata_device *dev,
1ad8e7f9e   Tejun Heo   [PATCH] libata: m...
49
  				  struct ata_taskfile *tf, const u8 *cdb,
2b789108f   Tejun Heo   libata: add @time...
50
51
  				  int dma_dir, void *buf, unsigned int buflen,
  				  unsigned long timeout);
2432697ba   Tejun Heo   [PATCH] libata: i...
52
53
54
  extern unsigned ata_exec_internal_sg(struct ata_device *dev,
  				     struct ata_taskfile *tf, const u8 *cdb,
  				     int dma_dir, struct scatterlist *sg,
2b789108f   Tejun Heo   libata: add @time...
55
  				     unsigned int n_elem, unsigned long timeout);
aa2731ad9   Tejun Heo   libata: separate ...
56
57
  extern int ata_wait_ready(struct ata_link *link, unsigned long deadline,
  			  int (*check_ready)(struct ata_link *link));
a9beec953   Tejun Heo   [PATCH] libata-hp...
58
  extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
bff046476   Tejun Heo   [PATCH] libata: c...
59
  			   unsigned int flags, u16 *id);
fe30911b3   Tejun Heo   libata: separate ...
60
  extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
422c9daa8   Tejun Heo   libata-pmp-prep: ...
61
62
  extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
  			      unsigned int readid_flags);
efdaedc44   Tejun Heo   [PATCH] libata: i...
63
  extern int ata_dev_configure(struct ata_device *dev);
a07d499b4   Tejun Heo   libata: add @spd_...
64
  extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
458337dbb   Tejun Heo   libata: improve a...
65
  extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
1152b2617   Tejun Heo   libata: implement...
66
67
  extern unsigned int ata_dev_set_feature(struct ata_device *dev,
  					u8 enable, u8 feature);
8a8bc2233   Tejun Heo   libata: revert co...
68
  extern void ata_qc_free(struct ata_queued_cmd *qc);
8e0e694a3   Tejun Heo   [PATCH] libata: m...
69
  extern void ata_qc_issue(struct ata_queued_cmd *qc);
f686bcb80   Tejun Heo   [PATCH] libata-eh...
70
  extern void __ata_qc_complete(struct ata_queued_cmd *qc);
5895ef9a5   Tejun Heo   libata: don't che...
71
  extern int atapi_check_dma(struct ata_queued_cmd *qc);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
  extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
b1c72916a   Tejun Heo   libata: implement...
73
74
  extern bool ata_phys_link_online(struct ata_link *link);
  extern bool ata_phys_link_offline(struct ata_link *link);
3ef3b43d5   Tejun Heo   [PATCH] libata-hp...
75
  extern void ata_dev_init(struct ata_device *dev);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
76
77
  extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp);
  extern int sata_link_init_spd(struct ata_link *link);
b095518ef   Jeff Garzik   [libata] ATA pass...
78
79
  extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
  extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
f31871951   Tejun Heo   libata: separate ...
80
  extern struct ata_port *ata_port_alloc(struct ata_host *host);
d9027470b   Gwendal Grignou   [libata] Add ATA ...
81
  extern const char *sata_spd_string(unsigned int spd);
238c9cf9e   James Bottomley   libata: plumb sas...
82
  extern int ata_port_probe(struct ata_port *ap);
9508a66f8   Dan Williams   [SCSI] libsas: as...
83
  extern void __ata_port_probe(struct ata_port *ap);
f01f62c25   Christoph Hellwig   libata: move ata_...
84
85
  extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
  				      u8 page, void *buf, unsigned int sectors);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86

6b66d9589   Matthew Garrett   libata: bind the ...
87
  #define to_ata_port(d) container_of(d, struct ata_port, tdev)
11ef697b3   Kristen Carlson Accardi   [PATCH] libata: A...
88
  /* libata-acpi.c */
e92351bb5   Tejun Heo   libata-acpi: s/CO...
89
  #ifdef CONFIG_ATA_ACPI
110f66d25   Tejun Heo   libata: make gtf_...
90
  extern unsigned int ata_acpi_gtf_filter;
562f0c2d7   Tejun Heo   libata-acpi: add ...
91
  extern void ata_acpi_dissociate(struct ata_host *host);
64578a3de   Tejun Heo   libata-acpi: impl...
92
  extern int ata_acpi_on_suspend(struct ata_port *ap);
6746544c3   Tejun Heo   libata: reimpleme...
93
  extern void ata_acpi_on_resume(struct ata_port *ap);
562f0c2d7   Tejun Heo   libata-acpi: add ...
94
95
  extern int ata_acpi_on_devcfg(struct ata_device *dev);
  extern void ata_acpi_on_disable(struct ata_device *dev);
bd3adca52   Shaohua Li   libata-acpi: add ...
96
  extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state);
f1bc1e4c4   Aaron Lu   ata: acpi: rework...
97
98
99
  extern void ata_acpi_bind_port(struct ata_port *ap);
  extern void ata_acpi_bind_dev(struct ata_device *dev);
  extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev);
11ef697b3   Kristen Carlson Accardi   [PATCH] libata: A...
100
  #else
562f0c2d7   Tejun Heo   libata-acpi: add ...
101
  static inline void ata_acpi_dissociate(struct ata_host *host) { }
64578a3de   Tejun Heo   libata-acpi: impl...
102
  static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; }
6746544c3   Tejun Heo   libata: reimpleme...
103
  static inline void ata_acpi_on_resume(struct ata_port *ap) { }
562f0c2d7   Tejun Heo   libata-acpi: add ...
104
105
  static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; }
  static inline void ata_acpi_on_disable(struct ata_device *dev) { }
bd3adca52   Shaohua Li   libata-acpi: add ...
106
107
  static inline void ata_acpi_set_state(struct ata_port *ap,
  				      pm_message_t state) { }
f1bc1e4c4   Aaron Lu   ata: acpi: rework...
108
109
  static inline void ata_acpi_bind_port(struct ata_port *ap) {}
  static inline void ata_acpi_bind_dev(struct ata_device *dev) {}
11ef697b3   Kristen Carlson Accardi   [PATCH] libata: A...
110
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111
112
  
  /* libata-scsi.c */
f31871951   Tejun Heo   libata: separate ...
113
114
  extern int ata_scsi_add_hosts(struct ata_host *host,
  			      struct scsi_host_template *sht);
1ae463171   Tejun Heo   libata: improve S...
115
  extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
0ea035a3d   Tejun Heo   [PATCH] libata-hp...
116
  extern int ata_scsi_offline_dev(struct ata_device *dev);
06dbde5f3   Hannes Reinecke   libata: Implement...
117
118
  extern void ata_scsi_set_sense(struct ata_device *dev,
  			       struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq);
492bf6210   Hannes Reinecke   libata-eh: Set 'i...
119
120
121
  extern void ata_scsi_set_sense_information(struct ata_device *dev,
  					   struct scsi_cmnd *cmd,
  					   const struct ata_taskfile *tf);
7d77b2470   Tejun Heo   libata-pmp-prep: ...
122
  extern void ata_scsi_media_change_notify(struct ata_device *dev);
65f27f384   David Howells   WorkStruct: Pass ...
123
  extern void ata_scsi_hotplug(struct work_struct *work);
7b70fc039   Tejun Heo   [PATCH] libata-eh...
124
  extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
65f27f384   David Howells   WorkStruct: Pass ...
125
  extern void ata_scsi_dev_rescan(struct work_struct *work);
80289167f   Brian King   [PATCH] libata: A...
126
  extern int ata_bus_probe(struct ata_port *ap);
d9027470b   Gwendal Grignou   [libata] Add ATA ...
127
  extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
9cb78c16f   Hannes Reinecke   scsi: use 64-bit ...
128
  			      unsigned int id, u64 lun);
98bd4be1b   Shaohua Li   libata: move sas ...
129
130
  int ata_sas_allocate_tag(struct ata_port *ap);
  void ata_sas_free_tag(unsigned int tag, struct ata_port *ap);
d9027470b   Gwendal Grignou   [libata] Add ATA ...
131

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132

ece1d6361   Tejun Heo   [PATCH] libata: s...
133
  /* libata-eh.c */
87fbc5a06   Tejun Heo   libata: improve E...
134
135
  extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd);
  extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd);
c0c362b60   Tejun Heo   libata: implement...
136
137
  extern void ata_eh_acquire(struct ata_port *ap);
  extern void ata_eh_release(struct ata_port *ap);
381544bba   Jeff Garzik   libata: Fix EH me...
138
  extern void ata_scsi_error(struct Scsi_Host *host);
b93ab338f   Kees Cook   libata: Convert t...
139
  extern void ata_eh_fastdrain_timerfn(struct timer_list *t);
f686bcb80   Tejun Heo   [PATCH] libata-eh...
140
  extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
678afac67   Tejun Heo   libata: move ata_...
141
  extern void ata_dev_disable(struct ata_device *dev);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
142
143
144
145
146
147
  extern void ata_eh_detach_dev(struct ata_device *dev);
  extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
  			       unsigned int action);
  extern void ata_eh_done(struct ata_link *link, struct ata_device *dev,
  			unsigned int action);
  extern void ata_eh_autopsy(struct ata_port *ap);
6521148c6   Robert Hancock   libata: add comma...
148
  const char *ata_get_cmd_descript(u8 command);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
149
150
151
152
  extern void ata_eh_report(struct ata_port *ap);
  extern int ata_eh_reset(struct ata_link *link, int classify,
  			ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
  			ata_reset_fn_t hardreset, ata_postreset_fn_t postreset);
6f1d1e3a0   Tejun Heo   libata: move ata_...
153
  extern int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
154
155
156
157
158
  extern int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
  			  ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
  			  ata_postreset_fn_t postreset,
  			  struct ata_link **r_failed_disk);
  extern void ata_eh_finish(struct ata_port *ap);
d9027470b   Gwendal Grignou   [libata] Add ATA ...
159
160
161
  extern int ata_ering_map(struct ata_ering *ering,
  			 int (*map_fn)(struct ata_ering_entry *, void *),
  		  	 void *arg);
3dc67440d   Aaron Lu   libata: check zer...
162
163
164
  extern unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key);
  extern unsigned int atapi_eh_request_sense(struct ata_device *dev,
  					   u8 *sense_buf, u8 dfl_sense_key);
ece1d6361   Tejun Heo   [PATCH] libata: s...
165

48515f6c0   Tejun Heo   libata: separate ...
166
  /* libata-pmp.c */
88fcd5627   Tejun Heo   libata: make PMP ...
167
  #ifdef CONFIG_SATA_PMP
48515f6c0   Tejun Heo   libata: separate ...
168
169
  extern int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val);
  extern int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val);
6c8ea89ce   Tejun Heo   libata: implement...
170
171
  extern int sata_pmp_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
  			    unsigned hints);
48515f6c0   Tejun Heo   libata: separate ...
172
  extern int sata_pmp_attach(struct ata_device *dev);
88fcd5627   Tejun Heo   libata: make PMP ...
173
174
175
176
177
178
179
180
181
182
  #else /* CONFIG_SATA_PMP */
  static inline int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val)
  {
  	return -EINVAL;
  }
  
  static inline int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val)
  {
  	return -EINVAL;
  }
6c8ea89ce   Tejun Heo   libata: implement...
183
184
185
186
187
  static inline int sata_pmp_set_lpm(struct ata_link *link,
  				   enum ata_lpm_policy policy, unsigned hints)
  {
  	return -EINVAL;
  }
88fcd5627   Tejun Heo   libata: make PMP ...
188
189
190
191
192
  static inline int sata_pmp_attach(struct ata_device *dev)
  {
  	return -EINVAL;
  }
  #endif /* CONFIG_SATA_PMP */
48515f6c0   Tejun Heo   libata: separate ...
193

90088bb41   Tejun Heo   [PATCH] libata: m...
194
  /* libata-sff.c */
127102aea   Tejun Heo   libata: make SFF ...
195
  #ifdef CONFIG_ATA_SFF
c429137a6   Tejun Heo   libata-sff: port_...
196
  extern void ata_sff_flush_pio_task(struct ata_port *ap);
270390e1a   Tejun Heo   libata-sff: intro...
197
198
199
200
  extern void ata_sff_port_init(struct ata_port *ap);
  extern int ata_sff_init(void);
  extern void ata_sff_exit(void);
  #else /* CONFIG_ATA_SFF */
c429137a6   Tejun Heo   libata-sff: port_...
201
202
  static inline void ata_sff_flush_pio_task(struct ata_port *ap)
  { }
270390e1a   Tejun Heo   libata-sff: intro...
203
204
205
206
207
208
  static inline void ata_sff_port_init(struct ata_port *ap)
  { }
  static inline int ata_sff_init(void)
  { return 0; }
  static inline void ata_sff_exit(void)
  { }
127102aea   Tejun Heo   libata: make SFF ...
209
  #endif /* CONFIG_ATA_SFF */
77a527ead   Adrian Bunk   fix CONFIG_SATA_S...
210

afe759511   Aaron Lu   libata: identify ...
211
212
213
214
215
216
217
218
  /* libata-zpodd.c */
  #ifdef CONFIG_SATA_ZPODD
  void zpodd_init(struct ata_device *dev);
  void zpodd_exit(struct ata_device *dev);
  static inline bool zpodd_dev_enabled(struct ata_device *dev)
  {
  	return dev->zpodd != NULL;
  }
3dc67440d   Aaron Lu   libata: check zer...
219
  void zpodd_on_suspend(struct ata_device *dev);
213342053   Aaron Lu   libata: handle po...
220
221
222
223
  bool zpodd_zpready(struct ata_device *dev);
  void zpodd_enable_run_wake(struct ata_device *dev);
  void zpodd_disable_run_wake(struct ata_device *dev);
  void zpodd_post_poweron(struct ata_device *dev);
afe759511   Aaron Lu   libata: identify ...
224
225
226
227
  #else /* CONFIG_SATA_ZPODD */
  static inline void zpodd_init(struct ata_device *dev) {}
  static inline void zpodd_exit(struct ata_device *dev) {}
  static inline bool zpodd_dev_enabled(struct ata_device *dev) { return false; }
3dc67440d   Aaron Lu   libata: check zer...
228
  static inline void zpodd_on_suspend(struct ata_device *dev) {}
213342053   Aaron Lu   libata: handle po...
229
230
231
232
  static inline bool zpodd_zpready(struct ata_device *dev) { return false; }
  static inline void zpodd_enable_run_wake(struct ata_device *dev) {}
  static inline void zpodd_disable_run_wake(struct ata_device *dev) {}
  static inline void zpodd_post_poweron(struct ata_device *dev) {}
afe759511   Aaron Lu   libata: identify ...
233
  #endif /* CONFIG_SATA_ZPODD */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
234
  #endif /* __LIBATA_H__ */