Lines Matching refs:ch
87 static int siis_sata_connect(struct siis_channel *ch);
463 struct siis_channel *ch = device_get_softc(dev); in siis_ch_attach() local
467 ch->dev = dev; in siis_ch_attach()
468 ch->unit = (intptr_t)device_get_ivars(dev); in siis_ch_attach()
469 ch->quirks = ctlr->quirks; in siis_ch_attach()
470 ch->pm_level = 0; in siis_ch_attach()
472 device_get_unit(dev), "pm_level", &ch->pm_level); in siis_ch_attach()
476 ch->user[i].revision = sata_rev; in siis_ch_attach()
477 ch->user[i].mode = 0; in siis_ch_attach()
478 ch->user[i].bytecount = 8192; in siis_ch_attach()
479 ch->user[i].tags = SIIS_MAX_SLOTS; in siis_ch_attach()
480 ch->curr[i] = ch->user[i]; in siis_ch_attach()
481 if (ch->pm_level) in siis_ch_attach()
482 ch->user[i].caps = CTS_SATA_CAPS_H_PMREQ; in siis_ch_attach()
483 ch->user[i].caps |= CTS_SATA_CAPS_H_AN; in siis_ch_attach()
485 mtx_init(&ch->mtx, "SIIS channel lock", NULL, MTX_DEF); in siis_ch_attach()
486 rid = ch->unit; in siis_ch_attach()
487 if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in siis_ch_attach()
493 mtx_lock(&ch->mtx); in siis_ch_attach()
495 if (!(ch->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in siis_ch_attach()
501 if ((bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL, in siis_ch_attach()
502 siis_ch_intr_locked, dev, &ch->ih))) { in siis_ch_attach()
515 ch->sim = cam_sim_alloc(siisaction, siispoll, "siisch", ch, in siis_ch_attach()
516 device_get_unit(dev), &ch->mtx, 2, SIIS_MAX_SLOTS, devq); in siis_ch_attach()
517 if (ch->sim == NULL) { in siis_ch_attach()
523 if (xpt_bus_register(ch->sim, dev, 0) != CAM_SUCCESS) { in siis_ch_attach()
528 if (xpt_create_path(&ch->path, /*periph*/NULL, cam_sim_path(ch->sim), in siis_ch_attach()
534 mtx_unlock(&ch->mtx); in siis_ch_attach()
535 ch->led = led_create(siis_ch_led, dev, device_get_nameunit(dev)); in siis_ch_attach()
539 xpt_bus_deregister(cam_sim_path(ch->sim)); in siis_ch_attach()
541 cam_sim_free(ch->sim, /*free_devq*/TRUE); in siis_ch_attach()
543 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); in siis_ch_attach()
545 bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); in siis_ch_attach()
546 mtx_unlock(&ch->mtx); in siis_ch_attach()
547 mtx_destroy(&ch->mtx); in siis_ch_attach()
554 struct siis_channel *ch = device_get_softc(dev); in siis_ch_detach() local
556 led_destroy(ch->led); in siis_ch_detach()
557 mtx_lock(&ch->mtx); in siis_ch_detach()
558 xpt_async(AC_LOST_DEVICE, ch->path, NULL); in siis_ch_detach()
559 xpt_free_path(ch->path); in siis_ch_detach()
560 xpt_bus_deregister(cam_sim_path(ch->sim)); in siis_ch_detach()
561 cam_sim_free(ch->sim, /*free_devq*/TRUE); in siis_ch_detach()
562 mtx_unlock(&ch->mtx); in siis_ch_detach()
564 bus_teardown_intr(dev, ch->r_irq, ch->ih); in siis_ch_detach()
565 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); in siis_ch_detach()
571 bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); in siis_ch_detach()
572 mtx_destroy(&ch->mtx); in siis_ch_detach()
579 struct siis_channel *ch = device_get_softc(dev); in siis_ch_init() local
582 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PORT_RESET); in siis_ch_init()
583 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_32BIT); in siis_ch_init()
584 if (ch->pm_present) in siis_ch_init()
585 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siis_ch_init()
587 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siis_ch_init()
589 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_ch_init()
596 struct siis_channel *ch = device_get_softc(dev); in siis_ch_deinit() local
599 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_RESET); in siis_ch_deinit()
606 struct siis_channel *ch = device_get_softc(dev); in siis_ch_suspend() local
608 mtx_lock(&ch->mtx); in siis_ch_suspend()
609 xpt_freeze_simq(ch->sim, 1); in siis_ch_suspend()
610 while (ch->oslots) in siis_ch_suspend()
611 msleep(ch, &ch->mtx, PRIBIO, "siissusp", hz/100); in siis_ch_suspend()
613 mtx_unlock(&ch->mtx); in siis_ch_suspend()
620 struct siis_channel *ch = device_get_softc(dev); in siis_ch_resume() local
622 mtx_lock(&ch->mtx); in siis_ch_resume()
625 xpt_release_simq(ch->sim, TRUE); in siis_ch_resume()
626 mtx_unlock(&ch->mtx); in siis_ch_resume()
650 struct siis_channel *ch; in siis_ch_led() local
653 ch = device_get_softc(dev); in siis_ch_led()
656 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_LED_ON); in siis_ch_led()
658 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_LED_ON); in siis_ch_led()
669 struct siis_channel *ch = device_get_softc(dev); in siis_dmainit() local
676 0, NULL, NULL, &ch->dma.work_tag)) in siis_dmainit()
678 if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work, 0, in siis_dmainit()
679 &ch->dma.work_map)) in siis_dmainit()
681 if (bus_dmamap_load(ch->dma.work_tag, ch->dma.work_map, ch->dma.work, in siis_dmainit()
683 bus_dmamem_free(ch->dma.work_tag, ch->dma.work, ch->dma.work_map); in siis_dmainit()
686 ch->dma.work_bus = dcba.maddr; in siis_dmainit()
693 0, busdma_lock_mutex, &ch->mtx, &ch->dma.data_tag)) { in siis_dmainit()
715 struct siis_channel *ch = device_get_softc(dev); in siis_dmafini() local
717 if (ch->dma.data_tag) { in siis_dmafini()
718 bus_dma_tag_destroy(ch->dma.data_tag); in siis_dmafini()
719 ch->dma.data_tag = NULL; in siis_dmafini()
721 if (ch->dma.work_bus) { in siis_dmafini()
722 bus_dmamap_unload(ch->dma.work_tag, ch->dma.work_map); in siis_dmafini()
723 bus_dmamem_free(ch->dma.work_tag, ch->dma.work, ch->dma.work_map); in siis_dmafini()
724 ch->dma.work_bus = 0; in siis_dmafini()
725 ch->dma.work_map = NULL; in siis_dmafini()
726 ch->dma.work = NULL; in siis_dmafini()
728 if (ch->dma.work_tag) { in siis_dmafini()
729 bus_dma_tag_destroy(ch->dma.work_tag); in siis_dmafini()
730 ch->dma.work_tag = NULL; in siis_dmafini()
737 struct siis_channel *ch = device_get_softc(dev); in siis_slotsalloc() local
741 bzero(ch->slot, sizeof(ch->slot)); in siis_slotsalloc()
743 struct siis_slot *slot = &ch->slot[i]; in siis_slotsalloc()
749 callout_init_mtx(&slot->timeout, &ch->mtx, 0); in siis_slotsalloc()
751 if (bus_dmamap_create(ch->dma.data_tag, 0, &slot->dma.data_map)) in siis_slotsalloc()
752 device_printf(ch->dev, "FAILURE - create data_map\n"); in siis_slotsalloc()
759 struct siis_channel *ch = device_get_softc(dev); in siis_slotsfree() local
764 struct siis_slot *slot = &ch->slot[i]; in siis_slotsfree()
768 bus_dmamap_destroy(ch->dma.data_tag, slot->dma.data_map); in siis_slotsfree()
777 struct siis_channel *ch = device_get_softc(dev); in siis_notify_events() local
782 if (ch->quirks & SIIS_Q_SNTF) { in siis_notify_events()
783 status = ATA_INL(ch->r_mem, SIIS_P_SNTF); in siis_notify_events()
784 ATA_OUTL(ch->r_mem, SIIS_P_SNTF, status); in siis_notify_events()
790 status = (ch->pm_present) ? 0x8000 : 0x0001; in siis_notify_events()
798 xpt_path_path_id(ch->path), i, 0) == CAM_REQ_CMP) { in siis_notify_events()
809 struct siis_channel *ch = device_get_softc(dev); in siis_phy_check_events() local
812 if (ch->pm_level == 0) { in siis_phy_check_events()
813 u_int32_t status = ATA_INL(ch->r_mem, SIIS_P_SSTS); in siis_phy_check_events()
828 cam_sim_path(ch->sim), in siis_phy_check_events()
841 struct siis_channel *ch = device_get_softc(dev); in siis_ch_intr_locked() local
843 mtx_lock(&ch->mtx); in siis_ch_intr_locked()
845 mtx_unlock(&ch->mtx); in siis_ch_intr_locked()
852 struct siis_channel *ch = device_get_softc(dev); in siis_ch_intr() local
857 mtx_assert(&ch->mtx, MA_OWNED); in siis_ch_intr()
859 sstatus = ATA_INL(ch->r_mem, SIIS_P_SS); in siis_ch_intr()
860 ok = ch->rslots & ~sstatus; in siis_ch_intr()
864 siis_end_transaction(&ch->slot[i], SIIS_ERR_NONE); in siis_ch_intr()
870 istatus = ATA_INL(ch->r_mem, SIIS_P_IS) & in siis_ch_intr()
872 ATA_OUTL(ch->r_mem, SIIS_P_IS, istatus); in siis_ch_intr()
881 estatus = ATA_INL(ch->r_mem, SIIS_P_CMDERR); in siis_ch_intr()
882 ctx = ATA_INL(ch->r_mem, SIIS_P_CTX); in siis_ch_intr()
885 err = ch->rslots & sstatus; in siis_ch_intr()
890 if (!ch->recoverycmd && !ch->recovery) { in siis_ch_intr()
891 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_ch_intr()
892 ch->recovery = 1; in siis_ch_intr()
894 if (ch->frozen) { in siis_ch_intr()
895 union ccb *fccb = ch->frozen; in siis_ch_intr()
896 ch->frozen = NULL; in siis_ch_intr()
908 tslots = ch->numtslots[port]; in siis_ch_intr()
911 if (((ch->rslots >> i) & 1) == 0) in siis_ch_intr()
913 if (ch->slot[i].ccb->ccb_h.target_id != port) in siis_ch_intr()
925 siis_end_transaction(&ch->slot[i], et); in siis_ch_intr()
931 if (ch->rslots != 0 && !ch->recoverycmd) in siis_ch_intr()
932 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_RESUME); in siis_ch_intr()
943 if (((ch->rslots >> i) & 1) == 0) in siis_ch_intr()
945 siis_end_transaction(&ch->slot[i], et); in siis_ch_intr()
955 struct siis_channel *ch = device_get_softc(dev); in siis_check_collision() local
957 mtx_assert(&ch->mtx, MA_OWNED); in siis_check_collision()
961 if (((~ch->oslots) & (0x7fffffff >> (31 - in siis_check_collision()
962 ch->curr[ccb->ccb_h.target_id].tags))) == 0) in siis_check_collision()
968 if (ch->numrslots != 0) in siis_check_collision()
972 if (ch->aslots != 0) in siis_check_collision()
981 struct siis_channel *ch = device_get_softc(dev); in siis_begin_transaction() local
985 mtx_assert(&ch->mtx, MA_OWNED); in siis_begin_transaction()
990 tags = ch->curr[ccb->ccb_h.target_id].tags; in siis_begin_transaction()
991 tag = fls((~ch->oslots) & (0x7fffffff >> (31 - tags))) - 1; in siis_begin_transaction()
993 slot = &ch->slot[tag]; in siis_begin_transaction()
996 ch->oslots |= (1 << slot->slot); in siis_begin_transaction()
997 ch->numrslots++; in siis_begin_transaction()
1000 ch->numtslots[ccb->ccb_h.target_id]++; in siis_begin_transaction()
1004 ch->aslots |= (1 << slot->slot); in siis_begin_transaction()
1009 bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, in siis_begin_transaction()
1020 struct siis_channel *ch = device_get_softc(slot->dev); in siis_dmasetprd() local
1025 mtx_assert(&ch->mtx, MA_OWNED); in siis_dmasetprd()
1028 if (!ch->recoverycmd) in siis_dmasetprd()
1029 xpt_freeze_simq(ch->sim, 1); in siis_dmasetprd()
1037 ctp = (struct siis_cmd *)(ch->dma.work + SIIS_CT_OFFSET + in siis_dmasetprd()
1050 bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map, in siis_dmasetprd()
1062 struct siis_channel *ch = device_get_softc(dev); in siis_execute_transaction() local
1067 mtx_assert(&ch->mtx, MA_OWNED); in siis_execute_transaction()
1070 (ch->dma.work + SIIS_CT_OFFSET + (SIIS_CT_SIZE * slot->slot)); in siis_execute_transaction()
1109 device_printf(ch->dev, "Setting up SATA FIS failed\n"); in siis_execute_transaction()
1110 if (!ch->recoverycmd) in siis_execute_transaction()
1111 xpt_freeze_simq(ch->sim, 1); in siis_execute_transaction()
1115 bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, in siis_execute_transaction()
1119 ch->rslots |= (1 << slot->slot); in siis_execute_transaction()
1120 prb_bus = ch->dma.work_bus + in siis_execute_transaction()
1122 ATA_OUTL(ch->r_mem, SIIS_P_CACTL(slot->slot), prb_bus); in siis_execute_transaction()
1123 ATA_OUTL(ch->r_mem, SIIS_P_CACTH(slot->slot), prb_bus >> 32); in siis_execute_transaction()
1134 struct siis_channel *ch = device_get_softc(dev); in siis_process_timeout() local
1137 mtx_assert(&ch->mtx, MA_OWNED); in siis_process_timeout()
1138 if (!ch->recoverycmd && !ch->recovery) { in siis_process_timeout()
1139 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_process_timeout()
1140 ch->recovery = 1; in siis_process_timeout()
1145 if (ch->slot[i].state < SIIS_SLOT_RUNNING) in siis_process_timeout()
1147 siis_end_transaction(&ch->slot[i], SIIS_ERR_TIMEOUT); in siis_process_timeout()
1155 struct siis_channel *ch = device_get_softc(dev); in siis_rearm_timeout() local
1158 mtx_assert(&ch->mtx, MA_OWNED); in siis_rearm_timeout()
1160 struct siis_slot *slot = &ch->slot[i]; in siis_rearm_timeout()
1165 if ((ch->toslots & (1 << i)) == 0) in siis_rearm_timeout()
1178 struct siis_channel *ch = device_get_softc(dev); in siis_timeout() local
1181 mtx_assert(&ch->mtx, MA_OWNED); in siis_timeout()
1190 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_timeout()
1197 __func__, ATA_INL(ch->r_mem, SIIS_P_IS), in siis_timeout()
1198 ATA_INL(ch->r_mem, SIIS_P_SS), ch->rslots, in siis_timeout()
1199 ATA_INL(ch->r_mem, SIIS_P_CMDERR), ATA_INL(ch->r_mem, SIIS_P_STS), in siis_timeout()
1200 ATA_INL(ch->r_mem, SIIS_P_SERR)); in siis_timeout()
1202 if (ch->toslots == 0) in siis_timeout()
1203 xpt_freeze_simq(ch->sim, 1); in siis_timeout()
1204 ch->toslots |= (1 << slot->slot); in siis_timeout()
1205 if ((ch->rslots & ~ch->toslots) == 0) in siis_timeout()
1209 ch->rslots & ~ch->toslots); in siis_timeout()
1217 struct siis_channel *ch = device_get_softc(dev); in siis_end_transaction() local
1221 mtx_assert(&ch->mtx, MA_OWNED); in siis_end_transaction()
1222 bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, in siis_end_transaction()
1234 res->status = ATA_INB(ch->r_mem, offs + 2); in siis_end_transaction()
1235 res->error = ATA_INB(ch->r_mem, offs + 3); in siis_end_transaction()
1236 res->lba_low = ATA_INB(ch->r_mem, offs + 4); in siis_end_transaction()
1237 res->lba_mid = ATA_INB(ch->r_mem, offs + 5); in siis_end_transaction()
1238 res->lba_high = ATA_INB(ch->r_mem, offs + 6); in siis_end_transaction()
1239 res->device = ATA_INB(ch->r_mem, offs + 7); in siis_end_transaction()
1240 res->lba_low_exp = ATA_INB(ch->r_mem, offs + 8); in siis_end_transaction()
1241 res->lba_mid_exp = ATA_INB(ch->r_mem, offs + 9); in siis_end_transaction()
1242 res->lba_high_exp = ATA_INB(ch->r_mem, offs + 10); in siis_end_transaction()
1243 res->sector_count = ATA_INB(ch->r_mem, offs + 12); in siis_end_transaction()
1244 res->sector_count_exp = ATA_INB(ch->r_mem, offs + 13); in siis_end_transaction()
1248 ch->numrslots == 1) { in siis_end_transaction()
1250 ATA_INL(ch->r_mem, SIIS_P_LRAM_SLOT(slot->slot) + 4); in siis_end_transaction()
1254 ch->numrslots == 1) { in siis_end_transaction()
1256 ATA_INL(ch->r_mem, SIIS_P_LRAM_SLOT(slot->slot) + 4); in siis_end_transaction()
1260 bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map, in siis_end_transaction()
1263 bus_dmamap_unload(ch->dma.data_tag, slot->dma.data_map); in siis_end_transaction()
1266 if (et != SIIS_ERR_NONE || ch->recovery) { in siis_end_transaction()
1267 ch->eslots |= (1 << slot->slot); in siis_end_transaction()
1271 if (et != SIIS_ERR_NONE && (!ch->recoverycmd) && in siis_end_transaction()
1284 ch->fatalerr = 1; in siis_end_transaction()
1300 ch->fatalerr = 1; in siis_end_transaction()
1304 ch->fatalerr = 1; in siis_end_transaction()
1311 ch->oslots &= ~(1 << slot->slot); in siis_end_transaction()
1312 ch->rslots &= ~(1 << slot->slot); in siis_end_transaction()
1313 ch->aslots &= ~(1 << slot->slot); in siis_end_transaction()
1317 ch->numrslots--; in siis_end_transaction()
1320 ch->numtslots[ccb->ccb_h.target_id]--; in siis_end_transaction()
1324 lastto = (ch->toslots == (1 << slot->slot)); in siis_end_transaction()
1325 ch->toslots &= ~(1 << slot->slot); in siis_end_transaction()
1327 xpt_release_simq(ch->sim, TRUE); in siis_end_transaction()
1339 ch->hold[slot->slot] = ccb; in siis_end_transaction()
1340 ch->numhslots++; in siis_end_transaction()
1344 if (ch->rslots == 0) { in siis_end_transaction()
1346 if (ch->toslots != 0 || ch->fatalerr) { in siis_end_transaction()
1350 if (ch->eslots != 0) in siis_end_transaction()
1353 if (!ch->recoverycmd && ch->numhslots) in siis_end_transaction()
1357 } else if ((ch->rslots & ~ch->toslots) == 0 && in siis_end_transaction()
1361 if (ch->frozen && !siis_check_collision(dev, ch->frozen)) { in siis_end_transaction()
1362 union ccb *fccb = ch->frozen; in siis_end_transaction()
1363 ch->frozen = NULL; in siis_end_transaction()
1365 xpt_release_simq(ch->sim, TRUE); in siis_end_transaction()
1372 struct siis_channel *ch = device_get_softc(dev); in siis_issue_recovery() local
1380 if (ch->hold[i]) in siis_issue_recovery()
1391 if (ch->hold[i] == NULL) in siis_issue_recovery()
1393 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_issue_recovery()
1394 ch->hold[i]->ccb_h.status |= CAM_RESRC_UNAVAIL; in siis_issue_recovery()
1395 xpt_done(ch->hold[i]); in siis_issue_recovery()
1396 ch->hold[i] = NULL; in siis_issue_recovery()
1397 ch->numhslots--; in siis_issue_recovery()
1402 ccb->ccb_h = ch->hold[i]->ccb_h; /* Reuse old header. */ in siis_issue_recovery()
1435 csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data; in siis_issue_recovery()
1436 csio->dxfer_len = ch->hold[i]->csio.sense_len; in siis_issue_recovery()
1442 ch->recoverycmd = 1; in siis_issue_recovery()
1449 struct siis_channel *ch = device_get_softc(dev); in siis_process_read_log() local
1454 ch->recoverycmd = 0; in siis_process_read_log()
1459 if (!ch->hold[i]) in siis_process_read_log()
1461 if (ch->hold[i]->ccb_h.target_id != ccb->ccb_h.target_id) in siis_process_read_log()
1464 res = &ch->hold[i]->ataio.res; in siis_process_read_log()
1477 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_process_read_log()
1478 ch->hold[i]->ccb_h.status |= CAM_REQUEUE_REQ; in siis_process_read_log()
1480 xpt_done(ch->hold[i]); in siis_process_read_log()
1481 ch->hold[i] = NULL; in siis_process_read_log()
1482 ch->numhslots--; in siis_process_read_log()
1491 if (!ch->hold[i]) in siis_process_read_log()
1493 if (ch->hold[i]->ccb_h.target_id != ccb->ccb_h.target_id) in siis_process_read_log()
1495 xpt_done(ch->hold[i]); in siis_process_read_log()
1496 ch->hold[i] = NULL; in siis_process_read_log()
1497 ch->numhslots--; in siis_process_read_log()
1507 struct siis_channel *ch = device_get_softc(dev); in siis_process_request_sense() local
1510 ch->recoverycmd = 0; in siis_process_request_sense()
1514 ch->hold[i]->ccb_h.status |= CAM_AUTOSNS_VALID; in siis_process_request_sense()
1516 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_process_request_sense()
1517 ch->hold[i]->ccb_h.status |= CAM_AUTOSENSE_FAIL; in siis_process_request_sense()
1519 xpt_done(ch->hold[i]); in siis_process_request_sense()
1520 ch->hold[i] = NULL; in siis_process_request_sense()
1521 ch->numhslots--; in siis_process_request_sense()
1528 struct siis_channel *ch = device_get_softc(dev); in siis_portinit() local
1531 ch->eslots = 0; in siis_portinit()
1532 ch->recovery = 0; in siis_portinit()
1533 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_RESUME); in siis_portinit()
1535 ATA_OUTL(ch->r_mem, SIIS_P_PMPSTS(i), 0), in siis_portinit()
1536 ATA_OUTL(ch->r_mem, SIIS_P_PMPQACT(i), 0); in siis_portinit()
1538 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_INIT); in siis_portinit()
1545 struct siis_channel *ch = device_get_softc(dev); in siis_devreset() local
1549 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_DEV_RESET); in siis_devreset()
1550 while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) & in siis_devreset()
1565 struct siis_channel *ch = device_get_softc(dev); in siis_wait_ready() local
1569 while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) & in siis_wait_ready()
1584 struct siis_channel *ch = device_get_softc(dev); in siis_reset() local
1588 xpt_freeze_simq(ch->sim, 1); in siis_reset()
1591 if (!ch->recoverycmd && !ch->recovery) in siis_reset()
1592 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_reset()
1594 if (ch->frozen) { in siis_reset()
1595 union ccb *fccb = ch->frozen; in siis_reset()
1596 ch->frozen = NULL; in siis_reset()
1608 if (ch->slot[i].state < SIIS_SLOT_RUNNING) in siis_reset()
1611 siis_end_transaction(&ch->slot[i], SIIS_ERR_INNOCENT); in siis_reset()
1615 if (!ch->hold[i]) in siis_reset()
1617 xpt_done(ch->hold[i]); in siis_reset()
1618 ch->hold[i] = NULL; in siis_reset()
1619 ch->numhslots--; in siis_reset()
1621 if (ch->toslots != 0) in siis_reset()
1622 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1623 ch->eslots = 0; in siis_reset()
1624 ch->recovery = 0; in siis_reset()
1625 ch->toslots = 0; in siis_reset()
1626 ch->fatalerr = 0; in siis_reset()
1628 ATA_OUTL(ch->r_mem, SIIS_P_IECLR, 0x0000FFFF); in siis_reset()
1630 sata_rev = ch->user[ch->pm_present ? 15 : 0].revision; in siis_reset()
1639 ATA_OUTL(ch->r_mem, SIIS_P_SCTL, in siis_reset()
1640 ATA_SC_DET_IDLE | val | ((ch->pm_level > 0) ? 0 : in siis_reset()
1645 if (!siis_sata_connect(ch)) { in siis_reset()
1646 ch->devices = 0; in siis_reset()
1648 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_reset()
1653 xpt_async(AC_BUS_RESET, ch->path, NULL); in siis_reset()
1654 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1663 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_RESET); in siis_reset()
1666 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PORT_RESET); in siis_reset()
1667 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_32BIT); in siis_reset()
1668 if (ch->pm_present) in siis_reset()
1669 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siis_reset()
1671 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siis_reset()
1677 ch->devices = 1; in siis_reset()
1679 ATA_OUTL(ch->r_mem, SIIS_P_IS, 0xFFFFFFFF); in siis_reset()
1680 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_reset()
1682 device_printf(dev, "SIIS reset done: devices=%08x\n", ch->devices); in siis_reset()
1684 xpt_async(AC_BUS_RESET, ch->path, NULL); in siis_reset()
1685 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1691 struct siis_channel *ch = device_get_softc(dev); in siis_setup_fis() local
1701 ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA) in siis_setup_fis()
1746 siis_sata_connect(struct siis_channel *ch) in siis_sata_connect() argument
1753 status = ATA_INL(ch->r_mem, SIIS_P_SSTS); in siis_sata_connect()
1762 device_printf(ch->dev, "SATA offline status=%08x\n", in siis_sata_connect()
1773 device_printf(ch->dev, in siis_sata_connect()
1780 device_printf(ch->dev, "SATA connect time=%dus status=%08x\n", in siis_sata_connect()
1784 ATA_OUTL(ch->r_mem, SIIS_P_SERR, 0xffffffff); in siis_sata_connect()
1809 struct siis_channel *ch; in siisaction() local
1814 ch = (struct siis_channel *)cam_sim_softc(sim); in siisaction()
1815 dev = ch->dev; in siisaction()
1816 mtx_assert(&ch->mtx, MA_OWNED); in siisaction()
1823 if (ch->devices == 0 || in siisaction()
1824 (ch->pm_present == 0 && in siisaction()
1833 ch->frozen = ccb; in siisaction()
1835 xpt_freeze_simq(ch->sim, 1); in siisaction()
1852 d = &ch->curr[ccb->ccb_h.target_id]; in siisaction()
1854 d = &ch->user[ccb->ccb_h.target_id]; in siisaction()
1864 ch->pm_present = cts->xport_specific.sata.pm_present; in siisaction()
1865 if (ch->pm_present) in siisaction()
1866 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siisaction()
1868 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siisaction()
1887 d = &ch->curr[ccb->ccb_h.target_id]; in siisaction()
1889 d = &ch->user[ccb->ccb_h.target_id]; in siisaction()
1898 (ccb->ccb_h.target_id == 0 && !ch->pm_present))) { in siisaction()
1899 status = ATA_INL(ch->r_mem, SIIS_P_SSTS) & ATA_SS_SPD_MASK; in siisaction()
1907 if (ch->pm_level) in siisaction()
1911 ch->user[ccb->ccb_h.target_id].caps; in siisaction()
1918 (ch->quirks & SIIS_Q_SNTF) == 0) in siisaction()
1926 cts->xport_specific.sata.pm_present = ch->pm_present; in siisaction()
1986 struct siis_channel *ch = (struct siis_channel *)cam_sim_softc(sim); in siispoll() local
1988 siis_ch_intr(ch->dev); in siispoll()