Blame view

drivers/ata/libata.h 10.6 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
af36d7f0d   Jeff Garzik   [libata] license ...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
   *  libata.h - helper library for ATA
   *
   *  Copyright 2003-2004 Red Hat, Inc.  All rights reserved.
   *  Copyright 2003-2004 Jeff Garzik
   *
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2, or (at your option)
   *  any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *
   *  You should have received a copy of the GNU General Public License
   *  along with this program; see the file COPYING.  If not, write to
   *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
   *
   *
   *  libata documentation is available via 'make {ps|pdf}docs',
9bb9a39ce   Mauro Carvalho Chehab   ata: update refer...
24
   *  as Documentation/driver-api/libata.rst
af36d7f0d   Jeff Garzik   [libata] license ...
25
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
30
31
   */
  
  #ifndef __LIBATA_H__
  #define __LIBATA_H__
  
  #define DRV_NAME	"libata"
633273a3e   Tejun Heo   libata-pmp: hook ...
32
  #define DRV_VERSION	"3.00"	/* must be exactly four chars */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
  /* libata-core.c */
bff046476   Tejun Heo   [PATCH] libata: c...
35
36
37
  enum {
  	/* flags for ata_dev_read_id() */
  	ATA_READID_POSTRESET	= (1 << 0), /* reading ID after reset */
458337dbb   Tejun Heo   libata: improve a...
38
39
40
41
42
43
44
  
  	/* 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...
45
46
  
  	ATA_DNXFER_QUIET	= (1 << 31),
bff046476   Tejun Heo   [PATCH] libata: c...
47
  };
85d6725b7   Dan Williams   libata: make ata_...
48
  extern atomic_t ata_print_id;
baf4fdfaa   Mark Lord   libata: add suppo...
49
  extern int atapi_passthru16;
c3c013a2c   Jeff Garzik   [libata] Disable FUA
50
  extern int libata_fua;
d7d0dad62   Jeff Garzik   [libata] Disable ...
51
  extern int libata_noacpi;
ae8d4ee7f   Alan Cox   libata: Disable A...
52
  extern int libata_allow_tpm;
5ef410829   Lin Ming   ata: add ata port...
53
  extern struct device_type ata_port_type;
b1c72916a   Tejun Heo   libata: implement...
54
  extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
332673257   Tejun Heo   libata: implement...
55
  extern void ata_force_cbl(struct ata_port *ap);
a5987e0a1   Tejun Heo   libata: make ata_...
56
57
  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...
58
  extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
bd056d7ee   Tejun Heo   [PATCH] libata: s...
59
60
  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...
61
  			   unsigned int tag, int class);
cffd1ee99   Hannes Reinecke   libata: sanitize ...
62
63
  extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
  			     struct ata_device *dev);
3373efd89   Tejun Heo   [PATCH] libata: u...
64
  extern unsigned ata_exec_internal(struct ata_device *dev,
1ad8e7f9e   Tejun Heo   [PATCH] libata: m...
65
  				  struct ata_taskfile *tf, const u8 *cdb,
2b789108f   Tejun Heo   libata: add @time...
66
67
  				  int dma_dir, void *buf, unsigned int buflen,
  				  unsigned long timeout);
2432697ba   Tejun Heo   [PATCH] libata: i...
68
69
70
  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...
71
  				     unsigned int n_elem, unsigned long timeout);
aa2731ad9   Tejun Heo   libata: separate ...
72
73
  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...
74
  extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
bff046476   Tejun Heo   [PATCH] libata: c...
75
  			   unsigned int flags, u16 *id);
fe30911b3   Tejun Heo   libata: separate ...
76
  extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
422c9daa8   Tejun Heo   libata-pmp-prep: ...
77
78
  extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
  			      unsigned int readid_flags);
efdaedc44   Tejun Heo   [PATCH] libata: i...
79
  extern int ata_dev_configure(struct ata_device *dev);
a07d499b4   Tejun Heo   libata: add @spd_...
80
  extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
458337dbb   Tejun Heo   libata: improve a...
81
  extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
1152b2617   Tejun Heo   libata: implement...
82
83
  extern unsigned int ata_dev_set_feature(struct ata_device *dev,
  					u8 enable, u8 feature);
8a8bc2233   Tejun Heo   libata: revert co...
84
  extern void ata_qc_free(struct ata_queued_cmd *qc);
8e0e694a3   Tejun Heo   [PATCH] libata: m...
85
  extern void ata_qc_issue(struct ata_queued_cmd *qc);
f686bcb80   Tejun Heo   [PATCH] libata-eh...
86
  extern void __ata_qc_complete(struct ata_queued_cmd *qc);
5895ef9a5   Tejun Heo   libata: don't che...
87
  extern int atapi_check_dma(struct ata_queued_cmd *qc);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
  extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
b1c72916a   Tejun Heo   libata: implement...
89
90
  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...
91
  extern void ata_dev_init(struct ata_device *dev);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
92
93
  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...
94
95
  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 ...
96
  extern struct ata_port *ata_port_alloc(struct ata_host *host);
d9027470b   Gwendal Grignou   [libata] Add ATA ...
97
  extern const char *sata_spd_string(unsigned int spd);
238c9cf9e   James Bottomley   libata: plumb sas...
98
  extern int ata_port_probe(struct ata_port *ap);
9508a66f8   Dan Williams   [SCSI] libsas: as...
99
  extern void __ata_port_probe(struct ata_port *ap);
f01f62c25   Christoph Hellwig   libata: move ata_...
100
101
  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
102

6b66d9589   Matthew Garrett   libata: bind the ...
103
  #define to_ata_port(d) container_of(d, struct ata_port, tdev)
11ef697b3   Kristen Carlson Accardi   [PATCH] libata: A...
104
  /* libata-acpi.c */
e92351bb5   Tejun Heo   libata-acpi: s/CO...
105
  #ifdef CONFIG_ATA_ACPI
110f66d25   Tejun Heo   libata: make gtf_...
106
  extern unsigned int ata_acpi_gtf_filter;
562f0c2d7   Tejun Heo   libata-acpi: add ...
107
  extern void ata_acpi_dissociate(struct ata_host *host);
64578a3de   Tejun Heo   libata-acpi: impl...
108
  extern int ata_acpi_on_suspend(struct ata_port *ap);
6746544c3   Tejun Heo   libata: reimpleme...
109
  extern void ata_acpi_on_resume(struct ata_port *ap);
562f0c2d7   Tejun Heo   libata-acpi: add ...
110
111
  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 ...
112
  extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state);
