1185377Ssam/* 2185377Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3185377Ssam * Copyright (c) 2002-2008 Atheros Communications, Inc. 4185377Ssam * 5185377Ssam * Permission to use, copy, modify, and/or distribute this software for any 6185377Ssam * purpose with or without fee is hereby granted, provided that the above 7185377Ssam * copyright notice and this permission notice appear in all copies. 8185377Ssam * 9185377Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10185377Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11185377Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12185377Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13185377Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14185377Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15185377Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16185377Ssam * 17204644Srpaulo * $FreeBSD$ 18185377Ssam */ 19185377Ssam#include "opt_ah.h" 20185377Ssam 21185377Ssam#ifdef AH_SUPPORT_AR5312 22185377Ssam 23185377Ssam#include "ah.h" 24185377Ssam#include "ah_internal.h" 25185377Ssam 26185377Ssam#include "ar5312/ar5312.h" 27185377Ssam#include "ar5312/ar5312reg.h" 28185377Ssam#include "ar5212/ar5212desc.h" 29185377Ssam 30185377Ssam/* 31185377Ssam * Notify Power Mgt is enabled in self-generated frames. 32185377Ssam * If requested, force chip awake. 33185377Ssam * 34185377Ssam * Returns A_OK if chip is awake or successfully forced awake. 35185377Ssam * 36185377Ssam * WARNING WARNING WARNING 37185377Ssam * There is a problem with the chip where sometimes it will not wake up. 38185377Ssam */ 39185377Ssamstatic HAL_BOOL 40185377Ssamar5312SetPowerModeAwake(struct ath_hal *ah, int setChip) 41185377Ssam{ 42185377Ssam /* No need for this at the moment for APs */ 43185377Ssam return AH_TRUE; 44185377Ssam} 45185377Ssam 46185377Ssam/* 47185377Ssam * Notify Power Mgt is disabled in self-generated frames. 48185377Ssam * If requested, force chip to sleep. 49185377Ssam */ 50185377Ssamstatic void 51185377Ssamar5312SetPowerModeSleep(struct ath_hal *ah, int setChip) 52185377Ssam{ 53185377Ssam /* No need for this at the moment for APs */ 54185377Ssam} 55185377Ssam 56185377Ssam/* 57185377Ssam * Notify Power Management is enabled in self-generating 58185377Ssam * fames. If request, set power mode of chip to 59185377Ssam * auto/normal. Duration in units of 128us (1/8 TU). 60185377Ssam */ 61185377Ssamstatic void 62185377Ssamar5312SetPowerModeNetworkSleep(struct ath_hal *ah, int setChip) 63185377Ssam{ 64185377Ssam /* No need for this at the moment for APs */ 65185377Ssam} 66185377Ssam 67185377Ssam/* 68185377Ssam * Set power mgt to the requested mode, and conditionally set 69185377Ssam * the chip as well 70185377Ssam */ 71185377SsamHAL_BOOL 72185377Ssamar5312SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip) 73185377Ssam{ 74185377Ssam struct ath_hal_5212 *ahp = AH5212(ah); 75185377Ssam#ifdef AH_DEBUG 76185377Ssam static const char* modes[] = { 77185377Ssam "AWAKE", 78185377Ssam "FULL-SLEEP", 79185377Ssam "NETWORK SLEEP", 80185377Ssam "UNDEFINED" 81185377Ssam }; 82185377Ssam#endif 83185377Ssam int status = AH_TRUE; 84185377Ssam 85185377Ssam HALDEBUG(ah, HAL_DEBUG_POWER, "%s: %s -> %s (%s)\n", __func__, 86185377Ssam modes[ahp->ah_powerMode], modes[mode], 87185377Ssam setChip ? "set chip " : ""); 88185377Ssam switch (mode) { 89185377Ssam case HAL_PM_AWAKE: 90185377Ssam status = ar5312SetPowerModeAwake(ah, setChip); 91185377Ssam break; 92185377Ssam case HAL_PM_FULL_SLEEP: 93185377Ssam ar5312SetPowerModeSleep(ah, setChip); 94185377Ssam break; 95185377Ssam case HAL_PM_NETWORK_SLEEP: 96185377Ssam ar5312SetPowerModeNetworkSleep(ah, setChip); 97185377Ssam break; 98185377Ssam default: 99185377Ssam HALDEBUG(ah, HAL_DEBUG_POWER, "%s: unknown power mode %u\n", 100185377Ssam __func__, mode); 101185377Ssam return AH_FALSE; 102185377Ssam } 103185377Ssam ahp->ah_powerMode = mode; 104185377Ssam return status; 105185377Ssam} 106185377Ssam 107185377Ssam/* 108185377Ssam * Return the current sleep mode of the chip 109185377Ssam */ 110185377Ssamuint32_t 111185377Ssamar5312GetPowerMode(struct ath_hal *ah) 112185377Ssam{ 113185377Ssam return HAL_PM_AWAKE; 114185377Ssam} 115185377Ssam 116185377Ssam/* 117185377Ssam * Return the current sleep state of the chip 118185377Ssam * TRUE = sleeping 119185377Ssam */ 120185377SsamHAL_BOOL 121185377Ssamar5312GetPowerStatus(struct ath_hal *ah) 122185377Ssam{ 123185377Ssam return 0; /* Currently, 5312 is never in sleep mode. */ 124185377Ssam} 125185377Ssam#endif /* AH_SUPPORT_AR5312 */ 126