blob: 7cae7d63203026f5b7c6489453455f5653a90f2c [file] [log] [blame]
Thomas Gleixner74ba9202019-05-20 09:19:02 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -03003 Driver for Zarlink VP310/MT312/ZL10313 Satellite Channel Decoder
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
5 Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -03006 Copyright (C) 2008 Matthias Schwarzott <zzam@gentoo.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9 References:
10 http://products.zarlink.com/product_profiles/MT312.htm
11 http://products.zarlink.com/product_profiles/SL1935.htm
12*/
13
14#include <linux/delay.h>
15#include <linux/errno.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080019#include <linux/string.h>
20#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Mauro Carvalho Chehabfada1932017-12-28 13:03:51 -050022#include <media/dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include "mt312_priv.h"
24#include "mt312.h"
25
Mauro Carvalho Chehab83937962013-11-02 05:05:18 -030026/* Max transfer size done by I2C transfer functions */
27#define MAX_XFER_SIZE 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29struct mt312_state {
Matthias Schwarzott89f64752007-12-21 08:56:44 -030030 struct i2c_adapter *i2c;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 /* configuration settings */
Matthias Schwarzott89f64752007-12-21 08:56:44 -030032 const struct mt312_config *config;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 struct dvb_frontend frontend;
34
35 u8 id;
Matthias Schwarzott111221f2008-04-12 15:04:48 -030036 unsigned long xtal;
37 u8 freq_mult;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038};
39
40static int debug;
41#define dprintk(args...) \
42 do { \
Matthias Schwarzott89f64752007-12-21 08:56:44 -030043 if (debug) \
44 printk(KERN_DEBUG "mt312: " args); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 } while (0)
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define MT312_PLL_CLK 10000000UL /* 10 MHz */
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -030048#define MT312_PLL_CLK_10_111 10111000UL /* 10.111 MHz */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Matthias Schwarzott89f64752007-12-21 08:56:44 -030050static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg,
Matthias Schwarzott1881ee82008-04-12 15:04:46 -030051 u8 *buf, const size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
53 int ret;
54 struct i2c_msg msg[2];
55 u8 regbuf[1] = { reg };
56
57 msg[0].addr = state->config->demod_address;
58 msg[0].flags = 0;
59 msg[0].buf = regbuf;
60 msg[0].len = 1;
61 msg[1].addr = state->config->demod_address;
62 msg[1].flags = I2C_M_RD;
63 msg[1].buf = buf;
64 msg[1].len = count;
65
66 ret = i2c_transfer(state->i2c, msg, 2);
67
68 if (ret != 2) {
Matthias Schwarzott302e8ac2009-05-20 04:57:10 -030069 printk(KERN_DEBUG "%s: ret == %d\n", __func__, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 return -EREMOTEIO;
71 }
72
Matthias Schwarzott89f64752007-12-21 08:56:44 -030073 if (debug) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 int i;
75 dprintk("R(%d):", reg & 0x7f);
76 for (i = 0; i < count; i++)
Matthias Schwarzott0389b342009-07-02 16:17:28 -030077 printk(KERN_CONT " %02x", buf[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 printk("\n");
79 }
80
81 return 0;
82}
83
Matthias Schwarzott89f64752007-12-21 08:56:44 -030084static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg,
Matthias Schwarzott1881ee82008-04-12 15:04:46 -030085 const u8 *src, const size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
87 int ret;
Mauro Carvalho Chehab83937962013-11-02 05:05:18 -030088 u8 buf[MAX_XFER_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 struct i2c_msg msg;
90
Mauro Carvalho Chehab83937962013-11-02 05:05:18 -030091 if (1 + count > sizeof(buf)) {
92 printk(KERN_WARNING
Mauro Carvalho Chehab35f30f32014-09-24 20:35:12 -030093 "mt312: write: len=%zu is too big!\n", count);
Mauro Carvalho Chehab83937962013-11-02 05:05:18 -030094 return -EINVAL;
95 }
96
Matthias Schwarzott89f64752007-12-21 08:56:44 -030097 if (debug) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 int i;
99 dprintk("W(%d):", reg & 0x7f);
100 for (i = 0; i < count; i++)
Matthias Schwarzott0389b342009-07-02 16:17:28 -0300101 printk(KERN_CONT " %02x", src[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 printk("\n");
103 }
104
105 buf[0] = reg;
106 memcpy(&buf[1], src, count);
107
108 msg.addr = state->config->demod_address;
109 msg.flags = 0;
110 msg.buf = buf;
111 msg.len = count + 1;
112
113 ret = i2c_transfer(state->i2c, &msg, 1);
114
115 if (ret != 1) {
Harvey Harrison271ddbf2008-04-08 23:20:00 -0300116 dprintk("%s: ret == %d\n", __func__, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 return -EREMOTEIO;
118 }
119
120 return 0;
121}
122
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300123static inline int mt312_readreg(struct mt312_state *state,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 const enum mt312_reg_addr reg, u8 *val)
125{
126 return mt312_read(state, reg, val, 1);
127}
128
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300129static inline int mt312_writereg(struct mt312_state *state,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 const enum mt312_reg_addr reg, const u8 val)
131{
Arnd Bergmann3cd890d2017-11-30 11:55:46 -0500132 u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
133
134
135 return mt312_write(state, reg, &tmp, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136}
137
138static inline u32 mt312_div(u32 a, u32 b)
139{
140 return (a + (b / 2)) / b;
141}
142
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300143static int mt312_reset(struct mt312_state *state, const u8 full)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144{
145 return mt312_writereg(state, RESET, full ? 0x80 : 0x40);
146}
147
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300148static int mt312_get_inversion(struct mt312_state *state,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300149 enum fe_spectral_inversion *i)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
151 int ret;
152 u8 vit_mode;
153
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300154 ret = mt312_readreg(state, VIT_MODE, &vit_mode);
155 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 return ret;
157
158 if (vit_mode & 0x80) /* auto inversion was used */
159 *i = (vit_mode & 0x40) ? INVERSION_ON : INVERSION_OFF;
160
161 return 0;
162}
163
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300164static int mt312_get_symbol_rate(struct mt312_state *state, u32 *sr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165{
166 int ret;
167 u8 sym_rate_h;
168 u8 dec_ratio;
169 u16 sym_rat_op;
170 u16 monitor;
171 u8 buf[2];
172
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300173 ret = mt312_readreg(state, SYM_RATE_H, &sym_rate_h);
174 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 return ret;
176
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300177 if (sym_rate_h & 0x80) {
178 /* symbol rate search was used */
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300179 ret = mt312_writereg(state, MON_CTRL, 0x03);
180 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 return ret;
182
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300183 ret = mt312_read(state, MONITOR_H, buf, sizeof(buf));
184 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 return ret;
186
187 monitor = (buf[0] << 8) | buf[1];
188
Matthias Schwarzott0b6a3342007-12-21 08:58:09 -0300189 dprintk("sr(auto) = %u\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 mt312_div(monitor * 15625, 4));
191 } else {
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300192 ret = mt312_writereg(state, MON_CTRL, 0x05);
193 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 return ret;
195
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300196 ret = mt312_read(state, MONITOR_H, buf, sizeof(buf));
197 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 return ret;
199
200 dec_ratio = ((buf[0] >> 5) & 0x07) * 32;
201
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300202 ret = mt312_read(state, SYM_RAT_OP_H, buf, sizeof(buf));
203 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 return ret;
205
206 sym_rat_op = (buf[0] << 8) | buf[1];
207
Matthias Schwarzott0b6a3342007-12-21 08:58:09 -0300208 dprintk("sym_rat_op=%d dec_ratio=%d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 sym_rat_op, dec_ratio);
Matthias Schwarzott0b6a3342007-12-21 08:58:09 -0300210 dprintk("*sr(manual) = %lu\n",
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300211 (((state->xtal * 8192) / (sym_rat_op + 8192)) *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 2) - dec_ratio);
213 }
214
215 return 0;
216}
217
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300218static int mt312_get_code_rate(struct mt312_state *state, enum fe_code_rate *cr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219{
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300220 const enum fe_code_rate fec_tab[8] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_6_7, FEC_7_8,
222 FEC_AUTO, FEC_AUTO };
223
224 int ret;
225 u8 fec_status;
226
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300227 ret = mt312_readreg(state, FEC_STATUS, &fec_status);
228 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 return ret;
230
231 *cr = fec_tab[(fec_status >> 4) & 0x07];
232
233 return 0;
234}
235
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300236static int mt312_initfe(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700238 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 int ret;
240 u8 buf[2];
241
242 /* wake up */
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300243 ret = mt312_writereg(state, CONFIG,
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300244 (state->freq_mult == 6 ? 0x88 : 0x8c));
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300245 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 return ret;
247
248 /* wait at least 150 usec */
249 udelay(150);
250
251 /* full reset */
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300252 ret = mt312_reset(state, 1);
253 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 return ret;
255
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300256/* Per datasheet, write correct values. 09/28/03 ACCJr.
257 * If we don't do this, we won't get FE_HAS_VITERBI in the VP310. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 {
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300259 u8 buf_def[8] = { 0x14, 0x12, 0x03, 0x02,
260 0x01, 0x00, 0x00, 0x00 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300262 ret = mt312_write(state, VIT_SETUP, buf_def, sizeof(buf_def));
263 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 return ret;
265 }
266
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300267 switch (state->id) {
268 case ID_ZL10313:
269 /* enable ADC */
270 ret = mt312_writereg(state, GPP_CTRL, 0x80);
271 if (ret < 0)
272 return ret;
273
274 /* configure ZL10313 for optimal ADC performance */
275 buf[0] = 0x80;
276 buf[1] = 0xB0;
277 ret = mt312_write(state, HW_CTRL, buf, 2);
278 if (ret < 0)
279 return ret;
280
281 /* enable MPEG output and ADCs */
282 ret = mt312_writereg(state, HW_CTRL, 0x00);
283 if (ret < 0)
284 return ret;
285
286 ret = mt312_writereg(state, MPEG_CTRL, 0x00);
287 if (ret < 0)
288 return ret;
289
290 break;
291 }
292
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 /* SYS_CLK */
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300294 buf[0] = mt312_div(state->xtal * state->freq_mult * 2, 1000000);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296 /* DISEQC_RATIO */
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300297 buf[1] = mt312_div(state->xtal, 22000 * 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300299 ret = mt312_write(state, SYS_CLK, buf, sizeof(buf));
300 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 return ret;
302
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300303 ret = mt312_writereg(state, SNR_THS_HIGH, 0x32);
304 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 return ret;
306
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300307 /* different MOCLK polarity */
308 switch (state->id) {
309 case ID_ZL10313:
310 buf[0] = 0x33;
311 break;
312 default:
313 buf[0] = 0x53;
314 break;
315 }
316
317 ret = mt312_writereg(state, OP_CTRL, buf[0]);
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300318 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 return ret;
320
321 /* TS_SW_LIM */
322 buf[0] = 0x8c;
323 buf[1] = 0x98;
324
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300325 ret = mt312_write(state, TS_SW_LIM_L, buf, sizeof(buf));
326 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 return ret;
328
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300329 ret = mt312_writereg(state, CS_SW_LIM, 0x69);
330 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 return ret;
332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 return 0;
334}
335
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300336static int mt312_send_master_cmd(struct dvb_frontend *fe,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 struct dvb_diseqc_master_cmd *c)
338{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700339 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 int ret;
341 u8 diseqc_mode;
342
343 if ((c->msg_len == 0) || (c->msg_len > sizeof(c->msg)))
344 return -EINVAL;
345
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300346 ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode);
347 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 return ret;
349
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300350 ret = mt312_write(state, (0x80 | DISEQC_INSTR), c->msg, c->msg_len);
351 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 return ret;
353
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300354 ret = mt312_writereg(state, DISEQC_MODE,
355 (diseqc_mode & 0x40) | ((c->msg_len - 1) << 3)
356 | 0x04);
357 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 return ret;
359
Matthias Schwarzott82cd2df2008-04-12 15:04:47 -0300360 /* is there a better way to wait for message to be transmitted */
361 msleep(100);
362
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 /* set DISEQC_MODE[2:0] to zero if a return message is expected */
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300364 if (c->msg[0] & 0x02) {
365 ret = mt312_writereg(state, DISEQC_MODE, (diseqc_mode & 0x40));
366 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 return ret;
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300368 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
370 return 0;
371}
372
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300373static int mt312_send_burst(struct dvb_frontend *fe,
374 const enum fe_sec_mini_cmd c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700376 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 const u8 mini_tab[2] = { 0x02, 0x03 };
378
379 int ret;
380 u8 diseqc_mode;
381
382 if (c > SEC_MINI_B)
383 return -EINVAL;
384
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300385 ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode);
386 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 return ret;
388
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300389 ret = mt312_writereg(state, DISEQC_MODE,
390 (diseqc_mode & 0x40) | mini_tab[c]);
391 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 return ret;
393
394 return 0;
395}
396
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300397static int mt312_set_tone(struct dvb_frontend *fe,
398 const enum fe_sec_tone_mode t)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700400 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 const u8 tone_tab[2] = { 0x01, 0x00 };
402
403 int ret;
404 u8 diseqc_mode;
405
406 if (t > SEC_TONE_OFF)
407 return -EINVAL;
408
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300409 ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode);
410 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 return ret;
412
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300413 ret = mt312_writereg(state, DISEQC_MODE,
414 (diseqc_mode & 0x40) | tone_tab[t]);
415 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 return ret;
417
418 return 0;
419}
420
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300421static int mt312_set_voltage(struct dvb_frontend *fe,
422 const enum fe_sec_voltage v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700424 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 const u8 volt_tab[3] = { 0x00, 0x40, 0x00 };
Matthias Schwarzott11d3f322008-04-12 15:04:50 -0300426 u8 val;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427
428 if (v > SEC_VOLTAGE_OFF)
429 return -EINVAL;
430
Matthias Schwarzott11d3f322008-04-12 15:04:50 -0300431 val = volt_tab[v];
432 if (state->config->voltage_inverted)
433 val ^= 0x40;
434
435 return mt312_writereg(state, DISEQC_MODE, val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436}
437
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300438static int mt312_read_status(struct dvb_frontend *fe, enum fe_status *s)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700440 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 int ret;
442 u8 status[3];
443
444 *s = 0;
445
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300446 ret = mt312_read(state, QPSK_STAT_H, status, sizeof(status));
447 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 return ret;
449
Mauro Carvalho Chehab4bd69e72016-10-18 17:44:22 -0200450 dprintk("QPSK_STAT_H: 0x%02x, QPSK_STAT_L: 0x%02x, FEC_STATUS: 0x%02x\n",
451 status[0], status[1], status[2]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
453 if (status[0] & 0xc0)
454 *s |= FE_HAS_SIGNAL; /* signal noise ratio */
455 if (status[0] & 0x04)
456 *s |= FE_HAS_CARRIER; /* qpsk carrier lock */
457 if (status[2] & 0x02)
458 *s |= FE_HAS_VITERBI; /* viterbi lock */
459 if (status[2] & 0x04)
460 *s |= FE_HAS_SYNC; /* byte align lock */
461 if (status[0] & 0x01)
462 *s |= FE_HAS_LOCK; /* qpsk lock */
463
464 return 0;
465}
466
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300467static int mt312_read_ber(struct dvb_frontend *fe, u32 *ber)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700469 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 int ret;
471 u8 buf[3];
472
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300473 ret = mt312_read(state, RS_BERCNT_H, buf, 3);
474 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 return ret;
476
477 *ber = ((buf[0] << 16) | (buf[1] << 8) | buf[2]) * 64;
478
479 return 0;
480}
481
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300482static int mt312_read_signal_strength(struct dvb_frontend *fe,
483 u16 *signal_strength)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700485 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 int ret;
487 u8 buf[3];
488 u16 agc;
489 s16 err_db;
490
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300491 ret = mt312_read(state, AGC_H, buf, sizeof(buf));
492 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 return ret;
494
495 agc = (buf[0] << 6) | (buf[1] >> 2);
496 err_db = (s16) (((buf[1] & 0x03) << 14) | buf[2] << 6) >> 6;
497
498 *signal_strength = agc;
499
Matthias Schwarzott0b6a3342007-12-21 08:58:09 -0300500 dprintk("agc=%08x err_db=%hd\n", agc, err_db);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
502 return 0;
503}
504
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300505static int mt312_read_snr(struct dvb_frontend *fe, u16 *snr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700507 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 int ret;
509 u8 buf[2];
510
Matthias Schwarzott1881ee82008-04-12 15:04:46 -0300511 ret = mt312_read(state, M_SNR_H, buf, sizeof(buf));
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300512 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 return ret;
514
515 *snr = 0xFFFF - ((((buf[0] & 0x7f) << 8) | buf[1]) << 1);
516
517 return 0;
518}
519
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300520static int mt312_read_ucblocks(struct dvb_frontend *fe, u32 *ubc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700522 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 int ret;
524 u8 buf[2];
525
Matthias Schwarzott1881ee82008-04-12 15:04:46 -0300526 ret = mt312_read(state, RS_UBC_H, buf, sizeof(buf));
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300527 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 return ret;
529
530 *ubc = (buf[0] << 8) | buf[1];
531
532 return 0;
533}
534
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300535static int mt312_set_frontend(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300537 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700538 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 int ret;
540 u8 buf[5], config_val;
541 u16 sr;
542
543 const u8 fec_tab[10] =
544 { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f };
545 const u8 inv_tab[3] = { 0x00, 0x40, 0x80 };
546
Harvey Harrison271ddbf2008-04-08 23:20:00 -0300547 dprintk("%s: Freq %d\n", __func__, p->frequency);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400549 if ((p->frequency < fe->ops.info.frequency_min_hz / kHz)
550 || (p->frequency > fe->ops.info.frequency_max_hz / kHz))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 return -EINVAL;
552
Mauro Carvalho Chehab830e4b52012-10-27 16:14:01 -0300553 if (((int)p->inversion < INVERSION_OFF)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 || (p->inversion > INVERSION_ON))
555 return -EINVAL;
556
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300557 if ((p->symbol_rate < fe->ops.info.symbol_rate_min)
558 || (p->symbol_rate > fe->ops.info.symbol_rate_max))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 return -EINVAL;
560
Mauro Carvalho Chehab830e4b52012-10-27 16:14:01 -0300561 if (((int)p->fec_inner < FEC_NONE)
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300562 || (p->fec_inner > FEC_AUTO))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 return -EINVAL;
564
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300565 if ((p->fec_inner == FEC_4_5)
566 || (p->fec_inner == FEC_8_9))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 return -EINVAL;
568
569 switch (state->id) {
570 case ID_VP310:
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300571 /* For now we will do this only for the VP310.
572 * It should be better for the mt312 as well,
573 * but tuning will be slower. ACCJr 09/29/03
574 */
Alexey Dobriyan682e8522006-01-10 00:09:16 +0300575 ret = mt312_readreg(state, CONFIG, &config_val);
576 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 return ret;
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300578 if (p->symbol_rate >= 30000000) {
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300579 /* Note that 30MS/s should use 90MHz */
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300580 if (state->freq_mult == 6) {
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300581 /* We are running 60MHz */
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300582 state->freq_mult = 9;
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300583 ret = mt312_initfe(fe);
584 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 return ret;
586 }
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300587 } else {
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300588 if (state->freq_mult == 9) {
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300589 /* We are running 90MHz */
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300590 state->freq_mult = 6;
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300591 ret = mt312_initfe(fe);
592 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 return ret;
594 }
595 }
596 break;
597
598 case ID_MT312:
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300599 case ID_ZL10313:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 break;
601
602 default:
603 return -EINVAL;
604 }
605
Patrick Boettcherdea74862006-05-14 05:01:31 -0300606 if (fe->ops.tuner_ops.set_params) {
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300607 fe->ops.tuner_ops.set_params(fe);
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300608 if (fe->ops.i2c_gate_ctrl)
609 fe->ops.i2c_gate_ctrl(fe, 0);
Andrew de Quinceya81870e2006-04-18 17:47:09 -0300610 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611
612 /* sr = (u16)(sr * 256.0 / 1000000.0) */
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300613 sr = mt312_div(p->symbol_rate * 4, 15625);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614
615 /* SYM_RATE */
616 buf[0] = (sr >> 8) & 0x3f;
617 buf[1] = (sr >> 0) & 0xff;
618
619 /* VIT_MODE */
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300620 buf[2] = inv_tab[p->inversion] | fec_tab[p->fec_inner];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
622 /* QPSK_CTRL */
623 buf[3] = 0x40; /* swap I and Q before QPSK demodulation */
624
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300625 if (p->symbol_rate < 10000000)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 buf[3] |= 0x04; /* use afc mode */
627
628 /* GO */
629 buf[4] = 0x01;
630
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300631 ret = mt312_write(state, SYM_RATE_H, buf, sizeof(buf));
632 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 return ret;
634
Kangjie Lu9502cdf2018-12-21 02:07:20 -0500635 ret = mt312_reset(state, 0);
636 if (ret < 0)
637 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
639 return 0;
640}
641
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -0200642static int mt312_get_frontend(struct dvb_frontend *fe,
643 struct dtv_frontend_properties *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700645 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 int ret;
647
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300648 ret = mt312_get_inversion(state, &p->inversion);
649 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 return ret;
651
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300652 ret = mt312_get_symbol_rate(state, &p->symbol_rate);
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300653 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 return ret;
655
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300656 ret = mt312_get_code_rate(state, &p->fec_inner);
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300657 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 return ret;
659
660 return 0;
661}
662
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300663static int mt312_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
Andrew de Quinceya81870e2006-04-18 17:47:09 -0300664{
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300665 struct mt312_state *state = fe->demodulator_priv;
Andrew de Quinceya81870e2006-04-18 17:47:09 -0300666
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300667 u8 val = 0x00;
668 int ret;
669
670 switch (state->id) {
671 case ID_ZL10313:
672 ret = mt312_readreg(state, GPP_CTRL, &val);
673 if (ret < 0)
674 goto error;
675
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300676 /* preserve this bit to not accidentally shutdown ADC */
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300677 val &= 0x80;
678 break;
Andrew de Quinceya81870e2006-04-18 17:47:09 -0300679 }
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300680
681 if (enable)
682 val |= 0x40;
683 else
684 val &= ~0x40;
685
686 ret = mt312_writereg(state, GPP_CTRL, val);
687
688error:
689 return ret;
Andrew de Quinceya81870e2006-04-18 17:47:09 -0300690}
691
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300692static int mt312_sleep(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700694 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 int ret;
696 u8 config;
697
698 /* reset all registers to defaults */
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300699 ret = mt312_reset(state, 1);
700 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 return ret;
702
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300703 if (state->id == ID_ZL10313) {
704 /* reset ADC */
705 ret = mt312_writereg(state, GPP_CTRL, 0x00);
706 if (ret < 0)
707 return ret;
708
709 /* full shutdown of ADCs, mpeg bus tristated */
710 ret = mt312_writereg(state, HW_CTRL, 0x0d);
711 if (ret < 0)
712 return ret;
713 }
714
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300715 ret = mt312_readreg(state, CONFIG, &config);
716 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 return ret;
718
719 /* enter standby */
Matthias Schwarzott994fc28b2007-12-24 07:12:55 -0300720 ret = mt312_writereg(state, CONFIG, config & 0x7f);
721 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 return ret;
723
724 return 0;
725}
726
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300727static int mt312_get_tune_settings(struct dvb_frontend *fe,
728 struct dvb_frontend_tune_settings *fesettings)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729{
730 fesettings->min_delay_ms = 50;
731 fesettings->step_size = 0;
732 fesettings->max_drift = 0;
733 return 0;
734}
735
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300736static void mt312_release(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737{
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300738 struct mt312_state *state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 kfree(state);
740}
741
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300742#define MT312_SYS_CLK 90000000UL /* 90 MHz */
Max Kellermannbd336e62016-08-09 18:32:21 -0300743static const struct dvb_frontend_ops mt312_ops = {
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300744 .delsys = { SYS_DVBS },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .info = {
746 .name = "Zarlink ???? DVB-S",
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400747 .frequency_min_hz = 950 * MHz,
748 .frequency_max_hz = 2150 * MHz,
Matthias Schwarzott0389b342009-07-02 16:17:28 -0300749 /* FIXME: adjust freq to real used xtal */
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400750 .frequency_stepsize_hz = MT312_PLL_CLK / 128,
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300751 .symbol_rate_min = MT312_SYS_CLK / 128, /* FIXME as above */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 .symbol_rate_max = MT312_SYS_CLK / 2,
753 .caps =
754 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
755 FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
756 FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS |
Mauro Carvalho Chehab9101e622005-12-12 00:37:24 -0800757 FE_CAN_RECOVER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
759
760 .release = mt312_release,
761
762 .init = mt312_initfe,
763 .sleep = mt312_sleep,
Andrew de Quinceya81870e2006-04-18 17:47:09 -0300764 .i2c_gate_ctrl = mt312_i2c_gate_ctrl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765
Mauro Carvalho Chehab827b5f32011-12-26 13:50:05 -0300766 .set_frontend = mt312_set_frontend,
767 .get_frontend = mt312_get_frontend,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 .get_tune_settings = mt312_get_tune_settings,
769
770 .read_status = mt312_read_status,
771 .read_ber = mt312_read_ber,
772 .read_signal_strength = mt312_read_signal_strength,
773 .read_snr = mt312_read_snr,
774 .read_ucblocks = mt312_read_ucblocks,
775
776 .diseqc_send_master_cmd = mt312_send_master_cmd,
777 .diseqc_send_burst = mt312_send_burst,
778 .set_tone = mt312_set_tone,
779 .set_voltage = mt312_set_voltage,
780};
781
Matthias Schwarzotte4671b62008-04-30 12:21:04 -0300782struct dvb_frontend *mt312_attach(const struct mt312_config *config,
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300783 struct i2c_adapter *i2c)
Adrian Bunk805e6602006-02-27 00:07:49 -0300784{
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300785 struct mt312_state *state = NULL;
Adrian Bunk805e6602006-02-27 00:07:49 -0300786
787 /* allocate memory for the internal state */
Matthias Schwarzott084e24a2009-08-10 22:51:01 -0300788 state = kzalloc(sizeof(struct mt312_state), GFP_KERNEL);
Adrian Bunk805e6602006-02-27 00:07:49 -0300789 if (state == NULL)
790 goto error;
791
792 /* setup the state */
793 state->config = config;
794 state->i2c = i2c;
Adrian Bunk805e6602006-02-27 00:07:49 -0300795
796 /* check if the demod is there */
797 if (mt312_readreg(state, ID, &state->id) < 0)
798 goto error;
799
Patrick Boettcherdea74862006-05-14 05:01:31 -0300800 /* create dvb_frontend */
Matthias Schwarzotte4671b62008-04-30 12:21:04 -0300801 memcpy(&state->frontend.ops, &mt312_ops,
Matthias Schwarzott89f64752007-12-21 08:56:44 -0300802 sizeof(struct dvb_frontend_ops));
Patrick Boettcherdea74862006-05-14 05:01:31 -0300803 state->frontend.demodulator_priv = state;
804
Adrian Bunk805e6602006-02-27 00:07:49 -0300805 switch (state->id) {
806 case ID_VP310:
Mauro Carvalho Chehabcc1e6312018-09-10 16:20:42 -0400807 strscpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S",
808 sizeof(state->frontend.ops.info.name));
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300809 state->xtal = MT312_PLL_CLK;
810 state->freq_mult = 9;
Adrian Bunk805e6602006-02-27 00:07:49 -0300811 break;
812 case ID_MT312:
Mauro Carvalho Chehabcc1e6312018-09-10 16:20:42 -0400813 strscpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S",
814 sizeof(state->frontend.ops.info.name));
Matthias Schwarzott111221f2008-04-12 15:04:48 -0300815 state->xtal = MT312_PLL_CLK;
816 state->freq_mult = 6;
Adrian Bunk805e6602006-02-27 00:07:49 -0300817 break;
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300818 case ID_ZL10313:
Mauro Carvalho Chehabcc1e6312018-09-10 16:20:42 -0400819 strscpy(state->frontend.ops.info.name, "Zarlink ZL10313 DVB-S",
820 sizeof(state->frontend.ops.info.name));
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300821 state->xtal = MT312_PLL_CLK_10_111;
822 state->freq_mult = 9;
823 break;
Adrian Bunk805e6602006-02-27 00:07:49 -0300824 default:
Mauro Carvalho Chehab4bd69e72016-10-18 17:44:22 -0200825 printk(KERN_WARNING "Only Zarlink VP310/MT312/ZL10313 are supported chips.\n");
Adrian Bunk805e6602006-02-27 00:07:49 -0300826 goto error;
827 }
828
Adrian Bunk805e6602006-02-27 00:07:49 -0300829 return &state->frontend;
830
831error:
832 kfree(state);
833 return NULL;
834}
Matthias Schwarzotte4671b62008-04-30 12:21:04 -0300835EXPORT_SYMBOL(mt312_attach);
Adrian Bunk805e6602006-02-27 00:07:49 -0300836
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837module_param(debug, int, 0644);
838MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
839
Matthias Schwarzott6a5cbd52008-04-12 15:04:49 -0300840MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
Matthias Schwarzotte4671b62008-04-30 12:21:04 -0300842MODULE_AUTHOR("Matthias Schwarzott <zzam@gentoo.org>");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843MODULE_LICENSE("GPL");
844