stb0899_drv.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. STB0899 Multistandard Frontend driver
  4. Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  5. Copyright (C) ST Microelectronics
  6. */
  7. #ifndef __STB0899_DRV_H
  8. #define __STB0899_DRV_H
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <media/dvb_frontend.h>
  12. #define STB0899_TSMODE_SERIAL 1
  13. #define STB0899_CLKPOL_FALLING 2
  14. #define STB0899_CLKNULL_PARITY 3
  15. #define STB0899_SYNC_FORCED 4
  16. #define STB0899_FECMODE_DSS 5
  17. struct stb0899_s1_reg {
  18. u16 address;
  19. u8 data;
  20. };
  21. struct stb0899_s2_reg {
  22. u16 offset;
  23. u32 base_address;
  24. u32 data;
  25. };
  26. enum stb0899_inversion {
  27. IQ_SWAP_OFF = +1, /* inversion affects the sign of e. g. */
  28. IQ_SWAP_ON = -1, /* the derotator frequency register */
  29. };
  30. #define STB0899_GPIO00 0xf140
  31. #define STB0899_GPIO01 0xf141
  32. #define STB0899_GPIO02 0xf142
  33. #define STB0899_GPIO03 0xf143
  34. #define STB0899_GPIO04 0xf144
  35. #define STB0899_GPIO05 0xf145
  36. #define STB0899_GPIO06 0xf146
  37. #define STB0899_GPIO07 0xf147
  38. #define STB0899_GPIO08 0xf148
  39. #define STB0899_GPIO09 0xf149
  40. #define STB0899_GPIO10 0xf14a
  41. #define STB0899_GPIO11 0xf14b
  42. #define STB0899_GPIO12 0xf14c
  43. #define STB0899_GPIO13 0xf14d
  44. #define STB0899_GPIO14 0xf14e
  45. #define STB0899_GPIO15 0xf14f
  46. #define STB0899_GPIO16 0xf150
  47. #define STB0899_GPIO17 0xf151
  48. #define STB0899_GPIO18 0xf152
  49. #define STB0899_GPIO19 0xf153
  50. #define STB0899_GPIO20 0xf154
  51. #define STB0899_GPIOPULLUP 0x01 /* Output device is connected to Vdd */
  52. #define STB0899_GPIOPULLDN 0x00 /* Output device is connected to Vss */
  53. #define STB0899_POSTPROC_GPIO_POWER 0x00
  54. #define STB0899_POSTPROC_GPIO_LOCK 0x01
  55. /*
  56. * Post process output configuration control
  57. * 1. POWER ON/OFF (index 0)
  58. * 2. FE_HAS_LOCK/LOCK_LOSS (index 1)
  59. *
  60. * @gpio = one of the above listed GPIO's
  61. * @level = output state: pulled up or low
  62. */
  63. struct stb0899_postproc {
  64. u16 gpio;
  65. u8 level;
  66. };
  67. struct stb0899_config {
  68. const struct stb0899_s1_reg *init_dev;
  69. const struct stb0899_s2_reg *init_s2_demod;
  70. const struct stb0899_s1_reg *init_s1_demod;
  71. const struct stb0899_s2_reg *init_s2_fec;
  72. const struct stb0899_s1_reg *init_tst;
  73. const struct stb0899_postproc *postproc;
  74. enum stb0899_inversion inversion;
  75. u32 xtal_freq;
  76. u8 demod_address;
  77. u8 ts_output_mode;
  78. u8 block_sync_mode;
  79. u8 ts_pfbit_toggle;
  80. u8 clock_polarity;
  81. u8 data_clk_parity;
  82. u8 fec_mode;
  83. u8 data_output_ctl;
  84. u8 data_fifo_mode;
  85. u8 out_rate_comp;
  86. u8 i2c_repeater;
  87. // int inversion;
  88. int lo_clk;
  89. int hi_clk;
  90. u32 esno_ave;
  91. u32 esno_quant;
  92. u32 avframes_coarse;
  93. u32 avframes_fine;
  94. u32 miss_threshold;
  95. u32 uwp_threshold_acq;
  96. u32 uwp_threshold_track;
  97. u32 uwp_threshold_sof;
  98. u32 sof_search_timeout;
  99. u32 btr_nco_bits;
  100. u32 btr_gain_shift_offset;
  101. u32 crl_nco_bits;
  102. u32 ldpc_max_iter;
  103. int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
  104. int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
  105. int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
  106. int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  107. int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain);
  108. };
  109. #if IS_REACHABLE(CONFIG_DVB_STB0899)
  110. extern struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
  111. struct i2c_adapter *i2c);
  112. #else
  113. static inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
  114. struct i2c_adapter *i2c)
  115. {
  116. printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
  117. return NULL;
  118. }
  119. #endif //CONFIG_DVB_STB0899
  120. #endif