aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/eeprom.h
blob: f75e54f9147bc7063e9467c4d695920e4d5507b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/***************************************************************************
 *
 *    ****                              I
 *   ******                            ***
 *   *******                           ****
 *   ********    ****  ****     **** *********    ******* ****    ***********
 *   *********   ****  ****     **** *********  **************  *************
 *   **** *****  ****  ****     ****   ****    *****    ****** *****     ****
 *   ****  ***** ****  ****     ****   ****   *****      ****  ****      ****
 *  ****    *********  ****     ****   ****   ****       ****  ****      ****
 *  ****     ********  ****    ****I  ****    *****     *****  ****      ****
 *  ****      ******   ***** ******   *****    ****** *******  ****** *******
 *  ****        ****   ************    ******   *************   *************
 *  ****         ***     ****  ****     ****      *****  ****     *****  ****
 *                                                                       ****
 *          I N N O V A T I O N  T O D A Y  F O R  T O M M O R O W       ****
 *                                                                        ***
 *
 ***************************************************************************
 *
 *  Project     : SuperFemto
 *  File        : eeprom.h
 *  Description	: EEPROM interface.
 *
 *                Copyright (c) Nutaq. 2012
 *
 ***************************************************************************
 *
 * "$Revision: 1.1 $"
 * "$Name: $"
 * "$Date: 2012/06/20 02:18:30 $"
 * "$Author: Yves.Godin $"
 *
 ***************************************************************************/
#ifndef EEPROM_H__
#define EEPROM_H__

#include <stdint.h>

/****************************************************************************
 *                             Public constants                             *
 ****************************************************************************/

/**
 * EEPROM error code
 */
typedef enum
{
    EEPROM_SUCCESS          =  0,        ///< Success
    EEPROM_ERR_DEVICE       = -1,        ///< Device access error
    EEPROM_ERR_PARITY       = -2,        ///< Parity error
    EEPROM_ERR_UNAVAILABLE  = -3,        ///< Information unavailable
    EEPROM_ERR_INVALID      = -4,        ///< Invalid format
    EEPROM_ERR_UNSUPPORTED  = -5,        ///< Unsupported format
} eeprom_Error_t;


/****************************************************************************
 * Struct : eeprom_SysInfo_t
 ************************************************************************//**
 *
 * SuperFemto system information.
 *
 ***************************************************************************/
typedef struct eeprom_SysInfo
{
    char    szSn[16];               ///< Serial number
    uint8_t u8Rev;                  ///< Board revision
    uint8_t u8Tcxo;                 ///< TCXO present       (0:absent, 1:present, X:unknown)
    uint8_t u8Ocxo;                 ///< OCXO present       (0:absent, 1:present, X:unknown)
    uint8_t u8GSM850;               ///< GSM-850 supported  (0:unsupported, 1:supported, X:unknown)
    uint8_t u8GSM900;               ///< GSM-900 supported  (0:unsupported, 1:supported, X:unknown)
    uint8_t u8DCS1800;              ///< GSM-1800 supported (0:unsupported, 1:supported, X:unknown)
    uint8_t u8PCS1900;              ///< GSM-1900 supported (0:unsupported, 1:supported, X:unknown)
} eeprom_SysInfo_t;

/****************************************************************************
 * Struct : eeprom_RfClockCal_t
 ************************************************************************//**
 *
 * SuperFemto RF clock calibration.
 *
 ***************************************************************************/
typedef struct eeprom_RfClockCal
{
    int     iClkCor;                ///< Clock correction value in PPB.
    uint8_t u8ClkSrc;               ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:reserved, 6:RX, 7:Edge)
} eeprom_RfClockCal_t;

/****************************************************************************
 * Struct : eeprom_TxCal_t
 ************************************************************************//**
 *
 * SuperFemto transmit calibration table.
 *
 ***************************************************************************/
typedef struct eeprom_TxCal
{
	uint8_t u8DspMajVer;            ///< DSP firmware major version
	uint8_t u8DspMinVer;            ///< DSP firmware minor version
	uint8_t u8FpgaMajVer;           ///< FPGA firmware major version
	uint8_t u8FpgaMinVer;           ///< FPGA firmware minor version
    float fTxGainGmsk[80];          ///< Gain setting for GMSK output level from +50dBm to -29 dBm
    float fTx8PskCorr;              ///< Gain adjustment for 8 PSK (default to +3.25 dB)
    float fTxExtAttCorr[31];        ///< Gain adjustment for external attenuator (0:@1dB, 1:@2dB, ..., 31:@32dB)
    float fTxRollOffCorr[374];      /**< Gain correction for each ARFCN
                                                for GSM-850 : 0=128, 1:129, ..., 123:251, [124-373]:unused
                                                for GSM-900 : 0=955, 1:956, ...,  70:1, ..., 317:956, [318-373]:unused
                                                for DCS-1800: 0=512, 1:513, ..., 373:885
                                                for PCS-1900: 0=512, 1:513, ..., 298:810, [299-373]:unused */
} eeprom_TxCal_t;

/****************************************************************************
 * Struct : eeprom_RxCal_t
 ************************************************************************//**
 *
 * SuperFemto receive calibration table.
 *
 ***************************************************************************/
