blob: 7b853469bb3bcfa3374d5cfaefe0a1cd9b91517a [file] [log] [blame]
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001/*
2 * Afatech AF9033 demodulator driver
3 *
4 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "af9033_priv.h"
23
Mauro Carvalho Chehab37ebaf62013-11-02 05:11:47 -030024/* Max transfer size done by I2C transfer functions */
25#define MAX_XFER_SIZE 64
26
Antti Palosaari09611ca2014-08-31 02:18:34 -030027struct af9033_dev {
Antti Palosaarif5b00a72014-08-31 20:57:05 -030028 struct i2c_client *client;
Antti Palosaari4b64bb22012-03-30 08:21:25 -030029 struct dvb_frontend fe;
30 struct af9033_config cfg;
Antti Palosaari83f11612014-09-02 03:55:21 -030031 bool is_af9035;
32 bool is_it9135;
Antti Palosaari4b64bb22012-03-30 08:21:25 -030033
34 u32 bandwidth_hz;
35 bool ts_mode_parallel;
36 bool ts_mode_serial;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -030037
Antti Palosaari83f11612014-09-02 03:55:21 -030038 fe_status_t fe_status;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -030039 u32 ber;
40 u32 ucb;
Antti Palosaari204f4312014-09-02 08:01:10 -030041 u64 error_block_count;
42 u64 total_block_count;
Antti Palosaari83f11612014-09-02 03:55:21 -030043 struct delayed_work stat_work;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -030044 unsigned long last_stat_check;
Antti Palosaari4b64bb22012-03-30 08:21:25 -030045};
46
47/* write multiple registers */
Antti Palosaari09611ca2014-08-31 02:18:34 -030048static int af9033_wr_regs(struct af9033_dev *dev, u32 reg, const u8 *val,
Antti Palosaari4b64bb22012-03-30 08:21:25 -030049 int len)
50{
51 int ret;
Mauro Carvalho Chehab37ebaf62013-11-02 05:11:47 -030052 u8 buf[MAX_XFER_SIZE];
Antti Palosaari4b64bb22012-03-30 08:21:25 -030053 struct i2c_msg msg[1] = {
54 {
Antti Palosaarif5b00a72014-08-31 20:57:05 -030055 .addr = dev->client->addr,
Antti Palosaari4b64bb22012-03-30 08:21:25 -030056 .flags = 0,
Mauro Carvalho Chehab37ebaf62013-11-02 05:11:47 -030057 .len = 3 + len,
Antti Palosaari4b64bb22012-03-30 08:21:25 -030058 .buf = buf,
59 }
60 };
61
Mauro Carvalho Chehab37ebaf62013-11-02 05:11:47 -030062 if (3 + len > sizeof(buf)) {
Antti Palosaarif5b00a72014-08-31 20:57:05 -030063 dev_warn(&dev->client->dev,
Antti Palosaari6a087f12014-08-31 21:08:09 -030064 "i2c wr reg=%04x: len=%d is too big!\n",
65 reg, len);
Mauro Carvalho Chehab37ebaf62013-11-02 05:11:47 -030066 return -EINVAL;
67 }
68
Antti Palosaari4b64bb22012-03-30 08:21:25 -030069 buf[0] = (reg >> 16) & 0xff;
70 buf[1] = (reg >> 8) & 0xff;
71 buf[2] = (reg >> 0) & 0xff;
72 memcpy(&buf[3], val, len);
73
Antti Palosaarif5b00a72014-08-31 20:57:05 -030074 ret = i2c_transfer(dev->client->adapter, msg, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -030075 if (ret == 1) {
76 ret = 0;
77 } else {
Antti Palosaari6a087f12014-08-31 21:08:09 -030078 dev_warn(&dev->client->dev, "i2c wr failed=%d reg=%06x len=%d\n",
79 ret, reg, len);
Antti Palosaari4b64bb22012-03-30 08:21:25 -030080 ret = -EREMOTEIO;
81 }
82
83 return ret;
84}
85
86/* read multiple registers */
Antti Palosaari09611ca2014-08-31 02:18:34 -030087static int af9033_rd_regs(struct af9033_dev *dev, u32 reg, u8 *val, int len)
Antti Palosaari4b64bb22012-03-30 08:21:25 -030088{
89 int ret;
90 u8 buf[3] = { (reg >> 16) & 0xff, (reg >> 8) & 0xff,
91 (reg >> 0) & 0xff };
92 struct i2c_msg msg[2] = {
93 {
Antti Palosaarif5b00a72014-08-31 20:57:05 -030094 .addr = dev->client->addr,
Antti Palosaari4b64bb22012-03-30 08:21:25 -030095 .flags = 0,
96 .len = sizeof(buf),
97 .buf = buf
98 }, {
Antti Palosaarif5b00a72014-08-31 20:57:05 -030099 .addr = dev->client->addr,
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300100 .flags = I2C_M_RD,
101 .len = len,
102 .buf = val
103 }
104 };
105
Antti Palosaarif5b00a72014-08-31 20:57:05 -0300106 ret = i2c_transfer(dev->client->adapter, msg, 2);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300107 if (ret == 2) {
108 ret = 0;
109 } else {
Antti Palosaari6a087f12014-08-31 21:08:09 -0300110 dev_warn(&dev->client->dev, "i2c rd failed=%d reg=%06x len=%d\n",
111 ret, reg, len);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300112 ret = -EREMOTEIO;
113 }
114
115 return ret;
116}
117
118
119/* write single register */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300120static int af9033_wr_reg(struct af9033_dev *dev, u32 reg, u8 val)
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300121{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300122 return af9033_wr_regs(dev, reg, &val, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300123}
124
125/* read single register */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300126static int af9033_rd_reg(struct af9033_dev *dev, u32 reg, u8 *val)
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300127{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300128 return af9033_rd_regs(dev, reg, val, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300129}
130
131/* write single register with mask */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300132static int af9033_wr_reg_mask(struct af9033_dev *dev, u32 reg, u8 val,
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300133 u8 mask)
134{
135 int ret;
136 u8 tmp;
137
138 /* no need for read if whole reg is written */
139 if (mask != 0xff) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300140 ret = af9033_rd_regs(dev, reg, &tmp, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300141 if (ret)
142 return ret;
143
144 val &= mask;
145 tmp &= ~mask;
146 val |= tmp;
147 }
148
Antti Palosaari09611ca2014-08-31 02:18:34 -0300149 return af9033_wr_regs(dev, reg, &val, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300150}
151
152/* read single register with mask */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300153static int af9033_rd_reg_mask(struct af9033_dev *dev, u32 reg, u8 *val,
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300154 u8 mask)
155{
156 int ret, i;
157 u8 tmp;
158
Antti Palosaari09611ca2014-08-31 02:18:34 -0300159 ret = af9033_rd_regs(dev, reg, &tmp, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300160 if (ret)
161 return ret;
162
163 tmp &= mask;
164
165 /* find position of the first bit */
166 for (i = 0; i < 8; i++) {
167 if ((mask >> i) & 0x01)
168 break;
169 }
170 *val = tmp >> i;
171
172 return 0;
173}
174
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300175/* write reg val table using reg addr auto increment */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300176static int af9033_wr_reg_val_tab(struct af9033_dev *dev,
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300177 const struct reg_val *tab, int tab_len)
178{
Antti Palosaarid18a88b2013-11-27 17:17:43 -0300179#define MAX_TAB_LEN 212
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300180 int ret, i, j;
Antti Palosaarid18a88b2013-11-27 17:17:43 -0300181 u8 buf[1 + MAX_TAB_LEN];
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300182
Antti Palosaari6a087f12014-08-31 21:08:09 -0300183 dev_dbg(&dev->client->dev, "tab_len=%d\n", tab_len);
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300184
Antti Palosaarid18a88b2013-11-27 17:17:43 -0300185 if (tab_len > sizeof(buf)) {
Antti Palosaari6a087f12014-08-31 21:08:09 -0300186 dev_warn(&dev->client->dev, "tab len %d is too big\n", tab_len);
Antti Palosaarid18a88b2013-11-27 17:17:43 -0300187 return -EINVAL;
188 }
189
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300190 for (i = 0, j = 0; i < tab_len; i++) {
191 buf[j] = tab[i].val;
192
193 if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300194 ret = af9033_wr_regs(dev, tab[i].reg - j, buf, j + 1);
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300195 if (ret < 0)
196 goto err;
197
198 j = 0;
199 } else {
200 j++;
201 }
202 }
203
204 return 0;
205
206err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300207 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300208
209 return ret;
210}
211
Antti Palosaari09611ca2014-08-31 02:18:34 -0300212static u32 af9033_div(struct af9033_dev *dev, u32 a, u32 b, u32 x)
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300213{
214 u32 r = 0, c = 0, i;
215
Antti Palosaari6a087f12014-08-31 21:08:09 -0300216 dev_dbg(&dev->client->dev, "a=%d b=%d x=%d\n", a, b, x);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300217
218 if (a > b) {
219 c = a / b;
220 a = a - c * b;
221 }
222
223 for (i = 0; i < x; i++) {
224 if (a >= b) {
225 r += 1;
226 a -= b;
227 }
228 a <<= 1;
229 r <<= 1;
230 }
231 r = (c << (u32)x) + r;
232
Antti Palosaari6a087f12014-08-31 21:08:09 -0300233 dev_dbg(&dev->client->dev, "a=%d b=%d x=%d r=%d r=%x\n", a, b, x, r, r);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300234
235 return r;
236}
237
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300238static int af9033_init(struct dvb_frontend *fe)
239{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300240 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300241 int ret, i, len;
242 const struct reg_val *init;
243 u8 buf[4];
244 u32 adc_cw, clock_cw;
245 struct reg_val_mask tab[] = {
246 { 0x80fb24, 0x00, 0x08 },
247 { 0x80004c, 0x00, 0xff },
Antti Palosaari09611ca2014-08-31 02:18:34 -0300248 { 0x00f641, dev->cfg.tuner, 0xff },
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300249 { 0x80f5ca, 0x01, 0x01 },
250 { 0x80f715, 0x01, 0x01 },
251 { 0x00f41f, 0x04, 0x04 },
252 { 0x00f41a, 0x01, 0x01 },
253 { 0x80f731, 0x00, 0x01 },
254 { 0x00d91e, 0x00, 0x01 },
255 { 0x00d919, 0x00, 0x01 },
256 { 0x80f732, 0x00, 0x01 },
257 { 0x00d91f, 0x00, 0x01 },
258 { 0x00d91a, 0x00, 0x01 },
259 { 0x80f730, 0x00, 0x01 },
260 { 0x80f778, 0x00, 0xff },
261 { 0x80f73c, 0x01, 0x01 },
262 { 0x80f776, 0x00, 0x01 },
263 { 0x00d8fd, 0x01, 0xff },
264 { 0x00d830, 0x01, 0xff },
265 { 0x00d831, 0x00, 0xff },
266 { 0x00d832, 0x00, 0xff },
Antti Palosaari09611ca2014-08-31 02:18:34 -0300267 { 0x80f985, dev->ts_mode_serial, 0x01 },
268 { 0x80f986, dev->ts_mode_parallel, 0x01 },
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300269 { 0x00d827, 0x00, 0xff },
270 { 0x00d829, 0x00, 0xff },
Antti Palosaari09611ca2014-08-31 02:18:34 -0300271 { 0x800045, dev->cfg.adc_multiplier, 0xff },
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300272 };
273
274 /* program clock control */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300275 clock_cw = af9033_div(dev, dev->cfg.clock, 1000000ul, 19ul);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300276 buf[0] = (clock_cw >> 0) & 0xff;
277 buf[1] = (clock_cw >> 8) & 0xff;
278 buf[2] = (clock_cw >> 16) & 0xff;
279 buf[3] = (clock_cw >> 24) & 0xff;
280
Antti Palosaari6a087f12014-08-31 21:08:09 -0300281 dev_dbg(&dev->client->dev, "clock=%d clock_cw=%08x\n",
282 dev->cfg.clock, clock_cw);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300283
Antti Palosaari09611ca2014-08-31 02:18:34 -0300284 ret = af9033_wr_regs(dev, 0x800025, buf, 4);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300285 if (ret < 0)
286 goto err;
287
288 /* program ADC control */
289 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300290 if (clock_adc_lut[i].clock == dev->cfg.clock)
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300291 break;
292 }
293
Antti Palosaari09611ca2014-08-31 02:18:34 -0300294 adc_cw = af9033_div(dev, clock_adc_lut[i].adc, 1000000ul, 19ul);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300295 buf[0] = (adc_cw >> 0) & 0xff;
296 buf[1] = (adc_cw >> 8) & 0xff;
297 buf[2] = (adc_cw >> 16) & 0xff;
298
Antti Palosaari6a087f12014-08-31 21:08:09 -0300299 dev_dbg(&dev->client->dev, "adc=%d adc_cw=%06x\n",
300 clock_adc_lut[i].adc, adc_cw);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300301
Antti Palosaari09611ca2014-08-31 02:18:34 -0300302 ret = af9033_wr_regs(dev, 0x80f1cd, buf, 3);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300303 if (ret < 0)
304 goto err;
305
306 /* program register table */
307 for (i = 0; i < ARRAY_SIZE(tab); i++) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300308 ret = af9033_wr_reg_mask(dev, tab[i].reg, tab[i].val,
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300309 tab[i].mask);
310 if (ret < 0)
311 goto err;
312 }
313
Antti Palosaarica681fe2014-08-08 23:56:49 -0300314 /* clock output */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300315 if (dev->cfg.dyn0_clk) {
316 ret = af9033_wr_reg(dev, 0x80fba8, 0x00);
Antti Palosaari9dc0f3f2014-08-09 01:03:14 -0300317 if (ret < 0)
318 goto err;
319 }
320
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300321 /* settings for TS interface */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300322 if (dev->cfg.ts_mode == AF9033_TS_MODE_USB) {
323 ret = af9033_wr_reg_mask(dev, 0x80f9a5, 0x00, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300324 if (ret < 0)
325 goto err;
326
Antti Palosaari09611ca2014-08-31 02:18:34 -0300327 ret = af9033_wr_reg_mask(dev, 0x80f9b5, 0x01, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300328 if (ret < 0)
329 goto err;
330 } else {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300331 ret = af9033_wr_reg_mask(dev, 0x80f990, 0x00, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300332 if (ret < 0)
333 goto err;
334
Antti Palosaari09611ca2014-08-31 02:18:34 -0300335 ret = af9033_wr_reg_mask(dev, 0x80f9b5, 0x00, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300336 if (ret < 0)
337 goto err;
338 }
339
340 /* load OFSM settings */
Antti Palosaari6a087f12014-08-31 21:08:09 -0300341 dev_dbg(&dev->client->dev, "load ofsm settings\n");
Antti Palosaari09611ca2014-08-31 02:18:34 -0300342 switch (dev->cfg.tuner) {
Antti Palosaarife8eece2013-02-03 13:39:55 -0300343 case AF9033_TUNER_IT9135_38:
344 case AF9033_TUNER_IT9135_51:
345 case AF9033_TUNER_IT9135_52:
Antti Palosaari463c3992013-03-07 00:03:06 -0300346 len = ARRAY_SIZE(ofsm_init_it9135_v1);
347 init = ofsm_init_it9135_v1;
348 break;
Antti Palosaarife8eece2013-02-03 13:39:55 -0300349 case AF9033_TUNER_IT9135_60:
350 case AF9033_TUNER_IT9135_61:
351 case AF9033_TUNER_IT9135_62:
Antti Palosaari463c3992013-03-07 00:03:06 -0300352 len = ARRAY_SIZE(ofsm_init_it9135_v2);
353 init = ofsm_init_it9135_v2;
Antti Palosaarife8eece2013-02-03 13:39:55 -0300354 break;
355 default:
356 len = ARRAY_SIZE(ofsm_init);
357 init = ofsm_init;
358 break;
359 }
360
Antti Palosaari09611ca2014-08-31 02:18:34 -0300361 ret = af9033_wr_reg_val_tab(dev, init, len);
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300362 if (ret < 0)
363 goto err;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300364
365 /* load tuner specific settings */
Antti Palosaari6a087f12014-08-31 21:08:09 -0300366 dev_dbg(&dev->client->dev, "load tuner specific settings\n");
Antti Palosaari09611ca2014-08-31 02:18:34 -0300367 switch (dev->cfg.tuner) {
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300368 case AF9033_TUNER_TUA9001:
369 len = ARRAY_SIZE(tuner_init_tua9001);
370 init = tuner_init_tua9001;
371 break;
Michael Büschffc501f2012-04-02 12:18:36 -0300372 case AF9033_TUNER_FC0011:
373 len = ARRAY_SIZE(tuner_init_fc0011);
374 init = tuner_init_fc0011;
375 break;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300376 case AF9033_TUNER_MXL5007T:
377 len = ARRAY_SIZE(tuner_init_mxl5007t);
378 init = tuner_init_mxl5007t;
379 break;
Gianluca Gennarice1fe372012-04-02 17:25:14 -0300380 case AF9033_TUNER_TDA18218:
381 len = ARRAY_SIZE(tuner_init_tda18218);
382 init = tuner_init_tda18218;
383 break;
Oliver Schinagld67ceb32012-09-20 14:57:17 -0300384 case AF9033_TUNER_FC2580:
385 len = ARRAY_SIZE(tuner_init_fc2580);
386 init = tuner_init_fc2580;
387 break;
Antti Palosaarie713ad12012-12-02 18:47:00 -0300388 case AF9033_TUNER_FC0012:
389 len = ARRAY_SIZE(tuner_init_fc0012);
390 init = tuner_init_fc0012;
391 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300392 case AF9033_TUNER_IT9135_38:
Antti Palosaaria72cbb72013-03-07 21:17:55 -0300393 len = ARRAY_SIZE(tuner_init_it9135_38);
394 init = tuner_init_it9135_38;
395 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300396 case AF9033_TUNER_IT9135_51:
Antti Palosaaribb2e12a2013-03-07 21:25:16 -0300397 len = ARRAY_SIZE(tuner_init_it9135_51);
398 init = tuner_init_it9135_51;
399 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300400 case AF9033_TUNER_IT9135_52:
Antti Palosaari22d729f2013-03-07 21:29:05 -0300401 len = ARRAY_SIZE(tuner_init_it9135_52);
402 init = tuner_init_it9135_52;
403 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300404 case AF9033_TUNER_IT9135_60:
Antti Palosaaria49f53a2013-03-07 21:38:00 -0300405 len = ARRAY_SIZE(tuner_init_it9135_60);
406 init = tuner_init_it9135_60;
407 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300408 case AF9033_TUNER_IT9135_61:
Antti Palosaari85211322013-03-07 21:44:30 -0300409 len = ARRAY_SIZE(tuner_init_it9135_61);
410 init = tuner_init_it9135_61;
411 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300412 case AF9033_TUNER_IT9135_62:
Antti Palosaaridc4a2c42013-03-07 21:47:20 -0300413 len = ARRAY_SIZE(tuner_init_it9135_62);
414 init = tuner_init_it9135_62;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300415 break;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300416 default:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300417 dev_dbg(&dev->client->dev, "unsupported tuner ID=%d\n",
418 dev->cfg.tuner);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300419 ret = -ENODEV;
420 goto err;
421 }
422
Antti Palosaari09611ca2014-08-31 02:18:34 -0300423 ret = af9033_wr_reg_val_tab(dev, init, len);
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300424 if (ret < 0)
425 goto err;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300426
Antti Palosaari09611ca2014-08-31 02:18:34 -0300427 if (dev->cfg.ts_mode == AF9033_TS_MODE_SERIAL) {
428 ret = af9033_wr_reg_mask(dev, 0x00d91c, 0x01, 0x01);
Jose Alberto Reguero98059922012-09-23 16:48:47 -0300429 if (ret < 0)
430 goto err;
Antti Palosaaribf97b632012-12-08 22:51:19 -0300431
Antti Palosaari09611ca2014-08-31 02:18:34 -0300432 ret = af9033_wr_reg_mask(dev, 0x00d917, 0x00, 0x01);
Jose Alberto Reguero98059922012-09-23 16:48:47 -0300433 if (ret < 0)
434 goto err;
Antti Palosaaribf97b632012-12-08 22:51:19 -0300435
Antti Palosaari09611ca2014-08-31 02:18:34 -0300436 ret = af9033_wr_reg_mask(dev, 0x00d916, 0x00, 0x01);
Jose Alberto Reguero98059922012-09-23 16:48:47 -0300437 if (ret < 0)
438 goto err;
439 }
440
Antti Palosaari09611ca2014-08-31 02:18:34 -0300441 switch (dev->cfg.tuner) {
Antti Palosaari086991d2013-03-07 22:18:56 -0300442 case AF9033_TUNER_IT9135_60:
443 case AF9033_TUNER_IT9135_61:
444 case AF9033_TUNER_IT9135_62:
Antti Palosaari09611ca2014-08-31 02:18:34 -0300445 ret = af9033_wr_reg(dev, 0x800000, 0x01);
Antti Palosaari086991d2013-03-07 22:18:56 -0300446 if (ret < 0)
447 goto err;
448 }
449
Antti Palosaari09611ca2014-08-31 02:18:34 -0300450 dev->bandwidth_hz = 0; /* force to program all parameters */
Antti Palosaari83f11612014-09-02 03:55:21 -0300451 /* start statistics polling */
452 schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300453
454 return 0;
455
456err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300457 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300458
459 return ret;
460}
461
462static int af9033_sleep(struct dvb_frontend *fe)
463{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300464 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300465 int ret, i;
466 u8 tmp;
467
Antti Palosaari83f11612014-09-02 03:55:21 -0300468 /* stop statistics polling */
469 cancel_delayed_work_sync(&dev->stat_work);
470
Antti Palosaari09611ca2014-08-31 02:18:34 -0300471 ret = af9033_wr_reg(dev, 0x80004c, 1);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300472 if (ret < 0)
473 goto err;
474
Antti Palosaari09611ca2014-08-31 02:18:34 -0300475 ret = af9033_wr_reg(dev, 0x800000, 0);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300476 if (ret < 0)
477 goto err;
478
479 for (i = 100, tmp = 1; i && tmp; i--) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300480 ret = af9033_rd_reg(dev, 0x80004c, &tmp);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300481 if (ret < 0)
482 goto err;
483
484 usleep_range(200, 10000);
485 }
486
Antti Palosaari6a087f12014-08-31 21:08:09 -0300487 dev_dbg(&dev->client->dev, "loop=%d\n", i);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300488
489 if (i == 0) {
490 ret = -ETIMEDOUT;
491 goto err;
492 }
493
Antti Palosaari09611ca2014-08-31 02:18:34 -0300494 ret = af9033_wr_reg_mask(dev, 0x80fb24, 0x08, 0x08);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300495 if (ret < 0)
496 goto err;
497
498 /* prevent current leak (?) */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300499 if (dev->cfg.ts_mode == AF9033_TS_MODE_SERIAL) {
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300500 /* enable parallel TS */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300501 ret = af9033_wr_reg_mask(dev, 0x00d917, 0x00, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300502 if (ret < 0)
503 goto err;
504
Antti Palosaari09611ca2014-08-31 02:18:34 -0300505 ret = af9033_wr_reg_mask(dev, 0x00d916, 0x01, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300506 if (ret < 0)
507 goto err;
508 }
509
510 return 0;
511
512err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300513 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300514
515 return ret;
516}
517
518static int af9033_get_tune_settings(struct dvb_frontend *fe,
519 struct dvb_frontend_tune_settings *fesettings)
520{
Antti Palosaarife8eece2013-02-03 13:39:55 -0300521 /* 800 => 2000 because IT9135 v2 is slow to gain lock */
522 fesettings->min_delay_ms = 2000;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300523 fesettings->step_size = 0;
524 fesettings->max_drift = 0;
525
526 return 0;
527}
528
529static int af9033_set_frontend(struct dvb_frontend *fe)
530{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300531 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300532 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300533 int ret, i, spec_inv, sampling_freq;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300534 u8 tmp, buf[3], bandwidth_reg_val;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300535 u32 if_frequency, freq_cw, adc_freq;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300536
Antti Palosaari6a087f12014-08-31 21:08:09 -0300537 dev_dbg(&dev->client->dev, "frequency=%d bandwidth_hz=%d\n",
538 c->frequency, c->bandwidth_hz);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300539
540 /* check bandwidth */
541 switch (c->bandwidth_hz) {
542 case 6000000:
543 bandwidth_reg_val = 0x00;
544 break;
545 case 7000000:
546 bandwidth_reg_val = 0x01;
547 break;
548 case 8000000:
549 bandwidth_reg_val = 0x02;
550 break;
551 default:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300552 dev_dbg(&dev->client->dev, "invalid bandwidth_hz\n");
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300553 ret = -EINVAL;
554 goto err;
555 }
556
557 /* program tuner */
558 if (fe->ops.tuner_ops.set_params)
559 fe->ops.tuner_ops.set_params(fe);
560
561 /* program CFOE coefficients */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300562 if (c->bandwidth_hz != dev->bandwidth_hz) {
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300563 for (i = 0; i < ARRAY_SIZE(coeff_lut); i++) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300564 if (coeff_lut[i].clock == dev->cfg.clock &&
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300565 coeff_lut[i].bandwidth_hz == c->bandwidth_hz) {
566 break;
567 }
568 }
Antti Palosaari09611ca2014-08-31 02:18:34 -0300569 ret = af9033_wr_regs(dev, 0x800001,
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300570 coeff_lut[i].val, sizeof(coeff_lut[i].val));
571 }
572
573 /* program frequency control */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300574 if (c->bandwidth_hz != dev->bandwidth_hz) {
575 spec_inv = dev->cfg.spec_inv ? -1 : 1;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300576
577 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300578 if (clock_adc_lut[i].clock == dev->cfg.clock)
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300579 break;
580 }
581 adc_freq = clock_adc_lut[i].adc;
582
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300583 /* get used IF frequency */
584 if (fe->ops.tuner_ops.get_if_frequency)
585 fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
586 else
587 if_frequency = 0;
588
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300589 sampling_freq = if_frequency;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300590
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300591 while (sampling_freq > (adc_freq / 2))
592 sampling_freq -= adc_freq;
593
594 if (sampling_freq >= 0)
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300595 spec_inv *= -1;
596 else
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300597 sampling_freq *= -1;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300598
Antti Palosaari09611ca2014-08-31 02:18:34 -0300599 freq_cw = af9033_div(dev, sampling_freq, adc_freq, 23ul);
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300600
601 if (spec_inv == -1)
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300602 freq_cw = 0x800000 - freq_cw;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300603
Antti Palosaari09611ca2014-08-31 02:18:34 -0300604 if (dev->cfg.adc_multiplier == AF9033_ADC_MULTIPLIER_2X)
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300605 freq_cw /= 2;
606
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300607 buf[0] = (freq_cw >> 0) & 0xff;
608 buf[1] = (freq_cw >> 8) & 0xff;
609 buf[2] = (freq_cw >> 16) & 0x7f;
Antti Palosaarife8eece2013-02-03 13:39:55 -0300610
611 /* FIXME: there seems to be calculation error here... */
612 if (if_frequency == 0)
613 buf[2] = 0;
614
Antti Palosaari09611ca2014-08-31 02:18:34 -0300615 ret = af9033_wr_regs(dev, 0x800029, buf, 3);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300616 if (ret < 0)
617 goto err;
618
Antti Palosaari09611ca2014-08-31 02:18:34 -0300619 dev->bandwidth_hz = c->bandwidth_hz;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300620 }
621
Antti Palosaari09611ca2014-08-31 02:18:34 -0300622 ret = af9033_wr_reg_mask(dev, 0x80f904, bandwidth_reg_val, 0x03);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300623 if (ret < 0)
624 goto err;
625
Antti Palosaari09611ca2014-08-31 02:18:34 -0300626 ret = af9033_wr_reg(dev, 0x800040, 0x00);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300627 if (ret < 0)
628 goto err;
629
Antti Palosaari09611ca2014-08-31 02:18:34 -0300630 ret = af9033_wr_reg(dev, 0x800047, 0x00);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300631 if (ret < 0)
632 goto err;
633
Antti Palosaari09611ca2014-08-31 02:18:34 -0300634 ret = af9033_wr_reg_mask(dev, 0x80f999, 0x00, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300635 if (ret < 0)
636 goto err;
637
638 if (c->frequency <= 230000000)
639 tmp = 0x00; /* VHF */
640 else
641 tmp = 0x01; /* UHF */
642
Antti Palosaari09611ca2014-08-31 02:18:34 -0300643 ret = af9033_wr_reg(dev, 0x80004b, tmp);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300644 if (ret < 0)
645 goto err;
646
Antti Palosaari09611ca2014-08-31 02:18:34 -0300647 ret = af9033_wr_reg(dev, 0x800000, 0x00);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300648 if (ret < 0)
649 goto err;
650
651 return 0;
652
653err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300654 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300655
656 return ret;
657}
658
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300659static int af9033_get_frontend(struct dvb_frontend *fe)
660{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300661 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300662 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300663 int ret;
664 u8 buf[8];
665
Antti Palosaari6a087f12014-08-31 21:08:09 -0300666 dev_dbg(&dev->client->dev, "\n");
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300667
668 /* read all needed registers */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300669 ret = af9033_rd_regs(dev, 0x80f900, buf, sizeof(buf));
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300670 if (ret < 0)
671 goto err;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300672
673 switch ((buf[0] >> 0) & 3) {
674 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300675 c->transmission_mode = TRANSMISSION_MODE_2K;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300676 break;
677 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300678 c->transmission_mode = TRANSMISSION_MODE_8K;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300679 break;
680 }
681
682 switch ((buf[1] >> 0) & 3) {
683 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300684 c->guard_interval = GUARD_INTERVAL_1_32;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300685 break;
686 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300687 c->guard_interval = GUARD_INTERVAL_1_16;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300688 break;
689 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300690 c->guard_interval = GUARD_INTERVAL_1_8;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300691 break;
692 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300693 c->guard_interval = GUARD_INTERVAL_1_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300694 break;
695 }
696
697 switch ((buf[2] >> 0) & 7) {
698 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300699 c->hierarchy = HIERARCHY_NONE;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300700 break;
701 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300702 c->hierarchy = HIERARCHY_1;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300703 break;
704 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300705 c->hierarchy = HIERARCHY_2;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300706 break;
707 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300708 c->hierarchy = HIERARCHY_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300709 break;
710 }
711
712 switch ((buf[3] >> 0) & 3) {
713 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300714 c->modulation = QPSK;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300715 break;
716 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300717 c->modulation = QAM_16;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300718 break;
719 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300720 c->modulation = QAM_64;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300721 break;
722 }
723
724 switch ((buf[4] >> 0) & 3) {
725 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300726 c->bandwidth_hz = 6000000;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300727 break;
728 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300729 c->bandwidth_hz = 7000000;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300730 break;
731 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300732 c->bandwidth_hz = 8000000;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300733 break;
734 }
735
736 switch ((buf[6] >> 0) & 7) {
737 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300738 c->code_rate_HP = FEC_1_2;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300739 break;
740 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300741 c->code_rate_HP = FEC_2_3;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300742 break;
743 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300744 c->code_rate_HP = FEC_3_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300745 break;
746 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300747 c->code_rate_HP = FEC_5_6;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300748 break;
749 case 4:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300750 c->code_rate_HP = FEC_7_8;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300751 break;
752 case 5:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300753 c->code_rate_HP = FEC_NONE;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300754 break;
755 }
756
757 switch ((buf[7] >> 0) & 7) {
758 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300759 c->code_rate_LP = FEC_1_2;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300760 break;
761 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300762 c->code_rate_LP = FEC_2_3;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300763 break;
764 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300765 c->code_rate_LP = FEC_3_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300766 break;
767 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300768 c->code_rate_LP = FEC_5_6;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300769 break;
770 case 4:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300771 c->code_rate_LP = FEC_7_8;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300772 break;
773 case 5:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300774 c->code_rate_LP = FEC_NONE;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300775 break;
776 }
777
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300778 return 0;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300779
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300780err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300781 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300782
783 return ret;
784}
785
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300786static int af9033_read_status(struct dvb_frontend *fe, fe_status_t *status)
787{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300788 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300789 int ret;
790 u8 tmp;
791
792 *status = 0;
793
794 /* radio channel status, 0=no result, 1=has signal, 2=no signal */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300795 ret = af9033_rd_reg(dev, 0x800047, &tmp);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300796 if (ret < 0)
797 goto err;
798
799 /* has signal */
800 if (tmp == 0x01)
801 *status |= FE_HAS_SIGNAL;
802
803 if (tmp != 0x02) {
804 /* TPS lock */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300805 ret = af9033_rd_reg_mask(dev, 0x80f5a9, &tmp, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300806 if (ret < 0)
807 goto err;
808
809 if (tmp)
810 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
811 FE_HAS_VITERBI;
812
813 /* full lock */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300814 ret = af9033_rd_reg_mask(dev, 0x80f999, &tmp, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300815 if (ret < 0)
816 goto err;
817
818 if (tmp)
819 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
820 FE_HAS_VITERBI | FE_HAS_SYNC |
821 FE_HAS_LOCK;
822 }
823
Antti Palosaari83f11612014-09-02 03:55:21 -0300824 dev->fe_status = *status;
825
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300826 return 0;
827
828err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300829 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300830
831 return ret;
832}
833
834static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
835{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300836 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari6b457782014-09-02 05:03:21 -0300837 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
Antti Palosaarie898ef62012-04-01 12:50:02 -0300838
Antti Palosaari6b457782014-09-02 05:03:21 -0300839 /* use DVBv5 CNR */
840 if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
841 *snr = div_s64(c->cnr.stat[0].svalue, 100); /* 1000x => 10x */
842 else
843 *snr = 0;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300844
845 return 0;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300846}
847
848static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
849{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300850 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300851 int ret;
852 u8 strength2;
853
854 /* read signal strength of 0-100 scale */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300855 ret = af9033_rd_reg(dev, 0x800048, &strength2);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300856 if (ret < 0)
857 goto err;
858
859 /* scale value to 0x0000-0xffff */
860 *strength = strength2 * 0xffff / 100;
861
862 return 0;
863
864err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300865 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300866
867 return ret;
868}
869
Antti Palosaari09611ca2014-08-31 02:18:34 -0300870static int af9033_update_ch_stat(struct af9033_dev *dev)
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300871{
872 int ret = 0;
873 u32 err_cnt, bit_cnt;
874 u16 abort_cnt;
875 u8 buf[7];
876
877 /* only update data every half second */
Antti Palosaari09611ca2014-08-31 02:18:34 -0300878 if (time_after(jiffies, dev->last_stat_check + msecs_to_jiffies(500))) {
879 ret = af9033_rd_regs(dev, 0x800032, buf, sizeof(buf));
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300880 if (ret < 0)
881 goto err;
882 /* in 8 byte packets? */
883 abort_cnt = (buf[1] << 8) + buf[0];
884 /* in bits */
885 err_cnt = (buf[4] << 16) + (buf[3] << 8) + buf[2];
886 /* in 8 byte packets? always(?) 0x2710 = 10000 */
887 bit_cnt = (buf[6] << 8) + buf[5];
888
889 if (bit_cnt < abort_cnt) {
890 abort_cnt = 1000;
Antti Palosaari09611ca2014-08-31 02:18:34 -0300891 dev->ber = 0xffffffff;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300892 } else {
Antti Palosaari24e419a2014-08-09 14:59:53 -0300893 /*
894 * 8 byte packets, that have not been rejected already
895 */
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300896 bit_cnt -= (u32)abort_cnt;
897 if (bit_cnt == 0) {
Antti Palosaari09611ca2014-08-31 02:18:34 -0300898 dev->ber = 0xffffffff;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300899 } else {
900 err_cnt -= (u32)abort_cnt * 8 * 8;
901 bit_cnt *= 8 * 8;
Antti Palosaari09611ca2014-08-31 02:18:34 -0300902 dev->ber = err_cnt * (0xffffffff / bit_cnt);
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300903 }
904 }
Antti Palosaari09611ca2014-08-31 02:18:34 -0300905 dev->ucb += abort_cnt;
906 dev->last_stat_check = jiffies;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300907 }
908
909 return 0;
910err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300911 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300912
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300913 return ret;
914}
915
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300916static int af9033_read_ber(struct dvb_frontend *fe, u32 *ber)
917{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300918 struct af9033_dev *dev = fe->demodulator_priv;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300919 int ret;
920
Antti Palosaari09611ca2014-08-31 02:18:34 -0300921 ret = af9033_update_ch_stat(dev);
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300922 if (ret < 0)
923 return ret;
924
Antti Palosaari09611ca2014-08-31 02:18:34 -0300925 *ber = dev->ber;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300926
927 return 0;
928}
929
930static int af9033_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
931{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300932 struct af9033_dev *dev = fe->demodulator_priv;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300933 int ret;
934
Antti Palosaari09611ca2014-08-31 02:18:34 -0300935 ret = af9033_update_ch_stat(dev);
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300936 if (ret < 0)
937 return ret;
938
Antti Palosaari09611ca2014-08-31 02:18:34 -0300939 *ucblocks = dev->ucb;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300940
941 return 0;
942}
943
944static int af9033_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
945{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300946 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300947 int ret;
948
Antti Palosaari6a087f12014-08-31 21:08:09 -0300949 dev_dbg(&dev->client->dev, "enable=%d\n", enable);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300950
Antti Palosaari09611ca2014-08-31 02:18:34 -0300951 ret = af9033_wr_reg_mask(dev, 0x00fa04, enable, 0x01);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300952 if (ret < 0)
953 goto err;
954
955 return 0;
956
957err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300958 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300959
960 return ret;
961}
962
Mauro Carvalho Chehabed97a6f2014-03-14 14:29:06 -0300963static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
Antti Palosaari040cf862014-02-13 15:40:59 -0300964{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300965 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari040cf862014-02-13 15:40:59 -0300966 int ret;
967
Antti Palosaari6a087f12014-08-31 21:08:09 -0300968 dev_dbg(&dev->client->dev, "onoff=%d\n", onoff);
Antti Palosaari040cf862014-02-13 15:40:59 -0300969
Antti Palosaari09611ca2014-08-31 02:18:34 -0300970 ret = af9033_wr_reg_mask(dev, 0x80f993, onoff, 0x01);
Antti Palosaari040cf862014-02-13 15:40:59 -0300971 if (ret < 0)
972 goto err;
973
974 return 0;
975
976err:
Antti Palosaari6a087f12014-08-31 21:08:09 -0300977 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari040cf862014-02-13 15:40:59 -0300978
979 return ret;
980}
Antti Palosaari040cf862014-02-13 15:40:59 -0300981
Antti Palosaari24e419a2014-08-09 14:59:53 -0300982static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
983 int onoff)
Antti Palosaari040cf862014-02-13 15:40:59 -0300984{
Antti Palosaari09611ca2014-08-31 02:18:34 -0300985 struct af9033_dev *dev = fe->demodulator_priv;
Antti Palosaari040cf862014-02-13 15:40:59 -0300986 int ret;
987 u8 wbuf[2] = {(pid >> 0) & 0xff, (pid >> 8) & 0xff};
988
Antti Palosaari6a087f12014-08-31 21:08:09 -0300989 dev_dbg(&dev->client->dev, "index=%d pid=%04x onoff=%d\n",
990 index, pid, onoff);
Antti Palosaari040cf862014-02-13 15:40:59 -0300991
992 if (pid > 0x1fff)
993 return 0;
994
Antti Palosaari09611ca2014-08-31 02:18:34 -0300995 ret = af9033_wr_regs(dev, 0x80f996, wbuf, 2);
Antti Palosaari040cf862014-02-13 15:40:59 -0300996 if (ret < 0)
997 goto err;
998
Antti Palosaari09611ca2014-08-31 02:18:34 -0300999 ret = af9033_wr_reg(dev, 0x80f994, onoff);
Antti Palosaari040cf862014-02-13 15:40:59 -03001000 if (ret < 0)
1001 goto err;
1002
Antti Palosaari09611ca2014-08-31 02:18:34 -03001003 ret = af9033_wr_reg(dev, 0x80f995, index);
Antti Palosaari040cf862014-02-13 15:40:59 -03001004 if (ret < 0)
1005 goto err;
1006
1007 return 0;
1008
1009err:
Antti Palosaari6a087f12014-08-31 21:08:09 -03001010 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
Antti Palosaari040cf862014-02-13 15:40:59 -03001011
1012 return ret;
1013}
Antti Palosaari040cf862014-02-13 15:40:59 -03001014
Antti Palosaari83f11612014-09-02 03:55:21 -03001015static void af9033_stat_work(struct work_struct *work)
1016{
1017 struct af9033_dev *dev = container_of(work, struct af9033_dev, stat_work.work);
1018 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
Antti Palosaari3e413132014-09-02 04:24:41 -03001019 int ret, tmp, i, len;
Antti Palosaari204f4312014-09-02 08:01:10 -03001020 u8 u8tmp, buf[7];
Antti Palosaari83f11612014-09-02 03:55:21 -03001021
1022 dev_dbg(&dev->client->dev, "\n");
1023
Antti Palosaari3e413132014-09-02 04:24:41 -03001024 /* signal strength */
Antti Palosaari83f11612014-09-02 03:55:21 -03001025 if (dev->fe_status & FE_HAS_SIGNAL) {
1026 if (dev->is_af9035) {
1027 ret = af9033_rd_reg(dev, 0x80004a, &u8tmp);
1028 tmp = -u8tmp * 1000;
1029 } else {
1030 ret = af9033_rd_reg(dev, 0x8000f7, &u8tmp);
1031 tmp = (u8tmp - 100) * 1000;
1032 }
1033 if (ret)
1034 goto err;
1035
1036 c->strength.len = 1;
1037 c->strength.stat[0].scale = FE_SCALE_DECIBEL;
1038 c->strength.stat[0].svalue = tmp;
1039 } else {
1040 c->strength.len = 1;
1041 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1042 }
1043
Antti Palosaari3e413132014-09-02 04:24:41 -03001044 /* CNR */
1045 if (dev->fe_status & FE_HAS_VITERBI) {
1046 u32 snr_val;
1047 const struct val_snr *snr_lut;
1048
1049 /* read value */
1050 ret = af9033_rd_regs(dev, 0x80002c, buf, 3);
1051 if (ret)
1052 goto err;
1053
1054 snr_val = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0);
1055
1056 /* read current modulation */
1057 ret = af9033_rd_reg(dev, 0x80f903, &u8tmp);
1058 if (ret)
1059 goto err;
1060
1061 switch ((u8tmp >> 0) & 3) {
1062 case 0:
1063 len = ARRAY_SIZE(qpsk_snr_lut);
1064 snr_lut = qpsk_snr_lut;
1065 break;
1066 case 1:
1067 len = ARRAY_SIZE(qam16_snr_lut);
1068 snr_lut = qam16_snr_lut;
1069 break;
1070 case 2:
1071 len = ARRAY_SIZE(qam64_snr_lut);
1072 snr_lut = qam64_snr_lut;
1073 break;
1074 default:
1075 goto err_schedule_delayed_work;
1076 }
1077
1078 for (i = 0; i < len; i++) {
1079 tmp = snr_lut[i].snr * 1000;
1080 if (snr_val < snr_lut[i].val)
1081 break;
1082 }
1083
1084 c->cnr.len = 1;
1085 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
1086 c->cnr.stat[0].svalue = tmp;
1087 } else {
1088 c->cnr.len = 1;
1089 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1090 }
1091
Antti Palosaari204f4312014-09-02 08:01:10 -03001092 /* UCB/PER/BER */
1093 if (dev->fe_status & FE_HAS_LOCK) {
1094 /* outer FEC, 204 byte packets */
1095 u16 abort_packet_count, rsd_packet_count;
1096
1097 /*
1098 * Packet count used for measurement is 10000
1099 * (rsd_packet_count). Maybe it should be increased?
1100 */
1101
1102 ret = af9033_rd_regs(dev, 0x800032, buf, 7);
1103 if (ret)
1104 goto err;
1105
1106 abort_packet_count = (buf[1] << 8) | (buf[0] << 0);
1107 rsd_packet_count = (buf[6] << 8) | (buf[5] << 0);
1108
1109 dev->error_block_count += abort_packet_count;
1110 dev->total_block_count += rsd_packet_count;
1111
1112 c->block_count.len = 1;
1113 c->block_count.stat[0].scale = FE_SCALE_COUNTER;
1114 c->block_count.stat[0].uvalue = dev->total_block_count;
1115
1116 c->block_error.len = 1;
1117 c->block_error.stat[0].scale = FE_SCALE_COUNTER;
1118 c->block_error.stat[0].uvalue = dev->error_block_count;
1119 }
1120
Antti Palosaari3e413132014-09-02 04:24:41 -03001121err_schedule_delayed_work:
Antti Palosaari83f11612014-09-02 03:55:21 -03001122 schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
1123 return;
1124err:
1125 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
1126}
1127
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001128static struct dvb_frontend_ops af9033_ops = {
1129 .delsys = { SYS_DVBT },
1130 .info = {
1131 .name = "Afatech AF9033 (DVB-T)",
1132 .frequency_min = 174000000,
1133 .frequency_max = 862000000,
1134 .frequency_stepsize = 250000,
1135 .frequency_tolerance = 0,
1136 .caps = FE_CAN_FEC_1_2 |
1137 FE_CAN_FEC_2_3 |
1138 FE_CAN_FEC_3_4 |
1139 FE_CAN_FEC_5_6 |
1140 FE_CAN_FEC_7_8 |
1141 FE_CAN_FEC_AUTO |
1142 FE_CAN_QPSK |
1143 FE_CAN_QAM_16 |
1144 FE_CAN_QAM_64 |
1145 FE_CAN_QAM_AUTO |
1146 FE_CAN_TRANSMISSION_MODE_AUTO |
1147 FE_CAN_GUARD_INTERVAL_AUTO |
1148 FE_CAN_HIERARCHY_AUTO |
1149 FE_CAN_RECOVER |
1150 FE_CAN_MUTE_TS
1151 },
1152
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001153 .init = af9033_init,
1154 .sleep = af9033_sleep,
1155
1156 .get_tune_settings = af9033_get_tune_settings,
1157 .set_frontend = af9033_set_frontend,
Gianluca Gennari0a4df232012-04-05 12:47:19 -03001158 .get_frontend = af9033_get_frontend,
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001159
1160 .read_status = af9033_read_status,
1161 .read_snr = af9033_read_snr,
1162 .read_signal_strength = af9033_read_signal_strength,
1163 .read_ber = af9033_read_ber,
1164 .read_ucblocks = af9033_read_ucblocks,
1165
1166 .i2c_gate_ctrl = af9033_i2c_gate_ctrl,
1167};
1168
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001169static int af9033_probe(struct i2c_client *client,
1170 const struct i2c_device_id *id)
1171{
1172 struct af9033_config *cfg = client->dev.platform_data;
1173 struct af9033_dev *dev;
1174 int ret;
1175 u8 buf[8];
1176 u32 reg;
1177
1178 /* allocate memory for the internal state */
1179 dev = kzalloc(sizeof(struct af9033_dev), GFP_KERNEL);
1180 if (dev == NULL) {
1181 ret = -ENOMEM;
1182 dev_err(&client->dev, "Could not allocate memory for state\n");
1183 goto err;
1184 }
1185
1186 /* setup the state */
1187 dev->client = client;
Antti Palosaari83f11612014-09-02 03:55:21 -03001188 INIT_DELAYED_WORK(&dev->stat_work, af9033_stat_work);
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001189 memcpy(&dev->cfg, cfg, sizeof(struct af9033_config));
1190
1191 if (dev->cfg.clock != 12000000) {
1192 ret = -ENODEV;
1193 dev_err(&dev->client->dev,
Antti Palosaari6a087f12014-08-31 21:08:09 -03001194 "unsupported clock %d Hz, only 12000000 Hz is supported currently\n",
1195 dev->cfg.clock);
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001196 goto err_kfree;
1197 }
1198
1199 /* firmware version */
1200 switch (dev->cfg.tuner) {
1201 case AF9033_TUNER_IT9135_38:
1202 case AF9033_TUNER_IT9135_51:
1203 case AF9033_TUNER_IT9135_52:
1204 case AF9033_TUNER_IT9135_60:
1205 case AF9033_TUNER_IT9135_61:
1206 case AF9033_TUNER_IT9135_62:
Antti Palosaari83f11612014-09-02 03:55:21 -03001207 dev->is_it9135 = true;
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001208 reg = 0x004bfc;
1209 break;
1210 default:
Antti Palosaari83f11612014-09-02 03:55:21 -03001211 dev->is_af9035 = true;
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001212 reg = 0x0083e9;
1213 break;
1214 }
1215
1216 ret = af9033_rd_regs(dev, reg, &buf[0], 4);
1217 if (ret < 0)
1218 goto err_kfree;
1219
1220 ret = af9033_rd_regs(dev, 0x804191, &buf[4], 4);
1221 if (ret < 0)
1222 goto err_kfree;
1223
1224 dev_info(&dev->client->dev,
Antti Palosaari6a087f12014-08-31 21:08:09 -03001225 "firmware version: LINK %d.%d.%d.%d - OFDM %d.%d.%d.%d\n",
1226 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
1227 buf[7]);
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001228
1229 /* sleep */
1230 switch (dev->cfg.tuner) {
1231 case AF9033_TUNER_IT9135_38:
1232 case AF9033_TUNER_IT9135_51:
1233 case AF9033_TUNER_IT9135_52:
1234 case AF9033_TUNER_IT9135_60:
1235 case AF9033_TUNER_IT9135_61:
1236 case AF9033_TUNER_IT9135_62:
1237 /* IT9135 did not like to sleep at that early */
1238 break;
1239 default:
1240 ret = af9033_wr_reg(dev, 0x80004c, 1);
1241 if (ret < 0)
1242 goto err_kfree;
1243
1244 ret = af9033_wr_reg(dev, 0x800000, 0);
1245 if (ret < 0)
1246 goto err_kfree;
1247 }
1248
1249 /* configure internal TS mode */
1250 switch (dev->cfg.ts_mode) {
1251 case AF9033_TS_MODE_PARALLEL:
1252 dev->ts_mode_parallel = true;
1253 break;
1254 case AF9033_TS_MODE_SERIAL:
1255 dev->ts_mode_serial = true;
1256 break;
1257 case AF9033_TS_MODE_USB:
1258 /* usb mode for AF9035 */
1259 default:
1260 break;
1261 }
1262
1263 /* create dvb_frontend */
1264 memcpy(&dev->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops));
1265 dev->fe.demodulator_priv = dev;
1266 *cfg->fe = &dev->fe;
1267 if (cfg->ops) {
1268 cfg->ops->pid_filter = af9033_pid_filter;
1269 cfg->ops->pid_filter_ctrl = af9033_pid_filter_ctrl;
1270 }
1271 i2c_set_clientdata(client, dev);
1272
1273 dev_info(&dev->client->dev, "Afatech AF9033 successfully attached\n");
1274 return 0;
1275err_kfree:
1276 kfree(dev);
1277err:
Antti Palosaari6a087f12014-08-31 21:08:09 -03001278 dev_dbg(&client->dev, "failed=%d\n", ret);
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001279 return ret;
1280}
1281
1282static int af9033_remove(struct i2c_client *client)
1283{
1284 struct af9033_dev *dev = i2c_get_clientdata(client);
1285
Antti Palosaari6a087f12014-08-31 21:08:09 -03001286 dev_dbg(&dev->client->dev, "\n");
Antti Palosaarif5b00a72014-08-31 20:57:05 -03001287
1288 dev->fe.ops.release = NULL;
1289 dev->fe.demodulator_priv = NULL;
1290 kfree(dev);
1291
1292 return 0;
1293}
1294
1295static const struct i2c_device_id af9033_id_table[] = {
1296 {"af9033", 0},
1297 {}
1298};
1299MODULE_DEVICE_TABLE(i2c, af9033_id_table);
1300
1301static struct i2c_driver af9033_driver = {
1302 .driver = {
1303 .owner = THIS_MODULE,
1304 .name = "af9033",
1305 },
1306 .probe = af9033_probe,
1307 .remove = af9033_remove,
1308 .id_table = af9033_id_table,
1309};
1310
1311module_i2c_driver(af9033_driver);
1312
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001313MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1314MODULE_DESCRIPTION("Afatech AF9033 DVB-T demodulator driver");
1315MODULE_LICENSE("GPL");