Lines Matching refs:ap
289 static void bfin_set_piomode(struct ata_port *ap, struct ata_device *adev) in bfin_set_piomode() argument
292 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_set_piomode()
304 dev_dbg(adev->link->ap->dev, "set piomode: mode=%d, fsclk=%ud\n", mode, fsclk); in bfin_set_piomode()
368 static void bfin_set_dmamode(struct ata_port *ap, struct ata_device *adev) in bfin_set_dmamode() argument
371 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_set_dmamode()
380 dev_dbg(adev->link->ap->dev, "set udmamode: mode=%d\n", mode); in bfin_set_dmamode()
429 dev_dbg(adev->link->ap->dev, "set mdmamode: mode=%d\n", mode); in bfin_set_dmamode()
669 static void bfin_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) in bfin_tf_load() argument
671 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_tf_load()
674 if (tf->ctl != ap->last_ctl) { in bfin_tf_load()
676 ap->last_ctl = tf->ctl; in bfin_tf_load()
677 ata_wait_idle(ap); in bfin_tf_load()
689 dev_dbg(ap->dev, "hob: feat 0x%X nsect 0x%X, lba 0x%X " in bfin_tf_load()
703 dev_dbg(ap->dev, "feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", in bfin_tf_load()
713 dev_dbg(ap->dev, "device 0x%X\n", tf->device); in bfin_tf_load()
716 ata_wait_idle(ap); in bfin_tf_load()
726 static u8 bfin_check_status(struct ata_port *ap) in bfin_check_status() argument
728 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_check_status()
740 static void bfin_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in bfin_tf_read() argument
742 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_tf_read()
744 tf->command = bfin_check_status(ap); in bfin_tf_read()
770 static void bfin_exec_command(struct ata_port *ap, in bfin_exec_command() argument
773 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_exec_command()
774 dev_dbg(ap->dev, "ata%u: cmd 0x%X\n", ap->print_id, tf->command); in bfin_exec_command()
777 ata_sff_pause(ap); in bfin_exec_command()
785 static u8 bfin_check_altstatus(struct ata_port *ap) in bfin_check_altstatus() argument
787 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_check_altstatus()
799 static void bfin_dev_select(struct ata_port *ap, unsigned int device) in bfin_dev_select() argument
801 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_dev_select()
810 ata_sff_pause(ap); in bfin_dev_select()
819 static void bfin_set_devctl(struct ata_port *ap, u8 ctl) in bfin_set_devctl() argument
821 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_set_devctl()
834 struct ata_port *ap = qc->ap; in bfin_bmdma_setup() local
835 struct dma_desc_array *dma_desc_cpu = (struct dma_desc_array *)ap->bmdma_prd; in bfin_bmdma_setup()
836 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_bmdma_setup()
844 dev_dbg(qc->ap->dev, "in atapi dma setup\n"); in bfin_bmdma_setup()
855 dma_map_sg(ap->dev, qc->sg, qc->n_elem, dir); in bfin_bmdma_setup()
874 set_dma_curr_desc_addr(channel, (unsigned long *)ap->bmdma_prd_dma); in bfin_bmdma_setup()
882 bfin_exec_command(ap, &qc->tf); in bfin_bmdma_setup()
913 struct ata_port *ap = qc->ap; in bfin_bmdma_start() local
914 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_bmdma_start()
916 dev_dbg(qc->ap->dev, "in atapi dma start\n"); in bfin_bmdma_start()
918 if (!(ap->udma_mask || ap->mwdma_mask)) in bfin_bmdma_start()
922 if (ap->udma_mask) in bfin_bmdma_start()
937 struct ata_port *ap = qc->ap; in bfin_bmdma_stop() local
940 dev_dbg(qc->ap->dev, "in atapi dma stop\n"); in bfin_bmdma_stop()
942 if (!(ap->udma_mask || ap->mwdma_mask)) in bfin_bmdma_stop()
954 dma_unmap_sg(ap->dev, qc->sg, qc->n_elem, dir); in bfin_bmdma_stop()
965 static unsigned int bfin_devchk(struct ata_port *ap, in bfin_devchk() argument
968 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_devchk()
971 bfin_dev_select(ap, device); in bfin_devchk()
997 static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask) in bfin_bus_post_reset() argument
999 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_bus_post_reset()
1008 ata_sff_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); in bfin_bus_post_reset()
1017 bfin_dev_select(ap, 1); in bfin_bus_post_reset()
1026 ata_msleep(ap, 50); /* give drive a breather */ in bfin_bus_post_reset()
1029 ata_sff_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); in bfin_bus_post_reset()
1032 bfin_dev_select(ap, 0); in bfin_bus_post_reset()
1034 bfin_dev_select(ap, 1); in bfin_bus_post_reset()
1036 bfin_dev_select(ap, 0); in bfin_bus_post_reset()
1045 static unsigned int bfin_bus_softreset(struct ata_port *ap, in bfin_bus_softreset() argument
1048 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_bus_softreset()
1051 write_atapi_register(base, ATA_REG_CTRL, ap->ctl); in bfin_bus_softreset()
1053 write_atapi_register(base, ATA_REG_CTRL, ap->ctl | ATA_SRST); in bfin_bus_softreset()
1055 write_atapi_register(base, ATA_REG_CTRL, ap->ctl); in bfin_bus_softreset()
1067 ata_msleep(ap, 150); in bfin_bus_softreset()
1073 if (bfin_check_status(ap) == 0xFF) in bfin_bus_softreset()
1076 bfin_bus_post_reset(ap, devmask); in bfin_bus_softreset()
1092 struct ata_port *ap = link->ap; in bfin_softreset() local
1093 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; in bfin_softreset()
1098 if (bfin_devchk(ap, 0)) in bfin_softreset()
1100 if (slave_possible && bfin_devchk(ap, 1)) in bfin_softreset()
1104 bfin_dev_select(ap, 0); in bfin_softreset()
1107 err_mask = bfin_bus_softreset(ap, devmask); in bfin_softreset()
1109 ata_port_err(ap, "SRST failed (err_mask=0x%x)\n", in bfin_softreset()
1115 classes[0] = ata_sff_dev_classify(&ap->link.device[0], in bfin_softreset()
1118 classes[1] = ata_sff_dev_classify(&ap->link.device[1], in bfin_softreset()
1129 static unsigned char bfin_bmdma_status(struct ata_port *ap) in bfin_bmdma_status() argument
1132 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_bmdma_status()
1139 dev_dbg(ap->dev, "ATAPI: host_stat=0x%x\n", host_stat); in bfin_bmdma_status()
1157 struct ata_port *ap = dev->link->ap; in bfin_data_xfer() local
1158 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_data_xfer()
1193 static void bfin_irq_clear(struct ata_port *ap) in bfin_irq_clear() argument
1195 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_irq_clear()
1197 dev_dbg(ap->dev, "in atapi irq clear\n"); in bfin_irq_clear()
1210 void bfin_thaw(struct ata_port *ap) in bfin_thaw() argument
1212 dev_dbg(ap->dev, "in atapi dma thaw\n"); in bfin_thaw()
1213 bfin_check_status(ap); in bfin_thaw()
1214 ata_sff_irq_on(ap); in bfin_thaw()
1227 struct ata_port *ap = link->ap; in bfin_postreset() local
1228 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; in bfin_postreset()
1231 ata_sff_irq_on(ap); in bfin_postreset()
1235 bfin_dev_select(ap, 1); in bfin_postreset()
1237 bfin_dev_select(ap, 0); in bfin_postreset()
1245 write_atapi_register(base, ATA_REG_CTRL, ap->ctl); in bfin_postreset()
1248 static void bfin_port_stop(struct ata_port *ap) in bfin_port_stop() argument
1250 dev_dbg(ap->dev, "in atapi port stop\n"); in bfin_port_stop()
1251 if (ap->udma_mask != 0 || ap->mwdma_mask != 0) { in bfin_port_stop()
1252 dma_free_coherent(ap->dev, in bfin_port_stop()
1254 ap->bmdma_prd, in bfin_port_stop()
1255 ap->bmdma_prd_dma); in bfin_port_stop()
1262 static int bfin_port_start(struct ata_port *ap) in bfin_port_start() argument
1264 dev_dbg(ap->dev, "in atapi port start\n"); in bfin_port_start()
1265 if (!(ap->udma_mask || ap->mwdma_mask)) in bfin_port_start()
1268 ap->bmdma_prd = dma_alloc_coherent(ap->dev, in bfin_port_start()
1270 &ap->bmdma_prd_dma, in bfin_port_start()
1273 if (ap->bmdma_prd == NULL) { in bfin_port_start()
1274 dev_info(ap->dev, "Unable to allocate DMA descriptor array.\n"); in bfin_port_start()
1284 dma_free_coherent(ap->dev, in bfin_port_start()
1286 ap->bmdma_prd, in bfin_port_start()
1287 ap->bmdma_prd_dma); in bfin_port_start()
1291 ap->udma_mask = 0; in bfin_port_start()
1292 ap->mwdma_mask = 0; in bfin_port_start()
1293 dev_err(ap->dev, "Unable to request ATAPI DMA!" in bfin_port_start()
1299 static unsigned int bfin_ata_host_intr(struct ata_port *ap, in bfin_ata_host_intr() argument
1302 struct ata_eh_info *ehi = &ap->link.eh_info; in bfin_ata_host_intr()
1306 ap->print_id, qc->tf.protocol, ap->hsm_task_state); in bfin_ata_host_intr()
1309 switch (ap->hsm_task_state) { in bfin_ata_host_intr()
1326 host_stat = ap->ops->bmdma_status(ap); in bfin_ata_host_intr()
1328 ap->print_id, host_stat); in bfin_ata_host_intr()
1335 ap->ops->bmdma_stop(qc); in bfin_ata_host_intr()
1340 ap->hsm_task_state = HSM_ST_ERR; in bfin_ata_host_intr()
1351 status = ap->ops->sff_check_altstatus(ap); in bfin_ata_host_intr()
1356 status = ap->ops->sff_check_status(ap); in bfin_ata_host_intr()
1361 ap->ops->sff_irq_clear(ap); in bfin_ata_host_intr()
1363 ata_sff_hsm_move(ap, qc, status, 0); in bfin_ata_host_intr()
1373 ap->stats.idle_irq++; in bfin_ata_host_intr()
1376 if ((ap->stats.idle_irq % 1000) == 0) { in bfin_ata_host_intr()
1377 ap->ops->irq_ack(ap, 0); /* debug trap */ in bfin_ata_host_intr()
1378 ata_port_warn(ap, "irq trap\n"); in bfin_ata_host_intr()
1396 struct ata_port *ap = host->ports[i]; in bfin_ata_interrupt() local
1399 qc = ata_qc_from_tag(ap, ap->link.active_tag); in bfin_ata_interrupt()
1401 handled |= bfin_ata_host_intr(ap, qc); in bfin_ata_interrupt()