1 /*
2  * Afatech AF9013 demodulator driver
3  *
4  * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
5  * Copyright (C) 2011 Antti Palosaari <crope@iki.fi>
6  *
7  * Thanks to Afatech who kindly provided information.
8  *
9  *    This program is free software; you can redistribute it and/or modify
10  *    it under the terms of the GNU General Public License as published by
11  *    the Free Software Foundation; either version 2 of the License, or
12  *    (at your option) any later version.
13  *
14  *    This program is distributed in the hope that it will be useful,
15  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *    GNU General Public License for more details.
18  *
19  */
20 
21 #ifndef AF9013_PRIV_H
22 #define AF9013_PRIV_H
23 
24 #include <media/dvb_frontend.h>
25 #include <media/dvb_math.h>
26 #include "af9013.h"
27 #include <linux/firmware.h>
28 #include <linux/i2c-mux.h>
29 #include <linux/math64.h>
30 #include <linux/regmap.h>
31 
32 #define AF9013_FIRMWARE "dvb-fe-af9013.fw"
33 
34 struct af9013_reg_mask_val {
35 	u16 reg;
36 	u8  mask;
37 	u8  val;
38 };
39 
40 struct af9013_coeff {
41 	u32 clock;
42 	u32 bandwidth_hz;
43 	u8 val[24];
44 };
45 
46 /* pre-calculated coeff lookup table */
47 static const struct af9013_coeff coeff_lut[] = {
48 	/* 28.800 MHz */
49 	{ 28800000, 8000000, { 0x02, 0x8a, 0x28, 0xa3, 0x05, 0x14,
50 		0x51, 0x11, 0x00, 0xa2, 0x8f, 0x3d, 0x00, 0xa2, 0x8a,
51 		0x29, 0x00, 0xa2, 0x85, 0x14, 0x01, 0x45, 0x14, 0x14 } },
52 	{ 28800000, 7000000, { 0x02, 0x38, 0xe3, 0x8e, 0x04, 0x71,
53 		0xc7, 0x07, 0x00, 0x8e, 0x3d, 0x55, 0x00, 0x8e, 0x38,
54 		0xe4, 0x00, 0x8e, 0x34, 0x72, 0x01, 0x1c, 0x71, 0x32 } },
55 	{ 28800000, 6000000, { 0x01, 0xe7, 0x9e, 0x7a, 0x03, 0xcf,
56 		0x3c, 0x3d, 0x00, 0x79, 0xeb, 0x6e, 0x00, 0x79, 0xe7,
57 		0x9e, 0x00, 0x79, 0xe3, 0xcf, 0x00, 0xf3, 0xcf, 0x0f } },
58 	/* 20.480 MHz */
59 	{ 20480000, 8000000, { 0x03, 0x92, 0x49, 0x26, 0x07, 0x24,
60 		0x92, 0x13, 0x00, 0xe4, 0x99, 0x6e, 0x00, 0xe4, 0x92,
61 		0x49, 0x00, 0xe4, 0x8b, 0x25, 0x01, 0xc9, 0x24, 0x25 } },
62 	{ 20480000, 7000000, { 0x03, 0x20, 0x00, 0x01, 0x06, 0x40,
63 		0x00, 0x00, 0x00, 0xc8, 0x06, 0x40, 0x00, 0xc8, 0x00,
64 		0x00, 0x00, 0xc7, 0xf9, 0xc0, 0x01, 0x90, 0x00, 0x00 } },
65 	{ 20480000, 6000000, { 0x02, 0xad, 0xb6, 0xdc, 0x05, 0x5b,
66 		0x6d, 0x2e, 0x00, 0xab, 0x73, 0x13, 0x00, 0xab, 0x6d,
67 		0xb7, 0x00, 0xab, 0x68, 0x5c, 0x01, 0x56, 0xdb, 0x1c } },
68 	/* 28.000 MHz */
69 	{ 28000000, 8000000, { 0x02, 0x9c, 0xbc, 0x15, 0x05, 0x39,
70 		0x78, 0x0a, 0x00, 0xa7, 0x34, 0x3f, 0x00, 0xa7, 0x2f,
71 		0x05, 0x00, 0xa7, 0x29, 0xcc, 0x01, 0x4e, 0x5e, 0x03 } },
72 	{ 28000000, 7000000, { 0x02, 0x49, 0x24, 0x92, 0x04, 0x92,
73 		0x49, 0x09, 0x00, 0x92, 0x4d, 0xb7, 0x00, 0x92, 0x49,
74 		0x25, 0x00, 0x92, 0x44, 0x92, 0x01, 0x24, 0x92, 0x12 } },
75 	{ 28000000, 6000000, { 0x01, 0xf5, 0x8d, 0x10, 0x03, 0xeb,
76 		0x1a, 0x08, 0x00, 0x7d, 0x67, 0x2f, 0x00, 0x7d, 0x63,
77 		0x44, 0x00, 0x7d, 0x5f, 0x59, 0x00, 0xfa, 0xc6, 0x22 } },
78 	/* 25.000 MHz */
79 	{ 25000000, 8000000, { 0x02, 0xec, 0xfb, 0x9d, 0x05, 0xd9,
80 		0xf7, 0x0e, 0x00, 0xbb, 0x44, 0xc1, 0x00, 0xbb, 0x3e,
81 		0xe7, 0x00, 0xbb, 0x39, 0x0d, 0x01, 0x76, 0x7d, 0x34 } },
82 	{ 25000000, 7000000, { 0x02, 0x8f, 0x5c, 0x29, 0x05, 0x1e,
83 		0xb8, 0x14, 0x00, 0xa3, 0xdc, 0x29, 0x00, 0xa3, 0xd7,
84 		0x0a, 0x00, 0xa3, 0xd1, 0xec, 0x01, 0x47, 0xae, 0x05 } },
85 	{ 25000000, 6000000, { 0x02, 0x31, 0xbc, 0xb5, 0x04, 0x63,
86 		0x79, 0x1b, 0x00, 0x8c, 0x73, 0x91, 0x00, 0x8c, 0x6f,
87 		0x2d, 0x00, 0x8c, 0x6a, 0xca, 0x01, 0x18, 0xde, 0x17 } },
88 };
89 
90 /*
91  * Afatech AF9013 demod init
92  */
93 static const struct af9013_reg_mask_val demod_init_tab[] = {
94 	{0xd73a, 0xff, 0xa1},
95 	{0xd73b, 0xff, 0x1f},
96 	{0xd73c, 0xf0, 0xa0},
97 	{0xd732, 0x08, 0x00},
98 	{0xd731, 0x30, 0x30},
99 	{0xd73d, 0x80, 0x80},
100 	{0xd740, 0x01, 0x00},
101 	{0xd740, 0x02, 0x00},
102 	{0xd740, 0x04, 0x00},
103 	{0xd740, 0x08, 0x08},
104 	{0xd3c1, 0x10, 0x10},
105 	{0x9124, 0xff, 0x58},
106 	{0x9125, 0x03, 0x02},
107 	{0xd3a2, 0xff, 0x00},
108 	{0xd3a3, 0xff, 0x04},
109 	{0xd305, 0xff, 0x32},
110 	{0xd306, 0xff, 0x10},
111 	{0xd304, 0xff, 0x04},
112 	{0x9112, 0x01, 0x01},
113 	{0x911d, 0x01, 0x01},
114 	{0x911a, 0x01, 0x01},
115 	{0x911b, 0x01, 0x01},
116 	{0x9bce, 0x0f, 0x02},
117 	{0x9116, 0x01, 0x01},
118 	{0x9122, 0xff, 0xd0},
119 	{0xd2e0, 0xff, 0xd0},
120 	{0xd2e9, 0x0f, 0x0d},
121 	{0xd38c, 0xff, 0xfc},
122 	{0xd38d, 0xff, 0x00},
123 	{0xd38e, 0xff, 0x7e},
124 	{0xd38f, 0xff, 0x00},
125 	{0xd390, 0xff, 0x2f},
126 	{0xd145, 0x10, 0x10},
127 	{0xd1a9, 0x10, 0x10},
128 	{0xd158, 0xe0, 0x20},
129 	{0xd159, 0x3f, 0x06},
130 	{0xd167, 0xff, 0x00},
131 	{0xd168, 0x0f, 0x07},
132 	{0xd1c3, 0xe0, 0x00},
133 	{0xd1c4, 0x3f, 0x00},
134 	{0xd1c5, 0x7f, 0x10},
135 	{0xd1c6, 0x07, 0x02},
136 	{0xd080, 0x7c, 0x0c},
137 	{0xd081, 0xf0, 0x90},
138 	{0xd098, 0xf0, 0xf0},
139 	{0xd098, 0x0f, 0x03},
140 	{0xdbc0, 0x10, 0x10},
141 	{0xdbc7, 0xff, 0x08},
142 	{0xdbc8, 0xf0, 0x00},
143 	{0xdbc9, 0x1f, 0x01},
144 	{0xd280, 0xff, 0xe0},
145 	{0xd281, 0xff, 0xff},
146 	{0xd282, 0xff, 0xff},
147 	{0xd283, 0xff, 0xc3},
148 	{0xd284, 0xff, 0xff},
149 	{0xd285, 0x0f, 0x01},
150 	{0xd0f0, 0x7f, 0x1a},
151 	{0xd0f1, 0x10, 0x10},
152 	{0xd0f2, 0xff, 0x0c},
153 	{0xd101, 0xe0, 0xc0},
154 	{0xd103, 0x0f, 0x08},
155 	{0xd0f8, 0x7f, 0x20},
156 	{0xd111, 0x20, 0x00},
157 	{0xd111, 0x40, 0x00},
158 	{0x910b, 0xff, 0x0a},
159 	{0x9115, 0xff, 0x02},
160 	{0x910c, 0xff, 0x02},
161 	{0x910d, 0xff, 0x08},
162 	{0x910e, 0xff, 0x0a},
163 	{0x9bf6, 0xff, 0x06},
164 	{0x9bf8, 0xff, 0x02},
165 	{0x9bf7, 0xff, 0x05},
166 	{0x9bf9, 0xff, 0x0f},
167 	{0x9bfc, 0xff, 0x13},
168 	{0x9bd3, 0xff, 0xff},
169 	{0x9bbe, 0x01, 0x01},
170 	{0x9bcc, 0x01, 0x01},
171 };
172 
173 /*
174  * Panasonic ENV77H11D5 tuner init
175  * AF9013_TUNER_ENV77H11D5    0x81
176  */
177 static const struct af9013_reg_mask_val tuner_init_tab_env77h11d5[] = {
178 	{0x9bd5, 0xff, 0x01},
179 	{0x9bd6, 0xff, 0x03},
180 	{0x9bbe, 0xff, 0x01},
181 	{0xd1a0, 0x02, 0x02},
182 	{0xd000, 0x01, 0x01},
183 	{0xd000, 0x02, 0x00},
184 	{0xd001, 0x02, 0x02},
185 	{0xd001, 0x01, 0x00},
186 	{0xd001, 0x20, 0x00},
187 	{0xd002, 0x1f, 0x19},
188 	{0xd003, 0x1f, 0x1a},
189 	{0xd004, 0x1f, 0x19},
190 	{0xd005, 0x1f, 0x1a},
191 	{0xd00e, 0x1f, 0x10},
192 	{0xd00f, 0x07, 0x04},
193 	{0xd00f, 0x38, 0x28},
194 	{0xd010, 0x07, 0x04},
195 	{0xd010, 0x38, 0x28},
196 	{0xd016, 0xf0, 0x30},
197 	{0xd01f, 0x3f, 0x0a},
198 	{0xd020, 0x3f, 0x0a},
199 	{0x9bda, 0xff, 0x00},
200 	{0x9be3, 0xff, 0x00},
201 	{0xd015, 0xff, 0x50},
202 	{0xd016, 0x01, 0x00},
203 	{0xd044, 0xff, 0x46},
204 	{0xd045, 0x01, 0x00},
205 	{0xd008, 0xff, 0xdf},
206 	{0xd009, 0x03, 0x02},
207 	{0xd006, 0xff, 0x44},
208 	{0xd007, 0x03, 0x01},
209 	{0xd00c, 0xff, 0xeb},
210 	{0xd00d, 0x03, 0x02},
211 	{0xd00a, 0xff, 0xf4},
212 	{0xd00b, 0x03, 0x01},
213 	{0x9bba, 0xff, 0xf9},
214 	{0x9bc3, 0xff, 0xdf},
215 	{0x9bc4, 0xff, 0x02},
216 	{0x9bc5, 0xff, 0xeb},
217 	{0x9bc6, 0xff, 0x02},
218 	{0x9bc9, 0xff, 0x52},
219 	{0xd011, 0xff, 0x3c},
220 	{0xd012, 0x03, 0x01},
221 	{0xd013, 0xff, 0xf7},
222 	{0xd014, 0x03, 0x02},
223 	{0xd040, 0xff, 0x0b},
224 	{0xd041, 0x03, 0x02},
225 	{0xd042, 0xff, 0x4d},
226 	{0xd043, 0x03, 0x00},
227 	{0xd045, 0x02, 0x00},
228 	{0x9bcf, 0x01, 0x01},
229 	{0xd045, 0x04, 0x04},
230 	{0xd04f, 0xff, 0x9a},
231 	{0xd050, 0x01, 0x01},
232 	{0xd051, 0xff, 0x5a},
233 	{0xd052, 0x01, 0x01},
234 	{0xd053, 0xff, 0x50},
235 	{0xd054, 0xff, 0x46},
236 	{0x9bd7, 0xff, 0x0a},
237 	{0x9bd8, 0xff, 0x14},
238 	{0x9bd9, 0xff, 0x08},
239 };
240 
241 /*
242  * Microtune MT2060 tuner init
243  * AF9013_TUNER_MT2060        0x82
244  */
245 static const struct af9013_reg_mask_val tuner_init_tab_mt2060[] = {
246 	{0x9bd5, 0xff, 0x01},
247 	{0x9bd6, 0xff, 0x07},
248 	{0xd1a0, 0x02, 0x02},
249 	{0xd000, 0x01, 0x01},
250 	{0xd000, 0x02, 0x00},
251 	{0xd001, 0x02, 0x02},
252 	{0xd001, 0x01, 0x00},
253 	{0xd001, 0x20, 0x00},
254 	{0xd002, 0x1f, 0x19},
255 	{0xd003, 0x1f, 0x1a},
256 	{0xd004, 0x1f, 0x19},
257 	{0xd005, 0x1f, 0x1a},
258 	{0xd00e, 0x1f, 0x10},
259 	{0xd00f, 0x07, 0x04},
260 	{0xd00f, 0x38, 0x28},
261 	{0xd010, 0x07, 0x04},
262 	{0xd010, 0x38, 0x28},
263 	{0xd016, 0xf0, 0x30},
264 	{0xd01f, 0x3f, 0x0a},
265 	{0xd020, 0x3f, 0x0a},
266 	{0x9bda, 0xff, 0x00},
267 	{0x9be3, 0xff, 0x00},
268 	{0x9bbe, 0x01, 0x00},
269 	{0x9bcc, 0x01, 0x00},
270 	{0x9bb9, 0xff, 0x75},
271 	{0x9bcd, 0xff, 0x24},
272 	{0x9bff, 0xff, 0x30},
273 	{0xd015, 0xff, 0x46},
274 	{0xd016, 0x01, 0x00},
275 	{0xd044, 0xff, 0x46},
276 	{0xd045, 0x01, 0x00},
277 	{0xd008, 0xff, 0x0f},
278 	{0xd009, 0x03, 0x02},
279 	{0xd006, 0xff, 0x32},
280 	{0xd007, 0x03, 0x01},
281 	{0xd00c, 0xff, 0x36},
282 	{0xd00d, 0x03, 0x03},
283 	{0xd00a, 0xff, 0x35},
284 	{0xd00b, 0x03, 0x01},
285 	{0x9bc7, 0xff, 0x07},
286 	{0x9bc8, 0xff, 0x90},
287 	{0x9bc3, 0xff, 0x0f},
288 	{0x9bc4, 0xff, 0x02},
289 	{0x9bc5, 0xff, 0x36},
290 	{0x9bc6, 0xff, 0x03},
291 	{0x9bba, 0xff, 0xc9},
292 	{0x9bc9, 0xff, 0x79},
293 	{0xd011, 0xff, 0x10},
294 	{0xd012, 0x03, 0x01},
295 	{0xd013, 0xff, 0x45},
296 	{0xd014, 0x03, 0x03},
297 	{0xd040, 0xff, 0x98},
298 	{0xd041, 0x03, 0x00},
299 	{0xd042, 0xff, 0xcf},
300 	{0xd043, 0x03, 0x03},
301 	{0xd045, 0x02, 0x00},
302 	{0x9bcf, 0x01, 0x01},
303 	{0xd045, 0x04, 0x04},
304 	{0xd04f, 0xff, 0x9a},
305 	{0xd050, 0x01, 0x01},
306 	{0xd051, 0xff, 0x5a},
307 	{0xd052, 0x01, 0x01},
308 	{0xd053, 0xff, 0x50},
309 	{0xd054, 0xff, 0x46},
310 	{0x9bd7, 0xff, 0x0a},
311 	{0x9bd8, 0xff, 0x14},
312 	{0x9bd9, 0xff, 0x08},
313 	{0x9bd0, 0xff, 0xcc},
314 	{0x9be4, 0xff, 0xa0},
315 	{0x9bbd, 0xff, 0x8e},
316 	{0x9be2, 0xff, 0x4d},
317 	{0x9bee, 0x01, 0x01},
318 };
319 
320 /*
321  * Microtune MT2060 tuner init
322  * AF9013_TUNER_MT2060_2      0x93
323  */
324 static const struct af9013_reg_mask_val tuner_init_tab_mt2060_2[] = {
325 	{0x9bd5, 0xff, 0x01},
326 	{0x9bd6, 0xff, 0x06},
327 	{0x9bbe, 0xff, 0x01},
328 	{0xd1a0, 0x02, 0x02},
329 	{0xd000, 0x01, 0x01},
330 	{0xd000, 0x02, 0x00},
331 	{0xd001, 0x02, 0x02},
332 	{0xd001, 0x01, 0x00},
333 	{0xd001, 0x20, 0x00},
334 	{0xd002, 0x1f, 0x19},
335 	{0xd003, 0x1f, 0x1a},
336 	{0xd004, 0x1f, 0x19},
337 	{0xd005, 0x1f, 0x1a},
338 	{0xd00e, 0x1f, 0x10},
339 	{0xd00f, 0x07, 0x04},
340 	{0xd00f, 0x38, 0x28},
341 	{0xd010, 0x07, 0x04},
342 	{0xd010, 0x38, 0x28},
343 	{0xd016, 0xf0, 0x30},
344 	{0xd01f, 0x3f, 0x0a},
345 	{0xd020, 0x3f, 0x0a},
346 	{0xd015, 0xff, 0x46},
347 	{0xd016, 0x01, 0x00},
348 	{0xd044, 0xff, 0x46},
349 	{0xd045, 0x01, 0x00},
350 	{0xd008, 0xff, 0x0f},
351 	{0xd009, 0x03, 0x02},
352 	{0xd006, 0xff, 0x32},
353 	{0xd007, 0x03, 0x01},
354 	{0xd00c, 0xff, 0x36},
355 	{0xd00d, 0x03, 0x03},
356 	{0xd00a, 0xff, 0x35},
357 	{0xd00b, 0x03, 0x01},
358 	{0x9bc7, 0xff, 0x07},
359 	{0x9bc8, 0xff, 0x90},
360 	{0x9bc3, 0xff, 0x0f},
361 	{0x9bc4, 0xff, 0x02},
362 	{0x9bc5, 0xff, 0x36},
363 	{0x9bc6, 0xff, 0x03},
364 	{0x9bba, 0xff, 0xc9},
365 	{0x9bc9, 0xff, 0x79},
366 	{0xd011, 0xff, 0x10},
367 	{0xd012, 0x03, 0x01},
368 	{0xd013, 0xff, 0x45},
369 	{0xd014, 0x03, 0x03},
370 	{0xd040, 0xff, 0x98},
371 	{0xd041, 0x03, 0x00},
372 	{0xd042, 0xff, 0xcf},
373 	{0xd043, 0x03, 0x03},
374 	{0xd045, 0x02, 0x00},
375 	{0x9bcf, 0xff, 0x01},
376 	{0xd045, 0x04, 0x04},
377 	{0xd04f, 0xff, 0x9a},
378 	{0xd050, 0x01, 0x01},
379 	{0xd051, 0xff, 0x5a},
380 	{0xd052, 0x01, 0x01},
381 	{0xd053, 0xff, 0x96},
382 	{0xd054, 0xff, 0x46},
383 	{0xd045, 0x80, 0x00},
384 	{0x9bd7, 0xff, 0x0a},
385 	{0x9bd8, 0xff, 0x14},
386 	{0x9bd9, 0xff, 0x08},
387 };
388 
389 /*
390  * MaxLinear MXL5003 tuner init
391  * AF9013_TUNER_MXL5003D      0x03
392  */
393 static const struct af9013_reg_mask_val tuner_init_tab_mxl5003d[] = {
394 	{0x9bd5, 0xff, 0x01},
395 	{0x9bd6, 0xff, 0x09},
396 	{0xd1a0, 0x02, 0x02},
397 	{0xd000, 0x01, 0x01},
398 	{0xd000, 0x02, 0x00},
399 	{0xd001, 0x02, 0x02},
400 	{0xd001, 0x01, 0x00},
401 	{0xd001, 0x20, 0x00},
402 	{0xd002, 0x1f, 0x19},
403 	{0xd003, 0x1f, 0x1a},
404 	{0xd004, 0x1f, 0x19},
405 	{0xd005, 0x1f, 0x1a},
406 	{0xd00e, 0x1f, 0x10},
407 	{0xd00f, 0x07, 0x04},
408 	{0xd00f, 0x38, 0x28},
409 	{0xd010, 0x07, 0x04},
410 	{0xd010, 0x38, 0x28},
411 	{0xd016, 0xf0, 0x30},
412 	{0xd01f, 0x3f, 0x0a},
413 	{0xd020, 0x3f, 0x0a},
414 	{0x9bda, 0xff, 0x00},
415 	{0x9be3, 0xff, 0x00},
416 	{0x9bfc, 0xff, 0x0f},
417 	{0x9bf6, 0xff, 0x01},
418 	{0x9bbe, 0x01, 0x01},
419 	{0xd015, 0xff, 0x33},
420 	{0xd016, 0x01, 0x00},
421 	{0xd044, 0xff, 0x40},
422 	{0xd045, 0x01, 0x00},
423 	{0xd008, 0xff, 0x0f},
424 	{0xd009, 0x03, 0x02},
425 	{0xd006, 0xff, 0x6c},
426 	{0xd007, 0x03, 0x00},
427 	{0xd00c, 0xff, 0x3d},
428 	{0xd00d, 0x03, 0x00},
429 	{0xd00a, 0xff, 0x45},
430 	{0xd00b, 0x03, 0x01},
431 	{0x9bc7, 0xff, 0x07},
432 	{0x9bc8, 0xff, 0x52},
433 	{0x9bc3, 0xff, 0x0f},
434 	{0x9bc4, 0xff, 0x02},
435 	{0x9bc5, 0xff, 0x3d},
436 	{0x9bc6, 0xff, 0x00},
437 	{0x9bba, 0xff, 0xa2},
438 	{0x9bc9, 0xff, 0xa0},
439 	{0xd011, 0xff, 0x56},
440 	{0xd012, 0x03, 0x00},
441 	{0xd013, 0xff, 0x50},
442 	{0xd014, 0x03, 0x00},
443 	{0xd040, 0xff, 0x56},
444 	{0xd041, 0x03, 0x00},
445 	{0xd042, 0xff, 0x50},
446 	{0xd043, 0x03, 0x00},
447 	{0xd045, 0x02, 0x00},
448 	{0x9bcf, 0xff, 0x01},
449 	{0xd045, 0x04, 0x04},
450 	{0xd04f, 0xff, 0x9a},
451 	{0xd050, 0x01, 0x01},
452 	{0xd051, 0xff, 0x5a},
453 	{0xd052, 0x01, 0x01},
454 	{0xd053, 0xff, 0x50},
455 	{0xd054, 0xff, 0x46},
456 	{0x9bd7, 0xff, 0x0a},
457 	{0x9bd8, 0xff, 0x14},
458 	{0x9bd9, 0xff, 0x08},
459 };
460 
461 /*
462  * MaxLinear MXL5005S & MXL5007T tuner init
463  * AF9013_TUNER_MXL5005D      0x0d
464  * AF9013_TUNER_MXL5005R      0x1e
465  * AF9013_TUNER_MXL5007T      0xb1
466  */
467 static const struct af9013_reg_mask_val tuner_init_tab_mxl5005[] = {
468 	{0x9bd5, 0xff, 0x01},
469 	{0x9bd6, 0xff, 0x07},
470 	{0xd1a0, 0x02, 0x02},
471 	{0xd000, 0x01, 0x01},
472 	{0xd000, 0x02, 0x00},
473 	{0xd001, 0x02, 0x02},
474 	{0xd001, 0x01, 0x00},
475 	{0xd001, 0x20, 0x00},
476 	{0xd002, 0x1f, 0x19},
477 	{0xd003, 0x1f, 0x1a},
478 	{0xd004, 0x1f, 0x19},
479 	{0xd005, 0x1f, 0x1a},
480 	{0xd00e, 0x1f, 0x10},
481 	{0xd00f, 0x07, 0x04},
482 	{0xd00f, 0x38, 0x28},
483 	{0xd010, 0x07, 0x04},
484 	{0xd010, 0x38, 0x28},
485 	{0xd016, 0xf0, 0x30},
486 	{0xd01f, 0x3f, 0x0a},
487 	{0xd020, 0x3f, 0x0a},
488 	{0x9bda, 0xff, 0x01},
489 	{0x9be3, 0xff, 0x01},
490 	{0x9bbe, 0x01, 0x01},
491 	{0x9bcc, 0x01, 0x01},
492 	{0x9bb9, 0xff, 0x00},
493 	{0x9bcd, 0xff, 0x28},
494 	{0x9bff, 0xff, 0x24},
495 	{0xd015, 0xff, 0x40},
496 	{0xd016, 0x01, 0x00},
497 	{0xd044, 0xff, 0x40},
498 	{0xd045, 0x01, 0x00},
499 	{0xd008, 0xff, 0x0f},
500 	{0xd009, 0x03, 0x02},
501 	{0xd006, 0xff, 0x73},
502 	{0xd007, 0x03, 0x01},
503 	{0xd00c, 0xff, 0xfa},
504 	{0xd00d, 0x03, 0x01},
505 	{0xd00a, 0xff, 0xff},
506 	{0xd00b, 0x03, 0x01},
507 	{0x9bc7, 0xff, 0x23},
508 	{0x9bc8, 0xff, 0x55},
509 	{0x9bc3, 0xff, 0x01},
510 	{0x9bc4, 0xff, 0x02},
511 	{0x9bc5, 0xff, 0xfa},
512 	{0x9bc6, 0xff, 0x01},
513 	{0x9bba, 0xff, 0xff},
514 	{0x9bc9, 0xff, 0xff},
515 	{0x9bd3, 0xff, 0x95},
516 	{0xd011, 0xff, 0x70},
517 	{0xd012, 0x03, 0x01},
518 	{0xd013, 0xff, 0xfb},
519 	{0xd014, 0x03, 0x01},
520 	{0xd040, 0xff, 0x70},
521 	{0xd041, 0x03, 0x01},
522 	{0xd042, 0xff, 0xfb},
523 	{0xd043, 0x03, 0x01},
524 	{0xd045, 0x02, 0x00},
525 	{0x9bcf, 0x01, 0x01},
526 	{0xd045, 0x04, 0x04},
527 	{0xd04f, 0xff, 0x9a},
528 	{0xd050, 0x01, 0x01},
529 	{0xd051, 0xff, 0x5a},
530 	{0xd052, 0x01, 0x01},
531 	{0xd053, 0xff, 0x50},
532 	{0xd054, 0xff, 0x46},
533 	{0x9bd7, 0xff, 0x0a},
534 	{0x9bd8, 0xff, 0x14},
535 	{0x9bd9, 0xff, 0x08},
536 	{0x9bd0, 0xff, 0x93},
537 	{0x9be4, 0xff, 0xfe},
538 	{0x9bbd, 0xff, 0x63},
539 	{0x9be2, 0xff, 0xfe},
540 	{0x9bee, 0x01, 0x01},
541 };
542 
543 /*
544  * Quantek QT1010 tuner init
545  * AF9013_TUNER_QT1010        0x86
546  * AF9013_TUNER_QT1010A       0xa2
547  */
548 static const struct af9013_reg_mask_val tuner_init_tab_qt1010[] = {
549 	{0x9bd5, 0xff, 0x01},
550 	{0x9bd6, 0xff, 0x09},
551 	{0xd1a0, 0x02, 0x02},
552 	{0xd000, 0x01, 0x01},
553 	{0xd000, 0x02, 0x00},
554 	{0xd001, 0x02, 0x02},
555 	{0xd001, 0x01, 0x00},
556 	{0xd001, 0x20, 0x00},
557 	{0xd002, 0x1f, 0x19},
558 	{0xd003, 0x1f, 0x1a},
559 	{0xd004, 0x1f, 0x19},
560 	{0xd005, 0x1f, 0x1a},
561 	{0xd00e, 0x1f, 0x10},
562 	{0xd00f, 0x07, 0x04},
563 	{0xd00f, 0x38, 0x28},
564 	{0xd010, 0x07, 0x04},
565 	{0xd010, 0x38, 0x28},
566 	{0xd016, 0xf0, 0x30},
567 	{0xd01f, 0x3f, 0x0a},
568 	{0xd020, 0x3f, 0x0a},
569 	{0x9bda, 0xff, 0x01},
570 	{0x9be3, 0xff, 0x01},
571 	{0xd015, 0xff, 0x46},
572 	{0xd016, 0x01, 0x00},
573 	{0xd044, 0xff, 0x46},
574 	{0xd045, 0x01, 0x00},
575 	{0x9bbe, 0x01, 0x01},
576 	{0x9bcc, 0x01, 0x01},
577 	{0x9bb9, 0xff, 0x00},
578 	{0x9bcd, 0xff, 0x28},
579 	{0x9bff, 0xff, 0x20},
580 	{0xd008, 0xff, 0x0f},
581 	{0xd009, 0x03, 0x02},
582 	{0xd006, 0xff, 0x99},
583 	{0xd007, 0x03, 0x01},
584 	{0xd00c, 0xff, 0x0f},
585 	{0xd00d, 0x03, 0x02},
586 	{0xd00a, 0xff, 0x50},
587 	{0xd00b, 0x03, 0x01},
588 	{0x9bc7, 0xff, 0x00},
589 	{0x9bc8, 0xff, 0x00},
590 	{0x9bc3, 0xff, 0x0f},
591 	{0x9bc4, 0xff, 0x02},
592 	{0x9bc5, 0xff, 0x0f},
593 	{0x9bc6, 0xff, 0x02},
594 	{0x9bba, 0xff, 0xc5},
595 	{0x9bc9, 0xff, 0xff},
596 	{0xd011, 0xff, 0x58},
597 	{0xd012, 0x03, 0x02},
598 	{0xd013, 0xff, 0x89},
599 	{0xd014, 0x03, 0x01},
600 	{0xd040, 0xff, 0x58},
601 	{0xd041, 0x03, 0x02},
602 	{0xd042, 0xff, 0x89},
603 	{0xd043, 0x03, 0x01},
604 	{0xd045, 0x02, 0x00},
605 	{0x9bcf, 0x01, 0x01},
606 	{0xd045, 0x04, 0x04},
607 	{0xd04f, 0xff, 0x9a},
608 	{0xd050, 0x01, 0x01},
609 	{0xd051, 0xff, 0x5a},
610 	{0xd052, 0x01, 0x01},
611 	{0xd053, 0xff, 0x50},
612 	{0xd054, 0xff, 0x46},
613 	{0x9bd7, 0xff, 0x0a},
614 	{0x9bd8, 0xff, 0x14},
615 	{0x9bd9, 0xff, 0x08},
616 	{0x9bd0, 0xff, 0xcd},
617 	{0x9be4, 0xff, 0xbb},
618 	{0x9bbd, 0xff, 0x93},
619 	{0x9be2, 0xff, 0x80},
620 	{0x9bee, 0x01, 0x01},
621 };
622 
623 /*
624  * Freescale MC44S803 tuner init
625  * AF9013_TUNER_MC44S803      0x85
626  */
627 static const struct af9013_reg_mask_val tuner_init_tab_mc44s803[] = {
628 	{0x9bd5, 0xff, 0x01},
629 	{0x9bd6, 0xff, 0x06},
630 	{0xd1a0, 0x02, 0x02},
631 	{0xd000, 0x01, 0x01},
632 	{0xd000, 0x02, 0x00},
633 	{0xd001, 0x02, 0x02},
634 	{0xd001, 0x01, 0x00},
635 	{0xd001, 0x20, 0x00},
636 	{0xd002, 0x1f, 0x19},
637 	{0xd003, 0x1f, 0x1a},
638 	{0xd004, 0x1f, 0x19},
639 	{0xd005, 0x1f, 0x1a},
640 	{0xd00e, 0x1f, 0x10},
641 	{0xd00f, 0x07, 0x04},
642 	{0xd00f, 0x38, 0x28},
643 	{0xd010, 0x07, 0x04},
644 	{0xd010, 0x38, 0x28},
645 	{0xd016, 0xf0, 0x30},
646 	{0xd01f, 0x3f, 0x0a},
647 	{0xd020, 0x3f, 0x0a},
648 	{0x9bda, 0xff, 0x00},
649 	{0x9be3, 0xff, 0x00},
650 	{0x9bf6, 0xff, 0x01},
651 	{0x9bf8, 0xff, 0x02},
652 	{0x9bf9, 0xff, 0x02},
653 	{0x9bfc, 0xff, 0x1f},
654 	{0x9bbe, 0x01, 0x01},
655 	{0x9bcc, 0x01, 0x01},
656 	{0x9bb9, 0xff, 0x00},
657 	{0x9bcd, 0xff, 0x24},
658 	{0x9bff, 0xff, 0x24},
659 	{0xd015, 0xff, 0x46},
660 	{0xd016, 0x01, 0x00},
661 	{0xd044, 0xff, 0x46},
662 	{0xd045, 0x01, 0x00},
663 	{0xd008, 0xff, 0x01},
664 	{0xd009, 0x03, 0x02},
665 	{0xd006, 0xff, 0x7b},
666 	{0xd007, 0x03, 0x00},
667 	{0xd00c, 0xff, 0x7c},
668 	{0xd00d, 0x03, 0x02},
669 	{0xd00a, 0xff, 0xfe},
670 	{0xd00b, 0x03, 0x01},
671 	{0x9bc7, 0xff, 0x08},
672 	{0x9bc8, 0xff, 0x9a},
673 	{0x9bc3, 0xff, 0x01},
674 	{0x9bc4, 0xff, 0x02},
675 	{0x9bc5, 0xff, 0x7c},
676 	{0x9bc6, 0xff, 0x02},
677 	{0x9bba, 0xff, 0xfc},
678 	{0x9bc9, 0xff, 0xaa},
679 	{0xd011, 0xff, 0x6b},
680 	{0xd012, 0x03, 0x00},
681 	{0xd013, 0xff, 0x88},
682 	{0xd014, 0x03, 0x02},
683 	{0xd040, 0xff, 0x6b},
684 	{0xd041, 0x03, 0x00},
685 	{0xd042, 0xff, 0x7c},
686 	{0xd043, 0x03, 0x02},
687 	{0xd045, 0x02, 0x00},
688 	{0x9bcf, 0x01, 0x01},
689 	{0xd045, 0x04, 0x04},
690 	{0xd04f, 0xff, 0x9a},
691 	{0xd050, 0x01, 0x01},
692 	{0xd051, 0xff, 0x5a},
693 	{0xd052, 0x01, 0x01},
694 	{0xd053, 0xff, 0x50},
695 	{0xd054, 0xff, 0x46},
696 	{0x9bd7, 0xff, 0x0a},
697 	{0x9bd8, 0xff, 0x14},
698 	{0x9bd9, 0xff, 0x08},
699 	{0x9bd0, 0xff, 0x9e},
700 	{0x9be4, 0xff, 0xff},
701 	{0x9bbd, 0xff, 0x9e},
702 	{0x9be2, 0xff, 0x25},
703 	{0x9bee, 0x01, 0x01},
704 	{0xd73b, 0x08, 0x00},
705 };
706 
707 /*
708  * Unknown, probably for tin can tuner, tuner init
709  * AF9013_TUNER_UNKNOWN       0x8c
710  */
711 static const struct af9013_reg_mask_val tuner_init_tab_unknown[] = {
712 	{0x9bd5, 0xff, 0x01},
713 	{0x9bd6, 0xff, 0x02},
714 	{0xd1a0, 0x02, 0x02},
715 	{0xd000, 0x01, 0x01},
716 	{0xd000, 0x02, 0x00},
717 	{0xd001, 0x02, 0x02},
718 	{0xd001, 0x01, 0x00},
719 	{0xd001, 0x20, 0x00},
720 	{0xd002, 0x1f, 0x19},
721 	{0xd003, 0x1f, 0x1a},
722 	{0xd004, 0x1f, 0x19},
723 	{0xd005, 0x1f, 0x1a},
724 	{0xd00e, 0x1f, 0x10},
725 	{0xd00f, 0x07, 0x04},
726 	{0xd00f, 0x38, 0x28},
727 	{0xd010, 0x07, 0x04},
728 	{0xd010, 0x38, 0x28},
729 	{0xd016, 0xf0, 0x30},
730 	{0xd01f, 0x3f, 0x0a},
731 	{0xd020, 0x3f, 0x0a},
732 	{0x9bda, 0xff, 0x01},
733 	{0x9be3, 0xff, 0x01},
734 	{0xd1a0, 0x02, 0x00},
735 	{0x9bbe, 0x01, 0x01},
736 	{0x9bcc, 0x01, 0x01},
737 	{0x9bb9, 0xff, 0x00},
738 	{0x9bcd, 0xff, 0x18},
739 	{0x9bff, 0xff, 0x2c},
740 	{0xd015, 0xff, 0x46},
741 	{0xd016, 0x01, 0x00},
742 	{0xd044, 0xff, 0x46},
743 	{0xd045, 0x01, 0x00},
744 	{0xd008, 0xff, 0xdf},
745 	{0xd009, 0x03, 0x02},
746 	{0xd006, 0xff, 0x44},
747 	{0xd007, 0x03, 0x01},
748 	{0xd00c, 0xff, 0x00},
749 	{0xd00d, 0x03, 0x02},
750 	{0xd00a, 0xff, 0xf6},
751 	{0xd00b, 0x03, 0x01},
752 	{0x9bba, 0xff, 0xf9},
753 	{0x9bc8, 0xff, 0xaa},
754 	{0x9bc3, 0xff, 0xdf},
755 	{0x9bc4, 0xff, 0x02},
756 	{0x9bc5, 0xff, 0x00},
757 	{0x9bc6, 0xff, 0x02},
758 	{0x9bc9, 0xff, 0xf0},
759 	{0xd011, 0xff, 0x3c},
760 	{0xd012, 0x03, 0x01},
761 	{0xd013, 0xff, 0xf7},
762 	{0xd014, 0x03, 0x02},
763 	{0xd040, 0xff, 0x0b},
764 	{0xd041, 0x03, 0x02},
765 	{0xd042, 0xff, 0x4d},
766 	{0xd043, 0x03, 0x00},
767 	{0xd045, 0x02, 0x00},
768 	{0x9bcf, 0x01, 0x01},
769 	{0xd045, 0x04, 0x04},
770 	{0xd04f, 0xff, 0x9a},
771 	{0xd050, 0x01, 0x01},
772 	{0xd051, 0xff, 0x5a},
773 	{0xd052, 0x01, 0x01},
774 	{0xd053, 0xff, 0x50},
775 	{0xd054, 0xff, 0x46},
776 	{0x9bd7, 0xff, 0x0a},
777 	{0x9bd8, 0xff, 0x14},
778 	{0x9bd9, 0xff, 0x08},
779 };
780 
781 /*
782  * NXP TDA18271 & TDA18218 tuner init
783  * AF9013_TUNER_TDA18271      0x9c
784  * AF9013_TUNER_TDA18218      0xb3
785  */
786 static const struct af9013_reg_mask_val tuner_init_tab_tda18271[] = {
787 	{0x9bd5, 0xff, 0x01},
788 	{0x9bd6, 0xff, 0x04},
789 	{0xd1a0, 0x02, 0x02},
790 	{0xd000, 0x01, 0x01},
791 	{0xd000, 0x02, 0x00},
792 	{0xd001, 0x02, 0x02},
793 	{0xd001, 0x01, 0x00},
794 	{0xd001, 0x20, 0x00},
795 	{0xd002, 0x1f, 0x19},
796 	{0xd003, 0x1f, 0x1a},
797 	{0xd004, 0x1f, 0x19},
798 	{0xd005, 0x1f, 0x1a},
799 	{0xd00e, 0x1f, 0x10},
800 	{0xd00f, 0x07, 0x04},
801 	{0xd00f, 0x38, 0x28},
802 	{0xd010, 0x07, 0x04},
803 	{0xd010, 0x38, 0x28},
804 	{0xd016, 0xf0, 0x30},
805 	{0xd01f, 0x3f, 0x0a},
806 	{0xd020, 0x3f, 0x0a},
807 	{0x9bda, 0xff, 0x01},
808 	{0x9be3, 0xff, 0x01},
809 	{0xd1a0, 0x02, 0x00},
810 	{0x9bbe, 0x01, 0x01},
811 	{0x9bcc, 0x01, 0x01},
812 	{0x9bb9, 0xff, 0x00},
813 	{0x9bcd, 0xff, 0x18},
814 	{0x9bff, 0xff, 0x2c},
815 	{0xd015, 0xff, 0x46},
816 	{0xd016, 0x01, 0x00},
817 	{0xd044, 0xff, 0x46},
818 	{0xd045, 0x01, 0x00},
819 	{0xd008, 0xff, 0xdf},
820 	{0xd009, 0x03, 0x02},
821 	{0xd006, 0xff, 0x44},
822 	{0xd007, 0x03, 0x01},
823 	{0xd00c, 0xff, 0x00},
824 	{0xd00d, 0x03, 0x02},
825 	{0xd00a, 0xff, 0xf6},
826 	{0xd00b, 0x03, 0x01},
827 	{0x9bba, 0xff, 0xf9},
828 	{0x9bc8, 0xff, 0xaa},
829 	{0x9bc3, 0xff, 0xdf},
830 	{0x9bc4, 0xff, 0x02},
831 	{0x9bc5, 0xff, 0x00},
832 	{0x9bc6, 0xff, 0x02},
833 	{0x9bc9, 0xff, 0xf0},
834 	{0xd011, 0xff, 0x3c},
835 	{0xd012, 0x03, 0x01},
836 	{0xd013, 0xff, 0xf7},
837 	{0xd014, 0x03, 0x02},
838 	{0xd040, 0xff, 0x0b},
839 	{0xd041, 0x03, 0x02},
840 	{0xd042, 0xff, 0x4d},
841 	{0xd043, 0x03, 0x00},
842 	{0xd045, 0x02, 0x00},
843 	{0x9bcf, 0x01, 0x01},
844 	{0xd045, 0x04, 0x04},
845 	{0xd04f, 0xff, 0x9a},
846 	{0xd050, 0x01, 0x01},
847 	{0xd051, 0xff, 0x5a},
848 	{0xd052, 0x01, 0x01},
849 	{0xd053, 0xff, 0x50},
850 	{0xd054, 0xff, 0x46},
851 	{0x9bd7, 0xff, 0x0a},
852 	{0x9bd8, 0xff, 0x14},
853 	{0x9bd9, 0xff, 0x08},
854 	{0x9bd0, 0xff, 0xa8},
855 	{0x9be4, 0xff, 0x7f},
856 	{0x9bbd, 0xff, 0xa8},
857 	{0x9be2, 0xff, 0x20},
858 	{0x9bee, 0x01, 0x01},
859 };
860 
861 #endif /* AF9013_PRIV_H */
862