| @@ -1,41 +1,41 @@ | | | @@ -1,41 +1,41 @@ |
1 | /* $NetBSD: satapmp_subr.c,v 1.11 2013/04/17 12:22:43 jakllsch Exp $ */ | | 1 | /* $NetBSD: satapmp_subr.c,v 1.12 2013/05/03 20:02:08 jakllsch Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2012 Manuel Bouyer. All rights reserved. | | 4 | * Copyright (c) 2012 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 | * |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | */ | | 25 | */ |
26 | | | 26 | |
27 | #include <sys/cdefs.h> | | 27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.11 2013/04/17 12:22:43 jakllsch Exp $"); | | 28 | __KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.12 2013/05/03 20:02:08 jakllsch Exp $"); |
29 | | | 29 | |
30 | #include <sys/param.h> | | 30 | #include <sys/param.h> |
31 | #include <sys/systm.h> | | 31 | #include <sys/systm.h> |
32 | #include <sys/kernel.h> | | 32 | #include <sys/kernel.h> |
33 | #include <sys/device.h> | | 33 | #include <sys/device.h> |
34 | #include <sys/conf.h> | | 34 | #include <sys/conf.h> |
35 | #include <sys/fcntl.h> | | 35 | #include <sys/fcntl.h> |
36 | #include <sys/proc.h> | | 36 | #include <sys/proc.h> |
37 | #include <sys/errno.h> | | 37 | #include <sys/errno.h> |
38 | #include <sys/kmem.h> | | 38 | #include <sys/kmem.h> |
39 | #include <sys/intr.h> | | 39 | #include <sys/intr.h> |
40 | | | 40 | |
41 | #include <dev/ata/ataconf.h> | | 41 | #include <dev/ata/ataconf.h> |
| @@ -56,28 +56,28 @@ satapmp_read_8(struct ata_channel *chp, | | | @@ -56,28 +56,28 @@ satapmp_read_8(struct ata_channel *chp, |
56 | | | 56 | |
57 | KASSERT(port < PMP_MAX_DRIVES); | | 57 | KASSERT(port < PMP_MAX_DRIVES); |
58 | KASSERT(reg < PMP_GSCR_NREGS); | | 58 | KASSERT(reg < PMP_GSCR_NREGS); |
59 | KASSERT(chp->ch_ndrives >= PMP_MAX_DRIVES); | | 59 | KASSERT(chp->ch_ndrives >= PMP_MAX_DRIVES); |
60 | drvp = &chp->ch_drive[PMP_PORT_CTL]; | | 60 | drvp = &chp->ch_drive[PMP_PORT_CTL]; |
61 | KASSERT(drvp->drive == PMP_PORT_CTL); | | 61 | KASSERT(drvp->drive == PMP_PORT_CTL); |
62 | | | 62 | |
63 | memset(&ata_c, 0, sizeof(struct ata_command)); | | 63 | memset(&ata_c, 0, sizeof(struct ata_command)); |
64 | | | 64 | |
65 | ata_c.r_command = PMPC_READ_PORT; | | 65 | ata_c.r_command = PMPC_READ_PORT; |
66 | ata_c.r_features = reg; | | 66 | ata_c.r_features = reg; |
67 | ata_c.r_device = port; | | 67 | ata_c.r_device = port; |
68 | ata_c.timeout = 3000; /* 3s */ | | 68 | ata_c.timeout = 3000; /* 3s */ |
69 | ata_c.r_st_bmask = WDCS_DRDY; | | 69 | ata_c.r_st_bmask = 0; |
70 | ata_c.r_st_pmask = 0; | | 70 | ata_c.r_st_pmask = WDCS_DRDY; |
71 | ata_c.flags = AT_LBA48 | AT_READREG | AT_WAIT; | | 71 | ata_c.flags = AT_LBA48 | AT_READREG | AT_WAIT; |
72 | | | 72 | |
73 | if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, | | 73 | if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, |
74 | &ata_c) != ATACMD_COMPLETE) { | | 74 | &ata_c) != ATACMD_COMPLETE) { |
75 | aprint_error_dev(chp->atabus, | | 75 | aprint_error_dev(chp->atabus, |
76 | "PMP port %d register %d read failed\n", port, reg); | | 76 | "PMP port %d register %d read failed\n", port, reg); |
77 | return EIO; | | 77 | return EIO; |
78 | } | | 78 | } |
79 | if (ata_c.flags & (AT_TIMEOU | AT_DF)) { | | 79 | if (ata_c.flags & (AT_TIMEOU | AT_DF)) { |
80 | aprint_error_dev(chp->atabus, | | 80 | aprint_error_dev(chp->atabus, |
81 | "PMP port %d register %d read failed, flags 0x%x\n", | | 81 | "PMP port %d register %d read failed, flags 0x%x\n", |
82 | port, reg, ata_c.flags); | | 82 | port, reg, ata_c.flags); |
83 | return EIO; | | 83 | return EIO; |
| @@ -124,28 +124,28 @@ satapmp_write_8(struct ata_channel *chp, | | | @@ -124,28 +124,28 @@ satapmp_write_8(struct ata_channel *chp, |
124 | drvp = &chp->ch_drive[PMP_PORT_CTL]; | | 124 | drvp = &chp->ch_drive[PMP_PORT_CTL]; |
125 | KASSERT(drvp->drive == PMP_PORT_CTL); | | 125 | KASSERT(drvp->drive == PMP_PORT_CTL); |
126 | | | 126 | |
127 | memset(&ata_c, 0, sizeof(struct ata_command)); | | 127 | memset(&ata_c, 0, sizeof(struct ata_command)); |
128 | | | 128 | |
129 | ata_c.r_command = PMPC_WRITE_PORT; | | 129 | ata_c.r_command = PMPC_WRITE_PORT; |
130 | ata_c.r_features = reg; | | 130 | ata_c.r_features = reg; |
131 | ata_c.r_device = port; | | 131 | ata_c.r_device = port; |
132 | ata_c.r_lba = (((value >> 40) & 0xffffff) << 24) | | | 132 | ata_c.r_lba = (((value >> 40) & 0xffffff) << 24) | |
133 | (((value >> 8) & 0xffffff) << 0); | | 133 | (((value >> 8) & 0xffffff) << 0); |
134 | ata_c.r_count = (((value >> 32) & 0xff) << 8) | | | 134 | ata_c.r_count = (((value >> 32) & 0xff) << 8) | |
135 | (((value >> 0) & 0xff) << 0); | | 135 | (((value >> 0) & 0xff) << 0); |
136 | ata_c.timeout = 3000; /* 3s */ | | 136 | ata_c.timeout = 3000; /* 3s */ |
137 | ata_c.r_st_bmask = WDCS_DRDY; | | 137 | ata_c.r_st_bmask = 0; |
138 | ata_c.r_st_pmask = 0; | | 138 | ata_c.r_st_pmask = WDCS_DRDY; |
139 | ata_c.flags = AT_LBA48 | AT_WAIT; | | 139 | ata_c.flags = AT_LBA48 | AT_WAIT; |
140 | | | 140 | |
141 | if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, | | 141 | if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, |
142 | &ata_c) != ATACMD_COMPLETE) { | | 142 | &ata_c) != ATACMD_COMPLETE) { |
143 | aprint_error_dev(chp->atabus, | | 143 | aprint_error_dev(chp->atabus, |
144 | "PMP port %d register %d write failed\n", port, reg); | | 144 | "PMP port %d register %d write failed\n", port, reg); |
145 | return EIO; | | 145 | return EIO; |
146 | } | | 146 | } |
147 | if (ata_c.flags & (AT_TIMEOU | AT_DF)) { | | 147 | if (ata_c.flags & (AT_TIMEOU | AT_DF)) { |
148 | aprint_error_dev(chp->atabus, | | 148 | aprint_error_dev(chp->atabus, |
149 | "PMP port %d register %d write failed, flags 0x%x\n", | | 149 | "PMP port %d register %d write failed, flags 0x%x\n", |
150 | port, reg, ata_c.flags); | | 150 | port, reg, ata_c.flags); |
151 | return EIO; | | 151 | return EIO; |