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 }; 331 332 static struct lnbh25_config lnbh25_cfg = { 333 .i2c_address = 0x0c << 1, 334 .data2_config = LNBH25_TEN 335 }; 336 337 static int demod_attach_stv0910(struct ngene_channel *chan, 338 struct i2c_adapter *i2c) 339 { 340 struct device *pdev = &chan->dev->pci_dev->dev; 341 struct stv0910_cfg cfg = stv0910_p; 342 struct lnbh25_config lnbcfg = lnbh25_cfg; 343 344 chan->fe = dvb_attach(stv0910_attach, i2c, &cfg, (chan->number & 1)); 345 if (!chan->fe) { 346 cfg.adr = 0x6c; 347 chan->fe = dvb_attach(stv0910_attach, i2c, 348 &cfg, (chan->number & 1)); 349 } 350 if (!chan->fe) { 351 dev_err(pdev, "stv0910_attach() failed!\n"); 352 return -ENODEV; 353 } 354 355 /* 356 * attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit 357 * i2c addresses 358 */ 359 lnbcfg.i2c_address = (((chan->number & 1) ? 0x0d : 0x0c) << 1); 360 if (!dvb_attach(lnbh25_attach, chan->fe, &lnbcfg, i2c)) { 361 lnbcfg.i2c_address = (((chan->number & 1) ? 0x09 : 0x08) << 1); 362 if (!dvb_attach(lnbh25_attach, chan->fe, &lnbcfg, i2c)) { 363 dev_err(pdev, "lnbh25_attach() failed!\n"); 364 dvb_frontend_detach(chan->fe); 365 chan->fe = NULL; 366 return -ENODEV; 367 } 368 } 369 370 return 0; 371 } 372 373 static struct stv0367_config ddb_stv0367_config[] = { 374 { 375 .demod_address = 0x1f, 376 .xtal = 27000000, 377 .if_khz = 0, 378 .if_iq_mode = FE_TER_NORMAL_IF_TUNER, 379 .ts_mode = STV0367_SERIAL_PUNCT_CLOCK, 380 .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT, 381 }, { 382 .demod_address = 0x1e, 383 .xtal = 27000000, 384 .if_khz = 0, 385 .if_iq_mode = FE_TER_NORMAL_IF_TUNER, 386 .ts_mode = STV0367_SERIAL_PUNCT_CLOCK, 387 .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT, 388 }, 389 }; 390 391 static int demod_attach_stv0367(struct ngene_channel *chan, 392 struct i2c_adapter *i2c) 393 { 394 struct device *pdev = &chan->dev->pci_dev->dev; 395 396 chan->fe = dvb_attach(stv0367ddb_attach, 397 &ddb_stv0367_config[(chan->number & 1)], i2c); 398 399 if (!chan->fe) { 400 dev_err(pdev, "stv0367ddb_attach() failed!\n"); 401 return -ENODEV; 402 } 403 404 chan->fe->sec_priv = chan; 405 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; 406 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 407 return 0; 408 } 409 410 static int demod_attach_cxd28xx(struct ngene_channel *chan, 411 struct i2c_adapter *i2c, int osc24) 412 { 413 struct device *pdev = &chan->dev->pci_dev->dev; 414 struct cxd2841er_config cfg; 415 416 /* the cxd2841er driver expects 8bit/shifted I2C addresses */ 417 cfg.i2c_addr = ((chan->number & 1) ? 0x6d : 0x6c) << 1; 418 419 cfg.xtal = osc24 ? SONY_XTAL_24000 : SONY_XTAL_20500; 420 cfg.flags = CXD2841ER_AUTO_IFHZ | CXD2841ER_EARLY_TUNE | 421 CXD2841ER_NO_WAIT_LOCK | CXD2841ER_NO_AGCNEG | 422 CXD2841ER_TSBITS | CXD2841ER_TS_SERIAL; 423 424 /* attach frontend */ 425 chan->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); 426 427 if (!chan->fe) { 428 dev_err(pdev, "CXD28XX attach failed!\n"); 429 return -ENODEV; 430 } 431 432 chan->fe->sec_priv = chan; 433 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; 434 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 435 return 0; 436 } 437 438 static void cineS2_tuner_i2c_lock(struct dvb_frontend *fe, int lock) 439 { 440 struct ngene_channel *chan = fe->analog_demod_priv; 441 442 if (lock) 443 down(&chan->dev->pll_mutex); 444 else 445 up(&chan->dev->pll_mutex); 446 } 447 448 static int port_has_stv0900(struct i2c_adapter *i2c, int port) 449 { 450 u8 val; 451 if (i2c_read_reg16(i2c, 0x68+port/2, 0xf100, &val) < 0) 452 return 0; 453 return 1; 454 } 455 456 static int port_has_drxk(struct i2c_adapter *i2c, int port) 457 { 458 u8 val; 459 460 if (i2c_read(i2c, 0x29+port, &val) < 0) 461 return 0; 462 return 1; 463 } 464 465 static int port_has_stv0367(struct i2c_adapter *i2c) 466 { 467 u8 val; 468 469 if (i2c_read_reg16(i2c, 0x1e, 0xf000, &val) < 0) 470 return 0; 471 if (val != 0x60) 472 return 0; 473 if (i2c_read_reg16(i2c, 0x1f, 0xf000, &val) < 0) 474 return 0; 475 if (val != 0x60) 476 return 0; 477 return 1; 478 } 479 480 int ngene_port_has_cxd2099(struct i2c_adapter *i2c, u8 *type) 481 { 482 u8 val; 483 u8 probe[4] = { 0xe0, 0x00, 0x00, 0x00 }, data[4]; 484 struct i2c_msg msgs[2] = {{ .addr = 0x40, .flags = 0, 485 .buf = probe, .len = 4 }, 486 { .addr = 0x40, .flags = I2C_M_RD, 487 .buf = data, .len = 4 } }; 488 val = i2c_transfer(i2c, msgs, 2); 489 if (val != 2) 490 return 0; 491 492 if (data[0] == 0x02 && data[1] == 0x2b && data[3] == 0x43) 493 *type = 2; 494 else 495 *type = 1; 496 return 1; 497 } 498 499 static int demod_attach_drxk(struct ngene_channel *chan, 500 struct i2c_adapter *i2c) 501 { 502 struct device *pdev = &chan->dev->pci_dev->dev; 503 struct drxk_config config; 504 505 memset(&config, 0, sizeof(config)); 506 config.microcode_name = "drxk_a3.mc"; 507 config.qam_demod_parameter_count = 4; 508 config.adr = 0x29 + (chan->number ^ 2); 509 510 chan->fe = dvb_attach(drxk_attach, &config, i2c); 511 if (!chan->fe) { 512 dev_err(pdev, "No DRXK found!\n"); 513 return -ENODEV; 514 } 515 chan->fe->sec_priv = chan; 516 chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; 517 chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 518 return 0; 519 } 520 521 /****************************************************************************/ 522 /* XO2 related lists and functions ******************************************/ 523 /****************************************************************************/ 524 525 static char *xo2names[] = { 526 "DUAL DVB-S2", 527 "DUAL DVB-C/T/T2", 528 "DUAL DVB-ISDBT", 529 "DUAL DVB-C/C2/T/T2", 530 "DUAL ATSC", 531 "DUAL DVB-C/C2/T/T2/I", 532 }; 533 534 static int init_xo2(struct ngene_channel *chan, struct i2c_adapter *i2c) 535 { 536 struct device *pdev = &chan->dev->pci_dev->dev; 537 u8 addr = 0x10; 538 u8 val, data[2]; 539 int res; 540 541 res = i2c_read_regs(i2c, addr, 0x04, data, 2); 542 if (res < 0) 543 return res; 544 545 if (data[0] != 0x01) { 546 dev_info(pdev, "Invalid XO2 on channel %d\n", chan->number); 547 return -1; 548 } 549 550 i2c_read_reg(i2c, addr, 0x08, &val); 551 if (val != 0) { 552 i2c_write_reg(i2c, addr, 0x08, 0x00); 553 msleep(100); 554 } 555 /* Enable tuner power, disable pll, reset demods */ 556 i2c_write_reg(i2c, addr, 0x08, 0x04); 557 usleep_range(2000, 3000); 558 /* Release demod resets */ 559 i2c_write_reg(i2c, addr, 0x08, 0x07); 560 561 /* 562 * speed: 0=55,1=75,2=90,3=104 MBit/s 563 * Note: The ngene hardware must be run at 75 MBit/s compared 564 * to more modern ddbridge hardware which runs at 90 MBit/s, 565 * else there will be issues with the data transport and non- 566 * working secondary/slave demods/tuners. 567 */ 568 i2c_write_reg(i2c, addr, 0x09, 1); 569 570 i2c_write_reg(i2c, addr, 0x0a, 0x01); 571 i2c_write_reg(i2c, addr, 0x0b, 0x01); 572 573 usleep_range(2000, 3000); 574 /* Start XO2 PLL */ 575 i2c_write_reg(i2c, addr, 0x08, 0x87); 576 577 return 0; 578 } 579 580 static int port_has_xo2(struct i2c_adapter *i2c, u8 *type, u8 *id) 581 { 582 u8 probe[1] = { 0x00 }, data[4]; 583 u8 addr = 0x10; 584 585 *type = NGENE_XO2_TYPE_NONE; 586 587 if (i2c_io(i2c, addr, probe, 1, data, 4)) 588 return 0; 589 if (data[0] == 'D' && data[1] == 'F') { 590 *id = data[2]; 591 *type = NGENE_XO2_TYPE_DUOFLEX; 592 return 1; 593 } 594 if (data[0] == 'C' && data[1] == 'I') { 595 *id = data[2]; 596 *type = NGENE_XO2_TYPE_CI; 597 return 1; 598 } 599 return 0; 600 } 601 602 /****************************************************************************/ 603 /* Probing and port/channel handling ****************************************/ 604 /****************************************************************************/ 605 606 static int cineS2_probe(struct ngene_channel *chan) 607 { 608 struct device *pdev = &chan->dev->pci_dev->dev; 609 struct i2c_adapter *i2c = i2c_adapter_from_chan(chan); 610 struct stv090x_config *fe_conf; 611 u8 buf[3]; 612 u8 xo2_type, xo2_id, xo2_demodtype; 613 u8 sony_osc24 = 0; 614 struct i2c_msg i2c_msg = { .flags = 0, .buf = buf }; 615 int rc; 616 617 if (port_has_xo2(i2c, &xo2_type, &xo2_id)) { 618 xo2_id >>= 2; 619 dev_dbg(pdev, "XO2 on channel %d (type %d, id %d)\n", 620 chan->number, xo2_type, xo2_id); 621 622 switch (xo2_type) { 623 case NGENE_XO2_TYPE_DUOFLEX: 624 if (chan->number & 1) 625 dev_dbg(pdev, 626 "skipping XO2 init on odd channel %d", 627 chan->number); 628 else 629 init_xo2(chan, i2c); 630 631 xo2_demodtype = DEMOD_TYPE_XO2 + xo2_id; 632 633 switch (xo2_demodtype) { 634 case DEMOD_TYPE_SONY_CT2: 635 case DEMOD_TYPE_SONY_ISDBT: 636 case DEMOD_TYPE_SONY_C2T2: 637 case DEMOD_TYPE_SONY_C2T2I: 638 dev_info(pdev, "%s (XO2) on channel %d\n", 639 xo2names[xo2_id], chan->number); 640 chan->demod_type = xo2_demodtype; 641 if (xo2_demodtype == DEMOD_TYPE_SONY_C2T2I) 642 sony_osc24 = 1; 643 644 demod_attach_cxd28xx(chan, i2c, sony_osc24); 645 break; 646 case DEMOD_TYPE_STV0910: 647 dev_info(pdev, "%s (XO2) on channel %d\n", 648 xo2names[xo2_id], chan->number); 649 chan->demod_type = xo2_demodtype; 650 demod_attach_stv0910(chan, i2c); 651 break; 652 default: 653 dev_warn(pdev, 654 "Unsupported XO2 module on channel %d\n", 655 chan->number); 656 return -ENODEV; 657 } 658 break; 659 case NGENE_XO2_TYPE_CI: 660 dev_info(pdev, "DuoFlex CI modules not supported\n"); 661 return -ENODEV; 662 default: 663 dev_info(pdev, "Unsupported XO2 module type\n"); 664 return -ENODEV; 665 } 666 } else if (port_has_stv0900(i2c, chan->number)) { 667 chan->demod_type = DEMOD_TYPE_STV090X; 668 fe_conf = chan->dev->card_info->fe_config[chan->number]; 669 /* demod found, attach it */ 670 rc = demod_attach_stv0900(chan); 671 if (rc < 0 || chan->number < 2) 672 return rc; 673 674 /* demod #2: reprogram outputs DPN1 & DPN2 */ 675 i2c_msg.addr = fe_conf->address; 676 i2c_msg.len = 3; 677 buf[0] = 0xf1; 678 switch (chan->number) { 679 case 2: 680 buf[1] = 0x5c; 681 buf[2] = 0xc2; 682 break; 683 case 3: 684 buf[1] = 0x61; 685 buf[2] = 0xcc; 686 break; 687 default: 688 return -ENODEV; 689 } 690 rc = i2c_transfer(i2c, &i2c_msg, 1); 691 if (rc != 1) { 692 dev_err(pdev, "Could not setup DPNx\n"); 693 return -EIO; 694 } 695 } else if (port_has_drxk(i2c, chan->number^2)) { 696 chan->demod_type = DEMOD_TYPE_DRXK; 697 demod_attach_drxk(chan, i2c); 698 } else if (port_has_stv0367(i2c)) { 699 chan->demod_type = DEMOD_TYPE_STV0367; 700 dev_info(pdev, "STV0367 on channel %d\n", chan->number); 701 demod_attach_stv0367(chan, i2c); 702 } else { 703 dev_info(pdev, "No demod found on chan %d\n", chan->number); 704 return -ENODEV; 705 } 706 return 0; 707 } 708 709 710 static struct lgdt330x_config aver_m780 = { 711 .demod_chip = LGDT3303, 712 .serial_mpeg = 0x00, /* PARALLEL */ 713 .clock_polarity_flip = 1, 714 }; 715 716 static struct mt2131_config m780_tunerconfig = { 717 0xc0 >> 1 718 }; 719 720 /* A single func to attach the demo and tuner, rather than 721 * use two sep funcs like the current design mandates. 722 */ 723 static int demod_attach_lg330x(struct ngene_channel *chan) 724 { 725 struct device *pdev = &chan->dev->pci_dev->dev; 726 727 chan->fe = dvb_attach(lgdt330x_attach, &aver_m780, 728 0xb2 >> 1, &chan->i2c_adapter); 729 if (chan->fe == NULL) { 730 dev_err(pdev, "No LGDT330x found!\n"); 731 return -ENODEV; 732 } 733 734 dvb_attach(mt2131_attach, chan->fe, &chan->i2c_adapter, 735 &m780_tunerconfig, 0); 736 737 return (chan->fe) ? 0 : -ENODEV; 738 } 739 740 static int demod_attach_drxd(struct ngene_channel *chan) 741 { 742 struct device *pdev = &chan->dev->pci_dev->dev; 743 struct drxd_config *feconf; 744 745 feconf = chan->dev->card_info->fe_config[chan->number]; 746 747 chan->fe = dvb_attach(drxd_attach, feconf, chan, 748 &chan->i2c_adapter, &chan->dev->pci_dev->dev); 749 if (!chan->fe) { 750 dev_err(pdev, "No DRXD found!\n"); 751 return -ENODEV; 752 } 753 return 0; 754 } 755 756 static int tuner_attach_dtt7520x(struct ngene_channel *chan) 757 { 758 struct device *pdev = &chan->dev->pci_dev->dev; 759 struct drxd_config *feconf; 760 761 feconf = chan->dev->card_info->fe_config[chan->number]; 762 763 if (!dvb_attach(dvb_pll_attach, chan->fe, feconf->pll_address, 764 &chan->i2c_adapter, 765 feconf->pll_type)) { 766 dev_err(pdev, "No pll(%d) found!\n", feconf->pll_type); 767 return -ENODEV; 768 } 769 return 0; 770 } 771 772 /****************************************************************************/ 773 /* EEPROM TAGS **************************************************************/ 774 /****************************************************************************/ 775 776 #define MICNG_EE_START 0x0100 777 #define MICNG_EE_END 0x0FF0 778 779 #define MICNG_EETAG_END0 0x0000 780 #define MICNG_EETAG_END1 0xFFFF 781 782 /* 0x0001 - 0x000F reserved for housekeeping */ 783 /* 0xFFFF - 0xFFFE reserved for housekeeping */ 784 785 /* Micronas assigned tags 786 EEProm tags for hardware support */ 787 788 #define MICNG_EETAG_DRXD1_OSCDEVIATION 0x1000 /* 2 Bytes data */ 789 #define MICNG_EETAG_DRXD2_OSCDEVIATION 0x1001 /* 2 Bytes data */ 790 791 #define MICNG_EETAG_MT2060_1_1STIF 0x1100 /* 2 Bytes data */ 792 #define MICNG_EETAG_MT2060_2_1STIF 0x1101 /* 2 Bytes data */ 793 794 /* Tag range for OEMs */ 795 796 #define MICNG_EETAG_OEM_FIRST 0xC000 797 #define MICNG_EETAG_OEM_LAST 0xFFEF 798 799 static int i2c_write_eeprom(struct i2c_adapter *adapter, 800 u8 adr, u16 reg, u8 data) 801 { 802 struct device *pdev = adapter->dev.parent; 803 u8 m[3] = {(reg >> 8), (reg & 0xff), data}; 804 struct i2c_msg msg = {.addr = adr, .flags = 0, .buf = m, 805 .len = sizeof(m)}; 806 807 if (i2c_transfer(adapter, &msg, 1) != 1) { 808 dev_err(pdev, "Error writing EEPROM!\n"); 809 return -EIO; 810 } 811 return 0; 812 } 813 814 static int i2c_read_eeprom(struct i2c_adapter *adapter, 815 u8 adr, u16 reg, u8 *data, int len) 816 { 817 struct device *pdev = adapter->dev.parent; 818 u8 msg[2] = {(reg >> 8), (reg & 0xff)}; 819 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0, 820 .buf = msg, .len = 2 }, 821 {.addr = adr, .flags = I2C_M_RD, 822 .buf = data, .len = len} }; 823 824 if (i2c_transfer(adapter, msgs, 2) != 2) { 825 dev_err(pdev, "Error reading EEPROM\n"); 826 return -EIO; 827 } 828 return 0; 829 } 830 831 static int ReadEEProm(struct i2c_adapter *adapter, 832 u16 Tag, u32 MaxLen, u8 *data, u32 *pLength) 833 { 834 struct device *pdev = adapter->dev.parent; 835 int status = 0; 836 u16 Addr = MICNG_EE_START, Length, tag = 0; 837 u8 EETag[3]; 838 839 while (Addr + sizeof(u16) + 1 < MICNG_EE_END) { 840 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag, sizeof(EETag))) 841 return -1; 842 tag = (EETag[0] << 8) | EETag[1]; 843 if (tag == MICNG_EETAG_END0 || tag == MICNG_EETAG_END1) 844 return -1; 845 if (tag == Tag) 846 break; 847 Addr += sizeof(u16) + 1 + EETag[2]; 848 } 849 if (Addr + sizeof(u16) + 1 + EETag[2] > MICNG_EE_END) { 850 dev_err(pdev, "Reached EOEE @ Tag = %04x Length = %3d\n", 851 tag, EETag[2]); 852 return -1; 853 } 854 Length = EETag[2]; 855 if (Length > MaxLen) 856 Length = (u16) MaxLen; 857 if (Length > 0) { 858 Addr += sizeof(u16) + 1; 859 status = i2c_read_eeprom(adapter, 0x50, Addr, data, Length); 860 if (!status) { 861 *pLength = EETag[2]; 862 #if 0 863 if (Length < EETag[2]) 864 status = STATUS_BUFFER_OVERFLOW; 865 #endif 866 } 867 } 868 return status; 869 } 870 871 static int WriteEEProm(struct i2c_adapter *adapter, 872 u16 Tag, u32 Length, u8 *data) 873 { 874 struct device *pdev = adapter->dev.parent; 875 int status = 0; 876 u16 Addr = MICNG_EE_START; 877 u8 EETag[3]; 878 u16 tag = 0; 879 int retry, i; 880 881 while (Addr + sizeof(u16) + 1 < MICNG_EE_END) { 882 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag, sizeof(EETag))) 883 return -1; 884 tag = (EETag[0] << 8) | EETag[1]; 885 if (tag == MICNG_EETAG_END0 || tag == MICNG_EETAG_END1) 886 return -1; 887 if (tag == Tag) 888 break; 889 Addr += sizeof(u16) + 1 + EETag[2]; 890 } 891 if (Addr + sizeof(u16) + 1 + EETag[2] > MICNG_EE_END) { 892 dev_err(pdev, "Reached EOEE @ Tag = %04x Length = %3d\n", 893 tag, EETag[2]); 894 return -1; 895 } 896 897 if (Length > EETag[2]) 898 return -EINVAL; 899 /* Note: We write the data one byte at a time to avoid 900 issues with page sizes. (which are different for 901 each manufacture and eeprom size) 902 */ 903 Addr += sizeof(u16) + 1; 904 for (i = 0; i < Length; i++, Addr++) { 905 status = i2c_write_eeprom(adapter, 0x50, Addr, data[i]); 906 907 if (status) 908 break; 909 910 /* Poll for finishing write cycle */ 911 retry = 10; 912 while (retry) { 913 u8 Tmp; 914 915 msleep(50); 916 status = i2c_read_eeprom(adapter, 0x50, Addr, &Tmp, 1); 917 if (status) 918 break; 919 if (Tmp != data[i]) 920 dev_err(pdev, "eeprom write error\n"); 921 retry -= 1; 922 } 923 if (status) { 924 dev_err(pdev, "Timeout polling eeprom\n"); 925 break; 926 } 927 } 928 return status; 929 } 930 931 static int eeprom_read_ushort(struct i2c_adapter *adapter, u16 tag, u16 *data) 932 { 933 int stat; 934 u8 buf[2]; 935 u32 len = 0; 936 937 stat = ReadEEProm(adapter, tag, 2, buf, &len); 938 if (stat) 939 return stat; 940 if (len != 2) 941 return -EINVAL; 942 943 *data = (buf[0] << 8) | buf[1]; 944 return 0; 945 } 946 947 static int eeprom_write_ushort(struct i2c_adapter *adapter, u16 tag, u16 data) 948 { 949 int stat; 950 u8 buf[2]; 951 952 buf[0] = data >> 8; 953 buf[1] = data & 0xff; 954 stat = WriteEEProm(adapter, tag, 2, buf); 955 if (stat) 956 return stat; 957 return 0; 958 } 959 960 static s16 osc_deviation(void *priv, s16 deviation, int flag) 961 { 962 struct ngene_channel *chan = priv; 963 struct device *pdev = &chan->dev->pci_dev->dev; 964 struct i2c_adapter *adap = &chan->i2c_adapter; 965 u16 data = 0; 966 967 if (flag) { 968 data = (u16) deviation; 969 dev_info(pdev, "write deviation %d\n", 970 deviation); 971 eeprom_write_ushort(adap, 0x1000 + chan->number, data); 972 } else { 973 if (eeprom_read_ushort(adap, 0x1000 + chan->number, &data)) 974 data = 0; 975 dev_info(pdev, "read deviation %d\n", 976 (s16)data); 977 } 978 979 return (s16) data; 980 } 981 982 /****************************************************************************/ 983 /* Switch control (I2C gates, etc.) *****************************************/ 984 /****************************************************************************/ 985 986 987 static struct stv090x_config fe_cineS2 = { 988 .device = STV0900, 989 .demod_mode = STV090x_DUAL, 990 .clk_mode = STV090x_CLK_EXT, 991 992 .xtal = 27000000, 993 .address = 0x68, 994 995 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 996 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 997 998 .repeater_level = STV090x_RPTLEVEL_16, 999 1000 .adc1_range = STV090x_ADC_1Vpp, 1001 .adc2_range = STV090x_ADC_1Vpp, 1002 1003 .diseqc_envelope_mode = true, 1004 1005 .tuner_i2c_lock = cineS2_tuner_i2c_lock, 1006 }; 1007 1008 static struct stv090x_config fe_cineS2_2 = { 1009 .device = STV0900, 1010 .demod_mode = STV090x_DUAL, 1011 .clk_mode = STV090x_CLK_EXT, 1012 1013 .xtal = 27000000, 1014 .address = 0x69, 1015 1016 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1017 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1018 1019 .repeater_level = STV090x_RPTLEVEL_16, 1020 1021 .adc1_range = STV090x_ADC_1Vpp, 1022 .adc2_range = STV090x_ADC_1Vpp, 1023 1024 .diseqc_envelope_mode = true, 1025 1026 .tuner_i2c_lock = cineS2_tuner_i2c_lock, 1027 }; 1028 1029 static struct stv6110x_config tuner_cineS2_0 = { 1030 .addr = 0x60, 1031 .refclk = 27000000, 1032 .clk_div = 1, 1033 }; 1034 1035 static struct stv6110x_config tuner_cineS2_1 = { 1036 .addr = 0x63, 1037 .refclk = 27000000, 1038 .clk_div = 1, 1039 }; 1040 1041 static const struct ngene_info ngene_info_cineS2 = { 1042 .type = NGENE_SIDEWINDER, 1043 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner", 1044 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, 1045 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, 1046 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, 1047 .fe_config = {&fe_cineS2, &fe_cineS2}, 1048 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, 1049 .lnb = {0x0b, 0x08}, 1050 .tsf = {3, 3}, 1051 .fw_version = 18, 1052 .msi_supported = true, 1053 }; 1054 1055 static const struct ngene_info ngene_info_satixS2 = { 1056 .type = NGENE_SIDEWINDER, 1057 .name = "Mystique SaTiX-S2 Dual", 1058 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, 1059 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, 1060 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, 1061 .fe_config = {&fe_cineS2, &fe_cineS2}, 1062 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, 1063 .lnb = {0x0b, 0x08}, 1064 .tsf = {3, 3}, 1065 .fw_version = 18, 1066 .msi_supported = true, 1067 }; 1068 1069 static const struct ngene_info ngene_info_satixS2v2 = { 1070 .type = NGENE_SIDEWINDER, 1071 .name = "Mystique SaTiX-S2 Dual (v2)", 1072 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, 1073 NGENE_IO_TSOUT}, 1074 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, 1075 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe}, 1076 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, 1077 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, 1078 .lnb = {0x0a, 0x08, 0x0b, 0x09}, 1079 .tsf = {3, 3}, 1080 .fw_version = 18, 1081 .msi_supported = true, 1082 }; 1083 1084 static const struct ngene_info ngene_info_cineS2v5 = { 1085 .type = NGENE_SIDEWINDER, 1086 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)", 1087 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, 1088 NGENE_IO_TSOUT}, 1089 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, 1090 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe}, 1091 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, 1092 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, 1093 .lnb = {0x0a, 0x08, 0x0b, 0x09}, 1094 .tsf = {3, 3}, 1095 .fw_version = 18, 1096 .msi_supported = true, 1097 }; 1098 1099 1100 static const struct ngene_info ngene_info_duoFlex = { 1101 .type = NGENE_SIDEWINDER, 1102 .name = "Digital Devices DuoFlex PCIe or miniPCIe", 1103 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, 1104 NGENE_IO_TSOUT}, 1105 .demod_attach = {cineS2_probe, cineS2_probe, cineS2_probe, cineS2_probe}, 1106 .tuner_attach = {tuner_attach_probe, tuner_attach_probe, tuner_attach_probe, tuner_attach_probe}, 1107 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, 1108 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, 1109 .lnb = {0x0a, 0x08, 0x0b, 0x09}, 1110 .tsf = {3, 3}, 1111 .fw_version = 18, 1112 .msi_supported = true, 1113 }; 1114 1115 static const struct ngene_info ngene_info_m780 = { 1116 .type = NGENE_APP, 1117 .name = "Aver M780 ATSC/QAM-B", 1118 1119 /* Channel 0 is analog, which is currently unsupported */ 1120 .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN }, 1121 .demod_attach = { NULL, demod_attach_lg330x }, 1122 1123 /* Ensure these are NULL else the frame will call them (as funcs) */ 1124 .tuner_attach = { NULL, NULL, NULL, NULL }, 1125 .fe_config = { NULL, &aver_m780 }, 1126 .avf = { 0 }, 1127 1128 /* A custom electrical interface config for the demod to bridge */ 1129 .tsf = { 4, 4 }, 1130 .fw_version = 15, 1131 }; 1132 1133 static struct drxd_config fe_terratec_dvbt_0 = { 1134 .index = 0, 1135 .demod_address = 0x70, 1136 .demod_revision = 0xa2, 1137 .demoda_address = 0x00, 1138 .pll_address = 0x60, 1139 .pll_type = DVB_PLL_THOMSON_DTT7520X, 1140 .clock = 20000, 1141 .osc_deviation = osc_deviation, 1142 }; 1143 1144 static struct drxd_config fe_terratec_dvbt_1 = { 1145 .index = 1, 1146 .demod_address = 0x71, 1147 .demod_revision = 0xa2, 1148 .demoda_address = 0x00, 1149 .pll_address = 0x60, 1150 .pll_type = DVB_PLL_THOMSON_DTT7520X, 1151 .clock = 20000, 1152 .osc_deviation = osc_deviation, 1153 }; 1154 1155 static const struct ngene_info ngene_info_terratec = { 1156 .type = NGENE_TERRATEC, 1157 .name = "Terratec Integra/Cinergy2400i Dual DVB-T", 1158 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, 1159 .demod_attach = {demod_attach_drxd, demod_attach_drxd}, 1160 .tuner_attach = {tuner_attach_dtt7520x, tuner_attach_dtt7520x}, 1161 .fe_config = {&fe_terratec_dvbt_0, &fe_terratec_dvbt_1}, 1162 .i2c_access = 1, 1163 }; 1164 1165 /****************************************************************************/ 1166 1167 1168 1169 /****************************************************************************/ 1170 /* PCI Subsystem ID *********************************************************/ 1171 /****************************************************************************/ 1172 1173 #define NGENE_ID(_subvend, _subdev, _driverdata) { \ 1174 .vendor = NGENE_VID, .device = NGENE_PID, \ 1175 .subvendor = _subvend, .subdevice = _subdev, \ 1176 .driver_data = (unsigned long) &_driverdata } 1177 1178 /****************************************************************************/ 1179 1180 static const struct pci_device_id ngene_id_tbl[] = { 1181 NGENE_ID(0x18c3, 0xab04, ngene_info_cineS2), 1182 NGENE_ID(0x18c3, 0xab05, ngene_info_cineS2v5), 1183 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2), 1184 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2), 1185 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2), 1186 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2), 1187 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5), 1188 NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlex), 1189 NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlex), 1190 NGENE_ID(0x1461, 0x062e, ngene_info_m780), 1191 NGENE_ID(0x153b, 0x1167, ngene_info_terratec), 1192 {0} 1193 }; 1194 MODULE_DEVICE_TABLE(pci, ngene_id_tbl); 1195 1196 /****************************************************************************/ 1197 /* Init/Exit ****************************************************************/ 1198 /****************************************************************************/ 1199 1200 static pci_ers_result_t ngene_error_detected(struct pci_dev *dev, 1201 enum pci_channel_state state) 1202 { 1203 dev_err(&dev->dev, "PCI error\n"); 1204 if (state == pci_channel_io_perm_failure) 1205 return PCI_ERS_RESULT_DISCONNECT; 1206 if (state == pci_channel_io_frozen) 1207 return PCI_ERS_RESULT_NEED_RESET; 1208 return PCI_ERS_RESULT_CAN_RECOVER; 1209 } 1210 1211 static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev) 1212 { 1213 dev_info(&dev->dev, "slot reset\n"); 1214 return 0; 1215 } 1216 1217 static void ngene_resume(struct pci_dev *dev) 1218 { 1219 dev_info(&dev->dev, "resume\n"); 1220 } 1221 1222 static const struct pci_error_handlers ngene_errors = { 1223 .error_detected = ngene_error_detected, 1224 .slot_reset = ngene_slot_reset, 1225 .resume = ngene_resume, 1226 }; 1227 1228 static struct pci_driver ngene_pci_driver = { 1229 .name = "ngene", 1230 .id_table = ngene_id_tbl, 1231 .probe = ngene_probe, 1232 .remove = ngene_remove, 1233 .err_handler = &ngene_errors, 1234 .shutdown = ngene_shutdown, 1235 }; 1236 1237 static __init int module_init_ngene(void) 1238 { 1239 /* pr_*() since we don't have a device to use with dev_*() yet */ 1240 pr_info("nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n"); 1241 1242 return pci_register_driver(&ngene_pci_driver); 1243 } 1244 1245 static __exit void module_exit_ngene(void) 1246 { 1247 pci_unregister_driver(&ngene_pci_driver); 1248 } 1249 1250 module_init(module_init_ngene); 1251 module_exit(module_exit_ngene); 1252 1253 MODULE_DESCRIPTION("nGene"); 1254 MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel"); 1255 MODULE_LICENSE("GPL"); 1256