summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2005-05-21 20:14:56 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2005-05-21 20:14:56 +0000
commit234b5755c3537864cb5d1d463413b5ab260999f4 (patch)
tree94565db63de3449a98f77edd8fcd95b86b05ca01 /sys/dev/ic
parent192e9f6efd27e5be2810bc98d9a6515947804698 (diff)
sync power management settings. this should fix some unrecoverable
sleep mode timeouts for ar5210, ar5211 and ar5212.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/ar5210.c22
-rw-r--r--sys/dev/ic/ar5211.c19
-rw-r--r--sys/dev/ic/ar5212.c5
3 files changed, 29 insertions, 17 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);
}
diff --git a/sys/dev/ic/ar5211.c b/sys/dev/ic/ar5211.c
index 52d7ca81307..06279fb8f3c 100644
--- a/sys/dev/ic/ar5211.c
+++ b/sys/dev/ic/ar5211.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5211.c,v 1.13 2005/05/08 14:46:50 reyk Exp $ */
+/* $OpenBSD: ar5211.c,v 1.14 2005/05/21 20:14:55 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -2105,14 +2105,21 @@ ar5k_ar5211_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_AR5211_STA_ID1);
+
switch (mode) {
case HAL_PM_AUTO:
+ staid &= ~AR5K_AR5211_STA_ID1_DEFAULT_ANTENNA;
+ /* fallthrough */
+ case HAL_PM_NETWORK_SLEEP:
if (set_chip == AH_TRUE) {
AR5K_REG_WRITE(AR5K_AR5211_SCR,
AR5K_AR5211_SCR_SLE | sleep_duration);
}
+ staid |= AR5K_AR5211_STA_ID1_PWR_SV;
break;
case HAL_PM_FULL_SLEEP:
@@ -2120,6 +2127,7 @@ ar5k_ar5211_set_power(hal, mode, set_chip, sleep_duration)
AR5K_REG_WRITE(AR5K_AR5211_SCR,
AR5K_AR5211_SCR_SLE_SLP);
}
+ staid |= AR5K_AR5211_STA_ID1_PWR_SV;
break;
case HAL_PM_AWAKE:
@@ -2143,10 +2151,10 @@ ar5k_ar5211_set_power(hal, mode, set_chip, sleep_duration)
/* Fail if the AR5211 didn't wake up */
if (i <= 0)
return (AH_FALSE);
+
+ staid &= ~AR5K_AR5211_STA_ID1_PWR_SV;
break;
- case HAL_PM_NETWORK_SLEEP:
- case HAL_PM_UNDEFINED:
default:
return (AH_FALSE);
}
@@ -2154,10 +2162,7 @@ ar5k_ar5211_set_power(hal, mode, set_chip, sleep_duration)
commit:
hal->ah_power_mode = mode;
- AR5K_REG_DISABLE_BITS(AR5K_AR5211_STA_ID1,
- AR5K_AR5211_STA_ID1_DEFAULT_ANTENNA);
- AR5K_REG_ENABLE_BITS(AR5K_AR5211_STA_ID1,
- AR5K_AR5211_STA_ID1_PWR_SV);
+ AR5K_REG_WRITE(AR5K_AR5211_STA_ID1, staid);
return (AH_TRUE);
}
diff --git a/sys/dev/ic/ar5212.c b/sys/dev/ic/ar5212.c
index 7e4812e43cd..abe67443f40 100644
--- a/sys/dev/ic/ar5212.c
+++ b/sys/dev/ic/ar5212.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5212.c,v 1.17 2005/05/21 19:01:41 reyk Exp $ */
+/* $OpenBSD: ar5212.c,v 1.18 2005/05/21 20:14:55 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -2418,6 +2418,9 @@ ar5k_ar5212_set_power(hal, mode, set_chip, sleep_duration)
staid = AR5K_REG_READ(AR5K_AR5212_STA_ID1);
switch (mode) {
+ case HAL_PM_AUTO:
+ staid &= ~AR5K_AR5212_STA_ID1_DEFAULT_ANTENNA;
+ /* fallthrough */
case HAL_PM_NETWORK_SLEEP:
if (set_chip == AH_TRUE) {
AR5K_REG_WRITE(AR5K_AR5212_SCR,