1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Sony CXD2820R demodulator driver 4 * 5 * Copyright (C) 2010 Antti Palosaari <crope@iki.fi> 6 */ 7 8 9 #ifndef CXD2820R_H 10 #define CXD2820R_H 11 12 #include <linux/dvb/frontend.h> 13 14 #define CXD2820R_GPIO_D (0 << 0) /* disable */ 15 #define CXD2820R_GPIO_E (1 << 0) /* enable */ 16 #define CXD2820R_GPIO_O (0 << 1) /* output */ 17 #define CXD2820R_GPIO_I (1 << 1) /* input */ 18 #define CXD2820R_GPIO_L (0 << 2) /* output low */ 19 #define CXD2820R_GPIO_H (1 << 2) /* output high */ 20 21 #define CXD2820R_TS_SERIAL 0x08 22 #define CXD2820R_TS_SERIAL_MSB 0x28 23 #define CXD2820R_TS_PARALLEL 0x30 24 #define CXD2820R_TS_PARALLEL_MSB 0x70 25 26 /* 27 * I2C address: 0x6c, 0x6d 28 */ 29 30 /** 31 * struct cxd2820r_platform_data - Platform data for the cxd2820r driver 32 * @ts_mode: TS mode. 33 * @ts_clk_inv: TS clock inverted. 34 * @if_agc_polarity: IF AGC polarity. 35 * @spec_inv: Input spectrum inverted. 36 * @gpio_chip_base: GPIO. 37 * @get_dvb_frontend: Get DVB frontend. 38 */ 39 struct cxd2820r_platform_data { 40 u8 ts_mode; 41 bool ts_clk_inv; 42 bool if_agc_polarity; 43 bool spec_inv; 44 int **gpio_chip_base; 45 46 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 47 /* private: For legacy media attach wrapper. Do not set value. */ 48 bool attach_in_use; 49 }; 50 51 /** 52 * struct cxd2820r_config - configuration for cxd2020r demod 53 * 54 * @i2c_address: Demodulator I2C address. Driver determines DVB-C slave I2C 55 * address automatically from master address. 56 * Default: none, must set. Values: 0x6c, 0x6d. 57 * @ts_mode: TS output mode. Default: none, must set. Values: FIXME? 58 * @ts_clock_inv: TS clock inverted. Default: 0. Values: 0, 1. 59 * @if_agc_polarity: Default: 0. Values: 0, 1 60 * @spec_inv: Spectrum inversion. Default: 0. Values: 0, 1. 61 */ 62 struct cxd2820r_config { 63 /* Demodulator I2C address. 64 * Driver determines DVB-C slave I2C address automatically from master 65 * address. 66 * Default: none, must set 67 * Values: 0x6c, 0x6d 68 */ 69 u8 i2c_address; 70 71 /* TS output mode. 72 * Default: none, must set. 73 * Values: 74 */ 75 u8 ts_mode; 76 77 /* TS clock inverted. 78 * Default: 0 79 * Values: 0, 1 80 */ 81 bool ts_clock_inv; 82 83 /* IF AGC polarity. 84 * Default: 0 85 * Values: 0, 1 86 */ 87 bool if_agc_polarity; 88 89 /* Spectrum inversion. 90 * Default: 0 91 * Values: 0, 1 92 */ 93 bool spec_inv; 94 }; 95 96 97 #if IS_REACHABLE(CONFIG_DVB_CXD2820R) 98 /** 99 * Attach a cxd2820r demod 100 * 101 * @config: pointer to &struct cxd2820r_config with demod configuration. 102 * @i2c: i2c adapter to use. 103 * @gpio_chip_base: if zero, disables GPIO setting. Otherwise, if 104 * CONFIG_GPIOLIB is set dynamically allocate 105 * gpio base; if is not set, use its value to 106 * setup the GPIO pins. 107 * 108 * return: FE pointer on success, NULL on failure. 109 */ 110 extern struct dvb_frontend *cxd2820r_attach( 111 const struct cxd2820r_config *config, 112 struct i2c_adapter *i2c, 113 int *gpio_chip_base 114 ); 115 #else 116 static inline struct dvb_frontend *cxd2820r_attach( 117 const struct cxd2820r_config *config, 118 struct i2c_adapter *i2c, 119 int *gpio_chip_base 120 ) 121 { 122 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 123 return NULL; 124 } 125 126 #endif 127 128 #endif /* CXD2820R_H */ 129