2 * ngene-cards.c: nGene PCIe bridge driver - card specific info
4 * Copyright (C) 2005-2007 Micronas
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
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.
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.
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
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
30 #include <linux/module.h>
31 #include <linux/init.h>
32 #include <linux/pci.h>
33 #include <linux/pci_ids.h>
45 /****************************************************************************/
46 /* Demod/tuner attachment ***************************************************/
47 /****************************************************************************/
49 static int tuner_attach_stv6110(struct ngene_channel
*chan
)
51 struct stv090x_config
*feconf
= (struct stv090x_config
*)
52 chan
->dev
->card_info
->fe_config
[chan
->number
];
53 struct stv6110x_config
*tunerconf
= (struct stv6110x_config
*)
54 chan
->dev
->card_info
->tuner_config
[chan
->number
];
55 struct stv6110x_devctl
*ctl
;
57 ctl
= dvb_attach(stv6110x_attach
, chan
->fe
, tunerconf
,
60 printk(KERN_ERR DEVICE_NAME
": No STV6110X found!\n");
64 feconf
->tuner_init
= ctl
->tuner_init
;
65 feconf
->tuner_set_mode
= ctl
->tuner_set_mode
;
66 feconf
->tuner_set_frequency
= ctl
->tuner_set_frequency
;
67 feconf
->tuner_get_frequency
= ctl
->tuner_get_frequency
;
68 feconf
->tuner_set_bandwidth
= ctl
->tuner_set_bandwidth
;
69 feconf
->tuner_get_bandwidth
= ctl
->tuner_get_bandwidth
;
70 feconf
->tuner_set_bbgain
= ctl
->tuner_set_bbgain
;
71 feconf
->tuner_get_bbgain
= ctl
->tuner_get_bbgain
;
72 feconf
->tuner_set_refclk
= ctl
->tuner_set_refclk
;
73 feconf
->tuner_get_status
= ctl
->tuner_get_status
;
79 static int demod_attach_stv0900(struct ngene_channel
*chan
)
81 struct stv090x_config
*feconf
= (struct stv090x_config
*)
82 chan
->dev
->card_info
->fe_config
[chan
->number
];
84 chan
->fe
= dvb_attach(stv090x_attach
,
87 chan
->number
== 0 ? STV090x_DEMODULATOR_0
:
88 STV090x_DEMODULATOR_1
);
89 if (chan
->fe
== NULL
) {
90 printk(KERN_ERR DEVICE_NAME
": No STV0900 found!\n");
94 if (!dvb_attach(lnbh24_attach
, chan
->fe
, &chan
->i2c_adapter
, 0,
95 0, chan
->dev
->card_info
->lnb
[chan
->number
])) {
96 printk(KERN_ERR DEVICE_NAME
": No LNBH24 found!\n");
97 dvb_frontend_detach(chan
->fe
);
104 static struct lgdt330x_config aver_m780
= {
105 .demod_address
= 0xb2 >> 1,
106 .demod_chip
= LGDT3303
,
107 .serial_mpeg
= 0x00, /* PARALLEL */
108 .clock_polarity_flip
= 1,
111 static struct mt2131_config m780_tunerconfig
= {
115 /* A single func to attach the demo and tuner, rather than
116 * use two sep funcs like the current design mandates.
118 static int demod_attach_lg330x(struct ngene_channel
*chan
)
120 chan
->fe
= dvb_attach(lgdt330x_attach
, &aver_m780
, &chan
->i2c_adapter
);
121 if (chan
->fe
== NULL
) {
122 printk(KERN_ERR DEVICE_NAME
": No LGDT330x found!\n");
126 dvb_attach(mt2131_attach
, chan
->fe
, &chan
->i2c_adapter
,
127 &m780_tunerconfig
, 0);
129 return (chan
->fe
) ? 0 : -ENODEV
;
132 /****************************************************************************/
133 /* Switch control (I2C gates, etc.) *****************************************/
134 /****************************************************************************/
137 static struct stv090x_config fe_cineS2
= {
139 .demod_mode
= STV090x_DUAL
,
140 .clk_mode
= STV090x_CLK_EXT
,
145 .ts1_mode
= STV090x_TSMODE_SERIAL_PUNCTURED
,
146 .ts2_mode
= STV090x_TSMODE_SERIAL_PUNCTURED
,
148 .repeater_level
= STV090x_RPTLEVEL_16
,
150 .adc1_range
= STV090x_ADC_1Vpp
,
151 .adc2_range
= STV090x_ADC_1Vpp
,
153 .diseqc_envelope_mode
= true,
156 static struct stv6110x_config tuner_cineS2_0
= {
162 static struct stv6110x_config tuner_cineS2_1
= {
168 static struct ngene_info ngene_info_cineS2
= {
169 .type
= NGENE_SIDEWINDER
,
170 .name
= "Linux4Media cineS2 DVB-S2 Twin Tuner",
171 .io_type
= {NGENE_IO_TSIN
, NGENE_IO_TSIN
},
172 .demod_attach
= {demod_attach_stv0900
, demod_attach_stv0900
},
173 .tuner_attach
= {tuner_attach_stv6110
, tuner_attach_stv6110
},
174 .fe_config
= {&fe_cineS2
, &fe_cineS2
},
175 .tuner_config
= {&tuner_cineS2_0
, &tuner_cineS2_1
},
181 static struct ngene_info ngene_info_satixS2
= {
182 .type
= NGENE_SIDEWINDER
,
183 .name
= "Mystique SaTiX-S2 Dual",
184 .io_type
= {NGENE_IO_TSIN
, NGENE_IO_TSIN
},
185 .demod_attach
= {demod_attach_stv0900
, demod_attach_stv0900
},
186 .tuner_attach
= {tuner_attach_stv6110
, tuner_attach_stv6110
},
187 .fe_config
= {&fe_cineS2
, &fe_cineS2
},
188 .tuner_config
= {&tuner_cineS2_0
, &tuner_cineS2_1
},
194 static struct ngene_info ngene_info_satixS2v2
= {
195 .type
= NGENE_SIDEWINDER
,
196 .name
= "Mystique SaTiX-S2 Dual (v2)",
197 .io_type
= {NGENE_IO_TSIN
, NGENE_IO_TSIN
},
198 .demod_attach
= {demod_attach_stv0900
, demod_attach_stv0900
},
199 .tuner_attach
= {tuner_attach_stv6110
, tuner_attach_stv6110
},
200 .fe_config
= {&fe_cineS2
, &fe_cineS2
},
201 .tuner_config
= {&tuner_cineS2_0
, &tuner_cineS2_1
},
207 static struct ngene_info ngene_info_cineS2v5
= {
208 .type
= NGENE_SIDEWINDER
,
209 .name
= "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)",
210 .io_type
= {NGENE_IO_TSIN
, NGENE_IO_TSIN
},
211 .demod_attach
= {demod_attach_stv0900
, demod_attach_stv0900
},
212 .tuner_attach
= {tuner_attach_stv6110
, tuner_attach_stv6110
},
213 .fe_config
= {&fe_cineS2
, &fe_cineS2
},
214 .tuner_config
= {&tuner_cineS2_0
, &tuner_cineS2_1
},
220 static struct ngene_info ngene_info_duoFlexS2
= {
221 .type
= NGENE_SIDEWINDER
,
222 .name
= "Digital Devices DuoFlex S2 miniPCIe",
223 .io_type
= {NGENE_IO_TSIN
, NGENE_IO_TSIN
},
224 .demod_attach
= {demod_attach_stv0900
, demod_attach_stv0900
},
225 .tuner_attach
= {tuner_attach_stv6110
, tuner_attach_stv6110
},
226 .fe_config
= {&fe_cineS2
, &fe_cineS2
},
227 .tuner_config
= {&tuner_cineS2_0
, &tuner_cineS2_1
},
233 static struct ngene_info ngene_info_m780
= {
235 .name
= "Aver M780 ATSC/QAM-B",
237 /* Channel 0 is analog, which is currently unsupported */
238 .io_type
= { NGENE_IO_NONE
, NGENE_IO_TSIN
},
239 .demod_attach
= { NULL
, demod_attach_lg330x
},
241 /* Ensure these are NULL else the frame will call them (as funcs) */
242 .tuner_attach
= { 0, 0, 0, 0 },
243 .fe_config
= { NULL
, &aver_m780
},
246 /* A custom electrical interface config for the demod to bridge */
251 /****************************************************************************/
255 /****************************************************************************/
256 /* PCI Subsystem ID *********************************************************/
257 /****************************************************************************/
259 #define NGENE_ID(_subvend, _subdev, _driverdata) { \
260 .vendor = NGENE_VID, .device = NGENE_PID, \
261 .subvendor = _subvend, .subdevice = _subdev, \
262 .driver_data = (unsigned long) &_driverdata }
264 /****************************************************************************/
266 static const struct pci_device_id ngene_id_tbl
[] __devinitdata
= {
267 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2
),
268 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2
),
269 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2
),
270 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2
),
271 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5
),
272 NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlexS2
),
273 NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlexS2
),
274 NGENE_ID(0x1461, 0x062e, ngene_info_m780
),
277 MODULE_DEVICE_TABLE(pci
, ngene_id_tbl
);
279 /****************************************************************************/
280 /* Init/Exit ****************************************************************/
281 /****************************************************************************/
283 static pci_ers_result_t
ngene_error_detected(struct pci_dev
*dev
,
284 enum pci_channel_state state
)
286 printk(KERN_ERR DEVICE_NAME
": PCI error\n");
287 if (state
== pci_channel_io_perm_failure
)
288 return PCI_ERS_RESULT_DISCONNECT
;
289 if (state
== pci_channel_io_frozen
)
290 return PCI_ERS_RESULT_NEED_RESET
;
291 return PCI_ERS_RESULT_CAN_RECOVER
;
294 static pci_ers_result_t
ngene_link_reset(struct pci_dev
*dev
)
296 printk(KERN_INFO DEVICE_NAME
": link reset\n");
300 static pci_ers_result_t
ngene_slot_reset(struct pci_dev
*dev
)
302 printk(KERN_INFO DEVICE_NAME
": slot reset\n");
306 static void ngene_resume(struct pci_dev
*dev
)
308 printk(KERN_INFO DEVICE_NAME
": resume\n");
311 static struct pci_error_handlers ngene_errors
= {
312 .error_detected
= ngene_error_detected
,
313 .link_reset
= ngene_link_reset
,
314 .slot_reset
= ngene_slot_reset
,
315 .resume
= ngene_resume
,
318 static struct pci_driver ngene_pci_driver
= {
320 .id_table
= ngene_id_tbl
,
321 .probe
= ngene_probe
,
322 .remove
= __devexit_p(ngene_remove
),
323 .err_handler
= &ngene_errors
,
326 static __init
int module_init_ngene(void)
329 "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n");
330 return pci_register_driver(&ngene_pci_driver
);
333 static __exit
void module_exit_ngene(void)
335 pci_unregister_driver(&ngene_pci_driver
);
338 module_init(module_init_ngene
);
339 module_exit(module_exit_ngene
);
341 MODULE_DESCRIPTION("nGene");
342 MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel");
343 MODULE_LICENSE("GPL");