\hypertarget{r12a__rf_8c_source}{}\doxysection{r12a\+\_\+rf.\+c}
\label{r12a__rf_8c_source}\index{dev/rtwn/rtl8812a/r12a\_rf.c@{dev/rtwn/rtl8812a/r12a\_rf.c}}
\mbox{\hyperlink{r12a__rf_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00002}00002 \textcolor{comment}{ * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00003}00003 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00004}00004 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00005}00005 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00006}00006 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00007}00007 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00008}00008 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00009}00009 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00010}00010 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00012}00012 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00013}00013 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00014}00014 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00015}00015 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00016}00016 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00017}00017 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00018}00018 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00019}00019 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00020}00020 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00021}00021 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00022}00022 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00023}00023 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00024}00024 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00025}00025 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00026}00026 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00027}00027 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00028}\mbox{\hyperlink{r12a__rf_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00028}} \mbox{\hyperlink{r12a__rf_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00029}00029 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00030}00030 \textcolor{preprocessor}{\#include "{}opt\_wlan.h"{}}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/mutex.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/mbuf.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/socket.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/queue.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/taskqueue.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/bus.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/endian.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <sys/linker.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00045}00045 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00046}00046 \textcolor{preprocessor}{\#include <net/if.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <net/ethernet.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00048}00048 \textcolor{preprocessor}{\#include <net/if\_media.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00050}00050 \textcolor{preprocessor}{\#include <net80211/ieee80211\_var.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <net80211/ieee80211\_radiotap.h>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00052}00052 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00053}00053 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{if__rtwnreg_8h}{dev/rtwn/if\_rtwnreg.h}}>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00054}00054 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{if__rtwnvar_8h}{dev/rtwn/if\_rtwnvar.h}}>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00055}00055 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00056}00056 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{r12a_8h}{dev/rtwn/rtl8812a/r12a.h}}>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00057}00057 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{r12a__reg_8h}{dev/rtwn/rtl8812a/r12a\_reg.h}}>}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00058}00058 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00059}00059 uint32\_t}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00060}\mbox{\hyperlink{r12a_8h_abb838ff0c393f478fbdde110bb9ce329}{00060}} \mbox{\hyperlink{r12a__rf_8c_a788d0791ba008b8120dee96cec172182}{r12a\_rf\_read}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structrtwn__softc}{rtwn\_softc}} *sc, \textcolor{keywordtype}{int} chain, uint8\_t addr)}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00061}00061 \{}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00062}00062         uint32\_t pi\_mode, val;}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00063}00063 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00064}00064         \textcolor{comment}{/* Turn off CCA (avoids reading the wrong value). */}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00065}00065         \textcolor{keywordflow}{if} (addr != \mbox{\hyperlink{r92c__reg_8h_a739294bf73d680d1a39ab8544fb83806}{R92C\_RF\_AC}})}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00066}00066                 \mbox{\hyperlink{if__rtwnvar_8h_a108e6a2e96b424d9bff00da07e1e950c}{rtwn\_bb\_setbits}}(sc, \mbox{\hyperlink{r12a__reg_8h_a7a0687aba768d9da4e464f47d11dabfa}{R12A\_CCA\_ON\_SEC}}, 0, 0x08);}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00067}00067 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00068}00068         val = \mbox{\hyperlink{if__rtwnvar_8h_af11cc5dead469677938a0d194dfa0df9}{rtwn\_bb\_read}}(sc, \mbox{\hyperlink{r12a__reg_8h_aca5a080f8fac8191bc1cdd920da59449}{R12A\_HSSI\_PARAM1}}(chain));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00069}00069         pi\_mode = (val \& \mbox{\hyperlink{r12a__reg_8h_acce5d7f253b85ac70f6b6e4ffa2c566e}{R12A\_HSSI\_PARAM1\_PI}}) ? 1 : 0;}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00070}00070 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00071}00071         \mbox{\hyperlink{if__rtwnvar_8h_a108e6a2e96b424d9bff00da07e1e950c}{rtwn\_bb\_setbits}}(sc, \mbox{\hyperlink{r12a__reg_8h_adce3ab2f3c438d66e2fb825a3963bf94}{R12A\_HSSI\_PARAM2}},}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00072}00072             \mbox{\hyperlink{r12a__reg_8h_a2ba3b23f7052a1df31703e6e6620e878}{R12A\_HSSI\_PARAM2\_READ\_ADDR\_MASK}}, addr);}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00073}00073 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00074}00074         val = \mbox{\hyperlink{if__rtwnvar_8h_af11cc5dead469677938a0d194dfa0df9}{rtwn\_bb\_read}}(sc, pi\_mode ? \mbox{\hyperlink{r12a__reg_8h_a3197567aa104d633e30c381c53427101}{R12A\_HSPI\_READBACK}}(chain) :}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00075}00075             \mbox{\hyperlink{r12a__reg_8h_a9fb2065094f48bfd82f523315c5758cb}{R12A\_LSSI\_READBACK}}(chain));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00076}00076 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00077}00077         \textcolor{comment}{/* Turn on CCA (when exiting). */}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00078}00078         \textcolor{keywordflow}{if} (addr != \mbox{\hyperlink{r92c__reg_8h_a739294bf73d680d1a39ab8544fb83806}{R92C\_RF\_AC}})}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00079}00079                 \mbox{\hyperlink{if__rtwnvar_8h_a108e6a2e96b424d9bff00da07e1e950c}{rtwn\_bb\_setbits}}(sc, \mbox{\hyperlink{r12a__reg_8h_a7a0687aba768d9da4e464f47d11dabfa}{R12A\_CCA\_ON\_SEC}}, 0x08, 0);}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00080}00080 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00081}00081         \textcolor{keywordflow}{return} (\mbox{\hyperlink{if__rtwnreg_8h_aa1f710025311c0169fbc5b1296d914b6}{MS}}(val, R92C\_LSSI\_READBACK\_DATA));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00082}00082 \}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00083}00083 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00084}00084 uint32\_t}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00085}\mbox{\hyperlink{r12a_8h_a9a5840e4ccfd6a42515d7f83a904e5d0}{00085}} \mbox{\hyperlink{r12a__rf_8c_a62befa53fc8bf91bb4bd87f81339eef9}{r12a\_c\_cut\_rf\_read}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structrtwn__softc}{rtwn\_softc}} *sc, \textcolor{keywordtype}{int} chain, uint8\_t addr)}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00086}00086 \{}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00087}00087         uint32\_t pi\_mode, val;}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00088}00088 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00089}00089         val = \mbox{\hyperlink{if__rtwnvar_8h_af11cc5dead469677938a0d194dfa0df9}{rtwn\_bb\_read}}(sc, \mbox{\hyperlink{r12a__reg_8h_aca5a080f8fac8191bc1cdd920da59449}{R12A\_HSSI\_PARAM1}}(chain));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00090}00090         pi\_mode = (val \& \mbox{\hyperlink{r12a__reg_8h_acce5d7f253b85ac70f6b6e4ffa2c566e}{R12A\_HSSI\_PARAM1\_PI}}) ? 1 : 0;}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00091}00091 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00092}00092         \mbox{\hyperlink{if__rtwnvar_8h_a108e6a2e96b424d9bff00da07e1e950c}{rtwn\_bb\_setbits}}(sc, \mbox{\hyperlink{r12a__reg_8h_adce3ab2f3c438d66e2fb825a3963bf94}{R12A\_HSSI\_PARAM2}},}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00093}00093             \mbox{\hyperlink{r12a__reg_8h_a2ba3b23f7052a1df31703e6e6620e878}{R12A\_HSSI\_PARAM2\_READ\_ADDR\_MASK}}, addr);}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00094}00094         \mbox{\hyperlink{if__rtwnvar_8h_a3fe76ab201bc261d0950f661104812e2}{rtwn\_delay}}(sc, 20);}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00095}00095 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00096}00096         val = \mbox{\hyperlink{if__rtwnvar_8h_af11cc5dead469677938a0d194dfa0df9}{rtwn\_bb\_read}}(sc, pi\_mode ? \mbox{\hyperlink{r12a__reg_8h_a3197567aa104d633e30c381c53427101}{R12A\_HSPI\_READBACK}}(chain) :}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00097}00097             \mbox{\hyperlink{r12a__reg_8h_a9fb2065094f48bfd82f523315c5758cb}{R12A\_LSSI\_READBACK}}(chain));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00099}00099         \textcolor{keywordflow}{return} (\mbox{\hyperlink{if__rtwnreg_8h_aa1f710025311c0169fbc5b1296d914b6}{MS}}(val, R92C\_LSSI\_READBACK\_DATA));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00100}00100 \}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00101}00101 }
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00102}00102 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00103}\mbox{\hyperlink{r12a_8h_aa3375f991a082ce00ea906229ae20fd9}{00103}} \mbox{\hyperlink{r12a__rf_8c_a1df322b27800661c585b626bd9aa8b13}{r12a\_rf\_write}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structrtwn__softc}{rtwn\_softc}} *sc, \textcolor{keywordtype}{int} chain, uint8\_t addr,}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00104}00104     uint32\_t val)}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00105}00105 \{}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00106}00106         \mbox{\hyperlink{if__rtwnvar_8h_a0ff1edced16207606d6b996b11fddc6b}{rtwn\_bb\_write}}(sc, \mbox{\hyperlink{r12a__reg_8h_ad0a632b59e559194211e5859ab7d8fdf}{R12A\_LSSI\_PARAM}}(chain),}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00107}00107             \mbox{\hyperlink{if__rtwnreg_8h_a14155179e01608510206b9cdf4790068}{SM}}(R88E\_LSSI\_PARAM\_ADDR, addr) |}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00108}00108             \mbox{\hyperlink{if__rtwnreg_8h_a14155179e01608510206b9cdf4790068}{SM}}(R92C\_LSSI\_PARAM\_DATA, val));}
\DoxyCodeLine{\Hypertarget{r12a__rf_8c_source_l00109}00109 \}}

\end{DoxyCode}
