Lines Matching refs:ch

86 static int siis_sata_connect(struct siis_channel *ch);
460 struct siis_channel *ch = device_get_softc(dev); in siis_ch_attach() local
464 ch->dev = dev; in siis_ch_attach()
465 ch->unit = (intptr_t)device_get_ivars(dev); in siis_ch_attach()
466 ch->quirks = ctlr->quirks; in siis_ch_attach()
467 ch->pm_level = 0; in siis_ch_attach()
469 device_get_unit(dev), "pm_level", &ch->pm_level); in siis_ch_attach()
473 ch->user[i].revision = sata_rev; in siis_ch_attach()
474 ch->user[i].mode = 0; in siis_ch_attach()
475 ch->user[i].bytecount = 8192; in siis_ch_attach()
476 ch->user[i].tags = SIIS_MAX_SLOTS; in siis_ch_attach()
477 ch->curr[i] = ch->user[i]; in siis_ch_attach()
478 if (ch->pm_level) in siis_ch_attach()
479 ch->user[i].caps = CTS_SATA_CAPS_H_PMREQ; in siis_ch_attach()
480 ch->user[i].caps |= CTS_SATA_CAPS_H_AN; in siis_ch_attach()
482 mtx_init(&ch->mtx, "SIIS channel lock", NULL, MTX_DEF); in siis_ch_attach()
483 rid = ch->unit; in siis_ch_attach()
484 if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in siis_ch_attach()
490 mtx_lock(&ch->mtx); in siis_ch_attach()
492 if (!(ch->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in siis_ch_attach()
498 if ((bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL, in siis_ch_attach()
499 siis_ch_intr_locked, dev, &ch->ih))) { in siis_ch_attach()
512 ch->sim = cam_sim_alloc(siisaction, siispoll, "siisch", ch, in siis_ch_attach()
513 device_get_unit(dev), &ch->mtx, 2, SIIS_MAX_SLOTS, devq); in siis_ch_attach()
514 if (ch->sim == NULL) { in siis_ch_attach()
520 if (xpt_bus_register(ch->sim, dev, 0) != CAM_SUCCESS) { in siis_ch_attach()
525 if (xpt_create_path(&ch->path, /*periph*/NULL, cam_sim_path(ch->sim), in siis_ch_attach()
531 mtx_unlock(&ch->mtx); in siis_ch_attach()
532 ch->led = led_create(siis_ch_led, dev, device_get_nameunit(dev)); in siis_ch_attach()
536 xpt_bus_deregister(cam_sim_path(ch->sim)); in siis_ch_attach()
538 cam_sim_free(ch->sim, /*free_devq*/TRUE); in siis_ch_attach()
540 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); in siis_ch_attach()
542 bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); in siis_ch_attach()
543 mtx_unlock(&ch->mtx); in siis_ch_attach()
544 mtx_destroy(&ch->mtx); in siis_ch_attach()
551 struct siis_channel *ch = device_get_softc(dev); in siis_ch_detach() local
553 led_destroy(ch->led); in siis_ch_detach()
554 mtx_lock(&ch->mtx); in siis_ch_detach()
555 xpt_async(AC_LOST_DEVICE, ch->path, NULL); in siis_ch_detach()
556 xpt_free_path(ch->path); in siis_ch_detach()
557 xpt_bus_deregister(cam_sim_path(ch->sim)); in siis_ch_detach()
558 cam_sim_free(ch->sim, /*free_devq*/TRUE); in siis_ch_detach()
559 mtx_unlock(&ch->mtx); in siis_ch_detach()
561 bus_teardown_intr(dev, ch->r_irq, ch->ih); in siis_ch_detach()
562 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); in siis_ch_detach()
568 bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); in siis_ch_detach()
569 mtx_destroy(&ch->mtx); in siis_ch_detach()
576 struct siis_channel *ch = device_get_softc(dev); in siis_ch_init() local
579 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PORT_RESET); in siis_ch_init()
580 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_32BIT); in siis_ch_init()
581 if (ch->pm_present) in siis_ch_init()
582 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siis_ch_init()
584 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siis_ch_init()
586 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_ch_init()
593 struct siis_channel *ch = device_get_softc(dev); in siis_ch_deinit() local
596 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_RESET); in siis_ch_deinit()
603 struct siis_channel *ch = device_get_softc(dev); in siis_ch_suspend() local
605 mtx_lock(&ch->mtx); in siis_ch_suspend()
606 xpt_freeze_simq(ch->sim, 1); in siis_ch_suspend()
607 while (ch->oslots) in siis_ch_suspend()
608 msleep(ch, &ch->mtx, PRIBIO, "siissusp", hz/100); in siis_ch_suspend()
610 mtx_unlock(&ch->mtx); in siis_ch_suspend()
617 struct siis_channel *ch = device_get_softc(dev); in siis_ch_resume() local
619 mtx_lock(&ch->mtx); in siis_ch_resume()
622 xpt_release_simq(ch->sim, TRUE); in siis_ch_resume()
623 mtx_unlock(&ch->mtx); in siis_ch_resume()
648 struct siis_channel *ch; in siis_ch_led() local
651 ch = device_get_softc(dev); in siis_ch_led()
654 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_LED_ON); in siis_ch_led()
656 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_LED_ON); in siis_ch_led()
667 struct siis_channel *ch = device_get_softc(dev); in siis_dmainit() local
674 0, NULL, NULL, &ch->dma.work_tag)) in siis_dmainit()
676 if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work, 0, in siis_dmainit()
677 &ch->dma.work_map)) in siis_dmainit()
679 if (bus_dmamap_load(ch->dma.work_tag, ch->dma.work_map, ch->dma.work, in siis_dmainit()
681 bus_dmamem_free(ch->dma.work_tag, ch->dma.work, ch->dma.work_map); in siis_dmainit()
684 ch->dma.work_bus = dcba.maddr; in siis_dmainit()
690 0, busdma_lock_mutex, &ch->mtx, &ch->dma.data_tag)) { in siis_dmainit()
712 struct siis_channel *ch = device_get_softc(dev); in siis_dmafini() local
714 if (ch->dma.data_tag) { in siis_dmafini()
715 bus_dma_tag_destroy(ch->dma.data_tag); in siis_dmafini()
716 ch->dma.data_tag = NULL; in siis_dmafini()
718 if (ch->dma.work_bus) { in siis_dmafini()
719 bus_dmamap_unload(ch->dma.work_tag, ch->dma.work_map); in siis_dmafini()
720 bus_dmamem_free(ch->dma.work_tag, ch->dma.work, ch->dma.work_map); in siis_dmafini()
721 ch->dma.work_bus = 0; in siis_dmafini()
722 ch->dma.work_map = NULL; in siis_dmafini()
723 ch->dma.work = NULL; in siis_dmafini()
725 if (ch->dma.work_tag) { in siis_dmafini()
726 bus_dma_tag_destroy(ch->dma.work_tag); in siis_dmafini()
727 ch->dma.work_tag = NULL; in siis_dmafini()
734 struct siis_channel *ch = device_get_softc(dev); in siis_slotsalloc() local
738 bzero(ch->slot, sizeof(ch->slot)); in siis_slotsalloc()
740 struct siis_slot *slot = &ch->slot[i]; in siis_slotsalloc()
747 callout_init_mtx(&slot->timeout, &ch->mtx, 0); in siis_slotsalloc()
749 if (bus_dmamap_create(ch->dma.data_tag, 0, &slot->dma.data_map)) in siis_slotsalloc()
750 device_printf(ch->dev, "FAILURE - create data_map\n"); in siis_slotsalloc()
757 struct siis_channel *ch = device_get_softc(dev); in siis_slotsfree() local
762 struct siis_slot *slot = &ch->slot[i]; in siis_slotsfree()
766 bus_dmamap_destroy(ch->dma.data_tag, slot->dma.data_map); in siis_slotsfree()
775 struct siis_channel *ch = device_get_softc(dev); in siis_notify_events() local
780 if (ch->quirks & SIIS_Q_SNTF) { in siis_notify_events()
781 status = ATA_INL(ch->r_mem, SIIS_P_SNTF); in siis_notify_events()
782 ATA_OUTL(ch->r_mem, SIIS_P_SNTF, status); in siis_notify_events()
788 status = (ch->pm_present) ? 0x8000 : 0x0001; in siis_notify_events()
796 xpt_path_path_id(ch->path), i, 0) == CAM_REQ_CMP) { in siis_notify_events()
807 struct siis_channel *ch = device_get_softc(dev); in siis_phy_check_events() local
810 if (ch->pm_level == 0) { in siis_phy_check_events()
811 u_int32_t status = ATA_INL(ch->r_mem, SIIS_P_SSTS); in siis_phy_check_events()
826 cam_sim_path(ch->sim), in siis_phy_check_events()
839 struct siis_channel *ch = device_get_softc(dev); in siis_ch_intr_locked() local
841 mtx_lock(&ch->mtx); in siis_ch_intr_locked()
843 mtx_unlock(&ch->mtx); in siis_ch_intr_locked()
850 struct siis_channel *ch = device_get_softc(dev); in siis_ch_intr() local
855 mtx_assert(&ch->mtx, MA_OWNED); in siis_ch_intr()
857 sstatus = ATA_INL(ch->r_mem, SIIS_P_SS); in siis_ch_intr()
858 ok = ch->rslots & ~sstatus; in siis_ch_intr()
862 siis_end_transaction(&ch->slot[i], SIIS_ERR_NONE); in siis_ch_intr()
868 istatus = ATA_INL(ch->r_mem, SIIS_P_IS) & in siis_ch_intr()
870 ATA_OUTL(ch->r_mem, SIIS_P_IS, istatus); in siis_ch_intr()
879 estatus = ATA_INL(ch->r_mem, SIIS_P_CMDERR); in siis_ch_intr()
880 ctx = ATA_INL(ch->r_mem, SIIS_P_CTX); in siis_ch_intr()
887 if (!ch->recoverycmd && !ch->recovery) { in siis_ch_intr()
888 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_ch_intr()
889 ch->recovery = 1; in siis_ch_intr()
891 if (ch->frozen) { in siis_ch_intr()
892 union ccb *fccb = ch->frozen; in siis_ch_intr()
893 ch->frozen = NULL; in siis_ch_intr()
905 tslots = ch->numtslots[port]; in siis_ch_intr()
908 if (((ch->rslots >> i) & 1) == 0) in siis_ch_intr()
910 if (ch->slot[i].ccb->ccb_h.target_id != port) in siis_ch_intr()
922 siis_end_transaction(&ch->slot[i], et); in siis_ch_intr()
928 if (ch->rslots != 0 && !ch->recoverycmd) in siis_ch_intr()
929 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_RESUME); in siis_ch_intr()
940 if (((ch->rslots >> i) & 1) == 0) in siis_ch_intr()
942 siis_end_transaction(&ch->slot[i], et); in siis_ch_intr()
952 struct siis_channel *ch = device_get_softc(dev); in siis_check_collision() local
954 mtx_assert(&ch->mtx, MA_OWNED); in siis_check_collision()
958 if (((~ch->oslots) & (0x7fffffff >> (31 - in siis_check_collision()
959 ch->curr[ccb->ccb_h.target_id].tags))) == 0) in siis_check_collision()
965 if (ch->numrslots != 0) in siis_check_collision()
969 if (ch->aslots != 0) in siis_check_collision()
978 struct siis_channel *ch = device_get_softc(dev); in siis_begin_transaction() local
982 mtx_assert(&ch->mtx, MA_OWNED); in siis_begin_transaction()
987 tags = ch->curr[ccb->ccb_h.target_id].tags; in siis_begin_transaction()
988 tag = fls((~ch->oslots) & (0x7fffffff >> (31 - tags))) - 1; in siis_begin_transaction()
990 slot = &ch->slot[tag]; in siis_begin_transaction()
993 ch->oslots |= (1 << slot->slot); in siis_begin_transaction()
994 ch->numrslots++; in siis_begin_transaction()
997 ch->numtslots[ccb->ccb_h.target_id]++; in siis_begin_transaction()
1001 ch->aslots |= (1 << slot->slot); in siis_begin_transaction()
1006 bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, in siis_begin_transaction()
1017 struct siis_channel *ch = device_get_softc(slot->dev); in siis_dmasetprd() local
1022 mtx_assert(&ch->mtx, MA_OWNED); in siis_dmasetprd()
1025 if (!ch->recoverycmd) in siis_dmasetprd()
1026 xpt_freeze_simq(ch->sim, 1); in siis_dmasetprd()
1034 ctp = (struct siis_cmd *)(ch->dma.work + slot->prb_offset); in siis_dmasetprd()
1046 bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map, in siis_dmasetprd()
1058 struct siis_channel *ch = device_get_softc(dev); in siis_execute_transaction() local
1063 mtx_assert(&ch->mtx, MA_OWNED); in siis_execute_transaction()
1065 ctp = (struct siis_cmd *)(ch->dma.work + slot->prb_offset); in siis_execute_transaction()
1104 device_printf(ch->dev, "Setting up SATA FIS failed\n"); in siis_execute_transaction()
1105 if (!ch->recoverycmd) in siis_execute_transaction()
1106 xpt_freeze_simq(ch->sim, 1); in siis_execute_transaction()
1110 bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, in siis_execute_transaction()
1114 ch->rslots |= (1 << slot->slot); in siis_execute_transaction()
1115 prb_bus = ch->dma.work_bus + slot->prb_offset; in siis_execute_transaction()
1116 ATA_OUTL(ch->r_mem, SIIS_P_CACTL(slot->slot), prb_bus); in siis_execute_transaction()
1117 ATA_OUTL(ch->r_mem, SIIS_P_CACTH(slot->slot), prb_bus >> 32); in siis_execute_transaction()
1128 struct siis_channel *ch = device_get_softc(dev); in siis_process_timeout() local
1131 mtx_assert(&ch->mtx, MA_OWNED); in siis_process_timeout()
1132 if (!ch->recoverycmd && !ch->recovery) { in siis_process_timeout()
1133 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_process_timeout()
1134 ch->recovery = 1; in siis_process_timeout()
1139 if (ch->slot[i].state < SIIS_SLOT_RUNNING) in siis_process_timeout()
1141 siis_end_transaction(&ch->slot[i], SIIS_ERR_TIMEOUT); in siis_process_timeout()
1149 struct siis_channel *ch = device_get_softc(dev); in siis_rearm_timeout() local
1152 mtx_assert(&ch->mtx, MA_OWNED); in siis_rearm_timeout()
1154 struct siis_slot *slot = &ch->slot[i]; in siis_rearm_timeout()
1159 if ((ch->toslots & (1 << i)) == 0) in siis_rearm_timeout()
1173 struct siis_channel *ch = device_get_softc(dev); in siis_timeout() local
1176 mtx_assert(&ch->mtx, MA_OWNED); in siis_timeout()
1185 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_timeout()
1192 __func__, ATA_INL(ch->r_mem, SIIS_P_IS), in siis_timeout()
1193 ATA_INL(ch->r_mem, SIIS_P_SS), ch->rslots, in siis_timeout()
1194 ATA_INL(ch->r_mem, SIIS_P_CMDERR), ATA_INL(ch->r_mem, SIIS_P_STS), in siis_timeout()
1195 ATA_INL(ch->r_mem, SIIS_P_SERR)); in siis_timeout()
1197 if (ch->toslots == 0) in siis_timeout()
1198 xpt_freeze_simq(ch->sim, 1); in siis_timeout()
1199 ch->toslots |= (1 << slot->slot); in siis_timeout()
1200 if ((ch->rslots & ~ch->toslots) == 0) in siis_timeout()
1204 ch->rslots & ~ch->toslots); in siis_timeout()
1212 struct siis_channel *ch = device_get_softc(dev); in siis_end_transaction() local
1216 mtx_assert(&ch->mtx, MA_OWNED); in siis_end_transaction()
1217 bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, in siis_end_transaction()
1229 res->status = ATA_INB(ch->r_mem, offs + 2); in siis_end_transaction()
1230 res->error = ATA_INB(ch->r_mem, offs + 3); in siis_end_transaction()
1231 res->lba_low = ATA_INB(ch->r_mem, offs + 4); in siis_end_transaction()
1232 res->lba_mid = ATA_INB(ch->r_mem, offs + 5); in siis_end_transaction()
1233 res->lba_high = ATA_INB(ch->r_mem, offs + 6); in siis_end_transaction()
1234 res->device = ATA_INB(ch->r_mem, offs + 7); in siis_end_transaction()
1235 res->lba_low_exp = ATA_INB(ch->r_mem, offs + 8); in siis_end_transaction()
1236 res->lba_mid_exp = ATA_INB(ch->r_mem, offs + 9); in siis_end_transaction()
1237 res->lba_high_exp = ATA_INB(ch->r_mem, offs + 10); in siis_end_transaction()
1238 res->sector_count = ATA_INB(ch->r_mem, offs + 12); in siis_end_transaction()
1239 res->sector_count_exp = ATA_INB(ch->r_mem, offs + 13); in siis_end_transaction()
1243 ch->numrslots == 1) { in siis_end_transaction()
1245 ATA_INL(ch->r_mem, SIIS_P_LRAM_SLOT(slot->slot) + 4); in siis_end_transaction()
1249 ch->numrslots == 1) { in siis_end_transaction()
1251 ATA_INL(ch->r_mem, SIIS_P_LRAM_SLOT(slot->slot) + 4); in siis_end_transaction()
1255 bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map, in siis_end_transaction()
1258 bus_dmamap_unload(ch->dma.data_tag, slot->dma.data_map); in siis_end_transaction()
1261 if (et != SIIS_ERR_NONE || ch->recovery) { in siis_end_transaction()
1262 ch->eslots |= (1 << slot->slot); in siis_end_transaction()
1266 if (et != SIIS_ERR_NONE && (!ch->recoverycmd) && in siis_end_transaction()
1279 ch->fatalerr = 1; in siis_end_transaction()
1295 ch->fatalerr = 1; in siis_end_transaction()
1299 ch->fatalerr = 1; in siis_end_transaction()
1306 ch->oslots &= ~(1 << slot->slot); in siis_end_transaction()
1307 ch->rslots &= ~(1 << slot->slot); in siis_end_transaction()
1308 ch->aslots &= ~(1 << slot->slot); in siis_end_transaction()
1312 ch->numrslots--; in siis_end_transaction()
1315 ch->numtslots[ccb->ccb_h.target_id]--; in siis_end_transaction()
1319 lastto = (ch->toslots == (1 << slot->slot)); in siis_end_transaction()
1320 ch->toslots &= ~(1 << slot->slot); in siis_end_transaction()
1322 xpt_release_simq(ch->sim, TRUE); in siis_end_transaction()
1334 ch->hold[slot->slot] = ccb; in siis_end_transaction()
1335 ch->numhslots++; in siis_end_transaction()
1339 if (ch->rslots == 0) { in siis_end_transaction()
1341 if (ch->toslots != 0 || ch->fatalerr) { in siis_end_transaction()
1345 if (ch->eslots != 0) in siis_end_transaction()
1348 if (!ch->recoverycmd && ch->numhslots) in siis_end_transaction()
1352 } else if ((ch->rslots & ~ch->toslots) == 0 && in siis_end_transaction()
1356 if (ch->frozen && !siis_check_collision(dev, ch->frozen)) { in siis_end_transaction()
1357 union ccb *fccb = ch->frozen; in siis_end_transaction()
1358 ch->frozen = NULL; in siis_end_transaction()
1360 xpt_release_simq(ch->sim, TRUE); in siis_end_transaction()
1367 struct siis_channel *ch = device_get_softc(dev); in siis_issue_recovery() local
1375 if (ch->hold[i]) in siis_issue_recovery()
1386 if (ch->hold[i] == NULL) in siis_issue_recovery()
1388 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_issue_recovery()
1389 ch->hold[i]->ccb_h.status |= CAM_RESRC_UNAVAIL; in siis_issue_recovery()
1390 xpt_done(ch->hold[i]); in siis_issue_recovery()
1391 ch->hold[i] = NULL; in siis_issue_recovery()
1392 ch->numhslots--; in siis_issue_recovery()
1397 xpt_setup_ccb(&ccb->ccb_h, ch->hold[i]->ccb_h.path, in siis_issue_recovery()
1398 ch->hold[i]->ccb_h.pinfo.priority); in siis_issue_recovery()
1431 csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data; in siis_issue_recovery()
1432 csio->dxfer_len = ch->hold[i]->csio.sense_len; in siis_issue_recovery()
1438 ch->recoverycmd = 1; in siis_issue_recovery()
1445 struct siis_channel *ch = device_get_softc(dev); in siis_process_read_log() local
1450 ch->recoverycmd = 0; in siis_process_read_log()
1455 if (!ch->hold[i]) in siis_process_read_log()
1457 if (ch->hold[i]->ccb_h.target_id != ccb->ccb_h.target_id) in siis_process_read_log()
1460 res = &ch->hold[i]->ataio.res; in siis_process_read_log()
1473 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_process_read_log()
1474 ch->hold[i]->ccb_h.status |= CAM_REQUEUE_REQ; in siis_process_read_log()
1476 xpt_done(ch->hold[i]); in siis_process_read_log()
1477 ch->hold[i] = NULL; in siis_process_read_log()
1478 ch->numhslots--; in siis_process_read_log()
1487 if (!ch->hold[i]) in siis_process_read_log()
1489 if (ch->hold[i]->ccb_h.target_id != ccb->ccb_h.target_id) in siis_process_read_log()
1491 xpt_done(ch->hold[i]); in siis_process_read_log()
1492 ch->hold[i] = NULL; in siis_process_read_log()
1493 ch->numhslots--; in siis_process_read_log()
1503 struct siis_channel *ch = device_get_softc(dev); in siis_process_request_sense() local
1506 ch->recoverycmd = 0; in siis_process_request_sense()
1510 ch->hold[i]->ccb_h.status |= CAM_AUTOSNS_VALID; in siis_process_request_sense()
1512 ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK; in siis_process_request_sense()
1513 ch->hold[i]->ccb_h.status |= CAM_AUTOSENSE_FAIL; in siis_process_request_sense()
1515 xpt_done(ch->hold[i]); in siis_process_request_sense()
1516 ch->hold[i] = NULL; in siis_process_request_sense()
1517 ch->numhslots--; in siis_process_request_sense()
1524 struct siis_channel *ch = device_get_softc(dev); in siis_portinit() local
1527 ch->eslots = 0; in siis_portinit()
1528 ch->recovery = 0; in siis_portinit()
1529 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_RESUME); in siis_portinit()
1531 ATA_OUTL(ch->r_mem, SIIS_P_PMPSTS(i), 0), in siis_portinit()
1532 ATA_OUTL(ch->r_mem, SIIS_P_PMPQACT(i), 0); in siis_portinit()
1534 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_INIT); in siis_portinit()
1541 struct siis_channel *ch = device_get_softc(dev); in siis_devreset() local
1545 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_DEV_RESET); in siis_devreset()
1546 while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) & in siis_devreset()
1561 struct siis_channel *ch = device_get_softc(dev); in siis_wait_ready() local
1565 while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) & in siis_wait_ready()
1580 struct siis_channel *ch = device_get_softc(dev); in siis_reset() local
1584 xpt_freeze_simq(ch->sim, 1); in siis_reset()
1587 if (!ch->recoverycmd && !ch->recovery) in siis_reset()
1588 xpt_freeze_simq(ch->sim, ch->numrslots); in siis_reset()
1590 if (ch->frozen) { in siis_reset()
1591 union ccb *fccb = ch->frozen; in siis_reset()
1592 ch->frozen = NULL; in siis_reset()
1604 if (ch->slot[i].state < SIIS_SLOT_RUNNING) in siis_reset()
1607 siis_end_transaction(&ch->slot[i], SIIS_ERR_INNOCENT); in siis_reset()
1611 if (!ch->hold[i]) in siis_reset()
1613 xpt_done(ch->hold[i]); in siis_reset()
1614 ch->hold[i] = NULL; in siis_reset()
1615 ch->numhslots--; in siis_reset()
1617 if (ch->toslots != 0) in siis_reset()
1618 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1619 ch->eslots = 0; in siis_reset()
1620 ch->recovery = 0; in siis_reset()
1621 ch->toslots = 0; in siis_reset()
1622 ch->fatalerr = 0; in siis_reset()
1624 ATA_OUTL(ch->r_mem, SIIS_P_IECLR, 0x0000FFFF); in siis_reset()
1626 sata_rev = ch->user[ch->pm_present ? 15 : 0].revision; in siis_reset()
1635 ATA_OUTL(ch->r_mem, SIIS_P_SCTL, in siis_reset()
1636 ATA_SC_DET_IDLE | val | ((ch->pm_level > 0) ? 0 : in siis_reset()
1641 if (!siis_sata_connect(ch)) { in siis_reset()
1642 ch->devices = 0; in siis_reset()
1644 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_reset()
1649 xpt_async(AC_BUS_RESET, ch->path, NULL); in siis_reset()
1650 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1659 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PORT_RESET); in siis_reset()
1662 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PORT_RESET); in siis_reset()
1663 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_32BIT); in siis_reset()
1664 if (ch->pm_present) in siis_reset()
1665 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siis_reset()
1667 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siis_reset()
1673 ch->devices = 1; in siis_reset()
1675 ATA_OUTL(ch->r_mem, SIIS_P_IS, 0xFFFFFFFF); in siis_reset()
1676 ATA_OUTL(ch->r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED); in siis_reset()
1678 device_printf(dev, "SIIS reset done: devices=%08x\n", ch->devices); in siis_reset()
1680 xpt_async(AC_BUS_RESET, ch->path, NULL); in siis_reset()
1681 xpt_release_simq(ch->sim, TRUE); in siis_reset()
1687 struct siis_channel *ch = device_get_softc(dev); in siis_setup_fis() local
1697 ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA) in siis_setup_fis()
1743 siis_sata_connect(struct siis_channel *ch) in siis_sata_connect() argument
1750 status = ATA_INL(ch->r_mem, SIIS_P_SSTS); in siis_sata_connect()
1759 device_printf(ch->dev, "SATA offline status=%08x\n", in siis_sata_connect()
1770 device_printf(ch->dev, in siis_sata_connect()
1777 device_printf(ch->dev, "SATA connect time=%dus status=%08x\n", in siis_sata_connect()
1781 ATA_OUTL(ch->r_mem, SIIS_P_SERR, 0xffffffff); in siis_sata_connect()
1806 struct siis_channel *ch; in siisaction() local
1811 ch = (struct siis_channel *)cam_sim_softc(sim); in siisaction()
1812 dev = ch->dev; in siisaction()
1813 mtx_assert(&ch->mtx, MA_OWNED); in siisaction()
1820 if (ch->devices == 0 || in siisaction()
1821 (ch->pm_present == 0 && in siisaction()
1830 ch->frozen = ccb; in siisaction()
1832 xpt_freeze_simq(ch->sim, 1); in siisaction()
1849 d = &ch->curr[ccb->ccb_h.target_id]; in siisaction()
1851 d = &ch->user[ccb->ccb_h.target_id]; in siisaction()
1861 ch->pm_present = cts->xport_specific.sata.pm_present; in siisaction()
1862 if (ch->pm_present) in siisaction()
1863 ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_PME); in siisaction()
1865 ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); in siisaction()
1884 d = &ch->curr[ccb->ccb_h.target_id]; in siisaction()
1886 d = &ch->user[ccb->ccb_h.target_id]; in siisaction()
1895 (ccb->ccb_h.target_id == 0 && !ch->pm_present))) { in siisaction()
1896 status = ATA_INL(ch->r_mem, SIIS_P_SSTS) & ATA_SS_SPD_MASK; in siisaction()
1904 if (ch->pm_level) in siisaction()
1908 ch->user[ccb->ccb_h.target_id].caps; in siisaction()
1915 (ch->quirks & SIIS_Q_SNTF) == 0) in siisaction()
1923 cts->xport_specific.sata.pm_present = ch->pm_present; in siisaction()
1983 struct siis_channel *ch = (struct siis_channel *)cam_sim_softc(sim); in siispoll() local
1985 siis_ch_intr(ch->dev); in siispoll()