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#ifdef AH_DEBUG 75185377Ssam static const char* modes[] = { 76185377Ssam "AWAKE", 77185377Ssam "FULL-SLEEP", 78185377Ssam "NETWORK SLEEP", 79185377Ssam "UNDEFINED" 80185377Ssam }; 81185377Ssam#endif 82185377Ssam int status = AH_TRUE; 83185377Ssam 84185377Ssam HALDEBUG(ah, HAL_DEBUG_POWER, "%s: %s -> %s (%s)\n", __func__, 85262969Sadrian modes[ah->ah_powerMode], modes[mode], 86185377Ssam setChip ? "set chip " : ""); 87185377Ssam switch (mode) { 88185377Ssam case HAL_PM_AWAKE: 89185377Ssam status = ar5312SetPowerModeAwake(ah, setChip); 90185377Ssam break; 91185377Ssam case HAL_PM_FULL_SLEEP: 92185377Ssam ar5312SetPowerModeSleep(ah, setChip); 93185377Ssam break; 94185377Ssam case HAL_PM_NETWORK_SLEEP: 95185377Ssam ar5312SetPowerModeNetworkSleep(ah, setChip); 96185377Ssam break; 97185377Ssam default: 98185377Ssam HALDEBUG(ah, HAL_DEBUG_POWER, "%s: unknown power mode %u\n", 99185377Ssam __func__, mode); 100185377Ssam return AH_FALSE; 101185377Ssam } 102262969Sadrian ah->ah_powerMode = mode; 103185377Ssam return status; 104185377Ssam} 105185377Ssam 106185377Ssam/* 107185377Ssam * Return the current sleep mode of the chip 108185377Ssam */ 109185377Ssamuint32_t 110185377Ssamar5312GetPowerMode(struct ath_hal *ah) 111185377Ssam{ 112185377Ssam return HAL_PM_AWAKE; 113185377Ssam} 114185377Ssam 115185377Ssam/* 116185377Ssam * Return the current sleep state of the chip 117185377Ssam * TRUE = sleeping 118185377Ssam */ 119185377SsamHAL_BOOL 120185377Ssamar5312GetPowerStatus(struct ath_hal *ah) 121185377Ssam{ 122185377Ssam return 0; /* Currently, 5312 is never in sleep mode. */ 123185377Ssam} 124185377Ssam#endif /* AH_SUPPORT_AR5312 */ 125