Path: blob/main/sys/dev/ath/ath_hal/ar5312/ar5312_power.c
39566 views
/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2002-2008 Sam Leffler, Errno Consulting4* Copyright (c) 2002-2008 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/18#include "opt_ah.h"1920#ifdef AH_SUPPORT_AR53122122#include "ah.h"23#include "ah_internal.h"2425#include "ar5312/ar5312.h"26#include "ar5312/ar5312reg.h"27#include "ar5212/ar5212desc.h"2829/*30* Notify Power Mgt is enabled in self-generated frames.31* If requested, force chip awake.32*33* Returns A_OK if chip is awake or successfully forced awake.34*35* WARNING WARNING WARNING36* There is a problem with the chip where sometimes it will not wake up.37*/38static HAL_BOOL39ar5312SetPowerModeAwake(struct ath_hal *ah, int setChip)40{41/* No need for this at the moment for APs */42return AH_TRUE;43}4445/*46* Notify Power Mgt is disabled in self-generated frames.47* If requested, force chip to sleep.48*/49static void50ar5312SetPowerModeSleep(struct ath_hal *ah, int setChip)51{52/* No need for this at the moment for APs */53}5455/*56* Notify Power Management is enabled in self-generating57* fames. If request, set power mode of chip to58* auto/normal. Duration in units of 128us (1/8 TU).59*/60static void61ar5312SetPowerModeNetworkSleep(struct ath_hal *ah, int setChip)62{63/* No need for this at the moment for APs */64}6566/*67* Set power mgt to the requested mode, and conditionally set68* the chip as well69*/70HAL_BOOL71ar5312SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip)72{73#ifdef AH_DEBUG74static const char* modes[] = {75"AWAKE",76"FULL-SLEEP",77"NETWORK SLEEP",78"UNDEFINED"79};80#endif81int status = AH_TRUE;8283HALDEBUG(ah, HAL_DEBUG_POWER, "%s: %s -> %s (%s)\n", __func__,84modes[ah->ah_powerMode], modes[mode],85setChip ? "set chip " : "");86switch (mode) {87case HAL_PM_AWAKE:88status = ar5312SetPowerModeAwake(ah, setChip);89break;90case HAL_PM_FULL_SLEEP:91ar5312SetPowerModeSleep(ah, setChip);92break;93case HAL_PM_NETWORK_SLEEP:94ar5312SetPowerModeNetworkSleep(ah, setChip);95break;96default:97HALDEBUG(ah, HAL_DEBUG_POWER, "%s: unknown power mode %u\n",98__func__, mode);99return AH_FALSE;100}101ah->ah_powerMode = mode;102return status;103}104105/*106* Return the current sleep mode of the chip107*/108uint32_t109ar5312GetPowerMode(struct ath_hal *ah)110{111return HAL_PM_AWAKE;112}113114/*115* Return the current sleep state of the chip116* TRUE = sleeping117*/118HAL_BOOL119ar5312GetPowerStatus(struct ath_hal *ah)120{121return 0; /* Currently, 5312 is never in sleep mode. */122}123#endif /* AH_SUPPORT_AR5312 */124125126