blob: 8e6ae558ee57424b40f5622ce44ea86ca2c1a737 [file] [log] [blame]
Manu Abraham41e840b2009-12-02 21:57:10 -03001/*
2 Mantis VP-1034 driver
3
Manu Abraham8825a092009-12-15 09:13:49 -03004 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
Manu Abraham41e840b2009-12-02 21:57:10 -03005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
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.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
Manu Abrahamb3b96142009-12-04 05:41:11 -030021#include <linux/signal.h>
22#include <linux/sched.h>
23#include <linux/interrupt.h>
Manu Abraham41e840b2009-12-02 21:57:10 -030024
Manu Abrahamb3b96142009-12-04 05:41:11 -030025#include "dmxdev.h"
26#include "dvbdev.h"
27#include "dvb_demux.h"
28#include "dvb_frontend.h"
29#include "dvb_net.h"
30
31#include "mb86a16.h"
32#include "mantis_common.h"
33#include "mantis_ioc.h"
Manu Abrahambc832fa2009-12-04 05:57:28 -030034#include "mantis_dvb.h"
Manu Abrahamb3b96142009-12-04 05:41:11 -030035#include "mantis_vp1034.h"
36#include "mantis_reg.h"
37
38struct mb86a16_config vp1034_mb86a16_config = {
Manu Abraham41e840b2009-12-02 21:57:10 -030039 .demod_address = 0x08,
40 .set_voltage = vp1034_set_voltage,
41};
42
Manu Abrahamdf0cca12009-12-02 22:07:24 -030043#define MANTIS_MODEL_NAME "VP-1034"
44#define MANTIS_DEV_TYPE "DVB-S/DSS"
45
Manu Abraham41e840b2009-12-02 21:57:10 -030046int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
47{
48 struct mantis_pci *mantis = fe->dvb->priv;
49
50 switch (voltage) {
51 case SEC_VOLTAGE_13:
Manu Abrahamb3b96142009-12-04 05:41:11 -030052 dprintk(MANTIS_ERROR, 1, "Polarization=[13V]");
Manu Abraham715d3412009-12-03 05:37:51 -030053 gpio_set_bits(mantis, 13, 1);
54 gpio_set_bits(mantis, 14, 0);
Manu Abraham41e840b2009-12-02 21:57:10 -030055 break;
56 case SEC_VOLTAGE_18:
Manu Abrahamb3b96142009-12-04 05:41:11 -030057 dprintk(MANTIS_ERROR, 1, "Polarization=[18V]");
Manu Abraham715d3412009-12-03 05:37:51 -030058 gpio_set_bits(mantis, 13, 1);
59 gpio_set_bits(mantis, 14, 1);
Manu Abraham41e840b2009-12-02 21:57:10 -030060 break;
61 case SEC_VOLTAGE_OFF:
Manu Abrahamb3b96142009-12-04 05:41:11 -030062 dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN");
Manu Abraham41e840b2009-12-02 21:57:10 -030063 break;
64 default:
Manu Abrahamf5ae4f62009-12-15 08:47:21 -030065 dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage);
Manu Abraham41e840b2009-12-02 21:57:10 -030066 return -EINVAL;
67 }
68 mmwrite(0x00, MANTIS_GPIF_DOUT);
69
70 return 0;
71}
Manu Abrahamb3b96142009-12-04 05:41:11 -030072
73static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
74{
75 struct i2c_adapter *adapter = &mantis->adapter;
76
Manu Abrahambc832fa2009-12-04 05:57:28 -030077 int err = 0;
Manu Abrahamb3b96142009-12-04 05:41:11 -030078
Manu Abrahambc832fa2009-12-04 05:57:28 -030079 err = mantis_frontend_power(mantis, POWER_ON);
80 if (err == 0) {
81 mantis_frontend_soft_reset(mantis);
82 msleep(250);
83
84 dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
85 fe = mb86a16_attach(&vp1034_mb86a16_config, adapter);
86 if (fe) {
87 dprintk(MANTIS_ERROR, 1,
88 "found MB86A16 DVB-S/DSS frontend @0x%02x",
89 vp1034_mb86a16_config.demod_address);
90
91 } else {
92 return -1;
93 }
Manu Abrahamb3b96142009-12-04 05:41:11 -030094 } else {
Manu Abrahambc832fa2009-12-04 05:57:28 -030095 dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
96 adapter->name,
97 err);
Manu Abrahamb3b96142009-12-04 05:41:11 -030098
Manu Abrahambc832fa2009-12-04 05:57:28 -030099 return -EIO;
100 }
Manu Abrahamb3b96142009-12-04 05:41:11 -0300101 mantis->fe = fe;
102 dprintk(MANTIS_ERROR, 1, "Done!");
103
104 return 0;
105}
106
107struct mantis_hwconfig vp1034_config = {
108 .model_name = MANTIS_MODEL_NAME,
109 .dev_type = MANTIS_DEV_TYPE,
110 .ts_size = MANTIS_TS_204,
111
112 .baud_rate = MANTIS_BAUD_9600,
113 .parity = MANTIS_PARITY_NONE,
114 .bytes = 0,
115
116 .frontend_init = vp1034_frontend_init,
Manu Abrahambc832fa2009-12-04 05:57:28 -0300117 .power = GPIF_A12,
118 .reset = GPIF_A13,
Manu Abrahamb3b96142009-12-04 05:41:11 -0300119};