4 * Copyright (C) 2014 Akihiro Tsukada <tskd08@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <linux/freezer.h>
18 #include <linux/kernel.h>
19 #include <linux/kthread.h>
20 #include <linux/mutex.h>
21 #include <linux/module.h>
22 #include <linux/pci.h>
23 #include <linux/string.h>
27 #include "dvb_demux.h"
28 #include "dvb_frontend.h"
32 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
34 static bool one_adapter
;
35 module_param(one_adapter
, bool, 0444);
36 MODULE_PARM_DESC(one_adapter
, "Place FE's together under one adapter.");
38 static int num_bufs
= 4;
39 module_param(num_bufs
, int, 0444);
40 MODULE_PARM_DESC(num_bufs
, "Number of DMA buffer (188KiB) per FE.");
43 static const struct i2c_algorithm pt3_i2c_algo
= {
44 .master_xfer
= &pt3_i2c_master_xfer
,
45 .functionality
= &pt3_i2c_functionality
,
48 static const struct pt3_adap_config adap_conf
[PT3_NUM_FE
] = {
51 I2C_BOARD_INFO(TC90522_I2C_DEV_SAT
, 0x11),
54 I2C_BOARD_INFO("qm1d1c0042", 0x63),
56 .tuner_cfg
.qm1d1c0042
= {
59 .init_freq
= 1049480 - 300,
63 I2C_BOARD_INFO(TC90522_I2C_DEV_TER
, 0x10),
66 I2C_BOARD_INFO("mxl301rf", 0x62),
68 .init_freq
= 515142857,
72 I2C_BOARD_INFO(TC90522_I2C_DEV_SAT
, 0x13),
75 I2C_BOARD_INFO("qm1d1c0042", 0x60),
77 .tuner_cfg
.qm1d1c0042
= {
80 .init_freq
= 1049480 + 300,
84 I2C_BOARD_INFO(TC90522_I2C_DEV_TER
, 0x12),
87 I2C_BOARD_INFO("mxl301rf", 0x61),
89 .init_freq
= 521142857,
100 pt3_demod_write(struct pt3_adapter
*adap
, const struct reg_val
*data
, int num
)
106 msg
.addr
= adap
->i2c_demod
->addr
;
109 for (i
= 0; i
< num
; i
++) {
110 msg
.buf
= (u8
*)&data
[i
];
111 ret
= i2c_transfer(adap
->i2c_demod
->adapter
, &msg
, 1);
120 static inline void pt3_lnb_ctrl(struct pt3_board
*pt3
, bool on
)
122 iowrite32((on
? 0x0f : 0x0c), pt3
->regs
[0] + REG_SYSTEM_W
);
125 static inline struct pt3_adapter
*pt3_find_adapter(struct dvb_frontend
*fe
)
127 struct pt3_board
*pt3
;
132 for (i
= 0; i
< PT3_NUM_FE
; i
++)
133 if (pt3
->adaps
[i
]->fe
== fe
)
134 return pt3
->adaps
[i
];
136 return container_of(fe
->dvb
, struct pt3_adapter
, dvb_adap
);
140 * all 4 tuners in PT3 are packaged in a can module (Sharp VA4M6JC2103).
141 * it seems that they share the power lines and Amp power line and
142 * adaps[3] controls those powers.
145 pt3_set_tuner_power(struct pt3_board
*pt3
, bool tuner_on
, bool amp_on
)
147 struct reg_val rv
= { 0x1e, 0x99 };
153 return pt3_demod_write(pt3
->adaps
[PT3_NUM_FE
- 1], &rv
, 1);
156 static int pt3_set_lna(struct dvb_frontend
*fe
)
158 struct pt3_adapter
*adap
;
159 struct pt3_board
*pt3
;
163 /* LNA is shared btw. 2 TERR-tuners */
165 adap
= pt3_find_adapter(fe
);
166 val
= fe
->dtv_property_cache
.lna
;
167 if (val
== LNA_AUTO
|| val
== adap
->cur_lna
)
170 pt3
= adap
->dvb_adap
.priv
;
171 if (mutex_lock_interruptible(&pt3
->lock
))
178 if (val
&& pt3
->lna_on_cnt
<= 1) {
180 ret
= pt3_set_tuner_power(pt3
, true, true);
181 } else if (!val
&& pt3
->lna_on_cnt
<= 0) {
183 ret
= pt3_set_tuner_power(pt3
, true, false);
186 mutex_unlock(&pt3
->lock
);
187 adap
->cur_lna
= (val
!= 0);
191 static int pt3_set_voltage(struct dvb_frontend
*fe
, enum fe_sec_voltage volt
)
193 struct pt3_adapter
*adap
;
194 struct pt3_board
*pt3
;
197 /* LNB power is shared btw. 2 SAT-tuners */
199 adap
= pt3_find_adapter(fe
);
200 on
= (volt
!= SEC_VOLTAGE_OFF
);
201 if (on
== adap
->cur_lnb
)
204 pt3
= adap
->dvb_adap
.priv
;
205 if (mutex_lock_interruptible(&pt3
->lock
))
212 if (on
&& pt3
->lnb_on_cnt
<= 1) {
214 pt3_lnb_ctrl(pt3
, true);
215 } else if (!on
&& pt3
->lnb_on_cnt
<= 0) {
217 pt3_lnb_ctrl(pt3
, false);
219 mutex_unlock(&pt3
->lock
);
223 /* register values used in pt3_fe_init() */
225 static const struct reg_val init0_sat
[] = {
229 static const struct reg_val init0_ter
[] = {
233 static const struct reg_val cfg_sat
[] = {
237 static const struct reg_val cfg_ter
[] = {
242 * pt3_fe_init: initialize demod sub modules and ISDB-T tuners all at once.
244 * As for demod IC (TC90522) and ISDB-T tuners (MxL301RF),
245 * the i2c sequences for init'ing them are not public and hidden in a ROM,
246 * and include the board specific configurations as well.
247 * They are stored in a lump and cannot be taken out / accessed separately,
248 * thus cannot be moved to the FE/tuner driver.
250 static int pt3_fe_init(struct pt3_board
*pt3
)
253 struct dvb_frontend
*fe
;
256 ret
= pt3_init_all_demods(pt3
);
258 dev_warn(&pt3
->pdev
->dev
, "Failed to init demod chips\n");
262 /* additional config? */
263 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
264 fe
= pt3
->adaps
[i
]->fe
;
266 if (fe
->ops
.delsys
[0] == SYS_ISDBS
)
267 ret
= pt3_demod_write(pt3
->adaps
[i
],
268 init0_sat
, ARRAY_SIZE(init0_sat
));
270 ret
= pt3_demod_write(pt3
->adaps
[i
],
271 init0_ter
, ARRAY_SIZE(init0_ter
));
273 dev_warn(&pt3
->pdev
->dev
,
274 "demod[%d] failed in init sequence0\n", i
);
277 ret
= fe
->ops
.init(fe
);
282 usleep_range(2000, 4000);
283 ret
= pt3_set_tuner_power(pt3
, true, false);
285 dev_warn(&pt3
->pdev
->dev
, "Failed to control tuner module\n");
289 /* output pin configuration */
290 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
291 fe
= pt3
->adaps
[i
]->fe
;
292 if (fe
->ops
.delsys
[0] == SYS_ISDBS
)
293 ret
= pt3_demod_write(pt3
->adaps
[i
],
294 cfg_sat
, ARRAY_SIZE(cfg_sat
));
296 ret
= pt3_demod_write(pt3
->adaps
[i
],
297 cfg_ter
, ARRAY_SIZE(cfg_ter
));
299 dev_warn(&pt3
->pdev
->dev
,
300 "demod[%d] failed in init sequence1\n", i
);
304 usleep_range(4000, 6000);
306 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
307 fe
= pt3
->adaps
[i
]->fe
;
308 if (fe
->ops
.delsys
[0] != SYS_ISDBS
)
310 /* init and wake-up ISDB-S tuners */
311 ret
= fe
->ops
.tuner_ops
.init(fe
);
313 dev_warn(&pt3
->pdev
->dev
,
314 "Failed to init SAT-tuner[%d]\n", i
);
318 ret
= pt3_init_all_mxl301rf(pt3
);
320 dev_warn(&pt3
->pdev
->dev
, "Failed to init TERR-tuners\n");
324 ret
= pt3_set_tuner_power(pt3
, true, true);
326 dev_warn(&pt3
->pdev
->dev
, "Failed to control tuner module\n");
330 /* Wake up all tuners and make an initial tuning,
331 * in order to avoid interference among the tuners in the module,
332 * according to the doc from the manufacturer.
334 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
335 fe
= pt3
->adaps
[i
]->fe
;
337 if (fe
->ops
.delsys
[0] == SYS_ISDBT
)
338 ret
= fe
->ops
.tuner_ops
.init(fe
);
339 /* set only when called from pt3_probe(), not resume() */
340 if (ret
== 0 && fe
->dtv_property_cache
.frequency
== 0) {
341 fe
->dtv_property_cache
.frequency
=
342 adap_conf
[i
].init_freq
;
343 ret
= fe
->ops
.tuner_ops
.set_params(fe
);
346 dev_warn(&pt3
->pdev
->dev
,
347 "Failed in initial tuning of tuner[%d]\n", i
);
352 /* and sleep again, waiting to be opened by users. */
353 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
354 fe
= pt3
->adaps
[i
]->fe
;
355 if (fe
->ops
.tuner_ops
.sleep
)
356 ret
= fe
->ops
.tuner_ops
.sleep(fe
);
360 ret
= fe
->ops
.sleep(fe
);
363 if (fe
->ops
.delsys
[0] == SYS_ISDBS
)
364 fe
->ops
.set_voltage
= &pt3_set_voltage
;
366 fe
->ops
.set_lna
= &pt3_set_lna
;
368 if (i
< PT3_NUM_FE
) {
369 dev_warn(&pt3
->pdev
->dev
, "FE[%d] failed to standby\n", i
);
376 static int pt3_attach_fe(struct pt3_board
*pt3
, int i
)
378 struct i2c_board_info info
;
379 struct tc90522_config cfg
;
380 struct i2c_client
*cl
;
381 struct dvb_adapter
*dvb_adap
;
384 info
= adap_conf
[i
].demod_info
;
385 cfg
= adap_conf
[i
].demod_cfg
;
386 cfg
.tuner_i2c
= NULL
;
387 info
.platform_data
= &cfg
;
390 request_module("tc90522");
391 cl
= i2c_new_device(&pt3
->i2c_adap
, &info
);
392 if (!cl
|| !cl
->dev
.driver
)
394 pt3
->adaps
[i
]->i2c_demod
= cl
;
395 if (!try_module_get(cl
->dev
.driver
->owner
))
396 goto err_demod_i2c_unregister_device
;
398 if (!strncmp(cl
->name
, TC90522_I2C_DEV_SAT
,
399 strlen(TC90522_I2C_DEV_SAT
))) {
400 struct qm1d1c0042_config tcfg
;
402 tcfg
= adap_conf
[i
].tuner_cfg
.qm1d1c0042
;
404 info
= adap_conf
[i
].tuner_info
;
405 info
.platform_data
= &tcfg
;
406 request_module("qm1d1c0042");
407 cl
= i2c_new_device(cfg
.tuner_i2c
, &info
);
409 struct mxl301rf_config tcfg
;
411 tcfg
= adap_conf
[i
].tuner_cfg
.mxl301rf
;
413 info
= adap_conf
[i
].tuner_info
;
414 info
.platform_data
= &tcfg
;
415 request_module("mxl301rf");
416 cl
= i2c_new_device(cfg
.tuner_i2c
, &info
);
418 if (!cl
|| !cl
->dev
.driver
)
419 goto err_demod_module_put
;
420 pt3
->adaps
[i
]->i2c_tuner
= cl
;
421 if (!try_module_get(cl
->dev
.driver
->owner
))
422 goto err_tuner_i2c_unregister_device
;
424 dvb_adap
= &pt3
->adaps
[one_adapter
? 0 : i
]->dvb_adap
;
425 ret
= dvb_register_frontend(dvb_adap
, cfg
.fe
);
427 goto err_tuner_module_put
;
428 pt3
->adaps
[i
]->fe
= cfg
.fe
;
431 err_tuner_module_put
:
432 module_put(pt3
->adaps
[i
]->i2c_tuner
->dev
.driver
->owner
);
433 err_tuner_i2c_unregister_device
:
434 i2c_unregister_device(pt3
->adaps
[i
]->i2c_tuner
);
435 err_demod_module_put
:
436 module_put(pt3
->adaps
[i
]->i2c_demod
->dev
.driver
->owner
);
437 err_demod_i2c_unregister_device
:
438 i2c_unregister_device(pt3
->adaps
[i
]->i2c_demod
);
444 static int pt3_fetch_thread(void *data
)
446 struct pt3_adapter
*adap
= data
;
450 #define PT3_INITIAL_BUF_DROPS 4
451 #define PT3_FETCH_DELAY 10
452 #define PT3_FETCH_DELAY_DELTA 2
454 pt3_init_dmabuf(adap
);
455 adap
->num_discard
= PT3_INITIAL_BUF_DROPS
;
457 dev_dbg(adap
->dvb_adap
.device
, "PT3: [%s] started\n",
460 while (!kthread_freezable_should_stop(&was_frozen
)) {
462 adap
->num_discard
= PT3_INITIAL_BUF_DROPS
;
466 delay
= PT3_FETCH_DELAY
* NSEC_PER_MSEC
;
467 set_current_state(TASK_UNINTERRUPTIBLE
);
468 freezable_schedule_hrtimeout_range(&delay
,
469 PT3_FETCH_DELAY_DELTA
* NSEC_PER_MSEC
,
472 dev_dbg(adap
->dvb_adap
.device
, "PT3: [%s] exited\n",
478 static int pt3_start_streaming(struct pt3_adapter
*adap
)
480 struct task_struct
*thread
;
482 /* start fetching thread */
483 thread
= kthread_run(pt3_fetch_thread
, adap
, "pt3-ad%i-dmx%i",
484 adap
->dvb_adap
.num
, adap
->dmxdev
.dvbdev
->id
);
485 if (IS_ERR(thread
)) {
486 int ret
= PTR_ERR(thread
);
488 dev_warn(adap
->dvb_adap
.device
,
489 "PT3 (adap:%d, dmx:%d): failed to start kthread\n",
490 adap
->dvb_adap
.num
, adap
->dmxdev
.dvbdev
->id
);
493 adap
->thread
= thread
;
495 return pt3_start_dma(adap
);
498 static int pt3_stop_streaming(struct pt3_adapter
*adap
)
502 ret
= pt3_stop_dma(adap
);
504 dev_warn(adap
->dvb_adap
.device
,
505 "PT3: failed to stop streaming of adap:%d/FE:%d\n",
506 adap
->dvb_adap
.num
, adap
->fe
->id
);
508 /* kill the fetching thread */
509 ret
= kthread_stop(adap
->thread
);
513 static int pt3_start_feed(struct dvb_demux_feed
*feed
)
515 struct pt3_adapter
*adap
;
517 if (signal_pending(current
))
520 adap
= container_of(feed
->demux
, struct pt3_adapter
, demux
);
524 if (adap
->num_feeds
!= 1) {
525 dev_warn(adap
->dvb_adap
.device
,
526 "%s: unmatched start/stop_feed in adap:%i/dmx:%i\n",
527 __func__
, adap
->dvb_adap
.num
, adap
->dmxdev
.dvbdev
->id
);
531 return pt3_start_streaming(adap
);
535 static int pt3_stop_feed(struct dvb_demux_feed
*feed
)
537 struct pt3_adapter
*adap
;
539 adap
= container_of(feed
->demux
, struct pt3_adapter
, demux
);
542 if (adap
->num_feeds
> 0 || !adap
->thread
)
546 return pt3_stop_streaming(adap
);
550 static int pt3_alloc_adapter(struct pt3_board
*pt3
, int index
)
553 struct pt3_adapter
*adap
;
554 struct dvb_adapter
*da
;
556 adap
= kzalloc(sizeof(*adap
), GFP_KERNEL
);
560 pt3
->adaps
[index
] = adap
;
561 adap
->adap_idx
= index
;
563 if (index
== 0 || !one_adapter
) {
564 ret
= dvb_register_adapter(&adap
->dvb_adap
, "PT3 DVB",
565 THIS_MODULE
, &pt3
->pdev
->dev
, adapter_nr
);
567 dev_err(&pt3
->pdev
->dev
,
568 "failed to register adapter dev\n");
571 da
= &adap
->dvb_adap
;
573 da
= &pt3
->adaps
[0]->dvb_adap
;
575 adap
->dvb_adap
.priv
= pt3
;
576 adap
->demux
.dmx
.capabilities
= DMX_TS_FILTERING
| DMX_SECTION_FILTERING
;
577 adap
->demux
.priv
= adap
;
578 adap
->demux
.feednum
= 256;
579 adap
->demux
.filternum
= 256;
580 adap
->demux
.start_feed
= pt3_start_feed
;
581 adap
->demux
.stop_feed
= pt3_stop_feed
;
582 ret
= dvb_dmx_init(&adap
->demux
);
584 dev_err(&pt3
->pdev
->dev
, "failed to init dmx dev\n");
588 adap
->dmxdev
.filternum
= 256;
589 adap
->dmxdev
.demux
= &adap
->demux
.dmx
;
590 ret
= dvb_dmxdev_init(&adap
->dmxdev
, da
);
592 dev_err(&pt3
->pdev
->dev
, "failed to init dmxdev\n");
596 ret
= pt3_alloc_dmabuf(adap
);
598 dev_err(&pt3
->pdev
->dev
, "failed to alloc DMA buffers\n");
605 pt3_free_dmabuf(adap
);
606 dvb_dmxdev_release(&adap
->dmxdev
);
608 dvb_dmx_release(&adap
->demux
);
610 if (index
== 0 || !one_adapter
)
611 dvb_unregister_adapter(da
);
614 pt3
->adaps
[index
] = NULL
;
618 static void pt3_cleanup_adapter(struct pt3_board
*pt3
, int index
)
620 struct pt3_adapter
*adap
;
621 struct dmx_demux
*dmx
;
623 adap
= pt3
->adaps
[index
];
627 /* stop demux kthread */
629 pt3_stop_streaming(adap
);
631 dmx
= &adap
->demux
.dmx
;
634 adap
->fe
->callback
= NULL
;
635 if (adap
->fe
->frontend_priv
)
636 dvb_unregister_frontend(adap
->fe
);
637 if (adap
->i2c_tuner
) {
638 module_put(adap
->i2c_tuner
->dev
.driver
->owner
);
639 i2c_unregister_device(adap
->i2c_tuner
);
641 if (adap
->i2c_demod
) {
642 module_put(adap
->i2c_demod
->dev
.driver
->owner
);
643 i2c_unregister_device(adap
->i2c_demod
);
646 pt3_free_dmabuf(adap
);
647 dvb_dmxdev_release(&adap
->dmxdev
);
648 dvb_dmx_release(&adap
->demux
);
649 if (index
== 0 || !one_adapter
)
650 dvb_unregister_adapter(&adap
->dvb_adap
);
652 pt3
->adaps
[index
] = NULL
;
655 #ifdef CONFIG_PM_SLEEP
657 static int pt3_suspend(struct device
*dev
)
659 struct pci_dev
*pdev
= to_pci_dev(dev
);
660 struct pt3_board
*pt3
= pci_get_drvdata(pdev
);
662 struct pt3_adapter
*adap
;
664 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
665 adap
= pt3
->adaps
[i
];
666 if (adap
->num_feeds
> 0)
668 dvb_frontend_suspend(adap
->fe
);
669 pt3_free_dmabuf(adap
);
672 pt3_lnb_ctrl(pt3
, false);
673 pt3_set_tuner_power(pt3
, false, false);
677 static int pt3_resume(struct device
*dev
)
679 struct pci_dev
*pdev
= to_pci_dev(dev
);
680 struct pt3_board
*pt3
= pci_get_drvdata(pdev
);
682 struct pt3_adapter
*adap
;
684 ret
= pt3_fe_init(pt3
);
688 if (pt3
->lna_on_cnt
> 0)
689 pt3_set_tuner_power(pt3
, true, true);
690 if (pt3
->lnb_on_cnt
> 0)
691 pt3_lnb_ctrl(pt3
, true);
693 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
694 adap
= pt3
->adaps
[i
];
695 dvb_frontend_resume(adap
->fe
);
696 ret
= pt3_alloc_dmabuf(adap
);
698 dev_err(&pt3
->pdev
->dev
, "failed to alloc DMA bufs\n");
701 if (adap
->num_feeds
> 0)
708 #endif /* CONFIG_PM_SLEEP */
711 static void pt3_remove(struct pci_dev
*pdev
)
713 struct pt3_board
*pt3
;
716 pt3
= pci_get_drvdata(pdev
);
717 for (i
= PT3_NUM_FE
- 1; i
>= 0; i
--)
718 pt3_cleanup_adapter(pt3
, i
);
719 i2c_del_adapter(&pt3
->i2c_adap
);
721 pci_iounmap(pt3
->pdev
, pt3
->regs
[0]);
722 pci_iounmap(pt3
->pdev
, pt3
->regs
[1]);
723 pci_release_regions(pdev
);
724 pci_disable_device(pdev
);
728 static int pt3_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
733 struct pt3_board
*pt3
;
734 struct i2c_adapter
*i2c
;
736 if (pci_read_config_byte(pdev
, PCI_REVISION_ID
, &rev
) || rev
!= 1)
739 ret
= pci_enable_device(pdev
);
742 pci_set_master(pdev
);
744 ret
= pci_request_regions(pdev
, DRV_NAME
);
746 goto err_disable_device
;
748 ret
= dma_set_mask(&pdev
->dev
, DMA_BIT_MASK(64));
750 dma_set_coherent_mask(&pdev
->dev
, DMA_BIT_MASK(64));
752 ret
= dma_set_mask(&pdev
->dev
, DMA_BIT_MASK(32));
754 dma_set_coherent_mask(&pdev
->dev
, DMA_BIT_MASK(32));
756 dev_err(&pdev
->dev
, "Failed to set DMA mask\n");
757 goto err_release_regions
;
759 dev_info(&pdev
->dev
, "Use 32bit DMA\n");
762 pt3
= kzalloc(sizeof(*pt3
), GFP_KERNEL
);
765 goto err_release_regions
;
767 pci_set_drvdata(pdev
, pt3
);
769 mutex_init(&pt3
->lock
);
770 pt3
->regs
[0] = pci_ioremap_bar(pdev
, 0);
771 pt3
->regs
[1] = pci_ioremap_bar(pdev
, 2);
772 if (pt3
->regs
[0] == NULL
|| pt3
->regs
[1] == NULL
) {
773 dev_err(&pdev
->dev
, "Failed to ioremap\n");
778 ver
= ioread32(pt3
->regs
[0] + REG_VERSION
);
779 if ((ver
>> 16) != 0x0301) {
780 dev_warn(&pdev
->dev
, "PT%d, I/F-ver.:%d not supported\n",
781 ver
>> 24, (ver
& 0x00ff0000) >> 16);
786 pt3
->num_bufs
= clamp_val(num_bufs
, MIN_DATA_BUFS
, MAX_DATA_BUFS
);
788 pt3
->i2c_buf
= kmalloc(sizeof(*pt3
->i2c_buf
), GFP_KERNEL
);
789 if (pt3
->i2c_buf
== NULL
) {
793 i2c
= &pt3
->i2c_adap
;
794 i2c
->owner
= THIS_MODULE
;
795 i2c
->algo
= &pt3_i2c_algo
;
796 i2c
->algo_data
= NULL
;
797 i2c
->dev
.parent
= &pdev
->dev
;
798 strlcpy(i2c
->name
, DRV_NAME
, sizeof(i2c
->name
));
799 i2c_set_adapdata(i2c
, pt3
);
800 ret
= i2c_add_adapter(i2c
);
804 for (i
= 0; i
< PT3_NUM_FE
; i
++) {
805 ret
= pt3_alloc_adapter(pt3
, i
);
809 ret
= pt3_attach_fe(pt3
, i
);
813 if (i
< PT3_NUM_FE
) {
814 dev_err(&pdev
->dev
, "Failed to create FE%d\n", i
);
815 goto err_cleanup_adapters
;
818 ret
= pt3_fe_init(pt3
);
820 dev_err(&pdev
->dev
, "Failed to init frontends\n");
822 goto err_cleanup_adapters
;
826 "successfully init'ed PT%d (fw:0x%02x, I/F:0x%02x)\n",
827 ver
>> 24, (ver
>> 8) & 0xff, (ver
>> 16) & 0xff);
830 err_cleanup_adapters
:
832 pt3_cleanup_adapter(pt3
, i
--);
833 i2c_del_adapter(i2c
);
838 pci_iounmap(pdev
, pt3
->regs
[0]);
840 pci_iounmap(pdev
, pt3
->regs
[1]);
844 pci_release_regions(pdev
);
846 pci_disable_device(pdev
);
851 static const struct pci_device_id pt3_id_table
[] = {
852 { PCI_DEVICE_SUB(0x1172, 0x4c15, 0xee8d, 0x0368) },
855 MODULE_DEVICE_TABLE(pci
, pt3_id_table
);
857 static SIMPLE_DEV_PM_OPS(pt3_pm_ops
, pt3_suspend
, pt3_resume
);
859 static struct pci_driver pt3_driver
= {
862 .remove
= pt3_remove
,
863 .id_table
= pt3_id_table
,
865 .driver
.pm
= &pt3_pm_ops
,
868 module_pci_driver(pt3_driver
);
870 MODULE_DESCRIPTION("Earthsoft PT3 Driver");
871 MODULE_AUTHOR("Akihiro TSUKADA");
872 MODULE_LICENSE("GPL");