Lines Matching full:ap
55 * @ap: port where the device is
64 u8 ata_sff_check_status(struct ata_port *ap) in ata_sff_check_status() argument
66 return ioread8(ap->ioaddr.status_addr); in ata_sff_check_status()
72 * @ap: port where the device is
84 static bool ata_sff_altstatus(struct ata_port *ap, u8 *status) in ata_sff_altstatus() argument
88 if (ap->ops->sff_check_altstatus) { in ata_sff_altstatus()
89 tmp = ap->ops->sff_check_altstatus(ap); in ata_sff_altstatus()
92 if (ap->ioaddr.altstatus_addr) { in ata_sff_altstatus()
93 tmp = ioread8(ap->ioaddr.altstatus_addr); in ata_sff_altstatus()
106 * @ap: port where the device is
116 static u8 ata_sff_irq_status(struct ata_port *ap) in ata_sff_irq_status() argument
121 if (ata_sff_altstatus(ap, &status) && (status & ATA_BUSY)) in ata_sff_irq_status()
124 status = ap->ops->sff_check_status(ap); in ata_sff_irq_status()
130 * @ap: Port to wait for.
140 static void ata_sff_sync(struct ata_port *ap) in ata_sff_sync() argument
142 ata_sff_altstatus(ap, NULL); in ata_sff_sync()
147 * @ap: Port to pause for.
157 void ata_sff_pause(struct ata_port *ap) in ata_sff_pause() argument
159 ata_sff_sync(ap); in ata_sff_pause()
166 * @ap: Port to pause for.
172 void ata_sff_dma_pause(struct ata_port *ap) in ata_sff_dma_pause() argument
178 if (ata_sff_altstatus(ap, NULL)) in ata_sff_dma_pause()
189 * @ap: port containing status register to be polled
202 int ata_sff_busy_sleep(struct ata_port *ap, in ata_sff_busy_sleep() argument
208 status = ata_sff_busy_wait(ap, ATA_BUSY, 300); in ata_sff_busy_sleep()
213 ata_msleep(ap, 50); in ata_sff_busy_sleep()
214 status = ata_sff_busy_wait(ap, ATA_BUSY, 3); in ata_sff_busy_sleep()
218 ata_port_warn(ap, in ata_sff_busy_sleep()
225 ata_msleep(ap, 50); in ata_sff_busy_sleep()
226 status = ap->ops->sff_check_status(ap); in ata_sff_busy_sleep()
233 ata_port_err(ap, in ata_sff_busy_sleep()
245 u8 status = link->ap->ops->sff_check_status(link->ap); in ata_sff_check_ready()
272 * @ap: port where the device is
283 static bool ata_sff_set_devctl(struct ata_port *ap, u8 ctl) in ata_sff_set_devctl() argument
285 if (ap->ops->sff_set_devctl) { in ata_sff_set_devctl()
286 ap->ops->sff_set_devctl(ap, ctl); in ata_sff_set_devctl()
289 if (ap->ioaddr.ctl_addr) { in ata_sff_set_devctl()
290 iowrite8(ctl, ap->ioaddr.ctl_addr); in ata_sff_set_devctl()
299 * @ap: ATA channel to manipulate
311 void ata_sff_dev_select(struct ata_port *ap, unsigned int device) in ata_sff_dev_select() argument
320 iowrite8(tmp, ap->ioaddr.device_addr); in ata_sff_dev_select()
321 ata_sff_pause(ap); /* needed; also flushes, for mmio */ in ata_sff_dev_select()
327 * @ap: ATA channel to manipulate
343 static void ata_dev_select(struct ata_port *ap, unsigned int device, in ata_dev_select() argument
347 ata_wait_idle(ap); in ata_dev_select()
349 ap->ops->sff_dev_select(ap, device); in ata_dev_select()
352 if (can_sleep && ap->link.device[device].class == ATA_DEV_ATAPI) in ata_dev_select()
353 ata_msleep(ap, 150); in ata_dev_select()
354 ata_wait_idle(ap); in ata_dev_select()
360 * @ap: Port on which interrupts are enabled.
371 void ata_sff_irq_on(struct ata_port *ap) in ata_sff_irq_on() argument
373 if (ap->ops->sff_irq_on) { in ata_sff_irq_on()
374 ap->ops->sff_irq_on(ap); in ata_sff_irq_on()
378 ap->ctl &= ~ATA_NIEN; in ata_sff_irq_on()
379 ap->last_ctl = ap->ctl; in ata_sff_irq_on()
381 ata_sff_set_devctl(ap, ap->ctl); in ata_sff_irq_on()
382 ata_wait_idle(ap); in ata_sff_irq_on()
384 if (ap->ops->sff_irq_clear) in ata_sff_irq_on()
385 ap->ops->sff_irq_clear(ap); in ata_sff_irq_on()
391 * @ap: Port to which output is sent
399 void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) in ata_sff_tf_load() argument
401 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_tf_load()
404 if (tf->ctl != ap->last_ctl) { in ata_sff_tf_load()
407 ap->last_ctl = tf->ctl; in ata_sff_tf_load()
408 ata_wait_idle(ap); in ata_sff_tf_load()
431 ata_wait_idle(ap); in ata_sff_tf_load()
437 * @ap: Port from which input is read
448 void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in ata_sff_tf_read() argument
450 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_tf_read()
452 tf->status = ata_sff_check_status(ap); in ata_sff_tf_read()
469 ap->last_ctl = tf->ctl; in ata_sff_tf_read()
478 * @ap: port to which command is being issued
487 void ata_sff_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) in ata_sff_exec_command() argument
489 iowrite8(tf->command, ap->ioaddr.command_addr); in ata_sff_exec_command()
490 ata_sff_pause(ap); in ata_sff_exec_command()
496 * @ap: port to which command is being issued
507 static inline void ata_tf_to_host(struct ata_port *ap, in ata_tf_to_host() argument
511 trace_ata_tf_load(ap, tf); in ata_tf_to_host()
512 ap->ops->sff_tf_load(ap, tf); in ata_tf_to_host()
513 trace_ata_exec_command(ap, tf, tag); in ata_tf_to_host()
514 ap->ops->sff_exec_command(ap, tf); in ata_tf_to_host()
535 struct ata_port *ap = qc->dev->link->ap; in ata_sff_data_xfer() local
536 void __iomem *data_addr = ap->ioaddr.data_addr; in ata_sff_data_xfer()
591 struct ata_port *ap = dev->link->ap; in ata_sff_data_xfer32() local
592 void __iomem *data_addr = ap->ioaddr.data_addr; in ata_sff_data_xfer32()
596 if (!(ap->pflags & ATA_PFLAG_PIO32)) in ata_sff_data_xfer32()
641 qc->ap->ops->sff_data_xfer(qc, buf + offset, xfer_size, do_write); in ata_pio_xfer()
659 struct ata_port *ap = qc->ap; in ata_pio_sector() local
668 ap->hsm_task_state = HSM_ST_LAST; in ata_pio_sector()
700 ap->hsm_task_state = HSM_ST_LAST; in ata_pio_sector()
730 ata_sff_sync(qc->ap); /* flush */ in ata_pio_sectors()
735 * @ap: Port to which ATAPI device is attached.
744 static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) in atapi_send_cdb() argument
750 ap->ops->sff_data_xfer(qc, qc->cdb, qc->dev->cdb_len, 1); in atapi_send_cdb()
751 ata_sff_sync(ap); in atapi_send_cdb()
756 ap->hsm_task_state = HSM_ST; in atapi_send_cdb()
759 ap->hsm_task_state = HSM_ST_LAST; in atapi_send_cdb()
763 ap->hsm_task_state = HSM_ST_LAST; in atapi_send_cdb()
765 trace_ata_bmdma_start(ap, &qc->tf, qc->tag); in atapi_send_cdb()
766 ap->ops->bmdma_start(qc); in atapi_send_cdb()
788 struct ata_port *ap = qc->ap; in __atapi_pio_bytes() local
822 consumed = ap->ops->sff_data_xfer(qc, buf + offset, count, rw); in __atapi_pio_bytes()
856 struct ata_port *ap = qc->ap; in atapi_pio_bytes() local
868 ap->ops->sff_tf_read(ap, &qc->result_tf); in atapi_pio_bytes()
888 ata_sff_sync(ap); /* flush */ in atapi_pio_bytes()
897 ap->hsm_task_state = HSM_ST_ERR; in atapi_pio_bytes()
902 * @ap: the target ata_port
908 static inline int ata_hsm_ok_in_wq(struct ata_port *ap, in ata_hsm_ok_in_wq() argument
914 if (ap->hsm_task_state == HSM_ST_FIRST) { in ata_hsm_ok_in_wq()
940 struct ata_port *ap = qc->ap; in ata_hsm_qc_complete() local
942 if (ap->ops->error_handler) { in ata_hsm_qc_complete()
947 qc = ata_qc_from_tag(ap, qc->tag); in ata_hsm_qc_complete()
950 ata_sff_irq_on(ap); in ata_hsm_qc_complete()
953 ata_port_freeze(ap); in ata_hsm_qc_complete()
959 ata_port_freeze(ap); in ata_hsm_qc_complete()
963 ata_sff_irq_on(ap); in ata_hsm_qc_complete()
972 * @ap: the target ata_port
980 int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, in ata_sff_hsm_move() argument
987 lockdep_assert_held(ap->lock); in ata_sff_hsm_move()
995 WARN_ON_ONCE(in_wq != ata_hsm_ok_in_wq(ap, qc)); in ata_sff_hsm_move()
1000 switch (ap->hsm_task_state) { in ata_sff_hsm_move()
1023 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1044 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1058 ap->hsm_task_state = HSM_ST; in ata_sff_hsm_move()
1062 atapi_send_cdb(ap, qc); in ata_sff_hsm_move()
1077 ap->hsm_task_state = HSM_ST_LAST; in ata_sff_hsm_move()
1092 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1098 if (unlikely(ap->hsm_task_state == HSM_ST_ERR)) in ata_sff_hsm_move()
1130 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1150 status = ata_wait_idle(ap); in ata_sff_hsm_move()
1174 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1180 if (ap->hsm_task_state == HSM_ST_LAST && in ata_sff_hsm_move()
1183 status = ata_wait_idle(ap); in ata_sff_hsm_move()
1194 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1203 ap->hsm_task_state = HSM_ST_IDLE; in ata_sff_hsm_move()
1212 ap->hsm_task_state = HSM_ST_IDLE; in ata_sff_hsm_move()
1222 ap->print_id, ap->hsm_task_state); in ata_sff_hsm_move()
1243 struct ata_port *ap = link->ap; in ata_sff_queue_pio_task() local
1245 WARN_ON((ap->sff_pio_task_link != NULL) && in ata_sff_queue_pio_task()
1246 (ap->sff_pio_task_link != link)); in ata_sff_queue_pio_task()
1247 ap->sff_pio_task_link = link; in ata_sff_queue_pio_task()
1250 ata_sff_queue_delayed_work(&ap->sff_pio_task, msecs_to_jiffies(delay)); in ata_sff_queue_pio_task()
1254 void ata_sff_flush_pio_task(struct ata_port *ap) in ata_sff_flush_pio_task() argument
1256 trace_ata_sff_flush_pio_task(ap); in ata_sff_flush_pio_task()
1258 cancel_delayed_work_sync(&ap->sff_pio_task); in ata_sff_flush_pio_task()
1268 spin_lock_irq(ap->lock); in ata_sff_flush_pio_task()
1269 ap->hsm_task_state = HSM_ST_IDLE; in ata_sff_flush_pio_task()
1270 spin_unlock_irq(ap->lock); in ata_sff_flush_pio_task()
1272 ap->sff_pio_task_link = NULL; in ata_sff_flush_pio_task()
1277 struct ata_port *ap = in ata_sff_pio_task() local
1279 struct ata_link *link = ap->sff_pio_task_link; in ata_sff_pio_task()
1284 spin_lock_irq(ap->lock); in ata_sff_pio_task()
1286 BUG_ON(ap->sff_pio_task_link == NULL); in ata_sff_pio_task()
1288 qc = ata_qc_from_tag(ap, link->active_tag); in ata_sff_pio_task()
1290 ap->sff_pio_task_link = NULL; in ata_sff_pio_task()
1295 WARN_ON_ONCE(ap->hsm_task_state == HSM_ST_IDLE); in ata_sff_pio_task()
1304 status = ata_sff_busy_wait(ap, ATA_BUSY, 5); in ata_sff_pio_task()
1306 spin_unlock_irq(ap->lock); in ata_sff_pio_task()
1307 ata_msleep(ap, 2); in ata_sff_pio_task()
1308 spin_lock_irq(ap->lock); in ata_sff_pio_task()
1310 status = ata_sff_busy_wait(ap, ATA_BUSY, 10); in ata_sff_pio_task()
1321 ap->sff_pio_task_link = NULL; in ata_sff_pio_task()
1323 poll_next = ata_sff_hsm_move(ap, qc, status, 1); in ata_sff_pio_task()
1331 spin_unlock_irq(ap->lock); in ata_sff_pio_task()
1349 struct ata_port *ap = qc->ap; in ata_sff_qc_issue() local
1355 if (ap->flags & ATA_FLAG_PIO_POLLING) in ata_sff_qc_issue()
1359 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_sff_qc_issue()
1367 ata_tf_to_host(ap, &qc->tf, qc->tag); in ata_sff_qc_issue()
1368 ap->hsm_task_state = HSM_ST_LAST; in ata_sff_qc_issue()
1379 ata_tf_to_host(ap, &qc->tf, qc->tag); in ata_sff_qc_issue()
1383 ap->hsm_task_state = HSM_ST_FIRST; in ata_sff_qc_issue()
1391 ap->hsm_task_state = HSM_ST; in ata_sff_qc_issue()
1409 ata_tf_to_host(ap, &qc->tf, qc->tag); in ata_sff_qc_issue()
1411 ap->hsm_task_state = HSM_ST_FIRST; in ata_sff_qc_issue()
1442 qc->ap->ops->sff_tf_read(qc->ap, &qc->result_tf); in ata_sff_qc_fill_rtf()
1447 static unsigned int ata_sff_idle_irq(struct ata_port *ap) in ata_sff_idle_irq() argument
1449 ap->stats.idle_irq++; in ata_sff_idle_irq()
1452 if ((ap->stats.idle_irq % 1000) == 0) { in ata_sff_idle_irq()
1453 ap->ops->sff_check_status(ap); in ata_sff_idle_irq()
1454 if (ap->ops->sff_irq_clear) in ata_sff_idle_irq()
1455 ap->ops->sff_irq_clear(ap); in ata_sff_idle_irq()
1456 ata_port_warn(ap, "irq trap\n"); in ata_sff_idle_irq()
1463 static unsigned int __ata_sff_port_intr(struct ata_port *ap, in __ata_sff_port_intr() argument
1472 switch (ap->hsm_task_state) { in __ata_sff_port_intr()
1483 return ata_sff_idle_irq(ap); in __ata_sff_port_intr()
1486 return ata_sff_idle_irq(ap); in __ata_sff_port_intr()
1492 status = ata_sff_irq_status(ap); in __ata_sff_port_intr()
1497 ap->hsm_task_state = HSM_ST_ERR; in __ata_sff_port_intr()
1499 return ata_sff_idle_irq(ap); in __ata_sff_port_intr()
1503 if (ap->ops->sff_irq_clear) in __ata_sff_port_intr()
1504 ap->ops->sff_irq_clear(ap); in __ata_sff_port_intr()
1506 ata_sff_hsm_move(ap, qc, status, 0); in __ata_sff_port_intr()
1513 * @ap: Port on which interrupt arrived (possibly...)
1524 unsigned int ata_sff_port_intr(struct ata_port *ap, struct ata_queued_cmd *qc) in ata_sff_port_intr() argument
1526 return __ata_sff_port_intr(ap, qc, false); in ata_sff_port_intr()
1545 struct ata_port *ap = host->ports[i]; in __ata_sff_interrupt() local
1548 qc = ata_qc_from_tag(ap, ap->link.active_tag); in __ata_sff_interrupt()
1551 handled |= port_intr(ap, qc); in __ata_sff_interrupt()
1567 struct ata_port *ap = host->ports[i]; in __ata_sff_interrupt() local
1572 if (!ap->ops->sff_irq_check || in __ata_sff_interrupt()
1573 !ap->ops->sff_irq_check(ap)) in __ata_sff_interrupt()
1577 ap->ops->sff_check_status(ap); in __ata_sff_interrupt()
1578 if (ap->ops->sff_irq_clear) in __ata_sff_interrupt()
1579 ap->ops->sff_irq_clear(ap); in __ata_sff_interrupt()
1582 if (!(ap->ops->sff_check_status(ap) & ATA_BUSY)) in __ata_sff_interrupt()
1624 * @ap: port that appears to have timed out
1635 void ata_sff_lost_interrupt(struct ata_port *ap) in ata_sff_lost_interrupt() argument
1641 qc = ata_qc_from_tag(ap, ap->link.active_tag); in ata_sff_lost_interrupt()
1647 if (WARN_ON_ONCE(!ata_sff_altstatus(ap, &status))) in ata_sff_lost_interrupt()
1654 ata_port_warn(ap, "lost interrupt (Status 0x%x)\n", status); in ata_sff_lost_interrupt()
1657 ata_sff_port_intr(ap, qc); in ata_sff_lost_interrupt()
1663 * @ap: port to freeze
1670 void ata_sff_freeze(struct ata_port *ap) in ata_sff_freeze() argument
1672 ap->ctl |= ATA_NIEN; in ata_sff_freeze()
1673 ap->last_ctl = ap->ctl; in ata_sff_freeze()
1675 ata_sff_set_devctl(ap, ap->ctl); in ata_sff_freeze()
1681 ap->ops->sff_check_status(ap); in ata_sff_freeze()
1683 if (ap->ops->sff_irq_clear) in ata_sff_freeze()
1684 ap->ops->sff_irq_clear(ap); in ata_sff_freeze()
1690 * @ap: port to thaw
1697 void ata_sff_thaw(struct ata_port *ap) in ata_sff_thaw() argument
1700 ap->ops->sff_check_status(ap); in ata_sff_thaw()
1701 if (ap->ops->sff_irq_clear) in ata_sff_thaw()
1702 ap->ops->sff_irq_clear(ap); in ata_sff_thaw()
1703 ata_sff_irq_on(ap); in ata_sff_thaw()
1751 * @ap: ATA channel to examine
1769 static bool ata_devchk(struct ata_port *ap, unsigned int device) in ata_devchk() argument
1771 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_devchk()
1774 ap->ops->sff_dev_select(ap, device); in ata_devchk()
1818 struct ata_port *ap = dev->link->ap; in ata_sff_dev_classify() local
1823 ap->ops->sff_dev_select(ap, dev->devno); in ata_sff_dev_classify()
1827 ap->ops->sff_tf_read(ap, &tf); in ata_sff_dev_classify()
1844 class = ata_port_classify(ap, &tf); in ata_sff_dev_classify()
1860 if (ap->ops->sff_check_status(ap) == 0) in ata_sff_dev_classify()
1888 struct ata_port *ap = link->ap; in ata_sff_wait_after_reset() local
1889 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_wait_after_reset()
1894 ata_msleep(ap, ATA_WAIT_AFTER_RESET); in ata_sff_wait_after_reset()
1910 ap->ops->sff_dev_select(ap, 1); in ata_sff_wait_after_reset()
1923 ata_msleep(ap, 50); /* give drive a breather */ in ata_sff_wait_after_reset()
1935 ap->ops->sff_dev_select(ap, 0); in ata_sff_wait_after_reset()
1937 ap->ops->sff_dev_select(ap, 1); in ata_sff_wait_after_reset()
1939 ap->ops->sff_dev_select(ap, 0); in ata_sff_wait_after_reset()
1945 static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, in ata_bus_softreset() argument
1948 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_bus_softreset()
1950 if (ap->ioaddr.ctl_addr) { in ata_bus_softreset()
1952 iowrite8(ap->ctl, ioaddr->ctl_addr); in ata_bus_softreset()
1954 iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr); in ata_bus_softreset()
1956 iowrite8(ap->ctl, ioaddr->ctl_addr); in ata_bus_softreset()
1957 ap->last_ctl = ap->ctl; in ata_bus_softreset()
1961 return ata_sff_wait_after_reset(&ap->link, devmask, deadline); in ata_bus_softreset()
1981 struct ata_port *ap = link->ap; in ata_sff_softreset() local
1982 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; in ata_sff_softreset()
1988 if (ata_devchk(ap, 0)) in ata_sff_softreset()
1990 if (slave_possible && ata_devchk(ap, 1)) in ata_sff_softreset()
1994 ap->ops->sff_dev_select(ap, 0); in ata_sff_softreset()
1997 rc = ata_bus_softreset(ap, devmask, deadline); in ata_sff_softreset()
2061 struct ata_port *ap = link->ap; in ata_sff_postreset() local
2067 ap->ops->sff_dev_select(ap, 1); in ata_sff_postreset()
2069 ap->ops->sff_dev_select(ap, 0); in ata_sff_postreset()
2076 if (ata_sff_set_devctl(ap, ap->ctl)) in ata_sff_postreset()
2077 ap->last_ctl = ap->ctl; in ata_sff_postreset()
2094 struct ata_port *ap; in ata_sff_drain_fifo() local
2100 ap = qc->ap; in ata_sff_drain_fifo()
2102 for (count = 0; (ap->ops->sff_check_status(ap) & ATA_DRQ) in ata_sff_drain_fifo()
2104 ioread16(ap->ioaddr.data_addr); in ata_sff_drain_fifo()
2107 ata_port_dbg(ap, "drained %d bytes to clear DRQ\n", count); in ata_sff_drain_fifo()
2114 * @ap: port to handle error for
2124 void ata_sff_error_handler(struct ata_port *ap) in ata_sff_error_handler() argument
2126 ata_reset_fn_t softreset = ap->ops->softreset; in ata_sff_error_handler()
2127 ata_reset_fn_t hardreset = ap->ops->hardreset; in ata_sff_error_handler()
2131 qc = __ata_qc_from_tag(ap, ap->link.active_tag); in ata_sff_error_handler()
2135 spin_lock_irqsave(ap->lock, flags); in ata_sff_error_handler()
2144 if (ap->ops->sff_drain_fifo) in ata_sff_error_handler()
2145 ap->ops->sff_drain_fifo(qc); in ata_sff_error_handler()
2147 spin_unlock_irqrestore(ap->lock, flags); in ata_sff_error_handler()
2151 hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link)) in ata_sff_error_handler()
2154 ata_do_eh(ap, ap->ops->prereset, softreset, hardreset, in ata_sff_error_handler()
2155 ap->ops->postreset); in ata_sff_error_handler()
2229 struct ata_port *ap = host->ports[i]; in ata_pci_sff_init_host() local
2233 if (ata_port_is_dummy(ap)) in ata_pci_sff_init_host()
2241 ap->ops = &ata_dummy_port_ops; in ata_pci_sff_init_host()
2253 ap->ops = &ata_dummy_port_ops; in ata_pci_sff_init_host()
2258 ap->ioaddr.cmd_addr = iomap[base]; in ata_pci_sff_init_host()
2259 ap->ioaddr.altstatus_addr = in ata_pci_sff_init_host()
2260 ap->ioaddr.ctl_addr = (void __iomem *) in ata_pci_sff_init_host()
2262 ata_sff_std_ports(&ap->ioaddr); in ata_pci_sff_init_host()
2264 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx", in ata_pci_sff_init_host()
2569 struct ata_port *ap = qc->ap; in ata_bmdma_fill_sg() local
2570 struct ata_bmdma_prd *prd = ap->bmdma_prd; in ata_bmdma_fill_sg()
2619 struct ata_port *ap = qc->ap; in ata_bmdma_fill_sg_dumb() local
2620 struct ata_bmdma_prd *prd = ap->bmdma_prd; in ata_bmdma_fill_sg_dumb()
2719 struct ata_port *ap = qc->ap; in ata_bmdma_qc_issue() local
2727 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_bmdma_qc_issue()
2734 trace_ata_tf_load(ap, &qc->tf); in ata_bmdma_qc_issue()
2735 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in ata_bmdma_qc_issue()
2736 trace_ata_bmdma_setup(ap, &qc->tf, qc->tag); in ata_bmdma_qc_issue()
2737 ap->ops->bmdma_setup(qc); /* set up bmdma */ in ata_bmdma_qc_issue()
2738 trace_ata_bmdma_start(ap, &qc->tf, qc->tag); in ata_bmdma_qc_issue()
2739 ap->ops->bmdma_start(qc); /* initiate bmdma */ in ata_bmdma_qc_issue()
2740 ap->hsm_task_state = HSM_ST_LAST; in ata_bmdma_qc_issue()
2746 trace_ata_tf_load(ap, &qc->tf); in ata_bmdma_qc_issue()
2747 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in ata_bmdma_qc_issue()
2748 trace_ata_bmdma_setup(ap, &qc->tf, qc->tag); in ata_bmdma_qc_issue()
2749 ap->ops->bmdma_setup(qc); /* set up bmdma */ in ata_bmdma_qc_issue()
2750 ap->hsm_task_state = HSM_ST_FIRST; in ata_bmdma_qc_issue()
2768 * @ap: Port on which interrupt arrived (possibly...)
2779 unsigned int ata_bmdma_port_intr(struct ata_port *ap, struct ata_queued_cmd *qc) in ata_bmdma_port_intr() argument
2781 struct ata_eh_info *ehi = &ap->link.eh_info; in ata_bmdma_port_intr()
2786 if (ap->hsm_task_state == HSM_ST_LAST && ata_is_dma(qc->tf.protocol)) { in ata_bmdma_port_intr()
2788 host_stat = ap->ops->bmdma_status(ap); in ata_bmdma_port_intr()
2789 trace_ata_bmdma_status(ap, host_stat); in ata_bmdma_port_intr()
2793 return ata_sff_idle_irq(ap); in ata_bmdma_port_intr()
2796 trace_ata_bmdma_stop(ap, &qc->tf, qc->tag); in ata_bmdma_port_intr()
2797 ap->ops->bmdma_stop(qc); in ata_bmdma_port_intr()
2803 ap->hsm_task_state = HSM_ST_ERR; in ata_bmdma_port_intr()
2807 handled = __ata_sff_port_intr(ap, qc, bmdma_stopped); in ata_bmdma_port_intr()
2838 * @ap: port to handle error for
2848 void ata_bmdma_error_handler(struct ata_port *ap) in ata_bmdma_error_handler() argument
2854 qc = __ata_qc_from_tag(ap, ap->link.active_tag); in ata_bmdma_error_handler()
2859 spin_lock_irqsave(ap->lock, flags); in ata_bmdma_error_handler()
2864 host_stat = ap->ops->bmdma_status(ap); in ata_bmdma_error_handler()
2865 trace_ata_bmdma_status(ap, host_stat); in ata_bmdma_error_handler()
2877 trace_ata_bmdma_stop(ap, &qc->tf, qc->tag); in ata_bmdma_error_handler()
2878 ap->ops->bmdma_stop(qc); in ata_bmdma_error_handler()
2882 ap->ops->sff_check_status(ap); in ata_bmdma_error_handler()
2883 if (ap->ops->sff_irq_clear) in ata_bmdma_error_handler()
2884 ap->ops->sff_irq_clear(ap); in ata_bmdma_error_handler()
2888 spin_unlock_irqrestore(ap->lock, flags); in ata_bmdma_error_handler()
2891 ata_eh_thaw_port(ap); in ata_bmdma_error_handler()
2893 ata_sff_error_handler(ap); in ata_bmdma_error_handler()
2906 struct ata_port *ap = qc->ap; in ata_bmdma_post_internal_cmd() local
2910 spin_lock_irqsave(ap->lock, flags); in ata_bmdma_post_internal_cmd()
2911 trace_ata_bmdma_stop(ap, &qc->tf, qc->tag); in ata_bmdma_post_internal_cmd()
2912 ap->ops->bmdma_stop(qc); in ata_bmdma_post_internal_cmd()
2913 spin_unlock_irqrestore(ap->lock, flags); in ata_bmdma_post_internal_cmd()
2920 * @ap: Port associated with this ATA transaction.
2929 void ata_bmdma_irq_clear(struct ata_port *ap) in ata_bmdma_irq_clear() argument
2931 void __iomem *mmio = ap->ioaddr.bmdma_addr; in ata_bmdma_irq_clear()
2949 struct ata_port *ap = qc->ap; in ata_bmdma_setup() local
2955 iowrite32(ap->bmdma_prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS); in ata_bmdma_setup()
2958 dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_setup()
2962 iowrite8(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_setup()
2965 ap->ops->sff_exec_command(ap, &qc->tf); in ata_bmdma_setup()
2978 struct ata_port *ap = qc->ap; in ata_bmdma_start() local
2982 dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_start()
2983 iowrite8(dmactl | ATA_DMA_START, ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_start()
3015 struct ata_port *ap = qc->ap; in ata_bmdma_stop() local
3016 void __iomem *mmio = ap->ioaddr.bmdma_addr; in ata_bmdma_stop()
3023 ata_sff_dma_pause(ap); in ata_bmdma_stop()
3029 * @ap: Port associated with this ATA transaction.
3038 u8 ata_bmdma_status(struct ata_port *ap) in ata_bmdma_status() argument
3040 return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); in ata_bmdma_status()
3047 * @ap: Port to initialize
3057 int ata_bmdma_port_start(struct ata_port *ap) in ata_bmdma_port_start() argument
3059 if (ap->mwdma_mask || ap->udma_mask) { in ata_bmdma_port_start()
3060 ap->bmdma_prd = in ata_bmdma_port_start()
3061 dmam_alloc_coherent(ap->host->dev, ATA_PRD_TBL_SZ, in ata_bmdma_port_start()
3062 &ap->bmdma_prd_dma, GFP_KERNEL); in ata_bmdma_port_start()
3063 if (!ap->bmdma_prd) in ata_bmdma_port_start()
3073 * @ap: Port to initialize
3085 int ata_bmdma_port_start32(struct ata_port *ap) in ata_bmdma_port_start32() argument
3087 ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; in ata_bmdma_port_start32()
3088 return ata_bmdma_port_start(ap); in ata_bmdma_port_start32()
3172 struct ata_port *ap = host->ports[i]; in ata_pci_bmdma_init() local
3175 if (ata_port_is_dummy(ap)) in ata_pci_bmdma_init()
3178 ap->ioaddr.bmdma_addr = bmdma; in ata_pci_bmdma_init()
3179 if ((!(ap->flags & ATA_FLAG_IGN_SIMPLEX)) && in ata_pci_bmdma_init()
3183 ata_port_desc(ap, "bmdma 0x%llx", in ata_pci_bmdma_init()
3250 * @ap: Port to initialize
3258 void ata_sff_port_init(struct ata_port *ap) in ata_sff_port_init() argument
3260 INIT_DELAYED_WORK(&ap->sff_pio_task, ata_sff_pio_task); in ata_sff_port_init()
3261 ap->ctl = ATA_DEVCTL_OBS; in ata_sff_port_init()
3262 ap->last_ctl = 0xFF; in ata_sff_port_init()