typedef struct eeprom_RxCal
{
	uint8_t u8DspMajVer;            ///< DSP firmware major version
	uint8_t u8DspMinVer;            ///< DSP firmware minor version
	uint8_t u8FpgaMajVer;           ///< FPGA firmware major version
	uint8_t u8FpgaMinVer;           ///< FPGA firmware minor version
    float fExtRxGain;               ///< External RX gain
    float fRxMixGainCorr;           ///< Mixer gain error compensation
    float fRxLnaGainCorr[3];        ///< LNA gain error compensation (1:@-12 dB, 2:@-24 dB, 3:@-36 dB)
    float fRxRollOffCorr[374];      /***< Frequency roll-off compensation
                                                for GSM-850 : 0=128, 1:129, ..., 123:251, [124-373]:unused
                                                for GSM-900 : 0=955, 1:956, ...,  70:1, ..., 317:956, [318-373]:unused
                                                for DCS-1800: 0=512, 1:513, ..., 373:885
                                                for PCS-1900: 0=512, 1:513, ..., 298:810, [299-373]:unused */
    uint8_t u8IqImbalMode;          ///< IQ imbalance mode (0:off, 1:on, 2:auto)
    uint16_t u16IqImbalCorr[4];     ///< IQ imbalance compensation
} eeprom_RxCal_t;


/****************************************************************************
 *                             Public functions                             *
 ****************************************************************************/

eeprom_Error_t eeprom_ReadEthAddr( uint8_t *ethaddr );

/****************************************************************************
 * Function : eeprom_ResetCfg
 ************************************************************************//**
 *
 * This function reset the content of the EEPROM config area.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_ResetCfg( void );

/****************************************************************************
 * Function : eeprom_ReadSysInfo
 ************************************************************************//**
 *
 * This function reads the system information from the EEPROM.
 *
 * @param [inout] pTime
 *    Pointer to a system info structure.
 *
 * @param [inout] pSysInfo
 *    Pointer to a system info structure.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_ReadSysInfo( eeprom_SysInfo_t *pSysInfo );

/****************************************************************************
 * Function : eeprom_WriteSysInfo
 ************************************************************************//**
 *
 * This function writes the system information to the EEPROM.
 *
 * @param [in] pSysInfo
 *    Pointer to the system info structure to be written.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_WriteSysInfo( const eeprom_SysInfo_t *pSysInfo );

/****************************************************************************
 * Function : eeprom_ReadRfClockCal
 ************************************************************************//**
 *
 * This function reads the RF clock calibration data from the EEPROM.
 *
 * @param [inout] pRfClockCal
 *    Pointer to a RF clock calibration structure.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_ReadRfClockCal( eeprom_RfClockCal_t *pRfClockCal );

/****************************************************************************
 * Function : eeprom_WriteRfClockCal
 ************************************************************************//**
 *
 * This function writes the RF clock calibration data to the EEPROM.
 *
 * @param [in] pSysInfo
 *    Pointer to the system info structure to be written.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_WriteRfClockCal( const eeprom_RfClockCal_t *pRfClockCal );

/****************************************************************************
 * Function : eeprom_ReadTxCal
 ************************************************************************//**
 *
 * This function reads the TX calibration tables for the specified band from
 * the EEPROM.
 *
 * @param [in] iBand
 *    GSM band (0:GSM-850, 1:GSM-900, 2:DCS-1800, 3:PCS-1900).
 *
 * @param [inout] pTxCal
 *    Pointer to a TX calibration table structure.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_ReadTxCal( int iBand, eeprom_TxCal_t *pTxCal );

/****************************************************************************
 * Function : eeprom_WriteTxCal
 ************************************************************************//**
 *
 * This function writes the TX calibration tables for the specified band to
 * the EEPROM.
 *
 * @param [in] iBand
 *    GSM band (0:GSM-850, 1:GSM-900, 2:DCS-1800, 3:PCS-1900).
 *
 * @param [in] pTxCal
 *    Pointer to a TX calibration table structure.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_WriteTxCal( int iBand, const eeprom_TxCal_t *pTxCal );

/****************************************************************************
 * Function : eeprom_ReadRxCal
 ************************************************************************//**
 *
 * This function reads the RX calibration tables for the specified band from
 * the EEPROM.
 *
 * @param [in] iBand
 *    GSM band (0:GSM-850, 1:GSM-900, 2:DCS-1800, 3:PCS-1900).
 *
 * @param [in] iUplink
 *    Uplink flag (0:downlink, X:downlink).
 *
 * @param [inout] pRxCal
 *    Pointer to a RX calibration table structure.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_ReadRxCal( int iBand, int iUplink, eeprom_RxCal_t *pRxCal );

/****************************************************************************
 * Function : eeprom_WriteRxCal
 ************************************************************************//**
 *
 * This function writes the RX calibration tables for the specified band to
 * the EEPROM.
 *
 * @param [in] iBand
 *    GSM band (0:GSM-850, 1:GSM-900, 2:DCS-1800, 3:PCS-1900).
 *
 * @param [in] iUplink
 *    Uplink flag (0:downlink, X:downlink).
 *
 * @param [in] pRxCal
 *    Pointer to a RX calibration table structure.
 *
 * @return
 *    0 if or an error core.
 *
 ****************************************************************************/
eeprom_Error_t eeprom_WriteRxCal( int iBand, int iUplink, const eeprom_RxCal_t *pRxCal );

void eeprom_free_resources(void);

#endif  // EEPROM_H__