18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci STB0899 Multistandard Frontend driver 48c2ecf20Sopenharmony_ci Copyright (C) Manu Abraham (abraham.manu@gmail.com) 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci Copyright (C) ST Microelectronics 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci*/ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __STB0899_DRV_H 118c2ecf20Sopenharmony_ci#define __STB0899_DRV_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/kernel.h> 148c2ecf20Sopenharmony_ci#include <linux/module.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <media/dvb_frontend.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define STB0899_TSMODE_SERIAL 1 198c2ecf20Sopenharmony_ci#define STB0899_CLKPOL_FALLING 2 208c2ecf20Sopenharmony_ci#define STB0899_CLKNULL_PARITY 3 218c2ecf20Sopenharmony_ci#define STB0899_SYNC_FORCED 4 228c2ecf20Sopenharmony_ci#define STB0899_FECMODE_DSS 5 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct stb0899_s1_reg { 258c2ecf20Sopenharmony_ci u16 address; 268c2ecf20Sopenharmony_ci u8 data; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct stb0899_s2_reg { 308c2ecf20Sopenharmony_ci u16 offset; 318c2ecf20Sopenharmony_ci u32 base_address; 328c2ecf20Sopenharmony_ci u32 data; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cienum stb0899_inversion { 368c2ecf20Sopenharmony_ci IQ_SWAP_OFF = +1, /* inversion affects the sign of e. g. */ 378c2ecf20Sopenharmony_ci IQ_SWAP_ON = -1, /* the derotator frequency register */ 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define STB0899_GPIO00 0xf140 418c2ecf20Sopenharmony_ci#define STB0899_GPIO01 0xf141 428c2ecf20Sopenharmony_ci#define STB0899_GPIO02 0xf142 438c2ecf20Sopenharmony_ci#define STB0899_GPIO03 0xf143 448c2ecf20Sopenharmony_ci#define STB0899_GPIO04 0xf144 458c2ecf20Sopenharmony_ci#define STB0899_GPIO05 0xf145 468c2ecf20Sopenharmony_ci#define STB0899_GPIO06 0xf146 478c2ecf20Sopenharmony_ci#define STB0899_GPIO07 0xf147 488c2ecf20Sopenharmony_ci#define STB0899_GPIO08 0xf148 498c2ecf20Sopenharmony_ci#define STB0899_GPIO09 0xf149 508c2ecf20Sopenharmony_ci#define STB0899_GPIO10 0xf14a 518c2ecf20Sopenharmony_ci#define STB0899_GPIO11 0xf14b 528c2ecf20Sopenharmony_ci#define STB0899_GPIO12 0xf14c 538c2ecf20Sopenharmony_ci#define STB0899_GPIO13 0xf14d 548c2ecf20Sopenharmony_ci#define STB0899_GPIO14 0xf14e 558c2ecf20Sopenharmony_ci#define STB0899_GPIO15 0xf14f 568c2ecf20Sopenharmony_ci#define STB0899_GPIO16 0xf150 578c2ecf20Sopenharmony_ci#define STB0899_GPIO17 0xf151 588c2ecf20Sopenharmony_ci#define STB0899_GPIO18 0xf152 598c2ecf20Sopenharmony_ci#define STB0899_GPIO19 0xf153 608c2ecf20Sopenharmony_ci#define STB0899_GPIO20 0xf154 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define STB0899_GPIOPULLUP 0x01 /* Output device is connected to Vdd */ 638c2ecf20Sopenharmony_ci#define STB0899_GPIOPULLDN 0x00 /* Output device is connected to Vss */ 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define STB0899_POSTPROC_GPIO_POWER 0x00 668c2ecf20Sopenharmony_ci#define STB0899_POSTPROC_GPIO_LOCK 0x01 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* 698c2ecf20Sopenharmony_ci * Post process output configuration control 708c2ecf20Sopenharmony_ci * 1. POWER ON/OFF (index 0) 718c2ecf20Sopenharmony_ci * 2. FE_HAS_LOCK/LOCK_LOSS (index 1) 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * @gpio = one of the above listed GPIO's 748c2ecf20Sopenharmony_ci * @level = output state: pulled up or low 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistruct stb0899_postproc { 778c2ecf20Sopenharmony_ci u16 gpio; 788c2ecf20Sopenharmony_ci u8 level; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct stb0899_config { 828c2ecf20Sopenharmony_ci const struct stb0899_s1_reg *init_dev; 838c2ecf20Sopenharmony_ci const struct stb0899_s2_reg *init_s2_demod; 848c2ecf20Sopenharmony_ci const struct stb0899_s1_reg *init_s1_demod; 858c2ecf20Sopenharmony_ci const struct stb0899_s2_reg *init_s2_fec; 868c2ecf20Sopenharmony_ci const struct stb0899_s1_reg *init_tst; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci const struct stb0899_postproc *postproc; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci enum stb0899_inversion inversion; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci u32 xtal_freq; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci u8 demod_address; 958c2ecf20Sopenharmony_ci u8 ts_output_mode; 968c2ecf20Sopenharmony_ci u8 block_sync_mode; 978c2ecf20Sopenharmony_ci u8 ts_pfbit_toggle; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci u8 clock_polarity; 1008c2ecf20Sopenharmony_ci u8 data_clk_parity; 1018c2ecf20Sopenharmony_ci u8 fec_mode; 1028c2ecf20Sopenharmony_ci u8 data_output_ctl; 1038c2ecf20Sopenharmony_ci u8 data_fifo_mode; 1048c2ecf20Sopenharmony_ci u8 out_rate_comp; 1058c2ecf20Sopenharmony_ci u8 i2c_repeater; 1068c2ecf20Sopenharmony_ci// int inversion; 1078c2ecf20Sopenharmony_ci int lo_clk; 1088c2ecf20Sopenharmony_ci int hi_clk; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci u32 esno_ave; 1118c2ecf20Sopenharmony_ci u32 esno_quant; 1128c2ecf20Sopenharmony_ci u32 avframes_coarse; 1138c2ecf20Sopenharmony_ci u32 avframes_fine; 1148c2ecf20Sopenharmony_ci u32 miss_threshold; 1158c2ecf20Sopenharmony_ci u32 uwp_threshold_acq; 1168c2ecf20Sopenharmony_ci u32 uwp_threshold_track; 1178c2ecf20Sopenharmony_ci u32 uwp_threshold_sof; 1188c2ecf20Sopenharmony_ci u32 sof_search_timeout; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci u32 btr_nco_bits; 1218c2ecf20Sopenharmony_ci u32 btr_gain_shift_offset; 1228c2ecf20Sopenharmony_ci u32 crl_nco_bits; 1238c2ecf20Sopenharmony_ci u32 ldpc_max_iter; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency); 1268c2ecf20Sopenharmony_ci int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency); 1278c2ecf20Sopenharmony_ci int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth); 1288c2ecf20Sopenharmony_ci int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); 1298c2ecf20Sopenharmony_ci int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain); 1308c2ecf20Sopenharmony_ci}; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_DVB_STB0899) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ciextern struct dvb_frontend *stb0899_attach(struct stb0899_config *config, 1358c2ecf20Sopenharmony_ci struct i2c_adapter *i2c); 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#else 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistatic inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config, 1408c2ecf20Sopenharmony_ci struct i2c_adapter *i2c) 1418c2ecf20Sopenharmony_ci{ 1428c2ecf20Sopenharmony_ci printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__); 1438c2ecf20Sopenharmony_ci return NULL; 1448c2ecf20Sopenharmony_ci} 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#endif //CONFIG_DVB_STB0899 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#endif 150