Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 2 | /* |
Antti Palosaari | 7978b8a | 2015-04-16 21:36:00 -0300 | [diff] [blame] | 3 | * Montage Technology M88DS3103/M88RS6000 demodulator driver |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef M88DS3103_H |
| 9 | #define M88DS3103_H |
| 10 | |
| 11 | #include <linux/dvb/frontend.h> |
| 12 | |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 13 | /* |
| 14 | * I2C address |
| 15 | * 0x68, |
| 16 | */ |
| 17 | |
| 18 | /** |
Mauro Carvalho Chehab | be9b53c | 2017-11-29 14:02:22 -0500 | [diff] [blame] | 19 | * enum m88ds3103_ts_mode - TS connection mode |
| 20 | * @M88DS3103_TS_SERIAL: TS output pin D0, normal |
| 21 | * @M88DS3103_TS_SERIAL_D7: TS output pin D7 |
| 22 | * @M88DS3103_TS_PARALLEL: TS Parallel mode |
| 23 | * @M88DS3103_TS_CI: TS CI Mode |
| 24 | */ |
| 25 | enum m88ds3103_ts_mode { |
| 26 | M88DS3103_TS_SERIAL, |
| 27 | M88DS3103_TS_SERIAL_D7, |
| 28 | M88DS3103_TS_PARALLEL, |
| 29 | M88DS3103_TS_CI |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * enum m88ds3103_clock_out |
| 34 | * @M88DS3103_CLOCK_OUT_DISABLED: Clock output is disabled |
| 35 | * @M88DS3103_CLOCK_OUT_ENABLED: Clock output is enabled with crystal |
| 36 | * clock. |
| 37 | * @M88DS3103_CLOCK_OUT_ENABLED_DIV2: Clock output is enabled with half |
| 38 | * crystal clock. |
| 39 | */ |
| 40 | enum m88ds3103_clock_out { |
| 41 | M88DS3103_CLOCK_OUT_DISABLED, |
| 42 | M88DS3103_CLOCK_OUT_ENABLED, |
| 43 | M88DS3103_CLOCK_OUT_ENABLED_DIV2 |
| 44 | }; |
| 45 | |
| 46 | /** |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 47 | * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver |
| 48 | * @clk: Clock frequency. |
| 49 | * @i2c_wr_max: Max bytes I2C adapter can write at once. |
| 50 | * @ts_mode: TS mode. |
| 51 | * @ts_clk: TS clock (KHz). |
| 52 | * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising |
| 53 | * edge. |
| 54 | * @spec_inv: Input spectrum inversion. |
| 55 | * @agc: AGC configuration. |
| 56 | * @agc_inv: AGC polarity. |
| 57 | * @clk_out: Clock output. |
| 58 | * @envelope_mode: DiSEqC envelope mode. |
| 59 | * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to |
| 60 | * set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18. |
| 61 | * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to |
| 62 | * enable. 1: pin high to enable, pin low to disable. |
| 63 | * @get_dvb_frontend: Get DVB frontend. |
| 64 | * @get_i2c_adapter: Get I2C adapter. |
| 65 | */ |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 66 | struct m88ds3103_platform_data { |
| 67 | u32 clk; |
| 68 | u16 i2c_wr_max; |
Mauro Carvalho Chehab | be9b53c | 2017-11-29 14:02:22 -0500 | [diff] [blame] | 69 | enum m88ds3103_ts_mode ts_mode; |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 70 | u32 ts_clk; |
Mauro Carvalho Chehab | be9b53c | 2017-11-29 14:02:22 -0500 | [diff] [blame] | 71 | enum m88ds3103_clock_out clk_out; |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 72 | u8 ts_clk_pol:1; |
| 73 | u8 spec_inv:1; |
| 74 | u8 agc; |
| 75 | u8 agc_inv:1; |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 76 | u8 envelope_mode:1; |
| 77 | u8 lnb_hv_pol:1; |
| 78 | u8 lnb_en_pol:1; |
| 79 | |
| 80 | struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); |
| 81 | struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); |
| 82 | |
| 83 | /* private: For legacy media attach wrapper. Do not set value. */ |
| 84 | u8 attach_in_use:1; |
| 85 | }; |
| 86 | |
Mauro Carvalho Chehab | be9b53c | 2017-11-29 14:02:22 -0500 | [diff] [blame] | 87 | /** |
| 88 | * struct m88ds3103_config - m88ds3102 configuration |
| 89 | * |
| 90 | * @i2c_addr: I2C address. Default: none, must set. Example: 0x68, ... |
| 91 | * @clock: Device's clock. Default: none, must set. Example: 27000000 |
| 92 | * @i2c_wr_max: Max bytes I2C provider is asked to write at once. |
| 93 | * Default: none, must set. Example: 33, 65, ... |
| 94 | * @ts_mode: TS output mode, as defined by &enum m88ds3103_ts_mode. |
| 95 | * Default: M88DS3103_TS_SERIAL. |
| 96 | * @ts_clk: TS clk in KHz. Default: 0. |
| 97 | * @ts_clk_pol: TS clk polarity.Default: 0. |
| 98 | * 1-active at falling edge; 0-active at rising edge. |
| 99 | * @spec_inv: Spectrum inversion. Default: 0. |
| 100 | * @agc_inv: AGC polarity. Default: 0. |
| 101 | * @clock_out: Clock output, as defined by &enum m88ds3103_clock_out. |
| 102 | * Default: M88DS3103_CLOCK_OUT_DISABLED. |
| 103 | * @envelope_mode: DiSEqC envelope mode. Default: 0. |
| 104 | * @agc: AGC configuration. Default: none, must set. |
| 105 | * @lnb_hv_pol: LNB H/V pin polarity. Default: 0. Values: |
| 106 | * 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18; |
| 107 | * 0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13. |
| 108 | * @lnb_en_pol: LNB enable pin polarity. Default: 0. Values: |
| 109 | * 1: pin high to enable, pin low to disable; |
| 110 | * 0: pin high to disable, pin low to enable. |
Antti Palosaari | f01919e8 | 2015-04-16 20:04:55 -0300 | [diff] [blame] | 111 | */ |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 112 | struct m88ds3103_config { |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 113 | u8 i2c_addr; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 114 | u32 clock; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 115 | u16 i2c_wr_max; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 116 | u8 ts_mode; |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 117 | u32 ts_clk; |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 118 | u8 ts_clk_pol:1; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 119 | u8 spec_inv:1; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 120 | u8 agc_inv:1; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 121 | u8 clock_out; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 122 | u8 envelope_mode:1; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 123 | u8 agc; |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 124 | u8 lnb_hv_pol:1; |
nibble.max | 79d0933 | 2014-08-11 01:22:45 -0300 | [diff] [blame] | 125 | u8 lnb_en_pol:1; |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 126 | }; |
| 127 | |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 128 | #if defined(CONFIG_DVB_M88DS3103) || \ |
| 129 | (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE)) |
Mauro Carvalho Chehab | be9b53c | 2017-11-29 14:02:22 -0500 | [diff] [blame] | 130 | /** |
Mauro Carvalho Chehab | b064945 | 2020-10-23 16:08:10 +0200 | [diff] [blame] | 131 | * m88ds3103_attach - Attach a m88ds3103 demod |
Mauro Carvalho Chehab | be9b53c | 2017-11-29 14:02:22 -0500 | [diff] [blame] | 132 | * |
| 133 | * @config: pointer to &struct m88ds3103_config with demod configuration. |
| 134 | * @i2c: i2c adapter to use. |
| 135 | * @tuner_i2c: on success, returns the I2C adapter associated with |
| 136 | * m88ds3103 tuner. |
| 137 | * |
| 138 | * return: FE pointer on success, NULL on failure. |
| 139 | * Note: Do not add new m88ds3103_attach() users! Use I2C bindings instead. |
| 140 | */ |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 141 | extern struct dvb_frontend *m88ds3103_attach( |
| 142 | const struct m88ds3103_config *config, |
| 143 | struct i2c_adapter *i2c, |
| 144 | struct i2c_adapter **tuner_i2c); |
David Howells | 0f91c9d | 2015-05-26 12:04:00 -0300 | [diff] [blame] | 145 | 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] | 146 | #else |
| 147 | static inline struct dvb_frontend *m88ds3103_attach( |
| 148 | const struct m88ds3103_config *config, |
| 149 | struct i2c_adapter *i2c, |
| 150 | struct i2c_adapter **tuner_i2c) |
| 151 | { |
| 152 | pr_warn("%s: driver disabled by Kconfig\n", __func__); |
| 153 | return NULL; |
| 154 | } |
David Howells | 0f91c9d | 2015-05-26 12:04:00 -0300 | [diff] [blame] | 155 | #define m88ds3103_get_agc_pwm NULL |
Antti Palosaari | 395d00d | 2013-02-25 08:39:16 -0300 | [diff] [blame] | 156 | #endif |
| 157 | |
| 158 | #endif |