aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 13:20:11 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 13:20:11 -0400
commit61998bcb4bf0efa0276e88c7853091e482a826f4 (patch)
treee01a1cbcc20ca013622fce45a1a056b89a11a40b
parentc36ad397a30fcf9369d82584324cc24189eb6b1c (diff)
parent0a139e79976b9eb60517edec63406236a789f812 (diff)
Merge head 'upstream-20050628-1' of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
-rw-r--r--Documentation/DocBook/libata.tmpl96
-rw-r--r--drivers/scsi/ahci.c22
-rw-r--r--drivers/scsi/libata-core.c6
3 files changed, 101 insertions, 23 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index 6df1dfd18b65..375ae760dc1e 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -84,6 +84,14 @@ void (*port_disable) (struct ata_port *);
84 Called from ata_bus_probe() and ata_bus_reset() error paths, 84 Called from ata_bus_probe() and ata_bus_reset() error paths,
85 as well as when unregistering from the SCSI module (rmmod, hot 85 as well as when unregistering from the SCSI module (rmmod, hot
86 unplug). 86 unplug).
87 This function should do whatever needs to be done to take the
88 port out of use. In most cases, ata_port_disable() can be used
89 as this hook.
90 </para>
91 <para>
92 Called from ata_bus_probe() on a failed probe.
93 Called from ata_bus_reset() on a failed bus reset.
94 Called from ata_scsi_release().
87 </para> 95 </para>
88 96
89 </sect2> 97 </sect2>
@@ -98,6 +106,13 @@ void (*dev_config) (struct ata_port *, struct ata_device *);
98 found. Typically used to apply device-specific fixups prior to 106 found. Typically used to apply device-specific fixups prior to
99 issue of SET FEATURES - XFER MODE, and prior to operation. 107 issue of SET FEATURES - XFER MODE, and prior to operation.
100 </para> 108 </para>
109 <para>
110 Called by ata_device_add() after ata_dev_identify() determines
111 a device is present.
112 </para>
113 <para>
114 This entry may be specified as NULL in ata_port_operations.
115 </para>
101 116
102 </sect2> 117 </sect2>
103 118
@@ -135,6 +150,8 @@ void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
135 registers / DMA buffers. ->tf_read() is called to read the 150 registers / DMA buffers. ->tf_read() is called to read the
136 hardware registers / DMA buffers, to obtain the current set of 151 hardware registers / DMA buffers, to obtain the current set of
137 taskfile register values. 152 taskfile register values.
153 Most drivers for taskfile-based hardware (PIO or MMIO) use
154 ata_tf_load() and ata_tf_read() for these hooks.
138 </para> 155 </para>
139 156
140 </sect2> 157 </sect2>
@@ -147,6 +164,8 @@ void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);
147 <para> 164 <para>
148 causes an ATA command, previously loaded with 165 causes an ATA command, previously loaded with
149 ->tf_load(), to be initiated in hardware. 166 ->tf_load(), to be initiated in hardware.
167 Most drivers for taskfile-based hardware use ata_exec_command()
168 for this hook.
150 </para> 169 </para>
151 170
152 </sect2> 171 </sect2>
@@ -161,6 +180,10 @@ Allow low-level driver to filter ATA PACKET commands, returning a status
161indicating whether or not it is OK to use DMA for the supplied PACKET 180indicating whether or not it is OK to use DMA for the supplied PACKET
162command. 181command.
163 </para> 182 </para>
183 <para>
184 This hook may be specified as NULL, in which case libata will
185 assume that atapi dma can be supported.
186 </para>
164 187
165 </sect2> 188 </sect2>
166 189
@@ -175,6 +198,14 @@ u8 (*check_err)(struct ata_port *ap);
175 Reads the Status/AltStatus/Error ATA shadow register from 198 Reads the Status/AltStatus/Error ATA shadow register from
176 hardware. On some hardware, reading the Status register has 199 hardware. On some hardware, reading the Status register has
177 the side effect of clearing the interrupt condition. 200 the side effect of clearing the interrupt condition.
201 Most drivers for taskfile-based hardware use
202 ata_check_status() for this hook.
203 </para>
204 <para>
205 Note that because this is called from ata_device_add(), at
206 least a dummy function that clears device interrupts must be
207 provided for all drivers, even if the controller doesn't
208 actually have a taskfile status register.
178 </para> 209 </para>
179 210
180 </sect2> 211 </sect2>
@@ -188,7 +219,13 @@ void (*dev_select)(struct ata_port *ap, unsigned int device);
188 Issues the low-level hardware command(s) that causes one of N 219 Issues the low-level hardware command(s) that causes one of N
189 hardware devices to be considered 'selected' (active and 220 hardware devices to be considered 'selected' (active and
190 available for use) on the ATA bus. This generally has no 221 available for use) on the ATA bus. This generally has no
191meaning on FIS-based devices. 222 meaning on FIS-based devices.
223 </para>
224 <para>
225 Most drivers for taskfile-based hardware use
226 ata_std_dev_select() for this hook. Controllers which do not
227 support second drives on a port (such as SATA contollers) will
228 use ata_noop_dev_select().
192 </para> 229 </para>
193 230
194 </sect2> 231 </sect2>
@@ -204,6 +241,8 @@ void (*phy_reset) (struct ata_port *ap);
204 for device presence (PATA and SATA), typically a soft reset 241 for device presence (PATA and SATA), typically a soft reset
205 (SRST) will be performed. Drivers typically use the helper 242 (SRST) will be performed. Drivers typically use the helper
206 functions ata_bus_reset() or sata_phy_reset() for this hook. 243 functions ata_bus_reset() or sata_phy_reset() for this hook.
244 Many SATA drivers use sata_phy_reset() or call it from within
245 their own phy_reset() functions.
207 </para> 246 </para>
208 247
209 </sect2> 248 </sect2>
@@ -227,6 +266,25 @@ PCI IDE DMA Status register.
227These hooks are typically either no-ops, or simply not implemented, in 266These hooks are typically either no-ops, or simply not implemented, in
228FIS-based drivers. 267FIS-based drivers.
229 </para> 268 </para>
269 <para>
270Most legacy IDE drivers use ata_bmdma_setup() for the bmdma_setup()
271hook. ata_bmdma_setup() will write the pointer to the PRD table to
272the IDE PRD Table Address register, enable DMA in the DMA Command
273register, and call exec_command() to begin the transfer.
274 </para>
275 <para>
276Most legacy IDE drivers use ata_bmdma_start() for the bmdma_start()
277hook. ata_bmdma_start() will write the ATA_DMA_START flag to the DMA
278Command register.
279 </para>
280 <para>
281Many legacy IDE drivers use ata_bmdma_stop() for the bmdma_stop()
282hook. ata_bmdma_stop() clears the ATA_DMA_START flag in the DMA
283command register.
284 </para>
285 <para>
286Many legacy IDE drivers use ata_bmdma_status() as the bmdma_status() hook.
287 </para>
230 288
231 </sect2> 289 </sect2>
232 290
@@ -250,6 +308,10 @@ int (*qc_issue) (struct ata_queued_cmd *qc);
250 helper function ata_qc_issue_prot() for taskfile protocol-based 308 helper function ata_qc_issue_prot() for taskfile protocol-based
251 dispatch. More advanced drivers implement their own ->qc_issue. 309 dispatch. More advanced drivers implement their own ->qc_issue.
252 </para> 310 </para>
311 <para>
312 ata_qc_issue_prot() calls ->tf_load(), ->bmdma_setup(), and
313 ->bmdma_start() as necessary to initiate a transfer.
314 </para>
253 315
254 </sect2> 316 </sect2>
255 317
@@ -279,6 +341,21 @@ void (*irq_clear) (struct ata_port *);
279 before the interrupt handler is registered, to be sure hardware 341 before the interrupt handler is registered, to be sure hardware
280 is quiet. 342 is quiet.
281 </para> 343 </para>
344 <para>
345 The second argument, dev_instance, should be cast to a pointer
346 to struct ata_host_set.
347 </para>
348 <para>
349 Most legacy IDE drivers use ata_interrupt() for the
350 irq_handler hook, which scans all ports in the host_set,
351 determines which queued command was active (if any), and calls
352 ata_host_intr(ap,qc).
353 </para>
354 <para>
355 Most legacy IDE drivers use ata_bmdma_irq_clear() for the
356 irq_clear() hook, which simply clears the interrupt and error
357 flags in the DMA status register.
358 </para>
282 359
283 </sect2> 360 </sect2>
284 361
@@ -292,6 +369,7 @@ void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
292 <para> 369 <para>
293 Read and write standard SATA phy registers. Currently only used 370 Read and write standard SATA phy registers. Currently only used
294 if ->phy_reset hook called the sata_phy_reset() helper function. 371 if ->phy_reset hook called the sata_phy_reset() helper function.
372 sc_reg is one of SCR_STATUS, SCR_CONTROL, SCR_ERROR, or SCR_ACTIVE.
295 </para> 373 </para>
296 374
297 </sect2> 375 </sect2>
@@ -307,17 +385,29 @@ void (*host_stop) (struct ata_host_set *host_set);
307 ->port_start() is called just after the data structures for each 385 ->port_start() is called just after the data structures for each
308 port are initialized. Typically this is used to alloc per-port 386 port are initialized. Typically this is used to alloc per-port
309 DMA buffers / tables / rings, enable DMA engines, and similar 387 DMA buffers / tables / rings, enable DMA engines, and similar
310 tasks. 388 tasks. Some drivers also use this entry point as a chance to
389 allocate driver-private memory for ap->private_data.
390 </para>
391 <para>
392 Many drivers use ata_port_start() as this hook or call
393 it from their own port_start() hooks. ata_port_start()
394 allocates space for a legacy IDE PRD table and returns.
311 </para> 395 </para>
312 <para> 396 <para>
313 ->port_stop() is called after ->host_stop(). It's sole function 397 ->port_stop() is called after ->host_stop(). It's sole function
314 is to release DMA/memory resources, now that they are no longer 398 is to release DMA/memory resources, now that they are no longer
315 actively being used. 399 actively being used. Many drivers also free driver-private
400 data from port at this time.
401 </para>
402 <para>
403 Many drivers use ata_port_stop() as this hook, which frees the
404 PRD table.
316 </para> 405 </para>
317 <para> 406 <para>
318 ->host_stop() is called after all ->port_stop() calls 407 ->host_stop() is called after all ->port_stop() calls
319have completed. The hook must finalize hardware shutdown, release DMA 408have completed. The hook must finalize hardware shutdown, release DMA
320and other resources, etc. 409and other resources, etc.
410 This hook may be specified as NULL, in which case it is not called.
321 </para> 411 </para>
322 412
323 </sect2> 413 </sect2>
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 9a547ca9c864..c5623694d10f 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -304,26 +304,19 @@ static int ahci_port_start(struct ata_port *ap)
304 struct device *dev = ap->host_set->dev; 304 struct device *dev = ap->host_set->dev;
305 struct ahci_host_priv *hpriv = ap->host_set->private_data; 305 struct ahci_host_priv *hpriv = ap->host_set->private_data;
306 struct ahci_port_priv *pp; 306 struct ahci_port_priv *pp;
307 int rc;
308 void *mem, *mmio = ap->host_set->mmio_base; 307 void *mem, *mmio = ap->host_set->mmio_base;
309 void *port_mmio = ahci_port_base(mmio, ap->port_no); 308 void *port_mmio = ahci_port_base(mmio, ap->port_no);
310 dma_addr_t mem_dma; 309 dma_addr_t mem_dma;
311 310
312 rc = ata_port_start(ap);
313 if (rc)
314 return rc;
315
316 pp = kmalloc(sizeof(*pp), GFP_KERNEL); 311 pp = kmalloc(sizeof(*pp), GFP_KERNEL);
317 if (!pp) { 312 if (!pp)
318 rc = -ENOMEM; 313 return -ENOMEM;
319 goto err_out;
320 }
321 memset(pp, 0, sizeof(*pp)); 314 memset(pp, 0, sizeof(*pp));
322 315
323 mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL); 316 mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
324 if (!mem) { 317 if (!mem) {
325 rc = -ENOMEM; 318 kfree(pp);
326 goto err_out_kfree; 319 return -ENOMEM;
327 } 320 }
328 memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ); 321 memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
329 322
@@ -373,12 +366,6 @@ static int ahci_port_start(struct ata_port *ap)
373 readl(port_mmio + PORT_CMD); /* flush */ 366 readl(port_mmio + PORT_CMD); /* flush */
374 367
375 return 0; 368 return 0;
376
377err_out_kfree:
378 kfree(pp);
379err_out:
380 ata_port_stop(ap);
381 return rc;
382} 369}
383 370
384 371
@@ -404,7 +391,6 @@ static void ahci_port_stop(struct ata_port *ap)
404 dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, 391 dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
405 pp->cmd_slot, pp->cmd_slot_dma); 392 pp->cmd_slot, pp->cmd_slot_dma);
406 kfree(pp); 393 kfree(pp);
407 ata_port_stop(ap);
408} 394}
409 395
410static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in) 396static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 36b401fee1f1..cb535fa185b9 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1408,7 +1408,9 @@ void __sata_phy_reset(struct ata_port *ap)
1408 if (ap->flags & ATA_FLAG_SATA_RESET) { 1408 if (ap->flags & ATA_FLAG_SATA_RESET) {
1409 /* issue phy wake/reset */ 1409 /* issue phy wake/reset */
1410 scr_write_flush(ap, SCR_CONTROL, 0x301); 1410 scr_write_flush(ap, SCR_CONTROL, 0x301);
1411 udelay(400); /* FIXME: a guess */ 1411 /* Couldn't find anything in SATA I/II specs, but
1412 * AHCI-1.1 10.4.2 says at least 1 ms. */
1413 mdelay(1);
1412 } 1414 }
1413 scr_write_flush(ap, SCR_CONTROL, 0x300); /* phy wake/clear reset */ 1415 scr_write_flush(ap, SCR_CONTROL, 0x300); /* phy wake/clear reset */
1414 1416
@@ -1920,6 +1922,7 @@ static const char * ata_dma_blacklist [] = {
1920 "HITACHI CDR-8335", 1922 "HITACHI CDR-8335",
1921 "HITACHI CDR-8435", 1923 "HITACHI CDR-8435",
1922 "Toshiba CD-ROM XM-6202B", 1924 "Toshiba CD-ROM XM-6202B",
1925 "TOSHIBA CD-ROM XM-1702BC",
1923 "CD-532E-A", 1926 "CD-532E-A",
1924 "E-IDE CD-ROM CR-840", 1927 "E-IDE CD-ROM CR-840",
1925 "CD-ROM Drive/F5A", 1928 "CD-ROM Drive/F5A",
@@ -1927,7 +1930,6 @@ static const char * ata_dma_blacklist [] = {
1927 "SAMSUNG CD-ROM SC-148C", 1930 "SAMSUNG CD-ROM SC-148C",
1928 "SAMSUNG CD-ROM SC", 1931 "SAMSUNG CD-ROM SC",
1929 "SanDisk SDP3B-64", 1932 "SanDisk SDP3B-64",
1930 "SAMSUNG CD-ROM SN-124",
1931 "ATAPI CD-ROM DRIVE 40X MAXIMUM", 1933 "ATAPI CD-ROM DRIVE 40X MAXIMUM",
1932 "_NEC DV5800A", 1934 "_NEC DV5800A",
1933}; 1935};