Lines Matching defs:chp
244 siisata_disable_port_interrupt(struct ata_channel *chp)
246 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
248 PRWRITE(sc, PRX(chp->ch_channel, PRO_PIEC), 0xffffffff);
252 siisata_enable_port_interrupt(struct ata_channel *chp)
254 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
257 (void)PRREAD(sc, PRX(chp->ch_channel, PRO_PSS));
258 PRWRITE(sc, PRX(chp->ch_channel, PRO_PIS), 0xffffffff);
260 PRWRITE(sc, PRX(chp->ch_channel, PRO_PIES),
268 struct ata_channel *chp;
272 chp = (struct ata_channel *)schp;
278 PRWRITE(sc, PRX(chp->ch_channel, PRO_PCC),
281 error = siisata_reinit_port(chp, -1);
283 siisata_enable_port_interrupt(chp);
285 GRWRITE(sc, GR_GC, GRREAD(sc, GR_GC) | GR_GC_PXIE(chp->ch_channel));
298 struct ata_channel *chp;
301 chp = (struct ata_channel *)schp;
302 sc->sc_chanarray[port] = chp;
303 chp->ch_channel = port;
304 chp->ch_atac = &sc->sc_atac;
305 chp->ch_queue = ata_queue_alloc(SIISATA_MAX_SLOTS);
306 if (chp->ch_queue == NULL) {
309 "for command queue\n", chp->ch_channel);
383 PRX(chp->ch_channel, PRO_SSTATUS), 4, &schp->sch_sstatus) != 0) {
386 chp->ch_channel);
390 PRX(chp->ch_channel, PRO_SCONTROL), 4, &schp->sch_scontrol) != 0) {
393 chp->ch_channel);
397 PRX(chp->ch_channel, PRO_SERROR), 4, &schp->sch_serror) != 0) {
400 chp->ch_channel);
406 ata_channel_attach(chp);
414 struct ata_channel *chp;
417 chp = sc->sc_chanarray[i];
419 if (child == chp->atabus)
420 chp->atabus = NULL;
430 struct ata_channel *chp;
438 chp = sc->sc_chanarray[i];
440 if (chp->atabus != NULL) {
441 if ((error = config_detach(chp->atabus, flags)) != 0)
444 KASSERT(chp->atabus == NULL);
447 if (chp->ch_flags & ATACH_DETACHED)
460 ata_channel_detach(chp);
481 struct ata_channel *chp = (struct ata_channel *)schp;
483 ata_channel_lock(chp);
484 siisata_reset_channel(chp, AT_POLL);
485 ata_channel_unlock(chp);
512 struct ata_channel *chp = &schp->ata_channel;
518 pss = PRREAD(sc, PRX(chp->ch_channel, PRO_PSS));
521 SIISATANAME(sc), __func__, chp->ch_channel, pss),
529 pis = PRREAD(sc, PRX(chp->ch_channel, PRO_PIS));
536 ec = PRREAD(sc, PRX(chp->ch_channel, PRO_PCE));
544 (chp->ch_flags & ATACH_NCQ) == 0 &&
545 (xfer = ata_queue_get_active_xfer(chp)) != NULL) {
549 PRSX(chp->ch_channel, xfer->c_slot,
553 int ntfd = satafis_rdh_parse(chp,
564 if (!ISSET(chp->ch_flags, ATACH_RECOVERING))
576 ec, chp->ch_channel,
577 PRREAD(sc, PRX(chp->ch_channel, PRO_PCR)));
580 ata_channel_lock(chp);
581 siisata_device_reset(chp);
582 ata_channel_unlock(chp);
587 PRWRITE(sc, PRX(chp->ch_channel, PRO_PIS), 0xffffffff);
590 ata_channel_freeze(chp);
594 xfer->ops->c_intr(chp, xfer, tfd);
605 uint32_t aslots = ata_queue_active(chp);
610 xfer = ata_queue_hwslot_to_xfer(chp, slot);
611 xfer->ops->c_intr(chp, xfer, 0);
617 ata_channel_lock(chp);
618 ata_channel_thaw_locked(chp);
619 ata_thread_run(chp, 0, ATACH_TH_RECOVERY, tfd);
620 ata_channel_unlock(chp);
626 siisata_channel_recover(struct ata_channel *chp, int flags, uint32_t tfd)
628 struct siisata_channel *schp = (struct siisata_channel *)chp;
633 ata_channel_lock_owned(chp);
635 if (chp->ch_ndrives > PMP_PORT_CTL) {
637 int pcr = PRREAD(sc, PRX(chp->ch_channel, PRO_PCR));
650 siisata_device_reset(chp);
655 (void)siisata_reinit_port(chp, drive);
657 ata_recovery_resume(chp, drive, tfd, flags);
667 struct ata_channel *chp = drvp->chnl_softc;
668 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
669 struct siisata_channel *schp = (struct siisata_channel *)chp;
676 ata_channel_lock_owned(chp);
678 if (siisata_reinit_port(chp, drvp->drive))
679 siisata_reset_channel(chp, flags);
682 if (!ata_queue_alloc_slot(chp, &c_slot, ATA_MAX_OPENINGS)) {
685 __func__, chp->ch_channel);
696 siisata_disable_port_interrupt(chp);
702 pss = PRREAD(sc, PRX(chp->ch_channel, PRO_PSS));
709 ata_delay(chp, 10, "siiprb", flags);
715 pis = PRREAD(sc, PRX(chp->ch_channel, PRO_PIS));
716 const uint32_t ps = PRREAD(sc, PRX(chp->ch_channel, PRO_PS));
722 chp->ch_channel, drvp->drive, slot, c_slot);
724 PRWRITE(sc, PRX(chp->ch_channel, PRO_PIS), pis &
728 siisata_enable_port_interrupt(chp);
732 siisata_device_reset(chp); /* XXX is this right? */
739 *sigp |= (PRREAD(sc, PRSX(chp->ch_channel, c_slot,
741 *sigp |= PRREAD(sc, PRSX(chp->ch_channel, c_slot,
746 ata_queue_free_slot(chp, c_slot);
750 siisata_reset_channel(struct ata_channel *chp, int flags)
752 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
753 struct siisata_channel *schp = (struct siisata_channel *)chp;
756 chp->ch_channel), DEBUG_FUNCS);
758 ata_channel_lock_owned(chp);
760 if (sata_reset_interface(chp, sc->sc_prt, schp->sch_scontrol,
763 SIISATANAME(sc), chp->ch_channel);
767 siisata_device_reset(chp);
769 PRWRITE(sc, PRX(chp->ch_channel, PRO_SERROR),
770 PRREAD(sc, PRX(chp->ch_channel, PRO_SERROR)));
794 siisata_probe_drive(struct ata_channel *chp)
796 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
797 struct siisata_channel *schp = (struct siisata_channel *)chp;
805 __func__, chp->ch_channel), DEBUG_FUNCS);
807 ata_channel_lock(chp);
810 if (!ata_queue_alloc_slot(chp, &c_slot, ATA_MAX_OPENINGS)) {
813 __func__, chp->ch_channel);
814 ata_channel_unlock(chp);
822 siisata_disable_port_interrupt(chp);
824 switch(sata_reset_interface(chp, sc->sc_prt, schp->sch_scontrol,
828 (void)PRREAD(sc, PRX(chp->ch_channel, PRO_PSS));
829 PRWRITE(sc, PRX(chp->ch_channel, PRO_PIS), 0xffffffff);
834 if (PRREAD(sc, PRX(chp->ch_channel, PRO_PS)) &
840 ata_delay(chp, 10, "siiprbrd", AT_WAIT);
845 "reinitializing\n", chp->ch_channel);
846 if (siisata_reinit_port(chp, -1))
847 siisata_reset_channel(chp, AT_WAIT);
859 if ((PRREAD(sc, PRX(chp->ch_channel, PRO_PSS)) &
865 if (PRREAD(sc, PRX(chp->ch_channel, PRO_PIS)) &
871 ata_delay(chp, 10, "siiprb", AT_WAIT);
879 "resetting\n", chp->ch_channel,
880 PRREAD(sc, PRX(chp->ch_channel, PRO_PCE)),
881 PRREAD(sc, PRX(chp->ch_channel, PRO_PSS)),
882 PRREAD(sc, PRX(chp->ch_channel, PRO_PIS)));
883 if (siisata_reinit_port(chp, -1))
884 siisata_reset_channel(chp, AT_WAIT);
890 sig |= (PRREAD(sc, PRSX(chp->ch_channel, c_slot,
892 sig |= PRREAD(sc, PRSX(chp->ch_channel, c_slot,
899 PRWRITE(sc, PRX(chp->ch_channel, PRO_PCS),
901 sata_interpret_sig(chp, 0, sig);
907 siisata_enable_port_interrupt(chp);
909 ata_queue_free_slot(chp, c_slot);
911 ata_channel_unlock(chp);
914 __func__, chp->ch_channel), DEBUG_PROBE);
919 siisata_setup_channel(struct ata_channel *chp)
935 struct ata_channel *chp = drvp->chnl_softc;
939 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__),
951 ata_exec_xfer(chp, xfer);
954 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__),
959 siisata_cmd_start(struct ata_channel *chp, struct ata_xfer *xfer)
961 struct siisata_channel *schp = (struct siisata_channel *)chp;
966 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__,
967 chp->ch_channel, xfer->c_drive, ata_c->r_command, xfer->c_slot),
970 ata_channel_lock_owned(chp);
984 if (siisata_dma_setup(chp, xfer->c_slot,
995 siisata_disable_port_interrupt(chp);
1002 callout_reset(&chp->c_timo_callout, mstohz(ata_c->timeout),
1003 ata_timeout, chp);
1010 siisata_cmd_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1012 struct siisata_channel *schp = (struct siisata_channel *)chp;
1029 siisata_enable_port_interrupt(chp);
1032 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__),
1039 siisata_cmd_abort(struct ata_channel *chp, struct ata_xfer *xfer)
1041 siisata_cmd_complete(chp, xfer, 0);
1045 siisata_cmd_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer,
1049 struct siisata_channel *schp = (struct siisata_channel *)chp;
1067 __func__, chp->ch_channel, reason);
1070 siisata_cmd_done_end(chp, xfer);
1074 ata_deactivate_xfer(chp, xfer);
1079 siisata_cmd_complete(struct ata_channel *chp, struct ata_xfer *xfer, int tfd)
1081 struct siisata_channel *schp = (struct siisata_channel *)chp;
1084 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1089 chp->ch_channel, xfer->c_slot), DEBUG_FUNCS);
1093 if (ata_waitdrain_xfer_check(chp, xfer))
1106 siisata_cmd_done(chp, xfer, tfd);
1109 ata_deactivate_xfer(chp, xfer);
1112 atastart(chp);
1118 siisata_cmd_done(struct ata_channel *chp, struct ata_xfer *xfer, int tfd)
1121 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1122 struct siisata_channel *schp = (struct siisata_channel *)chp;
1140 PRSX(chp->ch_channel, xfer->c_slot, PRSO_FIS),
1154 if (PRREAD(sc, PRSX(chp->ch_channel, xfer->c_slot, PRSO_RTC)))
1157 siisata_cmd_done_end(chp, xfer);
1161 siisata_cmd_done_end(struct ata_channel *chp, struct ata_xfer *xfer)
1179 struct ata_channel *chp = drvp->chnl_softc;
1183 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__),
1192 ata_exec_xfer(chp, xfer);
1196 siisata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
1198 struct siisata_channel *schp = (struct siisata_channel *)chp;
1203 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__,
1204 chp->ch_channel, xfer->c_slot, xfer->c_drive), DEBUG_FUNCS);
1206 ata_channel_lock_owned(chp);
1215 if (siisata_dma_setup(chp, xfer->c_slot, ata_bio->databuf, ata_bio->bcount,
1225 siisata_disable_port_interrupt(chp);
1231 callout_reset(&chp->c_timo_callout, mstohz(ATA_DELAY),
1232 ata_timeout, chp);
1239 siisata_bio_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1241 struct siisata_channel *schp = (struct siisata_channel *)chp;
1257 siisata_enable_port_interrupt(chp);
1260 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__),
1267 siisata_bio_abort(struct ata_channel *chp, struct ata_xfer *xfer)
1269 siisata_cmd_complete(chp, xfer, 0);
1273 siisata_bio_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer,
1276 struct siisata_channel *schp = (struct siisata_channel *)chp;
1282 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__,
1283 chp->ch_channel, xfer->c_slot), DEBUG_FUNCS);
1301 __func__, chp->ch_channel, reason);
1307 ata_deactivate_xfer(chp, xfer);
1310 (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
1314 siisata_bio_complete(struct ata_channel *chp, struct ata_xfer *xfer, int tfd)
1316 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1317 struct siisata_channel *schp = (struct siisata_channel *)chp;
1322 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__,
1323 chp->ch_channel, xfer->c_slot, xfer->c_drive, tfd), DEBUG_FUNCS);
1325 if (ata_waitdrain_xfer_check(chp, xfer))
1352 PRREAD(sc, PRSX(chp->ch_channel, xfer->c_slot, PRSO_RTC));
1359 ata_deactivate_xfer(chp, xfer);
1361 (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
1363 atastart(chp);
1368 siisata_dma_setup(struct ata_channel *chp, int slot, void *data,
1373 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1374 struct siisata_channel *schp = (struct siisata_channel *)chp;
1389 SIISATANAME(sc), chp->ch_channel, slot, error);
1443 siisata_reinit_port(struct ata_channel *chp, int drive)
1445 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1449 if (chp->ch_ndrives > 1) {
1459 PRWRITE(sc, PRX(chp->ch_channel, PRO_PCC), PR_PC_RESUME);
1461 for (int i = 0; i < chp->ch_ndrives; i++) {
1465 PRWRITE(sc, PRX(chp->ch_channel, PRO_PMPSTS(i)), 0);
1466 PRWRITE(sc, PRX(chp->ch_channel, PRO_PMPQACT(i)), 0);
1470 PRWRITE(sc, PRX(chp->ch_channel, PRO_PCS), PR_PC_PORT_INITIALIZE);
1472 ps = PRREAD(sc, PRX(chp->ch_channel, PRO_PS));
1483 if (chp->ch_ndrives > 1)
1484 PRWRITE(sc, PRX(chp->ch_channel, PRO_PCS), PR_PC_PMP_ENABLE);
1490 siisata_device_reset(struct ata_channel *chp)
1492 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1495 ata_channel_lock_owned(chp);
1502 PRWRITE(sc, PRX(chp->ch_channel, PRO_PCS), PR_PC_DEVICE_RESET);
1505 ps = PRREAD(sc, PRX(chp->ch_channel, PRO_PS));
1513 siisata_reset_channel(chp, AT_POLL);
1516 ata_kill_active(chp, KILL_RESET, 0);
1524 struct ata_channel *chp = ata_sc->sc_chan;
1525 struct atac_softc *atac = chp->ch_atac;
1527 struct scsipi_channel *chan = &chp->ch_atapi_channel;
1545 chan->chan_channel = chp->ch_channel;
1552 chp->atapibus = config_found(ata_sc->sc_dev, chan, atapiprint,
1574 struct ata_channel *chp =
1577 ata_kill_pending(&chp->ch_drive[periph->periph_target]);
1581 siisata_atapi_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer,
1585 struct siisata_channel *schp = (struct siisata_channel *)chp;
1604 __func__, chp->ch_channel, reason);
1609 ata_deactivate_xfer(chp, xfer);
1612 ata_free_xfer(chp, xfer);
1626 struct ata_channel *chp = atac->atac_channels[chan->chan_channel];
1627 struct ata_drive_datas *drvp = &chp->ch_drive[target];
1690 PRWRITE(siic, PRX(chp->ch_channel, PRO_PCS),
1693 PRWRITE(siic, PRX(chp->ch_channel, PRO_PCC),
1785 siisata_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer)
1787 struct siisata_channel *schp = (struct siisata_channel *)chp;
1793 SIISATANAME((struct siisata_softc *)chp->ch_atac), chp->ch_channel,
1794 chp->ch_drive[xfer->c_drive].drive, sc_xfer->xs_control),
1797 ata_channel_lock_owned(chp);
1815 if (siisata_dma_setup(chp, xfer->c_slot,
1829 siisata_disable_port_interrupt(chp);
1835 callout_reset(&chp->c_timo_callout, mstohz(sc_xfer->timeout),
1836 ata_timeout, chp);
1843 siisata_atapi_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1845 struct siisata_channel *schp = (struct siisata_channel *)chp;
1860 siisata_enable_port_interrupt(chp);
1863 SIISATANAME((struct siisata_softc *)chp->ch_atac), __func__),
1870 siisata_atapi_abort(struct ata_channel *chp, struct ata_xfer *xfer)
1872 siisata_atapi_complete(chp, xfer, 0);
1876 siisata_atapi_complete(struct ata_channel *chp, struct ata_xfer *xfer,
1879 struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
1880 struct siisata_channel *schp = (struct siisata_channel *)chp;
1886 if (ata_waitdrain_xfer_check(chp, xfer))
1900 sc_xfer->resid -= PRREAD(sc, PRSX(chp->ch_channel, xfer->c_slot,
1918 ata_deactivate_xfer(chp, xfer);
1920 ata_free_xfer(chp, xfer);
1923 atastart(chp);