blob: 7fb5b743d4d2a75a8620e087ab3297fc9fccafab [file] [log] [blame]
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -03001#ifndef __MT2063_H__
2#define __MT2063_H__
3
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -03004#include "dvb_frontend.h"
5
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -03006#define DVBFE_TUNER_OPEN 99
7#define DVBFE_TUNER_SOFTWARE_SHUTDOWN 100
8#define DVBFE_TUNER_CLEAR_POWER_MASKBITS 101
9
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030010#define MT2063_ERROR (1 << 31)
11#define MT2063_USER_ERROR (1 << 30)
12
13/* Macro to be used to check for errors */
14#define MT2063_IS_ERROR(s) (((s) >> 30) != 0)
15#define MT2063_NO_ERROR(s) (((s) >> 30) == 0)
16
17#define MT2063_OK (0x00000000)
18
19/* Unknown error */
20#define MT2063_UNKNOWN (0x80000001)
21
22/* Error: Upconverter PLL is not locked */
23#define MT2063_UPC_UNLOCK (0x80000002)
24
25/* Error: Downconverter PLL is not locked */
26#define MT2063_DNC_UNLOCK (0x80000004)
27
28/* Error: Two-wire serial bus communications error */
29#define MT2063_COMM_ERR (0x80000008)
30
31/* Error: Tuner handle passed to function was invalid */
32#define MT2063_INV_HANDLE (0x80000010)
33
34/* Error: Function argument is invalid (out of range) */
35#define MT2063_ARG_RANGE (0x80000020)
36
37/* Error: Function argument (ptr to return value) was NULL */
38#define MT2063_ARG_NULL (0x80000040)
39
40/* Error: Attempt to open more than MT_TUNER_CNT tuners */
41#define MT2063_TUNER_CNT_ERR (0x80000080)
42
43/* Error: Tuner Part Code / Rev Code mismatches expected value */
44#define MT2063_TUNER_ID_ERR (0x80000100)
45
46/* Error: Tuner Initialization failure */
47#define MT2063_TUNER_INIT_ERR (0x80000200)
48
49#define MT2063_TUNER_OPEN_ERR (0x80000400)
50
51/* User-definable fields (see mt_userdef.h) */
52#define MT2063_USER_DEFINED1 (0x00001000)
53#define MT2063_USER_DEFINED2 (0x00002000)
54#define MT2063_USER_DEFINED3 (0x00004000)
55#define MT2063_USER_DEFINED4 (0x00008000)
56#define MT2063_USER_MASK (0x4000f000)
57#define MT2063_USER_SHIFT (12)
58
59/* Info: Mask of bits used for # of LO-related spurs that were avoided during tuning */
60#define MT2063_SPUR_CNT_MASK (0x001f0000)
61#define MT2063_SPUR_SHIFT (16)
62
63/* Info: Tuner timeout waiting for condition */
64#define MT2063_TUNER_TIMEOUT (0x00400000)
65
66/* Info: Unavoidable LO-related spur may be present in the output */
67#define MT2063_SPUR_PRESENT_ERR (0x00800000)
68
69/* Info: Tuner input frequency is out of range */
70#define MT2063_FIN_RANGE (0x01000000)
71
72/* Info: Tuner output frequency is out of range */
73#define MT2063_FOUT_RANGE (0x02000000)
74
75/* Info: Upconverter frequency is out of range (may be reason for MT_UPC_UNLOCK) */
76#define MT2063_UPC_RANGE (0x04000000)
77
78/* Info: Downconverter frequency is out of range (may be reason for MT_DPC_UNLOCK) */
79#define MT2063_DNC_RANGE (0x08000000)
80
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030081/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -030082 * Data Types
83 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030084#define MT2060_CNT 10
85
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -030086#define MAX_UDATA (4294967295) /* max value storable in u32 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030087
88/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -030089 * Define an MTxxxx_CNT macro for each type of tuner that will be built
90 * into your application (e.g., MT2121, MT2060). MT_TUNER_CNT
91 * must be set to the SUM of all of the MTxxxx_CNT macros.
92 *
93 * #define MT2050_CNT (1)
94 * #define MT2060_CNT (1)
95 * #define MT2111_CNT (1)
96 * #define MT2121_CNT (3)
97 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030098
99#define MT2063_CNT (1)
100
101#if !defined( MT2063_TUNER_CNT )
102#define MT2063_TUNER_CNT (1) /* total num of MicroTuner tuners */
103#endif
104#define MT2063_I2C (0xC0)
105
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300106u32 MT2063_WriteSub(void *hUserData,
107 u32 addr,
108 u8 subAddress, u8 * pData, u32 cnt);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300109
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300110u32 MT2063_ReadSub(void *hUserData,
111 u32 addr,
112 u8 subAddress, u8 * pData, u32 cnt);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300113
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300114void MT2063_Sleep(void *hUserData, u32 nMinDelayTime);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300115
116#if defined(MT2060_CNT)
117#if MT2060_CNT > 0
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300118u32 MT2060_TunerGain(void *hUserData, s32 * pMeas);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300119#endif
120#endif
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300121
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300122/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300123 * Constant defining the version of the following structure
124 * and therefore the API for this code.
125 *
126 * When compiling the tuner driver, the preprocessor will
127 * check against this version number to make sure that
128 * it matches the version that the tuner driver knows about.
129 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300130/* Version 010201 => 1.21 */
131#define MT2063_AVOID_SPURS_INFO_VERSION 010201
132
133/* DECT Frequency Avoidance */
134#define MT2063_DECT_AVOID_US_FREQS 0x00000001
135
136#define MT2063_DECT_AVOID_EURO_FREQS 0x00000002
137
138#define MT2063_EXCLUDE_US_DECT_FREQUENCIES(s) (((s) & MT2063_DECT_AVOID_US_FREQS) != 0)
139
140#define MT2063_EXCLUDE_EURO_DECT_FREQUENCIES(s) (((s) & MT2063_DECT_AVOID_EURO_FREQS) != 0)
141
142enum MT2063_DECT_Avoid_Type {
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300143 MT2063_NO_DECT_AVOIDANCE = 0, /* Do not create DECT exclusion zones. */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300144 MT2063_AVOID_US_DECT = MT2063_DECT_AVOID_US_FREQS, /* Avoid US DECT frequencies. */
145 MT2063_AVOID_EURO_DECT = MT2063_DECT_AVOID_EURO_FREQS, /* Avoid European DECT frequencies. */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300146 MT2063_AVOID_BOTH /* Avoid both regions. Not typically used. */
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300147};
148
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300149#define MT2063_MAX_ZONES 48
150
151struct MT2063_ExclZone_t;
152
153struct MT2063_ExclZone_t {
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300154 u32 min_;
155 u32 max_;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300156 struct MT2063_ExclZone_t *next_;
157};
158
159/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300160 * Structure of data needed for Spur Avoidance
161 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300162struct MT2063_AvoidSpursData_t {
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300163 u32 nAS_Algorithm;
164 u32 f_ref;
165 u32 f_in;
166 u32 f_LO1;
167 u32 f_if1_Center;
168 u32 f_if1_Request;
169 u32 f_if1_bw;
170 u32 f_LO2;
171 u32 f_out;
172 u32 f_out_bw;
173 u32 f_LO1_Step;
174 u32 f_LO2_Step;
175 u32 f_LO1_FracN_Avoid;
176 u32 f_LO2_FracN_Avoid;
177 u32 f_zif_bw;
178 u32 f_min_LO_Separation;
179 u32 maxH1;
180 u32 maxH2;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300181 enum MT2063_DECT_Avoid_Type avoidDECT;
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300182 u32 bSpurPresent;
183 u32 bSpurAvoided;
184 u32 nSpursFound;
185 u32 nZones;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300186 struct MT2063_ExclZone_t *freeZones;
187 struct MT2063_ExclZone_t *usedZones;
188 struct MT2063_ExclZone_t MT2063_ExclZones[MT2063_MAX_ZONES];
189};
190
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300191u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300192
193void MT2063_UnRegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info);
194
195void MT2063_ResetExclZones(struct MT2063_AvoidSpursData_t *pAS_Info);
196
197void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300198 u32 f_min, u32 f_max);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300199
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300200u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300201
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300202u32 MT2063_AvoidSpurs(void *h, struct MT2063_AvoidSpursData_t *pAS_Info);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300203
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300204u32 MT2063_AvoidSpursVersion(void);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300205
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300206
207/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300208 * Values returned by the MT2063's on-chip temperature sensor
209 * to be read/written.
210 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300211enum MT2063_Temperature {
212 MT2063_T_0C = 0, /* Temperature approx 0C */
213 MT2063_T_10C, /* Temperature approx 10C */
214 MT2063_T_20C, /* Temperature approx 20C */
215 MT2063_T_30C, /* Temperature approx 30C */
216 MT2063_T_40C, /* Temperature approx 40C */
217 MT2063_T_50C, /* Temperature approx 50C */
218 MT2063_T_60C, /* Temperature approx 60C */
219 MT2063_T_70C, /* Temperature approx 70C */
220 MT2063_T_80C, /* Temperature approx 80C */
221 MT2063_T_90C, /* Temperature approx 90C */
222 MT2063_T_100C, /* Temperature approx 100C */
223 MT2063_T_110C, /* Temperature approx 110C */
224 MT2063_T_120C, /* Temperature approx 120C */
225 MT2063_T_130C, /* Temperature approx 130C */
226 MT2063_T_140C, /* Temperature approx 140C */
227 MT2063_T_150C, /* Temperature approx 150C */
228};
229
230/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300231 * Parameters for selecting GPIO bits
232 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300233enum MT2063_GPIO_Attr {
234 MT2063_GPIO_IN,
235 MT2063_GPIO_DIR,
236 MT2063_GPIO_OUT,
237};
238
239enum MT2063_GPIO_ID {
240 MT2063_GPIO0,
241 MT2063_GPIO1,
242 MT2063_GPIO2,
243};
244
245/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300246 * Parameter for function MT2063_SetExtSRO that specifies the external
247 * SRO drive frequency.
248 *
249 * MT2063_EXT_SRO_OFF is the power-up default value.
250 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300251enum MT2063_Ext_SRO {
252 MT2063_EXT_SRO_OFF, /* External SRO drive off */
253 MT2063_EXT_SRO_BY_4, /* External SRO drive divide by 4 */
254 MT2063_EXT_SRO_BY_2, /* External SRO drive divide by 2 */
255 MT2063_EXT_SRO_BY_1 /* External SRO drive divide by 1 */
256};
257
258/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300259 * Parameter for function MT2063_SetPowerMask that specifies the power down
260 * of various sections of the MT2063.
261 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300262enum MT2063_Mask_Bits {
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300263 MT2063_REG_SD = 0x0040, /* Shutdown regulator */
264 MT2063_SRO_SD = 0x0020, /* Shutdown SRO */
265 MT2063_AFC_SD = 0x0010, /* Shutdown AFC A/D */
266 MT2063_PD_SD = 0x0002, /* Enable power detector shutdown */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300267 MT2063_PDADC_SD = 0x0001, /* Enable power detector A/D shutdown */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300268 MT2063_VCO_SD = 0x8000, /* Enable VCO shutdown */
269 MT2063_LTX_SD = 0x4000, /* Enable LTX shutdown */
270 MT2063_LT1_SD = 0x2000, /* Enable LT1 shutdown */
271 MT2063_LNA_SD = 0x1000, /* Enable LNA shutdown */
272 MT2063_UPC_SD = 0x0800, /* Enable upconverter shutdown */
273 MT2063_DNC_SD = 0x0400, /* Enable downconverter shutdown */
274 MT2063_VGA_SD = 0x0200, /* Enable VGA shutdown */
275 MT2063_AMP_SD = 0x0100, /* Enable AMP shutdown */
276 MT2063_ALL_SD = 0xFF73, /* All shutdown bits for this tuner */
277 MT2063_NONE_SD = 0x0000 /* No shutdown bits */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300278};
279
280/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300281 * Parameter for function MT2063_GetParam & MT2063_SetParam that
282 * specifies the tuning algorithm parameter to be read/written.
283 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300284enum MT2063_Param {
285 /* tuner address set by MT2063_Open() */
286 MT2063_IC_ADDR,
287
288 /* max number of MT2063 tuners set by MT_TUNER_CNT in mt_userdef.h */
289 MT2063_MAX_OPEN,
290
291 /* current number of open MT2063 tuners set by MT2063_Open() */
292 MT2063_NUM_OPEN,
293
294 /* crystal frequency (default: 16000000 Hz) */
295 MT2063_SRO_FREQ,
296
297 /* min tuning step size (default: 50000 Hz) */
298 MT2063_STEPSIZE,
299
300 /* input center frequency set by MT2063_Tune() */
301 MT2063_INPUT_FREQ,
302
303 /* LO1 Frequency set by MT2063_Tune() */
304 MT2063_LO1_FREQ,
305
306 /* LO1 minimum step size (default: 250000 Hz) */
307 MT2063_LO1_STEPSIZE,
308
309 /* LO1 FracN keep-out region (default: 999999 Hz) */
310 MT2063_LO1_FRACN_AVOID_PARAM,
311
312 /* Current 1st IF in use set by MT2063_Tune() */
313 MT2063_IF1_ACTUAL,
314
315 /* Requested 1st IF set by MT2063_Tune() */
316 MT2063_IF1_REQUEST,
317
318 /* Center of 1st IF SAW filter (default: 1218000000 Hz) */
319 MT2063_IF1_CENTER,
320
321 /* Bandwidth of 1st IF SAW filter (default: 20000000 Hz) */
322 MT2063_IF1_BW,
323
324 /* zero-IF bandwidth (default: 2000000 Hz) */
325 MT2063_ZIF_BW,
326
327 /* LO2 Frequency set by MT2063_Tune() */
328 MT2063_LO2_FREQ,
329
330 /* LO2 minimum step size (default: 50000 Hz) */
331 MT2063_LO2_STEPSIZE,
332
333 /* LO2 FracN keep-out region (default: 374999 Hz) */
334 MT2063_LO2_FRACN_AVOID,
335
336 /* output center frequency set by MT2063_Tune() */
337 MT2063_OUTPUT_FREQ,
338
339 /* output bandwidth set by MT2063_Tune() */
340 MT2063_OUTPUT_BW,
341
342 /* min inter-tuner LO separation (default: 1000000 Hz) */
343 MT2063_LO_SEPARATION,
344
345 /* ID of avoid-spurs algorithm in use compile-time constant */
346 MT2063_AS_ALG,
347
348 /* max # of intra-tuner harmonics (default: 15) */
349 MT2063_MAX_HARM1,
350
351 /* max # of inter-tuner harmonics (default: 7) */
352 MT2063_MAX_HARM2,
353
354 /* # of 1st IF exclusion zones used set by MT2063_Tune() */
355 MT2063_EXCL_ZONES,
356
357 /* # of spurs found/avoided set by MT2063_Tune() */
358 MT2063_NUM_SPURS,
359
360 /* >0 spurs avoided set by MT2063_Tune() */
361 MT2063_SPUR_AVOIDED,
362
363 /* >0 spurs in output (mathematically) set by MT2063_Tune() */
364 MT2063_SPUR_PRESENT,
365
366 /* Receiver Mode for some parameters. 1 is DVB-T */
367 MT2063_RCVR_MODE,
368
369 /* directly set LNA attenuation, parameter is value to set */
370 MT2063_ACLNA,
371
372 /* maximum LNA attenuation, parameter is value to set */
373 MT2063_ACLNA_MAX,
374
375 /* directly set ATN attenuation. Paremeter is value to set. */
376 MT2063_ACRF,
377
378 /* maxium ATN attenuation. Paremeter is value to set. */
379 MT2063_ACRF_MAX,
380
381 /* directly set FIF attenuation. Paremeter is value to set. */
382 MT2063_ACFIF,
383
384 /* maxium FIF attenuation. Paremeter is value to set. */
385 MT2063_ACFIF_MAX,
386
387 /* LNA Rin */
388 MT2063_LNA_RIN,
389
390 /* Power Detector LNA level target */
391 MT2063_LNA_TGT,
392
393 /* Power Detector 1 level */
394 MT2063_PD1,
395
396 /* Power Detector 1 level target */
397 MT2063_PD1_TGT,
398
399 /* Power Detector 2 level */
400 MT2063_PD2,
401
402 /* Power Detector 2 level target */
403 MT2063_PD2_TGT,
404
405 /* Selects, which DNC is activ */
406 MT2063_DNC_OUTPUT_ENABLE,
407
408 /* VGA gain code */
409 MT2063_VGAGC,
410
411 /* VGA bias current */
412 MT2063_VGAOI,
413
414 /* TAGC, determins the speed of the AGC */
415 MT2063_TAGC,
416
417 /* AMP gain code */
418 MT2063_AMPGC,
419
420 /* Control setting to avoid DECT freqs (default: MT_AVOID_BOTH) */
421 MT2063_AVOID_DECT,
422
423 /* Cleartune filter selection: 0 - by IC (default), 1 - by software */
424 MT2063_CTFILT_SW,
425
426 MT2063_EOP /* last entry in enumerated list */
427};
428
429/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300430 * Parameter for selecting tuner mode
431 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300432enum MT2063_RCVR_MODES {
433 MT2063_CABLE_QAM = 0, /* Digital cable */
434 MT2063_CABLE_ANALOG, /* Analog cable */
435 MT2063_OFFAIR_COFDM, /* Digital offair */
436 MT2063_OFFAIR_COFDM_SAWLESS, /* Digital offair without SAW */
437 MT2063_OFFAIR_ANALOG, /* Analog offair */
438 MT2063_OFFAIR_8VSB, /* Analog offair */
439 MT2063_NUM_RCVR_MODES
440};
441
442/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300443 * Possible values for MT2063_DNC_OUTPUT
444 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300445enum MT2063_DNC_Output_Enable {
446 MT2063_DNC_NONE = 0,
447 MT2063_DNC_1,
448 MT2063_DNC_2,
449 MT2063_DNC_BOTH
450};
451
452/*
453** Two-wire serial bus subaddresses of the tuner registers.
454** Also known as the tuner's register addresses.
455*/
456enum MT2063_Register_Offsets {
457 MT2063_REG_PART_REV = 0, /* 0x00: Part/Rev Code */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300458 MT2063_REG_LO1CQ_1, /* 0x01: LO1C Queued Byte 1 */
459 MT2063_REG_LO1CQ_2, /* 0x02: LO1C Queued Byte 2 */
460 MT2063_REG_LO2CQ_1, /* 0x03: LO2C Queued Byte 1 */
461 MT2063_REG_LO2CQ_2, /* 0x04: LO2C Queued Byte 2 */
462 MT2063_REG_LO2CQ_3, /* 0x05: LO2C Queued Byte 3 */
463 MT2063_REG_RSVD_06, /* 0x06: Reserved */
464 MT2063_REG_LO_STATUS, /* 0x07: LO Status */
465 MT2063_REG_FIFFC, /* 0x08: FIFF Center */
466 MT2063_REG_CLEARTUNE, /* 0x09: ClearTune Filter */
467 MT2063_REG_ADC_OUT, /* 0x0A: ADC_OUT */
468 MT2063_REG_LO1C_1, /* 0x0B: LO1C Byte 1 */
469 MT2063_REG_LO1C_2, /* 0x0C: LO1C Byte 2 */
470 MT2063_REG_LO2C_1, /* 0x0D: LO2C Byte 1 */
471 MT2063_REG_LO2C_2, /* 0x0E: LO2C Byte 2 */
472 MT2063_REG_LO2C_3, /* 0x0F: LO2C Byte 3 */
473 MT2063_REG_RSVD_10, /* 0x10: Reserved */
474 MT2063_REG_PWR_1, /* 0x11: PWR Byte 1 */
475 MT2063_REG_PWR_2, /* 0x12: PWR Byte 2 */
476 MT2063_REG_TEMP_STATUS, /* 0x13: Temp Status */
477 MT2063_REG_XO_STATUS, /* 0x14: Crystal Status */
478 MT2063_REG_RF_STATUS, /* 0x15: RF Attn Status */
479 MT2063_REG_FIF_STATUS, /* 0x16: FIF Attn Status */
480 MT2063_REG_LNA_OV, /* 0x17: LNA Attn Override */
481 MT2063_REG_RF_OV, /* 0x18: RF Attn Override */
482 MT2063_REG_FIF_OV, /* 0x19: FIF Attn Override */
483 MT2063_REG_LNA_TGT, /* 0x1A: Reserved */
484 MT2063_REG_PD1_TGT, /* 0x1B: Pwr Det 1 Target */
485 MT2063_REG_PD2_TGT, /* 0x1C: Pwr Det 2 Target */
486 MT2063_REG_RSVD_1D, /* 0x1D: Reserved */
487 MT2063_REG_RSVD_1E, /* 0x1E: Reserved */
488 MT2063_REG_RSVD_1F, /* 0x1F: Reserved */
489 MT2063_REG_RSVD_20, /* 0x20: Reserved */
490 MT2063_REG_BYP_CTRL, /* 0x21: Bypass Control */
491 MT2063_REG_RSVD_22, /* 0x22: Reserved */
492 MT2063_REG_RSVD_23, /* 0x23: Reserved */
493 MT2063_REG_RSVD_24, /* 0x24: Reserved */
494 MT2063_REG_RSVD_25, /* 0x25: Reserved */
495 MT2063_REG_RSVD_26, /* 0x26: Reserved */
496 MT2063_REG_RSVD_27, /* 0x27: Reserved */
497 MT2063_REG_FIFF_CTRL, /* 0x28: FIFF Control */
498 MT2063_REG_FIFF_OFFSET, /* 0x29: FIFF Offset */
499 MT2063_REG_CTUNE_CTRL, /* 0x2A: Reserved */
500 MT2063_REG_CTUNE_OV, /* 0x2B: Reserved */
501 MT2063_REG_CTRL_2C, /* 0x2C: Reserved */
502 MT2063_REG_FIFF_CTRL2, /* 0x2D: Fiff Control */
503 MT2063_REG_RSVD_2E, /* 0x2E: Reserved */
504 MT2063_REG_DNC_GAIN, /* 0x2F: DNC Control */
505 MT2063_REG_VGA_GAIN, /* 0x30: VGA Gain Ctrl */
506 MT2063_REG_RSVD_31, /* 0x31: Reserved */
507 MT2063_REG_TEMP_SEL, /* 0x32: Temperature Selection */
508 MT2063_REG_RSVD_33, /* 0x33: Reserved */
509 MT2063_REG_RSVD_34, /* 0x34: Reserved */
510 MT2063_REG_RSVD_35, /* 0x35: Reserved */
511 MT2063_REG_RSVD_36, /* 0x36: Reserved */
512 MT2063_REG_RSVD_37, /* 0x37: Reserved */
513 MT2063_REG_RSVD_38, /* 0x38: Reserved */
514 MT2063_REG_RSVD_39, /* 0x39: Reserved */
515 MT2063_REG_RSVD_3A, /* 0x3A: Reserved */
516 MT2063_REG_RSVD_3B, /* 0x3B: Reserved */
517 MT2063_REG_RSVD_3C, /* 0x3C: Reserved */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300518 MT2063_REG_END_REGS
519};
520
521struct MT2063_Info_t {
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300522 void *handle;
523 void *hUserData;
524 u32 address;
525 u32 version;
526 u32 tuner_id;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300527 struct MT2063_AvoidSpursData_t AS_Data;
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300528 u32 f_IF1_actual;
529 u32 rcvr_mode;
530 u32 ctfilt_sw;
531 u32 CTFiltMax[31];
532 u32 num_regs;
533 u8 reg[MT2063_REG_END_REGS];
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300534};
535typedef struct MT2063_Info_t *pMT2063_Info_t;
536
537enum MTTune_atv_standard {
538 MTTUNEA_UNKNOWN = 0,
539 MTTUNEA_PAL_B,
540 MTTUNEA_PAL_G,
541 MTTUNEA_PAL_I,
542 MTTUNEA_PAL_L,
543 MTTUNEA_PAL_MN,
544 MTTUNEA_PAL_DK,
545 MTTUNEA_DIGITAL,
546 MTTUNEA_FMRADIO,
547 MTTUNEA_DVBC,
548 MTTUNEA_DVBT
549};
550
551/* ====== Functions which are declared in MT2063.c File ======= */
552
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300553u32 MT2063_Open(u32 MT2063_Addr,
554 void ** hMT2063, void *hUserData);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300555
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300556u32 MT2063_Close(void *hMT2063);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300557
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300558u32 MT2063_Tune(void *h, u32 f_in); /* RF input center frequency */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300559
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300560u32 MT2063_GetGPIO(void *h, enum MT2063_GPIO_ID gpio_id,
561 enum MT2063_GPIO_Attr attr, u32 * value);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300562
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300563u32 MT2063_GetLocked(void *h);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300564
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300565u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300566
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300567u32 MT2063_GetReg(void *h, u8 reg, u8 * val);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300568
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300569u32 MT2063_GetTemp(void *h, enum MT2063_Temperature *value);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300570
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300571u32 MT2063_GetUserData(void *h, void ** hUserData);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300572
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300573u32 MT2063_ReInit(void *h);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300574
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300575u32 MT2063_SetGPIO(void *h, enum MT2063_GPIO_ID gpio_id,
576 enum MT2063_GPIO_Attr attr, u32 value);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300577
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300578u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300579
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300580u32 MT2063_SetPowerMaskBits(void *h, enum MT2063_Mask_Bits Bits);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300581
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300582u32 MT2063_ClearPowerMaskBits(void *h, enum MT2063_Mask_Bits Bits);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300583
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300584u32 MT2063_GetPowerMaskBits(void *h, enum MT2063_Mask_Bits *Bits);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300585
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300586u32 MT2063_EnableExternalShutdown(void *h, u8 Enabled);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300587
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300588u32 MT2063_SoftwareShutdown(void *h, u8 Shutdown);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300589
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300590u32 MT2063_SetExtSRO(void *h, enum MT2063_Ext_SRO Ext_SRO_Setting);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300591
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300592u32 MT2063_SetReg(void *h, u8 reg, u8 val);
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300593
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300594u32 MT_Tune_atv(void *h, u32 f_in, u32 bw_in,
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300595 enum MTTune_atv_standard tv_type);
596
597struct mt2063_config {
598 u8 tuner_address;
599 u32 refclock;
600};
601
602struct mt2063_state {
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300603 struct i2c_adapter *i2c;
604
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300605 const struct mt2063_config *config;
606 struct dvb_tuner_ops ops;
607 struct dvb_frontend *frontend;
608 struct tuner_state status;
609 const struct MT2063_Info_t *MT2063_ht;
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300610 bool MT2063_init;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300611
612 enum MTTune_atv_standard tv_type;
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300613 u32 frequency;
614 u32 srate;
615 u32 bandwidth;
616 u32 reference;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300617};
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300618
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -0300619#if defined(CONFIG_MEDIA_TUNER_MT2063) || (defined(CONFIG_MEDIA_TUNER_MT2063_MODULE) && defined(MODULE))
620struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
621 struct mt2063_config *config,
622 struct i2c_adapter *i2c);
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300623
624#else
625
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300626static inline struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -0300627 struct mt2063_config *config,
628 struct i2c_adapter *i2c)
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300629{
630 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
631 return NULL;
632}
633
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300634#endif /* CONFIG_DVB_MT2063 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300635
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300636#endif /* __MT2063_H__ */