m88ds3103.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Montage Technology M88DS3103/M88RS6000 demodulator driver
  3. *
  4. * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #ifndef M88DS3103_H
  17. #define M88DS3103_H
  18. #include <linux/dvb/frontend.h>
  19. /*
  20. * I2C address
  21. * 0x68,
  22. */
  23. /**
  24. * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver
  25. * @clk: Clock frequency.
  26. * @i2c_wr_max: Max bytes I2C adapter can write at once.
  27. * @ts_mode: TS mode.
  28. * @ts_clk: TS clock (KHz).
  29. * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising
  30. * edge.
  31. * @spec_inv: Input spectrum inversion.
  32. * @agc: AGC configuration.
  33. * @agc_inv: AGC polarity.
  34. * @clk_out: Clock output.
  35. * @envelope_mode: DiSEqC envelope mode.
  36. * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to
  37. * set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18.
  38. * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to
  39. * enable. 1: pin high to enable, pin low to disable.
  40. * @get_dvb_frontend: Get DVB frontend.
  41. * @get_i2c_adapter: Get I2C adapter.
  42. */
  43. struct m88ds3103_platform_data {
  44. u32 clk;
  45. u16 i2c_wr_max;
  46. #define M88DS3103_TS_SERIAL 0 /* TS output pin D0, normal */
  47. #define M88DS3103_TS_SERIAL_D7 1 /* TS output pin D7 */
  48. #define M88DS3103_TS_PARALLEL 2 /* TS Parallel mode */
  49. #define M88DS3103_TS_CI 3 /* TS CI Mode */
  50. u8 ts_mode:2;
  51. u32 ts_clk;
  52. u8 ts_clk_pol:1;
  53. u8 spec_inv:1;
  54. u8 agc;
  55. u8 agc_inv:1;
  56. #define M88DS3103_CLOCK_OUT_DISABLED 0
  57. #define M88DS3103_CLOCK_OUT_ENABLED 1
  58. #define M88DS3103_CLOCK_OUT_ENABLED_DIV2 2
  59. u8 clk_out:2;
  60. u8 envelope_mode:1;
  61. u8 lnb_hv_pol:1;
  62. u8 lnb_en_pol:1;
  63. struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
  64. struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
  65. /* private: For legacy media attach wrapper. Do not set value. */
  66. u8 attach_in_use:1;
  67. };
  68. /*
  69. * Do not add new m88ds3103_attach() users! Use I2C bindings instead.
  70. */
  71. struct m88ds3103_config {
  72. /*
  73. * I2C address
  74. * Default: none, must set
  75. * 0x68, ...
  76. */
  77. u8 i2c_addr;
  78. /*
  79. * clock
  80. * Default: none, must set
  81. * 27000000
  82. */
  83. u32 clock;
  84. /*
  85. * max bytes I2C provider is asked to write at once
  86. * Default: none, must set
  87. * 33, 65, ...
  88. */
  89. u16 i2c_wr_max;
  90. /*
  91. * TS output mode
  92. * Default: M88DS3103_TS_SERIAL
  93. */
  94. #define M88DS3103_TS_SERIAL 0 /* TS output pin D0, normal */
  95. #define M88DS3103_TS_SERIAL_D7 1 /* TS output pin D7 */
  96. #define M88DS3103_TS_PARALLEL 2 /* TS Parallel mode */
  97. #define M88DS3103_TS_CI 3 /* TS CI Mode */
  98. u8 ts_mode;
  99. /*
  100. * TS clk in KHz
  101. * Default: 0.
  102. */
  103. u32 ts_clk;
  104. /*
  105. * TS clk polarity.
  106. * Default: 0. 1-active at falling edge; 0-active at rising edge.
  107. */
  108. u8 ts_clk_pol:1;
  109. /*
  110. * spectrum inversion
  111. * Default: 0
  112. */
  113. u8 spec_inv:1;
  114. /*
  115. * AGC polarity
  116. * Default: 0
  117. */
  118. u8 agc_inv:1;
  119. /*
  120. * clock output
  121. * Default: M88DS3103_CLOCK_OUT_DISABLED
  122. */
  123. #define M88DS3103_CLOCK_OUT_DISABLED 0
  124. #define M88DS3103_CLOCK_OUT_ENABLED 1
  125. #define M88DS3103_CLOCK_OUT_ENABLED_DIV2 2
  126. u8 clock_out;
  127. /*
  128. * DiSEqC envelope mode
  129. * Default: 0
  130. */
  131. u8 envelope_mode:1;
  132. /*
  133. * AGC configuration
  134. * Default: none, must set
  135. */
  136. u8 agc;
  137. /*
  138. * LNB H/V pin polarity
  139. * Default: 0.
  140. * 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18.
  141. * 0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13.
  142. */
  143. u8 lnb_hv_pol:1;
  144. /*
  145. * LNB enable pin polarity
  146. * Default: 0.
  147. * 1: pin high to enable, pin low to disable.
  148. * 0: pin high to disable, pin low to enable.
  149. */
  150. u8 lnb_en_pol:1;
  151. };
  152. #if defined(CONFIG_DVB_M88DS3103) || \
  153. (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE))
  154. extern struct dvb_frontend *m88ds3103_attach(
  155. const struct m88ds3103_config *config,
  156. struct i2c_adapter *i2c,
  157. struct i2c_adapter **tuner_i2c);
  158. extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm);
  159. #else
  160. static inline struct dvb_frontend *m88ds3103_attach(
  161. const struct m88ds3103_config *config,
  162. struct i2c_adapter *i2c,
  163. struct i2c_adapter **tuner_i2c)
  164. {
  165. pr_warn("%s: driver disabled by Kconfig\n", __func__);
  166. return NULL;
  167. }
  168. #define m88ds3103_get_agc_pwm NULL
  169. #endif
  170. #endif