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
83 static u8 ata_sff_altstatus(struct ata_port *ap) in ata_sff_altstatus() argument
85 if (ap->ops->sff_check_altstatus) in ata_sff_altstatus()
86 return ap->ops->sff_check_altstatus(ap); in ata_sff_altstatus()
88 return ioread8(ap->ioaddr.altstatus_addr); in ata_sff_altstatus()
93 * @ap: port where the device is
103 static u8 ata_sff_irq_status(struct ata_port *ap) in ata_sff_irq_status() argument
107 if (ap->ops->sff_check_altstatus || ap->ioaddr.altstatus_addr) { in ata_sff_irq_status()
108 status = ata_sff_altstatus(ap); in ata_sff_irq_status()
114 status = ap->ops->sff_check_status(ap); in ata_sff_irq_status()
120 * @ap: Port to wait for.
130 static void ata_sff_sync(struct ata_port *ap) in ata_sff_sync() argument
132 if (ap->ops->sff_check_altstatus) in ata_sff_sync()
133 ap->ops->sff_check_altstatus(ap); in ata_sff_sync()
134 else if (ap->ioaddr.altstatus_addr) in ata_sff_sync()
135 ioread8(ap->ioaddr.altstatus_addr); in ata_sff_sync()
140 * @ap: Port to pause for.
150 void ata_sff_pause(struct ata_port *ap) in ata_sff_pause() argument
152 ata_sff_sync(ap); in ata_sff_pause()
159 * @ap: Port to pause for.
165 void ata_sff_dma_pause(struct ata_port *ap) in ata_sff_dma_pause() argument
167 if (ap->ops->sff_check_altstatus || ap->ioaddr.altstatus_addr) { in ata_sff_dma_pause()
170 ata_sff_altstatus(ap); in ata_sff_dma_pause()
182 * @ap: port containing status register to be polled
195 int ata_sff_busy_sleep(struct ata_port *ap, in ata_sff_busy_sleep() argument
201 status = ata_sff_busy_wait(ap, ATA_BUSY, 300); in ata_sff_busy_sleep()
206 ata_msleep(ap, 50); in ata_sff_busy_sleep()
207 status = ata_sff_busy_wait(ap, ATA_BUSY, 3); in ata_sff_busy_sleep()
211 ata_port_warn(ap, in ata_sff_busy_sleep()
218 ata_msleep(ap, 50); in ata_sff_busy_sleep()
219 status = ap->ops->sff_check_status(ap); in ata_sff_busy_sleep()
226 ata_port_err(ap, in ata_sff_busy_sleep()
238 u8 status = link->ap->ops->sff_check_status(link->ap); in ata_sff_check_ready()
265 * @ap: port where the device is
276 static void ata_sff_set_devctl(struct ata_port *ap, u8 ctl) in ata_sff_set_devctl() argument
278 if (ap->ops->sff_set_devctl) in ata_sff_set_devctl()
279 ap->ops->sff_set_devctl(ap, ctl); in ata_sff_set_devctl()
281 iowrite8(ctl, ap->ioaddr.ctl_addr); in ata_sff_set_devctl()
286 * @ap: ATA channel to manipulate
298 void ata_sff_dev_select(struct ata_port *ap, unsigned int device) in ata_sff_dev_select() argument
307 iowrite8(tmp, ap->ioaddr.device_addr); in ata_sff_dev_select()
308 ata_sff_pause(ap); /* needed; also flushes, for mmio */ in ata_sff_dev_select()
314 * @ap: ATA channel to manipulate
330 static void ata_dev_select(struct ata_port *ap, unsigned int device, in ata_dev_select() argument
333 if (ata_msg_probe(ap)) in ata_dev_select()
334 ata_port_info(ap, "ata_dev_select: ENTER, device %u, wait %u\n", in ata_dev_select()
338 ata_wait_idle(ap); in ata_dev_select()
340 ap->ops->sff_dev_select(ap, device); in ata_dev_select()
343 if (can_sleep && ap->link.device[device].class == ATA_DEV_ATAPI) in ata_dev_select()
344 ata_msleep(ap, 150); in ata_dev_select()
345 ata_wait_idle(ap); in ata_dev_select()
351 * @ap: Port on which interrupts are enabled.
362 void ata_sff_irq_on(struct ata_port *ap) in ata_sff_irq_on() argument
364 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_irq_on()
366 if (ap->ops->sff_irq_on) { in ata_sff_irq_on()
367 ap->ops->sff_irq_on(ap); in ata_sff_irq_on()
371 ap->ctl &= ~ATA_NIEN; in ata_sff_irq_on()
372 ap->last_ctl = ap->ctl; in ata_sff_irq_on()
374 if (ap->ops->sff_set_devctl || ioaddr->ctl_addr) in ata_sff_irq_on()
375 ata_sff_set_devctl(ap, ap->ctl); in ata_sff_irq_on()
376 ata_wait_idle(ap); in ata_sff_irq_on()
378 if (ap->ops->sff_irq_clear) in ata_sff_irq_on()
379 ap->ops->sff_irq_clear(ap); in ata_sff_irq_on()
385 * @ap: Port to which output is sent
393 void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) in ata_sff_tf_load() argument
395 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_tf_load()
398 if (tf->ctl != ap->last_ctl) { in ata_sff_tf_load()
401 ap->last_ctl = tf->ctl; in ata_sff_tf_load()
402 ata_wait_idle(ap); in ata_sff_tf_load()
439 ata_wait_idle(ap); in ata_sff_tf_load()
445 * @ap: Port from which input is read
456 void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in ata_sff_tf_read() argument
458 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_tf_read()
460 tf->command = ata_sff_check_status(ap); in ata_sff_tf_read()
477 ap->last_ctl = tf->ctl; in ata_sff_tf_read()
486 * @ap: port to which command is being issued
495 void ata_sff_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) in ata_sff_exec_command() argument
497 DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command); in ata_sff_exec_command()
499 iowrite8(tf->command, ap->ioaddr.command_addr); in ata_sff_exec_command()
500 ata_sff_pause(ap); in ata_sff_exec_command()
506 * @ap: port to which command is being issued
516 static inline void ata_tf_to_host(struct ata_port *ap, in ata_tf_to_host() argument
519 ap->ops->sff_tf_load(ap, tf); in ata_tf_to_host()
520 ap->ops->sff_exec_command(ap, tf); in ata_tf_to_host()
541 struct ata_port *ap = qc->dev->link->ap; in ata_sff_data_xfer() local
542 void __iomem *data_addr = ap->ioaddr.data_addr; in ata_sff_data_xfer()
597 struct ata_port *ap = dev->link->ap; in ata_sff_data_xfer32() local
598 void __iomem *data_addr = ap->ioaddr.data_addr; in ata_sff_data_xfer32()
602 if (!(ap->pflags & ATA_PFLAG_PIO32)) in ata_sff_data_xfer32()
652 struct ata_port *ap = qc->ap; in ata_pio_sector() local
662 ap->hsm_task_state = HSM_ST_LAST; in ata_pio_sector()
675 ap->ops->sff_data_xfer(qc, buf + offset, qc->sect_size, do_write); in ata_pio_sector()
687 ap->hsm_task_state = HSM_ST_LAST; in ata_pio_sector()
717 ata_sff_sync(qc->ap); /* flush */ in ata_pio_sectors()
722 * @ap: Port to which ATAPI device is attached.
731 static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) in atapi_send_cdb() argument
737 ap->ops->sff_data_xfer(qc, qc->cdb, qc->dev->cdb_len, 1); in atapi_send_cdb()
738 ata_sff_sync(ap); in atapi_send_cdb()
743 ap->hsm_task_state = HSM_ST; in atapi_send_cdb()
746 ap->hsm_task_state = HSM_ST_LAST; in atapi_send_cdb()
750 ap->hsm_task_state = HSM_ST_LAST; in atapi_send_cdb()
752 ap->ops->bmdma_start(qc); in atapi_send_cdb()
774 struct ata_port *ap = qc->ap; in __atapi_pio_bytes() local
808 consumed = ap->ops->sff_data_xfer(qc, buf + offset, count, rw); in __atapi_pio_bytes()
842 struct ata_port *ap = qc->ap; in atapi_pio_bytes() local
854 ap->ops->sff_tf_read(ap, &qc->result_tf); in atapi_pio_bytes()
872 VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); in atapi_pio_bytes()
876 ata_sff_sync(ap); /* flush */ in atapi_pio_bytes()
885 ap->hsm_task_state = HSM_ST_ERR; in atapi_pio_bytes()
890 * @ap: the target ata_port
896 static inline int ata_hsm_ok_in_wq(struct ata_port *ap, in ata_hsm_ok_in_wq() argument
902 if (ap->hsm_task_state == HSM_ST_FIRST) { in ata_hsm_ok_in_wq()
928 struct ata_port *ap = qc->ap; in ata_hsm_qc_complete() local
930 if (ap->ops->error_handler) { in ata_hsm_qc_complete()
935 qc = ata_qc_from_tag(ap, qc->tag); in ata_hsm_qc_complete()
938 ata_sff_irq_on(ap); in ata_hsm_qc_complete()
941 ata_port_freeze(ap); in ata_hsm_qc_complete()
947 ata_port_freeze(ap); in ata_hsm_qc_complete()
951 ata_sff_irq_on(ap); in ata_hsm_qc_complete()
960 * @ap: the target ata_port
968 int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, in ata_sff_hsm_move() argument
975 lockdep_assert_held(ap->lock); in ata_sff_hsm_move()
983 WARN_ON_ONCE(in_wq != ata_hsm_ok_in_wq(ap, qc)); in ata_sff_hsm_move()
987 ap->print_id, qc->tf.protocol, ap->hsm_task_state, status); in ata_sff_hsm_move()
989 switch (ap->hsm_task_state) { in ata_sff_hsm_move()
1012 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1033 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1047 ap->hsm_task_state = HSM_ST; in ata_sff_hsm_move()
1051 atapi_send_cdb(ap, qc); in ata_sff_hsm_move()
1066 ap->hsm_task_state = HSM_ST_LAST; in ata_sff_hsm_move()
1081 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1087 if (unlikely(ap->hsm_task_state == HSM_ST_ERR)) in ata_sff_hsm_move()
1119 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1139 status = ata_wait_idle(ap); in ata_sff_hsm_move()
1163 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1169 if (ap->hsm_task_state == HSM_ST_LAST && in ata_sff_hsm_move()
1172 status = ata_wait_idle(ap); in ata_sff_hsm_move()
1183 ap->hsm_task_state = HSM_ST_ERR; in ata_sff_hsm_move()
1189 ap->print_id, qc->dev->devno, status); in ata_sff_hsm_move()
1193 ap->hsm_task_state = HSM_ST_IDLE; in ata_sff_hsm_move()
1202 ap->hsm_task_state = HSM_ST_IDLE; in ata_sff_hsm_move()
1212 ap->print_id, ap->hsm_task_state); in ata_sff_hsm_move()
1233 struct ata_port *ap = link->ap; in ata_sff_queue_pio_task() local
1235 WARN_ON((ap->sff_pio_task_link != NULL) && in ata_sff_queue_pio_task()
1236 (ap->sff_pio_task_link != link)); in ata_sff_queue_pio_task()
1237 ap->sff_pio_task_link = link; in ata_sff_queue_pio_task()
1240 ata_sff_queue_delayed_work(&ap->sff_pio_task, msecs_to_jiffies(delay)); in ata_sff_queue_pio_task()
1244 void ata_sff_flush_pio_task(struct ata_port *ap) in ata_sff_flush_pio_task() argument
1248 cancel_delayed_work_sync(&ap->sff_pio_task); in ata_sff_flush_pio_task()
1258 spin_lock_irq(ap->lock); in ata_sff_flush_pio_task()
1259 ap->hsm_task_state = HSM_ST_IDLE; in ata_sff_flush_pio_task()
1260 spin_unlock_irq(ap->lock); in ata_sff_flush_pio_task()
1262 ap->sff_pio_task_link = NULL; in ata_sff_flush_pio_task()
1264 if (ata_msg_ctl(ap)) in ata_sff_flush_pio_task()
1265 ata_port_dbg(ap, "%s: EXIT\n", __func__); in ata_sff_flush_pio_task()
1270 struct ata_port *ap = in ata_sff_pio_task() local
1272 struct ata_link *link = ap->sff_pio_task_link; in ata_sff_pio_task()
1277 spin_lock_irq(ap->lock); in ata_sff_pio_task()
1279 BUG_ON(ap->sff_pio_task_link == NULL); in ata_sff_pio_task()
1281 qc = ata_qc_from_tag(ap, link->active_tag); in ata_sff_pio_task()
1283 ap->sff_pio_task_link = NULL; in ata_sff_pio_task()
1288 WARN_ON_ONCE(ap->hsm_task_state == HSM_ST_IDLE); in ata_sff_pio_task()
1297 status = ata_sff_busy_wait(ap, ATA_BUSY, 5); in ata_sff_pio_task()
1299 spin_unlock_irq(ap->lock); in ata_sff_pio_task()
1300 ata_msleep(ap, 2); in ata_sff_pio_task()
1301 spin_lock_irq(ap->lock); in ata_sff_pio_task()
1303 status = ata_sff_busy_wait(ap, ATA_BUSY, 10); in ata_sff_pio_task()
1314 ap->sff_pio_task_link = NULL; in ata_sff_pio_task()
1316 poll_next = ata_sff_hsm_move(ap, qc, status, 1); in ata_sff_pio_task()
1324 spin_unlock_irq(ap->lock); in ata_sff_pio_task()
1342 struct ata_port *ap = qc->ap; in ata_sff_qc_issue() local
1348 if (ap->flags & ATA_FLAG_PIO_POLLING) in ata_sff_qc_issue()
1352 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_sff_qc_issue()
1360 ata_tf_to_host(ap, &qc->tf); in ata_sff_qc_issue()
1361 ap->hsm_task_state = HSM_ST_LAST; in ata_sff_qc_issue()
1372 ata_tf_to_host(ap, &qc->tf); in ata_sff_qc_issue()
1376 ap->hsm_task_state = HSM_ST_FIRST; in ata_sff_qc_issue()
1384 ap->hsm_task_state = HSM_ST; in ata_sff_qc_issue()
1402 ata_tf_to_host(ap, &qc->tf); in ata_sff_qc_issue()
1404 ap->hsm_task_state = HSM_ST_FIRST; in ata_sff_qc_issue()
1435 qc->ap->ops->sff_tf_read(qc->ap, &qc->result_tf); in ata_sff_qc_fill_rtf()
1440 static unsigned int ata_sff_idle_irq(struct ata_port *ap) in ata_sff_idle_irq() argument
1442 ap->stats.idle_irq++; in ata_sff_idle_irq()
1445 if ((ap->stats.idle_irq % 1000) == 0) { in ata_sff_idle_irq()
1446 ap->ops->sff_check_status(ap); in ata_sff_idle_irq()
1447 if (ap->ops->sff_irq_clear) in ata_sff_idle_irq()
1448 ap->ops->sff_irq_clear(ap); in ata_sff_idle_irq()
1449 ata_port_warn(ap, "irq trap\n"); in ata_sff_idle_irq()
1456 static unsigned int __ata_sff_port_intr(struct ata_port *ap, in __ata_sff_port_intr() argument
1463 ap->print_id, qc->tf.protocol, ap->hsm_task_state); in __ata_sff_port_intr()
1466 switch (ap->hsm_task_state) { in __ata_sff_port_intr()
1477 return ata_sff_idle_irq(ap); in __ata_sff_port_intr()
1480 return ata_sff_idle_irq(ap); in __ata_sff_port_intr()
1486 status = ata_sff_irq_status(ap); in __ata_sff_port_intr()
1491 ap->hsm_task_state = HSM_ST_ERR; in __ata_sff_port_intr()
1493 return ata_sff_idle_irq(ap); in __ata_sff_port_intr()
1497 if (ap->ops->sff_irq_clear) in __ata_sff_port_intr()
1498 ap->ops->sff_irq_clear(ap); in __ata_sff_port_intr()
1500 ata_sff_hsm_move(ap, qc, status, 0); in __ata_sff_port_intr()
1507 * @ap: Port on which interrupt arrived (possibly...)
1518 unsigned int ata_sff_port_intr(struct ata_port *ap, struct ata_queued_cmd *qc) in ata_sff_port_intr() argument
1520 return __ata_sff_port_intr(ap, qc, false); in ata_sff_port_intr()
1539 struct ata_port *ap = host->ports[i]; in __ata_sff_interrupt() local
1542 qc = ata_qc_from_tag(ap, ap->link.active_tag); in __ata_sff_interrupt()
1545 handled |= port_intr(ap, qc); in __ata_sff_interrupt()
1561 struct ata_port *ap = host->ports[i]; in __ata_sff_interrupt() local
1566 if (!ap->ops->sff_irq_check || in __ata_sff_interrupt()
1567 !ap->ops->sff_irq_check(ap)) in __ata_sff_interrupt()
1571 ap->ops->sff_check_status(ap); in __ata_sff_interrupt()
1572 if (ap->ops->sff_irq_clear) in __ata_sff_interrupt()
1573 ap->ops->sff_irq_clear(ap); in __ata_sff_interrupt()
1576 if (!(ap->ops->sff_check_status(ap) & ATA_BUSY)) in __ata_sff_interrupt()
1618 * @ap: port that appears to have timed out
1629 void ata_sff_lost_interrupt(struct ata_port *ap) in ata_sff_lost_interrupt() argument
1635 qc = ata_qc_from_tag(ap, ap->link.active_tag); in ata_sff_lost_interrupt()
1641 status = ata_sff_altstatus(ap); in ata_sff_lost_interrupt()
1647 ata_port_warn(ap, "lost interrupt (Status 0x%x)\n", in ata_sff_lost_interrupt()
1651 ata_sff_port_intr(ap, qc); in ata_sff_lost_interrupt()
1657 * @ap: port to freeze
1664 void ata_sff_freeze(struct ata_port *ap) in ata_sff_freeze() argument
1666 ap->ctl |= ATA_NIEN; in ata_sff_freeze()
1667 ap->last_ctl = ap->ctl; in ata_sff_freeze()
1669 if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) in ata_sff_freeze()
1670 ata_sff_set_devctl(ap, ap->ctl); in ata_sff_freeze()
1676 ap->ops->sff_check_status(ap); in ata_sff_freeze()
1678 if (ap->ops->sff_irq_clear) in ata_sff_freeze()
1679 ap->ops->sff_irq_clear(ap); in ata_sff_freeze()
1685 * @ap: port to thaw
1692 void ata_sff_thaw(struct ata_port *ap) in ata_sff_thaw() argument
1695 ap->ops->sff_check_status(ap); in ata_sff_thaw()
1696 if (ap->ops->sff_irq_clear) in ata_sff_thaw()
1697 ap->ops->sff_irq_clear(ap); in ata_sff_thaw()
1698 ata_sff_irq_on(ap); in ata_sff_thaw()
1747 * @ap: ATA channel to examine
1762 static unsigned int ata_devchk(struct ata_port *ap, unsigned int device) in ata_devchk() argument
1764 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_devchk()
1767 ap->ops->sff_dev_select(ap, device); in ata_devchk()
1811 struct ata_port *ap = dev->link->ap; in ata_sff_dev_classify() local
1816 ap->ops->sff_dev_select(ap, dev->devno); in ata_sff_dev_classify()
1820 ap->ops->sff_tf_read(ap, &tf); in ata_sff_dev_classify()
1851 (ap->ops->sff_check_status(ap) == 0)) in ata_sff_dev_classify()
1878 struct ata_port *ap = link->ap; in ata_sff_wait_after_reset() local
1879 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_sff_wait_after_reset()
1884 ata_msleep(ap, ATA_WAIT_AFTER_RESET); in ata_sff_wait_after_reset()
1900 ap->ops->sff_dev_select(ap, 1); in ata_sff_wait_after_reset()
1913 ata_msleep(ap, 50); /* give drive a breather */ in ata_sff_wait_after_reset()
1925 ap->ops->sff_dev_select(ap, 0); in ata_sff_wait_after_reset()
1927 ap->ops->sff_dev_select(ap, 1); in ata_sff_wait_after_reset()
1929 ap->ops->sff_dev_select(ap, 0); in ata_sff_wait_after_reset()
1935 static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, in ata_bus_softreset() argument
1938 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_bus_softreset()
1940 DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); in ata_bus_softreset()
1942 if (ap->ioaddr.ctl_addr) { in ata_bus_softreset()
1944 iowrite8(ap->ctl, ioaddr->ctl_addr); in ata_bus_softreset()
1946 iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr); in ata_bus_softreset()
1948 iowrite8(ap->ctl, ioaddr->ctl_addr); in ata_bus_softreset()
1949 ap->last_ctl = ap->ctl; in ata_bus_softreset()
1953 return ata_sff_wait_after_reset(&ap->link, devmask, deadline); in ata_bus_softreset()
1973 struct ata_port *ap = link->ap; in ata_sff_softreset() local
1974 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; in ata_sff_softreset()
1982 if (ata_devchk(ap, 0)) in ata_sff_softreset()
1984 if (slave_possible && ata_devchk(ap, 1)) in ata_sff_softreset()
1988 ap->ops->sff_dev_select(ap, 0); in ata_sff_softreset()
1992 rc = ata_bus_softreset(ap, devmask, deadline); in ata_sff_softreset()
2058 struct ata_port *ap = link->ap; in ata_sff_postreset() local
2064 ap->ops->sff_dev_select(ap, 1); in ata_sff_postreset()
2066 ap->ops->sff_dev_select(ap, 0); in ata_sff_postreset()
2075 if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) { in ata_sff_postreset()
2076 ata_sff_set_devctl(ap, ap->ctl); in ata_sff_postreset()
2077 ap->last_ctl = ap->ctl; in ata_sff_postreset()
2095 struct ata_port *ap; in ata_sff_drain_fifo() local
2101 ap = qc->ap; in ata_sff_drain_fifo()
2103 for (count = 0; (ap->ops->sff_check_status(ap) & ATA_DRQ) in ata_sff_drain_fifo()
2105 ioread16(ap->ioaddr.data_addr); in ata_sff_drain_fifo()
2109 ata_port_dbg(ap, "drained %d bytes to clear DRQ\n", count); in ata_sff_drain_fifo()
2116 * @ap: port to handle error for
2126 void ata_sff_error_handler(struct ata_port *ap) in ata_sff_error_handler() argument
2128 ata_reset_fn_t softreset = ap->ops->softreset; in ata_sff_error_handler()
2129 ata_reset_fn_t hardreset = ap->ops->hardreset; in ata_sff_error_handler()
2133 qc = __ata_qc_from_tag(ap, ap->link.active_tag); in ata_sff_error_handler()
2137 spin_lock_irqsave(ap->lock, flags); in ata_sff_error_handler()
2146 if (ap->ops->sff_drain_fifo) in ata_sff_error_handler()
2147 ap->ops->sff_drain_fifo(qc); in ata_sff_error_handler()
2149 spin_unlock_irqrestore(ap->lock, flags); in ata_sff_error_handler()
2153 hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link)) in ata_sff_error_handler()
2156 ata_do_eh(ap, ap->ops->prereset, softreset, hardreset, in ata_sff_error_handler()
2157 ap->ops->postreset); in ata_sff_error_handler()
2231 struct ata_port *ap = host->ports[i]; in ata_pci_sff_init_host() local
2235 if (ata_port_is_dummy(ap)) in ata_pci_sff_init_host()
2243 ap->ops = &ata_dummy_port_ops; in ata_pci_sff_init_host()
2255 ap->ops = &ata_dummy_port_ops; in ata_pci_sff_init_host()
2260 ap->ioaddr.cmd_addr = iomap[base]; in ata_pci_sff_init_host()
2261 ap->ioaddr.altstatus_addr = in ata_pci_sff_init_host()
2262 ap->ioaddr.ctl_addr = (void __iomem *) in ata_pci_sff_init_host()
2264 ata_sff_std_ports(&ap->ioaddr); in ata_pci_sff_init_host()
2266 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx", in ata_pci_sff_init_host()
2573 struct ata_port *ap = qc->ap; in ata_bmdma_fill_sg() local
2574 struct ata_bmdma_prd *prd = ap->bmdma_prd; in ata_bmdma_fill_sg()
2624 struct ata_port *ap = qc->ap; in ata_bmdma_fill_sg_dumb() local
2625 struct ata_bmdma_prd *prd = ap->bmdma_prd; in ata_bmdma_fill_sg_dumb()
2725 struct ata_port *ap = qc->ap; in ata_bmdma_qc_issue() local
2733 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_bmdma_qc_issue()
2740 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in ata_bmdma_qc_issue()
2741 ap->ops->bmdma_setup(qc); /* set up bmdma */ in ata_bmdma_qc_issue()
2742 ap->ops->bmdma_start(qc); /* initiate bmdma */ in ata_bmdma_qc_issue()
2743 ap->hsm_task_state = HSM_ST_LAST; in ata_bmdma_qc_issue()
2749 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in ata_bmdma_qc_issue()
2750 ap->ops->bmdma_setup(qc); /* set up bmdma */ in ata_bmdma_qc_issue()
2751 ap->hsm_task_state = HSM_ST_FIRST; in ata_bmdma_qc_issue()
2769 * @ap: Port on which interrupt arrived (possibly...)
2780 unsigned int ata_bmdma_port_intr(struct ata_port *ap, struct ata_queued_cmd *qc) in ata_bmdma_port_intr() argument
2782 struct ata_eh_info *ehi = &ap->link.eh_info; in ata_bmdma_port_intr()
2787 if (ap->hsm_task_state == HSM_ST_LAST && ata_is_dma(qc->tf.protocol)) { in ata_bmdma_port_intr()
2789 host_stat = ap->ops->bmdma_status(ap); in ata_bmdma_port_intr()
2790 VPRINTK("ata%u: host_stat 0x%X\n", ap->print_id, host_stat); in ata_bmdma_port_intr()
2794 return ata_sff_idle_irq(ap); 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()
2876 ap->ops->bmdma_stop(qc); in ata_bmdma_error_handler()
2880 ap->ops->sff_check_status(ap); in ata_bmdma_error_handler()
2881 if (ap->ops->sff_irq_clear) in ata_bmdma_error_handler()
2882 ap->ops->sff_irq_clear(ap); in ata_bmdma_error_handler()
2886 spin_unlock_irqrestore(ap->lock, flags); in ata_bmdma_error_handler()
2889 ata_eh_thaw_port(ap); in ata_bmdma_error_handler()
2891 ata_sff_error_handler(ap); in ata_bmdma_error_handler()
2904 struct ata_port *ap = qc->ap; in ata_bmdma_post_internal_cmd() local
2908 spin_lock_irqsave(ap->lock, flags); in ata_bmdma_post_internal_cmd()
2909 ap->ops->bmdma_stop(qc); in ata_bmdma_post_internal_cmd()
2910 spin_unlock_irqrestore(ap->lock, flags); in ata_bmdma_post_internal_cmd()
2917 * @ap: Port associated with this ATA transaction.
2926 void ata_bmdma_irq_clear(struct ata_port *ap) in ata_bmdma_irq_clear() argument
2928 void __iomem *mmio = ap->ioaddr.bmdma_addr; in ata_bmdma_irq_clear()
2946 struct ata_port *ap = qc->ap; in ata_bmdma_setup() local
2952 iowrite32(ap->bmdma_prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS); in ata_bmdma_setup()
2955 dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_setup()
2959 iowrite8(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_setup()
2962 ap->ops->sff_exec_command(ap, &qc->tf); in ata_bmdma_setup()
2975 struct ata_port *ap = qc->ap; in ata_bmdma_start() local
2979 dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_start()
2980 iowrite8(dmactl | ATA_DMA_START, ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in ata_bmdma_start()
3012 struct ata_port *ap = qc->ap; in ata_bmdma_stop() local
3013 void __iomem *mmio = ap->ioaddr.bmdma_addr; in ata_bmdma_stop()
3020 ata_sff_dma_pause(ap); in ata_bmdma_stop()
3026 * @ap: Port associated with this ATA transaction.
3035 u8 ata_bmdma_status(struct ata_port *ap) in ata_bmdma_status() argument
3037 return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); in ata_bmdma_status()
3044 * @ap: Port to initialize
3054 int ata_bmdma_port_start(struct ata_port *ap) in ata_bmdma_port_start() argument
3056 if (ap->mwdma_mask || ap->udma_mask) { in ata_bmdma_port_start()
3057 ap->bmdma_prd = in ata_bmdma_port_start()
3058 dmam_alloc_coherent(ap->host->dev, ATA_PRD_TBL_SZ, in ata_bmdma_port_start()
3059 &ap->bmdma_prd_dma, GFP_KERNEL); in ata_bmdma_port_start()
3060 if (!ap->bmdma_prd) in ata_bmdma_port_start()
3070 * @ap: Port to initialize
3082 int ata_bmdma_port_start32(struct ata_port *ap) in ata_bmdma_port_start32() argument
3084 ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; in ata_bmdma_port_start32()
3085 return ata_bmdma_port_start(ap); in ata_bmdma_port_start32()
3169 struct ata_port *ap = host->ports[i]; in ata_pci_bmdma_init() local
3172 if (ata_port_is_dummy(ap)) in ata_pci_bmdma_init()
3175 ap->ioaddr.bmdma_addr = bmdma; in ata_pci_bmdma_init()
3176 if ((!(ap->flags & ATA_FLAG_IGN_SIMPLEX)) && in ata_pci_bmdma_init()
3180 ata_port_desc(ap, "bmdma 0x%llx", in ata_pci_bmdma_init()
3247 * @ap: Port to initialize
3255 void ata_sff_port_init(struct ata_port *ap) in ata_sff_port_init() argument
3257 INIT_DELAYED_WORK(&ap->sff_pio_task, ata_sff_pio_task); in ata_sff_port_init()
3258 ap->ctl = ATA_DEVCTL_OBS; in ata_sff_port_init()
3259 ap->last_ctl = 0xFF; in ata_sff_port_init()