1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 Mantis VP-3030 driver
4
5 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
6
7 */
8
9 #include <linux/signal.h>
10 #include <linux/sched.h>
11 #include <linux/interrupt.h>
12
13 #include <media/dmxdev.h>
14 #include <media/dvbdev.h>
15 #include <media/dvb_demux.h>
16 #include <media/dvb_frontend.h>
17 #include <media/dvb_net.h>
18
19 #include "zl10353.h"
20 #include "tda665x.h"
21 #include "mantis_common.h"
22 #include "mantis_ioc.h"
23 #include "mantis_dvb.h"
24 #include "mantis_vp3030.h"
25
26 static struct zl10353_config mantis_vp3030_config = {
27 .demod_address = 0x0f,
28 };
29
30 static struct tda665x_config env57h12d5_config = {
31 .name = "ENV57H12D5 (ET-50DT)",
32 .addr = 0x60,
33 .frequency_min = 47 * MHz,
34 .frequency_max = 862 * MHz,
35 .frequency_offst = 3616667,
36 .ref_multiplier = 6, /* 1/6 MHz */
37 .ref_divider = 100000, /* 1/6 MHz */
38 };
39
40 #define MANTIS_MODEL_NAME "VP-3030"
41 #define MANTIS_DEV_TYPE "DVB-T"
42
43
vp3030_frontend_init(struct mantis_pci * mantis,struct dvb_frontend * fe)44 static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
45 {
46 struct i2c_adapter *adapter = &mantis->adapter;
47 struct mantis_hwconfig *config = mantis->hwconfig;
48 int err = 0;
49
50 mantis_gpio_set_bits(mantis, config->reset, 0);
51 msleep(100);
52 err = mantis_frontend_power(mantis, POWER_ON);
53 msleep(100);
54 mantis_gpio_set_bits(mantis, config->reset, 1);
55
56 if (err == 0) {
57 msleep(250);
58 dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
59 fe = dvb_attach(zl10353_attach, &mantis_vp3030_config, adapter);
60
61 if (!fe)
62 return -1;
63
64 dvb_attach(tda665x_attach, fe, &env57h12d5_config, adapter);
65 } else {
66 dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
67 adapter->name,
68 err);
69
70 return -EIO;
71
72 }
73 mantis->fe = fe;
74 dprintk(MANTIS_ERROR, 1, "Done!");
75
76 return 0;
77 }
78
79 struct mantis_hwconfig vp3030_config = {
80 .model_name = MANTIS_MODEL_NAME,
81 .dev_type = MANTIS_DEV_TYPE,
82 .ts_size = MANTIS_TS_188,
83
84 .baud_rate = MANTIS_BAUD_9600,
85 .parity = MANTIS_PARITY_NONE,
86 .bytes = 0,
87
88 .frontend_init = vp3030_frontend_init,
89 .power = GPIF_A12,
90 .reset = GPIF_A13,
91
92 .i2c_mode = MANTIS_BYTE_MODE
93 };
94