Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Montage Technology M88DS3103/M88RS6000 demodulator driver
0004  *
0005  * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
0006  */
0007 
0008 #ifndef M88DS3103_H
0009 #define M88DS3103_H
0010 
0011 #include <linux/dvb/frontend.h>
0012 
0013 /*
0014  * I2C address
0015  * 0x68,
0016  */
0017 
0018 /**
0019  * enum m88ds3103_ts_mode - TS connection mode
0020  * @M88DS3103_TS_SERIAL:    TS output pin D0, normal
0021  * @M88DS3103_TS_SERIAL_D7: TS output pin D7
0022  * @M88DS3103_TS_PARALLEL:  TS Parallel mode
0023  * @M88DS3103_TS_CI:        TS CI Mode
0024  */
0025 enum m88ds3103_ts_mode {
0026     M88DS3103_TS_SERIAL,
0027     M88DS3103_TS_SERIAL_D7,
0028     M88DS3103_TS_PARALLEL,
0029     M88DS3103_TS_CI
0030 };
0031 
0032 /**
0033  * enum m88ds3103_clock_out
0034  * @M88DS3103_CLOCK_OUT_DISABLED:   Clock output is disabled
0035  * @M88DS3103_CLOCK_OUT_ENABLED:    Clock output is enabled with crystal
0036  *                  clock.
0037  * @M88DS3103_CLOCK_OUT_ENABLED_DIV2:   Clock output is enabled with half
0038  *                  crystal clock.
0039  */
0040 enum m88ds3103_clock_out {
0041     M88DS3103_CLOCK_OUT_DISABLED,
0042     M88DS3103_CLOCK_OUT_ENABLED,
0043     M88DS3103_CLOCK_OUT_ENABLED_DIV2
0044 };
0045 
0046 /**
0047  * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver
0048  * @clk: Clock frequency.
0049  * @i2c_wr_max: Max bytes I2C adapter can write at once.
0050  * @ts_mode: TS mode.
0051  * @ts_clk: TS clock (KHz).
0052  * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising
0053  *  edge.
0054  * @spec_inv: Input spectrum inversion.
0055  * @agc: AGC configuration.
0056  * @agc_inv: AGC polarity.
0057  * @clk_out: Clock output.
0058  * @envelope_mode: DiSEqC envelope mode.
0059  * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to
0060  *  set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18.
0061  * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to
0062  *  enable. 1: pin high to enable, pin low to disable.
0063  * @get_dvb_frontend: Get DVB frontend.
0064  * @get_i2c_adapter: Get I2C adapter.
0065  */
0066 struct m88ds3103_platform_data {
0067     u32 clk;
0068     u16 i2c_wr_max;
0069     enum m88ds3103_ts_mode ts_mode;
0070     u32 ts_clk;
0071     enum m88ds3103_clock_out clk_out;
0072     u8 ts_clk_pol:1;
0073     u8 spec_inv:1;
0074     u8 agc;
0075     u8 agc_inv:1;
0076     u8 envelope_mode:1;
0077     u8 lnb_hv_pol:1;
0078     u8 lnb_en_pol:1;
0079 
0080     struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
0081     struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
0082 
0083 /* private: For legacy media attach wrapper. Do not set value. */
0084     u8 attach_in_use:1;
0085 };
0086 
0087 /**
0088  * struct m88ds3103_config - m88ds3102 configuration
0089  *
0090  * @i2c_addr:   I2C address. Default: none, must set. Example: 0x68, ...
0091  * @clock:  Device's clock. Default: none, must set. Example: 27000000
0092  * @i2c_wr_max: Max bytes I2C provider is asked to write at once.
0093  *      Default: none, must set. Example: 33, 65, ...
0094  * @ts_mode:    TS output mode, as defined by &enum m88ds3103_ts_mode.
0095  *      Default: M88DS3103_TS_SERIAL.
0096  * @ts_clk: TS clk in KHz. Default: 0.
0097  * @ts_clk_pol: TS clk polarity.Default: 0.
0098  *      1-active at falling edge; 0-active at rising edge.
0099  * @spec_inv:   Spectrum inversion. Default: 0.
0100  * @agc_inv:    AGC polarity. Default: 0.
0101  * @clock_out:  Clock output, as defined by &enum m88ds3103_clock_out.
0102  *      Default: M88DS3103_CLOCK_OUT_DISABLED.
0103  * @envelope_mode: DiSEqC envelope mode. Default: 0.
0104  * @agc:    AGC configuration. Default: none, must set.
0105  * @lnb_hv_pol: LNB H/V pin polarity. Default: 0. Values:
0106  *      1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18;
0107  *      0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13.
0108  * @lnb_en_pol: LNB enable pin polarity. Default: 0. Values:
0109  *      1: pin high to enable, pin low to disable;
0110  *      0: pin high to disable, pin low to enable.
0111  */
0112 struct m88ds3103_config {
0113     u8 i2c_addr;
0114     u32 clock;
0115     u16 i2c_wr_max;
0116     u8 ts_mode;
0117     u32 ts_clk;
0118     u8 ts_clk_pol:1;
0119     u8 spec_inv:1;
0120     u8 agc_inv:1;
0121     u8 clock_out;
0122     u8 envelope_mode:1;
0123     u8 agc;
0124     u8 lnb_hv_pol:1;
0125     u8 lnb_en_pol:1;
0126 };
0127 
0128 #if defined(CONFIG_DVB_M88DS3103) || \
0129         (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE))
0130 /**
0131  * m88ds3103_attach - Attach a m88ds3103 demod
0132  *
0133  * @config: pointer to &struct m88ds3103_config with demod configuration.
0134  * @i2c: i2c adapter to use.
0135  * @tuner_i2c: on success, returns the I2C adapter associated with
0136  *      m88ds3103 tuner.
0137  *
0138  * return: FE pointer on success, NULL on failure.
0139  * Note: Do not add new m88ds3103_attach() users! Use I2C bindings instead.
0140  */
0141 extern struct dvb_frontend *m88ds3103_attach(
0142         const struct m88ds3103_config *config,
0143         struct i2c_adapter *i2c,
0144         struct i2c_adapter **tuner_i2c);
0145 extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm);
0146 #else
0147 static inline struct dvb_frontend *m88ds3103_attach(
0148         const struct m88ds3103_config *config,
0149         struct i2c_adapter *i2c,
0150         struct i2c_adapter **tuner_i2c)
0151 {
0152     pr_warn("%s: driver disabled by Kconfig\n", __func__);
0153     return NULL;
0154 }
0155 #define m88ds3103_get_agc_pwm NULL
0156 #endif
0157 
0158 #endif