f1bc1e4c4   Aaron Lu   ata: acpi: rework...
113
114
115
  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...
116
  #else
562f0c2d7   Tejun Heo   libata-acpi: add ...
117
  static inline void ata_acpi_dissociate(struct ata_host *host) { }
64578a3de   Tejun Heo   libata-acpi: impl...
118
  static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; }
6746544c3   Tejun Heo   libata: reimpleme...
119
  static inline void ata_acpi_on_resume(struct ata_port *ap) { }
562f0c2d7   Tejun Heo   libata-acpi: add ...
120
121
  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 ...
122
123
  static inline void ata_acpi_set_state(struct ata_port *ap,
  				      pm_message_t state) { }
f1bc1e4c4   Aaron Lu   ata: acpi: rework...
124
125
  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...
126
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
128
  
  /* libata-scsi.c */
f31871951   Tejun Heo   libata: separate ...
129
130
  extern int ata_scsi_add_hosts(struct ata_host *host,
  			      struct scsi_host_template *sht);
1ae463171   Tejun Heo   libata: improve S...
131
  extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
0ea035a3d   Tejun Heo   [PATCH] libata-hp...
132
  extern int ata_scsi_offline_dev(struct ata_device *dev);
06dbde5f3   Hannes Reinecke   libata: Implement...
133
134
  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...
135
136
137
  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: ...
138
  extern void ata_scsi_media_change_notify(struct ata_device *dev);
