···60606161 <chapter id="libataDriverApi">6262 <title>libata Driver API</title>6363+ <para>6464+ struct ata_port_operations is defined for every low-level libata6565+ hardware driver, and it controls how the low-level driver6666+ interfaces with the ATA and SCSI layers.6767+ </para>6868+ <para>6969+ FIS-based drivers will hook into the system with ->qc_prep() and7070+ ->qc_issue() high-level hooks. Hardware which behaves in a manner7171+ similar to PCI IDE hardware may utilize several generic helpers,7272+ defining at a bare minimum the bus I/O addresses of the ATA shadow7373+ register blocks.7474+ </para>6375 <sect1>6476 <title>struct ata_port_operations</title>65777878+ <sect2><title>Disable ATA port</title>6679 <programlisting>6780void (*port_disable) (struct ata_port *);6881 </programlisting>···8673 unplug).8774 </para>88757676+ </sect2>7777+7878+ <sect2><title>Post-IDENTIFY device configuration</title>8979 <programlisting>9080void (*dev_config) (struct ata_port *, struct ata_device *);9181 </programlisting>···9983 issue of SET FEATURES - XFER MODE, and prior to operation.10084 </para>101858686+ </sect2>8787+8888+ <sect2><title>Set PIO/DMA mode</title>10289 <programlisting>10390void (*set_piomode) (struct ata_port *, struct ata_device *);10491void (*set_dmamode) (struct ata_port *, struct ata_device *);···122103 ->set_dma_mode() is only called if DMA is possible.123104 </para>124105106106+ </sect2>107107+108108+ <sect2><title>Taskfile read/write</title>125109 <programlisting>126110void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);127111void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);···137115 taskfile register values.138116 </para>139117118118+ </sect2>119119+120120+ <sect2><title>ATA command execute</title>140121 <programlisting>141122void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);142123 </programlisting>···149124 ->tf_load(), to be initiated in hardware.150125 </para>151126127127+ </sect2>128128+129129+ <sect2><title>Per-cmd ATAPI DMA capabilities filter</title>152130 <programlisting>153131int (*check_atapi_dma) (struct ata_queued_cmd *qc);154132 </programlisting>···162134command.163135 </para>164136137137+ </sect2>138138+139139+ <sect2><title>Read specific ATA shadow registers</title>165140 <programlisting>166141u8 (*check_status)(struct ata_port *ap);167142u8 (*check_altstatus)(struct ata_port *ap);···177146 the side effect of clearing the interrupt condition.178147 </para>179148149149+ </sect2>150150+151151+ <sect2><title>Select ATA device on bus</title>180152 <programlisting>181153void (*dev_select)(struct ata_port *ap, unsigned int device);182154 </programlisting>···191157meaning on FIS-based devices.192158 </para>193159160160+ </sect2>161161+162162+ <sect2><title>Reset ATA bus</title>194163 <programlisting>195164void (*phy_reset) (struct ata_port *ap);196165 </programlisting>···206169 functions ata_bus_reset() or sata_phy_reset() for this hook.207170 </para>208171172172+ </sect2>173173+174174+ <sect2><title>Control PCI IDE BMDMA engine</title>209175 <programlisting>210176void (*bmdma_setup) (struct ata_queued_cmd *qc);211177void (*bmdma_start) (struct ata_queued_cmd *qc);···228188FIS-based drivers.229189 </para>230190191191+ </sect2>192192+193193+ <sect2><title>High-level taskfile hooks</title>231194 <programlisting>232195void (*qc_prep) (struct ata_queued_cmd *qc);233196int (*qc_issue) (struct ata_queued_cmd *qc);···251208 dispatch. More advanced drivers implement their own ->qc_issue.252209 </para>253210211211+ </sect2>212212+213213+ <sect2><title>Timeout (error) handling</title>254214 <programlisting>255215void (*eng_timeout) (struct ata_port *ap);256216 </programlisting>···265219drivers may use the helper function ata_eng_timeout().266220 </para>267221222222+ </sect2>223223+224224+ <sect2><title>Hardware interrupt handling</title>268225 <programlisting>269226irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);270227void (*irq_clear) (struct ata_port *);···280231 is quiet.281232 </para>282233234234+ </sect2>235235+236236+ <sect2><title>SATA phy read/write</title>283237 <programlisting>284238u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);285239void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,···294242 if ->phy_reset hook called the sata_phy_reset() helper function.295243 </para>296244245245+ </sect2>246246+247247+ <sect2><title>Init and shutdown</title>297248 <programlisting>298249int (*port_start) (struct ata_port *ap);299250void (*port_stop) (struct ata_port *ap);···319264have completed. The hook must finalize hardware shutdown, release DMA320265and other resources, etc.321266 </para>267267+268268+ </sect2>322269323270 </sect1>324271 </chapter>