Home | History | Annotate | Download | only in ic

Lines Matching refs:chp

123 #define	AHCISATA_DO_EXTRA_DELAY(sc, chp, msg, flags)			\
124 ata_delay(chp, AHCISATA_EXTRA_DELAY_MS, msg, flags)
126 #define AHCISATA_DO_EXTRA_DELAY(sc, chp, msg, flags) do { } while (0)
212 struct ata_channel *chp;
223 chp = &achp->ata_channel;
225 ahci_probe_drive(chp);
259 struct ata_channel *chp;
408 chp = &achp->ata_channel;
409 sc->sc_chanarray[i] = chp;
410 chp->ch_channel = i;
411 chp->ch_atac = &sc->sc_atac;
412 chp->ch_queue = ata_queue_alloc(sc->sc_ncmds);
413 if (chp->ch_queue == NULL) {
510 ata_channel_attach(chp);
521 struct ata_channel *chp;
525 chp = &achp->ata_channel;
530 if (child == chp->atabus)
531 chp->atabus = NULL;
540 struct ata_channel *chp;
550 chp = &achp->ata_channel;
560 if (chp->atabus != NULL) {
561 if ((error = config_detach(chp->atabus, flags)) != 0)
564 KASSERT(chp->atabus == NULL);
567 if (chp->ch_flags & ATACH_DETACHED)
580 ata_channel_detach(chp);
632 struct ata_channel *chp = &achp->ata_channel;
633 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
636 ret = ahci_intr_port_common(chp);
638 AHCI_WRITE(sc, AHCI_IS, 1U << chp->ch_channel);
645 ahci_intr_port_common(struct ata_channel *chp)
647 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
654 is = AHCI_READ(sc, AHCI_P_IS(chp->ch_channel));
655 AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), is);
660 chp->ch_channel, is,
661 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)),
662 AHCI_READ(sc, AHCI_P_SACT(chp->ch_channel)),
663 AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel))),
666 if ((chp->ch_flags & ATACH_NCQ) == 0) {
668 sact = AHCI_READ(sc, AHCI_P_CI(chp->ch_channel));
671 sact = AHCI_READ(sc, AHCI_P_SACT(chp->ch_channel));
679 tfd = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
681 if ((chp->ch_flags & ATACH_NCQ) == 0) {
684 AHCI_P_CMD(chp->ch_channel))
691 AHCINAME(sc), chp->ch_channel, sact, is, tfd),
701 AHCINAME(sc), chp->ch_channel,
702 AHCI_READ(sc, AHCI_P_SERR(chp->ch_channel))),
706 if (!ISSET(chp->ch_flags, ATACH_RECOVERING))
709 tfd = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
713 if (!ISSET(chp->ch_flags, ATACH_RECOVERING))
717 AHCINAME(sc), chp->ch_channel, tfd), DEBUG_INTR);
724 ata_channel_freeze(chp);
726 aslots = ata_queue_active(chp);
731 xfer = ata_queue_hwslot_to_xfer(chp, slot);
732 xfer->ops->c_intr(chp, xfer, tfd);
748 xfer = ata_queue_hwslot_to_xfer(chp, slot);
749 xfer->ops->c_intr(chp, xfer, tfd);
755 ata_channel_lock(chp);
756 ata_channel_thaw_locked(chp);
757 ata_thread_run(chp, 0, ATACH_TH_RECOVERY, tfd);
758 ata_channel_unlock(chp);
767 struct ata_channel *chp = drvp->chnl_softc;
768 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
771 ata_channel_lock_owned(chp);
774 if (!ata_queue_alloc_slot(chp, &c_slot, ATA_MAX_OPENINGS)) {
777 __func__, chp->ch_channel);
783 ahci_channel_stop(sc, chp, flags);
784 ahci_do_reset_drive(chp, drvp->drive, flags, sigp, c_slot);
787 ata_queue_free_slot(chp, c_slot);
792 ahci_exec_fis(struct ata_channel *chp, int timeout, int flags, int slot)
794 struct ahci_channel *achp = (struct ahci_channel *)chp;
795 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
809 AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << slot);
811 if ((AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)) & (1U << slot)) ==
814 is = AHCI_READ(sc, AHCI_P_IS(chp->ch_channel));
828 AHCINAME(sc), chp->ch_channel, is);
831 ata_delay(chp, 10, "ahcifis", flags);
835 AHCINAME(sc), chp->ch_channel);
840 ahci_do_reset_drive(struct ata_channel *chp, int drive, int flags,
843 struct ahci_channel *achp = (struct ahci_channel *)chp;
844 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
851 ata_channel_lock_owned(chp);
855 AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
863 ahci_channel_start(sc, chp, flags, 1);
866 cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel));
868 ahci_channel_stop(sc, chp, flags);
869 cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel));
873 chp->ch_channel, drive);
879 KASSERT((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR) == 0);
881 ahci_channel_start(sc, chp, flags, 0);
899 switch (ahci_exec_fis(chp, 100, flags, c_slot)) {
910 ahci_reset_channel(chp, flags);
914 "for drive %d\n", AHCINAME(sc), chp->ch_channel, drive);
926 ata_delay(chp, 10, "ahcirstw", flags);
939 switch (ahci_exec_fis(chp, 310, flags, c_slot)) {
954 "for drive %d\n", AHCINAME(sc), chp->ch_channel, drive);
964 sig = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
967 ata_delay(chp, 10, "ahcid2h", flags);
976 sig = AHCI_READ(sc, AHCI_P_SIG(chp->ch_channel));
980 AHCINAME(sc), chp->ch_channel, sig,
981 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel))), DEBUG_PROBE);
983 ahci_channel_stop(sc, chp, flags);
984 AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahcirst", flags);
986 AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
987 ahci_channel_start(sc, chp, flags,
993 ahci_reset_channel(struct ata_channel *chp, int flags)
995 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
996 struct ahci_channel *achp = (struct ahci_channel *)chp;
999 ata_channel_lock_owned(chp);
1001 ahci_channel_stop(sc, chp, flags);
1002 if (sata_reset_interface(chp, sc->sc_ahcit, achp->ahcic_scontrol,
1004 printf("%s: port %d reset failed\n", AHCINAME(sc), chp->ch_channel);
1007 ata_kill_active(chp, KILL_RESET, flags);
1008 AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahcirst", flags);
1010 AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
1012 ahci_channel_start(sc, chp, flags,
1016 tfd = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
1019 ata_delay(chp, 10, "ahcid2h", flags);
1027 AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
1051 ahci_probe_drive(struct ata_channel *chp)
1053 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1054 struct ahci_channel *achp = (struct ahci_channel *)chp;
1059 ata_channel_lock(chp);
1062 if (!ata_queue_alloc_slot(chp, &c_slot, ATA_MAX_OPENINGS)) {
1065 __func__, chp->ch_channel);
1066 ata_channel_unlock(chp);
1071 AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
1075 switch (sata_reset_interface(chp, sc->sc_ahcit, achp->ahcic_scontrol,
1078 AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahcidv", AT_WAIT);
1081 sig = AHCI_READ(sc, AHCI_P_SIG(chp->ch_channel));
1084 error = ahci_do_reset_drive(chp, PMP_PORT_CTL, AT_WAIT,
1091 AHCINAME(sc), chp->ch_channel,
1095 ahci_reset_channel(chp, AT_WAIT);
1098 ahci_do_reset_drive(chp, 0, AT_WAIT, &sig, c_slot);
1100 sata_interpret_sig(chp, 0, sig);
1102 if (chp->ch_ndrives > PMP_PORT_CTL &&
1103 chp
1104 AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
1105 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) |
1109 AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
1112 AHCI_WRITE(sc, AHCI_P_IE(chp->ch_channel),
1121 AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahciprb", AT_WAIT);
1128 ata_queue_free_slot(chp, c_slot);
1130 ata_channel_unlock(chp);
1134 ahci_setup_channel(struct ata_channel *chp)
1150 struct ata_channel *chp = drvp->chnl_softc;
1154 chp->ch_channel,
1155 AHCI_READ(AHCI_CH2SC(chp), AHCI_P_CI(chp->ch_channel))),
1166 ata_exec_xfer(chp, xfer);
1170 ahci_cmd_start(struct ata_channel *chp, struct ata_xfer *xfer)
1172 struct ahci_softc *sc = AHCI_CH2SC(chp);
1173 struct ahci_channel *achp = (struct ahci_channel *)chp;
1180 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)),
1184 ata_channel_lock_owned(chp);
1187 AHCIDEBUG_PRINT(("%s port %d tbl %p\n", AHCINAME(sc), chp->ch_channel,
1195 chp->ch_channel, cmd_h), DEBUG_XFERS);
1196 if (ahci_dma_setup(chp, slot,
1217 AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << slot);
1220 callout_reset(&chp->c_timo_callout, mstohz(ata_c->timeout),
1221 ata_timeout, chp);
1228 ahci_cmd_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1230 struct ahci_softc *sc = AHCI_CH2SC(chp);
1231 struct ahci_channel *achp = (struct ahci_channel *)chp;
1233 ata_channel_lock(chp);
1241 ata_channel_unlock(chp);
1243 ata_channel_lock(chp);
1244 ata_delay(chp, 10, "ahcipl", xfer->c_ata_c.flags);
1246 AHCIDEBUG_PRINT(("%s port %d poll end GHC 0x%x IS 0x%x list 0x%x%x fis 0x%x%x CMD 0x%x CI 0x%x\n", AHCINAME(sc), chp->ch_channel,
1248 AHCI_READ(sc, AHCI_P_CLBU(chp->ch_channel)),
1249 AHCI_READ(sc, AHCI_P_CLB(chp->ch_channel)),
1250 AHCI_READ(sc, AHCI_P_FBU(chp->ch_channel)),
1251 AHCI_READ(sc, AHCI_P_FB(chp->ch_channel)),
1252 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)),
1253 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel))),
1256 ata_channel_unlock(chp);
1260 xfer->ops->c_intr(chp, xfer, 0);
1269 ahci_cmd_abort(struct ata_channel *chp, struct ata_xfer *xfer)
1271 ahci_cmd_complete(chp, xfer, 0);
1275 ahci_cmd_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer, int reason)
1280 AHCIDEBUG_PRINT(("ahci_cmd_kill_xfer port %d\n", chp->ch_channel),
1301 ahci_cmd_done_end(chp, xfer);
1304 ata_deactivate_xfer(chp, xfer);
1308 ahci_cmd_complete(struct ata_channel *chp, struct ata_xfer *xfer, int tfd)
1311 struct ahci_channel *achp = (struct ahci_channel *)chp;
1312 struct ahci_softc *sc = AHCI_CH2SC(chp);
1315 chp->ch_channel,
1316 AHCI_READ(AHCI_CH2SC(chp), AHCI_P_CMD(chp->ch_channel)),
1317 AHCI_READ(AHCI_CH2SC(chp), AHCI_P_CI(chp->ch_channel))),
1320 if (ata_waitdrain_xfer_check(chp, xfer))
1339 ahci_cmd_done(chp, xfer);
1341 ata_deactivate_xfer(chp, xfer);
1344 atastart(chp);
1350 ahci_cmd_done(struct ata_channel *chp, struct ata_xfer *xfer)
1352 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1353 struct ahci_channel *achp = (struct ahci_channel *)chp;
1359 chp->ch_channel, xfer->c_flags, ata_c->flags), DEBUG_FUNCS);
1384 ahci_cmd_done_end(chp, xfer);
1388 ahci_cmd_done_end(struct ata_channel *chp, struct ata_xfer *xfer)
1406 struct ata_channel *chp = drvp->chnl_softc;
1410 chp->ch_channel,
1411 AHCI_READ(AHCI_CH2SC(chp), AHCI_P_CI(chp->ch_channel))),
1419 ata_exec_xfer(chp, xfer);
1423 ahci_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
1425 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1426 struct ahci_channel *achp = (struct ahci_channel *)chp;
1432 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel))), DEBUG_XFERS);
1434 ata_channel_lock_owned(chp);
1437 AHCIDEBUG_PRINT(("%s port %d tbl %p\n", AHCINAME(sc), chp->ch_channel,
1445 chp->ch_channel, cmd_h), DEBUG_XFERS);
1446 if (ahci_dma_setup(chp, xfer->c_slot, ata_bio->databuf, ata_bio->bcount,
1465 AHCI_WRITE(sc, AHCI_P_SACT(chp->ch_channel), 1U << xfer->c_slot);
1467 AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << xfer->c_slot);
1470 callout_reset(&chp->c_timo_callout, mstohz(ATA_DELAY),
1471 ata_timeout, chp);
1478 ahci_bio_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1480 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1481 struct ahci_channel *achp = (struct ahci_channel *)chp;
1492 AHCIDEBUG_PRINT(("%s port %d poll end GHC 0x%x IS 0x%x list 0x%x%x fis 0x%x%x CMD 0x%x CI 0x%x\n", AHCINAME(sc), chp->ch_channel,
1494 AHCI_READ(sc, AHCI_P_CLBU(chp->ch_channel)),
1495 AHCI_READ(sc, AHCI_P_CLB(chp->ch_channel)),
1496 AHCI_READ(sc, AHCI_P_FBU(chp->ch_channel)),
1497 AHCI_READ(sc, AHCI_P_FB(chp->ch_channel)),
1498 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)),
1499 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel))),
1503 xfer->ops->c_intr(chp, xfer, 0);
1511 ahci_bio_abort(struct ata_channel *chp, struct ata_xfer *xfer)
1513 ahci_bio_complete(chp, xfer, 0);
1517 ahci_bio_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer, int reason)
1523 AHCIDEBUG_PRINT(("ahci_bio_kill_xfer port %d\n", chp->ch_channel),
1547 ata_deactivate_xfer(chp, xfer);
1549 (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
1553 ahci_bio_complete(struct ata_channel *chp, struct ata_xfer *xfer, int tfd)
1557 struct ahci_channel *achp = (struct ahci_channel *)chp;
1558 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1560 AHCIDEBUG_PRINT(("ahci_bio_complete port %d\n", chp->ch_channel),
1563 if (ata_waitdrain_xfer_check(chp, xfer))
1607 ata_deactivate_xfer(chp, xfer);
1609 (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
1611 atastart(chp);
1616 ahci_channel_stop(struct ahci_softc *sc, struct ata_channel *chp, int flags)
1620 AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
1621 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & ~AHCI_P_CMD_ST);
1624 if ((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR)
1627 ata_delay(chp, 10, "ahcistop", flags);
1629 if (AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR) {
1636 sc->sc_channel_stop(sc, chp);
1640 ahci_channel_start(struct ahci_softc *sc, struct ata_channel *chp,
1646 AHCI_WRITE(sc, AHCI_P_SERR(chp->ch_channel),
1647 AHCI_READ(sc, AHCI_P_SERR(chp->ch_channel)));
1652 AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
1653 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) | AHCI_P_CMD_CLO);
1656 if ((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) &
1659 ata_delay(chp, 10, "ahciclo", flags);
1661 if (AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CLO) {
1669 sc->sc_channel_start(sc, chp);
1674 if (chp->ch_ndrives > PMP_PORT_CTL &&
1675 chp
1678 AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel), p_cmd);
1683 ahci_channel_recover(struct ata_channel *chp, int flags, uint32_t tfd)
1685 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1689 ata_channel_lock_owned(chp);
1700 if (chp->ch_ndrives > PMP_PORT_CTL) {
1701 uint32_t fbs = AHCI_READ(sc, AHCI_P_FBS(chp->ch_channel));
1710 AHCI_WRITE(sc, AHCI_P_FBS(chp->ch_channel), fbs);
1713 AHCI_P_FBS(chp->ch_channel));
1739 ahci_reset_channel(chp, flags);
1744 ahci_channel_stop(sc, chp, flags);
1745 ahci_channel_start(sc, chp, flags,
1748 ata_recovery_resume(chp, drive, tfd, flags);
1756 ahci_dma_setup(struct ata_channel *chp, int slot, void *data,
1760 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1761 struct ahci_channel *achp = (struct ahci_channel *)chp;
1778 AHCINAME(sc), chp->ch_channel, error);
1801 struct ata_channel *chp = ata_sc->sc_chan;
1802 struct atac_softc *atac = chp->ch_atac;
1804 struct scsipi_channel *chan = &chp->ch_atapi_channel;
1820 chan->chan_channel = chp->ch_channel;
1826 chp->atapibus = config_found(ata_sc->sc_dev, chan, atapiprint,
1848 struct ata_channel *chp =
1851 ata_kill_pending(&chp->ch_drive[periph->periph_target]);
1918 ahci_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer)
1920 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1921 struct ahci_channel *achp = (struct ahci_channel *)chp;
1927 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel))), DEBUG_XFERS);
1929 ata_channel_lock_owned(chp);
1932 AHCIDEBUG_PRINT(("%s port %d tbl %p\n", AHCINAME(sc), chp->ch_channel,
1942 chp->ch_channel, cmd_h), DEBUG_XFERS);
1943 if (ahci_dma_setup(chp, xfer->c_slot,
1965 AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << xfer->c_slot);
1968 callout_reset(&chp->c_timo_callout, mstohz(sc_xfer->timeout),
1969 ata_timeout, chp);
1976 ahci_atapi_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1978 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
1979 struct ahci_channel *achp = (struct ahci_channel *)chp;
1990 AHCIDEBUG_PRINT(("%s port %d poll end GHC 0x%x IS 0x%x list 0x%x%x fis 0x%x%x CMD 0x%x CI 0x%x\n", AHCINAME(sc), chp->ch_channel,
1992 AHCI_READ(sc, AHCI_P_CLBU(chp->ch_channel)),
1993 AHCI_READ(sc, AHCI_P_CLB(chp->ch_channel)),
1994 AHCI_READ(sc, AHCI_P_FBU(chp->ch_channel)),
1995 AHCI_READ(sc, AHCI_P_FB(chp->ch_channel)),
1996 AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)),
1997 AHCI_READ(sc, AHCI_P_CI(chp->ch_channel))),
2001 xfer->ops->c_intr(chp, xfer, 0);
2009 ahci_atapi_abort(struct ata_channel *chp, struct ata_xfer *xfer)
2011 ahci_atapi_complete(chp, xfer, 0);
2015 ahci_atapi_complete(struct ata_channel *chp, struct ata_xfer *xfer, int tfd)
2018 struct ahci_channel *achp = (struct ahci_channel *)chp;
2019 struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
2021 AHCIDEBUG_PRINT(("ahci_atapi_complete port %d\n", chp->ch_channel),
2024 if (ata_waitdrain_xfer_check(chp, xfer))
2058 ata_deactivate_xfer(chp, xfer);
2060 ata_free_xfer(chp, xfer);
2063 atastart(chp);
2068 ahci_atapi_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer, int reason)
2093 ata_deactivate_xfer(chp, xfer);
2095 ata_free_xfer(chp, xfer);
2109 struct ata_channel *chp = atac->atac_channels[chan->chan_channel];
2110 struct ata_drive_datas *drvp = &chp->ch_drive[target];
2197 AHCINAME(ahcic), chp->ch_channel, target), DEBUG_PROBE);