Lines Matching full:ap

164 #define HSDEVP_FROM_AP(ap)	(struct sata_dwc_device_port*)	\  argument
165 (ap)->private_data
209 static struct ata_port ap; variable
210 static struct ata_port *pap = ≈
225 static u8 ata_irq_on(struct ata_port *ap);
226 static struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
228 static int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
230 static void ata_tf_to_host(struct ata_port *ap,
232 static void ata_exec_command(struct ata_port *ap,
235 static u8 ata_check_altstatus(struct ata_port *ap);
236 static u8 ata_check_status(struct ata_port *ap);
237 static void ata_dev_select(struct ata_port *ap, unsigned int device,
240 static void ata_tf_load(struct ata_port *ap,
246 static void ata_std_dev_select(struct ata_port *ap, unsigned int device);
250 static void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
255 static void __ata_port_freeze(struct ata_port *ap);
256 static int ata_port_freeze(struct ata_port *ap);
260 static void ata_pio_queue_task(struct ata_port *ap,
263 static int sata_dwc_softreset(struct ata_port *ap);
303 ap.pflags |= ATA_PFLAG_INITIALIZING; in init_sata()
304 ap.flags = ATA_FLAG_DISABLED; in init_sata()
305 ap.print_id = -1; in init_sata()
306 ap.ctl = ATA_DEVCTL_OBS; in init_sata()
307 ap.host = &host; in init_sata()
308 ap.last_ctl = 0xFF; in init_sata()
310 link = &ap.link; in init_sata()
311 link->ap = ≈ in init_sata()
316 ap.port_no = i; in init_sata()
317 host.ports[i] = ≈ in init_sata()
320 ap.pio_mask = pi.pio_mask; in init_sata()
321 ap.mwdma_mask = pi.mwdma_mask; in init_sata()
322 ap.udma_mask = pi.udma_mask; in init_sata()
323 ap.flags |= pi.flags; in init_sata()
324 ap.link.flags |= pi.link_flags; in init_sata()
354 status = ata_check_altstatus(&ap); in init_sata()
368 status = ata_check_altstatus(&ap); in init_sata()
387 rc = sata_dwc_softreset(&ap); in init_sata()
413 hsdev.host = ap.host; in init_sata()
432 static u8 ata_check_altstatus(struct ata_port *ap) in ata_check_altstatus() argument
435 val = readb(ap->ioaddr.altstatus_addr); in ata_check_altstatus()
439 static int sata_dwc_softreset(struct ata_port *ap) in sata_dwc_softreset() argument
443 struct ata_ioports *ioaddr = &ap->ioaddr; in sata_dwc_softreset()
445 in_le32((void *)ap->ioaddr.scr_addr + (SCR_ERROR * 4)); in sata_dwc_softreset()
467 writeb(ap->ctl, ioaddr->ctl_addr); in sata_dwc_softreset()
471 writeb(ap->ctl | ATA_SRST, ioaddr->ctl_addr); in sata_dwc_softreset()
474 writeb(ap->ctl, ioaddr->ctl_addr); in sata_dwc_softreset()
477 ata_check_status(ap); in sata_dwc_softreset()
480 ata_check_status(ap); in sata_dwc_softreset()
483 u8 status = ata_check_status(ap); in sata_dwc_softreset()
501 static u8 ata_check_status(struct ata_port *ap) in ata_check_status() argument
504 val = readb(ap->ioaddr.status_addr); in ata_check_status()
549 status = ata_check_altstatus(&ap); in scan_sata()
580 ap.cbl = ATA_CBL_SATA; in scan_sata()
659 if (ap.flags & ATA_FLAG_NCQ) in scan_sata()
675 if ((ap.cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ata_dev->id))) { in scan_sata()
712 static u8 ata_busy_wait(struct ata_port *ap, in ata_busy_wait() argument
719 status = ata_check_status(ap); in ata_busy_wait()
729 struct ata_port *ap = pap; in ata_dev_read_id() local
738 status = ata_busy_wait(ap, ATA_BUSY, 30000); in ata_dev_read_id()
745 ata_dev_select(ap, dev->devno, 1, 1); in ata_dev_read_id()
749 ap->print_id = 1; in ata_dev_read_id()
750 ap->flags &= ~ATA_FLAG_DISABLED; in ata_dev_read_id()
751 tf.ctl = ap->ctl; in ata_dev_read_id()
883 static u8 ata_wait_idle(struct ata_port *ap) in ata_wait_idle() argument
885 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); in ata_wait_idle()
889 static void ata_dev_select(struct ata_port *ap, unsigned int device, in ata_dev_select() argument
893 ata_wait_idle(ap); in ata_dev_select()
895 ata_std_dev_select(ap, device); in ata_dev_select()
898 ata_wait_idle(ap); in ata_dev_select()
901 static void ata_std_dev_select(struct ata_port *ap, unsigned int device) in ata_std_dev_select() argument
911 writeb(tmp, ap->ioaddr.device_addr); in ata_std_dev_select()
913 readb(ap->ioaddr.altstatus_addr); in ata_std_dev_select()
953 struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap, in __ata_qc_from_tag() argument
957 return &ap->qcmd[tag]; in __ata_qc_from_tag()
961 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
964 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
967 static int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
969 __ata_port_freeze(ap); in ata_port_freeze()
979 struct ata_port *ap = pap; in ata_exec_internal() local
988 status = ata_busy_wait(ap, ATA_BUSY, 300000); in ata_exec_internal()
995 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_exec_internal()
1000 if (test_and_set_bit(tag, &ap->qc_allocated)) { in ata_exec_internal()
1005 qc = __ata_qc_from_tag(ap, tag); in ata_exec_internal()
1007 qc->ap = ap; in ata_exec_internal()
1014 preempted_qc_active = ap->qc_active; in ata_exec_internal()
1015 preempted_nr_active_links = ap->nr_active_links; in ata_exec_internal()
1018 ap->qc_active = 0; in ata_exec_internal()
1019 ap->nr_active_links = 0; in ata_exec_internal()
1033 status = ata_busy_wait(ap, ATA_BUSY, 30000); in ata_exec_internal()
1041 if (waiting_for_reg_state(ap->ioaddr.altstatus_addr, 1000, 0x8)) { in ata_exec_internal()
1045 status = readb(ap->ioaddr.altstatus_addr); in ata_exec_internal()
1047 errorStatus = readb(ap->ioaddr.feature_addr); in ata_exec_internal()
1060 status = ata_busy_wait(ap, ATA_BUSY, 10); in ata_exec_internal()
1067 ata_pio_task(ap); in ata_exec_internal()
1072 ata_port_freeze(ap); in ata_exec_internal()
1092 ap->qc_active = preempted_qc_active; in ata_exec_internal()
1093 ap->nr_active_links = preempted_nr_active_links; in ata_exec_internal()
1095 if (ap->flags & ATA_FLAG_DISABLED) { in ata_exec_internal()
1097 ap->flags &= ~ATA_FLAG_DISABLED; in ata_exec_internal()
1105 struct ata_port *ap = qc->ap; in ata_qc_issue() local
1111 ap->nr_active_links++; in ata_qc_issue()
1114 ap->nr_active_links++; in ata_qc_issue()
1119 ap->qc_active |= 1 << qc->tag; in ata_qc_issue()
1137 struct ata_port *ap = qc->ap; in ata_qc_issue_prot() local
1139 if (ap->flags & ATA_FLAG_PIO_POLLING) { in ata_qc_issue_prot()
1152 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_qc_issue_prot()
1159 ata_tf_to_host(ap, &qc->tf); in ata_qc_issue_prot()
1161 ap->hsm_task_state = HSM_ST; in ata_qc_issue_prot()
1164 ata_pio_queue_task(ap, qc, 0); in ata_qc_issue_prot()
1175 static void ata_tf_to_host(struct ata_port *ap, in ata_tf_to_host() argument
1178 ata_tf_load(ap, tf); in ata_tf_to_host()
1179 ata_exec_command(ap, tf); in ata_tf_to_host()
1182 static void ata_tf_load(struct ata_port *ap, in ata_tf_load() argument
1185 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_tf_load()
1188 if (tf->ctl != ap->last_ctl) { in ata_tf_load()
1191 ap->last_ctl = tf->ctl; in ata_tf_load()
1192 ata_wait_idle(ap); in ata_tf_load()
1214 ata_wait_idle(ap); in ata_tf_load()
1217 static void ata_exec_command(struct ata_port *ap, in ata_exec_command() argument
1220 writeb(tf->command, ap->ioaddr.command_addr); in ata_exec_command()
1222 readb(ap->ioaddr.altstatus_addr); in ata_exec_command()
1227 static void ata_pio_queue_task(struct ata_port *ap, in ata_pio_queue_task() argument
1230 ap->port_task_data = data; in ata_pio_queue_task()
1252 struct ata_port *ap = arg_ap; in ata_pio_task() local
1253 struct ata_queued_cmd *qc = ap->port_task_data; in ata_pio_task()
1265 status = ata_busy_wait(ap, ATA_BUSY, 5); in ata_pio_task()
1268 status = ata_busy_wait(ap, ATA_BUSY, 10); in ata_pio_task()
1270 ata_pio_queue_task(ap, qc, ATA_SHORT_PAUSE); in ata_pio_task()
1275 poll_next = ata_hsm_move(ap, qc, status, 1); in ata_pio_task()
1284 static int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, in ata_hsm_move() argument
1290 switch (ap->hsm_task_state) { in ata_hsm_move()
1300 ap->hsm_task_state = HSM_ST_ERR; in ata_hsm_move()
1315 ap->hsm_task_state = HSM_ST_ERR; in ata_hsm_move()
1328 ap->hsm_task_state = HSM_ST; in ata_hsm_move()
1347 ap->hsm_task_state = HSM_ST_ERR; in ata_hsm_move()
1365 status = ata_wait_idle(ap); in ata_hsm_move()
1375 ap->hsm_task_state = HSM_ST_ERR; in ata_hsm_move()
1380 if (ap->hsm_task_state == HSM_ST_LAST && in ata_hsm_move()
1382 status = ata_wait_idle(ap); in ata_hsm_move()
1392 ap->hsm_task_state = HSM_ST_ERR; in ata_hsm_move()
1396 ap->hsm_task_state = HSM_ST_IDLE; in ata_hsm_move()
1407 ap->hsm_task_state = HSM_ST_IDLE; in ata_hsm_move()
1422 struct ata_port *ap; in ata_pio_sectors() local
1423 ap = pap; in ata_pio_sectors()
1424 qc->pdata = ap->pdata; in ata_pio_sectors()
1428 readb(qc->ap->ioaddr.altstatus_addr); in ata_pio_sectors()
1435 struct ata_port *ap = qc->ap; in ata_pio_sector() local
1441 ap->hsm_task_state = HSM_ST_LAST; in ata_pio_sector()
1468 struct ata_port *ap = pap; in ata_mmio_data_xfer() local
1469 void __iomem *data_addr = ap->ioaddr.data_addr; in ata_mmio_data_xfer()
1499 struct ata_port *ap = qc->ap; in ata_hsm_qc_complete() local
1505 qc = &ap->qcmd[qc->tag]; in ata_hsm_qc_complete()
1508 ata_irq_on(ap); in ata_hsm_qc_complete()
1511 ata_port_freeze(ap); in ata_hsm_qc_complete()
1518 ata_port_freeze(ap); in ata_hsm_qc_complete()
1523 static u8 ata_irq_on(struct ata_port *ap) in ata_irq_on() argument
1525 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_irq_on()
1528 ap->ctl &= ~ATA_NIEN; in ata_irq_on()
1529 ap->last_ctl = ap->ctl; in ata_irq_on()
1532 writeb(ap->ctl, ioaddr->ctl_addr); in ata_irq_on()
1534 tmp = ata_wait_idle(ap); in ata_irq_on()
1581 struct ata_port *ap = qc->ap; in fill_result_tf() local
1584 ata_tf_read(ap, &qc->result_tf); in fill_result_tf()
1587 static void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in ata_tf_read() argument
1589 struct ata_ioports *ioaddr = &ap->ioaddr; in ata_tf_read()
1591 tf->command = ata_check_status(ap); in ata_tf_read()
1610 ap->last_ctl = tf->ctl; in ata_tf_read()
1619 struct ata_port *ap = qc->ap; in __ata_qc_complete() local
1623 ap->nr_active_links--; in __ata_qc_complete()
1625 if (qc->flags & ATA_QCFLAG_CLEAR_EXCL && ap->excl_link == link) in __ata_qc_complete()
1626 ap->excl_link = NULL; in __ata_qc_complete()
1629 ap->qc_active &= ~(1 << qc->tag); in __ata_qc_complete()
1634 struct ata_port *ap = qc->ap; in ata_qc_free() local
1640 clear_bit(tag, &ap->qc_allocated); in ata_qc_free()
1683 struct ata_port *ap; in ata_dev_set_feature() local
1684 ap = pap; in ata_dev_set_feature()
1688 tf.ctl = ap->ctl; in ata_dev_set_feature()
1706 struct ata_port *ap; in ata_dev_init_params() local
1707 ap = pap; in ata_dev_init_params()
1714 tf.ctl = ap->ctl; in ata_dev_init_params()
1790 struct ata_port *ap = pap; in ata_dev_read_sectors() local
1801 ata_dev_select(ap, dev->devno, 1, 1); in ata_dev_read_sectors()
1805 tf.ctl = ap->ctl; in ata_dev_read_sectors()
1806 ap->print_id = 1; in ata_dev_read_sectors()
1807 ap->flags &= ~ATA_FLAG_DISABLED; in ata_dev_read_sectors()
1809 ap->pdata = pdata; in ata_dev_read_sectors()
1964 struct ata_port *ap = pap; in ata_dev_write_sectors() local
1975 ata_dev_select(ap, dev->devno, 1, 1); in ata_dev_write_sectors()
1979 tf.ctl = ap->ctl; in ata_dev_write_sectors()
1980 ap->print_id = 1; in ata_dev_write_sectors()
1981 ap->flags &= ~ATA_FLAG_DISABLED; in ata_dev_write_sectors()
1983 ap->pdata = pdata; in ata_dev_write_sectors()