Lines 55-60
__FBSDID("$FreeBSD$");
Link Here
|
55 |
|
55 |
|
56 |
#include <dev/rtwn/if_rtwn_debug.h> |
56 |
#include <dev/rtwn/if_rtwn_debug.h> |
57 |
|
57 |
|
|
|
58 |
#include <dev/rtwn/usb/rtwn_usb_var.h> |
59 |
|
58 |
#include <dev/rtwn/rtl8192c/r92c.h> |
60 |
#include <dev/rtwn/rtl8192c/r92c.h> |
59 |
|
61 |
|
60 |
#include <dev/rtwn/rtl8192e/r92e.h> |
62 |
#include <dev/rtwn/rtl8192e/r92e.h> |
Lines 226-233
r92e_power_on(struct rtwn_softc *sc)
Link Here
|
226 |
if (res != 0) \ |
228 |
if (res != 0) \ |
227 |
return (EIO); \ |
229 |
return (EIO); \ |
228 |
} while(0) |
230 |
} while(0) |
|
|
231 |
struct rtwn_usb_softc *uc; |
229 |
int ntries; |
232 |
int ntries; |
230 |
|
233 |
|
|
|
234 |
if ((uc = RTWN_USB_SOFTC(sc)) != NULL) { |
235 |
RTWN_LOCK(sc); |
236 |
uc->uc_write_delay = 1; |
237 |
RTWN_UNLOCK(sc); |
238 |
} |
239 |
|
231 |
if (rtwn_read_4(sc, R92C_SYS_CFG) & R92C_SYS_CFG_TRP_BT_EN) |
240 |
if (rtwn_read_4(sc, R92C_SYS_CFG) & R92C_SYS_CFG_TRP_BT_EN) |
232 |
RTWN_CHK(rtwn_write_1(sc, R92C_LDO_SWR_CTRL, 0xc3)); |
241 |
RTWN_CHK(rtwn_write_1(sc, R92C_LDO_SWR_CTRL, 0xc3)); |
233 |
else { |
242 |
else { |
Lines 254-259
r92e_power_on(struct rtwn_softc *sc)
Link Here
|
254 |
rtwn_delay(sc, 10); |
263 |
rtwn_delay(sc, 10); |
255 |
} |
264 |
} |
256 |
if (ntries == 5000) { |
265 |
if (ntries == 5000) { |
|
|
266 |
if (uc != NULL) { |
267 |
RTWN_LOCK(sc); |
268 |
uc->uc_write_delay = 0; |
269 |
RTWN_UNLOCK(sc); |
270 |
} |
257 |
device_printf(sc->sc_dev, |
271 |
device_printf(sc->sc_dev, |
258 |
"timeout waiting for chip power up\n"); |
272 |
"timeout waiting for chip power up\n"); |
259 |
return (ETIMEDOUT); |
273 |
return (ETIMEDOUT); |
Lines 271-278
r92e_power_on(struct rtwn_softc *sc)
Link Here
|
271 |
break; |
285 |
break; |
272 |
rtwn_delay(sc, 10); |
286 |
rtwn_delay(sc, 10); |
273 |
} |
287 |
} |
274 |
if (ntries == 5000) |
288 |
if (ntries == 5000) { |
|
|
289 |
if (uc != NULL) { |
290 |
RTWN_LOCK(sc); |
291 |
uc->uc_write_delay = 0; |
292 |
RTWN_UNLOCK(sc); |
293 |
} |
275 |
return (ETIMEDOUT); |
294 |
return (ETIMEDOUT); |
|
|
295 |
} |
276 |
|
296 |
|
277 |
/* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */ |
297 |
/* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */ |
278 |
RTWN_CHK(rtwn_write_2(sc, R92C_CR, 0)); |
298 |
RTWN_CHK(rtwn_write_2(sc, R92C_CR, 0)); |
Lines 283-300
r92e_power_on(struct rtwn_softc *sc)
Link Here
|
283 |
((sc->sc_hwcrypto != RTWN_CRYPTO_SW) ? R92C_CR_ENSEC : 0) | |
303 |
((sc->sc_hwcrypto != RTWN_CRYPTO_SW) ? R92C_CR_ENSEC : 0) | |
284 |
R92C_CR_CALTMR_EN)); |
304 |
R92C_CR_CALTMR_EN)); |
285 |
|
305 |
|
|
|
306 |
if (uc != NULL) { |
307 |
RTWN_LOCK(sc); |
308 |
uc->uc_write_delay = 0; |
309 |
RTWN_UNLOCK(sc); |
310 |
} |
286 |
return (0); |
311 |
return (0); |
287 |
} |
312 |
} |
288 |
|
313 |
|
289 |
void |
314 |
void |
290 |
r92e_power_off(struct rtwn_softc *sc) |
315 |
r92e_power_off(struct rtwn_softc *sc) |
291 |
{ |
316 |
{ |
|
|
317 |
struct rtwn_usb_softc *uc; |
292 |
int error, ntries; |
318 |
int error, ntries; |
293 |
|
319 |
|
|
|
320 |
if ((uc = RTWN_USB_SOFTC(sc)) != NULL) { |
321 |
RTWN_LOCK(sc); |
322 |
uc->uc_write_delay = 1; |
323 |
RTWN_UNLOCK(sc); |
324 |
} |
325 |
|
294 |
/* Stop Rx. */ |
326 |
/* Stop Rx. */ |
295 |
error = rtwn_write_1(sc, R92C_CR, 0); |
327 |
error = rtwn_write_1(sc, R92C_CR, 0); |
296 |
if (error == ENXIO) /* hardware gone */ |
328 |
if (error == ENXIO) { /* hardware gone */ |
|
|
329 |
if (uc != NULL) { |
330 |
RTWN_LOCK(sc); |
331 |
uc->uc_write_delay = 0; |
332 |
RTWN_UNLOCK(sc); |
333 |
} |
297 |
return; |
334 |
return; |
|
|
335 |
} |
298 |
|
336 |
|
299 |
/* Move card to Low Power state. */ |
337 |
/* Move card to Low Power state. */ |
300 |
/* Block all Tx queues. */ |
338 |
/* Block all Tx queues. */ |
Lines 308-313
r92e_power_off(struct rtwn_softc *sc)
Link Here
|
308 |
rtwn_delay(sc, 10); |
346 |
rtwn_delay(sc, 10); |
309 |
} |
347 |
} |
310 |
if (ntries == 5000) { |
348 |
if (ntries == 5000) { |
|
|
349 |
if (uc != NULL) { |
350 |
RTWN_LOCK(sc); |
351 |
uc->uc_write_delay = 0; |
352 |
RTWN_UNLOCK(sc); |
353 |
} |
311 |
device_printf(sc->sc_dev, "%s: failed to block Tx queues\n", |
354 |
device_printf(sc->sc_dev, "%s: failed to block Tx queues\n", |
312 |
__func__); |
355 |
__func__); |
313 |
return; |
356 |
return; |
Lines 365-370
r92e_power_off(struct rtwn_softc *sc)
Link Here
|
365 |
rtwn_delay(sc, 10); |
408 |
rtwn_delay(sc, 10); |
366 |
} |
409 |
} |
367 |
if (ntries == 5000) { |
410 |
if (ntries == 5000) { |
|
|
411 |
if (uc != NULL) { |
412 |
RTWN_LOCK(sc); |
413 |
uc->uc_write_delay = 0; |
414 |
RTWN_UNLOCK(sc); |
415 |
} |
368 |
device_printf(sc->sc_dev, "%s: could not turn off MAC\n", |
416 |
device_printf(sc->sc_dev, "%s: could not turn off MAC\n", |
369 |
__func__); |
417 |
__func__); |
370 |
return; |
418 |
return; |
Lines 387-390
r92e_power_off(struct rtwn_softc *sc)
Link Here
|
387 |
/* Enable SW LPS. */ |
435 |
/* Enable SW LPS. */ |
388 |
rtwn_setbits_1_shift(sc, R92C_APS_FSMCO, 0, |
436 |
rtwn_setbits_1_shift(sc, R92C_APS_FSMCO, 0, |
389 |
R92C_APS_FSMCO_APFM_RSM, 1); |
437 |
R92C_APS_FSMCO_APFM_RSM, 1); |
|
|
438 |
if (uc != NULL) { |
439 |
RTWN_LOCK(sc); |
440 |
uc->uc_write_delay = 0; |
441 |
RTWN_UNLOCK(sc); |
442 |
} |
443 |
|
390 |
} |
444 |
} |