18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *    Support for Legend Silicon GB20600 (a.k.a DMB-TH) demodulator
48c2ecf20Sopenharmony_ci *    LGS8913, LGS8GL5, LGS8G75
58c2ecf20Sopenharmony_ci *    experimental support LGS8G42, LGS8G52
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *    Copyright (C) 2007-2009 David T.L. Wong <davidtlwong@gmail.com>
88c2ecf20Sopenharmony_ci *    Copyright (C) 2008 Sirius International (Hong Kong) Limited
98c2ecf20Sopenharmony_ci *    Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5)
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __LGS8GXX_H__
138c2ecf20Sopenharmony_ci#define __LGS8GXX_H__
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/dvb/frontend.h>
168c2ecf20Sopenharmony_ci#include <linux/i2c.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define LGS8GXX_PROD_LGS8913 0
198c2ecf20Sopenharmony_ci#define LGS8GXX_PROD_LGS8GL5 1
208c2ecf20Sopenharmony_ci#define LGS8GXX_PROD_LGS8G42 3
218c2ecf20Sopenharmony_ci#define LGS8GXX_PROD_LGS8G52 4
228c2ecf20Sopenharmony_ci#define LGS8GXX_PROD_LGS8G54 5
238c2ecf20Sopenharmony_ci#define LGS8GXX_PROD_LGS8G75 6
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistruct lgs8gxx_config {
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	/* product type */
288c2ecf20Sopenharmony_ci	u8 prod;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	/* the demodulator's i2c address */
318c2ecf20Sopenharmony_ci	u8 demod_address;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	/* parallel or serial transport stream */
348c2ecf20Sopenharmony_ci	u8 serial_ts;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	/* transport stream polarity*/
378c2ecf20Sopenharmony_ci	u8 ts_clk_pol;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	/* transport stream clock gated by ts_valid */
408c2ecf20Sopenharmony_ci	u8 ts_clk_gated;
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	/* A/D Clock frequency */
438c2ecf20Sopenharmony_ci	u32 if_clk_freq; /* in kHz */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	/* IF frequency */
468c2ecf20Sopenharmony_ci	u32 if_freq; /* in kHz */
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	/*Use External ADC*/
498c2ecf20Sopenharmony_ci	u8 ext_adc;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	/*External ADC output two's complement*/
528c2ecf20Sopenharmony_ci	u8 adc_signed;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	/*Sample IF data at falling edge of IF_CLK*/
558c2ecf20Sopenharmony_ci	u8 if_neg_edge;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/*IF use Negative center frequency*/
588c2ecf20Sopenharmony_ci	u8 if_neg_center;
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	/*8G75 internal ADC input range selection*/
618c2ecf20Sopenharmony_ci	/*0: 0.8Vpp, 1: 1.0Vpp, 2: 1.6Vpp, 3: 2.0Vpp*/
628c2ecf20Sopenharmony_ci	u8 adc_vpp;
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci	/* slave address and configuration of the tuner */
658c2ecf20Sopenharmony_ci	u8 tuner_address;
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_DVB_LGS8GXX)
698c2ecf20Sopenharmony_ciextern struct dvb_frontend *lgs8gxx_attach(const struct lgs8gxx_config *config,
708c2ecf20Sopenharmony_ci					   struct i2c_adapter *i2c);
718c2ecf20Sopenharmony_ci#else
728c2ecf20Sopenharmony_cistatic inline
738c2ecf20Sopenharmony_cistruct dvb_frontend *lgs8gxx_attach(const struct lgs8gxx_config *config,
748c2ecf20Sopenharmony_ci				    struct i2c_adapter *i2c) {
758c2ecf20Sopenharmony_ci	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
768c2ecf20Sopenharmony_ci	return NULL;
778c2ecf20Sopenharmony_ci}
788c2ecf20Sopenharmony_ci#endif /* CONFIG_DVB_LGS8GXX */
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#endif /* __LGS8GXX_H__ */
81