···186186 ata_wait_idle(ap);187187}188188189189+190190+/**191191+ * ata_tf_load - send taskfile registers to host controller192192+ * @ap: Port to which output is sent193193+ * @tf: ATA taskfile register set194194+ *195195+ * Outputs ATA taskfile to standard ATA host controller using MMIO196196+ * or PIO as indicated by the ATA_FLAG_MMIO flag.197197+ * Writes the control, feature, nsect, lbal, lbam, and lbah registers.198198+ * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect,199199+ * hob_lbal, hob_lbam, and hob_lbah.200200+ *201201+ * This function waits for idle (!BUSY and !DRQ) after writing202202+ * registers. If the control register has a new value, this203203+ * function also waits for idle after writing control and before204204+ * writing the remaining registers.205205+ *206206+ * May be used as the tf_load() entry in ata_port_operations.207207+ *208208+ * LOCKING:209209+ * Inherited from caller.210210+ */189211void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)190212{191213 if (ap->flags & ATA_FLAG_MMIO)···217195}218196219197/**220220- * ata_exec_command - issue ATA command to host controller198198+ * ata_exec_command_pio - issue ATA command to host controller221199 * @ap: port to which command is being issued222200 * @tf: ATA taskfile register set223201 *224224- * Issues PIO/MMIO write to ATA command register, with proper202202+ * Issues PIO write to ATA command register, with proper225203 * synchronization with interrupt handler / other threads.226204 *227205 * LOCKING:···257235 ata_pause(ap);258236}259237238238+239239+/**240240+ * ata_exec_command - issue ATA command to host controller241241+ * @ap: port to which command is being issued242242+ * @tf: ATA taskfile register set243243+ *244244+ * Issues PIO/MMIO write to ATA command register, with proper245245+ * synchronization with interrupt handler / other threads.246246+ *247247+ * LOCKING:248248+ * spin_lock_irqsave(host_set lock)249249+ */260250void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf)261251{262252 if (ap->flags & ATA_FLAG_MMIO)···339305}340306341307/**342342- * ata_tf_read - input device's ATA taskfile shadow registers308308+ * ata_tf_read_pio - input device's ATA taskfile shadow registers343309 * @ap: Port from which input is read344310 * @tf: ATA taskfile register set for storing input345311 *···402368 }403369}404370371371+372372+/**373373+ * ata_tf_read - input device's ATA taskfile shadow registers374374+ * @ap: Port from which input is read375375+ * @tf: ATA taskfile register set for storing input376376+ *377377+ * Reads ATA taskfile registers for currently-selected device378378+ * into @tf.379379+ *380380+ * Reads nsect, lbal, lbam, lbah, and device. If ATA_TFLAG_LBA48381381+ * is set, also reads the hob registers.382382+ *383383+ * May be used as the tf_read() entry in ata_port_operations.384384+ *385385+ * LOCKING:386386+ * Inherited from caller.387387+ */405388void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)406389{407390 if (ap->flags & ATA_FLAG_MMIO)···432381 * @ap: port where the device is433382 *434383 * Reads ATA taskfile status register for currently-selected device435435- * and return it's value. This also clears pending interrupts384384+ * and return its value. This also clears pending interrupts436385 * from this device437386 *438387 * LOCKING:···448397 * @ap: port where the device is449398 *450399 * Reads ATA taskfile status register for currently-selected device451451- * via MMIO and return it's value. This also clears pending interrupts400400+ * via MMIO and return its value. This also clears pending interrupts452401 * from this device453402 *454403 * LOCKING:···459408 return readb((void __iomem *) ap->ioaddr.status_addr);460409}461410411411+412412+/**413413+ * ata_check_status - Read device status reg & clear interrupt414414+ * @ap: port where the device is415415+ *416416+ * Reads ATA taskfile status register for currently-selected device417417+ * and return its value. This also clears pending interrupts418418+ * from this device419419+ *420420+ * May be used as the check_status() entry in ata_port_operations.421421+ *422422+ * LOCKING:423423+ * Inherited from caller.424424+ */462425u8 ata_check_status(struct ata_port *ap)463426{464427 if (ap->flags & ATA_FLAG_MMIO)···480415 return ata_check_status_pio(ap);481416}482417418418+419419+/**420420+ * ata_altstatus - Read device alternate status reg421421+ * @ap: port where the device is422422+ *423423+ * Reads ATA taskfile alternate status register for424424+ * currently-selected device and return its value.425425+ *426426+ * Note: may NOT be used as the check_altstatus() entry in427427+ * ata_port_operations.428428+ *429429+ * LOCKING:430430+ * Inherited from caller.431431+ */483432u8 ata_altstatus(struct ata_port *ap)484433{485434 if (ap->ops->check_altstatus)···504425 return inb(ap->ioaddr.altstatus_addr);505426}506427428428+429429+/**430430+ * ata_chk_err - Read device error reg431431+ * @ap: port where the device is432432+ *433433+ * Reads ATA taskfile error register for434434+ * currently-selected device and return its value.435435+ *436436+ * Note: may NOT be used as the check_err() entry in437437+ * ata_port_operations.438438+ *439439+ * LOCKING:440440+ * Inherited from caller.441441+ */507442u8 ata_chk_err(struct ata_port *ap)508443{509444 if (ap->ops->check_err)···966873 }967874}968875876876+877877+/**878878+ * ata_noop_dev_select - Select device 0/1 on ATA bus879879+ * @ap: ATA channel to manipulate880880+ * @device: ATA device (numbered from zero) to select881881+ *882882+ * This function performs no actual function.883883+ *884884+ * May be used as the dev_select() entry in ata_port_operations.885885+ *886886+ * LOCKING:887887+ * caller.888888+ */969889void ata_noop_dev_select (struct ata_port *ap, unsigned int device)970890{971891}892892+972893973894/**974895 * ata_std_dev_select - Select device 0/1 on ATA bus···991884 *992885 * Use the method defined in the ATA specification to993886 * make either device 0, or device 1, active on the994994- * ATA channel.887887+ * ATA channel. Works with both PIO and MMIO.888888+ *889889+ * May be used as the dev_select() entry in ata_port_operations.995890 *996891 * LOCKING:997892 * caller.···22362127 * spin_lock_irqsave(host_set lock)22372128 */2238212921302130+21312131+21322132+/**21332133+ * ata_sg_init_one - Prepare a one-entry scatter-gather list.21342134+ * @qc: Queued command21352135+ * @buf: transfer buffer21362136+ * @buflen: length of buf21372137+ *21382138+ * Builds a single-entry scatter-gather list to initiate a21392139+ * transfer utilizing the specified buffer.21402140+ *21412141+ * LOCKING:21422142+ */22392143void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)22402144{22412145 struct scatterlist *sg;···22782156 *22792157 * LOCKING:22802158 * spin_lock_irqsave(host_set lock)21592159+ */21602160+21612161+21622162+/**21632163+ * ata_sg_init - Assign a scatter gather list to a queued command21642164+ * @qc: Queued command21652165+ * @sg: Scatter-gather list21662166+ * @n_elem: length of sg list21672167+ *21682168+ * Attaches a scatter-gather list to a queued command.21692169+ *21702170+ * LOCKING:22812171 */2282217222832173void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,···24652331 ata_qc_complete(qc, drv_stat);24662332}2467233323342334+23352335+/**23362336+ * swap_buf_le16 -23372337+ * @buf: Buffer to swap23382338+ * @buf_words: Number of 16-bit words in buffer.23392339+ *23402340+ * Swap halves of 16-bit words if needed to convert from23412341+ * little-endian byte order to native cpu byte order, or23422342+ * vice-versa.23432343+ *23442344+ * LOCKING:23452345+ */24682346void swap_buf_le16(u16 *buf, unsigned int buf_words)24692347{24702348#ifdef __BIG_ENDIAN···31382992 return -1;31392993}3140299429952995+31412996/**31422997 * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner31432998 * @qc: command to issue to device···31473000 * starts an ATA command. ATA commands are grouped into31483001 * classes called "protocols", and issuing each type of protocol31493002 * is slightly different.30033003+ *30043004+ * May be used as the qc_issue() entry in ata_port_operations.31503005 *31513006 * LOCKING:31523007 * spin_lock_irqsave(host_set lock)···32073058}3208305932093060/**32103210- * ata_bmdma_setup - Set up PCI IDE BMDMA transaction30613061+ * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction32113062 * @qc: Info associated with this ATA transaction.32123063 *32133064 * LOCKING:···33143165 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);33153166}3316316731683168+31693169+/**31703170+ * ata_bmdma_start - Start a PCI IDE BMDMA transaction31713171+ * @qc: Info associated with this ATA transaction.31723172+ *31733173+ * Writes the ATA_DMA_START flag to the DMA command register.31743174+ *31753175+ * May be used as the bmdma_start() entry in ata_port_operations.31763176+ *31773177+ * LOCKING:31783178+ * spin_lock_irqsave(host_set lock)31793179+ */33173180void ata_bmdma_start(struct ata_queued_cmd *qc)33183181{33193182 if (qc->ap->flags & ATA_FLAG_MMIO)···33343173 ata_bmdma_start_pio(qc);33353174}3336317531763176+31773177+/**31783178+ * ata_bmdma_setup - Set up PCI IDE BMDMA transaction31793179+ * @qc: Info associated with this ATA transaction.31803180+ *31813181+ * Writes address of PRD table to device's PRD Table Address31823182+ * register, sets the DMA control register, and calls31833183+ * ops->exec_command() to start the transfer.31843184+ *31853185+ * May be used as the bmdma_setup() entry in ata_port_operations.31863186+ *31873187+ * LOCKING:31883188+ * spin_lock_irqsave(host_set lock)31893189+ */33373190void ata_bmdma_setup(struct ata_queued_cmd *qc)33383191{33393192 if (qc->ap->flags & ATA_FLAG_MMIO)···33553180 else33563181 ata_bmdma_setup_pio(qc);33573182}31833183+31843184+31853185+/**31863186+ * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.31873187+ * @qc: Info associated with this ATA transaction.31883188+ *31893189+ * Clear interrupt and error flags in DMA status register.31903190+ *31913191+ * May be used as the irq_clear() entry in ata_port_operations.31923192+ *31933193+ * LOCKING:31943194+ * spin_lock_irqsave(host_set lock)31953195+ */3358319633593197void ata_bmdma_irq_clear(struct ata_port *ap)33603198{···3381319333823194}3383319531963196+31973197+/**31983198+ * ata_bmdma_status - Read PCI IDE BMDMA status31993199+ * @qc: Info associated with this ATA transaction.32003200+ *32013201+ * Read and return BMDMA status register.32023202+ *32033203+ * May be used as the bmdma_status() entry in ata_port_operations.32043204+ *32053205+ * LOCKING:32063206+ * spin_lock_irqsave(host_set lock)32073207+ */32083208+33843209u8 ata_bmdma_status(struct ata_port *ap)33853210{33863211 u8 host_stat;···34043203 host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);34053204 return host_stat;34063205}32063206+32073207+32083208+/**32093209+ * ata_bmdma_stop - Stop PCI IDE BMDMA transfer32103210+ * @qc: Info associated with this ATA transaction.32113211+ *32123212+ * Clears the ATA_DMA_START flag in the dma control register32133213+ *32143214+ * May be used as the bmdma_stop() entry in ata_port_operations.32153215+ *32163216+ * LOCKING:32173217+ * spin_lock_irqsave(host_set lock)32183218+ */3407321934083220void ata_bmdma_stop(struct ata_port *ap)34093221{···36213407 ata_qc_complete(qc, ATA_ERR);36223408}3623340934103410+34113411+/**34123412+ * ata_port_start - Set port up for dma.34133413+ * @ap: Port to initialize34143414+ *34153415+ * Called just after data structures for each port are34163416+ * initialized. Allocates space for PRD table.34173417+ *34183418+ * May be used as the port_start() entry in ata_port_operations.34193419+ *34203420+ * LOCKING:34213421+ */34223422+36243423int ata_port_start (struct ata_port *ap)36253424{36263425 struct device *dev = ap->host_set->dev;···3646341936473420 return 0;36483421}34223422+34233423+34243424+/**34253425+ * ata_port_stop - Undo ata_port_start()34263426+ * @ap: Port to shut down34273427+ *34283428+ * Frees the PRD table.34293429+ *34303430+ * May be used as the port_stop() entry in ata_port_operations.34313431+ *34323432+ * LOCKING:34333433+ */3649343436503435void ata_port_stop (struct ata_port *ap)36513436{···39593720/**39603721 * ata_std_ports - initialize ioaddr with standard port offsets.39613722 * @ioaddr: IO address structure to be initialized37233723+ *37243724+ * Utility function which initializes data_addr, error_addr,37253725+ * feature_addr, nsect_addr, lbal_addr, lbam_addr, lbah_addr,37263726+ * device_addr, status_addr, and command_addr to standard offsets37273727+ * relative to cmd_addr.37283728+ *37293729+ * Does not set ctl_addr, altstatus_addr, bmdma_addr, or scr_addr.39623730 */37313731+39633732void ata_std_ports(struct ata_ioports *ioaddr)39643733{39653734 ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA;···4008376140093762 return probe_ent;40103763}37643764+37653765+37663766+37673767+/**37683768+ * ata_pci_init_native_mode - Initialize native-mode driver37693769+ * @pdev: pci device to be initialized37703770+ * @port: array[2] of pointers to port info structures.37713771+ *37723772+ * Utility function which allocates and initializes an37733773+ * ata_probe_ent structure for a standard dual-port37743774+ * PIO-based IDE controller. The returned ata_probe_ent37753775+ * structure can be passed to ata_device_add(). The returned37763776+ * ata_probe_ent structure should then be freed with kfree().37773777+ */4011377840123779#ifdef CONFIG_PCI40133780struct ata_probe_ent *···41033842 * @pdev: Controller to be initialized41043843 * @port_info: Information from low-level host driver41053844 * @n_ports: Number of ports attached to host controller38453845+ *38463846+ * This is a helper function which can be called from a driver's38473847+ * xxx_init_one() probe function if the hardware uses traditional38483848+ * IDE taskfile registers.38493849+ *38503850+ * This function calls pci_enable_device(), reserves its register38513851+ * regions, sets the dma mask, enables bus master mode, and calls38523852+ * ata_device_add()41063853 *41073854 * LOCKING:41083855 * Inherited from PCI layer (may sleep).
+58
include/linux/libata.h
···466466 return ap->ops->check_status(ap);467467}468468469469+470470+/**471471+ * ata_pause - Flush writes and pause 400 nanoseconds.472472+ * @ap: Port to wait for.473473+ *474474+ * LOCKING:475475+ * Inherited from caller.476476+ */477477+469478static inline void ata_pause(struct ata_port *ap)470479{471480 ata_altstatus(ap);472481 ndelay(400);473482}483483+484484+485485+/**486486+ * ata_busy_wait - Wait for a port status register487487+ * @ap: Port to wait for.488488+ *489489+ * Waits up to max*10 microseconds for the selected bits in the port's490490+ * status register to be cleared.491491+ * Returns final value of status register.492492+ *493493+ * LOCKING:494494+ * Inherited from caller.495495+ */474496475497static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,476498 unsigned int max)···507485508486 return status;509487}488488+489489+490490+/**491491+ * ata_wait_idle - Wait for a port to be idle.492492+ * @ap: Port to wait for.493493+ *494494+ * Waits up to 10ms for port's BUSY and DRQ signals to clear.495495+ * Returns final value of status register.496496+ *497497+ * LOCKING:498498+ * Inherited from caller.499499+ */510500511501static inline u8 ata_wait_idle(struct ata_port *ap)512502{···558524 tf->device = ATA_DEVICE_OBS | ATA_DEV1;559525}560526527527+528528+/**529529+ * ata_irq_on - Enable interrupts on a port.530530+ * @ap: Port on which interrupts are enabled.531531+ *532532+ * Enable interrupts on a legacy IDE device using MMIO or PIO,533533+ * wait for idle, clear any pending interrupts.534534+ *535535+ * LOCKING:536536+ * Inherited from caller.537537+ */538538+561539static inline u8 ata_irq_on(struct ata_port *ap)562540{563541 struct ata_ioports *ioaddr = &ap->ioaddr;···588542589543 return tmp;590544}545545+546546+547547+/**548548+ * ata_irq_ack - Acknowledge a device interrupt.549549+ * @ap: Port on which interrupts are enabled.550550+ *551551+ * Wait up to 10 ms for legacy IDE device to become idle (BUSY552552+ * or BUSY+DRQ clear). Obtain dma status and port status from553553+ * device. Clear the interrupt. Return port status.554554+ *555555+ * LOCKING:556556+ */591557592558static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)593559{