m88ds3103.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. * enum m88ds3103_ts_mode - TS connection mode
  25. * @M88DS3103_TS_SERIAL: TS output pin D0, normal
  26. * @M88DS3103_TS_SERIAL_D7: TS output pin D7
  27. * @M88DS3103_TS_PARALLEL: TS Parallel mode
  28. * @M88DS3103_TS_CI: TS CI Mode
  29. */
  30. enum m88ds3103_ts_mode {
  31. M88DS3103_TS_SERIAL,
  32. M88DS3103_TS_SERIAL_D7,
  33. M88DS3103_TS_PARALLEL,
  34. M88DS3103_TS_CI
  35. };
  36. /**
  37. * enum m88ds3103_clock_out
  38. * @M88DS3103_CLOCK_OUT_DISABLED: Clock output is disabled
  39. * @M88DS3103_CLOCK_OUT_ENABLED: Clock output is enabled with crystal
  40. * clock.
  41. * @M88DS3103_CLOCK_OUT_ENABLED_DIV2: Clock output is enabled with half
  42. * crystal clock.
  43. */
  44. enum m88ds3103_clock_out {
  45. M88DS3103_CLOCK_OUT_DISABLED,
  46. M88DS3103_CLOCK_OUT_ENABLED,
  47. M88DS3103_CLOCK_OUT_ENABLED_DIV2
  48. };
  49. /**
  50. * struct m88ds3103_platform_data - Platform data for the m88ds3103 driver
  51. * @clk: Clock frequency.
  52. * @i2c_wr_max: Max bytes I2C adapter can write at once.
  53. * @ts_mode: TS mode.
  54. * @ts_clk: TS clock (KHz).
  55. * @ts_clk_pol: TS clk polarity. 1-active at falling edge; 0-active at rising
  56. * edge.
  57. * @spec_inv: Input spectrum inversion.
  58. * @agc: AGC configuration.
  59. * @agc_inv: AGC polarity.
  60. * @clk_out: Clock output.
  61. * @envelope_mode: DiSEqC envelope mode.
  62. * @lnb_hv_pol: LNB H/V pin polarity. 0: pin high set to VOLTAGE_18, pin low to
  63. * set VOLTAGE_13. 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18.
  64. * @lnb_en_pol: LNB enable pin polarity. 0: pin high to disable, pin low to
  65. * enable. 1: pin high to enable, pin low to disable.
  66. * @get_dvb_frontend: Get DVB frontend.
  67. * @get_i2c_adapter: Get I2C adapter.
  68. */
  69. struct m88ds3103_platform_data {
  70. u32 clk;
  71. u16 i2c_wr_max;
  72. enum m88ds3103_ts_mode ts_mode;
  73. u32 ts_clk;
  74. enum m88ds3103_clock_out clk_out;
  75. u8 ts_clk_pol:1;
  76. u8 spec_inv:1;
  77. u8 agc;
  78. u8 agc_inv:1;
  79. u8 envelope_mode:1;
  80. u8 lnb_hv_pol:1;
  81. u8 lnb_en_pol:1;
  82. struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
  83. struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
  84. /* private: For legacy media attach wrapper. Do not set value. */
  85. u8 attach_in_use:1;
  86. };
  87. /**
  88. * struct m88ds3103_config - m88ds3102 configuration
  89. *
  90. * @i2c_addr: I2C address. Default: none, must set. Example: 0x68, ...
  91. * @clock: Device's clock. Default: none, must set. Example: 27000000
  92. * @i2c_wr_max: Max bytes I2C provider is asked to write at once.
  93. * Default: none, must set. Example: 33, 65, ...
  94. * @ts_mode: TS output mode, as defined by &enum m88ds3103_ts_mode.
  95. * Default: M88DS3103_TS_SERIAL.
  96. * @ts_clk: TS clk in KHz. Default: 0.
  97. * @ts_clk_pol: TS clk polarity.Default: 0.
  98. * 1-active at falling edge; 0-active at rising edge.
  99. * @spec_inv: Spectrum inversion. Default: 0.
  100. * @agc_inv: AGC polarity. Default: 0.
  101. * @clock_out: Clock output, as defined by &enum m88ds3103_clock_out.
  102. * Default: M88DS3103_CLOCK_OUT_DISABLED.
  103. * @envelope_mode: DiSEqC envelope mode. Default: 0.
  104. * @agc: AGC configuration. Default: none, must set.
  105. * @lnb_hv_pol: LNB H/V pin polarity. Default: 0. Values:
  106. * 1: pin high set to VOLTAGE_13, pin low to set VOLTAGE_18;
  107. * 0: pin high set to VOLTAGE_18, pin low to set VOLTAGE_13.
  108. * @lnb_en_pol: LNB enable pin polarity. Default: 0. Values:
  109. * 1: pin high to enable, pin low to disable;
  110. * 0: pin high to disable, pin low to enable.
  111. */
  112. struct m88ds3103_config {
  113. u8 i2c_addr;
  114. u32 clock;
  115. u16 i2c_wr_max;
  116. u8 ts_mode;
  117. u32 ts_clk;
  118. u8 ts_clk_pol:1;
  119. u8 spec_inv:1;
  120. u8 agc_inv:1;
  121. u8 clock_out;
  122. u8 envelope_mode:1;
  123. u8 agc;
  124. u8 lnb_hv_pol:1;
  125. u8 lnb_en_pol:1;
  126. };
  127. #if defined(CONFIG_DVB_M88DS3103) || \
  128. (defined(CONFIG_DVB_M88DS3103_MODULE) && defined(MODULE))
  129. /**
  130. * Attach a m88ds3103 demod
  131. *
  132. * @config: pointer to &struct m88ds3103_config with demod configuration.
  133. * @i2c: i2c adapter to use.
  134. * @tuner_i2c: on success, returns the I2C adapter associated with
  135. * m88ds3103 tuner.
  136. *
  137. * return: FE pointer on success, NULL on failure.
  138. * Note: Do not add new m88ds3103_attach() users! Use I2C bindings instead.
  139. */
  140. extern struct dvb_frontend *m88ds3103_attach(
  141. const struct m88ds3103_config *config,
  142. struct i2c_adapter *i2c,
  143. struct i2c_adapter **tuner_i2c);
  144. extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm);
  145. #else
  146. static inline struct dvb_frontend *m88ds3103_attach(
  147. const struct m88ds3103_config *config,
  148. struct i2c_adapter *i2c,
  149. struct i2c_adapter **tuner_i2c)
  150. {
  151. pr_warn("%s: driver disabled by Kconfig\n", __func__);
  152. return NULL;
  153. }
  154. #define m88ds3103_get_agc_pwm NULL
  155. #endif
  156. #endif