···6061 <chapter id="libataDriverApi">62 <title>libata Driver API</title>00000000000063 <sect1>64 <title>struct ata_port_operations</title>65066 <programlisting>67void (*port_disable) (struct ata_port *);68 </programlisting>···86 unplug).87 </para>8800089 <programlisting>90void (*dev_config) (struct ata_port *, struct ata_device *);91 </programlisting>···99 issue of SET FEATURES - XFER MODE, and prior to operation.100 </para>101000102 <programlisting>103void (*set_piomode) (struct ata_port *, struct ata_device *);104void (*set_dmamode) (struct ata_port *, struct ata_device *);···122 ->set_dma_mode() is only called if DMA is possible.123 </para>124000125 <programlisting>126void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);127void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);···137 taskfile register values.138 </para>139000140 <programlisting>141void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);142 </programlisting>···149 ->tf_load(), to be initiated in hardware.150 </para>151000152 <programlisting>153int (*check_atapi_dma) (struct ata_queued_cmd *qc);154 </programlisting>···162command.163 </para>164000165 <programlisting>166u8 (*check_status)(struct ata_port *ap);167u8 (*check_altstatus)(struct ata_port *ap);···177 the side effect of clearing the interrupt condition.178 </para>179000180 <programlisting>181void (*dev_select)(struct ata_port *ap, unsigned int device);182 </programlisting>···191meaning on FIS-based devices.192 </para>193000194 <programlisting>195void (*phy_reset) (struct ata_port *ap);196 </programlisting>···206 functions ata_bus_reset() or sata_phy_reset() for this hook.207 </para>208000209 <programlisting>210void (*bmdma_setup) (struct ata_queued_cmd *qc);211void (*bmdma_start) (struct ata_queued_cmd *qc);···228FIS-based drivers.229 </para>230000231 <programlisting>232void (*qc_prep) (struct ata_queued_cmd *qc);233int (*qc_issue) (struct ata_queued_cmd *qc);···251 dispatch. More advanced drivers implement their own ->qc_issue.252 </para>253000254 <programlisting>255void (*eng_timeout) (struct ata_port *ap);256 </programlisting>···265drivers may use the helper function ata_eng_timeout().266 </para>267000268 <programlisting>269irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);270void (*irq_clear) (struct ata_port *);···280 is quiet.281 </para>282000283 <programlisting>284u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);285void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,···294 if ->phy_reset hook called the sata_phy_reset() helper function.295 </para>296000297 <programlisting>298int (*port_start) (struct ata_port *ap);299void (*port_stop) (struct ata_port *ap);···319have completed. The hook must finalize hardware shutdown, release DMA320and other resources, etc.321 </para>00322323 </sect1>324 </chapter>
···6061 <chapter id="libataDriverApi">62 <title>libata Driver API</title>63+ <para>64+ struct ata_port_operations is defined for every low-level libata65+ hardware driver, and it controls how the low-level driver66+ interfaces with the ATA and SCSI layers.67+ </para>68+ <para>69+ FIS-based drivers will hook into the system with ->qc_prep() and70+ ->qc_issue() high-level hooks. Hardware which behaves in a manner71+ similar to PCI IDE hardware may utilize several generic helpers,72+ defining at a bare minimum the bus I/O addresses of the ATA shadow73+ register blocks.74+ </para>75 <sect1>76 <title>struct ata_port_operations</title>7778+ <sect2><title>Disable ATA port</title>79 <programlisting>80void (*port_disable) (struct ata_port *);81 </programlisting>···73 unplug).74 </para>7576+ </sect2>77+78+ <sect2><title>Post-IDENTIFY device configuration</title>79 <programlisting>80void (*dev_config) (struct ata_port *, struct ata_device *);81 </programlisting>···83 issue of SET FEATURES - XFER MODE, and prior to operation.84 </para>8586+ </sect2>87+88+ <sect2><title>Set PIO/DMA mode</title>89 <programlisting>90void (*set_piomode) (struct ata_port *, struct ata_device *);91void (*set_dmamode) (struct ata_port *, struct ata_device *);···103 ->set_dma_mode() is only called if DMA is possible.104 </para>105106+ </sect2>107+108+ <sect2><title>Taskfile read/write</title>109 <programlisting>110void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);111void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);···115 taskfile register values.116 </para>117118+ </sect2>119+120+ <sect2><title>ATA command execute</title>121 <programlisting>122void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);123 </programlisting>···124 ->tf_load(), to be initiated in hardware.125 </para>126127+ </sect2>128+129+ <sect2><title>Per-cmd ATAPI DMA capabilities filter</title>130 <programlisting>131int (*check_atapi_dma) (struct ata_queued_cmd *qc);132 </programlisting>···134command.135 </para>136137+ </sect2>138+139+ <sect2><title>Read specific ATA shadow registers</title>140 <programlisting>141u8 (*check_status)(struct ata_port *ap);142u8 (*check_altstatus)(struct ata_port *ap);···146 the side effect of clearing the interrupt condition.147 </para>148149+ </sect2>150+151+ <sect2><title>Select ATA device on bus</title>152 <programlisting>153void (*dev_select)(struct ata_port *ap, unsigned int device);154 </programlisting>···157meaning on FIS-based devices.158 </para>159160+ </sect2>161+162+ <sect2><title>Reset ATA bus</title>163 <programlisting>164void (*phy_reset) (struct ata_port *ap);165 </programlisting>···169 functions ata_bus_reset() or sata_phy_reset() for this hook.170 </para>171172+ </sect2>173+174+ <sect2><title>Control PCI IDE BMDMA engine</title>175 <programlisting>176void (*bmdma_setup) (struct ata_queued_cmd *qc);177void (*bmdma_start) (struct ata_queued_cmd *qc);···188FIS-based drivers.189 </para>190191+ </sect2>192+193+ <sect2><title>High-level taskfile hooks</title>194 <programlisting>195void (*qc_prep) (struct ata_queued_cmd *qc);196int (*qc_issue) (struct ata_queued_cmd *qc);···208 dispatch. More advanced drivers implement their own ->qc_issue.209 </para>210211+ </sect2>212+213+ <sect2><title>Timeout (error) handling</title>214 <programlisting>215void (*eng_timeout) (struct ata_port *ap);216 </programlisting>···219drivers may use the helper function ata_eng_timeout().220 </para>221222+ </sect2>223+224+ <sect2><title>Hardware interrupt handling</title>225 <programlisting>226irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);227void (*irq_clear) (struct ata_port *);···231 is quiet.232 </para>233234+ </sect2>235+236+ <sect2><title>SATA phy read/write</title>237 <programlisting>238u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);239void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,···242 if ->phy_reset hook called the sata_phy_reset() helper function.243 </para>244245+ </sect2>246+247+ <sect2><title>Init and shutdown</title>248 <programlisting>249int (*port_start) (struct ata_port *ap);250void (*port_stop) (struct ata_port *ap);···264have completed. The hook must finalize hardware shutdown, release DMA265and other resources, etc.266 </para>267+268+ </sect2>269270 </sect1>271 </chapter>