blob: e32b68c0df701c29cfdd5dca6a5a543537cc8de9 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Antti Palosaari395d00d2013-02-25 08:39:16 -03002/*
Antti Palosaari7978b8a2015-04-16 21:36:00 -03003 * Montage Technology M88DS3103/M88RS6000 demodulator driver
Antti Palosaari395d00d2013-02-25 08:39:16 -03004 *
5 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
Antti Palosaari395d00d2013-02-25 08:39:16 -03006 */
7
8#ifndef M88DS3103_H
9#define M88DS3103_H
10
11#include <linux/dvb/frontend.h>
12
Antti Palosaarif01919e82015-04-16 20:04:55 -030013/*
14 * I2C address
15 * 0x68,
16 */
17
18/**
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -050019 * 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 */
25enum 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 */
40enum m88ds3103_clock_out {
41 M88DS3103_CLOCK_OUT_DISABLED,
42 M88DS3103_CLOCK_OUT_ENABLED,
43 M88DS3103_CLOCK_OUT_ENABLED_DIV2
44};
45
46/**
Antti Palosaarif01919e82015-04-16 20:04:55 -030047 * 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 Palosaarif01919e82015-04-16 20:04:55 -030066struct m88ds3103_platform_data {
67 u32 clk;
68 u16 i2c_wr_max;
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -050069 enum m88ds3103_ts_mode ts_mode;
Antti Palosaarif01919e82015-04-16 20:04:55 -030070 u32 ts_clk;
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -050071 enum m88ds3103_clock_out clk_out;
Antti Palosaarif01919e82015-04-16 20:04:55 -030072 u8 ts_clk_pol:1;
73 u8 spec_inv:1;
74 u8 agc;
75 u8 agc_inv:1;
Antti Palosaarif01919e82015-04-16 20:04:55 -030076 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 Chehabbe9b53c2017-11-29 14:02:22 -050087/**
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 Palosaarif01919e82015-04-16 20:04:55 -0300111 */
Antti Palosaari395d00d2013-02-25 08:39:16 -0300112struct m88ds3103_config {
Antti Palosaari395d00d2013-02-25 08:39:16 -0300113 u8 i2c_addr;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300114 u32 clock;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300115 u16 i2c_wr_max;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300116 u8 ts_mode;
nibble.max79d09332014-08-11 01:22:45 -0300117 u32 ts_clk;
nibble.max79d09332014-08-11 01:22:45 -0300118 u8 ts_clk_pol:1;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300119 u8 spec_inv:1;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300120 u8 agc_inv:1;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300121 u8 clock_out;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300122 u8 envelope_mode:1;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300123 u8 agc;
nibble.max79d09332014-08-11 01:22:45 -0300124 u8 lnb_hv_pol:1;
nibble.max79d09332014-08-11 01:22:45 -0300125 u8 lnb_en_pol:1;
Antti Palosaari395d00d2013-02-25 08:39:16 -0300126};
127
Antti Palosaari395d00d2013-02-25 08:39:16 -0300128#if defined(CONFIG_DVB_M88DS3103) || \
129 (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE))
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -0500130/**
Mauro Carvalho Chehabb0649452020-10-23 16:08:10 +0200131 * m88ds3103_attach - Attach a m88ds3103 demod
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -0500132 *
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 Palosaari395d00d2013-02-25 08:39:16 -0300141extern struct dvb_frontend *m88ds3103_attach(
142 const struct m88ds3103_config *config,
143 struct i2c_adapter *i2c,
144 struct i2c_adapter **tuner_i2c);
David Howells0f91c9d2015-05-26 12:04:00 -0300145extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm);
Antti Palosaari395d00d2013-02-25 08:39:16 -0300146#else
147static 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 Howells0f91c9d2015-05-26 12:04:00 -0300155#define m88ds3103_get_agc_pwm NULL
Antti Palosaari395d00d2013-02-25 08:39:16 -0300156#endif
157
158#endif