65f27f384   David Howells   WorkStruct: Pass ...
139
  extern void ata_scsi_hotplug(struct work_struct *work);
7b70fc039   Tejun Heo   [PATCH] libata-eh...
140
  extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
65f27f384   David Howells   WorkStruct: Pass ...
141
  extern void ata_scsi_dev_rescan(struct work_struct *work);
80289167f   Brian King   [PATCH] libata: A...
142
  extern int ata_bus_probe(struct ata_port *ap);
d9027470b   Gwendal Grignou   [libata] Add ATA ...
143
  extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
9cb78c16f   Hannes Reinecke   scsi: use 64-bit ...
144
  			      unsigned int id, u64 lun);
98bd4be1b   Shaohua Li   libata: move sas ...
145
146
  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 ...
147

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148

ece1d6361   Tejun Heo   [PATCH] libata: s...
149
  /* libata-eh.c */
87fbc5a06   Tejun Heo   libata: improve E...
150
151
  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...
152
153
  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...
154
  extern void ata_scsi_error(struct Scsi_Host *host);
5ddf24c5e   Tejun Heo   libata: implement...
155
  extern void ata_eh_fastdrain_timerfn(unsigned long arg);
f686bcb80   Tejun Heo   [PATCH] libata-eh...
156
  extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
678afac67   Tejun Heo   libata: move ata_...
157
  extern void ata_dev_disable(struct ata_device *dev);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
158
159
160
161
162
163
  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...
164
  const char *ata_get_cmd_descript(u8 command);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
165
166
167
168
  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_...
169
  extern int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
fb7fd6145   Tejun Heo   libata-pmp-prep: ...
170
171
172
173
174
  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 ...
175
176
177
  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...
178
179
180
  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...
181

48515f6c0   Tejun Heo   libata: separate ...
182
  /* libata-pmp.c */
88fcd5627   Tejun Heo   libata: make PMP ...
183
  #ifdef CONFIG_SATA_PMP
48515f6c0   Tejun Heo   libata: separate ...
184
185
  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...
186
187
  extern int sata_pmp_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
  			    unsigned hints);
48515f6c0   Tejun Heo   libata: separate ...
188
  extern int sata_pmp_attach(struct ata_device *dev);
88fcd5627   Tejun Heo   libata: make PMP ...
189
190
191
192
193
194
195
196
197
198
  #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...
199
200
201
202
203
  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 ...
204
205
206
207
208
  static inline int sata_pmp_attach(struct ata_device *dev)
  {
  	return -EINVAL;
  }
  #endif /* CONFIG_SATA_PMP */
48515f6c0   Tejun Heo   libata: separate ...
209

90088bb41   Tejun Heo   [PATCH] libata: m...
210
  /* libata-sff.c */
127102aea   Tejun Heo   libata: make SFF ...
211
  #ifdef CONFIG_ATA_SFF
c429137a6   Tejun Heo   libata-sff: port_...
212
  extern void ata_sff_flush_pio_task(struct ata_port *ap);
270390e1a   Tejun Heo   libata-sff: intro...
213
214
215
216
  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_...
217
218
  static inline void ata_sff_flush_pio_task(struct ata_port *ap)
  { }
270390e1a   Tejun Heo   libata-sff: intro...
219
220
221
222
223
224
  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 ...
225
  #endif /* CONFIG_ATA_SFF */
77a527ead   Adrian Bunk   fix CONFIG_SATA_S...
226

afe759511   Aaron Lu   libata: identify ...
227
228
229
230
231
232
233
234
  /* 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...
235
  void zpodd_on_suspend(struct ata_device *dev);
213342053   Aaron Lu   libata: handle po...
236
237
238
239
  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 ...
240
241
242
243
  #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...
244
  static inline void zpodd_on_suspend(struct ata_device *dev) {}
213342053   Aaron Lu   libata: handle po...
245
246
247
248
  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 ...
249
  #endif /* CONFIG_SATA_ZPODD */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
250
  #endif /* __LIBATA_H__ */