1 /**************************************************************************** 2 **+-----------------------------------------------------------------------+** 3 **| |** 4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 5 **| All rights reserved. |** 6 **| |** 7 **| Redistribution and use in source and binary forms, with or without |** 8 **| modification, are permitted provided that the following conditions |** 9 **| are met: |** 10 **| |** 11 **| * Redistributions of source code must retain the above copyright |** 12 **| notice, this list of conditions and the following disclaimer. |** 13 **| * Redistributions in binary form must reproduce the above copyright |** 14 **| notice, this list of conditions and the following disclaimer in |** 15 **| the documentation and/or other materials provided with the |** 16 **| distribution. |** 17 **| * Neither the name Texas Instruments nor the names of its |** 18 **| contributors may be used to endorse or promote products derived |** 19 **| from this software without specific prior written permission. |** 20 **| |** 21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 32 **| |** 33 **+-----------------------------------------------------------------------+** 34 ****************************************************************************/ 35 /**************************************************************************/ 36 /* */ 37 /* MODULE: whalHwEeprom.h */ 38 /* PURPOSE: Wlan hardware EEPROM access routines implemenatation */ 39 /* */ 40 /**************************************************************************/ 41 #ifndef _WHAL_HW_EEPROM_H 42 #define _WHAL_HW_EEPROM_H 43 44 #include "whalCommon.h" 45 #include "TNETWIF.h" 46 47 typedef struct _HwEeprom_T 48 { 49 TI_HANDLE hTNETWIF; 50 TI_HANDLE hOs; 51 TI_HANDLE hReport; 52 } HwEeprom_T; 53 54 extern HwEeprom_T *whal_hwEeprom_Create(TI_HANDLE hOs); 55 extern int whal_hwEeprom_Destroy(HwEeprom_T *pHwEeprom); 56 extern int whal_hwEeprom_Config (HwEeprom_T *pHwEeprom, TI_HANDLE hTNETWIF, TI_HANDLE hReport); 57 58 #ifdef USE_SYNC_API 59 60 extern int whal_hwEeprom_GetRadioTypeAndEEPROMversion(HwEeprom_T *pHwEeprom, UINT32 *major, UINT32 *minor, UINT32 *bugfix); 61 62 /**************************** 63 Offsets of Wlan Hardware data 64 ****************************/ 65 #define HW_EEPROM_AGC_TABLE_ADDR 0x18C 66 #define HW_EEPROM_DAC_ADDR 0x20D 67 #define HW_EEPROM_BIAS_ADDR 0x20E 68 #define HW_EEPROM_OSC_ADDR 0x215 69 #define MAX_AGC_TABLE_ENTRIES 128 70 71 /******************* 72 EEPROM access APIs 73 *******************/ 74 #define MAX_OSC_CAL 15 75 #define EEPROM_ACCESS_TO 10000 /* timeout counter */ 76 #define INVALID_PARAMETER1 -101 77 78 79 80 81 82 83 84 /************************************************************************ 85 * UINT32 whal_hwEepromReadByte(UINT16 wAddr,UINT8 *pbVal) * 86 ************************************************************************* 87 * DESCRIPTION: Reads a single byte from EEPROM. * 88 * * 89 * INPUT: wAddr - 16-bits EEPROM addrress * 90 * pbVal - pointer the to output parameter - EEPROM value * 91 * * 92 * OUTPUT: *pbVal contains EEPROM value * 93 * * 94 * RETURN: OK - successful * 95 * NOK timeout * 96 *************************************************************************/ 97 UINT32 whal_hwEepromReadByte(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 *pbVal); 98 99 /************************************************************************ 100 * UINT32 whal_hwEepromWriteByte(UINT16 wAddr,UINT8 bVal) * 101 ************************************************************************* 102 * DESCRIPTION: Writes a single byte to EEPROM * 103 * * 104 * INPUT: wAddr - 16-bits EEPROM addrress * 105 * bVal - new value * 106 * * 107 * OUTPUT: N/A * 108 * * 109 * RETURN: OK - successful * 110 * NOK timeout * 111 *************************************************************************/ 112 UINT32 whal_hwEepromWriteByte(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 bVal); 113 114 /************************************************************************ 115 * UINT32 whal_hwEepromWriteByteNoUnp(UINT16 wAddr,UINT8 bVal) * 116 ************************************************************************* 117 * DESCRIPTION: Writes a single byte to EEPROM. The caller must * 118 * unprotect the EEPROM first. This is done for fast * 119 * programming of several data bytes. * 120 * * 121 * INPUT: wAddr - 16-bits EEPROM addrress * 122 * bVal - new value * 123 * * 124 * OUTPUT: N/A * 125 * * 126 * RETURN: OK - successful * 127 * NOK timeout * 128 *************************************************************************/ 129 UINT32 whal_hwEepromWriteByteNoUnp(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 bVal); 130 131 /************************************************************************ 132 * void whal_hwEepromProtect(void) * 133 ************************************************************************* 134 * DESCRIPTION: Set EEPROM write protection. * 135 * Inhibits writing to the EEPROM. * 136 * * 137 * INPUT: N/A * 138 * * 139 * OUTPUT: N/A * 140 * * 141 * RETURN: N/A * 142 *************************************************************************/ 143 void whal_hwEepromProtect(HwEeprom_T *pHwEeprom); 144 145 /************************************************************************ 146 * void whal_hwEepromUnprotect(void) * 147 ************************************************************************* 148 * DESCRIPTION: Remove EEPROM write protection. * 149 * Enables writing to the EEPROM. * 150 * * 151 * INPUT: N/A * 152 * * 153 * OUTPUT: N/A * 154 * * 155 * RETURN: N/A * 156 *************************************************************************/ 157 void whal_hwEepromUnprotect(HwEeprom_T *pHwEeprom); 158 159 /************************* 160 EEPROM data manipulation 161 *************************/ 162 163 /************************************************************************ 164 * UINT32 whal_hwEepromGetCalValue(UINT8 *pbVal) * 165 ************************************************************************* 166 * DESCRIPTION: Reads oscillator cal. value from EEPROM * 167 * * 168 * INPUT: N/A * 169 * * 170 * OUTPUT: pbVal - pointer to the output parameter * 171 * * 172 * RETURN: OK successful * 173 * NOK timeout * 174 *************************************************************************/ 175 UINT32 whal_hwEepromGetCalValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal); 176 177 /************************************************************************ 178 * UINT32 whal_hwEepromSetCalValue(UINT8 bVal) * 179 ************************************************************************* 180 * DESCRIPTION: Writes new oscillator cal. value to EEPROM * 181 * * 182 * INPUT: bVal - new oscillator cal. value * 183 * * 184 * OUTPUT: N/A * 185 * * 186 * RETURN: OK successful * 187 * NOK timeout or invalid value * 188 *************************************************************************/ 189 UINT32 whal_hwEepromSetCalValue(HwEeprom_T *pHwEeprom, UINT8 bVal); 190 191 /************************************************************************ 192 * UINT32 whal_hwEepromGetBiasValue(UINT8 *pbVal) * 193 ************************************************************************* 194 * DESCRIPTION: Reads bias value from EEPROM * 195 * * 196 * INPUT: N/A * 197 * * 198 * OUTPUT: pbVal - pointer to the output parameter * 199 * * 200 * RETURN: OK successful * 201 * NOK timeout * 202 *************************************************************************/ 203 UINT32 whal_hwEepromGetBiasValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal); 204 205 /************************************************************************ 206 * UINT32 whal_hwEepromSetBiasValue(UINT8 bVal) * 207 ************************************************************************* 208 * DESCRIPTION: Writes new bias value to EEPROM * 209 * * 210 * INPUT: bVal - new bias value * 211 * * 212 * OUTPUT: N/A * 213 * * 214 * RETURN: OK successful * 215 * NOK timeout * 216 *************************************************************************/ 217 UINT32 whal_hwEepromSetBiasValue(HwEeprom_T *pHwEeprom, UINT8 bVal); 218 219 /************************************************************************ 220 * UINT32 whal_hwEepromGetDACValue(UINT8 *pbVal) * 221 ************************************************************************* 222 * DESCRIPTION: Reads DAC value from EEPROM * 223 * * 224 * INPUT: N/A * 225 * * 226 * OUTPUT: pbVal - pointer to the output parameter * 227 * * 228 * RETURN: OK successful * 229 * NOK timeout * 230 *************************************************************************/ 231 UINT32 whal_hwEepromGetDACValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal); 232 233 /************************************************************************ 234 * UINT32 whal_hwEepromSetDACValue(UINT8 bVal) * 235 ************************************************************************* 236 * DESCRIPTION: Writes new DAC value to EEPROM * 237 * * 238 * INPUT: bVal - new DAC value * 239 * * 240 * OUTPUT: N/A * 241 * * 242 * RETURN: OK successful * 243 * NOK timeout * 244 *************************************************************************/ 245 UINT32 whal_hwEepromSetDACValue(HwEeprom_T *pHwEeprom, UINT8 bVal); 246 247 /************************************************************************ 248 * int whal_hwEepromLoadBaseBandTable(void) * 249 ************************************************************************* 250 * DESCRIPTION: Loads BB registers table from EEPROM * 251 * * 252 * INPUT: N/A * 253 * * 254 * OUTPUT: N/A * 255 * * 256 * RETURN: N/A * 257 *************************************************************************/ 258 int whal_hwEepromLoadBaseBandTable(HwEeprom_T *pHwEeprom); 259 260 /************************************************************************ 261 * UINT32 whal_hwEepromGetAGCCell(UINT8 bTableOffset, UINT8 *pbVal) * 262 ************************************************************************* 263 * DESCRIPTION: Reads one cell from ACG table * 264 * * 265 * INPUT: bTableOffset - zero-based offset of the cell in AGC * 266 * table * 267 * OUTPUT: pbVal - pointer to the output parameter * 268 * * 269 * RETURN: OK * 270 * NOK - EEPROM write error * 271 * INVALID_PARAMETER1 - invalid parameter 1 * 272 *************************************************************************/ 273 UINT32 whal_hwEepromGetAGCCell(HwEeprom_T *pHwEeprom, UINT8 bTableOffset, UINT8 *pbVal); 274 275 /************************************************************************ 276 * UINT32 whal_hwEepromSetAGCCell(UINT8 bTableOffset, UINT8 bVal) * 277 ************************************************************************* 278 * DESCRIPTION: Writes one AGC table cell to EEPROM * 279 * * 280 * INPUT: bTableOffset - zero-based offset of the cell in AGC * 281 * table * 282 * bVal - new cell value * 283 * OUTPUT: N/A * 284 * * 285 * RETURN: OK * 286 * NOK - EEPROM write error * 287 * INVALID_PARAMETER1 - invalid parameter 1 * 288 *************************************************************************/ 289 UINT32 whal_hwEepromSetAGCCell(HwEeprom_T *pHwEeprom, UINT8 bTableOffset, UINT8 bVal); 290 291 292 void whal_hwEeprom_DumpEEPROM(HwEeprom_T *pHwEeprom); 293 294 #endif /* USE_SYNC_API */ 295 296 297 #endif /* _WHAL_HW_EEPROM_H */ 298 299 300 301