| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: wdc.c,v 1.304 2021/01/04 15:13:06 skrll Exp $ */ | | 1 | /* $NetBSD: wdc.c,v 1.305 2021/01/04 15:13:50 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. | | 4 | * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -48,27 +48,27 @@ | | | @@ -48,27 +48,27 @@ |
48 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 48 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
49 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 49 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
50 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 50 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
51 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 51 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
52 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 52 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
53 | * POSSIBILITY OF SUCH DAMAGE. | | 53 | * POSSIBILITY OF SUCH DAMAGE. |
54 | */ | | 54 | */ |
55 | | | 55 | |
56 | /* | | 56 | /* |
57 | * CODE UNTESTED IN THE CURRENT REVISION: | | 57 | * CODE UNTESTED IN THE CURRENT REVISION: |
58 | */ | | 58 | */ |
59 | | | 59 | |
60 | #include <sys/cdefs.h> | | 60 | #include <sys/cdefs.h> |
61 | __KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.304 2021/01/04 15:13:06 skrll Exp $"); | | 61 | __KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.305 2021/01/04 15:13:50 skrll Exp $"); |
62 | | | 62 | |
63 | #include "opt_ata.h" | | 63 | #include "opt_ata.h" |
64 | #include "opt_wdc.h" | | 64 | #include "opt_wdc.h" |
65 | | | 65 | |
66 | #include <sys/param.h> | | 66 | #include <sys/param.h> |
67 | #include <sys/systm.h> | | 67 | #include <sys/systm.h> |
68 | #include <sys/kernel.h> | | 68 | #include <sys/kernel.h> |
69 | #include <sys/conf.h> | | 69 | #include <sys/conf.h> |
70 | #include <sys/buf.h> | | 70 | #include <sys/buf.h> |
71 | #include <sys/device.h> | | 71 | #include <sys/device.h> |
72 | #include <sys/malloc.h> | | 72 | #include <sys/malloc.h> |
73 | #include <sys/kmem.h> | | 73 | #include <sys/kmem.h> |
74 | #include <sys/syslog.h> | | 74 | #include <sys/syslog.h> |
| @@ -708,28 +708,28 @@ wdcprobe1(struct ata_channel *chp, int p | | | @@ -708,28 +708,28 @@ wdcprobe1(struct ata_channel *chp, int p |
708 | bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], | | 708 | bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], |
709 | 0, WDSD_IBM | 0x10); | | 709 | 0, WDSD_IBM | 0x10); |
710 | bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0, | | 710 | bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0, |
711 | ATAPI_SOFT_RESET); | | 711 | ATAPI_SOFT_RESET); |
712 | } | | 712 | } |
713 | | | 713 | |
714 | delay(5000); | | 714 | delay(5000); |
715 | #endif | | 715 | #endif |
716 | | | 716 | |
717 | wdc->reset(chp, RESET_POLL); | | 717 | wdc->reset(chp, RESET_POLL); |
718 | DELAY(2000); | | 718 | DELAY(2000); |
719 | (void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0); | | 719 | (void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0); |
720 | | | 720 | |
721 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) | | 721 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) |
722 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, | | 722 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, |
723 | WDCTL_4BIT); | | 723 | WDCTL_4BIT); |
724 | | | 724 | |
725 | #ifdef WDC_NO_IDS | | 725 | #ifdef WDC_NO_IDS |
726 | ret_value = __wdcwait_reset(chp, ret_value, RESET_POLL); | | 726 | ret_value = __wdcwait_reset(chp, ret_value, RESET_POLL); |
727 | #else | | 727 | #else |
728 | ret_value = __wdcwait_reset(chp, ret_value, poll); | | 728 | ret_value = __wdcwait_reset(chp, ret_value, poll); |
729 | #endif | | 729 | #endif |
730 | ATADEBUG_PRINT(("%s:%d: after reset, ret_value=%#x\n", | | 730 | ATADEBUG_PRINT(("%s:%d: after reset, ret_value=%#x\n", |
731 | __func__, chp->ch_channel, ret_value), DEBUG_PROBE); | | 731 | __func__, chp->ch_channel, ret_value), DEBUG_PROBE); |
732 | | | 732 | |
733 | /* if reset failed, there's nothing here */ | | 733 | /* if reset failed, there's nothing here */ |
734 | if (ret_value == 0) { | | 734 | if (ret_value == 0) { |
735 | return 0; | | 735 | return 0; |
| @@ -1028,69 +1028,69 @@ wdcreset(struct ata_channel *chp, int po | | | @@ -1028,69 +1028,69 @@ wdcreset(struct ata_channel *chp, int po |
1028 | struct wdc_softc *wdc = CHAN_TO_WDC(chp); | | 1028 | struct wdc_softc *wdc = CHAN_TO_WDC(chp); |
1029 | struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; | | 1029 | struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; |
1030 | int drv_mask1, drv_mask2; | | 1030 | int drv_mask1, drv_mask2; |
1031 | | | 1031 | |
1032 | ata_channel_lock_owned(chp); | | 1032 | ata_channel_lock_owned(chp); |
1033 | | | 1033 | |
1034 | #ifdef WDC_NO_IDS | | 1034 | #ifdef WDC_NO_IDS |
1035 | poll = RESET_POLL; | | 1035 | poll = RESET_POLL; |
1036 | #endif | | 1036 | #endif |
1037 | wdc->reset(chp, poll); | | 1037 | wdc->reset(chp, poll); |
1038 | | | 1038 | |
1039 | drv_mask1 = (chp->ch_drive[0].drive_type != ATA_DRIVET_NONE) | | 1039 | drv_mask1 = (chp->ch_drive[0].drive_type != ATA_DRIVET_NONE) |
1040 | ? 0x01 : 0x00; | | 1040 | ? 0x01 : 0x00; |
1041 | if (chp->ch_ndrives > 1) | | 1041 | if (chp->ch_ndrives > 1) |
1042 | drv_mask1 |= (chp->ch_drive[1].drive_type != ATA_DRIVET_NONE) | | 1042 | drv_mask1 |= (chp->ch_drive[1].drive_type != ATA_DRIVET_NONE) |
1043 | ? 0x02 : 0x00; | | 1043 | ? 0x02 : 0x00; |
1044 | drv_mask2 = __wdcwait_reset(chp, drv_mask1, | | 1044 | drv_mask2 = __wdcwait_reset(chp, drv_mask1, |
1045 | (poll == RESET_SLEEP) ? 0 : 1); | | 1045 | (poll == RESET_SLEEP) ? 0 : 1); |
1046 | if (drv_mask2 != drv_mask1) { | | 1046 | if (drv_mask2 != drv_mask1) { |
1047 | aprint_error("%s channel %d: reset failed for", | | 1047 | aprint_error("%s channel %d: reset failed for", |
1048 | device_xname(atac->atac_dev), chp->ch_channel); | | 1048 | device_xname(atac->atac_dev), chp->ch_channel); |
1049 | if ((drv_mask1 & 0x01) != 0 && (drv_mask2 & 0x01) == 0) | | 1049 | if ((drv_mask1 & 0x01) != 0 && (drv_mask2 & 0x01) == 0) |
1050 | aprint_normal(" drive 0"); | | 1050 | aprint_normal(" drive 0"); |
1051 | if ((drv_mask1 & 0x02) != 0 && (drv_mask2 & 0x02) == 0) | | 1051 | if ((drv_mask1 & 0x02) != 0 && (drv_mask2 & 0x02) == 0) |
1052 | aprint_normal(" drive 1"); | | 1052 | aprint_normal(" drive 1"); |
1053 | aprint_normal("\n"); | | 1053 | aprint_normal("\n"); |
1054 | } | | 1054 | } |
1055 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) | | 1055 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) |
1056 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, | | 1056 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, |
1057 | WDCTL_4BIT); | | 1057 | WDCTL_4BIT); |
1058 | | | 1058 | |
1059 | return (drv_mask1 != drv_mask2) ? 1 : 0; | | 1059 | return (drv_mask1 != drv_mask2) ? 1 : 0; |
1060 | } | | 1060 | } |
1061 | | | 1061 | |
1062 | void | | 1062 | void |
1063 | wdc_do_reset(struct ata_channel *chp, int poll) | | 1063 | wdc_do_reset(struct ata_channel *chp, int poll) |
1064 | { | | 1064 | { |
1065 | struct wdc_softc *wdc = CHAN_TO_WDC(chp); | | 1065 | struct wdc_softc *wdc = CHAN_TO_WDC(chp); |
1066 | struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; | | 1066 | struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; |
1067 | int s = 0; | | 1067 | int s = 0; |
1068 | | | 1068 | |
1069 | if (poll != RESET_SLEEP) | | 1069 | if (poll != RESET_SLEEP) |
1070 | s = splbio(); | | 1070 | s = splbio(); |
1071 | if (wdc->select) | | 1071 | if (wdc->select) |
1072 | wdc->select(chp,0); | | 1072 | wdc->select(chp,0); |
1073 | /* master */ | | 1073 | /* master */ |
1074 | bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0, WDSD_IBM); | | 1074 | bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0, WDSD_IBM); |
1075 | delay(10); /* 400ns delay */ | | 1075 | delay(10); /* 400ns delay */ |
1076 | /* assert SRST, wait for reset to complete */ | | 1076 | /* assert SRST, wait for reset to complete */ |
1077 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) { | | 1077 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) { |
1078 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, | | 1078 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, |
1079 | WDCTL_RST | WDCTL_IDS | WDCTL_4BIT); | | 1079 | WDCTL_RST | WDCTL_IDS | WDCTL_4BIT); |
1080 | delay(2000); | | 1080 | delay(2000); |
1081 | } | | 1081 | } |
1082 | (void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0); | | 1082 | (void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0); |
1083 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) | | 1083 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) |
1084 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, | | 1084 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, |
1085 | WDCTL_4BIT | WDCTL_IDS); | | 1085 | WDCTL_4BIT | WDCTL_IDS); |
1086 | delay(10); /* 400ns delay */ | | 1086 | delay(10); /* 400ns delay */ |
1087 | if (poll != RESET_SLEEP) { | | 1087 | if (poll != RESET_SLEEP) { |
1088 | /* ACK interrupt in case there is one pending left */ | | 1088 | /* ACK interrupt in case there is one pending left */ |
1089 | if (wdc->irqack) | | 1089 | if (wdc->irqack) |
1090 | wdc->irqack(chp); | | 1090 | wdc->irqack(chp); |
1091 | splx(s); | | 1091 | splx(s); |
1092 | } | | 1092 | } |
1093 | } | | 1093 | } |
1094 | | | 1094 | |
1095 | static int | | 1095 | static int |
1096 | __wdcwait_reset(struct ata_channel *chp, int drv_mask, int poll) | | 1096 | __wdcwait_reset(struct ata_channel *chp, int drv_mask, int poll) |
| @@ -1441,28 +1441,28 @@ __wdccommand_start(struct ata_channel *c | | | @@ -1441,28 +1441,28 @@ __wdccommand_start(struct ata_channel *c |
1441 | WDSD_IBM | (drive << 4)); | | 1441 | WDSD_IBM | (drive << 4)); |
1442 | switch(wdcwait(chp, ata_c->r_st_bmask | WDCS_DRQ, | | 1442 | switch(wdcwait(chp, ata_c->r_st_bmask | WDCS_DRQ, |
1443 | ata_c->r_st_bmask, ata_c->timeout, wait_flags, &tfd)) { | | 1443 | ata_c->r_st_bmask, ata_c->timeout, wait_flags, &tfd)) { |
1444 | case WDCWAIT_OK: | | 1444 | case WDCWAIT_OK: |
1445 | break; | | 1445 | break; |
1446 | case WDCWAIT_TOUT: | | 1446 | case WDCWAIT_TOUT: |
1447 | ata_c->flags |= AT_TIMEOU; | | 1447 | ata_c->flags |= AT_TIMEOU; |
1448 | return ATASTART_ABORT; | | 1448 | return ATASTART_ABORT; |
1449 | case WDCWAIT_THR: | | 1449 | case WDCWAIT_THR: |
1450 | return ATASTART_TH; | | 1450 | return ATASTART_TH; |
1451 | } | | 1451 | } |
1452 | if (ata_c->flags & AT_POLL) { | | 1452 | if (ata_c->flags & AT_POLL) { |
1453 | /* polled command, disable interrupts */ | | 1453 | /* polled command, disable interrupts */ |
1454 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) | | 1454 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) |
1455 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, | | 1455 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, |
1456 | wd_aux_ctlr, WDCTL_4BIT | WDCTL_IDS); | | 1456 | wd_aux_ctlr, WDCTL_4BIT | WDCTL_IDS); |
1457 | } | | 1457 | } |
1458 | if ((ata_c->flags & AT_LBA48) != 0) { | | 1458 | if ((ata_c->flags & AT_LBA48) != 0) { |
1459 | wdccommandext(chp, drive, ata_c->r_command, | | 1459 | wdccommandext(chp, drive, ata_c->r_command, |
1460 | ata_c->r_lba, ata_c->r_count, ata_c->r_features, | | 1460 | ata_c->r_lba, ata_c->r_count, ata_c->r_features, |
1461 | ata_c->r_device & ~0x10); | | 1461 | ata_c->r_device & ~0x10); |
1462 | } else { | | 1462 | } else { |
1463 | wdccommand(chp, drive, ata_c->r_command, | | 1463 | wdccommand(chp, drive, ata_c->r_command, |
1464 | (ata_c->r_lba >> 8) & 0xffff, | | 1464 | (ata_c->r_lba >> 8) & 0xffff, |
1465 | WDSD_IBM | (drive << 4) | | | 1465 | WDSD_IBM | (drive << 4) | |
1466 | (((ata_c->flags & AT_LBA) != 0) ? WDSD_LBA : 0) | | | 1466 | (((ata_c->flags & AT_LBA) != 0) ? WDSD_LBA : 0) | |
1467 | ((ata_c->r_lba >> 24) & 0x0f), | | 1467 | ((ata_c->r_lba >> 24) & 0x0f), |
1468 | ata_c->r_lba & 0xff, | | 1468 | ata_c->r_lba & 0xff, |
| @@ -1646,68 +1646,68 @@ __wdccommand_done(struct ata_channel *ch | | | @@ -1646,68 +1646,68 @@ __wdccommand_done(struct ata_channel *ch |
1646 | wdr->cmd_iohs[wd_seccnt], 0); | | 1646 | wdr->cmd_iohs[wd_seccnt], 0); |
1647 | ata_c->r_lba = (uint64_t)bus_space_read_1(wdr->cmd_iot, | | 1647 | ata_c->r_lba = (uint64_t)bus_space_read_1(wdr->cmd_iot, |
1648 | wdr->cmd_iohs[wd_sector], 0) << 0; | | 1648 | wdr->cmd_iohs[wd_sector], 0) << 0; |
1649 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, | | 1649 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, |
1650 | wdr->cmd_iohs[wd_cyl_lo], 0) << 8; | | 1650 | wdr->cmd_iohs[wd_cyl_lo], 0) << 8; |
1651 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, | | 1651 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, |
1652 | wdr->cmd_iohs[wd_cyl_hi], 0) << 16; | | 1652 | wdr->cmd_iohs[wd_cyl_hi], 0) << 16; |
1653 | ata_c->r_device = bus_space_read_1(wdr->cmd_iot, | | 1653 | ata_c->r_device = bus_space_read_1(wdr->cmd_iot, |
1654 | wdr->cmd_iohs[wd_sdh], 0); | | 1654 | wdr->cmd_iohs[wd_sdh], 0); |
1655 | | | 1655 | |
1656 | if ((ata_c->flags & AT_LBA48) != 0) { | | 1656 | if ((ata_c->flags & AT_LBA48) != 0) { |
1657 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) { | | 1657 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) { |
1658 | if ((ata_c->flags & AT_POLL) != 0) | | 1658 | if ((ata_c->flags & AT_POLL) != 0) |
1659 | bus_space_write_1(wdr->ctl_iot, | | 1659 | bus_space_write_1(wdr->ctl_iot, |
1660 | wdr->ctl_ioh, wd_aux_ctlr, | | 1660 | wdr->ctl_ioh, wd_aux_ctlr, |
1661 | WDCTL_HOB|WDCTL_4BIT|WDCTL_IDS); | | 1661 | WDCTL_HOB|WDCTL_4BIT|WDCTL_IDS); |
1662 | else | | 1662 | else |
1663 | bus_space_write_1(wdr->ctl_iot, | | 1663 | bus_space_write_1(wdr->ctl_iot, |
1664 | wdr->ctl_ioh, wd_aux_ctlr, | | 1664 | wdr->ctl_ioh, wd_aux_ctlr, |
1665 | WDCTL_HOB|WDCTL_4BIT); | | 1665 | WDCTL_HOB|WDCTL_4BIT); |
1666 | } | | 1666 | } |
1667 | ata_c->r_count |= bus_space_read_1(wdr->cmd_iot, | | 1667 | ata_c->r_count |= bus_space_read_1(wdr->cmd_iot, |
1668 | wdr->cmd_iohs[wd_seccnt], 0) << 8; | | 1668 | wdr->cmd_iohs[wd_seccnt], 0) << 8; |
1669 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, | | 1669 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, |
1670 | wdr->cmd_iohs[wd_sector], 0) << 24; | | 1670 | wdr->cmd_iohs[wd_sector], 0) << 24; |
1671 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, | | 1671 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, |
1672 | wdr->cmd_iohs[wd_cyl_lo], 0) << 32; | | 1672 | wdr->cmd_iohs[wd_cyl_lo], 0) << 32; |
1673 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, | | 1673 | ata_c->r_lba |= (uint64_t)bus_space_read_1(wdr->cmd_iot, |
1674 | wdr->cmd_iohs[wd_cyl_hi], 0) << 40; | | 1674 | wdr->cmd_iohs[wd_cyl_hi], 0) << 40; |
1675 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) { | | 1675 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) { |
1676 | if ((ata_c->flags & AT_POLL) != 0) | | 1676 | if ((ata_c->flags & AT_POLL) != 0) |
1677 | bus_space_write_1(wdr->ctl_iot, | | 1677 | bus_space_write_1(wdr->ctl_iot, |
1678 | wdr->ctl_ioh, wd_aux_ctlr, | | 1678 | wdr->ctl_ioh, wd_aux_ctlr, |
1679 | WDCTL_4BIT|WDCTL_IDS); | | 1679 | WDCTL_4BIT|WDCTL_IDS); |
1680 | else | | 1680 | else |
1681 | bus_space_write_1(wdr->ctl_iot, | | 1681 | bus_space_write_1(wdr->ctl_iot, |
1682 | wdr->ctl_ioh, wd_aux_ctlr, | | 1682 | wdr->ctl_ioh, wd_aux_ctlr, |
1683 | WDCTL_4BIT); | | 1683 | WDCTL_4BIT); |
1684 | } | | 1684 | } |
1685 | } else { | | 1685 | } else { |
1686 | ata_c->r_lba |= | | 1686 | ata_c->r_lba |= |
1687 | (uint64_t)(ata_c->r_device & 0x0f) << 24; | | 1687 | (uint64_t)(ata_c->r_device & 0x0f) << 24; |
1688 | } | | 1688 | } |
1689 | ata_c->r_device &= 0xf0; | | 1689 | ata_c->r_device &= 0xf0; |
1690 | } | | 1690 | } |
1691 | | | 1691 | |
1692 | __wdccommand_done_end(chp, xfer); | | 1692 | __wdccommand_done_end(chp, xfer); |
1693 | | | 1693 | |
1694 | ata_deactivate_xfer(chp, xfer); | | 1694 | ata_deactivate_xfer(chp, xfer); |
1695 | | | 1695 | |
1696 | out: | | 1696 | out: |
1697 | if (ata_c->flags & AT_POLL) { | | 1697 | if (ata_c->flags & AT_POLL) { |
1698 | /* enable interrupts */ | | 1698 | /* enable interrupts */ |
1699 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) | | 1699 | if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) |
1700 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, | | 1700 | bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, |
1701 | wd_aux_ctlr, WDCTL_4BIT); | | 1701 | wd_aux_ctlr, WDCTL_4BIT); |
1702 | delay(10); /* some drives need a little delay here */ | | 1702 | delay(10); /* some drives need a little delay here */ |
1703 | } | | 1703 | } |
1704 | | | 1704 | |
1705 | if (start) | | 1705 | if (start) |
1706 | atastart(chp); | | 1706 | atastart(chp); |
1707 | } | | 1707 | } |
1708 | | | 1708 | |
1709 | static void | | 1709 | static void |
1710 | __wdccommand_done_end(struct ata_channel *chp, struct ata_xfer *xfer) | | 1710 | __wdccommand_done_end(struct ata_channel *chp, struct ata_xfer *xfer) |
1711 | { | | 1711 | { |
1712 | struct ata_command *ata_c = &xfer->c_ata_c; | | 1712 | struct ata_command *ata_c = &xfer->c_ata_c; |
1713 | | | 1713 | |