summaryrefslogtreecommitdiff
path: root/sys/dev/ic/ar5210.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ic/ar5210.c')
-rw-r--r--sys/dev/ic/ar5210.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/dev/ic/ar5210.c b/sys/dev/ic/ar5210.c
index 4f8e58a20e2..1c08ca87825 100644
--- a/sys/dev/ic/ar5210.c
+++ b/sys/dev/ic/ar5210.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5210.c,v 1.22 2005/05/08 14:55:09 reyk Exp $ */
+/* $OpenBSD: ar5210.c,v 1.23 2005/05/21 20:14:54 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -2016,14 +2016,21 @@ ar5k_ar5210_set_power(hal, mode, set_chip, sleep_duration)
HAL_BOOL set_chip;
u_int16_t sleep_duration;
{
+ u_int32_t staid;
int i;
+ staid = AR5K_REG_READ(AR5K_AR5210_STA_ID1);
+
switch (mode) {
case HAL_PM_AUTO:
+ staid &= ~AR5K_AR5210_STA_ID1_DEFAULT_ANTENNA;
+ /* fallthrough */
+ case HAL_PM_NETWORK_SLEEP:
if (set_chip == AH_TRUE) {
AR5K_REG_WRITE(AR5K_AR5210_SCR,
AR5K_AR5210_SCR_SLE | sleep_duration);
}
+ staid |= AR5K_AR5210_STA_ID1_PWR_SV;
break;
case HAL_PM_FULL_SLEEP:
@@ -2031,6 +2038,7 @@ ar5k_ar5210_set_power(hal, mode, set_chip, sleep_duration)
AR5K_REG_WRITE(AR5K_AR5210_SCR,
AR5K_AR5210_SCR_SLE_SLP);
}
+ staid |= AR5K_AR5210_STA_ID1_PWR_SV;
break;
case HAL_PM_AWAKE:
@@ -2038,12 +2046,11 @@ ar5k_ar5210_set_power(hal, mode, set_chip, sleep_duration)
goto commit;
AR5K_REG_WRITE(AR5K_AR5210_SCR, AR5K_AR5210_SCR_SLE_WAKE);
- AR5K_DELAY(2000);
for (i = 5000; i > 0; i--) {
/* Check if the AR5210 did wake up */
if ((AR5K_REG_READ(AR5K_AR5210_PCICFG) &
- AR5K_AR5210_PCICFG_SPWR_DN) == 0)
+ AR5K_AR5210_PCICFG_SPWR_DN) == 0)
break;
/* Wait a bit and retry */
@@ -2055,10 +2062,10 @@ ar5k_ar5210_set_power(hal, mode, set_chip, sleep_duration)
/* Fail if the AR5210 didn't wake up */
if (i <= 0)
return (AH_FALSE);
+
+ staid &= ~AR5K_AR5210_STA_ID1_PWR_SV;
break;
- case HAL_PM_NETWORK_SLEEP:
- case HAL_PM_UNDEFINED:
default:
return (AH_FALSE);
}
@@ -2066,10 +2073,7 @@ ar5k_ar5210_set_power(hal, mode, set_chip, sleep_duration)
commit:
hal->ah_power_mode = mode;
- AR5K_REG_DISABLE_BITS(AR5K_AR5210_STA_ID1,
- AR5K_AR5210_STA_ID1_DEFAULT_ANTENNA);
- AR5K_REG_ENABLE_BITS(AR5K_AR5210_STA_ID1,
- AR5K_AR5210_STA_ID1_PWR_SV);
+ AR5K_REG_WRITE(AR5K_AR5210_STA_ID1, staid);
return (AH_TRUE);
}