intel_dpio_phy.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright © 2014-2016 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #include "intel_drv.h"
  24. void chv_set_phy_signal_level(struct intel_encoder *encoder,
  25. u32 deemph_reg_value, u32 margin_reg_value,
  26. bool uniq_trans_scale)
  27. {
  28. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  29. struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
  30. struct intel_crtc *intel_crtc = to_intel_crtc(dport->base.base.crtc);
  31. enum dpio_channel ch = vlv_dport_to_channel(dport);
  32. enum pipe pipe = intel_crtc->pipe;
  33. u32 val;
  34. int i;
  35. mutex_lock(&dev_priv->sb_lock);
  36. /* Clear calc init */
  37. val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch));
  38. val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3);
  39. val &= ~(DPIO_PCS_TX1DEEMP_MASK | DPIO_PCS_TX2DEEMP_MASK);
  40. val |= DPIO_PCS_TX1DEEMP_9P5 | DPIO_PCS_TX2DEEMP_9P5;
  41. vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val);
  42. if (intel_crtc->config->lane_count > 2) {
  43. val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch));
  44. val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3);
  45. val &= ~(DPIO_PCS_TX1DEEMP_MASK | DPIO_PCS_TX2DEEMP_MASK);
  46. val |= DPIO_PCS_TX1DEEMP_9P5 | DPIO_PCS_TX2DEEMP_9P5;
  47. vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val);
  48. }
  49. val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW9(ch));
  50. val &= ~(DPIO_PCS_TX1MARGIN_MASK | DPIO_PCS_TX2MARGIN_MASK);
  51. val |= DPIO_PCS_TX1MARGIN_000 | DPIO_PCS_TX2MARGIN_000;
  52. vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW9(ch), val);
  53. if (intel_crtc->config->lane_count > 2) {
  54. val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW9(ch));
  55. val &= ~(DPIO_PCS_TX1MARGIN_MASK | DPIO_PCS_TX2MARGIN_MASK);
  56. val |= DPIO_PCS_TX1MARGIN_000 | DPIO_PCS_TX2MARGIN_000;
  57. vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW9(ch), val);
  58. }
  59. /* Program swing deemph */
  60. for (i = 0; i < intel_crtc->config->lane_count; i++) {
  61. val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW4(ch, i));
  62. val &= ~DPIO_SWING_DEEMPH9P5_MASK;
  63. val |= deemph_reg_value << DPIO_SWING_DEEMPH9P5_SHIFT;
  64. vlv_dpio_write(dev_priv, pipe, CHV_TX_DW4(ch, i), val);
  65. }
  66. /* Program swing margin */
  67. for (i = 0; i < intel_crtc->config->lane_count; i++) {
  68. val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW2(ch, i));
  69. val &= ~DPIO_SWING_MARGIN000_MASK;
  70. val |= margin_reg_value << DPIO_SWING_MARGIN000_SHIFT;
  71. /*
  72. * Supposedly this value shouldn't matter when unique transition
  73. * scale is disabled, but in fact it does matter. Let's just
  74. * always program the same value and hope it's OK.
  75. */
  76. val &= ~(0xff << DPIO_UNIQ_TRANS_SCALE_SHIFT);
  77. val |= 0x9a << DPIO_UNIQ_TRANS_SCALE_SHIFT;
  78. vlv_dpio_write(dev_priv, pipe, CHV_TX_DW2(ch, i), val);
  79. }
  80. /*
  81. * The document said it needs to set bit 27 for ch0 and bit 26
  82. * for ch1. Might be a typo in the doc.
  83. * For now, for this unique transition scale selection, set bit
  84. * 27 for ch0 and ch1.
  85. */
  86. for (i = 0; i < intel_crtc->config->lane_count; i++) {
  87. val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW3(ch, i));
  88. if (uniq_trans_scale)
  89. val |= DPIO_TX_UNIQ_TRANS_SCALE_EN;
  90. else
  91. val &= ~DPIO_TX_UNIQ_TRANS_SCALE_EN;
  92. vlv_dpio_write(dev_priv, pipe, CHV_TX_DW3(ch, i), val);
  93. }
  94. /* Start swing calculation */
  95. val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch));
  96. val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3;
  97. vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val);
  98. if (intel_crtc->config->lane_count > 2) {
  99. val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch));
  100. val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3;
  101. vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val);
  102. }
  103. mutex_unlock(&dev_priv->sb_lock);
  104. }