Sun Dec 29 12:46:43 2019 UTC ()
Read clock frequency from device properties


(jmcneill)
diff -r1.8 -r1.9 src/sys/dev/acpi/sdhc_acpi.c

cvs diff -r1.8 -r1.9 src/sys/dev/acpi/sdhc_acpi.c (switch to unified diff)

--- src/sys/dev/acpi/sdhc_acpi.c 2019/10/15 00:13:52 1.8
+++ src/sys/dev/acpi/sdhc_acpi.c 2019/12/29 12:46:43 1.9
@@ -1,290 +1,297 @@ @@ -1,290 +1,297 @@
1/* $NetBSD: sdhc_acpi.c,v 1.8 2019/10/15 00:13:52 chs Exp $ */ 1/* $NetBSD: sdhc_acpi.c,v 1.9 2019/12/29 12:46:43 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2016 Kimihiro Nonaka <nonaka@NetBSD.org> 4 * Copyright (c) 2016 Kimihiro Nonaka <nonaka@NetBSD.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products 12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission. 13 * derived from this software without specific prior written permission.
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, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.8 2019/10/15 00:13:52 chs Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.9 2019/12/29 12:46:43 jmcneill Exp $");
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/device.h> 32#include <sys/device.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/kmem.h> 34#include <sys/kmem.h>
35 35
36#include <dev/acpi/acpireg.h> 36#include <dev/acpi/acpireg.h>
37#include <dev/acpi/acpivar.h> 37#include <dev/acpi/acpivar.h>
38#include <dev/acpi/acpi_intr.h> 38#include <dev/acpi/acpi_intr.h>
39 39
40#include <dev/sdmmc/sdhcreg.h> 40#include <dev/sdmmc/sdhcreg.h>
41#include <dev/sdmmc/sdhcvar.h> 41#include <dev/sdmmc/sdhcvar.h>
42#include <dev/sdmmc/sdmmcvar.h> 42#include <dev/sdmmc/sdmmcvar.h>
43 43
44#define _COMPONENT ACPI_RESOURCE_COMPONENT 44#define _COMPONENT ACPI_RESOURCE_COMPONENT
45ACPI_MODULE_NAME ("sdhc_acpi") 45ACPI_MODULE_NAME ("sdhc_acpi")
46 46
47static int sdhc_acpi_match(device_t, cfdata_t, void *); 47static int sdhc_acpi_match(device_t, cfdata_t, void *);
48static void sdhc_acpi_attach(device_t, device_t, void *); 48static void sdhc_acpi_attach(device_t, device_t, void *);
49static int sdhc_acpi_detach(device_t, int); 49static int sdhc_acpi_detach(device_t, int);
50static bool sdhc_acpi_resume(device_t, const pmf_qual_t *); 50static bool sdhc_acpi_resume(device_t, const pmf_qual_t *);
51 51
52struct sdhc_acpi_softc { 52struct sdhc_acpi_softc {
53 struct sdhc_softc sc; 53 struct sdhc_softc sc;
54 bus_space_tag_t sc_memt; 54 bus_space_tag_t sc_memt;
55 bus_space_handle_t sc_memh; 55 bus_space_handle_t sc_memh;
56 bus_size_t sc_memsize; 56 bus_size_t sc_memsize;
57 void *sc_ih; 57 void *sc_ih;
58 58
59 ACPI_HANDLE sc_crs, sc_srs; 59 ACPI_HANDLE sc_crs, sc_srs;
60 ACPI_BUFFER sc_crs_buffer; 60 ACPI_BUFFER sc_crs_buffer;
61}; 61};
62 62
63CFATTACH_DECL_NEW(sdhc_acpi, sizeof(struct sdhc_acpi_softc), 63CFATTACH_DECL_NEW(sdhc_acpi, sizeof(struct sdhc_acpi_softc),
64 sdhc_acpi_match, sdhc_acpi_attach, sdhc_acpi_detach, NULL); 64 sdhc_acpi_match, sdhc_acpi_attach, sdhc_acpi_detach, NULL);
65 65
66static void sdhc_acpi_intel_emmc_hw_reset(struct sdhc_softc *, 66static void sdhc_acpi_intel_emmc_hw_reset(struct sdhc_softc *,
67 struct sdhc_host *); 67 struct sdhc_host *);
68 68
69static const struct sdhc_acpi_slot { 69static const struct sdhc_acpi_slot {
70 const char *hid; 70 const char *hid;
71 const char *uid; 71 const char *uid;
72 int type; 72 int type;
73#define SLOT_TYPE_SD 0 /* SD or SDIO */ 73#define SLOT_TYPE_SD 0 /* SD or SDIO */
74#define SLOT_TYPE_EMMC 1 /* eMMC */ 74#define SLOT_TYPE_EMMC 1 /* eMMC */
75} sdhc_acpi_slot_map[] = { 75} sdhc_acpi_slot_map[] = {
76 { "80865ACA", NULL, SLOT_TYPE_SD }, 76 { "80865ACA", NULL, SLOT_TYPE_SD },
77 { "80865ACC", NULL, SLOT_TYPE_EMMC }, 77 { "80865ACC", NULL, SLOT_TYPE_EMMC },
78 { "80865AD0", NULL, SLOT_TYPE_SD }, 78 { "80865AD0", NULL, SLOT_TYPE_SD },
79 { "80860F14", "1", SLOT_TYPE_EMMC }, 79 { "80860F14", "1", SLOT_TYPE_EMMC },
80 { "80860F14", "3", SLOT_TYPE_SD }, 80 { "80860F14", "3", SLOT_TYPE_SD },
81 { "80860F16", NULL, SLOT_TYPE_SD }, 81 { "80860F16", NULL, SLOT_TYPE_SD },
82 { "INT33BB", "2", SLOT_TYPE_SD }, 82 { "INT33BB", "2", SLOT_TYPE_SD },
83 { "INT33BB", "3", SLOT_TYPE_SD }, 83 { "INT33BB", "3", SLOT_TYPE_SD },
84 { "INT33C6", NULL, SLOT_TYPE_SD }, 84 { "INT33C6", NULL, SLOT_TYPE_SD },
85 { "INT3436", NULL, SLOT_TYPE_SD }, 85 { "INT3436", NULL, SLOT_TYPE_SD },
86 { "INT344D", NULL, SLOT_TYPE_SD }, 86 { "INT344D", NULL, SLOT_TYPE_SD },
87 { "PNP0D40", NULL, SLOT_TYPE_SD }, 87 { "PNP0D40", NULL, SLOT_TYPE_SD },
88 { "PNP0FFF", "3", SLOT_TYPE_SD }, 88 { "PNP0FFF", "3", SLOT_TYPE_SD },
89}; 89};
90 90
91static const struct sdhc_acpi_slot * 91static const struct sdhc_acpi_slot *
92sdhc_acpi_find_slot(ACPI_DEVICE_INFO *ad) 92sdhc_acpi_find_slot(ACPI_DEVICE_INFO *ad)
93{ 93{
94 const struct sdhc_acpi_slot *slot; 94 const struct sdhc_acpi_slot *slot;
95 const char *hid, *uid; 95 const char *hid, *uid;
96 size_t i; 96 size_t i;
97 97
98 hid = ad->HardwareId.String; 98 hid = ad->HardwareId.String;
99 uid = ad->UniqueId.String; 99 uid = ad->UniqueId.String;
100 100
101 if (!(ad->Valid & ACPI_VALID_HID) || hid == NULL) 101 if (!(ad->Valid & ACPI_VALID_HID) || hid == NULL)
102 return NULL; 102 return NULL;
103 103
104 for (i = 0; i < __arraycount(sdhc_acpi_slot_map); i++) { 104 for (i = 0; i < __arraycount(sdhc_acpi_slot_map); i++) {
105 slot = &sdhc_acpi_slot_map[i]; 105 slot = &sdhc_acpi_slot_map[i];
106 if (strcmp(hid, slot->hid) == 0) { 106 if (strcmp(hid, slot->hid) == 0) {
107 if (slot->uid == NULL || 107 if (slot->uid == NULL ||
108 ((ad->Valid & ACPI_VALID_UID) != 0 && 108 ((ad->Valid & ACPI_VALID_UID) != 0 &&
109 uid != NULL && 109 uid != NULL &&
110 strcmp(uid, slot->uid) == 0)) 110 strcmp(uid, slot->uid) == 0))
111 return slot; 111 return slot;
112 } 112 }
113 } 113 }
114 return NULL; 114 return NULL;
115} 115}
116 116
117static int 117static int
118sdhc_acpi_match(device_t parent, cfdata_t match, void *opaque) 118sdhc_acpi_match(device_t parent, cfdata_t match, void *opaque)
119{ 119{
120 struct acpi_attach_args *aa = opaque; 120 struct acpi_attach_args *aa = opaque;
121 121
122 if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) 122 if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
123 return 0; 123 return 0;
124 124
125 return sdhc_acpi_find_slot(aa->aa_node->ad_devinfo) != NULL; 125 return sdhc_acpi_find_slot(aa->aa_node->ad_devinfo) != NULL;
126} 126}
127 127
128static void 128static void
129sdhc_acpi_attach(device_t parent, device_t self, void *opaque) 129sdhc_acpi_attach(device_t parent, device_t self, void *opaque)
130{ 130{
131 struct sdhc_acpi_softc *sc = device_private(self); 131 struct sdhc_acpi_softc *sc = device_private(self);
132 struct acpi_attach_args *aa = opaque; 132 struct acpi_attach_args *aa = opaque;
133 const struct sdhc_acpi_slot *slot; 133 const struct sdhc_acpi_slot *slot;
134 struct acpi_resources res; 134 struct acpi_resources res;
135 struct acpi_mem *mem; 135 struct acpi_mem *mem;
136 struct acpi_irq *irq; 136 struct acpi_irq *irq;
137 ACPI_STATUS rv; 137 ACPI_STATUS rv;
 138 ACPI_INTEGER clock_freq;
138 139
139 sc->sc.sc_dev = self; 140 sc->sc.sc_dev = self;
140 sc->sc.sc_dmat = aa->aa_dmat; 141 sc->sc.sc_dmat = aa->aa_dmat;
141 sc->sc.sc_host = NULL; 142 sc->sc.sc_host = NULL;
142 sc->sc_memt = aa->aa_memt; 143 sc->sc_memt = aa->aa_memt;
143 144
144 slot = sdhc_acpi_find_slot(aa->aa_node->ad_devinfo); 145 slot = sdhc_acpi_find_slot(aa->aa_node->ad_devinfo);
145 if (slot->type == SLOT_TYPE_EMMC) 146 if (slot->type == SLOT_TYPE_EMMC)
146 sc->sc.sc_vendor_hw_reset = sdhc_acpi_intel_emmc_hw_reset; 147 sc->sc.sc_vendor_hw_reset = sdhc_acpi_intel_emmc_hw_reset;
147 148
148 rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", 149 rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
149 &res, &acpi_resource_parse_ops_default); 150 &res, &acpi_resource_parse_ops_default);
150 if (ACPI_FAILURE(rv)) 151 if (ACPI_FAILURE(rv))
151 return; 152 return;
152 153
153 AcpiGetHandle(aa->aa_node->ad_handle, "_CRS", &sc->sc_crs); 154 AcpiGetHandle(aa->aa_node->ad_handle, "_CRS", &sc->sc_crs);
154 AcpiGetHandle(aa->aa_node->ad_handle, "_SRS", &sc->sc_srs); 155 AcpiGetHandle(aa->aa_node->ad_handle, "_SRS", &sc->sc_srs);
155 if (sc->sc_crs && sc->sc_srs) { 156 if (sc->sc_crs && sc->sc_srs) {
156 /* XXX Why need this? */ 157 /* XXX Why need this? */
157 sc->sc_crs_buffer.Pointer = NULL; 158 sc->sc_crs_buffer.Pointer = NULL;
158 sc->sc_crs_buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 159 sc->sc_crs_buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
159 rv = AcpiGetCurrentResources(sc->sc_crs, &sc->sc_crs_buffer); 160 rv = AcpiGetCurrentResources(sc->sc_crs, &sc->sc_crs_buffer);
160 if (ACPI_FAILURE(rv)) 161 if (ACPI_FAILURE(rv))
161 sc->sc_crs = sc->sc_srs = NULL; 162 sc->sc_crs = sc->sc_srs = NULL;
162 } 163 }
163 164
164 mem = acpi_res_mem(&res, 0); 165 mem = acpi_res_mem(&res, 0);
165 irq = acpi_res_irq(&res, 0); 166 irq = acpi_res_irq(&res, 0);
166 if (mem == NULL || irq == NULL) { 167 if (mem == NULL || irq == NULL) {
167 aprint_error_dev(self, "incomplete resources\n"); 168 aprint_error_dev(self, "incomplete resources\n");
168 goto cleanup; 169 goto cleanup;
169 } 170 }
170 if (mem->ar_length == 0) { 171 if (mem->ar_length == 0) {
171 aprint_error_dev(self, "zero length memory resource\n"); 172 aprint_error_dev(self, "zero length memory resource\n");
172 goto cleanup; 173 goto cleanup;
173 } 174 }
174 sc->sc_memsize = mem->ar_length; 175 sc->sc_memsize = mem->ar_length;
175 176
176 if (bus_space_map(sc->sc_memt, mem->ar_base, sc->sc_memsize, 0, 177 if (bus_space_map(sc->sc_memt, mem->ar_base, sc->sc_memsize, 0,
177 &sc->sc_memh)) { 178 &sc->sc_memh)) {
178 aprint_error_dev(self, "couldn't map registers\n"); 179 aprint_error_dev(self, "couldn't map registers\n");
179 goto cleanup; 180 goto cleanup;
180 } 181 }
181 182
182 sc->sc_ih = acpi_intr_establish(self, 183 sc->sc_ih = acpi_intr_establish(self,
183 (uint64_t)(uintptr_t)aa->aa_node->ad_handle, 184 (uint64_t)(uintptr_t)aa->aa_node->ad_handle,
184 IPL_BIO, false, sdhc_intr, &sc->sc, device_xname(self)); 185 IPL_BIO, false, sdhc_intr, &sc->sc, device_xname(self));
185 if (sc->sc_ih == NULL) { 186 if (sc->sc_ih == NULL) {
186 aprint_error_dev(self, 187 aprint_error_dev(self,
187 "couldn't establish interrupt handler\n"); 188 "couldn't establish interrupt handler\n");
188 goto unmap; 189 goto unmap;
189 } 190 }
190 191
191 sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_SLEEP); 192 sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_SLEEP);
192 193
193 /* Enable DMA transfer */ 194 /* Enable DMA transfer */
194 sc->sc.sc_flags |= SDHC_FLAG_USE_DMA; 195 sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
195 196
 197 /* Read clock frequency from device properties */
 198 rv = acpi_dsd_integer(aa->aa_node->ad_handle, "clock-frequency",
 199 &clock_freq);
 200 if (ACPI_SUCCESS(rv))
 201 sc->sc.sc_clkbase = clock_freq / 1000;
 202
