Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 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" |
| 43 | |
| 44 | |
| 45 | /****************************************************************************/ |
| 46 | /* Demod/tuner attachment ***************************************************/ |
| 47 | /****************************************************************************/ |
| 48 | |
| 49 | static int tuner_attach_stv6110(struct ngene_channel *chan) |
| 50 | { |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 51 | struct i2c_adapter *i2c; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 52 | struct stv090x_config *feconf = (struct stv090x_config *) |
| 53 | chan->dev->card_info->fe_config[chan->number]; |
| 54 | struct stv6110x_config *tunerconf = (struct stv6110x_config *) |
| 55 | chan->dev->card_info->tuner_config[chan->number]; |
| 56 | struct stv6110x_devctl *ctl; |
| 57 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 58 | /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ |
| 59 | if (chan->number < 2) |
| 60 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 61 | else |
| 62 | i2c = &chan->dev->channel[1].i2c_adapter; |
| 63 | |
| 64 | ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf, i2c); |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 65 | if (ctl == NULL) { |
| 66 | printk(KERN_ERR DEVICE_NAME ": No STV6110X found!\n"); |
| 67 | return -ENODEV; |
| 68 | } |
| 69 | |
| 70 | feconf->tuner_init = ctl->tuner_init; |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 71 | feconf->tuner_sleep = ctl->tuner_sleep; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 72 | feconf->tuner_set_mode = ctl->tuner_set_mode; |
| 73 | feconf->tuner_set_frequency = ctl->tuner_set_frequency; |
| 74 | feconf->tuner_get_frequency = ctl->tuner_get_frequency; |
| 75 | feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth; |
| 76 | feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth; |
| 77 | feconf->tuner_set_bbgain = ctl->tuner_set_bbgain; |
| 78 | feconf->tuner_get_bbgain = ctl->tuner_get_bbgain; |
| 79 | feconf->tuner_set_refclk = ctl->tuner_set_refclk; |
| 80 | feconf->tuner_get_status = ctl->tuner_get_status; |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | |
| 86 | static int demod_attach_stv0900(struct ngene_channel *chan) |
| 87 | { |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 88 | struct i2c_adapter *i2c; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 89 | struct stv090x_config *feconf = (struct stv090x_config *) |
| 90 | chan->dev->card_info->fe_config[chan->number]; |
| 91 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 92 | /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ |
| 93 | /* Note: Both adapters share the same i2c bus, but the demod */ |
| 94 | /* driver requires that each demod has its own i2c adapter */ |
| 95 | if (chan->number < 2) |
| 96 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 97 | else |
| 98 | i2c = &chan->dev->channel[1].i2c_adapter; |
| 99 | |
| 100 | chan->fe = dvb_attach(stv090x_attach, feconf, i2c, |
| 101 | (chan->number & 1) == 0 ? STV090x_DEMODULATOR_0 |
| 102 | : STV090x_DEMODULATOR_1); |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 103 | if (chan->fe == NULL) { |
| 104 | printk(KERN_ERR DEVICE_NAME ": No STV0900 found!\n"); |
| 105 | return -ENODEV; |
| 106 | } |
| 107 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 108 | /* store channel info */ |
| 109 | if (feconf->tuner_i2c_lock) |
| 110 | chan->fe->analog_demod_priv = chan; |
| 111 | |
| 112 | if (!dvb_attach(lnbh24_attach, chan->fe, i2c, 0, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 113 | 0, chan->dev->card_info->lnb[chan->number])) { |
| 114 | printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n"); |
| 115 | dvb_frontend_detach(chan->fe); |
| 116 | return -ENODEV; |
| 117 | } |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 122 | static void cineS2_tuner_i2c_lock(struct dvb_frontend *fe, int lock) |
| 123 | { |
| 124 | struct ngene_channel *chan = fe->analog_demod_priv; |
| 125 | |
| 126 | if (lock) |
| 127 | down(&chan->dev->pll_mutex); |
| 128 | else |
| 129 | up(&chan->dev->pll_mutex); |
| 130 | } |
| 131 | |
| 132 | static int cineS2_probe(struct ngene_channel *chan) |
| 133 | { |
| 134 | struct i2c_adapter *i2c; |
| 135 | struct stv090x_config *fe_conf; |
| 136 | u8 buf[3]; |
| 137 | struct i2c_msg i2c_msg = { .flags = 0, .buf = buf }; |
| 138 | int rc; |
| 139 | |
| 140 | /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ |
| 141 | if (chan->number < 2) |
| 142 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 143 | else |
| 144 | i2c = &chan->dev->channel[1].i2c_adapter; |
| 145 | |
| 146 | fe_conf = chan->dev->card_info->fe_config[chan->number]; |
| 147 | i2c_msg.addr = fe_conf->address; |
| 148 | |
| 149 | /* probe demod */ |
| 150 | i2c_msg.len = 2; |
| 151 | buf[0] = 0xf1; |
| 152 | buf[1] = 0x00; |
| 153 | rc = i2c_transfer(i2c, &i2c_msg, 1); |
| 154 | if (rc != 1) |
| 155 | return -ENODEV; |
| 156 | |
| 157 | /* demod found, attach it */ |
| 158 | rc = demod_attach_stv0900(chan); |
| 159 | if (rc < 0 || chan->number < 2) |
| 160 | return rc; |
| 161 | |
| 162 | /* demod #2: reprogram outputs DPN1 & DPN2 */ |
| 163 | i2c_msg.len = 3; |
| 164 | buf[0] = 0xf1; |
| 165 | switch (chan->number) { |
| 166 | case 2: |
| 167 | buf[1] = 0x5c; |
| 168 | buf[2] = 0xc2; |
| 169 | break; |
| 170 | case 3: |
| 171 | buf[1] = 0x61; |
| 172 | buf[2] = 0xcc; |
| 173 | break; |
| 174 | default: |
| 175 | return -ENODEV; |
| 176 | } |
| 177 | rc = i2c_transfer(i2c, &i2c_msg, 1); |
| 178 | if (rc != 1) { |
| 179 | printk(KERN_ERR DEVICE_NAME ": could not setup DPNx\n"); |
| 180 | return -EIO; |
| 181 | } |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 187 | static struct lgdt330x_config aver_m780 = { |
| 188 | .demod_address = 0xb2 >> 1, |
| 189 | .demod_chip = LGDT3303, |
| 190 | .serial_mpeg = 0x00, /* PARALLEL */ |
| 191 | .clock_polarity_flip = 1, |
| 192 | }; |
| 193 | |
| 194 | static struct mt2131_config m780_tunerconfig = { |
| 195 | 0xc0 >> 1 |
| 196 | }; |
| 197 | |
| 198 | /* A single func to attach the demo and tuner, rather than |
| 199 | * use two sep funcs like the current design mandates. |
| 200 | */ |
| 201 | static int demod_attach_lg330x(struct ngene_channel *chan) |
| 202 | { |
| 203 | chan->fe = dvb_attach(lgdt330x_attach, &aver_m780, &chan->i2c_adapter); |
| 204 | if (chan->fe == NULL) { |
| 205 | printk(KERN_ERR DEVICE_NAME ": No LGDT330x found!\n"); |
| 206 | return -ENODEV; |
| 207 | } |
| 208 | |
| 209 | dvb_attach(mt2131_attach, chan->fe, &chan->i2c_adapter, |
| 210 | &m780_tunerconfig, 0); |
| 211 | |
| 212 | return (chan->fe) ? 0 : -ENODEV; |
| 213 | } |
| 214 | |
| 215 | /****************************************************************************/ |
| 216 | /* Switch control (I2C gates, etc.) *****************************************/ |
| 217 | /****************************************************************************/ |
| 218 | |
| 219 | |
| 220 | static struct stv090x_config fe_cineS2 = { |
| 221 | .device = STV0900, |
| 222 | .demod_mode = STV090x_DUAL, |
| 223 | .clk_mode = STV090x_CLK_EXT, |
| 224 | |
| 225 | .xtal = 27000000, |
| 226 | .address = 0x68, |
| 227 | |
| 228 | .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 229 | .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 230 | |
| 231 | .repeater_level = STV090x_RPTLEVEL_16, |
| 232 | |
| 233 | .adc1_range = STV090x_ADC_1Vpp, |
| 234 | .adc2_range = STV090x_ADC_1Vpp, |
| 235 | |
| 236 | .diseqc_envelope_mode = true, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 237 | |
| 238 | .tuner_i2c_lock = cineS2_tuner_i2c_lock, |
| 239 | }; |
| 240 | |
| 241 | static struct stv090x_config fe_cineS2_2 = { |
| 242 | .device = STV0900, |
| 243 | .demod_mode = STV090x_DUAL, |
| 244 | .clk_mode = STV090x_CLK_EXT, |
| 245 | |
| 246 | .xtal = 27000000, |
| 247 | .address = 0x69, |
| 248 | |
| 249 | .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 250 | .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 251 | |
| 252 | .repeater_level = STV090x_RPTLEVEL_16, |
| 253 | |
| 254 | .adc1_range = STV090x_ADC_1Vpp, |
| 255 | .adc2_range = STV090x_ADC_1Vpp, |
| 256 | |
| 257 | .diseqc_envelope_mode = true, |
| 258 | |
| 259 | .tuner_i2c_lock = cineS2_tuner_i2c_lock, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | static struct stv6110x_config tuner_cineS2_0 = { |
| 263 | .addr = 0x60, |
| 264 | .refclk = 27000000, |
| 265 | .clk_div = 1, |
| 266 | }; |
| 267 | |
| 268 | static struct stv6110x_config tuner_cineS2_1 = { |
| 269 | .addr = 0x63, |
| 270 | .refclk = 27000000, |
| 271 | .clk_div = 1, |
| 272 | }; |
| 273 | |
| 274 | static struct ngene_info ngene_info_cineS2 = { |
| 275 | .type = NGENE_SIDEWINDER, |
| 276 | .name = "Linux4Media cineS2 DVB-S2 Twin Tuner", |
| 277 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 278 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, |
| 279 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, |
| 280 | .fe_config = {&fe_cineS2, &fe_cineS2}, |
| 281 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, |
| 282 | .lnb = {0x0b, 0x08}, |
| 283 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 284 | .fw_version = 18, |
| 285 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | static struct ngene_info ngene_info_satixS2 = { |
| 289 | .type = NGENE_SIDEWINDER, |
| 290 | .name = "Mystique SaTiX-S2 Dual", |
| 291 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 292 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, |
| 293 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, |
| 294 | .fe_config = {&fe_cineS2, &fe_cineS2}, |
| 295 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, |
| 296 | .lnb = {0x0b, 0x08}, |
| 297 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 298 | .fw_version = 18, |
| 299 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | static struct ngene_info ngene_info_satixS2v2 = { |
| 303 | .type = NGENE_SIDEWINDER, |
| 304 | .name = "Mystique SaTiX-S2 Dual (v2)", |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 305 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 306 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, |
| 307 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110}, |
| 308 | .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, |
| 309 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, |
| 310 | .lnb = {0x0a, 0x08, 0x0b, 0x09}, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 311 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 312 | .fw_version = 18, |
| 313 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 314 | }; |
| 315 | |
| 316 | static struct ngene_info ngene_info_cineS2v5 = { |
| 317 | .type = NGENE_SIDEWINDER, |
| 318 | .name = "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)", |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 319 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 320 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, |
| 321 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110}, |
| 322 | .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, |
| 323 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, |
| 324 | .lnb = {0x0a, 0x08, 0x0b, 0x09}, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 325 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 326 | .fw_version = 18, |
| 327 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 328 | }; |
| 329 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 330 | |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 331 | static struct ngene_info ngene_info_duoFlexS2 = { |
| 332 | .type = NGENE_SIDEWINDER, |
| 333 | .name = "Digital Devices DuoFlex S2 miniPCIe", |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 334 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 335 | .demod_attach = {cineS2_probe, cineS2_probe, cineS2_probe, cineS2_probe}, |
| 336 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110}, |
| 337 | .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, |
| 338 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, |
| 339 | .lnb = {0x0a, 0x08, 0x0b, 0x09}, |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 340 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame^] | 341 | .fw_version = 18, |
| 342 | .msi_supported = true, |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 343 | }; |
| 344 | |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 345 | static struct ngene_info ngene_info_m780 = { |
| 346 | .type = NGENE_APP, |
| 347 | .name = "Aver M780 ATSC/QAM-B", |
| 348 | |
| 349 | /* Channel 0 is analog, which is currently unsupported */ |
| 350 | .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN }, |
| 351 | .demod_attach = { NULL, demod_attach_lg330x }, |
| 352 | |
| 353 | /* Ensure these are NULL else the frame will call them (as funcs) */ |
| 354 | .tuner_attach = { 0, 0, 0, 0 }, |
| 355 | .fe_config = { NULL, &aver_m780 }, |
| 356 | .avf = { 0 }, |
| 357 | |
| 358 | /* A custom electrical interface config for the demod to bridge */ |
| 359 | .tsf = { 4, 4 }, |
| 360 | .fw_version = 15, |
| 361 | }; |
| 362 | |
| 363 | /****************************************************************************/ |
| 364 | |
| 365 | |
| 366 | |
| 367 | /****************************************************************************/ |
| 368 | /* PCI Subsystem ID *********************************************************/ |
| 369 | /****************************************************************************/ |
| 370 | |
| 371 | #define NGENE_ID(_subvend, _subdev, _driverdata) { \ |
| 372 | .vendor = NGENE_VID, .device = NGENE_PID, \ |
| 373 | .subvendor = _subvend, .subdevice = _subdev, \ |
| 374 | .driver_data = (unsigned long) &_driverdata } |
| 375 | |
| 376 | /****************************************************************************/ |
| 377 | |
| 378 | static const struct pci_device_id ngene_id_tbl[] __devinitdata = { |
| 379 | NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2), |
| 380 | NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2), |
| 381 | NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2), |
| 382 | NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2), |
| 383 | NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5), |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 384 | NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlexS2), |
| 385 | NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlexS2), |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 386 | NGENE_ID(0x1461, 0x062e, ngene_info_m780), |
| 387 | {0} |
| 388 | }; |
| 389 | MODULE_DEVICE_TABLE(pci, ngene_id_tbl); |
| 390 | |
| 391 | /****************************************************************************/ |
| 392 | /* Init/Exit ****************************************************************/ |
| 393 | /****************************************************************************/ |
| 394 | |
| 395 | static pci_ers_result_t ngene_error_detected(struct pci_dev *dev, |
| 396 | enum pci_channel_state state) |
| 397 | { |
| 398 | printk(KERN_ERR DEVICE_NAME ": PCI error\n"); |
| 399 | if (state == pci_channel_io_perm_failure) |
| 400 | return PCI_ERS_RESULT_DISCONNECT; |
| 401 | if (state == pci_channel_io_frozen) |
| 402 | return PCI_ERS_RESULT_NEED_RESET; |
| 403 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 404 | } |
| 405 | |
| 406 | static pci_ers_result_t ngene_link_reset(struct pci_dev *dev) |
| 407 | { |
| 408 | printk(KERN_INFO DEVICE_NAME ": link reset\n"); |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev) |
| 413 | { |
| 414 | printk(KERN_INFO DEVICE_NAME ": slot reset\n"); |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | static void ngene_resume(struct pci_dev *dev) |
| 419 | { |
| 420 | printk(KERN_INFO DEVICE_NAME ": resume\n"); |
| 421 | } |
| 422 | |
| 423 | static struct pci_error_handlers ngene_errors = { |
| 424 | .error_detected = ngene_error_detected, |
| 425 | .link_reset = ngene_link_reset, |
| 426 | .slot_reset = ngene_slot_reset, |
| 427 | .resume = ngene_resume, |
| 428 | }; |
| 429 | |
| 430 | static struct pci_driver ngene_pci_driver = { |
| 431 | .name = "ngene", |
| 432 | .id_table = ngene_id_tbl, |
| 433 | .probe = ngene_probe, |
| 434 | .remove = __devexit_p(ngene_remove), |
| 435 | .err_handler = &ngene_errors, |
| 436 | }; |
| 437 | |
| 438 | static __init int module_init_ngene(void) |
| 439 | { |
| 440 | printk(KERN_INFO |
| 441 | "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n"); |
| 442 | return pci_register_driver(&ngene_pci_driver); |
| 443 | } |
| 444 | |
| 445 | static __exit void module_exit_ngene(void) |
| 446 | { |
| 447 | pci_unregister_driver(&ngene_pci_driver); |
| 448 | } |
| 449 | |
| 450 | module_init(module_init_ngene); |
| 451 | module_exit(module_exit_ngene); |
| 452 | |
| 453 | MODULE_DESCRIPTION("nGene"); |
| 454 | MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel"); |
| 455 | MODULE_LICENSE("GPL"); |