1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 STB0899 Multistandard Frontend driver
4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
6 Copyright (C) ST Microelectronics
10 #ifndef __STB0899_DRV_H
11 #define __STB0899_DRV_H
13 #include <linux/kernel.h>
14 #include <linux/module.h>
16 #include <media/dvb_frontend.h>
18 #define STB0899_TSMODE_SERIAL 1
19 #define STB0899_CLKPOL_FALLING 2
20 #define STB0899_CLKNULL_PARITY 3
21 #define STB0899_SYNC_FORCED 4
22 #define STB0899_FECMODE_DSS 5
24 struct stb0899_s1_reg {
29 struct stb0899_s2_reg {
35 enum stb0899_inversion {
36 IQ_SWAP_OFF = +1, /* inversion affects the sign of e. g. */
37 IQ_SWAP_ON = -1, /* the derotator frequency register */
40 #define STB0899_GPIO00 0xf140
41 #define STB0899_GPIO01 0xf141
42 #define STB0899_GPIO02 0xf142
43 #define STB0899_GPIO03 0xf143
44 #define STB0899_GPIO04 0xf144
45 #define STB0899_GPIO05 0xf145
46 #define STB0899_GPIO06 0xf146
47 #define STB0899_GPIO07 0xf147
48 #define STB0899_GPIO08 0xf148
49 #define STB0899_GPIO09 0xf149
50 #define STB0899_GPIO10 0xf14a
51 #define STB0899_GPIO11 0xf14b
52 #define STB0899_GPIO12 0xf14c
53 #define STB0899_GPIO13 0xf14d
54 #define STB0899_GPIO14 0xf14e
55 #define STB0899_GPIO15 0xf14f
56 #define STB0899_GPIO16 0xf150
57 #define STB0899_GPIO17 0xf151
58 #define STB0899_GPIO18 0xf152
59 #define STB0899_GPIO19 0xf153
60 #define STB0899_GPIO20 0xf154
62 #define STB0899_GPIOPULLUP 0x01 /* Output device is connected to Vdd */
63 #define STB0899_GPIOPULLDN 0x00 /* Output device is connected to Vss */
65 #define STB0899_POSTPROC_GPIO_POWER 0x00
66 #define STB0899_POSTPROC_GPIO_LOCK 0x01
69 * Post process output configuration control
70 * 1. POWER ON/OFF (index 0)
71 * 2. FE_HAS_LOCK/LOCK_LOSS (index 1)
73 * @gpio = one of the above listed GPIO's
74 * @level = output state: pulled up or low
76 struct stb0899_postproc {
81 struct stb0899_config {
82 const struct stb0899_s1_reg *init_dev;
83 const struct stb0899_s2_reg *init_s2_demod;
84 const struct stb0899_s1_reg *init_s1_demod;
85 const struct stb0899_s2_reg *init_s2_fec;
86 const struct stb0899_s1_reg *init_tst;
88 const struct stb0899_postproc *postproc;
90 enum stb0899_inversion inversion;
115 u32 uwp_threshold_acq;
116 u32 uwp_threshold_track;
117 u32 uwp_threshold_sof;
118 u32 sof_search_timeout;
121 u32 btr_gain_shift_offset;
125 int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
126 int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
127 int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
128 int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
129 int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain);
132 #if IS_REACHABLE(CONFIG_DVB_STB0899)
134 extern struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
135 struct i2c_adapter *i2c);
139 static inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
140 struct i2c_adapter *i2c)
142 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
146 #endif //CONFIG_DVB_STB0899