diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-06-06 03:21:03 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-06-06 03:21:03 -0400 |
commit | 3c241f8337542655ee013a661b7f1770f561d3ef (patch) | |
tree | 79dd9a5dd12d305e1be7b926d414855377d2e192 /Documentation | |
parent | dbf4ccd6043e58ed32fbf253fb3f0a9991e4c13a (diff) | |
parent | eae936e21bd726f9d9555f2262d439fbcd61dccf (diff) |
Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/DocBook/libata.tmpl | 156 |
1 files changed, 124 insertions, 32 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl index cf2fce7707da..6df1dfd18b65 100644 --- a/Documentation/DocBook/libata.tmpl +++ b/Documentation/DocBook/libata.tmpl | |||
@@ -14,7 +14,7 @@ | |||
14 | </authorgroup> | 14 | </authorgroup> |
15 | 15 | ||
16 | <copyright> | 16 | <copyright> |
17 | <year>2003</year> | 17 | <year>2003-2005</year> |
18 | <holder>Jeff Garzik</holder> | 18 | <holder>Jeff Garzik</holder> |
19 | </copyright> | 19 | </copyright> |
20 | 20 | ||
@@ -44,30 +44,38 @@ | |||
44 | 44 | ||
45 | <toc></toc> | 45 | <toc></toc> |
46 | 46 | ||
47 | <chapter id="libataThanks"> | 47 | <chapter id="libataIntroduction"> |
48 | <title>Thanks</title> | 48 | <title>Introduction</title> |
49 | <para> | 49 | <para> |
50 | The bulk of the ATA knowledge comes thanks to long conversations with | 50 | libATA is a library used inside the Linux kernel to support ATA host |
51 | Andre Hedrick (www.linux-ide.org). | 51 | controllers and devices. libATA provides an ATA driver API, class |
52 | transports for ATA and ATAPI devices, and SCSI<->ATA translation | ||
53 | for ATA devices according to the T10 SAT specification. | ||
52 | </para> | 54 | </para> |
53 | <para> | 55 | <para> |
54 | Thanks to Alan Cox for pointing out similarities | 56 | This Guide documents the libATA driver API, library functions, library |
55 | between SATA and SCSI, and in general for motivation to hack on | 57 | internals, and a couple sample ATA low-level drivers. |
56 | libata. | ||
57 | </para> | ||
58 | <para> | ||
59 | libata's device detection | ||
60 | method, ata_pio_devchk, and in general all the early probing was | ||
61 | based on extensive study of Hale Landis's probe/reset code in his | ||
62 | ATADRVR driver (www.ata-atapi.com). | ||
63 | </para> | 58 | </para> |
64 | </chapter> | 59 | </chapter> |
65 | 60 | ||
66 | <chapter id="libataDriverApi"> | 61 | <chapter id="libataDriverApi"> |
67 | <title>libata Driver API</title> | 62 | <title>libata Driver API</title> |
63 | <para> | ||
64 | struct ata_port_operations is defined for every low-level libata | ||
65 | hardware driver, and it controls how the low-level driver | ||
66 | interfaces with the ATA and SCSI layers. | ||
67 | </para> | ||
68 | <para> | ||
69 | FIS-based drivers will hook into the system with ->qc_prep() and | ||
70 | ->qc_issue() high-level hooks. Hardware which behaves in a manner | ||
71 | similar to PCI IDE hardware may utilize several generic helpers, | ||
72 | defining at a bare minimum the bus I/O addresses of the ATA shadow | ||
73 | register blocks. | ||
74 | </para> | ||
68 | <sect1> | 75 | <sect1> |
69 | <title>struct ata_port_operations</title> | 76 | <title>struct ata_port_operations</title> |
70 | 77 | ||
78 | <sect2><title>Disable ATA port</title> | ||
71 | <programlisting> | 79 | <programlisting> |
72 | void (*port_disable) (struct ata_port *); | 80 | void (*port_disable) (struct ata_port *); |
73 | </programlisting> | 81 | </programlisting> |
@@ -78,6 +86,9 @@ void (*port_disable) (struct ata_port *); | |||
78 | unplug). | 86 | unplug). |
79 | </para> | 87 | </para> |
80 | 88 | ||
89 | </sect2> | ||
90 | |||
91 | <sect2><title>Post-IDENTIFY device configuration</title> | ||
81 | <programlisting> | 92 | <programlisting> |
82 | void (*dev_config) (struct ata_port *, struct ata_device *); | 93 | void (*dev_config) (struct ata_port *, struct ata_device *); |
83 | </programlisting> | 94 | </programlisting> |
@@ -88,6 +99,9 @@ void (*dev_config) (struct ata_port *, struct ata_device *); | |||
88 | issue of SET FEATURES - XFER MODE, and prior to operation. | 99 | issue of SET FEATURES - XFER MODE, and prior to operation. |
89 | </para> | 100 | </para> |
90 | 101 | ||
102 | </sect2> | ||
103 | |||
104 | <sect2><title>Set PIO/DMA mode</title> | ||
91 | <programlisting> | 105 | <programlisting> |
92 | void (*set_piomode) (struct ata_port *, struct ata_device *); | 106 | void (*set_piomode) (struct ata_port *, struct ata_device *); |
93 | void (*set_dmamode) (struct ata_port *, struct ata_device *); | 107 | void (*set_dmamode) (struct ata_port *, struct ata_device *); |
@@ -108,6 +122,9 @@ void (*post_set_mode) (struct ata_port *ap); | |||
108 | ->set_dma_mode() is only called if DMA is possible. | 122 | ->set_dma_mode() is only called if DMA is possible. |
109 | </para> | 123 | </para> |
110 | 124 | ||
125 | </sect2> | ||
126 | |||
127 | <sect2><title>Taskfile read/write</title> | ||
111 | <programlisting> | 128 | <programlisting> |
112 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); | 129 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); |
113 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | 130 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); |
@@ -120,6 +137,9 @@ void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | |||
120 | taskfile register values. | 137 | taskfile register values. |
121 | </para> | 138 | </para> |
122 | 139 | ||
140 | </sect2> | ||
141 | |||
142 | <sect2><title>ATA command execute</title> | ||
123 | <programlisting> | 143 | <programlisting> |
124 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | 144 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); |
125 | </programlisting> | 145 | </programlisting> |
@@ -129,17 +149,37 @@ void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | |||
129 | ->tf_load(), to be initiated in hardware. | 149 | ->tf_load(), to be initiated in hardware. |
130 | </para> | 150 | </para> |
131 | 151 | ||
152 | </sect2> | ||
153 | |||
154 | <sect2><title>Per-cmd ATAPI DMA capabilities filter</title> | ||
155 | <programlisting> | ||
156 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | ||
157 | </programlisting> | ||
158 | |||
159 | <para> | ||
160 | Allow low-level driver to filter ATA PACKET commands, returning a status | ||
161 | indicating whether or not it is OK to use DMA for the supplied PACKET | ||
162 | command. | ||
163 | </para> | ||
164 | |||
165 | </sect2> | ||
166 | |||
167 | <sect2><title>Read specific ATA shadow registers</title> | ||
132 | <programlisting> | 168 | <programlisting> |
133 | u8 (*check_status)(struct ata_port *ap); | 169 | u8 (*check_status)(struct ata_port *ap); |
134 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 170 | u8 (*check_altstatus)(struct ata_port *ap); |
171 | u8 (*check_err)(struct ata_port *ap); | ||
135 | </programlisting> | 172 | </programlisting> |
136 | 173 | ||
137 | <para> | 174 | <para> |
138 | Reads the Status ATA shadow register from hardware. On some | 175 | Reads the Status/AltStatus/Error ATA shadow register from |
139 | hardware, this has the side effect of clearing the interrupt | 176 | hardware. On some hardware, reading the Status register has |
140 | condition. | 177 | the side effect of clearing the interrupt condition. |
141 | </para> | 178 | </para> |
142 | 179 | ||
180 | </sect2> | ||
181 | |||
182 | <sect2><title>Select ATA device on bus</title> | ||
143 | <programlisting> | 183 | <programlisting> |
144 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 184 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
145 | </programlisting> | 185 | </programlisting> |
@@ -147,9 +187,13 @@ void (*dev_select)(struct ata_port *ap, unsigned int device); | |||
147 | <para> | 187 | <para> |
148 | Issues the low-level hardware command(s) that causes one of N | 188 | Issues the low-level hardware command(s) that causes one of N |
149 | hardware devices to be considered 'selected' (active and | 189 | hardware devices to be considered 'selected' (active and |
150 | available for use) on the ATA bus. | 190 | available for use) on the ATA bus. This generally has no |
191 | meaning on FIS-based devices. | ||
151 | </para> | 192 | </para> |
152 | 193 | ||
194 | </sect2> | ||
195 | |||
196 | <sect2><title>Reset ATA bus</title> | ||
153 | <programlisting> | 197 | <programlisting> |
154 | void (*phy_reset) (struct ata_port *ap); | 198 | void (*phy_reset) (struct ata_port *ap); |
155 | </programlisting> | 199 | </programlisting> |
@@ -162,17 +206,31 @@ void (*phy_reset) (struct ata_port *ap); | |||
162 | functions ata_bus_reset() or sata_phy_reset() for this hook. | 206 | functions ata_bus_reset() or sata_phy_reset() for this hook. |
163 | </para> | 207 | </para> |
164 | 208 | ||
209 | </sect2> | ||
210 | |||
211 | <sect2><title>Control PCI IDE BMDMA engine</title> | ||
165 | <programlisting> | 212 | <programlisting> |
166 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | 213 | void (*bmdma_setup) (struct ata_queued_cmd *qc); |
167 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 214 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
215 | void (*bmdma_stop) (struct ata_port *ap); | ||
216 | u8 (*bmdma_status) (struct ata_port *ap); | ||
168 | </programlisting> | 217 | </programlisting> |
169 | 218 | ||
170 | <para> | 219 | <para> |
171 | When setting up an IDE BMDMA transaction, these hooks arm | 220 | When setting up an IDE BMDMA transaction, these hooks arm |
172 | (->bmdma_setup) and fire (->bmdma_start) the hardware's DMA | 221 | (->bmdma_setup), fire (->bmdma_start), and halt (->bmdma_stop) |
173 | engine. | 222 | the hardware's DMA engine. ->bmdma_status is used to read the standard |
223 | PCI IDE DMA Status register. | ||
174 | </para> | 224 | </para> |
175 | 225 | ||
226 | <para> | ||
227 | These hooks are typically either no-ops, or simply not implemented, in | ||
228 | FIS-based drivers. | ||
229 | </para> | ||
230 | |||
231 | </sect2> | ||
232 | |||
233 | <sect2><title>High-level taskfile hooks</title> | ||
176 | <programlisting> | 234 | <programlisting> |
177 | void (*qc_prep) (struct ata_queued_cmd *qc); | 235 | void (*qc_prep) (struct ata_queued_cmd *qc); |
178 | int (*qc_issue) (struct ata_queued_cmd *qc); | 236 | int (*qc_issue) (struct ata_queued_cmd *qc); |
@@ -190,20 +248,26 @@ int (*qc_issue) (struct ata_queued_cmd *qc); | |||
190 | ->qc_issue is used to make a command active, once the hardware | 248 | ->qc_issue is used to make a command active, once the hardware |
191 | and S/G tables have been prepared. IDE BMDMA drivers use the | 249 | and S/G tables have been prepared. IDE BMDMA drivers use the |
192 | helper function ata_qc_issue_prot() for taskfile protocol-based | 250 | helper function ata_qc_issue_prot() for taskfile protocol-based |
193 | dispatch. More advanced drivers roll their own ->qc_issue | 251 | dispatch. More advanced drivers implement their own ->qc_issue. |
194 | implementation, using this as the "issue new ATA command to | ||
195 | hardware" hook. | ||
196 | </para> | 252 | </para> |
197 | 253 | ||
254 | </sect2> | ||
255 | |||
256 | <sect2><title>Timeout (error) handling</title> | ||
198 | <programlisting> | 257 | <programlisting> |
199 | void (*eng_timeout) (struct ata_port *ap); | 258 | void (*eng_timeout) (struct ata_port *ap); |
200 | </programlisting> | 259 | </programlisting> |
201 | 260 | ||
202 | <para> | 261 | <para> |
203 | This is a high level error handling function, called from the | 262 | This is a high level error handling function, called from the |
204 | error handling thread, when a command times out. | 263 | error handling thread, when a command times out. Most newer |
264 | hardware will implement its own error handling code here. IDE BMDMA | ||
265 | drivers may use the helper function ata_eng_timeout(). | ||
205 | </para> | 266 | </para> |
206 | 267 | ||
268 | </sect2> | ||
269 | |||
270 | <sect2><title>Hardware interrupt handling</title> | ||
207 | <programlisting> | 271 | <programlisting> |
208 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 272 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
209 | void (*irq_clear) (struct ata_port *); | 273 | void (*irq_clear) (struct ata_port *); |
@@ -216,6 +280,9 @@ void (*irq_clear) (struct ata_port *); | |||
216 | is quiet. | 280 | is quiet. |
217 | </para> | 281 | </para> |
218 | 282 | ||
283 | </sect2> | ||
284 | |||
285 | <sect2><title>SATA phy read/write</title> | ||
219 | <programlisting> | 286 | <programlisting> |
220 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); | 287 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); |
221 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | 288 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, |
@@ -227,6 +294,9 @@ void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | |||
227 | if ->phy_reset hook called the sata_phy_reset() helper function. | 294 | if ->phy_reset hook called the sata_phy_reset() helper function. |
228 | </para> | 295 | </para> |
229 | 296 | ||
297 | </sect2> | ||
298 | |||
299 | <sect2><title>Init and shutdown</title> | ||
230 | <programlisting> | 300 | <programlisting> |
231 | int (*port_start) (struct ata_port *ap); | 301 | int (*port_start) (struct ata_port *ap); |
232 | void (*port_stop) (struct ata_port *ap); | 302 | void (*port_stop) (struct ata_port *ap); |
@@ -240,15 +310,17 @@ void (*host_stop) (struct ata_host_set *host_set); | |||
240 | tasks. | 310 | tasks. |
241 | </para> | 311 | </para> |
242 | <para> | 312 | <para> |
243 | ->host_stop() is called when the rmmod or hot unplug process | ||
244 | begins. The hook must stop all hardware interrupts, DMA | ||
245 | engines, etc. | ||
246 | </para> | ||
247 | <para> | ||
248 | ->port_stop() is called after ->host_stop(). It's sole function | 313 | ->port_stop() is called after ->host_stop(). It's sole function |
249 | is to release DMA/memory resources, now that they are no longer | 314 | is to release DMA/memory resources, now that they are no longer |
250 | actively being used. | 315 | actively being used. |
251 | </para> | 316 | </para> |
317 | <para> | ||
318 | ->host_stop() is called after all ->port_stop() calls | ||
319 | have completed. The hook must finalize hardware shutdown, release DMA | ||
320 | and other resources, etc. | ||
321 | </para> | ||
322 | |||
323 | </sect2> | ||
252 | 324 | ||
253 | </sect1> | 325 | </sect1> |
254 | </chapter> | 326 | </chapter> |
@@ -279,4 +351,24 @@ void (*host_stop) (struct ata_host_set *host_set); | |||
279 | !Idrivers/scsi/sata_sil.c | 351 | !Idrivers/scsi/sata_sil.c |
280 | </chapter> | 352 | </chapter> |
281 | 353 | ||
354 | <chapter id="libataThanks"> | ||
355 | <title>Thanks</title> | ||
356 | <para> | ||
357 | The bulk of the ATA knowledge comes thanks to long conversations with | ||
358 | Andre Hedrick (www.linux-ide.org), and long hours pondering the ATA | ||
359 | and SCSI specifications. | ||
360 | </para> | ||
361 | <para> | ||
362 | Thanks to Alan Cox for pointing out similarities | ||
363 | between SATA and SCSI, and in general for motivation to hack on | ||
364 | libata. | ||
365 | </para> | ||
366 | <para> | ||
367 | libata's device detection | ||
368 | method, ata_pio_devchk, and in general all the early probing was | ||
369 | based on extensive study of Hale Landis's probe/reset code in his | ||
370 | ATADRVR driver (www.ata-atapi.com). | ||
371 | </para> | ||
372 | </chapter> | ||
373 | |||
282 | </book> | 374 | </book> |