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 * To obtain the license, point your browser to 23 * http://www.gnu.org/copyleft/gpl.html 24 */ 25 26 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 27 28 #include <linux/module.h> 29 #include <linux/init.h> 30 #include <linux/pci.h> 31 #include <linux/pci_ids.h> 32 33 #include "ngene.h" 34 35 /* demods/tuners */ 36 #include "stv6110x.h" 37 #include "stv090x.h" 38 #include "lnbh24.h" 39 #include "lgdt330x.h" 40 #include "mt2131.h" 41 #include "tda18271c2dd.h" 42 #include "drxk.h" 43 #include "drxd.h" 44 #include "dvb-pll.h" 45 #include "stv0367.h" 46 #include "stv0367_priv.h" 47 #include "tda18212.h" 48 #include "cxd2841er.h" 49 #include "stv0910.h" 50 #include "stv6111.h" 51 #include "lnbh25.h" 52 53 /****************************************************************************/ 54 /* I2C transfer functions used for demod/tuner probing***********************/ 55 /****************************************************************************/ 56 57 static int i2c_io(struct i2c_adapter *adapter, u8 adr, 58 u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen) 59 { 60 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0, 61 .buf = wbuf, .len = wlen }, 62 {.addr = adr, .flags = I2C_M_RD, 63 .buf = rbuf, .len = rlen } }; 64 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1; 65 } 66 67 static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) 68 { 69 struct i2c_msg msg = {.addr = adr, .flags = 0, 70 .buf = data, .len = len}; 71 72 return (i2c_transfer(adap, &msg, 1) == 1) ? 0 : -1; 73 } 74 75 static int i2c_write_reg(struct i2c_adapter *adap, u8 adr, 76 u8 reg, u8 val) 77 { 78 u8 msg[2] = {reg, val}; 79 80 return i2c_write(adap, adr, msg, 2); 81 } 82 83 static int i2c_read(struct i2c_adapter *adapter, u8 adr, u8 *val) 84 { 85 struct i2c_msg msgs[1] = {{.addr = adr, .flags = I2C_M_RD, 86 .buf = val, .len = 1 } }; 87 return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1; 88 } 89 90 static int i2c_read_reg16(struct i2c_adapter *adapter, u8 adr, 91 u16 reg, u8 *val) 92 { 93 u8 msg[2] = {reg >> 8, reg & 0xff}; 94 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0, 95 .buf = msg, .len = 2}, 96 {.addr = adr, .flags = I2C_M_RD, 97 .buf = val, .len = 1} }; 98 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1; 99 } 100 101 static int i2c_read_regs(struct i2c_adapter *adapter, 102 u8 adr, u8 reg, u8 *val, u8 len) 103 { 104 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0, 105 .buf = ®, .len = 1}, 106 {.addr = adr, .flags = I2C_M_RD, 107 .buf = val, .len = len} }; 108 109 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1; 110 } 111 112 static int i2c_read_reg(struct i2c_adapter *adapter, u8 adr, u8 reg, u8 *val) 113 { 114 return i2c_read_regs(adapter, adr, reg, val, 1); 115 } 116 117 /****************************************************************************/ 118 /* Demod/tuner attachment ***************************************************/ 119 /****************************************************************************/ 120 121 static struct i2c_adapter *i2c_adapter_from_chan(struct ngene_channel *chan) 122 { 123 /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ 124 if (chan->number < 2) 125 return &chan->dev->channel[0].i2c_adapter; 126 127 return &chan->dev->channel[1].i2c_adapter; 128 } 129 130 static int tuner_attach_stv6110(struct ngene_channel *chan) 131 { 132 struct device *pdev = &chan->dev->pci_dev->dev; 133 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 134 struct stv090x_config *feconf = (struct stv090x_config *) 135 chan->dev->card_info->fe_config[chan->number]; 136 struct stv6110x_config *tunerconf = (struct stv6110x_config *) 137 chan->dev->card_info->tuner_config[chan->number]; 138 const struct stv6110x_devctl *ctl; 139 140 ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf, i2c); 141 if (ctl == NULL) { 142 dev_err(pdev, "No STV6110X found!\n"); 143 return -ENODEV; 144 } 145 146 feconf->tuner_init = ctl->tuner_init; 147 feconf->tuner_sleep = ctl->tuner_sleep; 148 feconf->tuner_set_mode = ctl->tuner_set_mode; 149 feconf->tuner_set_frequency = ctl->tuner_set_frequency; 150 feconf->tuner_get_frequency = ctl->tuner_get_frequency; 151 feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth; 152 feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth; 153 feconf->tuner_set_bbgain = ctl->tuner_set_bbgain; 154 feconf->tuner_get_bbgain = ctl->tuner_get_bbgain; 155 feconf->tuner_set_refclk = ctl->tuner_set_refclk; 156 feconf->tuner_get_status = ctl->tuner_get_status; 157 158 return 0; 159 } 160 161 static int tuner_attach_stv6111(struct ngene_channel *chan) 162 { 163 struct device *pdev = &chan->dev->pci_dev->dev; 164 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 165 struct dvb_frontend *fe; 166 u8 adr = 4 + ((chan->number & 1) ? 0x63 : 0x60); 167 168 fe = dvb_attach(stv6111_attach, chan->fe, i2c, adr); 169 if (!fe) { 170 fe = dvb_attach(stv6111_attach, chan->fe, i2c, adr & ~4); 171 if (!fe) { 172 dev_err(pdev, "stv6111_attach() failed!\n"); 173 return -ENODEV; 174 } 175 } 176 return 0; 177 } 178 179 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) 180 { 181 struct ngene_channel *chan = fe->sec_priv; 182 int status; 183 184 if (enable) { 185 down(&chan->dev->pll_mutex); 186 status = chan->gate_ctrl(fe, 1); 187 } else { 188 status = chan->gate_ctrl(fe, 0); 189 up(&chan->dev->pll_mutex); 190 } 191 return status; 192 } 193 194 static int tuner_attach_tda18271(struct ngene_channel *chan) 195 { 196 struct device *pdev = &chan->dev->pci_dev->dev; 197 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 198 struct dvb_frontend *fe; 199 200 if (chan->fe->ops.i2c_gate_ctrl) 201 chan->fe->ops.i2c_gate_ctrl(chan->fe, 1); 202 fe = dvb_attach(tda18271c2dd_attach, chan->fe, i2c, 0x60); 203 if (chan->fe->ops.i2c_gate_ctrl) 204 chan->fe->ops.i2c_gate_ctrl(chan->fe, 0); 205 if (!fe) { 206 dev_err(pdev, "No TDA18271 found!\n"); 207 return -ENODEV; 208 } 209 210 return 0; 211 } 212 213 static int tuner_tda18212_ping(struct ngene_channel *chan, 214 struct i2c_adapter *i2c, 215 unsigned short adr) 216 { 217 struct device *pdev = &chan->dev->pci_dev->dev; 218 u8 tda_id[2]; 219 u8 subaddr = 0x00; 220 221 dev_dbg(pdev, "stv0367-tda18212 tuner ping\n"); 222 if (chan->fe->ops.i2c_gate_ctrl) 223 chan->fe->ops.i2c_gate_ctrl(chan->fe, 1); 224 225 if (i2c_read_regs(i2c, adr, subaddr, tda_id, sizeof(tda_id)) < 0) 226 dev_dbg(pdev, "tda18212 ping 1 fail\n"); 227 if (i2c_read_regs(i2c, adr, subaddr, tda_id, sizeof(tda_id)) < 0) 228 dev_warn(pdev, "tda18212 ping failed, expect problems\n"); 229 230 if (chan->fe->ops.i2c_gate_ctrl) 231 chan->fe->ops.i2c_gate_ctrl(chan->fe, 0); 232 233 return 0; 234 } 235 236 static int tuner_attach_tda18212(struct ngene_channel *chan, u32 dmdtype) 237 { 238 struct device *pdev = &chan->dev->pci_dev->dev; 239 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 240 struct i2c_client *client; 241 struct tda18212_config config = { 242 .fe = chan->fe, 243 .if_dvbt_6 = 3550, 244 .if_dvbt_7 = 3700, 245 .if_dvbt_8 = 4150, 246 .if_dvbt2_6 = 3250, 247 .if_dvbt2_7 = 4000, 248 .if_dvbt2_8 = 4000, 249 .if_dvbc = 5000, 250 }; 251 u8 addr = (chan->number & 1) ? 0x63 : 0x60; 252 253 /* 254 * due to a hardware quirk with the I2C gate on the stv0367+tda18212 255 * combo, the tda18212 must be probed by reading it's id _twice_ when 256 * cold started, or it very likely will fail. 257 */ 258 if (dmdtype == DEMOD_TYPE_STV0367) 259 tuner_tda18212_ping(chan, i2c, addr); 260 261 /* perform tuner probe/init/attach */ 262 client = dvb_module_probe("tda18212", NULL, i2c, addr, &config); 263 if (!client) 264 goto err; 265 266 chan->i2c_client[0] = client; 267 chan->i2c_client_fe = 1; 268 269 return 0; 270 err: 271 dev_err(pdev, "TDA18212 tuner not found. Device is not fully operational.\n"); 272 return -ENODEV; 273 } 274 275 static int tuner_attach_probe(struct ngene_channel *chan) 276 { 277 switch (chan->demod_type) { 278 case DEMOD_TYPE_STV090X: 279 return tuner_attach_stv6110(chan); 280 case DEMOD_TYPE_DRXK: 281 return tuner_attach_tda18271(chan); 282 case DEMOD_TYPE_STV0367: 283 case DEMOD_TYPE_SONY_CT2: 284 case DEMOD_TYPE_SONY_ISDBT: 285 case DEMOD_TYPE_SONY_C2T2: 286 case DEMOD_TYPE_SONY_C2T2I: 287 return tuner_attach_tda18212(chan, chan->demod_type); 288 case DEMOD_TYPE_STV0910: 289 return tuner_attach_stv6111(chan); 290 } 291 292 return -EINVAL; 293 } 294 295 static int demod_attach_stv0900(struct ngene_channel *chan) 296 { 297 struct device *pdev = &chan->dev->pci_dev->dev; 298 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 299 struct stv090x_config *feconf = (struct stv090x_config *) 300 chan->dev->card_info->fe_config[chan->number]; 301 302 chan->fe = dvb_attach(stv090x_attach, feconf, i2c, 303 (chan->number & 1) == 0 ? STV090x_DEMODULATOR_0 304 : STV090x_DEMODULATOR_1); 305 if (chan->fe == NULL) { 306 dev_err(pdev, "No STV0900 found!\n"); 307 return -ENODEV; 308 } 309 310 /* store channel info */ 311 if (feconf->tuner_i2c_lock) 312 chan->fe->analog_demod_priv = chan; 313 314 if (!dvb_attach(lnbh24_attach, chan->fe, i2c, 0, 315 0, chan->dev->card_info->lnb[chan->number])) { 316 dev_err(pdev, "No LNBH24 found!\n"); 317 dvb_frontend_detach(chan->fe); 318 chan->fe = NULL; 319 return -ENODEV; 320 } 321 322 return 0; 323 } 324 325 static struct stv0910_cfg stv0910_p = { 326 .adr = 0x68, 327 .parallel = 1, 328 .rptlvl = 4, 329 .clk = 30000000, 330 .tsspeed = 0x28, 331 }; 332 333 static struct lnbh25_config lnbh25_cfg = { 334 .i2c_address = 0x0c << 1, 335 .data2_config = LNBH25_TEN 336 }; 337 338 static int demod_attach_stv0910(struct ngene_channel *chan, 339 struct i2c_adapter *i2c) 340 { 341 struct device *pdev = &chan->dev->pci_dev->dev; 342 struct stv0910_cfg cfg = stv0910_p; 343 struct lnbh25_config lnbcfg = lnbh25_cfg; 344 345 chan->fe = dvb_attach(stv0910_attach, i2c, &cfg, (chan->number & 1)); 346 if (!chan->fe) { 347 cfg.adr = 0x6c; 348 chan->fe = dvb_attach(stv0910_attach, i2c, 349 &cfg, (chan->number & 1)); 350 } 351 if (!chan->fe) { 352 dev_err(pdev, "stv0910_attach() failed!\n"); 353 return -ENODEV; 354 } 355 356 /* 357 * attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit 358 * i2c addresses 359 */ 360 lnbcfg.i2c_address = (((chan->number & 1) ? 0x0d : 0x0c) << 1); 361 if (!dvb_attach(lnbh25_attach, chan->fe, &lnbcfg, i2c)) { 362 lnbcfg.i2c_address = (((chan->number & 1) ? 0x09 : 0x08) << 1); 363 if (!dvb_attach(lnbh25_attach, chan->fe, &lnbcfg, i2c)) { 364 dev_err(pdev, "lnbh25_attach() failed!\n"); 365 dvb_frontend_detach(chan->fe); 366 chan->fe = NULL; 367 return -ENODEV; 368 } 369 } 370 371 return 0; 372 } 373 374 static struct stv0367_config ddb_stv0367_config[] = { 375 { 376 .demod_address = 0x1f, 377 .xtal = 27000000, 378 .if_khz = 0, 379 .if_iq_mode = FE_TER_NORMAL_IF_TUNER, 380 .ts_mode = STV0367_SERIAL_PUNCT_CLOCK, 381 .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT, 382 }, { 383 .demod_address = 0x1e, 384 .xtal = 27000000, 385 .if_khz = 0, 386 .if_iq_mode = FE_TER_NORMAL_IF_TUNER, 387 .ts_mode = STV0367_SERIAL_PUNCT_CLOCK, 388 .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT, 389 }, 390 }; 391 392 static int demod_attach_stv0367(struct ngene_channel *chan, 393 struct i2c_adapter *i2c) 394 { 395 struct device *pdev = &chan->dev->pci_dev->dev; 396 397 chan->fe = dvb_attach(stv0367ddb_attach, 398 &ddb_stv0367_config[(chan->number & 1)], i2c); 399 400 if (!chan->fe) { 401 dev_err(pdev, "stv0367ddb_attach() failed!\n"); 402 return -ENODEV; 403 } 404 405 chan->fe->sec_priv = chan; 406 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; 407 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 408 return 0; 409 } 410 411 static int demod_attach_cxd28xx(struct ngene_channel *chan, 412 struct i2c_adapter *i2c, int osc24) 413 { 414 struct device *pdev = &chan->dev->pci_dev->dev; 415 struct cxd2841er_config cfg; 416 417 /* the cxd2841er driver expects 8bit/shifted I2C addresses */ 418 cfg.i2c_addr = ((chan->number & 1) ? 0x6d : 0x6c) << 1; 419 420 cfg.xtal = osc24 ? SONY_XTAL_24000 : SONY_XTAL_20500; 421 cfg.flags = CXD2841ER_AUTO_IFHZ | CXD2841ER_EARLY_TUNE | 422 CXD2841ER_NO_WAIT_LOCK | CXD2841ER_NO_AGCNEG | 423 CXD2841ER_TSBITS | CXD2841ER_TS_SERIAL; 424 425 /* attach frontend */ 426 chan->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); 427 428 if (!chan->fe) { 429 dev_err(pdev, "CXD28XX attach failed!\n"); 430 return -ENODEV; 431 } 432 433 chan->fe->sec_priv = chan; 434 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; 435 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 436 return 0; 437 } 438 439 static void cineS2_tuner_i2c_lock(struct dvb_frontend *fe, int lock) 440 { 441 struct ngene_channel *chan = fe->analog_demod_priv; 442 443 if (lock) 444 down(&chan->dev->pll_mutex); 445 else 446 up(&chan->dev->pll_mutex); 447 } 448 449 static int port_has_stv0900(struct i2c_adapter *i2c, int port) 450 { 451 u8 val; 452 if (i2c_read_reg16(i2c, 0x68+port/2, 0xf100, &val) < 0) 453 return 0; 454 return 1; 455 } 456 457 static int port_has_drxk(struct i2c_adapter *i2c, int port) 458 { 459 u8 val; 460 461 if (i2c_read(i2c, 0x29+port, &val) < 0) 462 return 0; 463 return 1; 464 } 465 466 static int port_has_stv0367(struct i2c_adapter *i2c) 467 { 468 u8 val; 469 470 if (i2c_read_reg16(i2c, 0x1e, 0xf000, &val) < 0) 471 return 0; 472 if (val != 0x60) 473 return 0; 474 if (i2c_read_reg16(i2c, 0x1f, 0xf000, &val) < 0) 475 return 0; 476 if (val != 0x60) 477 return 0; 478 return 1; 479 } 480 481 int ngene_port_has_cxd2099(struct i2c_adapter *i2c, u8 *type) 482 { 483 u8 val; 484 u8 probe[4] = { 0xe0, 0x00, 0x00, 0x00 }, data[4]; 485 struct i2c_msg msgs[2] = {{ .addr = 0x40, .flags = 0, 486 .buf = probe, .len = 4 }, 487 { .addr = 0x40, .flags = I2C_M_RD, 488 .buf = data, .len = 4 } }; 489 val = i2c_transfer(i2c, msgs, 2); 490 if (val != 2) 491 return 0; 492 493 if (data[0] == 0x02 && data[1] == 0x2b && data[3] == 0x43) 494 *type = 2; 495 else 496 *type = 1; 497 return 1; 498 } 499 500 static int demod_attach_drxk(struct ngene_channel *chan, 501 struct i2c_adapter *i2c) 502 { 503 struct device *pdev = &chan->dev->pci_dev->dev; 504 struct drxk_config config; 505 506 memset(&config, 0, sizeof(config)); 507 config.microcode_name = "drxk_a3.mc"; 508 config.qam_demod_parameter_count = 4; 509 config.adr = 0x29 + (chan->number ^ 2); 510 511 chan->fe = dvb_attach(drxk_attach, &config, i2c); 512 if (!chan->fe) { 513 dev_err(pdev, "No DRXK found!\n"); 514 return -ENODEV; 515 } 516 chan->fe->sec_priv = chan; 517 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; 518 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 519 return 0; 520 } 521 522 /****************************************************************************/ 523 /* XO2 related lists and functions ******************************************/ 524 /****************************************************************************/ 525 526 static char *xo2names[] = { 527 "DUAL DVB-S2", 528 "DUAL DVB-C/T/T2", 529 "DUAL DVB-ISDBT", 530 "DUAL DVB-C/C2/T/T2", 531 "DUAL ATSC", 532 "DUAL DVB-C/C2/T/T2/I", 533 }; 534 535 static int init_xo2(struct ngene_channel *chan, struct i2c_adapter *i2c) 536 { 537 struct device *pdev = &chan->dev->pci_dev->dev; 538 u8 addr = 0x10; 539 u8 val, data[2]; 540 int res; 541 542 res = i2c_read_regs(i2c, addr, 0x04, data, 2); 543 if (res < 0) 544 return res; 545 546 if (data[0] != 0x01) { 547 dev_info(pdev, "Invalid XO2 on channel %d\n", chan->number); 548 return -1; 549 } 550 551 i2c_read_reg(i2c, addr, 0x08, &val); 552 if (val != 0) { 553 i2c_write_reg(i2c, addr, 0x08, 0x00); 554 msleep(100); 555 } 556 /* Enable tuner power, disable pll, reset demods */ 557 i2c_write_reg(i2c, addr, 0x08, 0x04); 558 usleep_range(2000, 3000); 559 /* Release demod resets */ 560 i2c_write_reg(i2c, addr, 0x08, 0x07); 561 562 /* 563 * speed: 0=55,1=75,2=90,3=104 MBit/s 564 * Note: The ngene hardware must be run at 75 MBit/s compared 565 * to more modern ddbridge hardware which runs at 90 MBit/s, 566 * else there will be issues with the data transport and non- 567 * working secondary/slave demods/tuners. 568 */ 569 i2c_write_reg(i2c, addr, 0x09, 1); 570 571 i2c_write_reg(i2c, addr, 0x0a, 0x01); 572 i2c_write_reg(i2c, addr, 0x0b, 0x01); 573 574 usleep_range(2000, 3000); 575 /* Start XO2 PLL */ 576 i2c_write_reg(i2c, addr, 0x08, 0x87); 577 578 return 0; 579 } 580 581 static int port_has_xo2(struct i2c_adapter *i2c, u8 *type, u8 *id) 582 { 583 u8 probe[1] = { 0x00 }, data[4]; 584 u8 addr = 0x10; 585 586 *type = NGENE_XO2_TYPE_NONE; 587 588 if (i2c_io(i2c, addr, probe, 1, data, 4)) 589 return 0; 590 if (data[0] == 'D' && data[1] == 'F') { 591 *id = data[2]; 592 *type = NGENE_XO2_TYPE_DUOFLEX; 593 return 1; 594 } 595 if (data[0] == 'C' && data[1] == 'I') { 596 *id = data[2]; 597 *type = NGENE_XO2_TYPE_CI; 598 return 1; 599 } 600 return 0; 601 } 602 603 /****************************************************************************/ 604 /* Probing and port/channel handling ****************************************/ 605 /****************************************************************************/ 606 607 static int cineS2_probe(struct ngene_channel *chan) 608 { 609 struct device *pdev = &chan->dev->pci_dev->dev; 610 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 611 struct stv090x_config *fe_conf; 612 u8 buf[3]; 613 u8 xo2_type, xo2_id, xo2_demodtype; 614 u8 sony_osc24 = 0; 615 struct i2c_msg i2c_msg = { .flags = 0, .buf = buf }; 616 int rc; 617 618 if (port_has_xo2(i2c, &xo2_type, &xo2_id)) { 619 xo2_id >>= 2; 620 dev_dbg(pdev, "XO2 on channel %d (type %d, id %d)\n", 621 chan->number, xo2_type, xo2_id); 622 623 switch (xo2_type) { 624 case NGENE_XO2_TYPE_DUOFLEX: 625 if (chan->number & 1) 626 dev_dbg(pdev, 627 "skipping XO2 init on odd channel %d", 628 chan->number); 629 else 630 init_xo2(chan, i2c); 631 632 xo2_demodtype = DEMOD_TYPE_XO2 + xo2_id; 633 634 switch (xo2_demodtype) { 635 case DEMOD_TYPE_SONY_CT2: 636 case DEMOD_TYPE_SONY_ISDBT: 637 case DEMOD_TYPE_SONY_C2T2: 638 case DEMOD_TYPE_SONY_C2T2I: 639 dev_info(pdev, "%s (XO2) on channel %d\n", 640 xo2names[xo2_id], chan->number); 641 chan->demod_type = xo2_demodtype; 642 if (xo2_demodtype == DEMOD_TYPE_SONY_C2T2I) 643 sony_osc24 = 1; 644 645 demod_attach_cxd28xx(chan, i2c, sony_osc24); 646 break; 647 case DEMOD_TYPE_STV0910: 648 dev_info(pdev, "%s (XO2) on channel %d\n", 649 xo2names[xo2_id], chan->number); 650 chan->demod_type = xo2_demodtype; 651 demod_attach_stv0910(chan, i2c); 652 break; 653 default: 654 dev_warn(pdev, 655 "Unsupported XO2 module on channel %d\n", 656 chan->number); 657 return -ENODEV; 658 } 659 break; 660 case NGENE_XO2_TYPE_CI: 661 dev_info(pdev, "DuoFlex CI modules not supported\n"); 662 return -ENODEV; 663 default: 664 dev_info(pdev, "Unsupported XO2 module type\n"); 665 return -ENODEV; 666 } 667 } else if (port_has_stv0900(i2c, chan->number)) { 668 chan->demod_type = DEMOD_TYPE_STV090X; 669 fe_conf = chan->dev->card_info->fe_config[chan->number]; 670 /* demod found, attach it */ 671 rc = demod_attach_stv0900(chan); 672 if (rc < 0 || chan->number < 2) 673 return rc; 674 675 /* demod #2: reprogram outputs DPN1 & DPN2 */ 676 i2c_msg.addr = fe_conf->address; 677 i2c_msg.len = 3; 678 buf[0] = 0xf1; 679 switch (chan->number) { 680 case 2: 681 buf[1] = 0x5c; 682 buf[2] = 0xc2; 683 break; 684 case 3: 685 buf[1] = 0x61; 686 buf[2] = 0xcc; 687 break; 688 default: 689 return -ENODEV; 690 } 691 rc = i2c_transfer(i2c, &i2c_msg, 1); 692 if (rc != 1) { 693 dev_err(pdev, "Could not setup DPNx\n"); 694 return -EIO; 695 } 696 } else if (port_has_drxk(i2c, chan->number^2)) { 697 chan->demod_type = DEMOD_TYPE_DRXK; 698 demod_attach_drxk(chan, i2c); 699 } else if (port_has_stv0367(i2c)) { 700 chan->demod_type = DEMOD_TYPE_STV0367; 701 dev_info(pdev, "STV0367 on channel %d\n", chan->number); 702 demod_attach_stv0367(chan, i2c); 703 } else { 704 dev_info(pdev, "No demod found on chan %d\n", chan->number); 705 return -ENODEV; 706 } 707 return 0; 708 } 709 710 711 static struct lgdt330x_config aver_m780 = { 712 .demod_chip = LGDT3303, 713 .serial_mpeg = 0x00, /* PARALLEL */ 714 .clock_polarity_flip = 1, 715 }; 716 717 static struct mt2131_config m780_tunerconfig = { 718 0xc0 >> 1 719 }; 720 721 /* A single func to attach the demo and tuner, rather than 722 * use two sep funcs like the current design mandates. 723 */ 724 static int demod_attach_lg330x(struct ngene_channel *chan) 725 { 726 struct device *pdev = &chan->dev->pci_dev->dev; 727 728 chan->fe = dvb_attach(lgdt330x_attach, &aver_m780, 729 0xb2 >> 1, &chan->i2c_adapter); 730 if (chan->fe == NULL) { 731 dev_err(pdev, "No LGDT330x found!\n"); 732 return -ENODEV; 733 } 734 735 dvb_attach(mt2131_attach, chan->fe, &chan->i2c_adapter, 736 &m780_tunerconfig, 0); 737 738 return (chan->fe) ? 0 : -ENODEV; 739 } 740 741 static int demod_attach_drxd(struct ngene_channel *chan) 742 { 743 struct device *pdev = &chan->dev->pci_dev->dev; 744 struct drxd_config *feconf; 745 746 feconf = chan->dev->card_info->fe_config[chan->number]; 747 748 chan->fe = dvb_attach(drxd_attach, feconf, chan, 749 &chan->i2c_adapter, &chan->dev->pci_dev->dev); 750 if (!chan->fe) { 751 dev_err(pdev, "No DRXD found!\n"); 752 return -ENODEV; 753 } 754 return 0; 755 } 756 757 static int tuner_attach_dtt7520x(struct ngene_channel *chan) 758 { 759 struct device *pdev = &chan->dev->pci_dev->dev; 760 struct drxd_config *feconf; 761 762 feconf = chan->dev->card_info->fe_config[chan->number]; 763 764 if (!dvb_attach(dvb_pll_attach, chan->fe, feconf->pll_address, 765 &chan->i2c_adapter, 766 feconf->pll_type)) { 767 dev_err(pdev, "No pll(%d) found!\n", feconf->pll_type); 768 return -ENODEV; 769 } 770 return 0; 771 } 772 773 /****************************************************************************/ 774 /* EEPROM TAGS **************************************************************/ 775 /****************************************************************************/ 776 777 #define MICNG_EE_START 0x0100 778 #define MICNG_EE_END 0x0FF0 779 780 #define MICNG_EETAG_END0 0x0000 781 #define MICNG_EETAG_END1 0xFFFF 782 783 /* 0x0001 - 0x000F reserved for housekeeping */ 784 /* 0xFFFF - 0xFFFE reserved for housekeeping */ 785 786 /* Micronas assigned tags 787 EEProm tags for hardware support */ 788 789 #define MICNG_EETAG_DRXD1_OSCDEVIATION 0x1000 /* 2 Bytes data */ 790 #define MICNG_EETAG_DRXD2_OSCDEVIATION 0x1001 /* 2 Bytes data */ 791 792 #define MICNG_EETAG_MT2060_1_1STIF 0x1100 /* 2 Bytes data */ 793 #define MICNG_EETAG_MT2060_2_1STIF 0x1101 /* 2 Bytes data */ 794 795 /* Tag range for OEMs */ 796 797 #define MICNG_EETAG_OEM_FIRST 0xC000 798 #define MICNG_EETAG_OEM_LAST 0xFFEF 799 800 static int i2c_write_eeprom(struct i2c_adapter *adapter, 801 u8 adr, u16 reg, u8 data) 802 { 803 struct device *pdev = adapter->dev.parent; 804 u8 m[3] = {(reg >> 8), (reg & 0xff), data}; 805 struct i2c_msg msg = {.addr = adr, .flags = 0, .buf = m, 806 .len = sizeof(m)}; 807 808 if (i2c_transfer(adapter, &msg, 1) != 1) { 809 dev_err(pdev, "Error writing EEPROM!\n"); 810 return -EIO; 811 } 812 return 0; 813 } 814 815 static int i2c_read_eeprom(struct i2c_adapter *adapter, 816 u8 adr, u16 reg, u8 *data, int len) 817 { 818 struct device *pdev = adapter->dev.parent; 819 u8 msg[2] = {(reg >> 8), (reg & 0xff)}; 820 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0, 821 .buf = msg, .len = 2 }, 822 {.addr = adr, .flags = I2C_M_RD, 823 .buf = data, .len = len} }; 824 825 if (i2c_transfer(adapter, msgs, 2) != 2) { 826 dev_err(pdev, "Error reading EEPROM\n"); 827 return -EIO; 828 } 829 return 0; 830 } 831 832 static int ReadEEProm(struct i2c_adapter *adapter, 833 u16 Tag, u32 MaxLen, u8 *data, u32 *pLength) 834 { 835 struct device *pdev = adapter->dev.parent; 836 int status = 0; 837 u16 Addr = MICNG_EE_START, Length, tag = 0; 838 u8 EETag[3]; 839 840 while (Addr + sizeof(u16) + 1 < MICNG_EE_END) { 841 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag, sizeof(EETag))) 842 return -1; 843 tag = (EETag[0] << 8) | EETag[1]; 844 if (tag == MICNG_EETAG_END0 || tag == MICNG_EETAG_END1) 845 return -1; 846 if (tag == Tag) 847 break; 848 Addr += sizeof(u16) + 1 + EETag[2]; 849 } 850 if (Addr + sizeof(u16) + 1 + EETag[2] > MICNG_EE_END) { 851 dev_err(pdev, "Reached EOEE @ Tag = %04x Length = %3d\n", 852 tag, EETag[2]); 853 return -1; 854 } 855 Length = EETag[2]; 856 if (Length > MaxLen) 857 Length = (u16) MaxLen; 858 if (Length > 0) { 859 Addr += sizeof(u16) + 1; 860 status = i2c_read_eeprom(adapter, 0x50, Addr, data, Length); 861 if (!status) { 862 *pLength = EETag[2]; 863 #if 0 864 if (Length < EETag[2]) 865 status = STATUS_BUFFER_OVERFLOW; 866 #endif 867 } 868 } 869 return status; 870 } 871 872 static int WriteEEProm(struct i2c_adapter *adapter, 873 u16 Tag, u32 Length, u8 *data) 874 { 875 struct device *pdev = adapter->dev.parent; 876 int status = 0; 877 u16 Addr = MICNG_EE_START; 878 u8 EETag[3]; 879 u16 tag = 0; 880 int retry, i; 881 882 while (Addr + sizeof(u16) + 1 < MICNG_EE_END) { 883 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag, sizeof(EETag))) 884 return -1; 885 tag = (EETag[0] << 8) | EETag[1]; 886 if (tag == MICNG_EETAG_END0 || tag == MICNG_EETAG_END1) 887 return -1; 888 if (tag == Tag) 889 break; 890 Addr += sizeof(u16) + 1 + EETag[2]; 891 } 892 if (Addr + sizeof(u16) + 1 + EETag[2] > MICNG_EE_END) { 893 dev_err(pdev, "Reached EOEE @ Tag = %04x Length = %3d\n", 894 tag, EETag[2]); 895 return -1; 896 } 897 898 if (Length > EETag[2]) 899 return -EINVAL; 900 /* Note: We write the data one byte at a time to avoid 901 issues with page sizes. (which are different for 902 each manufacture and eeprom size) 903 */ 904 Addr += sizeof(u16) + 1; 905 for (i = 0; i < Length; i++, Addr++) { 906 status = i2c_write_eeprom(adapter, 0x50, Addr, data[i]); 907 908 if (status) 909 break; 910 911 /* Poll for finishing write cycle */ 912 retry = 10; 913 while (retry) { 914 u8 Tmp; 915 916 msleep(50); 917 status = i2c_read_eeprom(adapter, 0x50, Addr, &Tmp, 1); 918 if (status) 919 break; 920 if (Tmp != data[i]) 921 dev_err(pdev, "eeprom write error\n"); 922 retry -= 1; 923 } 924 if (status) { 925 dev_err(pdev, "Timeout polling eeprom\n"); 926 break; 927 } 928 } 929 return status; 930 } 931 932 static int eeprom_read_ushort(struct i2c_adapter *adapter, u16 tag, u16 *data) 933 { 934 int stat; 935 u8 buf[2]; 936 u32 len = 0; 937 938 stat = ReadEEProm(adapter, tag, 2, buf, &len); 939 if (stat) 940 return stat; 941 if (len != 2) 942 return -EINVAL; 943 944 *data = (buf[0] << 8) | buf[1]; 945 return 0; 946 } 947 948 static int eeprom_write_ushort(struct i2c_adapter *adapter, u16 tag, u16 data) 949 { 950 int stat; 951 u8 buf[2]; 952 953 buf[0] = data >> 8; 954 buf[1] = data & 0xff; 955 stat = WriteEEProm(adapter, tag, 2, buf); 956 if (stat) 957 return stat; 958 return 0; 959 } 960 961 static s16 osc_deviation(void *priv, s16 deviation, int flag) 962 { 963 struct ngene_channel *chan = priv; 964 struct device *pdev = &chan->dev->pci_dev->dev; 965 struct i2c_adapter *adap = &chan->i2c_adapter; 966 u16 data = 0; 967 968 if (flag) { 969 data = (u16) deviation; 970 dev_info(pdev, "write deviation %d\n", 971 deviation); 972 eeprom_write_ushort(adap, 0x1000 + chan->number, data); 973 } else { 974 if (eeprom_read_ushort(adap, 0x1000 + chan->number, &data)) 975 data = 0; 976 dev_info(pdev, "read deviation %d\n", 977 (s16)data); 978 } 979 980 return (s16) data; 981 } 982 983 /****************************************************************************/ 984 /* Switch control (I2C gates, etc.) *****************************************/ 985 /****************************************************************************/ 986 987 988 static struct stv090x_config fe_cineS2 = { 989 .device = STV0900, 990 .demod_mode = STV090x_DUAL, 991 .clk_mode = STV090x_CLK_EXT, 992 993 .xtal = 27000000, 994 .address = 0x68, 995 996 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 997 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 998 999 .repeater_level = STV090x_RPTLEVEL_16, 1000 1001 .adc1_range = STV090x_ADC_1Vpp, 1002 .adc2_range = STV090x_ADC_1Vpp, 1003 1004 .diseqc_envelope_mode = true, 1005 1006 .tuner_i2c_lock = cineS2_tuner_i2c_lock, 1007 }; 1008 1009 static struct stv090x_config fe_cineS2_2 = { 1010 .device = STV0900, 1011 .demod_mode = STV090x_DUAL, 1012 .clk_mode = STV090x_CLK_EXT, 1013 1014 .xtal = 27000000, 1015 .address = 0x69, 1016 1017 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1018 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1019 1020 .repeater_level = STV090x_RPTLEVEL_16, 1021 1022 .adc1_range = STV090x_ADC_1Vpp, 1023 .adc2_range = STV090x_ADC_1Vpp, 1024 1025 .diseqc_envelope_mode = true, 1026 1027 .tuner_i2c_lock = cineS2_tuner_i2c_lock, 1028 }; 1029 1030 static struct stv6110x_config tuner_cineS2_0 = { 1031 .addr = 0x60, 1032 .refclk = 27000000, 1033 .clk_div = 1, 1034 }; 1035 1036 static struct stv6110x_config tuner_cineS2_1 = { 1037 .addr = 0x63, 1038 .refclk = 27000000, 1039 .clk_div = 1, 1040 }; 1041 1042 static const struct ngene_info ngene_info_cineS2 = { 1043 .type = NGENE_SIDEWINDER, 1044 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner", 1045 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, 1046 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, 1047 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, 1048 .fe_config = {&fe_cineS2, &fe_cineS2}, 1049 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, 1050 .lnb = {0x0b, 0x08}, 1051 .tsf = {3, 3}, 1052 .fw_version = 18, 1053 .msi_supported = true, 1054 }; 1055 1056 static const struct ngene_info ngene_info_satixS2 = { 1057 .type = NGENE_SIDEWINDER, 1058 .name = "Mystique SaTiX-S2 Dual", 1059 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, 1060 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, 1061 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, 1062 .fe_config = {&fe_cineS2, &fe_cineS2}, 1063 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, 1064 .lnb = {0x0b, 0x08}, 1065 .tsf = {3, 3}, 1066 .fw_version = 18, 1067 .msi_supported = true, 1068 }; 1069 1070 static const struct ngene_info ngene_info_satixS2v2 = { 1071 .type = NGENE_SIDEWINDER, 1072 .name = "Mystique SaTiX-S2 Dual (v2)", 1073 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, 1074 NGENE_IO_TSOUT}, 1075 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, 1076 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe}, 1077 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, 1078 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, 1079 .lnb = {0x0a, 0x08, 0x0b, 0x09}, 1080 .tsf = {3, 3}, 1081 .fw_version = 18, 1082 .msi_supported = true, 1083 }; 1084 1085 static const struct ngene_info ngene_info_cineS2v5 = { 1086 .type = NGENE_SIDEWINDER, 1087 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)", 1088 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, 1089 NGENE_IO_TSOUT}, 1090 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, 1091 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe}, 1092 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, 1093 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, 1094 .lnb = {0x0a, 0x08, 0x0b, 0x09}, 1095 .tsf = {3, 3}, 1096 .fw_version = 18, 1097 .msi_supported = true, 1098 }; 1099 1100 1101 static const struct ngene_info ngene_info_duoFlex = { 1102 .type = NGENE_SIDEWINDER, 1103 .name = "Digital Devices DuoFlex PCIe or miniPCIe", 1104 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, 1105 NGENE_IO_TSOUT}, 1106 .demod_attach = {cineS2_probe, cineS2_probe, cineS2_probe, cineS2_probe}, 1107 .tuner_attach = {tuner_attach_probe, tuner_attach_probe, tuner_attach_probe, tuner_attach_probe}, 1108 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, 1109 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, 1110 .lnb = {0x0a, 0x08, 0x0b, 0x09}, 1111 .tsf = {3, 3}, 1112 .fw_version = 18, 1113 .msi_supported = true, 1114 }; 1115 1116 static const struct ngene_info ngene_info_m780 = { 1117 .type = NGENE_APP, 1118 .name = "Aver M780 ATSC/QAM-B", 1119 1120 /* Channel 0 is analog, which is currently unsupported */ 1121 .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN }, 1122 .demod_attach = { NULL, demod_attach_lg330x }, 1123 1124 /* Ensure these are NULL else the frame will call them (as funcs) */ 1125 .tuner_attach = { NULL, NULL, NULL, NULL }, 1126 .fe_config = { NULL, &aver_m780 }, 1127 .avf = { 0 }, 1128 1129 /* A custom electrical interface config for the demod to bridge */ 1130 .tsf = { 4, 4 }, 1131 .fw_version = 15, 1132 }; 1133 1134 static struct drxd_config fe_terratec_dvbt_0 = { 1135 .index = 0, 1136 .demod_address = 0x70, 1137 .demod_revision = 0xa2, 1138 .demoda_address = 0x00, 1139 .pll_address = 0x60, 1140 .pll_type = DVB_PLL_THOMSON_DTT7520X, 1141 .clock = 20000, 1142 .osc_deviation = osc_deviation, 1143 }; 1144 1145 static struct drxd_config fe_terratec_dvbt_1 = { 1146 .index = 1, 1147 .demod_address = 0x71, 1148 .demod_revision = 0xa2, 1149 .demoda_address = 0x00, 1150 .pll_address = 0x60, 1151 .pll_type = DVB_PLL_THOMSON_DTT7520X, 1152 .clock = 20000, 1153 .osc_deviation = osc_deviation, 1154 }; 1155 1156 static const struct ngene_info ngene_info_terratec = { 1157 .type = NGENE_TERRATEC, 1158 .name = "Terratec Integra/Cinergy2400i Dual DVB-T", 1159 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, 1160 .demod_attach = {demod_attach_drxd, demod_attach_drxd}, 1161 .tuner_attach = {tuner_attach_dtt7520x, tuner_attach_dtt7520x}, 1162 .fe_config = {&fe_terratec_dvbt_0, &fe_terratec_dvbt_1}, 1163 .i2c_access = 1, 1164 }; 1165 1166 /****************************************************************************/ 1167 1168 1169 1170 /****************************************************************************/ 1171 /* PCI Subsystem ID *********************************************************/ 1172 /****************************************************************************/ 1173 1174 #define NGENE_ID(_subvend, _subdev, _driverdata) { \ 1175 .vendor = NGENE_VID, .device = NGENE_PID, \ 1176 .subvendor = _subvend, .subdevice = _subdev, \ 1177 .driver_data = (unsigned long) &_driverdata } 1178 1179 /****************************************************************************/ 1180 1181 static const struct pci_device_id ngene_id_tbl[] = { 1182 NGENE_ID(0x18c3, 0xab04, ngene_info_cineS2), 1183 NGENE_ID(0x18c3, 0xab05, ngene_info_cineS2v5), 1184 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2), 1185 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2), 1186 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2), 1187 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2), 1188 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5), 1189 NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlex), 1190 NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlex), 1191 NGENE_ID(0x1461, 0x062e, ngene_info_m780), 1192 NGENE_ID(0x153b, 0x1167, ngene_info_terratec), 1193 {0} 1194 }; 1195 MODULE_DEVICE_TABLE(pci, ngene_id_tbl); 1196 1197 /****************************************************************************/ 1198 /* Init/Exit ****************************************************************/ 1199 /****************************************************************************/ 1200 1201 static pci_ers_result_t ngene_error_detected(struct pci_dev *dev, 1202 enum pci_channel_state state) 1203 { 1204 dev_err(&dev->dev, "PCI error\n"); 1205 if (state == pci_channel_io_perm_failure) 1206 return PCI_ERS_RESULT_DISCONNECT; 1207 if (state == pci_channel_io_frozen) 1208 return PCI_ERS_RESULT_NEED_RESET; 1209 return PCI_ERS_RESULT_CAN_RECOVER; 1210 } 1211 1212 static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev) 1213 { 1214 dev_info(&dev->dev, "slot reset\n"); 1215 return 0; 1216 } 1217 1218 static void ngene_resume(struct pci_dev *dev) 1219 { 1220 dev_info(&dev->dev, "resume\n"); 1221 } 1222 1223 static const struct pci_error_handlers ngene_errors = { 1224 .error_detected = ngene_error_detected, 1225 .slot_reset = ngene_slot_reset, 1226 .resume = ngene_resume, 1227 }; 1228 1229 static struct pci_driver ngene_pci_driver = { 1230 .name = "ngene", 1231 .id_table = ngene_id_tbl, 1232 .probe = ngene_probe, 1233 .remove = ngene_remove, 1234 .err_handler = &ngene_errors, 1235 .shutdown = ngene_shutdown, 1236 }; 1237 1238 static __init int module_init_ngene(void) 1239 { 1240 /* pr_*() since we don't have a device to use with dev_*() yet */ 1241 pr_info("nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n"); 1242 1243 return pci_register_driver(&ngene_pci_driver); 1244 } 1245 1246 static __exit void module_exit_ngene(void) 1247 { 1248 pci_unregister_driver(&ngene_pci_driver); 1249 } 1250 1251 module_init(module_init_ngene); 1252 module_exit(module_exit_ngene); 1253 1254 MODULE_DESCRIPTION("nGene"); 1255 MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel"); 1256 MODULE_LICENSE("GPL"); 1257