196 if (sdhc_host_found(&sc->sc, sc->sc_memt, sc->sc_memh, 203 if (sdhc_host_found(&sc->sc, sc->sc_memt, sc->sc_memh,
197 sc->sc_memsize) != 0) { 204 sc->sc_memsize) != 0) {
198 aprint_error_dev(self, "couldn't initialize host\n"); 205 aprint_error_dev(self, "couldn't initialize host\n");
199 goto fail; 206 goto fail;
200 } 207 }
201 208
202 if (!pmf_device_register1(self, sdhc_suspend, sdhc_acpi_resume, 209 if (!pmf_device_register1(self, sdhc_suspend, sdhc_acpi_resume,
203 sdhc_shutdown)) { 210 sdhc_shutdown)) {
204 aprint_error_dev(self, "couldn't establish powerhook\n"); 211 aprint_error_dev(self, "couldn't establish powerhook\n");
205 } 212 }
206 213
207 acpi_resource_cleanup(&res); 214 acpi_resource_cleanup(&res);
208 return; 215 return;
209 216
210fail: 217fail:
211 if (sc->sc.sc_host != NULL) 218 if (sc->sc.sc_host != NULL)
212 kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *)); 219 kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *));
213 sc->sc.sc_host = NULL; 220 sc->sc.sc_host = NULL;
214 if (sc->sc_ih != NULL) 221 if (sc->sc_ih != NULL)
215 acpi_intr_disestablish(sc->sc_ih); 222 acpi_intr_disestablish(sc->sc_ih);
216 sc->sc_ih = NULL; 223 sc->sc_ih = NULL;
217unmap: 224unmap:
218 bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsize); 225 bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsize);
219 sc->sc_memsize = 0; 226 sc->sc_memsize = 0;
220cleanup: 227cleanup:
221 if (sc->sc_crs_buffer.Pointer) 228 if (sc->sc_crs_buffer.Pointer)
222 ACPI_FREE(sc->sc_crs_buffer.Pointer); 229 ACPI_FREE(sc->sc_crs_buffer.Pointer);
223 sc->sc_crs_buffer.Pointer = NULL; 230 sc->sc_crs_buffer.Pointer = NULL;
224 acpi_resource_cleanup(&res); 231 acpi_resource_cleanup(&res);
225} 232}
226 233
227static int 234static int
228sdhc_acpi_detach(device_t self, int flags) 235sdhc_acpi_detach(device_t self, int flags)
229{ 236{
230 struct sdhc_acpi_softc *sc = device_private(self); 237 struct sdhc_acpi_softc *sc = device_private(self);
231 int rv; 238 int rv;
232 239
233 pmf_device_deregister(self); 240 pmf_device_deregister(self);
234 241
235 rv = sdhc_detach(&sc->sc, flags); 242 rv = sdhc_detach(&sc->sc, flags);
236 if (rv) 243 if (rv)
237 return rv; 244 return rv;
238 245
239 if (sc->sc_ih != NULL) 246 if (sc->sc_ih != NULL)
240 acpi_intr_disestablish(sc->sc_ih); 247 acpi_intr_disestablish(sc->sc_ih);
241 248
242 if (sc->sc.sc_host != NULL) 249 if (sc->sc.sc_host != NULL)
243 kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *)); 250 kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *));
244 251
245 if (sc->sc_memsize > 0) 252 if (sc->sc_memsize > 0)
246 bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsize); 253 bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsize);
247 254
248 if (sc->sc_crs_buffer.Pointer) 255 if (sc->sc_crs_buffer.Pointer)
249 ACPI_FREE(sc->sc_crs_buffer.Pointer); 256 ACPI_FREE(sc->sc_crs_buffer.Pointer);
250 257
251 return 0; 258 return 0;
252} 259}
253 260
254static bool 261static bool
255sdhc_acpi_resume(device_t self, const pmf_qual_t *qual) 262sdhc_acpi_resume(device_t self, const pmf_qual_t *qual)
256{ 263{
257 struct sdhc_acpi_softc *sc = device_private(self); 264 struct sdhc_acpi_softc *sc = device_private(self);
258 ACPI_STATUS rv; 265 ACPI_STATUS rv;
259 266
260 if (sc->sc_crs && sc->sc_srs) { 267 if (sc->sc_crs && sc->sc_srs) {
261 rv = AcpiSetCurrentResources(sc->sc_srs, &sc->sc_crs_buffer); 268 rv = AcpiSetCurrentResources(sc->sc_srs, &sc->sc_crs_buffer);
262 if (ACPI_FAILURE(rv)) 269 if (ACPI_FAILURE(rv))
263 printf("%s: _SRS failed: %s\n", 270 printf("%s: _SRS failed: %s\n",
264 device_xname(self), AcpiFormatException(rv)); 271 device_xname(self), AcpiFormatException(rv));
265 } 272 }
266 273
267 return sdhc_resume(self, qual); 274 return sdhc_resume(self, qual);
268} 275}
269 276
270static void 277static void
271sdhc_acpi_intel_emmc_hw_reset(struct sdhc_softc *sc, struct sdhc_host *hp) 278sdhc_acpi_intel_emmc_hw_reset(struct sdhc_softc *sc, struct sdhc_host *hp)
272{ 279{
273 kmutex_t *plock = sdhc_host_lock(hp); 280 kmutex_t *plock = sdhc_host_lock(hp);
274 uint8_t reg; 281 uint8_t reg;
275 282
276 mutex_enter(plock); 283 mutex_enter(plock);
277 284
278 reg = sdhc_host_read_1(hp, SDHC_POWER_CTL); 285 reg = sdhc_host_read_1(hp, SDHC_POWER_CTL);
279 reg |= 0x10; 286 reg |= 0x10;
280 sdhc_host_write_1(hp, SDHC_POWER_CTL, reg); 287 sdhc_host_write_1(hp, SDHC_POWER_CTL, reg);
281 288
282 sdmmc_delay(10); 289 sdmmc_delay(10);
283 290
284 reg &= ~0x10; 291 reg &= ~0x10;
285 sdhc_host_write_1(hp, SDHC_POWER_CTL, reg); 292 sdhc_host_write_1(hp, SDHC_POWER_CTL, reg);
286 293
287 sdmmc_delay(1000); 294 sdmmc_delay(1000);
288 295
289 mutex_exit(plock); 296 mutex_exit(plock);
290} 297}