\hypertarget{ar5416__power_8c_source}{}\doxysection{ar5416\+\_\+power.\+c}
\label{ar5416__power_8c_source}\index{dev/ath/ath\_hal/ar5416/ar5416\_power.c@{dev/ath/ath\_hal/ar5416/ar5416\_power.c}}
\mbox{\hyperlink{ar5416__power_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: ISC}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2002-\/2008 Sam Leffler, Errno Consulting}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00005}00005 \textcolor{comment}{ * Copyright (c) 2002-\/2008 Atheros Communications, Inc.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00007}00007 \textcolor{comment}{ * Permission to use, copy, modify, and/or distribute this software for any}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00008}00008 \textcolor{comment}{ * purpose with or without fee is hereby granted, provided that the above}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00009}00009 \textcolor{comment}{ * copyright notice and this permission notice appear in all copies.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00010}00010 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00011}00011 \textcolor{comment}{ * THE SOFTWARE IS PROVIDED "{}AS IS"{} AND THE AUTHOR DISCLAIMS ALL WARRANTIES}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00012}00012 \textcolor{comment}{ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00013}00013 \textcolor{comment}{ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00014}00014 \textcolor{comment}{ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00015}00015 \textcolor{comment}{ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00016}00016 \textcolor{comment}{ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00017}00017 \textcolor{comment}{ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00018}00018 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00019}00019 \textcolor{comment}{ * \$FreeBSD\$}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00020}00020 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00021}00021 \textcolor{preprocessor}{\#include "{}opt\_ah.h"{}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00022}00022 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00023}00023 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{ah_8h}{ah.h}}"{}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00024}00024 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{ah__internal_8h}{ah\_internal.h}}"{}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00025}00025 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00026}00026 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{ar5416_8h}{ar5416/ar5416.h}}"{}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00027}00027 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{ar5416reg_8h}{ar5416/ar5416reg.h}}"{}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00029}00029 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00030}00030 \textcolor{comment}{ * Notify Power Mgt is enabled in self-\/generated frames.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00031}00031 \textcolor{comment}{ * If requested, force chip awake.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00032}00032 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00033}00033 \textcolor{comment}{ * Returns A\_OK if chip is awake or successfully forced awake.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00034}00034 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00035}00035 \textcolor{comment}{ * WARNING WARNING WARNING}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00036}00036 \textcolor{comment}{ * There is a problem with the chip where sometimes it will not wake up.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00037}00037 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00038}00038 \textcolor{keyword}{static} \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39a}{HAL\_BOOL}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00039}\mbox{\hyperlink{ar5416__power_8c_a0206a32521eb34c1f545004f628e18c7}{00039}} \mbox{\hyperlink{ar5416__power_8c_a0206a32521eb34c1f545004f628e18c7}{ar5416SetPowerModeAwake}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structath__hal}{ath\_hal}} *ah, \textcolor{keywordtype}{int} setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00040}00040 \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00041}00041 \textcolor{preprocessor}{\#define POWER\_UP\_TIME   200000}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00042}00042         uint32\_t val;}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00043}00043         \textcolor{keywordtype}{int} i = 0;}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00044}00044 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00045}00045         \textcolor{keywordflow}{if} (setChip) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00046}00046                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00047}00047 \textcolor{comment}{                 * Do a Power-\/On-\/Reset if OWL is shutdown}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00048}00048 \textcolor{comment}{                 * the NetBSD driver  power-\/cycles the Cardbus slot}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00049}00049 \textcolor{comment}{                 * as part of the reset procedure.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00050}00050 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00051}00051                 \textcolor{keywordflow}{if} ((\mbox{\hyperlink{ah__osdep_8h_afded631196d59ba3443fc37addc9a2a6}{OS\_REG\_READ}}(ah, \mbox{\hyperlink{ar5416reg_8h_afff7ab6d748ed5cd5715987234a68ba0}{AR\_RTC\_STATUS}}) }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00052}00052                         \& \mbox{\hyperlink{ar5416reg_8h_af060eb4901e485845e625cd579947824}{AR\_RTC\_PM\_STATUS\_M}}) == \mbox{\hyperlink{ar5416reg_8h_a95c532c31d4d660d73f5424f0c1649a8}{AR\_RTC\_STATUS\_SHUTDOWN}}) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00053}00053                         \textcolor{keywordflow}{if} (!\mbox{\hyperlink{ar5416_8h_ae8ae0b50e36c92ff07152a6794502f31}{ar5416SetResetReg}}(ah, \mbox{\hyperlink{ah_8h_adf764cbdea00d65edcd07bb9953ad2b7a75635359649da89bfc314ba4323824cb}{HAL\_RESET\_POWER\_ON}}))}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00054}00054                                 \textcolor{keywordflow}{goto} bad;                       }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00055}00055                         \mbox{\hyperlink{ar5416_8h_a2d8648a62309d936106c5710b0fae06c}{AH5416}}(ah)-\/>ah\_initPLL(ah, \mbox{\hyperlink{ah__internal_8h_ab933afbd431099f80d5e58c5a6271b4a}{AH\_NULL}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00056}00056                 \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00058}00058                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{ar5416reg_8h_ac2bbf500e741f9d05ec62e721649ff20}{AR\_SREV\_HOWL}}(ah))}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00059}00059                         \mbox{\hyperlink{ah__internal_8h_a115457790a8a1d2c0bf64407fee993c7}{OS\_REG\_SET\_BIT}}(ah, \mbox{\hyperlink{ar5416reg_8h_a652cdf1bd7e104887fd619fc993f6b6c}{AR\_RTC\_RESET}}, \mbox{\hyperlink{ar5416reg_8h_a2dca334e51cb436497b00681374a13bf}{AR\_RTC\_RESET\_EN}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00060}00060 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00061}00061                 \mbox{\hyperlink{ah__internal_8h_a115457790a8a1d2c0bf64407fee993c7}{OS\_REG\_SET\_BIT}}(ah, \mbox{\hyperlink{ar5416reg_8h_a79d3ae4d21bcc49efe15da518cfb7208}{AR\_RTC\_FORCE\_WAKE}}, \mbox{\hyperlink{ar5416reg_8h_a52b64185f542d2dbe30d572c82953b24}{AR\_RTC\_FORCE\_WAKE\_EN}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00062}00062                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{ar5416reg_8h_ac2bbf500e741f9d05ec62e721649ff20}{AR\_SREV\_HOWL}}(ah))}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00063}00063                         \mbox{\hyperlink{ah__osdep_8h_a34b88156c4561e13f775e8b9cd9a5374}{OS\_DELAY}}(10000);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00064}00064                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00065}00065                         \mbox{\hyperlink{ah__osdep_8h_a34b88156c4561e13f775e8b9cd9a5374}{OS\_DELAY}}(50);   \textcolor{comment}{/* Give chip the chance to awake */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00066}00066 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00067}00067                 \textcolor{keywordflow}{for} (i = \mbox{\hyperlink{ar5416__power_8c_aa60a4e4fa86c0453150732d7898bfbdf}{POWER\_UP\_TIME}} / 50; i != 0; i-\/-\/) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00068}00068                         val = \mbox{\hyperlink{ah__osdep_8h_afded631196d59ba3443fc37addc9a2a6}{OS\_REG\_READ}}(ah, \mbox{\hyperlink{ar5416reg_8h_afff7ab6d748ed5cd5715987234a68ba0}{AR\_RTC\_STATUS}}) \& \mbox{\hyperlink{ar5416reg_8h_a058a700bd0a552d209d9a376389e4e09}{AR\_RTC\_STATUS\_M}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00069}00069                         \textcolor{keywordflow}{if} (val == \mbox{\hyperlink{ar5416reg_8h_ac9f34b40024356f4db69874d1056a6f4}{AR\_RTC\_STATUS\_ON}})}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00070}00070                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00071}00071                         \mbox{\hyperlink{ah__osdep_8h_a34b88156c4561e13f775e8b9cd9a5374}{OS\_DELAY}}(50);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00072}00072                         \mbox{\hyperlink{ah__internal_8h_a115457790a8a1d2c0bf64407fee993c7}{OS\_REG\_SET\_BIT}}(ah, \mbox{\hyperlink{ar5416reg_8h_a79d3ae4d21bcc49efe15da518cfb7208}{AR\_RTC\_FORCE\_WAKE}}, \mbox{\hyperlink{ar5416reg_8h_a52b64185f542d2dbe30d572c82953b24}{AR\_RTC\_FORCE\_WAKE\_EN}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00073}00073                 \}               }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00074}00074         bad:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00075}00075                 \textcolor{keywordflow}{if} (i == 0) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00076}00076 \textcolor{preprocessor}{\#ifdef AH\_DEBUG}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00077}00077                         \mbox{\hyperlink{ah__osdep_8c_ab05b380aa2dabe9a6f6f1c13c6a482cf}{ath\_hal\_printf}}(ah, \textcolor{stringliteral}{"{}\%s: Failed to wakeup in \%ums\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00078}00078                                 \_\_func\_\_, \mbox{\hyperlink{ar5416__power_8c_aa60a4e4fa86c0453150732d7898bfbdf}{POWER\_UP\_TIME}}/1000);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00079}00079 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00080}00080                         \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39aa46085f3e46cbceb46c46b0bde64a6c20}{AH\_FALSE}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00081}00081                 \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00082}00082         \} }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00083}00083 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00084}00084         \mbox{\hyperlink{ah__internal_8h_a744f55d778d9d8426dc5190616d865e0}{OS\_REG\_CLR\_BIT}}(ah, \mbox{\hyperlink{ar5210reg_8h_a3449425878b8a4ad684aa58673c97f9e}{AR\_STA\_ID1}}, \mbox{\hyperlink{ar5211reg_8h_a6c6c19768dea12f1ac5c60b8e0369530}{AR\_STA\_ID1\_PWR\_SAV}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00085}00085         \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39aadc898cbb91e577b40c005576c51e8fdb}{AH\_TRUE}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00086}00086 \textcolor{preprocessor}{\#undef POWER\_UP\_TIME}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00087}00087 \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00088}00088 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00089}00089 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00090}00090 \textcolor{comment}{ * Notify Power Mgt is disabled in self-\/generated frames.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00091}00091 \textcolor{comment}{ * If requested, force chip to sleep.}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00092}00092 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00093}00093 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00094}\mbox{\hyperlink{ar5416__power_8c_aaa824b14ab90b694b3a09ecc739d3863}{00094}} \mbox{\hyperlink{ar5416__power_8c_aaa824b14ab90b694b3a09ecc739d3863}{ar5416SetPowerModeSleep}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structath__hal}{ath\_hal}} *ah, \textcolor{keywordtype}{int} setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00095}00095 \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00096}00096         \mbox{\hyperlink{ah__internal_8h_a115457790a8a1d2c0bf64407fee993c7}{OS\_REG\_SET\_BIT}}(ah, \mbox{\hyperlink{ar5210reg_8h_a3449425878b8a4ad684aa58673c97f9e}{AR\_STA\_ID1}}, \mbox{\hyperlink{ar5211reg_8h_a6c6c19768dea12f1ac5c60b8e0369530}{AR\_STA\_ID1\_PWR\_SAV}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00097}00097         \textcolor{keywordflow}{if} (setChip) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00098}00098                 \textcolor{comment}{/* Clear the RTC force wake bit to allow the mac to sleep */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00099}00099                 \mbox{\hyperlink{ah__internal_8h_a744f55d778d9d8426dc5190616d865e0}{OS\_REG\_CLR\_BIT}}(ah, \mbox{\hyperlink{ar5416reg_8h_a79d3ae4d21bcc49efe15da518cfb7208}{AR\_RTC\_FORCE\_WAKE}}, \mbox{\hyperlink{ar5416reg_8h_a52b64185f542d2dbe30d572c82953b24}{AR\_RTC\_FORCE\_WAKE\_EN}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00100}00100                 \textcolor{keywordflow}{if} (! \mbox{\hyperlink{ar5416reg_8h_ac2bbf500e741f9d05ec62e721649ff20}{AR\_SREV\_HOWL}}(ah))}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00101}00101                         \mbox{\hyperlink{ah__osdep_8h_a8e19d34bdc4596d48a978fc59e1b60fb}{OS\_REG\_WRITE}}(ah, \mbox{\hyperlink{ar5210reg_8h_aed89c9a0254eba1d8ae9289d744d1824}{AR\_RC}}, \mbox{\hyperlink{ar5416reg_8h_a7a32f346fcd0fe6c7ceb80c6e152e120}{AR\_RC\_AHB}}|\mbox{\hyperlink{ar5416reg_8h_a2d4fa527d5651793ffb797e12dc9a208}{AR\_RC\_HOSTIF}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00102}00102                 \textcolor{comment}{/* Shutdown chip. Active low */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00103}00103                 \textcolor{keywordflow}{if} (! \mbox{\hyperlink{ar5416reg_8h_aa4de7ae3059df6316c9a1945e7feb595}{AR\_SREV\_OWL}}(ah))}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00104}00104                         \mbox{\hyperlink{ah__internal_8h_a744f55d778d9d8426dc5190616d865e0}{OS\_REG\_CLR\_BIT}}(ah, \mbox{\hyperlink{ar5416reg_8h_a652cdf1bd7e104887fd619fc993f6b6c}{AR\_RTC\_RESET}}, \mbox{\hyperlink{ar5416reg_8h_a2dca334e51cb436497b00681374a13bf}{AR\_RTC\_RESET\_EN}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00105}00105         \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00106}00106 \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00107}00107 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00108}00108 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00109}00109 \textcolor{comment}{ * Notify Power Management is enabled in self-\/generating}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00110}00110 \textcolor{comment}{ * fames.  If request, set power mode of chip to}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00111}00111 \textcolor{comment}{ * auto/normal.  Duration in units of 128us (1/8 TU).}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00112}00112 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00113}00113 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00114}\mbox{\hyperlink{ar5416__power_8c_a2a095938d7b4d50de9daa97c37458622}{00114}} \mbox{\hyperlink{ar5416__power_8c_a2a095938d7b4d50de9daa97c37458622}{ar5416SetPowerModeNetworkSleep}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structath__hal}{ath\_hal}} *ah, \textcolor{keywordtype}{int} setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00115}00115 \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00116}00116         \mbox{\hyperlink{ah__internal_8h_a115457790a8a1d2c0bf64407fee993c7}{OS\_REG\_SET\_BIT}}(ah, \mbox{\hyperlink{ar5210reg_8h_a3449425878b8a4ad684aa58673c97f9e}{AR\_STA\_ID1}}, \mbox{\hyperlink{ar5211reg_8h_a6c6c19768dea12f1ac5c60b8e0369530}{AR\_STA\_ID1\_PWR\_SAV}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00117}00117 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00118}00118         \textcolor{keywordflow}{if} (setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00119}00119                 \mbox{\hyperlink{ah__internal_8h_a744f55d778d9d8426dc5190616d865e0}{OS\_REG\_CLR\_BIT}}(ah, \mbox{\hyperlink{ar5416reg_8h_a79d3ae4d21bcc49efe15da518cfb7208}{AR\_RTC\_FORCE\_WAKE}}, \mbox{\hyperlink{ar5416reg_8h_a52b64185f542d2dbe30d572c82953b24}{AR\_RTC\_FORCE\_WAKE\_EN}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00120}00120 \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00121}00121 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00122}00122 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00123}00123 \textcolor{comment}{ * Set power mgt to the requested mode, and conditionally set}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00124}00124 \textcolor{comment}{ * the chip as well}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00125}00125 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00126}00126 \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39a}{HAL\_BOOL}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00127}\mbox{\hyperlink{ar5416_8h_a6a8d652f69557e641d37d02568f44c39}{00127}} \mbox{\hyperlink{ar5416__power_8c_a6a8d652f69557e641d37d02568f44c39}{ar5416SetPowerMode}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structath__hal}{ath\_hal}} *ah, \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679}{HAL\_POWER\_MODE}} mode, \textcolor{keywordtype}{int} setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00128}00128 \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00129}00129 \textcolor{preprocessor}{\#ifdef AH\_DEBUG}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00130}00130         \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char}* \mbox{\hyperlink{ah__regdomain_8c_a51bafc1dc7a6bc7ea10a9d27dc538fa2}{modes}}[] = \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00131}00131                 \textcolor{stringliteral}{"{}AWAKE"{}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00132}00132                 \textcolor{stringliteral}{"{}FULL-\/SLEEP"{}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00133}00133                 \textcolor{stringliteral}{"{}NETWORK SLEEP"{}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00134}00134                 \textcolor{stringliteral}{"{}UNDEFINED"{}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00135}00135         \};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00136}00136 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00137}00137         \textcolor{keywordtype}{int} status = \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39aadc898cbb91e577b40c005576c51e8fdb}{AH\_TRUE}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00139}00139 \textcolor{preprocessor}{\#if 0}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00140}00140         \textcolor{keywordflow}{if} (!setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00141}00141                 \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39aadc898cbb91e577b40c005576c51e8fdb}{AH\_TRUE}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00142}00142 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00143}00143 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00144}00144         \mbox{\hyperlink{ah__internal_8h_ac09ac07206a85dc5f4079553a0520c4e}{HALDEBUG}}(ah, \mbox{\hyperlink{ah__debug_8h_a61dadd085c1777f559549e05962b2c9eae0170388650fa434fd210a84faffd903}{HAL\_DEBUG\_POWER}}, \textcolor{stringliteral}{"{}\%s: \%s -\/> \%s (\%s)\(\backslash\)n"{}}, \_\_func\_\_,}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00145}00145             \mbox{\hyperlink{ah__regdomain_8c_a51bafc1dc7a6bc7ea10a9d27dc538fa2}{modes}}[ah-\/>\mbox{\hyperlink{structath__hal_a8b89fe10ed10d784583dd165070322a2}{ah\_powerMode}}], \mbox{\hyperlink{ah__regdomain_8c_a51bafc1dc7a6bc7ea10a9d27dc538fa2}{modes}}[mode], setChip ? \textcolor{stringliteral}{"{}set chip "{}} : \textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00146}00146         \textcolor{keywordflow}{switch} (mode) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00147}00147         \textcolor{keywordflow}{case} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679a75d316373c0af3b3d0192bb3fe44fc7c}{HAL\_PM\_AWAKE}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00148}00148                 \textcolor{keywordflow}{if} (setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00149}00149                         ah-\/>\mbox{\hyperlink{structath__hal_a8b89fe10ed10d784583dd165070322a2}{ah\_powerMode}} = mode;}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00150}00150                 status = \mbox{\hyperlink{ar5416__power_8c_a0206a32521eb34c1f545004f628e18c7}{ar5416SetPowerModeAwake}}(ah, setChip);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00151}00151                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00152}00152         \textcolor{keywordflow}{case} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679adbe69065b7e1fb76540a8c9e0a337b0e}{HAL\_PM\_FULL\_SLEEP}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00153}00153                 \mbox{\hyperlink{ar5416__power_8c_aaa824b14ab90b694b3a09ecc739d3863}{ar5416SetPowerModeSleep}}(ah, setChip);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00154}00154                 \textcolor{keywordflow}{if} (setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00155}00155                         ah-\/>\mbox{\hyperlink{structath__hal_a8b89fe10ed10d784583dd165070322a2}{ah\_powerMode}} = mode;}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00156}00156                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00157}00157         \textcolor{keywordflow}{case} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679a1de51f765a05eadd50bbbd325e1c0409}{HAL\_PM\_NETWORK\_SLEEP}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00158}00158                 \mbox{\hyperlink{ar5416__power_8c_a2a095938d7b4d50de9daa97c37458622}{ar5416SetPowerModeNetworkSleep}}(ah, setChip);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00159}00159                 \textcolor{keywordflow}{if} (setChip)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00160}00160                         ah-\/>\mbox{\hyperlink{structath__hal_a8b89fe10ed10d784583dd165070322a2}{ah\_powerMode}} = mode;}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00161}00161                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00162}00162         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00163}00163                 \mbox{\hyperlink{ah__internal_8h_ac09ac07206a85dc5f4079553a0520c4e}{HALDEBUG}}(ah, \mbox{\hyperlink{ah__debug_8h_a61dadd085c1777f559549e05962b2c9ea35506ea938627da4c44204d0895d0bf8}{HAL\_DEBUG\_ANY}}, \textcolor{stringliteral}{"{}\%s: unknown power mode 0x\%x\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00164}00164                     \_\_func\_\_, mode);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00165}00165                 \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_ae8793e83d29537653565625006f5c39aa46085f3e46cbceb46c46b0bde64a6c20}{AH\_FALSE}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00166}00166         \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00167}00167         \textcolor{keywordflow}{return} status;}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00168}00168 \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00169}00169 }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00170}00170 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00171}00171 \textcolor{comment}{ * Return the current sleep mode of the chip}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00172}00172 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00173}00173 \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679}{HAL\_POWER\_MODE}}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00174}\mbox{\hyperlink{ar5416_8h_aea0596296f0f79df1a7f10aa3bab1ec3}{00174}} \mbox{\hyperlink{ar5416__power_8c_aea0596296f0f79df1a7f10aa3bab1ec3}{ar5416GetPowerMode}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structath__hal}{ath\_hal}} *ah)}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00175}00175 \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00176}00176         \textcolor{keywordtype}{int} mode = \mbox{\hyperlink{ah__osdep_8h_afded631196d59ba3443fc37addc9a2a6}{OS\_REG\_READ}}(ah, \mbox{\hyperlink{ar5416reg_8h_afff7ab6d748ed5cd5715987234a68ba0}{AR\_RTC\_STATUS}});}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00177}00177         \textcolor{keywordflow}{switch} (mode \& \mbox{\hyperlink{ar5416reg_8h_af060eb4901e485845e625cd579947824}{AR\_RTC\_PM\_STATUS\_M}}) \{}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00178}00178         \textcolor{keywordflow}{case} \mbox{\hyperlink{ar5416reg_8h_ac9f34b40024356f4db69874d1056a6f4}{AR\_RTC\_STATUS\_ON}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00179}00179         \textcolor{keywordflow}{case} \mbox{\hyperlink{ar5416reg_8h_a585f4cc91ab9b40c5e83c787b3bec1b9}{AR\_RTC\_STATUS\_WAKEUP}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00180}00180                 \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679a75d316373c0af3b3d0192bb3fe44fc7c}{HAL\_PM\_AWAKE}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00181}00181         \textcolor{keywordflow}{case} \mbox{\hyperlink{ar5416reg_8h_a3b1385ee7cf15807af500ee55ca0272b}{AR\_RTC\_STATUS\_SLEEP}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00182}00182                 \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679a1de51f765a05eadd50bbbd325e1c0409}{HAL\_PM\_NETWORK\_SLEEP}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00183}00183         \textcolor{keywordflow}{case} \mbox{\hyperlink{ar5416reg_8h_a95c532c31d4d660d73f5424f0c1649a8}{AR\_RTC\_STATUS\_SHUTDOWN}}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00184}00184                 \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679adbe69065b7e1fb76540a8c9e0a337b0e}{HAL\_PM\_FULL\_SLEEP}};}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00185}00185         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00186}00186                 \mbox{\hyperlink{ah__internal_8h_ac09ac07206a85dc5f4079553a0520c4e}{HALDEBUG}}(ah, \mbox{\hyperlink{ah__debug_8h_a61dadd085c1777f559549e05962b2c9ea35506ea938627da4c44204d0895d0bf8}{HAL\_DEBUG\_ANY}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00187}00187                     \textcolor{stringliteral}{"{}\%s: unknown power mode, RTC\_STATUS 0x\%x\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00188}00188                     \_\_func\_\_, mode);}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00189}00189                 \textcolor{keywordflow}{return} \mbox{\hyperlink{ah_8h_a48c3115e12caf57353013063438be679ae158b2e2aca4afbdab68e78e46dd69e1}{HAL\_PM\_UNDEFINED}};        }
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00190}00190         \}}
\DoxyCodeLine{\Hypertarget{ar5416__power_8c_source_l00191}00191 \}}

\end{DoxyCode}
