Home | History | Annotate | Download | only in ic

Lines Matching defs:chp

205 wdc_sataprobe(struct ata_channel *chp)
207 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
208 struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
212 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL);
216 ata_channel_lock(chp);
219 switch (sata_reset_interface(chp, wdr->sata_iot, wdr->sata_control,
231 ata_delay(chp, 1, "sataprb", AT_WAIT);
234 aprint_error_dev(chp->ch_atac->atac_dev,
246 device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
248 if (atabus_alloc_drives(chp, wdc->wdc_maxdrives) != 0) {
249 ata_channel_unlock(chp);
257 chp->ch_drive[0].drive_type = ATA_DRIVET_ATAPI;
259 chp->ch_drive[0].drive_type = ATA_DRIVET_ATA;
265 if (wdcreset(chp, RESET_SLEEP) != 0)
266 chp->ch_drive[0].drive_type = ATA_DRIVET_NONE;
273 ata_channel_unlock(chp);
293 wdc_drvprobe(struct ata_channel *chp)
296 struct atac_softc *atac = chp->ch_atac;
297 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
298 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
302 ata_channel_lock(chp);
303 if (atabus_alloc_drives(chp, wdc->wdc_maxdrives) != 0) {
304 ata_channel_unlock(chp);
307 if (wdcprobe1(chp, 0) == 0) {
309 atabus_free_drives(chp);
310 ata_channel_unlock(chp);
320 if (chp->ch_ndrives > 1 &&
321 chp->ch_drive[1].drive_type == ATA_DRIVET_ATA) {
323 wdc->select(chp,1);
330 if (chp->ch_drive[0].drive_type == ATA_DRIVET_ATA) {
332 wdc->select(chp,0);
341 if ((chp->ch_drive[0].drive_type != ATA_DRIVET_ATA ||
343 (chp->ch_ndrives < 2 ||
344 chp->ch_drive[1].drive_type != ATA_DRIVET_ATA ||
353 ata_delay(chp, 1, "atadrdy", AT_WAIT);
357 chp->ch_drive[0].drive_type != ATA_DRIVET_ATAPI)
358 chp->ch_drive[0].drive_type = ATA_DRIVET_NONE;
359 if (chp->ch_ndrives > 1 && (st1 & WDCS_DRDY) == 0 &&
360 chp->ch_drive[1].drive_type != ATA_DRIVET_ATAPI)
361 chp->ch_drive[1].drive_type = ATA_DRIVET_NONE;
362 ata_channel_unlock(chp);
366 chp->ch_channel, st0, st1), DEBUG_PROBE);
371 for (i = 0; i < chp->ch_ndrives; i++) {
377 chp->ch_drive[i].n_dmaerrs = NERRS_MAX - 1;
383 ata_channel_lock(chp);
384 chp->ch_drive[i].drive_flags |= ATA_DRIVE_CAP32;
385 ata_channel_unlock(chp);
387 if (chp->ch_drive[i].drive_type == ATA_DRIVET_NONE)
391 if (chp->ch_flags & ATACH_SHUTDOWN)
400 error = ata_get_params(&chp->ch_drive[i],
403 ata_channel_lock(chp);
404 ata_delay(chp, 1000, "atacnf", AT_WAIT);
405 ata_channel_unlock(chp);
408 if (chp->ch_flags & ATACH_SHUTDOWN)
411 error = ata_get_params(&chp->ch_drive[i],
417 chp->ch_channel, i, error), DEBUG_PROBE);
418 ata_channel_lock(chp);
419 if (chp->ch_drive[i].drive_type != ATA_DRIVET_ATA ||
421 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE;
422 ata_channel_unlock(chp);
431 wdc->select(chp,i);
446 chp->ch_channel, i), DEBUG_PROBE);
447 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE;
448 ata_channel_unlock(chp);
451 if (wdc_wait_for_ready(chp, 10000, 0, &tfd) ==
455 chp->ch_channel, i), DEBUG_PROBE);
456 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE;
457 ata_channel_unlock(chp);
463 if (wdc_wait_for_ready(chp, 10000, 0, &tfd) ==
467 chp->ch_channel, i), DEBUG_PROBE);
468 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE;
469 ata_channel_unlock(chp);
471 for (j = 0; j < chp->ch_ndrives; j++) {
472 if (chp->ch_drive[i].drive_type !=
474 chp->ch_drive[j].drive_type =
478 ata_channel_unlock(chp);
522 wdcprobe1(struct ata_channel *chp, int poll)
524 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
525 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
541 wdc->select(chp,0);
550 wdc->select(chp,1);
562 __func__, chp->ch_channel, st0, st1), DEBUG_PROBE);
571 wdc->select(chp,0);
581 __func__, chp->ch_channel, cl),
592 __func__, chp->ch_channel, cl),
603 __func__, chp->ch_channel, cl),
614 __func__, chp->ch_channel, cl),
623 __func__, chp->ch_channel, cl),
631 wdc->select(chp,1);
641 __func__, chp->ch_channel, cl),
652 __func__, chp->ch_channel, cl),
663 __func__, chp->ch_channel, cl),
674 __func__, chp->ch_channel, cl),
683 __func__, chp->ch_channel, cl),
701 wdc->select(chp,0);
709 wdc->select(chp,0);
719 wdc->reset(chp, RESET_POLL);
728 ret_value = __wdcwait_reset(chp, ret_value, RESET_POLL);
730 ret_value = __wdcwait_reset(chp, ret_value, poll);
733 __func__, chp->ch_channel, ret_value), DEBUG_PROBE);
750 wdc->select(chp,drive);
765 "cl=0x%x ch=0x%x\n", __func__, chp->ch_channel, drive, sc,
771 if (chp->ch_drive != NULL) {
773 chp->ch_drive[drive].drive_type = ATA_DRIVET_ATAPI;
775 chp->ch_drive[drive].drive_type = ATA_DRIVET_ATA;
793 wdcattach(struct ata_channel *chp)
795 struct atac_softc *atac = chp->ch_atac;
796 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
819 ata_channel_attach(chp);
826 struct ata_channel *chp;
830 chp = atac->atac_channels[i];
831 if (child == chp->atabus) {
832 chp->atabus = NULL;
842 struct ata_channel *chp;
847 chp = atac->atac_channels[i];
848 if (chp->atabus == NULL)
851 device_xname(atac->atac_dev), device_xname(chp->atabus)),
853 if ((error = config_detach(chp->atabus, flags)) != 0)
855 ata_channel_detach(chp);
866 struct ata_channel *chp = v;
870 atastart(chp);
884 struct ata_channel *chp = arg;
885 struct atac_softc *atac = chp->ch_atac;
886 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
887 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
897 if ((chp->ch_flags & ATACH_IRQ_WAIT) == 0)
900 xfer = ata_queue_get_active_xfer(chp);
925 if (chp->ch_flags & ATACH_DMA_WAIT) {
927 (*wdc->dma_finish)(wdc->dma_arg, chp->ch_channel,
933 chp->ch_flags &= ~ATACH_DMA_WAIT;
936 chp->ch_flags &= ~ATACH_IRQ_WAIT;
938 ret = xfer->ops->c_intr(chp, xfer, 1);
940 chp->ch_flags |= ATACH_IRQ_WAIT;
948 struct ata_channel *chp = drvp->chnl_softc;
950 ata_channel_lock_owned(chp);
955 device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
958 ata_thread_run(chp, flags, ATACH_TH_RESET, ATACH_NODRIVE);
962 wdc_reset_channel(struct ata_channel *chp, int flags)
966 ata_channel_lock_owned(chp);
969 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
972 chp->ch_flags &= ~ATACH_IRQ_WAIT;
978 xfer = ata_queue_get_active_xfer_locked(chp);
980 if (xfer && xfer->c_chp == chp && (xfer->c_flags & C_ATAPI)) {
981 wdccommandshort(chp, xfer->c_drive, ATAPI_SOFT_RESET);
982 ata_delay(chp, 1000, "atardl", flags);
987 (void) wdcreset(chp, RESET_SLEEP);
989 (void) wdcreset(chp, RESET_POLL);
995 ata_delay(chp, 1000, "atardl", flags);
1004 if (xfer->c_chp != chp) {
1013 if (chp->ch_flags & ATACH_DMA_WAIT) {
1015 chp->ch_channel, xfer->c_drive,
1017 chp->ch_flags &= ~ATACH_DMA_WAIT;
1023 ata_kill_active(chp, KILL_RESET, flags);
1027 wdcreset(struct ata_channel *chp, int poll)
1029 struct atac_softc *atac = chp->ch_atac;
1030 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1031 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1034 ata_channel_lock_owned(chp);
1039 wdc->reset(chp, poll);
1041 drv_mask1 = (chp->ch_drive[0].drive_type != ATA_DRIVET_NONE)
1043 if (chp->ch_ndrives > 1)
1044 drv_mask1 |= (chp->ch_drive[1].drive_type != ATA_DRIVET_NONE)
1046 drv_mask2 = __wdcwait_reset(chp, drv_mask1,
1050 device_xname(atac->atac_dev), chp->ch_channel);
1065 wdc_do_reset(struct ata_channel *chp, int poll)
1067 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1068 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1074 wdc->select(chp,0);
1092 wdc->irqack(chp);
1098 __wdcwait_reset(struct ata_channel *chp, int drv_mask, int poll)
1100 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1101 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1117 wdc->select(chp,0);
1136 wdc->select(chp,1);
1176 ata_delay(chp, WDCDELAY, "atarst", wflags);
1186 device_xname(chp->ch_atac->atac_dev),
1187 chp->ch_channel, sc0, sn0, cl0, ch0), DEBUG_PROBE);
1190 device_xname(chp->ch_atac->atac_dev),
1191 chp->ch_channel, sc1, sn1, cl1, ch1), DEBUG_PROBE);
1194 device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
1205 __wdcwait(struct ata_channel *chp, int mask, int bits, int timeout, int *tfd)
1207 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1208 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1214 device_xname(chp->ch_atac->atac_dev),
1215 chp->ch_channel), DEBUG_STATUS);
1249 xfer = ata_queue_get_active_xfer_locked(chp);
1252 device_xname(chp->ch_atac->atac_dev),
1253 chp->ch_channel, WDCDELAY * xtime);
1256 device_xname(chp->ch_atac->atac_dev),
1257 chp->ch_channel, xfer->c_drive,
1273 wdcwait(struct ata_channel *chp, int mask, int bits, int timeout, int flags,
1278 ata_channel_lock_owned(chp);
1282 error = __wdcwait(chp, mask, bits, timeout, tfd);
1284 error = __wdcwait(chp, mask, bits, WDCDELAY_POLL, tfd);
1286 if (ata_is_thread_run(chp) || (flags & AT_WAIT)) {
1292 if (__wdcwait(chp, mask, bits,
1298 &chp->ch_lock);
1318 wdc_dmawait(struct ata_channel *chp, struct ata_xfer *xfer, int timeout)
1320 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1326 chp->ch_channel, xfer->c_drive, WDC_DMAEND_END);
1333 chp->ch_channel, xfer->c_drive, WDC_DMAEND_ABRT);
1342 struct ata_channel *chp = arg;
1344 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1352 callout_ack(&chp->c_timo_callout);
1354 if ((chp->ch_flags & ATACH_IRQ_WAIT) == 0) {
1355 __wdcerror(chp, "timeout not expected without pending irq");
1359 xfer = ata_queue_get_active_xfer(chp);
1367 __wdcerror(chp, "lost interrupt");
1372 if (chp->ch_flags & ATACH_DMA_WAIT) {
1374 (*wdc->dma_finish)(wdc->dma_arg, chp->ch_channel,
1376 chp->ch_flags &= ~ATACH_DMA_WAIT;
1385 chp->ch_flags &= ~ATACH_IRQ_WAIT;
1387 xfer->ops->c_intr(chp, xfer, 1);
1404 struct ata_channel *chp = drvp->chnl_softc;
1408 device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
1412 if (chp->ch_atac->atac_cap & ATAC_CAP_NOIRQ)
1423 ata_exec_xfer(chp, xfer);
1427 __wdccommand_start(struct ata_channel *chp, struct ata_xfer *xfer)
1429 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1430 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1437 device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
1441 wdc->select(chp,drive);
1444 switch(wdcwait(chp, ata_c->r_st_bmask | WDCS_DRQ,
1461 wdccommandext(chp, drive, ata_c->r_command,
1465 wdccommand(chp, drive, ata_c->r_command,
1476 chp->ch_flags |= ATACH_IRQ_WAIT; /* wait for interrupt */
1477 callout_reset(&chp->c_timo_callout, ata_c->timeout / 1000 * hz,
1478 wdctimeout, chp);
1491 __wdccommand_poll(struct ata_channel *chp, struct ata_xfer *xfer)
1493 __wdccommand_intr(chp, xfer, 0);
1498 __wdccommand_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq)
1500 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1501 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1517 chp->ch_drive[xfer->c_drive].drive_flags;
1523 drive_flags = chp->ch_drive[xfer->c_drive].drive_flags;
1537 ata_channel_lock(chp);
1541 device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
1558 if (wdcwait(chp, ata_c->r_st_bmask | WDCS_DRQ,
1562 ata_channel_unlock(chp);
1569 if (wdcwait(chp, ata_c->r_st_pmask, ata_c->r_st_pmask,
1572 ata_channel_unlock(chp);
1579 wdc->irqack(chp);
1585 wdc->datain_pio(chp, drive_flags, data, bcount);
1597 wdc->dataout_pio(chp, drive_flags, data, bcount);
1600 chp->ch_flags |= ATACH_IRQ_WAIT; /* wait for interrupt */
1601 callout_reset(&chp->c_timo_callout,
1602 mstohz(ata_c->timeout), wdctimeout, chp);
1603 ata_channel_unlock(chp);
1617 ata_channel_unlock(chp);
1619 __wdccommand_done(chp, xfer);
1624 __wdccommand_done(struct ata_channel *chp, struct ata_xfer *xfer)
1626 struct atac_softc *atac = chp->ch_atac;
1627 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1628 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1633 device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive,
1636 if (ata_waitdrain_xfer_check(chp, xfer)) {
1695 __wdccommand_done_end(chp, xfer);
1697 ata_deactivate_xfer(chp, xfer);
1709 atastart(chp);
1713 __wdccommand_done_end(struct ata_channel *chp, struct ata_xfer *xfer)
1721 __wdccommand_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer,
1743 __wdccommand_done_end(chp, xfer);
1746 ata_deactivate_xfer(chp, xfer);
1754 wdccommand(struct ata_channel *chp, u_int8_t drive, u_int8_t command,
1758 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1759 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1763 device_xname(chp->ch_atac->atac_dev), chp->ch_channel, drive,
1767 wdc->select(chp,drive);
1791 wdccommandext(struct ata_channel *chp, u_int8_t drive, u_int8_t command,
1794 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1795 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1799 "device=0x%02x\n", device_xname(chp->ch_atac->atac_dev),
1800 chp->ch_channel, drive, command, blkno, count, features, device),
1806 wdc->select(chp,drive);
1859 wdccommandshort(struct ata_channel *chp, int drive, int command)
1861 struct wdc_softc *wdc = CHAN_TO_WDC(chp);
1862 struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
1865 device_xname(chp->ch_atac->atac_dev), chp->ch_channel, drive,
1869 wdc->select(chp,drive);
1879 __wdcerror(struct ata_channel *chp, const char *msg)
1881 struct atac_softc *atac = chp->ch_atac;
1882 struct ata_xfer *xfer = ata_queue_get_active_xfer(chp);
1886 chp->ch_channel, msg);
1889 chp->ch_channel, xfer->c_drive, msg);
1896 wdcbit_bucket(struct ata_channel *chp, int size)
1898 struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
1907 wdc_datain_pio(struct ata_channel *chp, int flags, void *bf, size_t len)
1909 struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
1999 wdc_dataout_pio(struct ata_channel *chp, int flags, void *bf, size_t len)
2001 struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);