18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Montage Technology M88DS3103/M88RS6000 demodulator driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef M88DS3103_H 98c2ecf20Sopenharmony_ci#define M88DS3103_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/dvb/frontend.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * I2C address 158c2ecf20Sopenharmony_ci * 0x68, 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/** 198c2ecf20Sopenharmony_ci * enum m88ds3103_ts_mode - TS connection mode 208c2ecf20Sopenharmony_ci * @M88DS3103_TS_SERIAL: TS output pin D0, normal 218c2ecf20Sopenharmony_ci * @M88DS3103_TS_SERIAL_D7: TS output pin D7 228c2ecf20Sopenharmony_ci * @M88DS3103_TS_PARALLEL: TS Parallel mode 238c2ecf20Sopenharmony_ci * @M88DS3103_TS_CI: TS CI Mode 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_cienum m88ds3103_ts_mode { 268c2ecf20Sopenharmony_ci M88DS3103_TS_SERIAL, 278c2ecf20Sopenharmony_ci M88DS3103_TS_SERIAL_D7, 288c2ecf20Sopenharmony_ci M88DS3103_TS_PARALLEL, 298c2ecf20Sopenharmony_ci M88DS3103_TS_CI 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/** 338c2ecf20Sopenharmony_ci * enum m88ds3103_clock_out 348c2ecf20Sopenharmony_ci * @M88DS3103_CLOCK_OUT_DISABLED: Clock output is disabled 358c2ecf20Sopenharmony_ci * @M88DS3103_CLOCK_OUT_ENABLED: Clock output is enabled with crystal 368c2ecf20Sopenharmony_ci * clock. 378c2ecf20Sopenharmony_ci * @M88DS3103_CLOCK_OUT_ENABLED_DIV2: Clock output is enabled with half 388c2ecf20Sopenharmony_ci * crystal clock. 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_cienum m88ds3103_clock_out { 418c2ecf20Sopenharmony_ci M88DS3103_CLOCK_OUT_DISABLED, 428c2ecf20Sopenharmony_ci M88DS3103_CLOCK_OUT_ENABLED, 438c2ecf20Sopenharmony_ci M88DS3103_CLOCK_OUT_ENABLED_DIV2 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/** 478c2ecf20Sopenharmony_ci * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver 488c2ecf20Sopenharmony_ci * @clk: Clock frequency. 498c2ecf20Sopenharmony_ci * @i2c_wr_max: Max bytes I2C adapter can write at once. 508c2ecf20Sopenharmony_ci * @ts_mode: TS mode. 518c2ecf20Sopenharmony_ci * @ts_clk: TS clock (KHz). 528c2ecf20Sopenharmony_ci * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising 538c2ecf20Sopenharmony_ci * edge. 548c2ecf20Sopenharmony_ci * @spec_inv: Input spectrum inversion. 558c2ecf20Sopenharmony_ci * @agc: AGC configuration. 568c2ecf20Sopenharmony_ci * @agc_inv: AGC polarity. 578c2ecf20Sopenharmony_ci * @clk_out: Clock output. 588c2ecf20Sopenharmony_ci * @envelope_mode: DiSEqC envelope mode. 598c2ecf20Sopenharmony_ci * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to 608c2ecf20Sopenharmony_ci * set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18. 618c2ecf20Sopenharmony_ci * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to 628c2ecf20Sopenharmony_ci * enable. 1: pin high to enable, pin low to disable. 638c2ecf20Sopenharmony_ci * @get_dvb_frontend: Get DVB frontend. 648c2ecf20Sopenharmony_ci * @get_i2c_adapter: Get I2C adapter. 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_cistruct m88ds3103_platform_data { 678c2ecf20Sopenharmony_ci u32 clk; 688c2ecf20Sopenharmony_ci u16 i2c_wr_max; 698c2ecf20Sopenharmony_ci enum m88ds3103_ts_mode ts_mode; 708c2ecf20Sopenharmony_ci u32 ts_clk; 718c2ecf20Sopenharmony_ci enum m88ds3103_clock_out clk_out; 728c2ecf20Sopenharmony_ci u8 ts_clk_pol:1; 738c2ecf20Sopenharmony_ci u8 spec_inv:1; 748c2ecf20Sopenharmony_ci u8 agc; 758c2ecf20Sopenharmony_ci u8 agc_inv:1; 768c2ecf20Sopenharmony_ci u8 envelope_mode:1; 778c2ecf20Sopenharmony_ci u8 lnb_hv_pol:1; 788c2ecf20Sopenharmony_ci u8 lnb_en_pol:1; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 818c2ecf20Sopenharmony_ci struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* private: For legacy media attach wrapper. Do not set value. */ 848c2ecf20Sopenharmony_ci u8 attach_in_use:1; 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/** 888c2ecf20Sopenharmony_ci * struct m88ds3103_config - m88ds3102 configuration 898c2ecf20Sopenharmony_ci * 908c2ecf20Sopenharmony_ci * @i2c_addr: I2C address. Default: none, must set. Example: 0x68, ... 918c2ecf20Sopenharmony_ci * @clock: Device's clock. Default: none, must set. Example: 27000000 928c2ecf20Sopenharmony_ci * @i2c_wr_max: Max bytes I2C provider is asked to write at once. 938c2ecf20Sopenharmony_ci * Default: none, must set. Example: 33, 65, ... 948c2ecf20Sopenharmony_ci * @ts_mode: TS output mode, as defined by &enum m88ds3103_ts_mode. 958c2ecf20Sopenharmony_ci * Default: M88DS3103_TS_SERIAL. 968c2ecf20Sopenharmony_ci * @ts_clk: TS clk in KHz. Default: 0. 978c2ecf20Sopenharmony_ci * @ts_clk_pol: TS clk polarity.Default: 0. 988c2ecf20Sopenharmony_ci * 1-active at falling edge; 0-active at rising edge. 998c2ecf20Sopenharmony_ci * @spec_inv: Spectrum inversion. Default: 0. 1008c2ecf20Sopenharmony_ci * @agc_inv: AGC polarity. Default: 0. 1018c2ecf20Sopenharmony_ci * @clock_out: Clock output, as defined by &enum m88ds3103_clock_out. 1028c2ecf20Sopenharmony_ci * Default: M88DS3103_CLOCK_OUT_DISABLED. 1038c2ecf20Sopenharmony_ci * @envelope_mode: DiSEqC envelope mode. Default: 0. 1048c2ecf20Sopenharmony_ci * @agc: AGC configuration. Default: none, must set. 1058c2ecf20Sopenharmony_ci * @lnb_hv_pol: LNB H/V pin polarity. Default: 0. Values: 1068c2ecf20Sopenharmony_ci * 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18; 1078c2ecf20Sopenharmony_ci * 0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13. 1088c2ecf20Sopenharmony_ci * @lnb_en_pol: LNB enable pin polarity. Default: 0. Values: 1098c2ecf20Sopenharmony_ci * 1: pin high to enable, pin low to disable; 1108c2ecf20Sopenharmony_ci * 0: pin high to disable, pin low to enable. 1118c2ecf20Sopenharmony_ci */ 1128c2ecf20Sopenharmony_cistruct m88ds3103_config { 1138c2ecf20Sopenharmony_ci u8 i2c_addr; 1148c2ecf20Sopenharmony_ci u32 clock; 1158c2ecf20Sopenharmony_ci u16 i2c_wr_max; 1168c2ecf20Sopenharmony_ci u8 ts_mode; 1178c2ecf20Sopenharmony_ci u32 ts_clk; 1188c2ecf20Sopenharmony_ci u8 ts_clk_pol:1; 1198c2ecf20Sopenharmony_ci u8 spec_inv:1; 1208c2ecf20Sopenharmony_ci u8 agc_inv:1; 1218c2ecf20Sopenharmony_ci u8 clock_out; 1228c2ecf20Sopenharmony_ci u8 envelope_mode:1; 1238c2ecf20Sopenharmony_ci u8 agc; 1248c2ecf20Sopenharmony_ci u8 lnb_hv_pol:1; 1258c2ecf20Sopenharmony_ci u8 lnb_en_pol:1; 1268c2ecf20Sopenharmony_ci}; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#if defined(CONFIG_DVB_M88DS3103) || \ 1298c2ecf20Sopenharmony_ci (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE)) 1308c2ecf20Sopenharmony_ci/** 1318c2ecf20Sopenharmony_ci * Attach a m88ds3103 demod 1328c2ecf20Sopenharmony_ci * 1338c2ecf20Sopenharmony_ci * @config: pointer to &struct m88ds3103_config with demod configuration. 1348c2ecf20Sopenharmony_ci * @i2c: i2c adapter to use. 1358c2ecf20Sopenharmony_ci * @tuner_i2c: on success, returns the I2C adapter associated with 1368c2ecf20Sopenharmony_ci * m88ds3103 tuner. 1378c2ecf20Sopenharmony_ci * 1388c2ecf20Sopenharmony_ci * return: FE pointer on success, NULL on failure. 1398c2ecf20Sopenharmony_ci * Note: Do not add new m88ds3103_attach() users! Use I2C bindings instead. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ciextern struct dvb_frontend *m88ds3103_attach( 1428c2ecf20Sopenharmony_ci const struct m88ds3103_config *config, 1438c2ecf20Sopenharmony_ci struct i2c_adapter *i2c, 1448c2ecf20Sopenharmony_ci struct i2c_adapter **tuner_i2c); 1458c2ecf20Sopenharmony_ciextern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm); 1468c2ecf20Sopenharmony_ci#else 1478c2ecf20Sopenharmony_cistatic inline struct dvb_frontend *m88ds3103_attach( 1488c2ecf20Sopenharmony_ci const struct m88ds3103_config *config, 1498c2ecf20Sopenharmony_ci struct i2c_adapter *i2c, 1508c2ecf20Sopenharmony_ci struct i2c_adapter **tuner_i2c) 1518c2ecf20Sopenharmony_ci{ 1528c2ecf20Sopenharmony_ci pr_warn("%s: driver disabled by Kconfig\n", __func__); 1538c2ecf20Sopenharmony_ci return NULL; 1548c2ecf20Sopenharmony_ci} 1558c2ecf20Sopenharmony_ci#define m88ds3103_get_agc_pwm NULL 1568c2ecf20Sopenharmony_ci#endif 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci#endif 159