m88ds3103.h 4.6 KB

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