dibx000_common.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef DIBX000_COMMON_H
  3. #define DIBX000_COMMON_H
  4. enum dibx000_i2c_interface {
  5. DIBX000_I2C_INTERFACE_TUNER = 0,
  6. DIBX000_I2C_INTERFACE_GPIO_1_2 = 1,
  7. DIBX000_I2C_INTERFACE_GPIO_3_4 = 2,
  8. DIBX000_I2C_INTERFACE_GPIO_6_7 = 3
  9. };
  10. struct dibx000_i2c_master {
  11. #define DIB3000MC 1
  12. #define DIB7000 2
  13. #define DIB7000P 11
  14. #define DIB7000MC 12
  15. #define DIB8000 13
  16. u16 device_rev;
  17. enum dibx000_i2c_interface selected_interface;
  18. /* struct i2c_adapter tuner_i2c_adap; */
  19. struct i2c_adapter gated_tuner_i2c_adap;
  20. struct i2c_adapter master_i2c_adap_gpio12;
  21. struct i2c_adapter master_i2c_adap_gpio34;
  22. struct i2c_adapter master_i2c_adap_gpio67;
  23. struct i2c_adapter *i2c_adap;
  24. u8 i2c_addr;
  25. u16 base_reg;
  26. /* for the I2C transfer */
  27. struct i2c_msg msg[34];
  28. u8 i2c_write_buffer[8];
  29. u8 i2c_read_buffer[2];
  30. struct mutex i2c_buffer_lock;
  31. };
  32. extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
  33. u16 device_rev, struct i2c_adapter *i2c_adap,
  34. u8 i2c_addr);
  35. extern struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master
  36. *mst,
  37. enum dibx000_i2c_interface
  38. intf, int gating);
  39. extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
  40. extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
  41. extern int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed);
  42. #define BAND_LBAND 0x01
  43. #define BAND_UHF 0x02
  44. #define BAND_VHF 0x04
  45. #define BAND_SBAND 0x08
  46. #define BAND_FM 0x10
  47. #define BAND_CBAND 0x20
  48. #define BAND_OF_FREQUENCY(freq_kHz) ((freq_kHz) <= 170000 ? BAND_CBAND : \
  49. (freq_kHz) <= 115000 ? BAND_FM : \
  50. (freq_kHz) <= 250000 ? BAND_VHF : \
  51. (freq_kHz) <= 863000 ? BAND_UHF : \
  52. (freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
  53. struct dibx000_agc_config {
  54. /* defines the capabilities of this AGC-setting - using the BAND_-defines */
  55. u8 band_caps;
  56. u16 setup;
  57. u16 inv_gain;
  58. u16 time_stabiliz;
  59. u8 alpha_level;
  60. u16 thlock;
  61. u8 wbd_inv;
  62. u16 wbd_ref;
  63. u8 wbd_sel;
  64. u8 wbd_alpha;
  65. u16 agc1_max;
  66. u16 agc1_min;
  67. u16 agc2_max;
  68. u16 agc2_min;
  69. u8 agc1_pt1;
  70. u8 agc1_pt2;
  71. u8 agc1_pt3;
  72. u8 agc1_slope1;
  73. u8 agc1_slope2;
  74. u8 agc2_pt1;
  75. u8 agc2_pt2;
  76. u8 agc2_slope1;
  77. u8 agc2_slope2;
  78. u8 alpha_mant;
  79. u8 alpha_exp;
  80. u8 beta_mant;
  81. u8 beta_exp;
  82. u8 perform_agc_softsplit;
  83. struct {
  84. u16 min;
  85. u16 max;
  86. u16 min_thres;
  87. u16 max_thres;
  88. } split;
  89. };
  90. struct dibx000_bandwidth_config {
  91. u32 internal;
  92. u32 sampling;
  93. u8 pll_prediv;
  94. u8 pll_ratio;
  95. u8 pll_range;
  96. u8 pll_reset;
  97. u8 pll_bypass;
  98. u8 enable_refdiv;
  99. u8 bypclk_div;
  100. u8 IO_CLK_en_core;
  101. u8 ADClkSrc;
  102. u8 modulo;
  103. u16 sad_cfg;
  104. u32 ifreq;
  105. u32 timf;
  106. u32 xtal_hz;
  107. };
  108. enum dibx000_adc_states {
  109. DIBX000_SLOW_ADC_ON = 0,
  110. DIBX000_SLOW_ADC_OFF,
  111. DIBX000_ADC_ON,
  112. DIBX000_ADC_OFF,
  113. DIBX000_VBG_ENABLE,
  114. DIBX000_VBG_DISABLE,
  115. };
  116. #define BANDWIDTH_TO_KHZ(v) ((v) / 1000)
  117. #define BANDWIDTH_TO_HZ(v) ((v) * 1000)
  118. /* Chip output mode. */
  119. #define OUTMODE_HIGH_Z 0
  120. #define OUTMODE_MPEG2_PAR_GATED_CLK 1
  121. #define OUTMODE_MPEG2_PAR_CONT_CLK 2
  122. #define OUTMODE_MPEG2_SERIAL 7
  123. #define OUTMODE_DIVERSITY 4
  124. #define OUTMODE_MPEG2_FIFO 5
  125. #define OUTMODE_ANALOG_ADC 6
  126. #define INPUT_MODE_OFF 0x11
  127. #define INPUT_MODE_DIVERSITY 0x12
  128. #define INPUT_MODE_MPEG 0x13
  129. enum frontend_tune_state {
  130. CT_TUNER_START = 10,
  131. CT_TUNER_STEP_0,
  132. CT_TUNER_STEP_1,
  133. CT_TUNER_STEP_2,
  134. CT_TUNER_STEP_3,
  135. CT_TUNER_STEP_4,
  136. CT_TUNER_STEP_5,
  137. CT_TUNER_STEP_6,
  138. CT_TUNER_STEP_7,
  139. CT_TUNER_STOP,
  140. CT_AGC_START = 20,
  141. CT_AGC_STEP_0,
  142. CT_AGC_STEP_1,
  143. CT_AGC_STEP_2,
  144. CT_AGC_STEP_3,
  145. CT_AGC_STEP_4,
  146. CT_AGC_STOP,
  147. CT_DEMOD_START = 30,
  148. CT_DEMOD_STEP_1,
  149. CT_DEMOD_STEP_2,
  150. CT_DEMOD_STEP_3,
  151. CT_DEMOD_STEP_4,
  152. CT_DEMOD_STEP_5,
  153. CT_DEMOD_STEP_6,
  154. CT_DEMOD_STEP_7,
  155. CT_DEMOD_STEP_8,
  156. CT_DEMOD_STEP_9,
  157. CT_DEMOD_STEP_10,
  158. CT_DEMOD_STEP_11,
  159. CT_DEMOD_SEARCH_NEXT = 51,
  160. CT_DEMOD_STEP_LOCKED,
  161. CT_DEMOD_STOP,
  162. CT_DONE = 100,
  163. CT_SHUTDOWN,
  164. };
  165. struct dvb_frontend_parametersContext {
  166. #define CHANNEL_STATUS_PARAMETERS_UNKNOWN 0x01
  167. #define CHANNEL_STATUS_PARAMETERS_SET 0x02
  168. u8 status;
  169. u32 tune_time_estimation[2];
  170. s32 tps_available;
  171. u16 tps[9];
  172. };
  173. #define FE_STATUS_TUNE_FAILED 0
  174. #define FE_STATUS_TUNE_TIMED_OUT -1
  175. #define FE_STATUS_TUNE_TIME_TOO_SHORT -2
  176. #define FE_STATUS_TUNE_PENDING -3
  177. #define FE_STATUS_STD_SUCCESS -4
  178. #define FE_STATUS_FFT_SUCCESS -5
  179. #define FE_STATUS_DEMOD_SUCCESS -6
  180. #define FE_STATUS_LOCKED -7
  181. #define FE_STATUS_DATA_LOCKED -8
  182. #define FE_CALLBACK_TIME_NEVER 0xffffffff
  183. #define DATA_BUS_ACCESS_MODE_8BIT 0x01
  184. #define DATA_BUS_ACCESS_MODE_16BIT 0x02
  185. #define DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT 0x10
  186. struct dibGPIOFunction {
  187. #define BOARD_GPIO_COMPONENT_BUS_ADAPTER 1
  188. #define BOARD_GPIO_COMPONENT_DEMOD 2
  189. u8 component;
  190. #define BOARD_GPIO_FUNCTION_BOARD_ON 1
  191. #define BOARD_GPIO_FUNCTION_BOARD_OFF 2
  192. #define BOARD_GPIO_FUNCTION_COMPONENT_ON 3
  193. #define BOARD_GPIO_FUNCTION_COMPONENT_OFF 4
  194. #define BOARD_GPIO_FUNCTION_SUBBAND_PWM 5
  195. #define BOARD_GPIO_FUNCTION_SUBBAND_GPIO 6
  196. u8 function;
  197. /* mask, direction and value are used specify which GPIO to change GPIO0
  198. * is LSB and possible GPIO31 is MSB. The same bit-position as in the
  199. * mask is used for the direction and the value. Direction == 1 is OUT,
  200. * 0 == IN. For direction "OUT" value is either 1 or 0, for direction IN
  201. * value has no meaning.
  202. *
  203. * In case of BOARD_GPIO_FUNCTION_PWM mask is giving the GPIO to be
  204. * used to do the PWM. Direction gives the PWModulator to be used.
  205. * Value gives the PWM value in device-dependent scale.
  206. */
  207. u32 mask;
  208. u32 direction;
  209. u32 value;
  210. };
  211. #define MAX_NB_SUBBANDS 8
  212. struct dibSubbandSelection {
  213. u8 size; /* Actual number of subbands. */
  214. struct {
  215. u16 f_mhz;
  216. struct dibGPIOFunction gpio;
  217. } subband[MAX_NB_SUBBANDS];
  218. };
  219. #define DEMOD_TIMF_SET 0x00
  220. #define DEMOD_TIMF_GET 0x01
  221. #define DEMOD_TIMF_UPDATE 0x02
  222. #define MPEG_ON_DIBTX 1
  223. #define DIV_ON_DIBTX 2
  224. #define ADC_ON_DIBTX 3
  225. #define DEMOUT_ON_HOSTBUS 4
  226. #define DIBTX_ON_HOSTBUS 5
  227. #define MPEG_ON_HOSTBUS 6
  228. #endif