Lines Matching full:ch

85 static int siis_sata_connect(struct siis_channel *ch);
458 struct siis_channel *ch = device_get_softc(dev); in siis_ch_attach() local
462 ch->dev = dev; in siis_ch_attach()
463 ch->unit = (intptr_t)device_get_ivars(dev); in siis_ch_attach()
464 ch->quirks = ctlr->quirks; in siis_ch_attach()
465 ch->pm_level = 0; in siis_ch_attach()
467 device_get_unit(dev), "pm_level", &ch->pm_level); in siis_ch_attach()
471 ch->user[i].revision = sata_rev; in siis_ch_attach()
472 ch->user[i].mode = 0; in siis_ch_attach()
473 ch->user[i].bytecount = 8192; in siis_ch_attach()
474 ch->user[i].tags = SIIS_MAX_SLOTS; in siis_ch_attach()
475 ch->curr[i] = ch->user[i]; in siis_ch_attach()
476 if (ch->pm_level) in siis_ch_attach()
477 ch->user[i].caps = CTS_SATA_CAPS_H_PMREQ; in siis_ch_attach()
478 ch->user[i].caps |= CTS_SATA_CAPS_H_AN; in siis_ch_attach()
480 mtx_init(&ch->mtx, "SIIS channel lock", NULL, MTX_DEF); in siis_ch_attach()
481 rid = ch->unit; in siis_ch_attach()
482 if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in siis_ch_attach()
488 mtx_lock(&ch->mtx); in siis_ch_attach()
490 if (!(ch->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in siis_ch_attach()
496 if ((bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL, in siis_ch_attach()
497 siis_ch_intr_locked, dev, &ch->ih))) { in siis_ch_attach()
510 ch->sim = cam_sim_alloc(siisaction, siispoll, "siisch", ch, in siis_ch_attach()
511 device_get_unit(dev), &ch->mtx, 2, SIIS_MAX_SLOTS, devq); in siis_ch_attach()
512 if (ch->sim == NULL) { in siis_ch_attach()
518 if (xpt_bus_register(ch->sim, dev, 0) != CAM_SUCCESS) { in siis_ch_attach()
523 if (xpt_create_path(&ch->path, /*periph*/NULL, cam_sim_path(ch->sim), in siis_ch_attach()
529 mtx_unlock(&ch->mtx); in siis_ch_attach()
530 ch->led = led_create(siis_ch_led, dev, device_get_nameunit(dev)); in siis_ch_attach()
534 xpt_bus_deregister(cam_sim_path(ch->sim)); in siis_ch_attach()
536 cam_sim_free(ch->sim, /*free_devq*/TRUE); in siis_ch_attach()
538 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); in siis_ch_attach()
540 bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); in siis_ch_attach()
541 mtx_unlock(&ch->mtx); in siis_ch_attach()
542 mtx_destroy(&ch->mtx); in siis_ch_attach()
549 struct siis_channel *ch = device_get_softc(dev); in siis_ch_detach() local
551 led_destroy(ch->led); in siis_ch_detach()
552 mtx_lock(&ch->mtx); in siis_ch_detach()
553 xpt_async(AC_LOST_DEVICE, ch->path, NULL); in siis_ch_detach()
554 xpt_free_path(ch->path); in siis_ch_detach()
555 xpt_bus_deregister(cam_sim_path(ch->sim)); in siis_ch_detach()
556 cam_sim_free(ch->sim, /*free_devq*/TRUE); in siis_ch_detach()
557 mtx_unlock(&ch->mtx); in siis_ch_detach()
559 bus_teardown_intr(dev, ch->r_irq, ch->ih); in siis_ch_detach()
560 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); in siis_ch_detach()
566 bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); in siis_ch_detach()
567 mtx_destroy(&ch->mtx); in siis_ch_detach()
574 struct siis_channel *ch = device_get_softc(dev); in siis_ch_init() local
577 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PORT_RESET); in siis_ch_init()
578 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_32BIT); in siis_ch_init()
579 if (ch->pm_present) in siis_ch_init()
580 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siis_ch_init()
582 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siis_ch_init()
584 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_ch_init()
591 struct siis_channel *ch = device_get_softc(dev); in siis_ch_deinit() local
594 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_RESET); in siis_ch_deinit()
601 struct siis_channel *ch = device_get_softc(dev); in siis_ch_suspend() local
603 mtx_lock(&ch->mtx); in siis_ch_suspend()
604 xpt_freeze_simq(ch->sim, 1); in siis_ch_suspend()
605 while (ch->oslots) in siis_ch_suspend()
606 msleep(ch, &ch->mtx, PRIBIO, "siissusp", hz/100); in siis_ch_suspend()
608 mtx_unlock(&ch->mtx); in siis_ch_suspend()
615 struct siis_channel *ch = device_get_softc(dev); in siis_ch_resume() local
617 mtx_lock(&ch->mtx); in siis_ch_resume()
620 xpt_release_simq(ch->sim, TRUE); in siis_ch_resume()
621 mtx_unlock(&ch->mtx); in siis_ch_resume()
646 struct siis_channel *ch; in siis_ch_led() local
649 ch = device_get_softc(dev); in siis_ch_led()
652 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_LED_ON); in siis_ch_led()
654 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_LED_ON); in siis_ch_led()
665 struct siis_channel *ch = device_get_softc(dev); in siis_dmainit() local
672 0, NULL, NULL, &ch->dma.work_tag)) in siis_dmainit()
674 if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work, 0, in siis_dmainit()
675 &ch->dma.work_map)) in siis_dmainit()
677 if (bus_dmamap_load(ch->dma.work_tag, ch->dma.work_map, ch->dma.work, in siis_dmainit()
679 bus_dmamem_free(ch->dma.work_tag, ch->dma.work, ch->dma.work_map); in siis_dmainit()
682 ch->dma.work_bus = dcba.maddr; in siis_dmainit()
688 0, busdma_lock_mutex, &ch->mtx, &ch->dma.data_tag)) { in siis_dmainit()
710 struct siis_channel *ch = device_get_softc(dev); in siis_dmafini() local
712 if (ch->dma.data_tag) { in siis_dmafini()
713 bus_dma_tag_destroy(ch->dma.data_tag); in siis_dmafini()
714 ch->dma.data_tag = NULL; in siis_dmafini()
716 if (ch->dma.work_bus) { in siis_dmafini()
717 bus_dmamap_unload(ch->dma.work_tag, ch->dma.work_map); in siis_dmafini()
718 bus_dmamem_free(ch->dma.work_tag, ch->dma.work, ch->dma.work_map); in siis_dmafini()
719 ch->dma.work_bus = 0; in siis_dmafini()
720 ch->dma.work_map = NULL; in siis_dmafini()
721 ch->dma.work = NULL; in siis_dmafini()
723 if (ch->dma.work_tag) { in siis_dmafini()
724 bus_dma_tag_destroy(ch->dma.work_tag); in siis_dmafini()
725 ch->dma.work_tag = NULL; in siis_dmafini()
732 struct siis_channel *ch = device_get_softc(dev); in siis_slotsalloc() local
736 bzero(ch->slot, sizeof(ch->slot)); in siis_slotsalloc()
738 struct siis_slot *slot = &ch->slot[i]; in siis_slotsalloc()
745 callout_init_mtx(&slot->timeout, &ch->mtx, 0); in siis_slotsalloc()
747 if (bus_dmamap_create(ch->dma.data_tag, 0, &slot->dma.data_map)) in siis_slotsalloc()
748 device_printf(ch->dev, "FAILURE - create data_map\n"); in siis_slotsalloc()
755 struct siis_channel *ch = device_get_softc(dev); in siis_slotsfree() local
760 struct siis_slot *slot = &ch->slot[i]; in siis_slotsfree()
764 bus_dmamap_destroy(ch->dma.data_tag, slot->dma.data_map); in siis_slotsfree()
773 struct siis_channel *ch = device_get_softc(dev); in siis_notify_events() local
778 if (ch->quirks & SIIS_Q_SNTF) { in siis_notify_events()
779 status = ATA_INL(ch->r_mem, SIIS_P_SNTF); in siis_notify_events()
780 ATA_OUTL(ch->r_mem, SIIS_P_SNTF, status); in siis_notify_events()
786 status = (ch->pm_present) ? 0x8000 : 0x0001; in siis_notify_events()
794 xpt_path_path_id(ch->path), i, 0) == CAM_REQ_CMP) { in siis_notify_events()
805 struct siis_channel *ch = device_get_softc(dev); in siis_phy_check_events() local
808 if (ch->pm_level == 0) { in siis_phy_check_events()
809 u_int32_t status = ATA_INL(ch->r_mem, SIIS_P_SSTS); in siis_phy_check_events()
824 cam_sim_path(ch->sim), in siis_phy_check_events()
837 struct siis_channel *ch = device_get_softc(dev); in siis_ch_intr_locked() local
839 mtx_lock(&ch->mtx); in siis_ch_intr_locked()
841 mtx_unlock(&ch->mtx); in siis_ch_intr_locked()
848 struct siis_channel *ch = device_get_softc(dev); in siis_ch_intr() local
853 mtx_assert(&ch->mtx, MA_OWNED); in siis_ch_intr()
855 sstatus = ATA_INL(ch->r_mem, SIIS_P_SS); in siis_ch_intr()
856 ok = ch->rslots & ~sstatus; in siis_ch_intr()
860 siis_end_transaction(&ch->slot[i], SIIS_ERR_NONE); in siis_ch_intr()
866 istatus = ATA_INL(ch->r_mem, SIIS_P_IS) & in siis_ch_intr()
868 ATA_OUTL(ch->r_mem, SIIS_P_IS, istatus); in siis_ch_intr()
877 estatus = ATA_INL(ch->r_mem, SIIS_P_CMDERR); in siis_ch_intr()
878 ctx = ATA_INL(ch->r_mem, SIIS_P_CTX); in siis_ch_intr()
882 // __func__, sstatus, istatus, ch->rslots, estatus, ccs, port, in siis_ch_intr()
883 // ATA_INL(ch->r_mem, SIIS_P_SERR)); in siis_ch_intr()
885 if (!ch->recoverycmd && !ch->recovery) { in siis_ch_intr()
886 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_ch_intr()
887 ch->recovery = 1; in siis_ch_intr()
889 if (ch->frozen) { in siis_ch_intr()
890 union ccb *fccb = ch->frozen; in siis_ch_intr()
891 ch->frozen = NULL; in siis_ch_intr()
903 tslots = ch->numtslots[port]; in siis_ch_intr()
906 if (((ch->rslots >> i) & 1) == 0) in siis_ch_intr()
908 if (ch->slot[i].ccb->ccb_h.target_id != port) in siis_ch_intr()
920 siis_end_transaction(&ch->slot[i], et); in siis_ch_intr()
926 if (ch->rslots != 0 && !ch->recoverycmd) in siis_ch_intr()
927 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_RESUME); in siis_ch_intr()
938 if (((ch->rslots >> i) & 1) == 0) in siis_ch_intr()
940 siis_end_transaction(&ch->slot[i], et); in siis_ch_intr()
950 struct siis_channel *ch = device_get_softc(dev); in siis_check_collision() local
952 mtx_assert(&ch->mtx, MA_OWNED); in siis_check_collision()
956 if (((~ch->oslots) & (0x7fffffff >> (31 - in siis_check_collision()
957 ch->curr[ccb->ccb_h.target_id].tags))) == 0) in siis_check_collision()
963 if (ch->numrslots != 0) in siis_check_collision()
967 if (ch->aslots != 0) in siis_check_collision()
976 struct siis_channel *ch = device_get_softc(dev); in siis_begin_transaction() local
980 mtx_assert(&ch->mtx, MA_OWNED); in siis_begin_transaction()
985 tags = ch->curr[ccb->ccb_h.target_id].tags; in siis_begin_transaction()
986 tag = fls((~ch->oslots) & (0x7fffffff >> (31 - tags))) - 1; in siis_begin_transaction()
988 slot = &ch->slot[tag]; in siis_begin_transaction()
991 ch->oslots |= (1 << slot->slot); in siis_begin_transaction()
992 ch->numrslots++; in siis_begin_transaction()
995 ch->numtslots[ccb->ccb_h.target_id]++; in siis_begin_transaction()
999 ch->aslots |= (1 << slot->slot); in siis_begin_transaction()
1004 bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, in siis_begin_transaction()
1015 struct siis_channel *ch = device_get_softc(slot->dev); in siis_dmasetprd() local
1020 mtx_assert(&ch->mtx, MA_OWNED); in siis_dmasetprd()
1023 if (!ch->recoverycmd) in siis_dmasetprd()
1024 xpt_freeze_simq(ch->sim, 1); in siis_dmasetprd()
1032 ctp = (struct siis_cmd *)(ch->dma.work + slot->prb_offset); in siis_dmasetprd()
1044 bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map, in siis_dmasetprd()
1056 struct siis_channel *ch = device_get_softc(dev); in siis_execute_transaction() local
1061 mtx_assert(&ch->mtx, MA_OWNED); in siis_execute_transaction()
1063 ctp = (struct siis_cmd *)(ch->dma.work + slot->prb_offset); in siis_execute_transaction()
1102 device_printf(ch->dev, "Setting up SATA FIS failed\n"); in siis_execute_transaction()
1103 if (!ch->recoverycmd) in siis_execute_transaction()
1104 xpt_freeze_simq(ch->sim, 1); in siis_execute_transaction()
1108 bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, in siis_execute_transaction()
1112 ch->rslots |= (1 << slot->slot); in siis_execute_transaction()
1113 prb_bus = ch->dma.work_bus + slot->prb_offset; in siis_execute_transaction()
1114 ATA_OUTL(ch->r_mem, SIIS_P_CACTL(slot->slot), prb_bus); in siis_execute_transaction()
1115 ATA_OUTL(ch->r_mem, SIIS_P_CACTH(slot->slot), prb_bus >> 32); in siis_execute_transaction()
1126 struct siis_channel *ch = device_get_softc(dev); in siis_process_timeout() local
1129 mtx_assert(&ch->mtx, MA_OWNED); in siis_process_timeout()
1130 if (!ch->recoverycmd && !ch->recovery) { in siis_process_timeout()
1131 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_process_timeout()
1132 ch->recovery = 1; in siis_process_timeout()
1137 if (ch->slot[i].state < SIIS_SLOT_RUNNING) in siis_process_timeout()
1139 siis_end_transaction(&ch->slot[i], SIIS_ERR_TIMEOUT); in siis_process_timeout()
1147 struct siis_channel *ch = device_get_softc(dev); in siis_rearm_timeout() local
1150 mtx_assert(&ch->mtx, MA_OWNED); in siis_rearm_timeout()
1152 struct siis_slot *slot = &ch->slot[i]; in siis_rearm_timeout()
1157 if ((ch->toslots & (1 << i)) == 0) in siis_rearm_timeout()
1171 struct siis_channel *ch = device_get_softc(dev); in siis_timeout() local
1174 mtx_assert(&ch->mtx, MA_OWNED); in siis_timeout()
1183 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_timeout()
1190 __func__, ATA_INL(ch->r_mem, SIIS_P_IS), in siis_timeout()
1191 ATA_INL(ch->r_mem, SIIS_P_SS), ch->rslots, in siis_timeout()
1192 ATA_INL(ch->r_mem, SIIS_P_CMDERR), ATA_INL(ch->r_mem, SIIS_P_STS), in siis_timeout()
1193 ATA_INL(ch->r_mem, SIIS_P_SERR)); in siis_timeout()
1195 if (ch->toslots == 0) in siis_timeout()
1196 xpt_freeze_simq(ch->sim, 1); in siis_timeout()
1197 ch->toslots |= (1 << slot->slot); in siis_timeout()
1198 if ((ch->rslots & ~ch->toslots) == 0) in siis_timeout()
1202 ch->rslots & ~ch->toslots); in siis_timeout()
1210 struct siis_channel *ch = device_get_softc(dev); in siis_end_transaction() local
1214 mtx_assert(&ch->mtx, MA_OWNED); in siis_end_transaction()
1215 bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, in siis_end_transaction()
1227 res->status = ATA_INB(ch->r_mem, offs + 2); in siis_end_transaction()
1228 res->error = ATA_INB(ch->r_mem, offs + 3); in siis_end_transaction()
1229 res->lba_low = ATA_INB(ch->r_mem, offs + 4); in siis_end_transaction()
1230 res->lba_mid = ATA_INB(ch->r_mem, offs + 5); in siis_end_transaction()
1231 res->lba_high = ATA_INB(ch->r_mem, offs + 6); in siis_end_transaction()
1232 res->device = ATA_INB(ch->r_mem, offs + 7); in siis_end_transaction()
1233 res->lba_low_exp = ATA_INB(ch->r_mem, offs + 8); in siis_end_transaction()
1234 res->lba_mid_exp = ATA_INB(ch->r_mem, offs + 9); in siis_end_transaction()
1235 res->lba_high_exp = ATA_INB(ch->r_mem, offs + 10); in siis_end_transaction()
1236 res->sector_count = ATA_INB(ch->r_mem, offs + 12); in siis_end_transaction()
1237 res->sector_count_exp = ATA_INB(ch->r_mem, offs + 13); in siis_end_transaction()
1241 ch->numrslots == 1) { in siis_end_transaction()
1243 ATA_INL(ch->r_mem, SIIS_P_LRAM_SLOT(slot->slot) + 4); in siis_end_transaction()
1247 ch->numrslots == 1) { in siis_end_transaction()
1249 ATA_INL(ch->r_mem, SIIS_P_LRAM_SLOT(slot->slot) + 4); in siis_end_transaction()
1253 bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map, in siis_end_transaction()
1256 bus_dmamap_unload(ch->dma.data_tag, slot->dma.data_map); in siis_end_transaction()
1259 if (et != SIIS_ERR_NONE || ch->recovery) { in siis_end_transaction()
1260 ch->eslots |= (1 << slot->slot); in siis_end_transaction()
1264 if (et != SIIS_ERR_NONE && (!ch->recoverycmd) && in siis_end_transaction()
1277 ch->fatalerr = 1; in siis_end_transaction()
1293 ch->fatalerr = 1; in siis_end_transaction()
1297 ch->fatalerr = 1; in siis_end_transaction()
1304 ch->oslots &= ~(1 << slot->slot); in siis_end_transaction()
1305 ch->rslots &= ~(1 << slot->slot); in siis_end_transaction()
1306 ch->aslots &= ~(1 << slot->slot); in siis_end_transaction()
1310 ch->numrslots--; in siis_end_transaction()
1313 ch->numtslots[ccb->ccb_h.target_id]--; in siis_end_transaction()
1317 lastto = (ch->toslots == (1 << slot->slot)); in siis_end_transaction()
1318 ch->toslots &= ~(1 << slot->slot); in siis_end_transaction()
1320 xpt_release_simq(ch->sim, TRUE); in siis_end_transaction()
1332 ch->hold[slot->slot] = ccb; in siis_end_transaction()
1333 ch->numhslots++; in siis_end_transaction()
1337 if (ch->rslots == 0) { in siis_end_transaction()
1339 if (ch->toslots != 0 || ch->fatalerr) { in siis_end_transaction()
1343 if (ch->eslots != 0) in siis_end_transaction()
1346 if (!ch->recoverycmd && ch->numhslots) in siis_end_transaction()
1350 } else if ((ch->rslots & ~ch->toslots) == 0 && in siis_end_transaction()
1354 if (ch->frozen && !siis_check_collision(dev, ch->frozen)) { in siis_end_transaction()
1355 union ccb *fccb = ch->frozen; in siis_end_transaction()
1356 ch->frozen = NULL; in siis_end_transaction()
1358 xpt_release_simq(ch->sim, TRUE); in siis_end_transaction()
1365 struct siis_channel *ch = device_get_softc(dev); in siis_issue_recovery() local
1373 if (ch->hold[i]) in siis_issue_recovery()
1384 if (ch->hold[i] == NULL) in siis_issue_recovery()
1386 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_issue_recovery()
1387 ch->hold[i]->ccb_h.status |= CAM_RESRC_UNAVAIL; in siis_issue_recovery()
1388 xpt_done(ch->hold[i]); in siis_issue_recovery()
1389 ch->hold[i] = NULL; in siis_issue_recovery()
1390 ch->numhslots--; in siis_issue_recovery()
1395 xpt_setup_ccb(&ccb->ccb_h, ch->hold[i]->ccb_h.path, in siis_issue_recovery()
1396 ch->hold[i]->ccb_h.pinfo.priority); in siis_issue_recovery()
1397 if (ch->hold[i]->ccb_h.func_code == XPT_ATA_IO) { in siis_issue_recovery()
1429 csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data; in siis_issue_recovery()
1430 csio->dxfer_len = ch->hold[i]->csio.sense_len; in siis_issue_recovery()
1436 ch->recoverycmd = 1; in siis_issue_recovery()
1443 struct siis_channel *ch = device_get_softc(dev); in siis_process_read_log() local
1448 ch->recoverycmd = 0; in siis_process_read_log()
1453 if (!ch->hold[i]) in siis_process_read_log()
1455 if (ch->hold[i]->ccb_h.target_id != ccb->ccb_h.target_id) in siis_process_read_log()
1458 res = &ch->hold[i]->ataio.res; in siis_process_read_log()
1471 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_process_read_log()
1472 ch->hold[i]->ccb_h.status |= CAM_REQUEUE_REQ; in siis_process_read_log()
1474 xpt_done(ch->hold[i]); in siis_process_read_log()
1475 ch->hold[i] = NULL; in siis_process_read_log()
1476 ch->numhslots--; in siis_process_read_log()
1485 if (!ch->hold[i]) in siis_process_read_log()
1487 if (ch->hold[i]->ccb_h.target_id != ccb->ccb_h.target_id) in siis_process_read_log()
1489 xpt_done(ch->hold[i]); in siis_process_read_log()
1490 ch->hold[i] = NULL; in siis_process_read_log()
1491 ch->numhslots--; in siis_process_read_log()
1501 struct siis_channel *ch = device_get_softc(dev); in siis_process_request_sense() local
1504 ch->recoverycmd = 0; in siis_process_request_sense()
1508 ch->hold[i]->ccb_h.status |= CAM_AUTOSNS_VALID; in siis_process_request_sense()
1510 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_process_request_sense()
1511 ch->hold[i]->ccb_h.status |= CAM_AUTOSENSE_FAIL; in siis_process_request_sense()
1513 xpt_done(ch->hold[i]); in siis_process_request_sense()
1514 ch->hold[i] = NULL; in siis_process_request_sense()
1515 ch->numhslots--; in siis_process_request_sense()
1522 struct siis_channel *ch = device_get_softc(dev); in siis_portinit() local
1525 ch->eslots = 0; in siis_portinit()
1526 ch->recovery = 0; in siis_portinit()
1527 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_RESUME); in siis_portinit()
1529 ATA_OUTL(ch->r_mem, SIIS_P_PMPSTS(i), 0), in siis_portinit()
1530 ATA_OUTL(ch->r_mem, SIIS_P_PMPQACT(i), 0); in siis_portinit()
1532 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_INIT); in siis_portinit()
1539 struct siis_channel *ch = device_get_softc(dev); in siis_devreset() local
1543 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_DEV_RESET); in siis_devreset()
1544 while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) & in siis_devreset()
1559 struct siis_channel *ch = device_get_softc(dev); in siis_wait_ready() local
1563 while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) & in siis_wait_ready()
1578 struct siis_channel *ch = device_get_softc(dev); in siis_reset() local
1582 xpt_freeze_simq(ch->sim, 1); in siis_reset()
1585 if (!ch->recoverycmd && !ch->recovery) in siis_reset()
1586 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_reset()
1588 if (ch->frozen) { in siis_reset()
1589 union ccb *fccb = ch->frozen; in siis_reset()
1590 ch->frozen = NULL; in siis_reset()
1602 if (ch->slot[i].state < SIIS_SLOT_RUNNING) in siis_reset()
1605 siis_end_transaction(&ch->slot[i], SIIS_ERR_INNOCENT); in siis_reset()
1609 if (!ch->hold[i]) in siis_reset()
1611 xpt_done(ch->hold[i]); in siis_reset()
1612 ch->hold[i] = NULL; in siis_reset()
1613 ch->numhslots--; in siis_reset()
1615 if (ch->toslots != 0) in siis_reset()
1616 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1617 ch->eslots = 0; in siis_reset()
1618 ch->recovery = 0; in siis_reset()
1619 ch->toslots = 0; in siis_reset()
1620 ch->fatalerr = 0; in siis_reset()
1622 ATA_OUTL(ch->r_mem, SIIS_P_IECLR, 0x0000FFFF); in siis_reset()
1624 sata_rev = ch->user[ch->pm_present ? 15 : 0].revision; in siis_reset()
1633 ATA_OUTL(ch->r_mem, SIIS_P_SCTL, in siis_reset()
1634 ATA_SC_DET_IDLE | val | ((ch->pm_level > 0) ? 0 : in siis_reset()
1639 if (!siis_sata_connect(ch)) { in siis_reset()
1640 ch->devices = 0; in siis_reset()
1642 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_reset()
1647 xpt_async(AC_BUS_RESET, ch->path, NULL); in siis_reset()
1648 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1657 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_RESET); in siis_reset()
1660 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PORT_RESET); in siis_reset()
1661 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_32BIT); in siis_reset()
1662 if (ch->pm_present) in siis_reset()
1663 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siis_reset()
1665 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siis_reset()
1671 ch->devices = 1; in siis_reset()
1673 ATA_OUTL(ch->r_mem, SIIS_P_IS, 0xFFFFFFFF); in siis_reset()
1674 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_reset()
1676 device_printf(dev, "SIIS reset done: devices=%08x\n", ch->devices); in siis_reset()
1678 xpt_async(AC_BUS_RESET, ch->path, NULL); in siis_reset()
1679 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1685 struct siis_channel *ch = device_get_softc(dev); in siis_setup_fis() local
1695 ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA) in siis_setup_fis()
1741 siis_sata_connect(struct siis_channel *ch) in siis_sata_connect() argument
1748 status = ATA_INL(ch->r_mem, SIIS_P_SSTS); in siis_sata_connect()
1757 device_printf(ch->dev, "SATA offline status=%08x\n", in siis_sata_connect()
1768 device_printf(ch->dev, in siis_sata_connect()
1775 device_printf(ch->dev, "SATA connect time=%dus status=%08x\n", in siis_sata_connect()
1779 ATA_OUTL(ch->r_mem, SIIS_P_SERR, 0xffffffff); in siis_sata_connect()
1804 struct siis_channel *ch; in siisaction() local
1809 ch = (struct siis_channel *)cam_sim_softc(sim); in siisaction()
1810 dev = ch->dev; in siisaction()
1811 mtx_assert(&ch->mtx, MA_OWNED); in siisaction()
1818 if (ch->devices == 0 || in siisaction()
1819 (ch->pm_present == 0 && in siisaction()
1828 ch->frozen = ccb; in siisaction()
1830 xpt_freeze_simq(ch->sim, 1); in siisaction()
1847 d = &ch->curr[ccb->ccb_h.target_id]; in siisaction()
1849 d = &ch->user[ccb->ccb_h.target_id]; in siisaction()
1859 ch->pm_present = cts->xport_specific.sata.pm_present; in siisaction()
1860 if (ch->pm_present) in siisaction()
1861 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siisaction()
1863 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siisaction()
1882 d = &ch->curr[ccb->ccb_h.target_id]; in siisaction()
1884 d = &ch->user[ccb->ccb_h.target_id]; in siisaction()
1893 (ccb->ccb_h.target_id == 0 && !ch->pm_present))) { in siisaction()
1894 status = ATA_INL(ch->r_mem, SIIS_P_SSTS) & ATA_SS_SPD_MASK; in siisaction()
1902 if (ch->pm_level) in siisaction()
1906 ch->user[ccb->ccb_h.target_id].caps; in siisaction()
1913 (ch->quirks & SIIS_Q_SNTF) == 0) in siisaction()
1921 cts->xport_specific.sata.pm_present = ch->pm_present; in siisaction()
1981 struct siis_channel *ch = (struct siis_channel *)cam_sim_softc(sim); in siispoll() local
1983 siis_ch_intr(ch->dev); in siispoll()