Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 1 | /* |
| 2 | Mantis VP-1034 driver |
| 3 | |
Manu Abraham | 8825a09 | 2009-12-15 09:13:49 -0300 | [diff] [blame] | 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 5 | |
| 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 Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 21 | #include <linux/signal.h> |
| 22 | #include <linux/sched.h> |
| 23 | #include <linux/interrupt.h> |
Alexey Dobriyan | b7f080c | 2011-06-16 11:01:34 +0000 | [diff] [blame] | 24 | #include <asm/io.h> |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 25 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 26 | #include "dmxdev.h" |
| 27 | #include "dvbdev.h" |
| 28 | #include "dvb_demux.h" |
| 29 | #include "dvb_frontend.h" |
| 30 | #include "dvb_net.h" |
| 31 | |
| 32 | #include "mb86a16.h" |
| 33 | #include "mantis_common.h" |
| 34 | #include "mantis_ioc.h" |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 35 | #include "mantis_dvb.h" |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 36 | #include "mantis_vp1034.h" |
| 37 | #include "mantis_reg.h" |
| 38 | |
Hans Verkuil | 967a378 | 2014-08-20 18:26:40 -0300 | [diff] [blame] | 39 | static struct mb86a16_config vp1034_mb86a16_config = { |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 40 | .demod_address = 0x08, |
| 41 | .set_voltage = vp1034_set_voltage, |
| 42 | }; |
| 43 | |
Manu Abraham | df0cca1 | 2009-12-02 22:07:24 -0300 | [diff] [blame] | 44 | #define MANTIS_MODEL_NAME "VP-1034" |
| 45 | #define MANTIS_DEV_TYPE "DVB-S/DSS" |
| 46 | |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 47 | int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
| 48 | { |
| 49 | struct mantis_pci *mantis = fe->dvb->priv; |
| 50 | |
| 51 | switch (voltage) { |
| 52 | case SEC_VOLTAGE_13: |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 53 | dprintk(MANTIS_ERROR, 1, "Polarization=[13V]"); |
Ben Hutchings | 3037fd1 | 2010-11-14 14:56:00 -0300 | [diff] [blame] | 54 | mantis_gpio_set_bits(mantis, 13, 1); |
| 55 | mantis_gpio_set_bits(mantis, 14, 0); |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 56 | break; |
| 57 | case SEC_VOLTAGE_18: |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 58 | dprintk(MANTIS_ERROR, 1, "Polarization=[18V]"); |
Ben Hutchings | 3037fd1 | 2010-11-14 14:56:00 -0300 | [diff] [blame] | 59 | mantis_gpio_set_bits(mantis, 13, 1); |
| 60 | mantis_gpio_set_bits(mantis, 14, 1); |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 61 | break; |
| 62 | case SEC_VOLTAGE_OFF: |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 63 | dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN"); |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 64 | break; |
| 65 | default: |
Manu Abraham | f5ae4f6 | 2009-12-15 08:47:21 -0300 | [diff] [blame] | 66 | dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage); |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 67 | return -EINVAL; |
| 68 | } |
| 69 | mmwrite(0x00, MANTIS_GPIF_DOUT); |
| 70 | |
| 71 | return 0; |
| 72 | } |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 73 | |
| 74 | static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) |
| 75 | { |
| 76 | struct i2c_adapter *adapter = &mantis->adapter; |
| 77 | |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 78 | int err = 0; |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 79 | |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 80 | err = mantis_frontend_power(mantis, POWER_ON); |
| 81 | if (err == 0) { |
| 82 | mantis_frontend_soft_reset(mantis); |
| 83 | msleep(250); |
| 84 | |
| 85 | dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)"); |
Bjørn Mork | a22407f | 2010-11-14 14:24:36 -0300 | [diff] [blame] | 86 | fe = dvb_attach(mb86a16_attach, &vp1034_mb86a16_config, adapter); |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 87 | if (fe) { |
| 88 | dprintk(MANTIS_ERROR, 1, |
| 89 | "found MB86A16 DVB-S/DSS frontend @0x%02x", |
| 90 | vp1034_mb86a16_config.demod_address); |
| 91 | |
| 92 | } else { |
| 93 | return -1; |
| 94 | } |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 95 | } else { |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 96 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", |
| 97 | adapter->name, |
| 98 | err); |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 99 | |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 100 | return -EIO; |
| 101 | } |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 102 | mantis->fe = fe; |
| 103 | dprintk(MANTIS_ERROR, 1, "Done!"); |
| 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | struct mantis_hwconfig vp1034_config = { |
| 109 | .model_name = MANTIS_MODEL_NAME, |
| 110 | .dev_type = MANTIS_DEV_TYPE, |
| 111 | .ts_size = MANTIS_TS_204, |
| 112 | |
| 113 | .baud_rate = MANTIS_BAUD_9600, |
| 114 | .parity = MANTIS_PARITY_NONE, |
| 115 | .bytes = 0, |
| 116 | |
| 117 | .frontend_init = vp1034_frontend_init, |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 118 | .power = GPIF_A12, |
| 119 | .reset = GPIF_A13, |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 120 | }; |