• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __PLT_H
2 #define __PLT_H
3 
4 #ifdef ANDROID
5 #define CURRENT_NVS_NAME    "/system/etc/firmware/ti-connectivity/wl1271-nvs.bin"
6 #else
7 #define CURRENT_NVS_NAME    "/lib/firmware/ti-connectivity/wl1271-nvs.bin"
8 #endif
9 #define NEW_NVS_NAME        "./new-nvs.bin"
10 #define NVS_FILE_SIZE_127X    0x390
11 #define NVS_FILE_SIZE_128X    0x459
12 
13 /* NVS definition start here */
14 
15 #define NVS_TX_TYPE_INDEX               0
16 
17 #define START_TYPE_INDEX_IN_TLV        0
18 #define TLV_TYPE_LENGTH                 1
19 #define START_LENGTH_INDEX              \
20 (START_TYPE_INDEX_IN_TLV + TLV_TYPE_LENGTH) /* 1 */
21 #define TLV_LENGTH_LENGTH               2
22 #define START_PARAM_INDEX               \
23 (START_LENGTH_INDEX + TLV_LENGTH_LENGTH) /* 3 */
24 
25 #define NVS_VERSION_1                   1
26 #define NVS_VERSION_2                   2
27 
28 #define NVS_MAC_FIRST_LENGTH_INDEX      0
29 #define NVS_MAC_FIRST_LENGHT_VALUE      1
30 
31 #define NVS_MAC_L_ADDRESS_INDEX         \
32 ((NVS_MAC_FIRST_LENGTH_INDEX) + 1) /* 1*/
33 #define NVS_MAC_L_ADDRESS_LENGTH        2
34 
35 #define NVS_MAC_L_VALUE_INDEX \
36 ((NVS_MAC_L_ADDRESS_INDEX) + (NVS_MAC_L_ADDRESS_LENGTH)) /* 3 */
37 
38 #define NVS_MAC_L_VALUE_LENGTH          4
39 
40 #define NVS_MAC_SECONDE_LENGTH_INDEX    \
41 ((NVS_MAC_L_VALUE_INDEX) + 4) /* 7 */
42 #define NVS_MAC_SECONDE_LENGHT_VALUE    1
43 
44 #define NVS_MAC_H_ADDRESS_INDEX         \
45 ((NVS_MAC_SECONDE_LENGTH_INDEX) + 1) /* 8*/
46 #define NVS_MAC_H_ADDRESS_LENGTH        2
47 
48 #define NVS_MAC_H_VALUE_INDEX           \
49 ((NVS_MAC_H_ADDRESS_INDEX) + (NVS_MAC_H_ADDRESS_LENGTH)) /* 10 */
50 #define NVS_MAC_H_VALUE_LENGTH          4
51 
52 #define NVS_END_BURST_TRANSACTION_INDEX         \
53 ((NVS_MAC_H_VALUE_INDEX) + (NVS_MAC_H_VALUE_LENGTH))    /* 14 */
54 #define NVS_END_BURST_TRANSACTION_VALUE         0
55 #define NVS_END_BURST_TRANSACTION_LENGTH        7
56 
57 #define NVS_ALING_TLV_START_ADDRESS_INDEX       \
58 ((NVS_END_BURST_TRANSACTION_INDEX) + \
59 (NVS_END_BURST_TRANSACTION_LENGTH)) /* 21 */
60 #define NVS_ALING_TLV_START_ADDRESS_VALUE       0
61 #define NVS_ALING_TLV_START_ADDRESS_LENGTH      3
62 
63 
64 /* NVS pre TLV length */
65 #define NVS_PRE_PARAMETERS_LENGTH               \
66 ((NVS_ALING_TLV_START_ADDRESS_INDEX) + \
67 (NVS_ALING_TLV_START_ADDRESS_LENGTH)) /* 24 */
68 
69 /* NVS P2G table */
70 #define NVS_TX_P2G_TABLE_LENGTH                 \
71 ((NUMBER_OF_SUB_BANDS_E) * 1 /* byte */) /* 8 */
72 
73 /* NVS PPA table */
74 #define NVS_TX_PPA_STEPS_TABLE_LENGTH   \
75 ((NUMBER_OF_SUB_BANDS_E) * ((TXPWR_CFG0__VGA_STEP__NUMBER_OF_STEPS_E) \
76 - 1) * 1 /* byte */)  /* 32 */
77 
78 /* NVS version 1 TX PD curve table length */
79 #define NVS_TX_PD_TABLE_LENGTH_NVS_V1   (1 /* byte to set size of table */ + \
80 ((NUMBER_OF_SUB_BANDS_E) * (2 /* 1 byte offset, 1 byte low range */ + \
81 2 /* first index in table */ + (((SIZE_OF_POWER_DETECTOR_TABLE) - 1) * \
82 1 /* 1 byte */)))) /* 233 */
83 
84 /* NVS version 2 TX PD curve table length */
85 #define NVS_TX_PD_TABLE_LENGTH_NVS_V2   \
86 ((NUMBER_OF_SUB_BANDS_E) * (12 /* 12index of one byte -2 dBm - 9dBm */ +\
87 28 /* 14 indexes of 2 byte -3dBm, 10dBm - 22 dBm */)) /* 320 */
88 
89 /* NVS version 1 TX parameters Length */
90 #define NVS_TX_PARAM_LENGTH_NVS_V1      \
91 ((NVS_TX_P2G_TABLE_LENGTH) + (NVS_TX_PPA_STEPS_TABLE_LENGTH) +\
92 (NVS_TX_PD_TABLE_LENGTH_NVS_V1)) /* 273 */
93 
94 /* NVS version 2 TX parameters Length */
95 #define NVS_TX_PARAM_LENGTH_NVS_V2       \
96 ((NVS_TX_P2G_TABLE_LENGTH) + (NVS_TX_PPA_STEPS_TABLE_LENGTH) +\
97 (NVS_TX_PD_TABLE_LENGTH_NVS_V2) +\
98 (NUMBER_OF_RADIO_CHANNEL_INDEXS_E /* for Per Channel power Gain Offset tabl */))
99 
100 /* NVS TX version */
101 /* #define NVS_TX_PARAM_LENGTH     NVS_TX_PARAM_LENGTH_NVS_V2 */
102 #define NVS_TX_PARAM_LENGTH     0x199
103 
104 /* NVS RX version */
105 #define NVS_RX_PARAM_LENGTH    NUMBER_OF_RX_BIP_EFUSE_PARAMETERS_E /* 19 */
106 
107 /* NVS version parameter length */
108 #define NVS_VERSION_PARAMETER_LENGTH    3
109 
110 /* NVS max length */
111 /* original ((NVS_TOTAL_LENGTH) + 4 - ((NVS_TOTAL_LENGTH) % 4)) */
112 #define NVS_TOTAL_LENGTH    500
113 
114 /* TLV max length */
115 #define  MAX_TLV_LENGTH                                 NVS_TOTAL_LENGTH
116 
117 #define  MAX_NVS_VERSION_LENGTH                 12
118 
119 enum wl1271_tm_commands {
120     WL1271_TM_CMD_UNSPEC,
121     WL1271_TM_CMD_TEST,
122     WL1271_TM_CMD_INTERROGATE,
123     WL1271_TM_CMD_CONFIGURE,
124     WL1271_TM_CMD_NVS_PUSH,
125     WL1271_TM_CMD_SET_PLT_MODE,
126     __WL1271_TM_CMD_AFTER_LAST
127 };
128 
129 enum wl1271_tm_attrs {
130     WL1271_TM_ATTR_UNSPEC,
131     WL1271_TM_ATTR_CMD_ID,
132     WL1271_TM_ATTR_ANSWER,
133     WL1271_TM_ATTR_DATA,
134     WL1271_TM_ATTR_IE_ID,
135     WL1271_TM_ATTR_PLT_MODE,
136     __WL1271_TM_ATTR_AFTER_LAST
137 };
138 
139 #define WL1271_TM_ATTR_MAX (__WL1271_TM_ATTR_AFTER_LAST - 1)
140 
141 enum wl1271_test_cmds {
142     TEST_CMD_PD_BUFFER_CAL = 0x1, /* TX PLT */
143     TEST_CMD_P2G_CAL,             /* TX BiP */
144     TEST_CMD_RX_PLT_ENTER,
145     TEST_CMD_RX_PLT_CAL,          /* RSSI Cal */
146     TEST_CMD_RX_PLT_EXIT,
147     TEST_CMD_RX_PLT_GET,
148     TEST_CMD_FCC,                 /* Continuous TX */
149     TEST_CMD_TELEC,  /* Carrier wave in a specific channel and band */
150     TEST_CMD_STOP_TX,             /* Stop FCC or TELEC */
151     TEST_CMD_PLT_TEMPLATE,        /* define Template for TX */
152     TEST_CMD_PLT_GAIN_ADJUST,
153     TEST_CMD_PLT_GAIN_GET,
154     TEST_CMD_CHANNEL_TUNE,
155     TEST_CMD_FREE_RUN_RSSI,        /* Free running RSSI measurement */
156     TEST_CMD_DEBUG,     /* test command for debug using the struct: */
157     TEST_CMD_CLPC_COMMANDS,
158     RESERVED_4,
159     TEST_CMD_RX_STAT_STOP,
160     TEST_CMD_RX_STAT_START,
161     TEST_CMD_RX_STAT_RESET,
162     TEST_CMD_RX_STAT_GET,
163     TEST_CMD_LOOPBACK_START,       /* for FW Test Debug */
164     TEST_CMD_LOOPBACK_STOP,        /* for FW Test Debug */
165     TEST_CMD_GET_FW_VERSIONS,
166     TEST_CMD_INI_FILE_RADIO_PARAM,
167     TEST_CMD_RUN_CALIBRATION_TYPE,
168     TEST_CMD_TX_GAIN_ADJUST,
169     TEST_CMD_UPDATE_PD_BUFFER_ERRORS,
170     TEST_CMD_UPDATE_PD_REFERENCE_POINT,
171     TEST_CMD_INI_FILE_GENERAL_PARAM,
172     TEST_CMD_SET_EFUSE,
173     TEST_CMD_GET_EFUSE,
174     TEST_CMD_TEST_TONE,
175     TEST_CMD_POWER_MODE,
176     TEST_CMD_SMART_REFLEX,
177     TEST_CMD_CHANNEL_RESPONSE,
178     TEST_CMD_DCO_ITRIM_FEATURE,
179     MAX_TEST_CMD_ID = 0xFF
180 };
181 
182 struct wl1271_cmd_header {
183     __u16 id;
184     __u16 status;
185     /* payload */
186     unsigned char data[0];
187 } __attribute__((packed));
188 
189 struct wl1271_cmd_test_header {
190     unsigned char id;
191     unsigned char padding[3];
192 } __attribute__((packed));
193 
194 struct wl1271_cmd_cal_channel_tune {
195     struct wl1271_cmd_header header;
196 
197     struct wl1271_cmd_test_header test;
198 
199     unsigned char band;
200     unsigned char channel;
201 
202     __le16 radio_status;
203 } __attribute__((packed));
204 
205 struct wl1271_cmd_cal_update_ref_point {
206     struct wl1271_cmd_header header;
207 
208     struct wl1271_cmd_test_header test;
209 
210     __le32 ref_power;
211     __le32 ref_detector;
212     unsigned char  sub_band;
213     unsigned char  padding[3];
214 } __attribute__((packed));
215 
216 struct wl1271_cmd_cal_tx_tone {
217     struct wl1271_cmd_header header;
218 
219     struct wl1271_cmd_test_header test;
220 
221     __le32 power;
222     __le32 tone_type;
223 } __attribute__((packed));
224 
225 struct wl1271_cmd_cal_p2g {
226     struct wl1271_cmd_header header;
227 
228     struct wl1271_cmd_test_header test;
229 
230     __le32 ver;
231     __le16 len;
232     unsigned char  buf[MAX_TLV_LENGTH];
233     unsigned char  type;
234     unsigned char  padding;
235 
236     __le16 radio_status;
237 
238     unsigned char  sub_band_mask;
239     unsigned char  padding2;
240 } __attribute__((packed));
241 
242 #define MAC_ADDR_LEN  6
243 
244 struct wl1271_cmd_pkt_params {
245     struct wl1271_cmd_header header;
246 
247     struct wl1271_cmd_test_header test;
248 
249     __le16 radio_status;
250     unsigned char padding[2];
251     __le32 delay;
252     __le32 rate;
253     __le16 size;
254     __le16 amount;
255     __le32 power;
256     __le16 seed;
257     unsigned char pkt_mode;
258     unsigned char dcf_enable;
259     unsigned char g_interval;
260     unsigned char preamble;
261     unsigned char type;
262     unsigned char scramble;
263     unsigned char clpc_enable;
264     unsigned char seq_nbr_mode;
265     unsigned char src_mac[MAC_ADDR_LEN];
266     unsigned char dst_mac[MAC_ADDR_LEN];
267     unsigned char padding1[2];
268 } __attribute__((packed));
269 
270 struct wl1271_rx_path_statcs {
271     __le32 nbr_rx_valid_pkts;
272     __le32 nbr_rx_fcs_err_pkts;
273     __le32 nbr_rx_plcp_err_pkts;
274     __le32 seq_nbr_miss_cnt; /* For PER calculation */
275     __le16 ave_snr; /* average SNR */
276     __le16 ave_rssi; /* average RSSI */
277     __le16 ave_evm;
278     unsigned char padding[2];
279 } __attribute__((packed));
280 
281 struct wl1271_rx_pkt_statcs {
282     __le32 length;
283     __le32 evm;
284     __le32 rssi;
285     __le16 freq_delta;
286     __le16 flags;
287     char type;
288     unsigned char rate;
289     unsigned char noise;
290     unsigned char agc_gain;
291     unsigned char padding[2];
292 } __attribute__((packed));
293 
294 #define RX_STAT_PACKETS_PER_MESSAGE        (20)
295 
296 struct wl1271_radio_rx_statcs {
297     struct wl1271_cmd_header header;
298 
299     struct wl1271_cmd_test_header test;
300 
301     struct wl1271_rx_path_statcs rx_path_statcs;
302     __le32 base_pkt_id;
303     __le32 nbr_pkts; /* input/output: number of following packets */
304     __le32 nbr_miss_pkts;
305     __le16 radio_status;
306     unsigned char padding[2];
307 } __attribute__((packed));
308 
309 enum wl1271_nvs_type {
310     eNVS_VERSION = 0xaa,
311     eNVS_RADIO_TX_PARAMETERS = 1,
312     eNVS_RADIO_RX_PARAMETERS = 2,
313     eNVS_RADIO_INI = 16,
314     eNVS_NON_FILE = 0xFE,
315     eTLV_LAST = 0xFF /* last TLV type */
316 };
317 
318 #define DEFAULT_EFUSE_VALUE            (0)
319 
320 enum wl1271_nvs_type_info {
321     eFIRST_RADIO_TYPE_PARAMETERS_INFO,
322     eNVS_RADIO_TX_TYPE_PARAMETERS_INFO = eFIRST_RADIO_TYPE_PARAMETERS_INFO,
323     eNVS_RADIO_RX_TYPE_PARAMETERS_INFO,
324     eLAST_RADIO_TYPE_PARAMETERS_INFO = eNVS_RADIO_RX_TYPE_PARAMETERS_INFO,
325     UNUSED_RADIO_TYPE_PARAMETERS_INFO,
326     eNUMBER_RADIO_TYPE_PARAMETERS_INFO = UNUSED_RADIO_TYPE_PARAMETERS_INFO,
327     LAST_RADIO_TYPE_PARAMETERS_INFO =
328         (eNUMBER_RADIO_TYPE_PARAMETERS_INFO - 1)
329 };
330 
331 enum EFUSE_PARAMETER_TYPE_ENMT {
332     EFUSE_FIRST_PARAMETER_E,
333     /* RX PARAMETERS */
334     EFUSE_FIRST_RX_PARAMETER_E = EFUSE_FIRST_PARAMETER_E,
335     RX_BIP_MAX_GAIN_ERROR_BAND_B_E = EFUSE_FIRST_RX_PARAMETER_E,
336 
337     RX_BIP_MAX_GAIN_ERROR_J_LOW_MID_E,
338     RX_BIP_MAX_GAIN_ERROR_J_HIGH_E,
339 
340     RX_BIP_MAX_GAIN_ERROR_5G_1ST_E,
341     RX_BIP_MAX_GAIN_ERROR_5G_2ND_E,
342     RX_BIP_MAX_GAIN_ERROR_5G_3RD_E,
343     RX_BIP_MAX_GAIN_ERROR_5G_4TH_E,
344 
345     RX_BIP_LNA_STEP_CORR_BAND_B_4TO3_E,
346     RX_BIP_LNA_STEP_CORR_BAND_B_3TO2_E,
347     RX_BIP_LNA_STEP_CORR_BAND_B_2TO1_E,
348     RX_BIP_LNA_STEP_CORR_BAND_B_1TO0_E,
349 
350     RX_BIP_LNA_STEP_CORR_BAND_A_4TO3_E,
351     RX_BIP_LNA_STEP_CORR_BAND_A_3TO2_E,
352     RX_BIP_LNA_STEP_CORR_BAND_A_2TO1_E,
353     RX_BIP_LNA_STEP_CORR_BAND_A_1TO0_E,
354 
355     RX_BIP_TA_STEP_CORR_BAND_B_2TO1_E,
356     RX_BIP_TA_STEP_CORR_BAND_B_1TO0_E,
357     RX_BIP_TA_STEP_CORR_BAND_A_2TO1_E,
358     RX_BIP_TA_STEP_CORR_BAND_A_1TO0_E,
359     NUMBER_OF_RX_BIP_EFUSE_PARAMETERS_E,
360 
361     /* TX PARAMETERS */
362     TX_BIP_PD_BUFFER_GAIN_ERROR_E = NUMBER_OF_RX_BIP_EFUSE_PARAMETERS_E,
363     TX_BIP_PD_BUFFER_VBIAS_ERROR_E,
364     EFUSE_NUMBER_OF_PARAMETERS_E,
365     EFUSE_LAST_PARAMETER_E = (EFUSE_NUMBER_OF_PARAMETERS_E - 1)
366 } EFUSE_PARAMETER_TYPE_ENM;
367 
368 int get_mac_addr(int ifc_num, unsigned char *mac_addr);
369 
370 int file_exist(const char *filename);
371 
372 #endif /* __PLT_H */
373