1 1.1 alc /* 2 1.1 alc * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3 1.1 alc * Copyright (c) 2002-2008 Atheros Communications, Inc. 4 1.1 alc * 5 1.1 alc * Permission to use, copy, modify, and/or distribute this software for any 6 1.1 alc * purpose with or without fee is hereby granted, provided that the above 7 1.1 alc * copyright notice and this permission notice appear in all copies. 8 1.1 alc * 9 1.1 alc * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 1.1 alc * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 1.1 alc * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 1.1 alc * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 1.1 alc * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 1.1 alc * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 1.1 alc * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 1.1 alc * 17 1.1 alc * $Id: ar5312_power.c,v 1.1.1.1 2008/12/11 04:46:45 alc Exp $ 18 1.1 alc */ 19 1.1 alc #include "opt_ah.h" 20 1.1 alc 21 1.1 alc #ifdef AH_SUPPORT_AR5312 22 1.1 alc 23 1.1 alc #include "ah.h" 24 1.1 alc #include "ah_internal.h" 25 1.1 alc 26 1.1 alc #include "ar5312/ar5312.h" 27 1.1 alc #include "ar5312/ar5312reg.h" 28 1.1 alc #include "ar5212/ar5212desc.h" 29 1.1 alc 30 1.1 alc /* 31 1.1 alc * Notify Power Mgt is enabled in self-generated frames. 32 1.1 alc * If requested, force chip awake. 33 1.1 alc * 34 1.1 alc * Returns A_OK if chip is awake or successfully forced awake. 35 1.1 alc * 36 1.1 alc * WARNING WARNING WARNING 37 1.1 alc * There is a problem with the chip where sometimes it will not wake up. 38 1.1 alc */ 39 1.1 alc static HAL_BOOL 40 1.1 alc ar5312SetPowerModeAwake(struct ath_hal *ah, int setChip) 41 1.1 alc { 42 1.1 alc /* No need for this at the moment for APs */ 43 1.1 alc return AH_TRUE; 44 1.1 alc } 45 1.1 alc 46 1.1 alc /* 47 1.1 alc * Notify Power Mgt is disabled in self-generated frames. 48 1.1 alc * If requested, force chip to sleep. 49 1.1 alc */ 50 1.1 alc static void 51 1.1 alc ar5312SetPowerModeSleep(struct ath_hal *ah, int setChip) 52 1.1 alc { 53 1.1 alc /* No need for this at the moment for APs */ 54 1.1 alc } 55 1.1 alc 56 1.1 alc /* 57 1.1 alc * Notify Power Management is enabled in self-generating 58 1.1 alc * fames. If request, set power mode of chip to 59 1.1 alc * auto/normal. Duration in units of 128us (1/8 TU). 60 1.1 alc */ 61 1.1 alc static void 62 1.1 alc ar5312SetPowerModeNetworkSleep(struct ath_hal *ah, int setChip) 63 1.1 alc { 64 1.1 alc /* No need for this at the moment for APs */ 65 1.1 alc } 66 1.1 alc 67 1.1 alc /* 68 1.1 alc * Set power mgt to the requested mode, and conditionally set 69 1.1 alc * the chip as well 70 1.1 alc */ 71 1.1 alc HAL_BOOL 72 1.1 alc ar5312SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip) 73 1.1 alc { 74 1.1 alc struct ath_hal_5212 *ahp = AH5212(ah); 75 1.1 alc #ifdef AH_DEBUG 76 1.1 alc static const char* modes[] = { 77 1.1 alc "AWAKE", 78 1.1 alc "FULL-SLEEP", 79 1.1 alc "NETWORK SLEEP", 80 1.1 alc "UNDEFINED" 81 1.1 alc }; 82 1.1 alc #endif 83 1.1 alc int status = AH_TRUE; 84 1.1 alc 85 1.1 alc HALDEBUG(ah, HAL_DEBUG_POWER, "%s: %s -> %s (%s)\n", __func__, 86 1.1 alc modes[ahp->ah_powerMode], modes[mode], 87 1.1 alc setChip ? "set chip " : ""); 88 1.1 alc switch (mode) { 89 1.1 alc case HAL_PM_AWAKE: 90 1.1 alc status = ar5312SetPowerModeAwake(ah, setChip); 91 1.1 alc break; 92 1.1 alc case HAL_PM_FULL_SLEEP: 93 1.1 alc ar5312SetPowerModeSleep(ah, setChip); 94 1.1 alc break; 95 1.1 alc case HAL_PM_NETWORK_SLEEP: 96 1.1 alc ar5312SetPowerModeNetworkSleep(ah, setChip); 97 1.1 alc break; 98 1.1 alc default: 99 1.1 alc HALDEBUG(ah, HAL_DEBUG_POWER, "%s: unknown power mode %u\n", 100 1.1 alc __func__, mode); 101 1.1 alc return AH_FALSE; 102 1.1 alc } 103 1.1 alc ahp->ah_powerMode = mode; 104 1.1 alc return status; 105 1.1 alc } 106 1.1 alc 107 1.1 alc /* 108 1.1 alc * Return the current sleep mode of the chip 109 1.1 alc */ 110 1.1 alc uint32_t 111 1.1 alc ar5312GetPowerMode(struct ath_hal *ah) 112 1.1 alc { 113 1.1 alc return HAL_PM_AWAKE; 114 1.1 alc } 115 1.1 alc 116 1.1 alc /* 117 1.1 alc * Return the current sleep state of the chip 118 1.1 alc * TRUE = sleeping 119 1.1 alc */ 120 1.1 alc HAL_BOOL 121 1.1 alc ar5312GetPowerStatus(struct ath_hal *ah) 122 1.1 alc { 123 1.1 alc return 0; /* Currently, 5312 is never in sleep mode. */ 124 1.1 alc } 125 1.1 alc #endif /* AH_SUPPORT_AR5312 */ 126