• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 	Mantis VP-1034 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 #include <asm/io.h>
13 
14 #include <media/dmxdev.h>
15 #include <media/dvbdev.h>
16 #include <media/dvb_demux.h>
17 #include <media/dvb_frontend.h>
18 #include <media/dvb_net.h>
19 
20 #include "mb86a16.h"
21 #include "mantis_common.h"
22 #include "mantis_ioc.h"
23 #include "mantis_dvb.h"
24 #include "mantis_vp1034.h"
25 #include "mantis_reg.h"
26 
27 static const struct mb86a16_config vp1034_mb86a16_config = {
28 	.demod_address	= 0x08,
29 	.set_voltage	= vp1034_set_voltage,
30 };
31 
32 #define MANTIS_MODEL_NAME	"VP-1034"
33 #define MANTIS_DEV_TYPE		"DVB-S/DSS"
34 
vp1034_set_voltage(struct dvb_frontend * fe,enum fe_sec_voltage voltage)35 int vp1034_set_voltage(struct dvb_frontend *fe, enum fe_sec_voltage voltage)
36 {
37 	struct mantis_pci *mantis = fe->dvb->priv;
38 
39 	switch (voltage) {
40 	case SEC_VOLTAGE_13:
41 		dprintk(MANTIS_ERROR, 1, "Polarization=[13V]");
42 		mantis_gpio_set_bits(mantis, 13, 1);
43 		mantis_gpio_set_bits(mantis, 14, 0);
44 		break;
45 	case SEC_VOLTAGE_18:
46 		dprintk(MANTIS_ERROR, 1, "Polarization=[18V]");
47 		mantis_gpio_set_bits(mantis, 13, 1);
48 		mantis_gpio_set_bits(mantis, 14, 1);
49 		break;
50 	case SEC_VOLTAGE_OFF:
51 		dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN");
52 		break;
53 	default:
54 		dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage);
55 		return -EINVAL;
56 	}
57 	mmwrite(0x00, MANTIS_GPIF_DOUT);
58 
59 	return 0;
60 }
61 
vp1034_frontend_init(struct mantis_pci * mantis,struct dvb_frontend * fe)62 static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
63 {
64 	struct i2c_adapter *adapter	= &mantis->adapter;
65 
66 	int err = 0;
67 
68 	err = mantis_frontend_power(mantis, POWER_ON);
69 	if (err == 0) {
70 		mantis_frontend_soft_reset(mantis);
71 		msleep(250);
72 
73 		dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
74 		fe = dvb_attach(mb86a16_attach, &vp1034_mb86a16_config, adapter);
75 		if (fe) {
76 			dprintk(MANTIS_ERROR, 1,
77 			"found MB86A16 DVB-S/DSS frontend @0x%02x",
78 			vp1034_mb86a16_config.demod_address);
79 
80 		} else {
81 			return -1;
82 		}
83 	} else {
84 		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
85 			adapter->name,
86 			err);
87 
88 		return -EIO;
89 	}
90 	mantis->fe = fe;
91 	dprintk(MANTIS_ERROR, 1, "Done!");
92 
93 	return 0;
94 }
95 
96 struct mantis_hwconfig vp1034_config = {
97 	.model_name	= MANTIS_MODEL_NAME,
98 	.dev_type	= MANTIS_DEV_TYPE,
99 	.ts_size	= MANTIS_TS_204,
100 
101 	.baud_rate	= MANTIS_BAUD_9600,
102 	.parity		= MANTIS_PARITY_NONE,
103 	.bytes		= 0,
104 
105 	.frontend_init	= vp1034_frontend_init,
106 	.power		= GPIF_A12,
107 	.reset		= GPIF_A13,
108 };
109