Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 1 | /* |
Antti Palosaari | 7978b8a | 2015-04-16 21:36:00 -0300 | [diff] [blame] | 2 | * Montage Technology M88DS3103/M88RS6000 demodulator driver |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> |
| 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. |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef M88DS3103_H |
| 18 | #define M88DS3103_H |
| 19 | |
| 20 | #include <linux/dvb/frontend.h> |
| 21 | |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 22 | /* |
| 23 | * I2C address |
| 24 | * 0x68, |
| 25 | */ |
| 26 | |
| 27 | /** |
| 28 | * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver |
| 29 | * @clk: Clock frequency. |
| 30 | * @i2c_wr_max: Max bytes I2C adapter can write at once. |
| 31 | * @ts_mode: TS mode. |
| 32 | * @ts_clk: TS clock (KHz). |
| 33 | * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising |
| 34 | * edge. |
| 35 | * @spec_inv: Input spectrum inversion. |
| 36 | * @agc: AGC configuration. |
| 37 | * @agc_inv: AGC polarity. |
| 38 | * @clk_out: Clock output. |
| 39 | * @envelope_mode: DiSEqC envelope mode. |
| 40 | * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to |
| 41 | * set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18. |
| 42 | * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to |
| 43 | * enable. 1: pin high to enable, pin low to disable. |
| 44 | * @get_dvb_frontend: Get DVB frontend. |
| 45 | * @get_i2c_adapter: Get I2C adapter. |
| 46 | */ |
| 47 | |
| 48 | struct m88ds3103_platform_data { |
| 49 | u32 clk; |
| 50 | u16 i2c_wr_max; |
| 51 | #define M88DS3103_TS_SERIAL 0 /* TS output pin D0, normal */ |
| 52 | #define M88DS3103_TS_SERIAL_D7 1 /* TS output pin D7 */ |
| 53 | #define M88DS3103_TS_PARALLEL 2 /* TS Parallel mode */ |
| 54 | #define M88DS3103_TS_CI 3 /* TS CI Mode */ |
| 55 | u8 ts_mode:2; |
| 56 | u32 ts_clk; |
| 57 | u8 ts_clk_pol:1; |
| 58 | u8 spec_inv:1; |
| 59 | u8 agc; |
| 60 | u8 agc_inv:1; |
| 61 | #define M88DS3103_CLOCK_OUT_DISABLED 0 |
| 62 | #define M88DS3103_CLOCK_OUT_ENABLED 1 |
| 63 | #define M88DS3103_CLOCK_OUT_ENABLED_DIV2 2 |
| 64 | u8 clk_out:2; |
| 65 | u8 envelope_mode:1; |
| 66 | u8 lnb_hv_pol:1; |
| 67 | u8 lnb_en_pol:1; |
| 68 | |
| 69 | struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); |
| 70 | struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); |
| 71 | |
| 72 | /* private: For legacy media attach wrapper. Do not set value. */ |
| 73 | u8 attach_in_use:1; |
| 74 | }; |
| 75 | |
| 76 | /* |
| 77 | * Do not add new m88ds3103_attach() users! Use I2C bindings instead. |
| 78 | */ |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 79 | struct m88ds3103_config { |
| 80 | /* |
| 81 | * I2C address |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 82 | * Default: none, must set |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 83 | * 0x68, ... |
| 84 | */ |
| 85 | u8 i2c_addr; |
| 86 | |
| 87 | /* |
| 88 | * clock |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 89 | * Default: none, must set |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 90 | * 27000000 |
| 91 | */ |
| 92 | u32 clock; |
| 93 | |
| 94 | /* |
| 95 | * max bytes I2C provider is asked to write at once |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 96 | * Default: none, must set |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 97 | * 33, 65, ... |
| 98 | */ |
| 99 | u16 i2c_wr_max; |
| 100 | |
| 101 | /* |
| 102 | * TS output mode |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 103 | * Default: M88DS3103_TS_SERIAL |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 104 | */ |
| 105 | #define M88DS3103_TS_SERIAL 0 /* TS output pin D0, normal */ |
| 106 | #define M88DS3103_TS_SERIAL_D7 1 /* TS output pin D7 */ |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 107 | #define M88DS3103_TS_PARALLEL 2 /* TS Parallel mode */ |
| 108 | #define M88DS3103_TS_CI 3 /* TS CI Mode */ |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 109 | u8 ts_mode; |
| 110 | |
| 111 | /* |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 112 | * TS clk in KHz |
| 113 | * Default: 0. |
| 114 | */ |
| 115 | u32 ts_clk; |
| 116 | |
| 117 | /* |
| 118 | * TS clk polarity. |
| 119 | * Default: 0. 1-active at falling edge; 0-active at rising edge. |
| 120 | */ |
| 121 | u8 ts_clk_pol:1; |
| 122 | |
| 123 | /* |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 124 | * spectrum inversion |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 125 | * Default: 0 |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 126 | */ |
| 127 | u8 spec_inv:1; |
| 128 | |
| 129 | /* |
| 130 | * AGC polarity |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 131 | * Default: 0 |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 132 | */ |
| 133 | u8 agc_inv:1; |
| 134 | |
| 135 | /* |
| 136 | * clock output |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 137 | * Default: M88DS3103_CLOCK_OUT_DISABLED |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 138 | */ |
| 139 | #define M88DS3103_CLOCK_OUT_DISABLED 0 |
| 140 | #define M88DS3103_CLOCK_OUT_ENABLED 1 |
| 141 | #define M88DS3103_CLOCK_OUT_ENABLED_DIV2 2 |
| 142 | u8 clock_out; |
| 143 | |
| 144 | /* |
| 145 | * DiSEqC envelope mode |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 146 | * Default: 0 |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 147 | */ |
| 148 | u8 envelope_mode:1; |
| 149 | |
Antti Palosaari | 58b7450 | 2013-12-02 13:11:21 -0300 | [diff] [blame] | 150 | /* |
| 151 | * AGC configuration |
| 152 | * Default: none, must set |
| 153 | */ |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 154 | u8 agc; |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 155 | |
| 156 | /* |
| 157 | * LNB H/V pin polarity |
| 158 | * Default: 0. |
| 159 | * 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18. |
| 160 | * 0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13. |
| 161 | */ |
| 162 | u8 lnb_hv_pol:1; |
| 163 | |
| 164 | /* |
| 165 | * LNB enable pin polarity |
| 166 | * Default: 0. |
| 167 | * 1: pin high to enable, pin low to disable. |
| 168 | * 0: pin high to disable, pin low to enable. |
| 169 | */ |
| 170 | u8 lnb_en_pol:1; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 171 | }; |
| 172 | |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 173 | #if defined(CONFIG_DVB_M88DS3103) || \ |
| 174 | (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE)) |
| 175 | extern struct dvb_frontend *m88ds3103_attach( |
| 176 | const struct m88ds3103_config *config, |
| 177 | struct i2c_adapter *i2c, |
| 178 | struct i2c_adapter **tuner_i2c); |
David Howells | 0f91c9d | 2015-05-26 12:04:00 -0300 | [diff] [blame] | 179 | extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm); |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 180 | #else |
| 181 | static inline struct dvb_frontend *m88ds3103_attach( |
| 182 | const struct m88ds3103_config *config, |
| 183 | struct i2c_adapter *i2c, |
| 184 | struct i2c_adapter **tuner_i2c) |
| 185 | { |
| 186 | pr_warn("%s: driver disabled by Kconfig\n", __func__); |
| 187 | return NULL; |
| 188 | } |
David Howells | 0f91c9d | 2015-05-26 12:04:00 -0300 | [diff] [blame] | 189 | #define m88ds3103_get_agc_pwm NULL |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 190 | #endif |
| 191 | |
| 192 | #endif |