blob: 5dece2c314ce2e01f5bbed7e524c42b3bea94122 [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
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -030085#define MAX_UDATA (4294967295) /* max value storable in u32 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030086
87/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -030088 * Define an MTxxxx_CNT macro for each type of tuner that will be built
89 * into your application (e.g., MT2121, MT2060). MT_TUNER_CNT
90 * must be set to the SUM of all of the MTxxxx_CNT macros.
91 *
92 * #define MT2050_CNT (1)
93 * #define MT2060_CNT (1)
94 * #define MT2111_CNT (1)
95 * #define MT2121_CNT (3)
96 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030097
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030098
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030099#define MT2063_TUNER_CNT (1) /* total num of MicroTuner tuners */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300100#define MT2063_I2C (0xC0)
101
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300102/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300103 * Constant defining the version of the following structure
104 * and therefore the API for this code.
105 *
106 * When compiling the tuner driver, the preprocessor will
107 * check against this version number to make sure that
108 * it matches the version that the tuner driver knows about.
109 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300110/* Version 010201 => 1.21 */
111#define MT2063_AVOID_SPURS_INFO_VERSION 010201
112
113/* DECT Frequency Avoidance */
114#define MT2063_DECT_AVOID_US_FREQS 0x00000001
115
116#define MT2063_DECT_AVOID_EURO_FREQS 0x00000002
117
118#define MT2063_EXCLUDE_US_DECT_FREQUENCIES(s) (((s) & MT2063_DECT_AVOID_US_FREQS) != 0)
119
120#define MT2063_EXCLUDE_EURO_DECT_FREQUENCIES(s) (((s) & MT2063_DECT_AVOID_EURO_FREQS) != 0)
121
122enum MT2063_DECT_Avoid_Type {
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300123 MT2063_NO_DECT_AVOIDANCE = 0, /* Do not create DECT exclusion zones. */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300124 MT2063_AVOID_US_DECT = MT2063_DECT_AVOID_US_FREQS, /* Avoid US DECT frequencies. */
125 MT2063_AVOID_EURO_DECT = MT2063_DECT_AVOID_EURO_FREQS, /* Avoid European DECT frequencies. */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300126 MT2063_AVOID_BOTH /* Avoid both regions. Not typically used. */
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300127};
128
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300129#define MT2063_MAX_ZONES 48
130
131struct MT2063_ExclZone_t;
132
133struct MT2063_ExclZone_t {
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300134 u32 min_;
135 u32 max_;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300136 struct MT2063_ExclZone_t *next_;
137};
138
139/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300140 * Structure of data needed for Spur Avoidance
141 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300142struct MT2063_AvoidSpursData_t {
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300143 u32 nAS_Algorithm;
144 u32 f_ref;
145 u32 f_in;
146 u32 f_LO1;
147 u32 f_if1_Center;
148 u32 f_if1_Request;
149 u32 f_if1_bw;
150 u32 f_LO2;
151 u32 f_out;
152 u32 f_out_bw;
153 u32 f_LO1_Step;
154 u32 f_LO2_Step;
155 u32 f_LO1_FracN_Avoid;
156 u32 f_LO2_FracN_Avoid;
157 u32 f_zif_bw;
158 u32 f_min_LO_Separation;
159 u32 maxH1;
160 u32 maxH2;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300161 enum MT2063_DECT_Avoid_Type avoidDECT;
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300162 u32 bSpurPresent;
163 u32 bSpurAvoided;
164 u32 nSpursFound;
165 u32 nZones;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300166 struct MT2063_ExclZone_t *freeZones;
167 struct MT2063_ExclZone_t *usedZones;
168 struct MT2063_ExclZone_t MT2063_ExclZones[MT2063_MAX_ZONES];
169};
170
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300171/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300172 * Values returned by the MT2063's on-chip temperature sensor
173 * to be read/written.
174 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300175enum MT2063_Temperature {
176 MT2063_T_0C = 0, /* Temperature approx 0C */
177 MT2063_T_10C, /* Temperature approx 10C */
178 MT2063_T_20C, /* Temperature approx 20C */
179 MT2063_T_30C, /* Temperature approx 30C */
180 MT2063_T_40C, /* Temperature approx 40C */
181 MT2063_T_50C, /* Temperature approx 50C */
182 MT2063_T_60C, /* Temperature approx 60C */
183 MT2063_T_70C, /* Temperature approx 70C */
184 MT2063_T_80C, /* Temperature approx 80C */
185 MT2063_T_90C, /* Temperature approx 90C */
186 MT2063_T_100C, /* Temperature approx 100C */
187 MT2063_T_110C, /* Temperature approx 110C */
188 MT2063_T_120C, /* Temperature approx 120C */
189 MT2063_T_130C, /* Temperature approx 130C */
190 MT2063_T_140C, /* Temperature approx 140C */
191 MT2063_T_150C, /* Temperature approx 150C */
192};
193
194/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300195 * Parameters for selecting GPIO bits
196 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300197enum MT2063_GPIO_Attr {
198 MT2063_GPIO_IN,
199 MT2063_GPIO_DIR,
200 MT2063_GPIO_OUT,
201};
202
203enum MT2063_GPIO_ID {
204 MT2063_GPIO0,
205 MT2063_GPIO1,
206 MT2063_GPIO2,
207};
208
209/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300210 * Parameter for function MT2063_SetExtSRO that specifies the external
211 * SRO drive frequency.
212 *
213 * MT2063_EXT_SRO_OFF is the power-up default value.
214 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300215enum MT2063_Ext_SRO {
216 MT2063_EXT_SRO_OFF, /* External SRO drive off */
217 MT2063_EXT_SRO_BY_4, /* External SRO drive divide by 4 */
218 MT2063_EXT_SRO_BY_2, /* External SRO drive divide by 2 */
219 MT2063_EXT_SRO_BY_1 /* External SRO drive divide by 1 */
220};
221
222/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300223 * Parameter for function MT2063_SetPowerMask that specifies the power down
224 * of various sections of the MT2063.
225 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300226enum MT2063_Mask_Bits {
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300227 MT2063_REG_SD = 0x0040, /* Shutdown regulator */
228 MT2063_SRO_SD = 0x0020, /* Shutdown SRO */
229 MT2063_AFC_SD = 0x0010, /* Shutdown AFC A/D */
230 MT2063_PD_SD = 0x0002, /* Enable power detector shutdown */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300231 MT2063_PDADC_SD = 0x0001, /* Enable power detector A/D shutdown */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300232 MT2063_VCO_SD = 0x8000, /* Enable VCO shutdown */
233 MT2063_LTX_SD = 0x4000, /* Enable LTX shutdown */
234 MT2063_LT1_SD = 0x2000, /* Enable LT1 shutdown */
235 MT2063_LNA_SD = 0x1000, /* Enable LNA shutdown */
236 MT2063_UPC_SD = 0x0800, /* Enable upconverter shutdown */
237 MT2063_DNC_SD = 0x0400, /* Enable downconverter shutdown */
238 MT2063_VGA_SD = 0x0200, /* Enable VGA shutdown */
239 MT2063_AMP_SD = 0x0100, /* Enable AMP shutdown */
240 MT2063_ALL_SD = 0xFF73, /* All shutdown bits for this tuner */
241 MT2063_NONE_SD = 0x0000 /* No shutdown bits */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300242};
243
244/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300245 * Parameter for function MT2063_GetParam & MT2063_SetParam that
246 * specifies the tuning algorithm parameter to be read/written.
247 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300248enum MT2063_Param {
249 /* tuner address set by MT2063_Open() */
250 MT2063_IC_ADDR,
251
252 /* max number of MT2063 tuners set by MT_TUNER_CNT in mt_userdef.h */
253 MT2063_MAX_OPEN,
254
255 /* current number of open MT2063 tuners set by MT2063_Open() */
256 MT2063_NUM_OPEN,
257
258 /* crystal frequency (default: 16000000 Hz) */
259 MT2063_SRO_FREQ,
260
261 /* min tuning step size (default: 50000 Hz) */
262 MT2063_STEPSIZE,
263
264 /* input center frequency set by MT2063_Tune() */
265 MT2063_INPUT_FREQ,
266
267 /* LO1 Frequency set by MT2063_Tune() */
268 MT2063_LO1_FREQ,
269
270 /* LO1 minimum step size (default: 250000 Hz) */
271 MT2063_LO1_STEPSIZE,
272
273 /* LO1 FracN keep-out region (default: 999999 Hz) */
274 MT2063_LO1_FRACN_AVOID_PARAM,
275
276 /* Current 1st IF in use set by MT2063_Tune() */
277 MT2063_IF1_ACTUAL,
278
279 /* Requested 1st IF set by MT2063_Tune() */
280 MT2063_IF1_REQUEST,
281
282 /* Center of 1st IF SAW filter (default: 1218000000 Hz) */
283 MT2063_IF1_CENTER,
284
285 /* Bandwidth of 1st IF SAW filter (default: 20000000 Hz) */
286 MT2063_IF1_BW,
287
288 /* zero-IF bandwidth (default: 2000000 Hz) */
289 MT2063_ZIF_BW,
290
291 /* LO2 Frequency set by MT2063_Tune() */
292 MT2063_LO2_FREQ,
293
294 /* LO2 minimum step size (default: 50000 Hz) */
295 MT2063_LO2_STEPSIZE,
296
297 /* LO2 FracN keep-out region (default: 374999 Hz) */
298 MT2063_LO2_FRACN_AVOID,
299
300 /* output center frequency set by MT2063_Tune() */
301 MT2063_OUTPUT_FREQ,
302
303 /* output bandwidth set by MT2063_Tune() */
304 MT2063_OUTPUT_BW,
305
306 /* min inter-tuner LO separation (default: 1000000 Hz) */
307 MT2063_LO_SEPARATION,
308
309 /* ID of avoid-spurs algorithm in use compile-time constant */
310 MT2063_AS_ALG,
311
312 /* max # of intra-tuner harmonics (default: 15) */
313 MT2063_MAX_HARM1,
314
315 /* max # of inter-tuner harmonics (default: 7) */
316 MT2063_MAX_HARM2,
317
318 /* # of 1st IF exclusion zones used set by MT2063_Tune() */
319 MT2063_EXCL_ZONES,
320
321 /* # of spurs found/avoided set by MT2063_Tune() */
322 MT2063_NUM_SPURS,
323
324 /* >0 spurs avoided set by MT2063_Tune() */
325 MT2063_SPUR_AVOIDED,
326
327 /* >0 spurs in output (mathematically) set by MT2063_Tune() */
328 MT2063_SPUR_PRESENT,
329
330 /* Receiver Mode for some parameters. 1 is DVB-T */
331 MT2063_RCVR_MODE,
332
333 /* directly set LNA attenuation, parameter is value to set */
334 MT2063_ACLNA,
335
336 /* maximum LNA attenuation, parameter is value to set */
337 MT2063_ACLNA_MAX,
338
339 /* directly set ATN attenuation. Paremeter is value to set. */
340 MT2063_ACRF,
341
342 /* maxium ATN attenuation. Paremeter is value to set. */
343 MT2063_ACRF_MAX,
344
345 /* directly set FIF attenuation. Paremeter is value to set. */
346 MT2063_ACFIF,
347
348 /* maxium FIF attenuation. Paremeter is value to set. */
349 MT2063_ACFIF_MAX,
350
351 /* LNA Rin */
352 MT2063_LNA_RIN,
353
354 /* Power Detector LNA level target */
355 MT2063_LNA_TGT,
356
357 /* Power Detector 1 level */
358 MT2063_PD1,
359
360 /* Power Detector 1 level target */
361 MT2063_PD1_TGT,
362
363 /* Power Detector 2 level */
364 MT2063_PD2,
365
366 /* Power Detector 2 level target */
367 MT2063_PD2_TGT,
368
369 /* Selects, which DNC is activ */
370 MT2063_DNC_OUTPUT_ENABLE,
371
372 /* VGA gain code */
373 MT2063_VGAGC,
374
375 /* VGA bias current */
376 MT2063_VGAOI,
377
378 /* TAGC, determins the speed of the AGC */
379 MT2063_TAGC,
380
381 /* AMP gain code */
382 MT2063_AMPGC,
383
384 /* Control setting to avoid DECT freqs (default: MT_AVOID_BOTH) */
385 MT2063_AVOID_DECT,
386
387 /* Cleartune filter selection: 0 - by IC (default), 1 - by software */
388 MT2063_CTFILT_SW,
389
390 MT2063_EOP /* last entry in enumerated list */
391};
392
393/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300394 * Parameter for selecting tuner mode
395 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300396enum MT2063_RCVR_MODES {
397 MT2063_CABLE_QAM = 0, /* Digital cable */
398 MT2063_CABLE_ANALOG, /* Analog cable */
399 MT2063_OFFAIR_COFDM, /* Digital offair */
400 MT2063_OFFAIR_COFDM_SAWLESS, /* Digital offair without SAW */
401 MT2063_OFFAIR_ANALOG, /* Analog offair */
402 MT2063_OFFAIR_8VSB, /* Analog offair */
403 MT2063_NUM_RCVR_MODES
404};
405
406/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300407 * Possible values for MT2063_DNC_OUTPUT
408 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300409enum MT2063_DNC_Output_Enable {
410 MT2063_DNC_NONE = 0,
411 MT2063_DNC_1,
412 MT2063_DNC_2,
413 MT2063_DNC_BOTH
414};
415
416/*
417** Two-wire serial bus subaddresses of the tuner registers.
418** Also known as the tuner's register addresses.
419*/
420enum MT2063_Register_Offsets {
421 MT2063_REG_PART_REV = 0, /* 0x00: Part/Rev Code */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300422 MT2063_REG_LO1CQ_1, /* 0x01: LO1C Queued Byte 1 */
423 MT2063_REG_LO1CQ_2, /* 0x02: LO1C Queued Byte 2 */
424 MT2063_REG_LO2CQ_1, /* 0x03: LO2C Queued Byte 1 */
425 MT2063_REG_LO2CQ_2, /* 0x04: LO2C Queued Byte 2 */
426 MT2063_REG_LO2CQ_3, /* 0x05: LO2C Queued Byte 3 */
427 MT2063_REG_RSVD_06, /* 0x06: Reserved */
428 MT2063_REG_LO_STATUS, /* 0x07: LO Status */
429 MT2063_REG_FIFFC, /* 0x08: FIFF Center */
430 MT2063_REG_CLEARTUNE, /* 0x09: ClearTune Filter */
431 MT2063_REG_ADC_OUT, /* 0x0A: ADC_OUT */
432 MT2063_REG_LO1C_1, /* 0x0B: LO1C Byte 1 */
433 MT2063_REG_LO1C_2, /* 0x0C: LO1C Byte 2 */
434 MT2063_REG_LO2C_1, /* 0x0D: LO2C Byte 1 */
435 MT2063_REG_LO2C_2, /* 0x0E: LO2C Byte 2 */
436 MT2063_REG_LO2C_3, /* 0x0F: LO2C Byte 3 */
437 MT2063_REG_RSVD_10, /* 0x10: Reserved */
438 MT2063_REG_PWR_1, /* 0x11: PWR Byte 1 */
439 MT2063_REG_PWR_2, /* 0x12: PWR Byte 2 */
440 MT2063_REG_TEMP_STATUS, /* 0x13: Temp Status */
441 MT2063_REG_XO_STATUS, /* 0x14: Crystal Status */
442 MT2063_REG_RF_STATUS, /* 0x15: RF Attn Status */
443 MT2063_REG_FIF_STATUS, /* 0x16: FIF Attn Status */
444 MT2063_REG_LNA_OV, /* 0x17: LNA Attn Override */
445 MT2063_REG_RF_OV, /* 0x18: RF Attn Override */
446 MT2063_REG_FIF_OV, /* 0x19: FIF Attn Override */
447 MT2063_REG_LNA_TGT, /* 0x1A: Reserved */
448 MT2063_REG_PD1_TGT, /* 0x1B: Pwr Det 1 Target */
449 MT2063_REG_PD2_TGT, /* 0x1C: Pwr Det 2 Target */
450 MT2063_REG_RSVD_1D, /* 0x1D: Reserved */
451 MT2063_REG_RSVD_1E, /* 0x1E: Reserved */
452 MT2063_REG_RSVD_1F, /* 0x1F: Reserved */
453 MT2063_REG_RSVD_20, /* 0x20: Reserved */
454 MT2063_REG_BYP_CTRL, /* 0x21: Bypass Control */
455 MT2063_REG_RSVD_22, /* 0x22: Reserved */
456 MT2063_REG_RSVD_23, /* 0x23: Reserved */
457 MT2063_REG_RSVD_24, /* 0x24: Reserved */
458 MT2063_REG_RSVD_25, /* 0x25: Reserved */
459 MT2063_REG_RSVD_26, /* 0x26: Reserved */
460 MT2063_REG_RSVD_27, /* 0x27: Reserved */
461 MT2063_REG_FIFF_CTRL, /* 0x28: FIFF Control */
462 MT2063_REG_FIFF_OFFSET, /* 0x29: FIFF Offset */
463 MT2063_REG_CTUNE_CTRL, /* 0x2A: Reserved */
464 MT2063_REG_CTUNE_OV, /* 0x2B: Reserved */
465 MT2063_REG_CTRL_2C, /* 0x2C: Reserved */
466 MT2063_REG_FIFF_CTRL2, /* 0x2D: Fiff Control */
467 MT2063_REG_RSVD_2E, /* 0x2E: Reserved */
468 MT2063_REG_DNC_GAIN, /* 0x2F: DNC Control */
469 MT2063_REG_VGA_GAIN, /* 0x30: VGA Gain Ctrl */
470 MT2063_REG_RSVD_31, /* 0x31: Reserved */
471 MT2063_REG_TEMP_SEL, /* 0x32: Temperature Selection */
472 MT2063_REG_RSVD_33, /* 0x33: Reserved */
473 MT2063_REG_RSVD_34, /* 0x34: Reserved */
474 MT2063_REG_RSVD_35, /* 0x35: Reserved */
475 MT2063_REG_RSVD_36, /* 0x36: Reserved */
476 MT2063_REG_RSVD_37, /* 0x37: Reserved */
477 MT2063_REG_RSVD_38, /* 0x38: Reserved */
478 MT2063_REG_RSVD_39, /* 0x39: Reserved */
479 MT2063_REG_RSVD_3A, /* 0x3A: Reserved */
480 MT2063_REG_RSVD_3B, /* 0x3B: Reserved */
481 MT2063_REG_RSVD_3C, /* 0x3C: Reserved */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300482 MT2063_REG_END_REGS
483};
484
485struct MT2063_Info_t {
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300486 void *handle;
487 void *hUserData;
488 u32 address;
489 u32 version;
490 u32 tuner_id;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300491 struct MT2063_AvoidSpursData_t AS_Data;
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300492 u32 f_IF1_actual;
493 u32 rcvr_mode;
494 u32 ctfilt_sw;
495 u32 CTFiltMax[31];
496 u32 num_regs;
497 u8 reg[MT2063_REG_END_REGS];
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300498};
499typedef struct MT2063_Info_t *pMT2063_Info_t;
500
501enum MTTune_atv_standard {
502 MTTUNEA_UNKNOWN = 0,
503 MTTUNEA_PAL_B,
504 MTTUNEA_PAL_G,
505 MTTUNEA_PAL_I,
506 MTTUNEA_PAL_L,
507 MTTUNEA_PAL_MN,
508 MTTUNEA_PAL_DK,
509 MTTUNEA_DIGITAL,
510 MTTUNEA_FMRADIO,
511 MTTUNEA_DVBC,
512 MTTUNEA_DVBT
513};
514
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300515struct mt2063_config {
516 u8 tuner_address;
517 u32 refclock;
518};
519
520struct mt2063_state {
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300521 struct i2c_adapter *i2c;
522
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300523 const struct mt2063_config *config;
524 struct dvb_tuner_ops ops;
525 struct dvb_frontend *frontend;
526 struct tuner_state status;
Mauro Carvalho Chehabf8676952011-07-20 22:00:30 -0300527 struct MT2063_Info_t *MT2063_ht;
Mauro Carvalho Chehabcfde8922011-07-20 21:01:48 -0300528 bool MT2063_init;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300529
530 enum MTTune_atv_standard tv_type;
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300531 u32 frequency;
532 u32 srate;
533 u32 bandwidth;
534 u32 reference;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300535};
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300536
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -0300537#if defined(CONFIG_MEDIA_TUNER_MT2063) || (defined(CONFIG_MEDIA_TUNER_MT2063_MODULE) && defined(MODULE))
538struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
539 struct mt2063_config *config,
540 struct i2c_adapter *i2c);
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300541
542#else
543
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300544static inline struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -0300545 struct mt2063_config *config,
546 struct i2c_adapter *i2c)
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300547{
548 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
549 return NULL;
550}
551
Mauro Carvalho Chehabf8676952011-07-20 22:00:30 -0300552unsigned int mt2063_setTune(struct dvb_frontend *fe, u32 f_in,
553 u32 bw_in,
554 enum MTTune_atv_standard tv_type);
555
556unsigned int mt2063_lockStatus(struct dvb_frontend *fe);
557unsigned int tuner_MT2063_Open(struct dvb_frontend *fe);
558unsigned int tuner_MT2063_SoftwareShutdown(struct dvb_frontend *fe);
559unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe);
560
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300561#endif /* CONFIG_DVB_MT2063 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300562
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300563#endif /* __MT2063_H__ */