Merge tag 'asm-generic' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm...
[deliverable/linux.git] / drivers / media / pci / ngene / ngene-cards.c
CommitLineData
cbddcba6
DH
1/*
2 * ngene-cards.c: nGene PCIe bridge driver - card specific info
3 *
4 * Copyright (C) 2005-2007 Micronas
5 *
6 * Copyright (C) 2008-2009 Ralph Metzler <rjkm@metzlerbros.de>
7 * Modifications for new nGene firmware,
8 * support for EEPROM-copying,
9 * support for new dual DVB-S2 card prototype
10 *
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2 only, as published by the Free Software Foundation.
15 *
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */
29
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/pci.h>
33#include <linux/pci_ids.h>
34
35#include "ngene.h"
36
37/* demods/tuners */
38#include "stv6110x.h"
39#include "stv090x.h"
40#include "lnbh24.h"
41#include "lgdt330x.h"
42#include "mt2131.h"
9143a437 43#include "tda18271c2dd.h"
9ca9efb0 44#include "drxk.h"
397e9723
PC
45#include "drxd.h"
46#include "dvb-pll.h"
cbddcba6
DH
47
48
49/****************************************************************************/
50/* Demod/tuner attachment ***************************************************/
51/****************************************************************************/
52
53static int tuner_attach_stv6110(struct ngene_channel *chan)
54{
5fec1857 55 struct i2c_adapter *i2c;
cbddcba6
DH
56 struct stv090x_config *feconf = (struct stv090x_config *)
57 chan->dev->card_info->fe_config[chan->number];
58 struct stv6110x_config *tunerconf = (struct stv6110x_config *)
59 chan->dev->card_info->tuner_config[chan->number];
60 struct stv6110x_devctl *ctl;
61
5fec1857
OE
62 /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
63 if (chan->number < 2)
64 i2c = &chan->dev->channel[0].i2c_adapter;
65 else
66 i2c = &chan->dev->channel[1].i2c_adapter;
67
68 ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf, i2c);
cbddcba6
DH
69 if (ctl == NULL) {
70 printk(KERN_ERR DEVICE_NAME ": No STV6110X found!\n");
71 return -ENODEV;
72 }
73
74 feconf->tuner_init = ctl->tuner_init;
5fec1857 75 feconf->tuner_sleep = ctl->tuner_sleep;
cbddcba6
DH
76 feconf->tuner_set_mode = ctl->tuner_set_mode;
77 feconf->tuner_set_frequency = ctl->tuner_set_frequency;
78 feconf->tuner_get_frequency = ctl->tuner_get_frequency;
79 feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth;
80 feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth;
81 feconf->tuner_set_bbgain = ctl->tuner_set_bbgain;
82 feconf->tuner_get_bbgain = ctl->tuner_get_bbgain;
83 feconf->tuner_set_refclk = ctl->tuner_set_refclk;
84 feconf->tuner_get_status = ctl->tuner_get_status;
85
86 return 0;
87}
88
89
9ca9efb0
RM
90static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
91{
92 struct ngene_channel *chan = fe->sec_priv;
93 int status;
94
95 if (enable) {
96 down(&chan->dev->pll_mutex);
97 status = chan->gate_ctrl(fe, 1);
98 } else {
99 status = chan->gate_ctrl(fe, 0);
100 up(&chan->dev->pll_mutex);
101 }
102 return status;
103}
104
9ca9efb0
RM
105static int tuner_attach_tda18271(struct ngene_channel *chan)
106{
107 struct i2c_adapter *i2c;
108 struct dvb_frontend *fe;
109
110 i2c = &chan->dev->channel[0].i2c_adapter;
111 if (chan->fe->ops.i2c_gate_ctrl)
112 chan->fe->ops.i2c_gate_ctrl(chan->fe, 1);
113 fe = dvb_attach(tda18271c2dd_attach, chan->fe, i2c, 0x60);
114 if (chan->fe->ops.i2c_gate_ctrl)
115 chan->fe->ops.i2c_gate_ctrl(chan->fe, 0);
116 if (!fe) {
9143a437 117 printk(KERN_ERR "No TDA18271 found!\n");
9ca9efb0
RM
118 return -ENODEV;
119 }
120
121 return 0;
122}
123
124static int tuner_attach_probe(struct ngene_channel *chan)
125{
126 if (chan->demod_type == 0)
127 return tuner_attach_stv6110(chan);
128 if (chan->demod_type == 1)
129 return tuner_attach_tda18271(chan);
130 return -EINVAL;
131}
132
cbddcba6
DH
133static int demod_attach_stv0900(struct ngene_channel *chan)
134{
5fec1857 135 struct i2c_adapter *i2c;
cbddcba6
DH
136 struct stv090x_config *feconf = (struct stv090x_config *)
137 chan->dev->card_info->fe_config[chan->number];
138
5fec1857
OE
139 /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
140 /* Note: Both adapters share the same i2c bus, but the demod */
141 /* driver requires that each demod has its own i2c adapter */
142 if (chan->number < 2)
143 i2c = &chan->dev->channel[0].i2c_adapter;
144 else
145 i2c = &chan->dev->channel[1].i2c_adapter;
146
147 chan->fe = dvb_attach(stv090x_attach, feconf, i2c,
148 (chan->number & 1) == 0 ? STV090x_DEMODULATOR_0
149 : STV090x_DEMODULATOR_1);
cbddcba6
DH
150 if (chan->fe == NULL) {
151 printk(KERN_ERR DEVICE_NAME ": No STV0900 found!\n");
152 return -ENODEV;
153 }
154
5fec1857
OE
155 /* store channel info */
156 if (feconf->tuner_i2c_lock)
157 chan->fe->analog_demod_priv = chan;
158
159 if (!dvb_attach(lnbh24_attach, chan->fe, i2c, 0,
cbddcba6
DH
160 0, chan->dev->card_info->lnb[chan->number])) {
161 printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n");
162 dvb_frontend_detach(chan->fe);
8a484719 163 chan->fe = NULL;
cbddcba6
DH
164 return -ENODEV;
165 }
166
167 return 0;
168}
169
5fec1857
OE
170static void cineS2_tuner_i2c_lock(struct dvb_frontend *fe, int lock)
171{
172 struct ngene_channel *chan = fe->analog_demod_priv;
173
174 if (lock)
175 down(&chan->dev->pll_mutex);
176 else
177 up(&chan->dev->pll_mutex);
178}
179
9ca9efb0
RM
180static int i2c_read(struct i2c_adapter *adapter, u8 adr, u8 *val)
181{
182 struct i2c_msg msgs[1] = {{.addr = adr, .flags = I2C_M_RD,
9143a437 183 .buf = val, .len = 1 } };
9ca9efb0
RM
184 return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1;
185}
186
187static int i2c_read_reg16(struct i2c_adapter *adapter, u8 adr,
188 u16 reg, u8 *val)
189{
190 u8 msg[2] = {reg>>8, reg&0xff};
191 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
192 .buf = msg, .len = 2},
193 {.addr = adr, .flags = I2C_M_RD,
9143a437 194 .buf = val, .len = 1} };
9ca9efb0
RM
195 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
196}
197
198static int port_has_stv0900(struct i2c_adapter *i2c, int port)
199{
200 u8 val;
201 if (i2c_read_reg16(i2c, 0x68+port/2, 0xf100, &val) < 0)
202 return 0;
203 return 1;
204}
205
206static int port_has_drxk(struct i2c_adapter *i2c, int port)
207{
208 u8 val;
209
210 if (i2c_read(i2c, 0x29+port, &val) < 0)
211 return 0;
9ca9efb0
RM
212 return 1;
213}
214
215static int demod_attach_drxk(struct ngene_channel *chan,
216 struct i2c_adapter *i2c)
217{
0fc55e81
MCC
218 struct drxk_config config;
219
220 memset(&config, 0, sizeof(config));
da989e0b 221 config.microcode_name = "drxk_a3.mc";
9e23f50a 222 config.qam_demod_parameter_count = 4;
0fc55e81
MCC
223 config.adr = 0x29 + (chan->number ^ 2);
224
fa4b2a17 225 chan->fe = dvb_attach(drxk_attach, &config, i2c);
9ca9efb0 226 if (!chan->fe) {
9143a437 227 printk(KERN_ERR "No DRXK found!\n");
9ca9efb0
RM
228 return -ENODEV;
229 }
9143a437
OE
230 chan->fe->sec_priv = chan;
231 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl;
232 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
9ca9efb0
RM
233 return 0;
234}
235
5fec1857
OE
236static int cineS2_probe(struct ngene_channel *chan)
237{
238 struct i2c_adapter *i2c;
239 struct stv090x_config *fe_conf;
240 u8 buf[3];
241 struct i2c_msg i2c_msg = { .flags = 0, .buf = buf };
242 int rc;
243
244 /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
245 if (chan->number < 2)
246 i2c = &chan->dev->channel[0].i2c_adapter;
247 else
248 i2c = &chan->dev->channel[1].i2c_adapter;
249
9ca9efb0 250 if (port_has_stv0900(i2c, chan->number)) {
9143a437 251 chan->demod_type = 0;
9ca9efb0
RM
252 fe_conf = chan->dev->card_info->fe_config[chan->number];
253 /* demod found, attach it */
254 rc = demod_attach_stv0900(chan);
255 if (rc < 0 || chan->number < 2)
256 return rc;
9143a437 257
9ca9efb0
RM
258 /* demod #2: reprogram outputs DPN1 & DPN2 */
259 i2c_msg.addr = fe_conf->address;
260 i2c_msg.len = 3;
261 buf[0] = 0xf1;
9143a437 262 switch (chan->number) {
9ca9efb0
RM
263 case 2:
264 buf[1] = 0x5c;
265 buf[2] = 0xc2;
266 break;
267 case 3:
268 buf[1] = 0x61;
269 buf[2] = 0xcc;
270 break;
271 default:
272 return -ENODEV;
273 }
274 rc = i2c_transfer(i2c, &i2c_msg, 1);
275 if (rc != 1) {
276 printk(KERN_ERR DEVICE_NAME ": could not setup DPNx\n");
277 return -EIO;
278 }
279 } else if (port_has_drxk(i2c, chan->number^2)) {
9143a437 280 chan->demod_type = 1;
9ca9efb0
RM
281 demod_attach_drxk(chan, i2c);
282 } else {
9143a437 283 printk(KERN_ERR "No demod found on chan %d\n", chan->number);
d9396b84 284 return -ENODEV;
5fec1857 285 }
5fec1857
OE
286 return 0;
287}
288
289
cbddcba6
DH
290static struct lgdt330x_config aver_m780 = {
291 .demod_address = 0xb2 >> 1,
292 .demod_chip = LGDT3303,
293 .serial_mpeg = 0x00, /* PARALLEL */
294 .clock_polarity_flip = 1,
295};
296
297static struct mt2131_config m780_tunerconfig = {
298 0xc0 >> 1
299};
300
301/* A single func to attach the demo and tuner, rather than
302 * use two sep funcs like the current design mandates.
303 */
304static int demod_attach_lg330x(struct ngene_channel *chan)
305{
306 chan->fe = dvb_attach(lgdt330x_attach, &aver_m780, &chan->i2c_adapter);
307 if (chan->fe == NULL) {
308 printk(KERN_ERR DEVICE_NAME ": No LGDT330x found!\n");
309 return -ENODEV;
310 }
311
312 dvb_attach(mt2131_attach, chan->fe, &chan->i2c_adapter,
313 &m780_tunerconfig, 0);
314
315 return (chan->fe) ? 0 : -ENODEV;
316}
317
397e9723
PC
318static int demod_attach_drxd(struct ngene_channel *chan)
319{
320 struct drxd_config *feconf;
321
322 feconf = chan->dev->card_info->fe_config[chan->number];
323
324 chan->fe = dvb_attach(drxd_attach, feconf, chan,
325 &chan->i2c_adapter, &chan->dev->pci_dev->dev);
326 if (!chan->fe) {
327 pr_err("No DRXD found!\n");
328 return -ENODEV;
329 }
330
331 if (!dvb_attach(dvb_pll_attach, chan->fe, feconf->pll_address,
332 &chan->i2c_adapter,
333 feconf->pll_type)) {
334 pr_err("No pll(%d) found!\n", feconf->pll_type);
335 return -ENODEV;
336 }
337 return 0;
338}
339
340/****************************************************************************/
341/* EEPROM TAGS **************************************************************/
342/****************************************************************************/
343
344#define MICNG_EE_START 0x0100
345#define MICNG_EE_END 0x0FF0
346
347#define MICNG_EETAG_END0 0x0000
348#define MICNG_EETAG_END1 0xFFFF
349
350/* 0x0001 - 0x000F reserved for housekeeping */
351/* 0xFFFF - 0xFFFE reserved for housekeeping */
352
353/* Micronas assigned tags
354 EEProm tags for hardware support */
355
356#define MICNG_EETAG_DRXD1_OSCDEVIATION 0x1000 /* 2 Bytes data */
357#define MICNG_EETAG_DRXD2_OSCDEVIATION 0x1001 /* 2 Bytes data */
358
359#define MICNG_EETAG_MT2060_1_1STIF 0x1100 /* 2 Bytes data */
360#define MICNG_EETAG_MT2060_2_1STIF 0x1101 /* 2 Bytes data */
361
362/* Tag range for OEMs */
363
364#define MICNG_EETAG_OEM_FIRST 0xC000
365#define MICNG_EETAG_OEM_LAST 0xFFEF
366
367static int i2c_write_eeprom(struct i2c_adapter *adapter,
368 u8 adr, u16 reg, u8 data)
369{
370 u8 m[3] = {(reg >> 8), (reg & 0xff), data};
371 struct i2c_msg msg = {.addr = adr, .flags = 0, .buf = m,
372 .len = sizeof(m)};
373
374 if (i2c_transfer(adapter, &msg, 1) != 1) {
375 pr_err(DEVICE_NAME ": Error writing EEPROM!\n");
376 return -EIO;
377 }
378 return 0;
379}
380
381static int i2c_read_eeprom(struct i2c_adapter *adapter,
382 u8 adr, u16 reg, u8 *data, int len)
383{
384 u8 msg[2] = {(reg >> 8), (reg & 0xff)};
385 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
386 .buf = msg, .len = 2 },
387 {.addr = adr, .flags = I2C_M_RD,
388 .buf = data, .len = len} };
389
390 if (i2c_transfer(adapter, msgs, 2) != 2) {
391 pr_err(DEVICE_NAME ": Error reading EEPROM\n");
392 return -EIO;
393 }
394 return 0;
395}
396
397static int ReadEEProm(struct i2c_adapter *adapter,
398 u16 Tag, u32 MaxLen, u8 *data, u32 *pLength)
399{
400 int status = 0;
401 u16 Addr = MICNG_EE_START, Length, tag = 0;
402 u8 EETag[3];
403
404 while (Addr + sizeof(u16) + 1 < MICNG_EE_END) {
405 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag, sizeof(EETag)))
406 return -1;
407 tag = (EETag[0] << 8) | EETag[1];
408 if (tag == MICNG_EETAG_END0 || tag == MICNG_EETAG_END1)
409 return -1;
410 if (tag == Tag)
411 break;
412 Addr += sizeof(u16) + 1 + EETag[2];
413 }
414 if (Addr + sizeof(u16) + 1 + EETag[2] > MICNG_EE_END) {
415 pr_err(DEVICE_NAME
416 ": Reached EOEE @ Tag = %04x Length = %3d\n",
417 tag, EETag[2]);
418 return -1;
419 }
420 Length = EETag[2];
421 if (Length > MaxLen)
422 Length = (u16) MaxLen;
423 if (Length > 0) {
424 Addr += sizeof(u16) + 1;
425 status = i2c_read_eeprom(adapter, 0x50, Addr, data, Length);
426 if (!status) {
427 *pLength = EETag[2];
428 if (Length < EETag[2])
429 ; /*status=STATUS_BUFFER_OVERFLOW; */
430 }
431 }
432 return status;
433}
434
435static int WriteEEProm(struct i2c_adapter *adapter,
436 u16 Tag, u32 Length, u8 *data)
437{
438 int status = 0;
439 u16 Addr = MICNG_EE_START;
440 u8 EETag[3];
441 u16 tag = 0;
442 int retry, i;
443
444 while (Addr + sizeof(u16) + 1 < MICNG_EE_END) {
445 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag, sizeof(EETag)))
446 return -1;
447 tag = (EETag[0] << 8) | EETag[1];
448 if (tag == MICNG_EETAG_END0 || tag == MICNG_EETAG_END1)
449 return -1;
450 if (tag == Tag)
451 break;
452 Addr += sizeof(u16) + 1 + EETag[2];
453 }
454 if (Addr + sizeof(u16) + 1 + EETag[2] > MICNG_EE_END) {
455 pr_err(DEVICE_NAME
456 ": Reached EOEE @ Tag = %04x Length = %3d\n",
457 tag, EETag[2]);
458 return -1;
459 }
460
461 if (Length > EETag[2])
462 return -EINVAL;
463 /* Note: We write the data one byte at a time to avoid
464 issues with page sizes. (which are different for
465 each manufacture and eeprom size)
466 */
467 Addr += sizeof(u16) + 1;
468 for (i = 0; i < Length; i++, Addr++) {
469 status = i2c_write_eeprom(adapter, 0x50, Addr, data[i]);
470
471 if (status)
472 break;
473
474 /* Poll for finishing write cycle */
475 retry = 10;
476 while (retry) {
477 u8 Tmp;
478
479 msleep(50);
480 status = i2c_read_eeprom(adapter, 0x50, Addr, &Tmp, 1);
481 if (status)
482 break;
483 if (Tmp != data[i])
484 pr_err(DEVICE_NAME
485 "eeprom write error\n");
486 retry -= 1;
487 }
488 if (status) {
489 pr_err(DEVICE_NAME
490 ": Timeout polling eeprom\n");
491 break;
492 }
493 }
494 return status;
495}
496
497static int eeprom_read_ushort(struct i2c_adapter *adapter, u16 tag, u16 *data)
498{
499 int stat;
500 u8 buf[2];
501 u32 len = 0;
502
503 stat = ReadEEProm(adapter, tag, 2, buf, &len);
504 if (stat)
505 return stat;
506 if (len != 2)
507 return -EINVAL;
508
509 *data = (buf[0] << 8) | buf[1];
510 return 0;
511}
512
513static int eeprom_write_ushort(struct i2c_adapter *adapter, u16 tag, u16 data)
514{
515 int stat;
516 u8 buf[2];
517
518 buf[0] = data >> 8;
519 buf[1] = data & 0xff;
520 stat = WriteEEProm(adapter, tag, 2, buf);
521 if (stat)
522 return stat;
523 return 0;
524}
525
526static s16 osc_deviation(void *priv, s16 deviation, int flag)
527{
528 struct ngene_channel *chan = priv;
529 struct i2c_adapter *adap = &chan->i2c_adapter;
530 u16 data = 0;
531
532 if (flag) {
533 data = (u16) deviation;
534 pr_info(DEVICE_NAME ": write deviation %d\n",
535 deviation);
536 eeprom_write_ushort(adap, 0x1000 + chan->number, data);
537 } else {
538 if (eeprom_read_ushort(adap, 0x1000 + chan->number, &data))
539 data = 0;
540 pr_info(DEVICE_NAME ": read deviation %d\n",
541 (s16) data);
542 }
543
544 return (s16) data;
545}
546
cbddcba6
DH
547/****************************************************************************/
548/* Switch control (I2C gates, etc.) *****************************************/
549/****************************************************************************/
550
551
552static struct stv090x_config fe_cineS2 = {
553 .device = STV0900,
554 .demod_mode = STV090x_DUAL,
555 .clk_mode = STV090x_CLK_EXT,
556
557 .xtal = 27000000,
558 .address = 0x68,
559
560 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
561 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
562
563 .repeater_level = STV090x_RPTLEVEL_16,
564
565 .adc1_range = STV090x_ADC_1Vpp,
566 .adc2_range = STV090x_ADC_1Vpp,
567
568 .diseqc_envelope_mode = true,
5fec1857
OE
569
570 .tuner_i2c_lock = cineS2_tuner_i2c_lock,
571};
572
573static struct stv090x_config fe_cineS2_2 = {
574 .device = STV0900,
575 .demod_mode = STV090x_DUAL,
576 .clk_mode = STV090x_CLK_EXT,
577
578 .xtal = 27000000,
579 .address = 0x69,
580
581 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
582 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
583
584 .repeater_level = STV090x_RPTLEVEL_16,
585
586 .adc1_range = STV090x_ADC_1Vpp,
587 .adc2_range = STV090x_ADC_1Vpp,
588
589 .diseqc_envelope_mode = true,
590
591 .tuner_i2c_lock = cineS2_tuner_i2c_lock,
cbddcba6
DH
592};
593
594static struct stv6110x_config tuner_cineS2_0 = {
595 .addr = 0x60,
596 .refclk = 27000000,
597 .clk_div = 1,
598};
599
600static struct stv6110x_config tuner_cineS2_1 = {
601 .addr = 0x63,
602 .refclk = 27000000,
603 .clk_div = 1,
604};
605
606static struct ngene_info ngene_info_cineS2 = {
607 .type = NGENE_SIDEWINDER,
608 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner",
609 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
610 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
611 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
612 .fe_config = {&fe_cineS2, &fe_cineS2},
613 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
614 .lnb = {0x0b, 0x08},
615 .tsf = {3, 3},
5fec1857
OE
616 .fw_version = 18,
617 .msi_supported = true,
cbddcba6
DH
618};
619
620static struct ngene_info ngene_info_satixS2 = {
621 .type = NGENE_SIDEWINDER,
622 .name = "Mystique SaTiX-S2 Dual",
623 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
624 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
625 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
626 .fe_config = {&fe_cineS2, &fe_cineS2},
627 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
628 .lnb = {0x0b, 0x08},
629 .tsf = {3, 3},
5fec1857
OE
630 .fw_version = 18,
631 .msi_supported = true,
cbddcba6
DH
632};
633
634static struct ngene_info ngene_info_satixS2v2 = {
635 .type = NGENE_SIDEWINDER,
636 .name = "Mystique SaTiX-S2 Dual (v2)",
f164396f
OE
637 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN,
638 NGENE_IO_TSOUT},
5fec1857 639 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe},
a26c1b3e 640 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe},
5fec1857
OE
641 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2},
642 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1},
643 .lnb = {0x0a, 0x08, 0x0b, 0x09},
cbddcba6 644 .tsf = {3, 3},
5fec1857
OE
645 .fw_version = 18,
646 .msi_supported = true,
cbddcba6
DH
647};
648
649static struct ngene_info ngene_info_cineS2v5 = {
650 .type = NGENE_SIDEWINDER,
651 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)",
0f0b270f
RM
652 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN,
653 NGENE_IO_TSOUT},
5fec1857 654 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe},
a26c1b3e 655 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe},
5fec1857
OE
656 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2},
657 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1},
658 .lnb = {0x0a, 0x08, 0x0b, 0x09},
cbddcba6 659 .tsf = {3, 3},
5fec1857
OE
660 .fw_version = 18,
661 .msi_supported = true,
cbddcba6
DH
662};
663
5fec1857 664
6c50b666 665static struct ngene_info ngene_info_duoFlex = {
9d78f460 666 .type = NGENE_SIDEWINDER,
6c50b666 667 .name = "Digital Devices DuoFlex PCIe or miniPCIe",
0f0b270f
RM
668 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN,
669 NGENE_IO_TSOUT},
5fec1857 670 .demod_attach = {cineS2_probe, cineS2_probe, cineS2_probe, cineS2_probe},
9ca9efb0 671 .tuner_attach = {tuner_attach_probe, tuner_attach_probe, tuner_attach_probe, tuner_attach_probe},
5fec1857
OE
672 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2},
673 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1},
674 .lnb = {0x0a, 0x08, 0x0b, 0x09},
9d78f460 675 .tsf = {3, 3},
5fec1857
OE
676 .fw_version = 18,
677 .msi_supported = true,
9d78f460
OE
678};
679
cbddcba6
DH
680static struct ngene_info ngene_info_m780 = {
681 .type = NGENE_APP,
682 .name = "Aver M780 ATSC/QAM-B",
683
684 /* Channel 0 is analog, which is currently unsupported */
685 .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN },
686 .demod_attach = { NULL, demod_attach_lg330x },
687
688 /* Ensure these are NULL else the frame will call them (as funcs) */
689 .tuner_attach = { 0, 0, 0, 0 },
690 .fe_config = { NULL, &aver_m780 },
691 .avf = { 0 },
692
693 /* A custom electrical interface config for the demod to bridge */
694 .tsf = { 4, 4 },
695 .fw_version = 15,
696};
697
397e9723
PC
698static struct drxd_config fe_terratec_dvbt_0 = {
699 .index = 0,
700 .demod_address = 0x70,
701 .demod_revision = 0xa2,
702 .demoda_address = 0x00,
703 .pll_address = 0x60,
704 .pll_type = DVB_PLL_THOMSON_DTT7520X,
705 .clock = 20000,
706 .osc_deviation = osc_deviation,
707};
708
709static struct drxd_config fe_terratec_dvbt_1 = {
710 .index = 1,
711 .demod_address = 0x71,
712 .demod_revision = 0xa2,
713 .demoda_address = 0x00,
714 .pll_address = 0x60,
715 .pll_type = DVB_PLL_THOMSON_DTT7520X,
716 .clock = 20000,
717 .osc_deviation = osc_deviation,
718};
719
720static struct ngene_info ngene_info_terratec = {
721 .type = NGENE_TERRATEC,
722 .name = "Terratec Integra/Cinergy2400i Dual DVB-T",
723 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
724 .demod_attach = {demod_attach_drxd, demod_attach_drxd},
725 .fe_config = {&fe_terratec_dvbt_0, &fe_terratec_dvbt_1},
726 .i2c_access = 1,
727};
728
cbddcba6
DH
729/****************************************************************************/
730
731
732
733/****************************************************************************/
734/* PCI Subsystem ID *********************************************************/
735/****************************************************************************/
736
737#define NGENE_ID(_subvend, _subdev, _driverdata) { \
738 .vendor = NGENE_VID, .device = NGENE_PID, \
739 .subvendor = _subvend, .subdevice = _subdev, \
740 .driver_data = (unsigned long) &_driverdata }
741
742/****************************************************************************/
743
744static const struct pci_device_id ngene_id_tbl[] __devinitdata = {
745 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
746 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
747 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
748 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2),
749 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5),
6c50b666
OE
750 NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlex),
751 NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlex),
cbddcba6 752 NGENE_ID(0x1461, 0x062e, ngene_info_m780),
397e9723 753 NGENE_ID(0x153b, 0x1167, ngene_info_terratec),
cbddcba6
DH
754 {0}
755};
756MODULE_DEVICE_TABLE(pci, ngene_id_tbl);
757
758/****************************************************************************/
759/* Init/Exit ****************************************************************/
760/****************************************************************************/
761
762static pci_ers_result_t ngene_error_detected(struct pci_dev *dev,
9143a437 763 enum pci_channel_state state)
cbddcba6
DH
764{
765 printk(KERN_ERR DEVICE_NAME ": PCI error\n");
766 if (state == pci_channel_io_perm_failure)
767 return PCI_ERS_RESULT_DISCONNECT;
768 if (state == pci_channel_io_frozen)
769 return PCI_ERS_RESULT_NEED_RESET;
770 return PCI_ERS_RESULT_CAN_RECOVER;
771}
772
773static pci_ers_result_t ngene_link_reset(struct pci_dev *dev)
774{
775 printk(KERN_INFO DEVICE_NAME ": link reset\n");
776 return 0;
777}
778
779static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev)
780{
781 printk(KERN_INFO DEVICE_NAME ": slot reset\n");
782 return 0;
783}
784
785static void ngene_resume(struct pci_dev *dev)
786{
787 printk(KERN_INFO DEVICE_NAME ": resume\n");
788}
789
1d352035 790static const struct pci_error_handlers ngene_errors = {
cbddcba6
DH
791 .error_detected = ngene_error_detected,
792 .link_reset = ngene_link_reset,
793 .slot_reset = ngene_slot_reset,
794 .resume = ngene_resume,
795};
796
797static struct pci_driver ngene_pci_driver = {
798 .name = "ngene",
799 .id_table = ngene_id_tbl,
800 .probe = ngene_probe,
801 .remove = __devexit_p(ngene_remove),
802 .err_handler = &ngene_errors,
1b7c41ef 803 .shutdown = ngene_shutdown,
cbddcba6
DH
804};
805
806static __init int module_init_ngene(void)
807{
808 printk(KERN_INFO
809 "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n");
810 return pci_register_driver(&ngene_pci_driver);
811}
812
813static __exit void module_exit_ngene(void)
814{
815 pci_unregister_driver(&ngene_pci_driver);
816}
817
818module_init(module_init_ngene);
819module_exit(module_exit_ngene);
820
821MODULE_DESCRIPTION("nGene");
822MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel");
823MODULE_LICENSE("GPL");
This page took 0.40521 seconds and 5 git commands to generate.