Lines Matching full:ch

55 static int ata_wait(struct ata_channel *ch, int unit, u_int8_t);
67 struct ata_channel *ch = device_get_softc(dev); in ata_generic_hw() local
69 ch->hw.begin_transaction = ata_begin_transaction; in ata_generic_hw()
70 ch->hw.end_transaction = ata_end_transaction; in ata_generic_hw()
71 ch->hw.status = ata_generic_status; in ata_generic_hw()
72 ch->hw.softreset = NULL; in ata_generic_hw()
73 ch->hw.command = ata_generic_command; in ata_generic_hw()
74 ch->hw.tf_read = ata_tf_read; in ata_generic_hw()
75 ch->hw.tf_write = ata_tf_write; in ata_generic_hw()
76 ch->hw.pm_read = NULL; in ata_generic_hw()
77 ch->hw.pm_write = NULL; in ata_generic_hw()
84 struct ata_channel *ch = device_get_softc(request->parent); in ata_begin_transaction() local
90 if ((ch->flags & ATA_NO_ATAPI_DMA) && in ata_begin_transaction()
93 if ((ch->flags & ATA_ATAPI_DMA_RO) && in ata_begin_transaction()
106 if (ch->hw.command(request)) { in ata_begin_transaction()
118 request->status = ATA_IDX_INB(ch, ATA_STATUS); in ata_begin_transaction()
121 request->error = ATA_IDX_INB(ch, ATA_ERROR); in ata_begin_transaction()
122 ch->hw.tf_read(request); in ata_begin_transaction()
128 if (ata_wait(ch, request->unit, (ATA_S_READY | ATA_S_DRQ)) < 0) { in ata_begin_transaction()
142 if ((error = ch->dma.load(request, NULL, &dummy))) { in ata_begin_transaction()
149 if ((ch->flags & ATA_DMA_BEFORE_CMD) && in ata_begin_transaction()
150 ch->dma.start && ch->dma.start(request)) { in ata_begin_transaction()
157 if (ch->hw.command(request)) { in ata_begin_transaction()
165 if (!(ch->flags & ATA_DMA_BEFORE_CMD) && in ata_begin_transaction()
166 ch->dma.start && ch->dma.start(request)) { in ata_begin_transaction()
177 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(request->unit)); in ata_begin_transaction()
179 if (!(ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_DSC)) in ata_begin_transaction()
185 if (ch->hw.command(request)) { in ata_begin_transaction()
196 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(request->unit)); in ata_begin_transaction()
198 if (!(ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_DSC)) in ata_begin_transaction()
204 if ((error = ch->dma.load(request, NULL, &dummy))) { in ata_begin_transaction()
211 if (ch->hw.command(request)) { in ata_begin_transaction()
218 if (ch->dma.start && ch->dma.start(request)) { in ata_begin_transaction()
228 if (ch->dma.unload) { in ata_begin_transaction()
229 ch->dma.unload(request); in ata_begin_transaction()
243 struct ata_channel *ch = device_get_softc(request->parent); in ata_end_transaction() local
249 request->status = ATA_IDX_INB(ch, ATA_STATUS); in ata_end_transaction()
262 ch->hw.tf_read(request); in ata_end_transaction()
267 request->error = ATA_IDX_INB(ch, ATA_ERROR); in ata_end_transaction()
279 if (ata_wait(ch, request->unit, flags) < 0) { in ata_end_transaction()
301 if (ata_wait(ch, request->unit, (ATA_S_READY | ATA_S_DRQ)) < 0) { in ata_end_transaction()
304 request->status = ATA_IDX_INB(ch, ATA_STATUS); in ata_end_transaction()
325 if (ch->dma.stop) in ata_end_transaction()
326 request->dma->status = ch->dma.stop(request); in ata_end_transaction()
330 request->error = ATA_IDX_INB(ch, ATA_ERROR); in ata_end_transaction()
339 ch->hw.tf_read(request); in ata_end_transaction()
343 ch->dma.unload(request); in ata_end_transaction()
350 length = ATA_IDX_INB(ch, ATA_CYL_LSB)|(ATA_IDX_INB(ch, ATA_CYL_MSB)<<8); in ata_end_transaction()
356 switch ((ATA_IDX_INB(ch, ATA_IREASON) & (ATA_I_CMD | ATA_I_IN)) | in ata_end_transaction()
367 ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (int16_t *)request->u.atapi.ccb, in ata_end_transaction()
425 request->error = ATA_IDX_INB(ch, ATA_ERROR); in ata_end_transaction()
440 if (ch->dma.stop) in ata_end_transaction()
441 request->dma->status = ch->dma.stop(request); in ata_end_transaction()
445 request->error = ATA_IDX_INB(ch, ATA_ERROR); in ata_end_transaction()
452 ch->dma.unload(request); in ata_end_transaction()
472 struct ata_channel *ch = device_get_softc(dev); in ata_generic_reset() local
479 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_MASTER)); in ata_generic_reset()
481 ostat0 = ATA_IDX_INB(ch, ATA_STATUS); in ata_generic_reset()
482 if (((ostat0 & 0xf8) != 0xf8 || (ch->flags & ATA_KNOWN_PRESENCE)) && in ata_generic_reset()
489 if (!(ch->flags & ATA_NO_SLAVE)) { in ata_generic_reset()
490 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_SLAVE)); in ata_generic_reset()
492 ostat1 = ATA_IDX_INB(ch, ATA_STATUS); in ata_generic_reset()
493 if (((ostat1 & 0xf8) != 0xf8 || (ch->flags & ATA_KNOWN_PRESENCE)) && in ata_generic_reset()
506 ch->devices = 0; in ata_generic_reset()
511 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_MASTER)); in ata_generic_reset()
513 ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_IDS | ATA_A_RESET); in ata_generic_reset()
515 ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_IDS); in ata_generic_reset()
517 ATA_IDX_INB(ch, ATA_ERROR); in ata_generic_reset()
522 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(ATA_MASTER)); in ata_generic_reset()
524 if (ch->flags & ATA_STATUS_IS_LONG) in ata_generic_reset()
525 stat0 = ATA_IDX_INL(ch, ATA_STATUS) & 0xff; in ata_generic_reset()
527 stat0 = ATA_IDX_INB(ch, ATA_STATUS); in ata_generic_reset()
528 err = ATA_IDX_INB(ch, ATA_ERROR); in ata_generic_reset()
529 lsb = ATA_IDX_INB(ch, ATA_CYL_LSB); in ata_generic_reset()
530 msb = ATA_IDX_INB(ch, ATA_CYL_MSB); in ata_generic_reset()
541 ch->devices |= ATA_ATAPI_MASTER; in ata_generic_reset()
544 ch->devices |= ATA_ATA_MASTER; in ata_generic_reset()
555 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(ATA_SLAVE)); in ata_generic_reset()
557 if (ch->flags & ATA_STATUS_IS_LONG) in ata_generic_reset()
558 stat1 = ATA_IDX_INL(ch, ATA_STATUS) & 0xff; in ata_generic_reset()
560 stat1 = ATA_IDX_INB(ch, ATA_STATUS); in ata_generic_reset()
561 err = ATA_IDX_INB(ch, ATA_ERROR); in ata_generic_reset()
562 lsb = ATA_IDX_INB(ch, ATA_CYL_LSB); in ata_generic_reset()
563 msb = ATA_IDX_INB(ch, ATA_CYL_MSB); in ata_generic_reset()
574 ch->devices |= ATA_ATAPI_SLAVE; in ata_generic_reset()
577 ch->devices |= ATA_ATA_SLAVE; in ata_generic_reset()
586 if ((ch->flags & ATA_KNOWN_PRESENCE) == 0 && in ata_generic_reset()
601 stat0, stat1, ch->devices); in ata_generic_reset()
608 struct ata_channel *ch = device_get_softc(dev); in ata_generic_status() local
610 if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY) { in ata_generic_status()
612 if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY) in ata_generic_status()
619 ata_wait(struct ata_channel *ch, int unit, u_int8_t mask) in ata_wait() argument
628 status = ATA_IDX_INB(ch, ATA_ALTSTAT); in ata_wait()
632 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(unit)); in ata_wait()
661 status = ATA_IDX_INB(ch, ATA_ALTSTAT); in ata_wait()
672 struct ata_channel *ch = device_get_softc(request->parent); in ata_generic_command() local
675 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(request->unit)); in ata_generic_command()
678 if (ata_wait(ch, request->unit, 0) < 0) { in ata_generic_command()
685 ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT); in ata_generic_command()
693 ATA_IDX_OUTB(ch, ATA_FEATURE, ATA_F_DMA); in ata_generic_command()
694 ATA_IDX_OUTB(ch, ATA_CYL_LSB, 0); in ata_generic_command()
695 ATA_IDX_OUTB(ch, ATA_CYL_MSB, 0); in ata_generic_command()
698 ATA_IDX_OUTB(ch, ATA_FEATURE, 0); in ata_generic_command()
699 ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->transfersize); in ata_generic_command()
700 ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->transfersize >> 8); in ata_generic_command()
702 ATA_IDX_OUTB(ch, ATA_COMMAND, ATA_PACKET_CMD); in ata_generic_command()
709 res = ata_wait(ch, request->unit, 0); in ata_generic_command()
720 int reason = ATA_IDX_INB(ch, ATA_IREASON); in ata_generic_command()
721 int status = ATA_IDX_INB(ch, ATA_STATUS); in ata_generic_command()
739 ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (int16_t *)request->u.atapi.ccb, in ata_generic_command()
743 ch->hw.tf_write(request); in ata_generic_command()
746 ATA_IDX_OUTB(ch, ATA_COMMAND, request->u.ata.command); in ata_generic_command()
754 struct ata_channel *ch = device_get_softc(request->parent); in ata_tf_read() local
757 ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT | ATA_A_HOB); in ata_tf_read()
758 request->u.ata.count = (ATA_IDX_INB(ch, ATA_COUNT) << 8); in ata_tf_read()
760 ((u_int64_t)(ATA_IDX_INB(ch, ATA_SECTOR)) << 24) | in ata_tf_read()
761 ((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_LSB)) << 32) | in ata_tf_read()
762 ((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_MSB)) << 40); in ata_tf_read()
764 ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT); in ata_tf_read()
765 request->u.ata.count |= ATA_IDX_INB(ch, ATA_COUNT); in ata_tf_read()
767 (ATA_IDX_INB(ch, ATA_SECTOR) | in ata_tf_read()
768 (ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) | in ata_tf_read()
769 (ATA_IDX_INB(ch, ATA_CYL_MSB) << 16)); in ata_tf_read()
772 request->u.ata.count = ATA_IDX_INB(ch, ATA_COUNT); in ata_tf_read()
773 request->u.ata.lba = ATA_IDX_INB(ch, ATA_SECTOR) | in ata_tf_read()
774 (ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) | in ata_tf_read()
775 (ATA_IDX_INB(ch, ATA_CYL_MSB) << 16) | in ata_tf_read()
776 ((ATA_IDX_INB(ch, ATA_DRIVE) & 0xf) << 24); in ata_tf_read()
783 struct ata_channel *ch = device_get_softc(request->parent); in ata_tf_write() local
786 ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature >> 8); in ata_tf_write()
787 ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature); in ata_tf_write()
788 ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count >> 8); in ata_tf_write()
789 ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count); in ata_tf_write()
790 ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba >> 24); in ata_tf_write()
791 ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba); in ata_tf_write()
792 ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 32); in ata_tf_write()
793 ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8); in ata_tf_write()
794 ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 40); in ata_tf_write()
795 ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16); in ata_tf_write()
796 ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_LBA | ATA_DEV(request->unit)); in ata_tf_write()
799 ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature); in ata_tf_write()
800 ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count); in ata_tf_write()
801 ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba); in ata_tf_write()
802 ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8); in ata_tf_write()
803 ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16); in ata_tf_write()
804 ATA_IDX_OUTB(ch, ATA_DRIVE, in ata_tf_write()
813 struct ata_channel *ch = device_get_softc(request->parent); in ata_pio_read() local
856 if (__predict_false((ch->flags & ATA_USE_16BIT) || in ata_pio_read()
862 ATA_IDX_INW_STRM(ch, ATA_DATA); in ata_pio_read()
868 ATA_IDX_INSW_STRM(ch, ATA_DATA, (void*)addr, in ata_pio_read()
874 ATA_IDX_INW_STRM(ch, ATA_DATA); in ata_pio_read()
878 ATA_IDX_INSL_STRM(ch, ATA_DATA, (void*)addr, size / 4); in ata_pio_read()
892 ATA_IDX_INW(ch, ATA_DATA); in ata_pio_read()
899 struct ata_channel *ch = device_get_softc(request->parent); in ata_pio_write() local
935 ATA_IDX_OUTW_STRM(ch, ATA_DATA, *(uint16_t *)&buf); in ata_pio_write()
943 if (__predict_false((ch->flags & ATA_USE_16BIT) || in ata_pio_write()
950 ATA_IDX_OUTW_STRM(ch, ATA_DATA, in ata_pio_write()
955 ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (void*)addr, in ata_pio_write()
962 ATA_IDX_OUTSL_STRM(ch, ATA_DATA, in ata_pio_write()
975 ATA_IDX_OUTW_STRM(ch, ATA_DATA, *(uint16_t *)&buf); in ata_pio_write()
983 ATA_IDX_OUTW(ch, ATA_DATA, 0); in ata_pio_write()