root/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. CheckPositive
  2. CheckNegative
  3. ODM_ReadAndConfig_MP_8723B_MAC_REG

   1 // SPDX-License-Identifier: GPL-2.0
   2 /******************************************************************************
   3 *
   4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5 *
   6 ******************************************************************************/
   7 
   8 #include <linux/kernel.h>
   9 #include "odm_precomp.h"
  10 
  11 static bool CheckPositive(
  12         PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
  13 )
  14 {
  15         u8 _BoardType =
  16                 ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /*  _GLNA */
  17                 ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /*  _GPA */
  18                 ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /*  _ALNA */
  19                 ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /*  _APA */
  20                 ((pDM_Odm->BoardType & BIT2) >> 2) << 4;  /*  _BT */
  21 
  22         u32   cond1   = Condition1, cond2 = Condition2;
  23         u32    driver1 =
  24                 pDM_Odm->CutVersion       << 24 |
  25                 pDM_Odm->SupportPlatform  << 16 |
  26                 pDM_Odm->PackageType      << 12 |
  27                 pDM_Odm->SupportInterface << 8  |
  28                 _BoardType;
  29 
  30         u32 driver2 =
  31                 pDM_Odm->TypeGLNA <<  0 |
  32                 pDM_Odm->TypeGPA  <<  8 |
  33                 pDM_Odm->TypeALNA << 16 |
  34                 pDM_Odm->TypeAPA  << 24;
  35 
  36         ODM_RT_TRACE(
  37                 pDM_Odm,
  38                 ODM_COMP_INIT,
  39                 ODM_DBG_TRACE,
  40                 (
  41                         "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n",
  42                         cond1,
  43                         cond2
  44                 )
  45         );
  46         ODM_RT_TRACE(
  47                 pDM_Odm,
  48                 ODM_COMP_INIT,
  49                 ODM_DBG_TRACE,
  50                 (
  51                         "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n",
  52                         driver1,
  53                         driver2
  54                 )
  55         );
  56 
  57         ODM_RT_TRACE(
  58                 pDM_Odm,
  59                 ODM_COMP_INIT,
  60                 ODM_DBG_TRACE,
  61                 (
  62                         "       (Platform, Interface) = (0x%X, 0x%X)\n",
  63                         pDM_Odm->SupportPlatform,
  64                         pDM_Odm->SupportInterface
  65                 )
  66         );
  67         ODM_RT_TRACE(
  68                 pDM_Odm,
  69                 ODM_COMP_INIT,
  70                 ODM_DBG_TRACE,
  71                 (
  72                         "       (Board, Package) = (0x%X, 0x%X)\n",
  73                         pDM_Odm->BoardType,
  74                         pDM_Odm->PackageType
  75                 )
  76         );
  77 
  78 
  79         /*  Value Defined Check =============== */
  80         /* QFN Type [15:12] and Cut Version [27:24] need to do value check */
  81 
  82         if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
  83                 return false;
  84         if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
  85                 return false;
  86 
  87         /*  Bit Defined Check ================ */
  88         /*  We don't care [31:28] and [23:20] */
  89         /*  */
  90         cond1   &= 0x000F0FFF;
  91         driver1 &= 0x000F0FFF;
  92 
  93         if ((cond1 & driver1) == cond1) {
  94                 u32 bitMask = 0;
  95                 if ((cond1 & 0x0F) == 0) /*  BoardType is DONTCARE */
  96                         return true;
  97 
  98                 if ((cond1 & BIT0) != 0) /* GLNA */
  99                         bitMask |= 0x000000FF;
 100                 if ((cond1 & BIT1) != 0) /* GPA */
 101                         bitMask |= 0x0000FF00;
 102                 if ((cond1 & BIT2) != 0) /* ALNA */
 103                         bitMask |= 0x00FF0000;
 104                 if ((cond1 & BIT3) != 0) /* APA */
 105                         bitMask |= 0xFF000000;
 106 
 107                 if ((cond2 & bitMask) == (driver2 & bitMask)) /*  BoardType of each RF path is matched */
 108                         return true;
 109         }
 110         return false;
 111 }
 112 
 113 static bool CheckNegative(
 114         PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
 115 )
 116 {
 117         return true;
 118 }
 119 
 120 /******************************************************************************
 121 *                           MAC_REG.TXT
 122 ******************************************************************************/
 123 
 124 static u32 Array_MP_8723B_MAC_REG[] = {
 125                 0x02F, 0x00000030,
 126                 0x035, 0x00000000,
 127                 0x039, 0x00000008,
 128                 0x04E, 0x000000E0,
 129                 0x064, 0x00000000,
 130                 0x067, 0x00000020,
 131                 0x428, 0x0000000A,
 132                 0x429, 0x00000010,
 133                 0x430, 0x00000000,
 134                 0x431, 0x00000000,
 135                 0x432, 0x00000000,
 136                 0x433, 0x00000001,
 137                 0x434, 0x00000004,
 138                 0x435, 0x00000005,
 139                 0x436, 0x00000007,
 140                 0x437, 0x00000008,
 141                 0x43C, 0x00000004,
 142                 0x43D, 0x00000005,
 143                 0x43E, 0x00000007,
 144                 0x43F, 0x00000008,
 145                 0x440, 0x0000005D,
 146                 0x441, 0x00000001,
 147                 0x442, 0x00000000,
 148                 0x444, 0x00000010,
 149                 0x445, 0x00000000,
 150                 0x446, 0x00000000,
 151                 0x447, 0x00000000,
 152                 0x448, 0x00000000,
 153                 0x449, 0x000000F0,
 154                 0x44A, 0x0000000F,
 155                 0x44B, 0x0000003E,
 156                 0x44C, 0x00000010,
 157                 0x44D, 0x00000000,
 158                 0x44E, 0x00000000,
 159                 0x44F, 0x00000000,
 160                 0x450, 0x00000000,
 161                 0x451, 0x000000F0,
 162                 0x452, 0x0000000F,
 163                 0x453, 0x00000000,
 164                 0x456, 0x0000005E,
 165                 0x460, 0x00000066,
 166                 0x461, 0x00000066,
 167                 0x4C8, 0x000000FF,
 168                 0x4C9, 0x00000008,
 169                 0x4CC, 0x000000FF,
 170                 0x4CD, 0x000000FF,
 171                 0x4CE, 0x00000001,
 172                 0x500, 0x00000026,
 173                 0x501, 0x000000A2,
 174                 0x502, 0x0000002F,
 175                 0x503, 0x00000000,
 176                 0x504, 0x00000028,
 177                 0x505, 0x000000A3,
 178                 0x506, 0x0000005E,
 179                 0x507, 0x00000000,
 180                 0x508, 0x0000002B,
 181                 0x509, 0x000000A4,
 182                 0x50A, 0x0000005E,
 183                 0x50B, 0x00000000,
 184                 0x50C, 0x0000004F,
 185                 0x50D, 0x000000A4,
 186                 0x50E, 0x00000000,
 187                 0x50F, 0x00000000,
 188                 0x512, 0x0000001C,
 189                 0x514, 0x0000000A,
 190                 0x516, 0x0000000A,
 191                 0x525, 0x0000004F,
 192                 0x550, 0x00000010,
 193                 0x551, 0x00000010,
 194                 0x559, 0x00000002,
 195                 0x55C, 0x00000050,
 196                 0x55D, 0x000000FF,
 197                 0x605, 0x00000030,
 198                 0x608, 0x0000000E,
 199                 0x609, 0x0000002A,
 200                 0x620, 0x000000FF,
 201                 0x621, 0x000000FF,
 202                 0x622, 0x000000FF,
 203                 0x623, 0x000000FF,
 204                 0x624, 0x000000FF,
 205                 0x625, 0x000000FF,
 206                 0x626, 0x000000FF,
 207                 0x627, 0x000000FF,
 208                 0x638, 0x00000050,
 209                 0x63C, 0x0000000A,
 210                 0x63D, 0x0000000A,
 211                 0x63E, 0x0000000E,
 212                 0x63F, 0x0000000E,
 213                 0x640, 0x00000040,
 214                 0x642, 0x00000040,
 215                 0x643, 0x00000000,
 216                 0x652, 0x000000C8,
 217                 0x66E, 0x00000005,
 218                 0x700, 0x00000021,
 219                 0x701, 0x00000043,
 220                 0x702, 0x00000065,
 221                 0x703, 0x00000087,
 222                 0x708, 0x00000021,
 223                 0x709, 0x00000043,
 224                 0x70A, 0x00000065,
 225                 0x70B, 0x00000087,
 226                 0x765, 0x00000018,
 227                 0x76E, 0x00000004,
 228 
 229 };
 230 
 231 void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
 232 {
 233         u32 i = 0;
 234         u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_MAC_REG);
 235         u32 *Array = Array_MP_8723B_MAC_REG;
 236 
 237         ODM_RT_TRACE(
 238                 pDM_Odm,
 239                 ODM_COMP_INIT,
 240                 ODM_DBG_LOUD,
 241                 ("===> ODM_ReadAndConfig_MP_8723B_MAC_REG\n")
 242         );
 243 
 244         for (i = 0; i < ArrayLen; i += 2) {
 245                 u32 v1 = Array[i];
 246                 u32 v2 = Array[i+1];
 247 
 248                 /*  This (offset, data) pair doesn't care the condition. */
 249                 if (v1 < 0x40000000) {
 250                         odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2);
 251                         continue;
 252                 } else {
 253                         /*  This line is the beginning of branch. */
 254                         bool bMatched = true;
 255                         u8  cCond  = (u8)((v1 & (BIT29|BIT28)) >> 28);
 256 
 257                         if (cCond == COND_ELSE) { /*  ELSE, ENDIF */
 258                                 bMatched = true;
 259                                 READ_NEXT_PAIR(v1, v2, i);
 260                         } else if (!CheckPositive(pDM_Odm, v1, v2)) {
 261                                 bMatched = false;
 262                                 READ_NEXT_PAIR(v1, v2, i);
 263                                 READ_NEXT_PAIR(v1, v2, i);
 264                         } else {
 265                                 READ_NEXT_PAIR(v1, v2, i);
 266                                 if (!CheckNegative(pDM_Odm, v1, v2))
 267                                         bMatched = false;
 268                                 else
 269                                         bMatched = true;
 270                                 READ_NEXT_PAIR(v1, v2, i);
 271                         }
 272 
 273                         if (!bMatched) {
 274                                 /*  Condition isn't matched. Discard the following (offset, data) pairs. */
 275                                 while (v1 < 0x40000000 && i < ArrayLen-2)
 276                                         READ_NEXT_PAIR(v1, v2, i);
 277 
 278                                 i -= 2; /*  prevent from for-loop += 2 */
 279                         } else { /*  Configure matched pairs and skip to end of if-else. */
 280                                 while (v1 < 0x40000000 && i < ArrayLen-2) {
 281                                         odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2);
 282                                         READ_NEXT_PAIR(v1, v2, i);
 283                                 }
 284 
 285                                 /*  Keeps reading until ENDIF. */
 286                                 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
 287                                 while (cCond != COND_ENDIF && i < ArrayLen-2) {
 288                                         READ_NEXT_PAIR(v1, v2, i);
 289                                         cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
 290                                 }
 291                         }
 292                 }
 293         }
 294 }

/* [<][>][^][v][top][bottom][index][help] */