1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 	Hopper VP-3028 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 "mantis_common.h"
21 #include "mantis_ioc.h"
22 #include "mantis_dvb.h"
23 #include "hopper_vp3028.h"
24 
25 static struct zl10353_config hopper_vp3028_config = {
26 	.demod_address	= 0x0f,
27 };
28 
29 #define MANTIS_MODEL_NAME	"VP-3028"
30 #define MANTIS_DEV_TYPE		"DVB-T"
31 
vp3028_frontend_init(struct mantis_pci * mantis,struct dvb_frontend * fe)32 static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
33 {
34 	struct i2c_adapter *adapter	= &mantis->adapter;
35 	struct mantis_hwconfig *config	= mantis->hwconfig;
36 	int err;
37 
38 	mantis_gpio_set_bits(mantis, config->reset, 0);
39 	msleep(100);
40 	err = mantis_frontend_power(mantis, POWER_ON);
41 	msleep(100);
42 	mantis_gpio_set_bits(mantis, config->reset, 1);
43 
44 	err = mantis_frontend_power(mantis, POWER_ON);
45 	if (err == 0) {
46 		msleep(250);
47 		dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
48 		fe = dvb_attach(zl10353_attach, &hopper_vp3028_config, adapter);
49 
50 		if (!fe)
51 			return -1;
52 	} else {
53 		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
54 			adapter->name,
55 			err);
56 
57 		return -EIO;
58 	}
59 	dprintk(MANTIS_ERROR, 1, "Done!");
60 
61 	return 0;
62 }
63 
64 struct mantis_hwconfig vp3028_config = {
65 	.model_name	= MANTIS_MODEL_NAME,
66 	.dev_type	= MANTIS_DEV_TYPE,
67 	.ts_size	= MANTIS_TS_188,
68 
69 	.baud_rate	= MANTIS_BAUD_9600,
70 	.parity		= MANTIS_PARITY_NONE,
71 	.bytes		= 0,
72 
73 	.frontend_init	= vp3028_frontend_init,
74 	.power		= GPIF_A00,
75 	.reset		= GPIF_A03,
76 };
77