1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
29a0bf528SMauro Carvalho Chehab #ifndef DIB8000_H
39a0bf528SMauro Carvalho Chehab #define DIB8000_H
49a0bf528SMauro Carvalho Chehab 
59a0bf528SMauro Carvalho Chehab #include "dibx000_common.h"
69a0bf528SMauro Carvalho Chehab 
79a0bf528SMauro Carvalho Chehab struct dib8000_config {
89a0bf528SMauro Carvalho Chehab 	u8 output_mpeg2_in_188_bytes;
99a0bf528SMauro Carvalho Chehab 	u8 hostbus_diversity;
109a0bf528SMauro Carvalho Chehab 	u8 tuner_is_baseband;
119a0bf528SMauro Carvalho Chehab 	int (*update_lna) (struct dvb_frontend *, u16 agc_global);
129a0bf528SMauro Carvalho Chehab 
139a0bf528SMauro Carvalho Chehab 	u8 agc_config_count;
149a0bf528SMauro Carvalho Chehab 	struct dibx000_agc_config *agc;
159a0bf528SMauro Carvalho Chehab 	struct dibx000_bandwidth_config *pll;
169a0bf528SMauro Carvalho Chehab 
179a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_DEFAULT_DIRECTIONS 0xffff
189a0bf528SMauro Carvalho Chehab 	u16 gpio_dir;
199a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_DEFAULT_VALUES     0x0000
209a0bf528SMauro Carvalho Chehab 	u16 gpio_val;
219a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_PWM_POS0(v)        ((v & 0xf) << 12)
229a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_PWM_POS1(v)        ((v & 0xf) << 8 )
239a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_PWM_POS2(v)        ((v & 0xf) << 4 )
249a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_PWM_POS3(v)         (v & 0xf)
259a0bf528SMauro Carvalho Chehab #define DIB8000_GPIO_DEFAULT_PWM_POS    0xffff
269a0bf528SMauro Carvalho Chehab 	u16 gpio_pwm_pos;
279a0bf528SMauro Carvalho Chehab 	u16 pwm_freq_div;
289a0bf528SMauro Carvalho Chehab 
299a0bf528SMauro Carvalho Chehab 	void (*agc_control) (struct dvb_frontend *, u8 before);
309a0bf528SMauro Carvalho Chehab 
319a0bf528SMauro Carvalho Chehab 	u16 drives;
329a0bf528SMauro Carvalho Chehab 	u16 diversity_delay;
339a0bf528SMauro Carvalho Chehab 	u8 div_cfg;
349a0bf528SMauro Carvalho Chehab 	u8 output_mode;
359a0bf528SMauro Carvalho Chehab 	u8 refclksel;
369a0bf528SMauro Carvalho Chehab 	u8 enMpegOutput:1;
37173a64cbSPatrick Boettcher 
38173a64cbSPatrick Boettcher 	struct dibx000_bandwidth_config *plltable;
399a0bf528SMauro Carvalho Chehab };
409a0bf528SMauro Carvalho Chehab 
419a0bf528SMauro Carvalho Chehab #define DEFAULT_DIB8000_I2C_ADDRESS 18
429a0bf528SMauro Carvalho Chehab 
43d44913c1SMauro Carvalho Chehab struct dib8000_ops {
44d44913c1SMauro Carvalho Chehab 	int (*set_wbd_ref)(struct dvb_frontend *fe, u16 value);
45d44913c1SMauro Carvalho Chehab 	int (*update_pll)(struct dvb_frontend *fe,
46173a64cbSPatrick Boettcher 		struct dibx000_bandwidth_config *pll, u32 bw, u8 ratio);
47d44913c1SMauro Carvalho Chehab 	int (*set_gpio)(struct dvb_frontend *fe, u8 num, u8 dir, u8 val);
48d44913c1SMauro Carvalho Chehab 	void (*pwm_agc_reset)(struct dvb_frontend *fe);
49d44913c1SMauro Carvalho Chehab 	struct i2c_adapter *(*get_i2c_tuner)(struct dvb_frontend *fe);
50d44913c1SMauro Carvalho Chehab 	int (*tuner_sleep)(struct dvb_frontend *fe, int onoff);
51d44913c1SMauro Carvalho Chehab 	s32 (*get_adc_power)(struct dvb_frontend *fe, u8 mode);
52d44913c1SMauro Carvalho Chehab 	int (*get_dc_power)(struct dvb_frontend *fe, u8 IQ);
53d44913c1SMauro Carvalho Chehab 	u32 (*ctrl_timf)(struct dvb_frontend *fe, uint8_t op, uint32_t timf);
54d44913c1SMauro Carvalho Chehab 	enum frontend_tune_state (*get_tune_state)(struct dvb_frontend *fe);
55d44913c1SMauro Carvalho Chehab 	int (*set_tune_state)(struct dvb_frontend *fe, enum frontend_tune_state tune_state);
56d44913c1SMauro Carvalho Chehab 	int (*set_slave_frontend)(struct dvb_frontend *fe, struct dvb_frontend *fe_slave);
57d44913c1SMauro Carvalho Chehab 	struct dvb_frontend *(*get_slave_frontend)(struct dvb_frontend *fe, int slave_index);
58d44913c1SMauro Carvalho Chehab 	int (*i2c_enumeration)(struct i2c_adapter *host, int no_of_demods,
59d44913c1SMauro Carvalho Chehab 		u8 default_addr, u8 first_addr, u8 is_dib8096p);
60d44913c1SMauro Carvalho Chehab 	struct i2c_adapter *(*get_i2c_master)(struct dvb_frontend *fe, enum dibx000_i2c_interface intf, int gating);
61d44913c1SMauro Carvalho Chehab 	int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff);
62d44913c1SMauro Carvalho Chehab 	int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
63d44913c1SMauro Carvalho Chehab 	struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg);
64d44913c1SMauro Carvalho Chehab };
65d44913c1SMauro Carvalho Chehab 
669b174527SArnd Bergmann #if IS_REACHABLE(CONFIG_DVB_DIB8000)
67d44913c1SMauro Carvalho Chehab void *dib8000_attach(struct dib8000_ops *ops);
689a0bf528SMauro Carvalho Chehab #else
dib8000_attach(struct dib8000_ops * ops)6921de82e3SMauro Carvalho Chehab static inline void *dib8000_attach(struct dib8000_ops *ops)
709a0bf528SMauro Carvalho Chehab {
719a0bf528SMauro Carvalho Chehab 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
729a0bf528SMauro Carvalho Chehab 	return NULL;
739a0bf528SMauro Carvalho Chehab }
749a0bf528SMauro Carvalho Chehab #endif
759a0bf528SMauro Carvalho Chehab 
769a0bf528SMauro Carvalho Chehab #endif
77