intel_dsi_cmd.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright © 2013 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. * Author: Jani Nikula <jani.nikula@intel.com>
  24. */
  25. #include <linux/export.h>
  26. #include <drm/drmP.h>
  27. #include <drm/drm_crtc.h>
  28. #include <video/mipi_display.h>
  29. #include "i915_drv.h"
  30. #include "intel_drv.h"
  31. #include "intel_dsi.h"
  32. #include "intel_dsi_cmd.h"
  33. /*
  34. * XXX: MIPI_DATA_ADDRESS, MIPI_DATA_LENGTH, MIPI_COMMAND_LENGTH, and
  35. * MIPI_COMMAND_ADDRESS registers.
  36. *
  37. * Apparently these registers provide a MIPI adapter level way to send (lots of)
  38. * commands and data to the receiver, without having to write the commands and
  39. * data to MIPI_{HS,LP}_GEN_{CTRL,DATA} registers word by word.
  40. *
  41. * Presumably for anything other than MIPI_DCS_WRITE_MEMORY_START and
  42. * MIPI_DCS_WRITE_MEMORY_CONTINUE (which are used to update the external
  43. * framebuffer in command mode displays) these are just an optimization that can
  44. * come later.
  45. *
  46. * For memory writes, these should probably be used for performance.
  47. */
  48. static void print_stat(struct intel_dsi *intel_dsi, enum port port)
  49. {
  50. struct drm_encoder *encoder = &intel_dsi->base.base;
  51. struct drm_device *dev = encoder->dev;
  52. struct drm_i915_private *dev_priv = dev->dev_private;
  53. u32 val;
  54. val = I915_READ(MIPI_INTR_STAT(port));
  55. #define STAT_BIT(val, bit) (val) & (bit) ? " " #bit : ""
  56. DRM_DEBUG_KMS("MIPI_INTR_STAT(%c) = %08x"
  57. "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
  58. "\n", port_name(port), val,
  59. STAT_BIT(val, TEARING_EFFECT),
  60. STAT_BIT(val, SPL_PKT_SENT_INTERRUPT),
  61. STAT_BIT(val, GEN_READ_DATA_AVAIL),
  62. STAT_BIT(val, LP_GENERIC_WR_FIFO_FULL),
  63. STAT_BIT(val, HS_GENERIC_WR_FIFO_FULL),
  64. STAT_BIT(val, RX_PROT_VIOLATION),
  65. STAT_BIT(val, RX_INVALID_TX_LENGTH),
  66. STAT_BIT(val, ACK_WITH_NO_ERROR),
  67. STAT_BIT(val, TURN_AROUND_ACK_TIMEOUT),
  68. STAT_BIT(val, LP_RX_TIMEOUT),
  69. STAT_BIT(val, HS_TX_TIMEOUT),
  70. STAT_BIT(val, DPI_FIFO_UNDERRUN),
  71. STAT_BIT(val, LOW_CONTENTION),
  72. STAT_BIT(val, HIGH_CONTENTION),
  73. STAT_BIT(val, TXDSI_VC_ID_INVALID),
  74. STAT_BIT(val, TXDSI_DATA_TYPE_NOT_RECOGNISED),
  75. STAT_BIT(val, TXCHECKSUM_ERROR),
  76. STAT_BIT(val, TXECC_MULTIBIT_ERROR),
  77. STAT_BIT(val, TXECC_SINGLE_BIT_ERROR),
  78. STAT_BIT(val, TXFALSE_CONTROL_ERROR),
  79. STAT_BIT(val, RXDSI_VC_ID_INVALID),
  80. STAT_BIT(val, RXDSI_DATA_TYPE_NOT_REGOGNISED),
  81. STAT_BIT(val, RXCHECKSUM_ERROR),
  82. STAT_BIT(val, RXECC_MULTIBIT_ERROR),
  83. STAT_BIT(val, RXECC_SINGLE_BIT_ERROR),
  84. STAT_BIT(val, RXFALSE_CONTROL_ERROR),
  85. STAT_BIT(val, RXHS_RECEIVE_TIMEOUT_ERROR),
  86. STAT_BIT(val, RX_LP_TX_SYNC_ERROR),
  87. STAT_BIT(val, RXEXCAPE_MODE_ENTRY_ERROR),
  88. STAT_BIT(val, RXEOT_SYNC_ERROR),
  89. STAT_BIT(val, RXSOT_SYNC_ERROR),
  90. STAT_BIT(val, RXSOT_ERROR));
  91. #undef STAT_BIT
  92. }
  93. /* enable or disable command mode hs transmissions */
  94. void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
  95. enum port port)
  96. {
  97. struct drm_encoder *encoder = &intel_dsi->base.base;
  98. struct drm_device *dev = encoder->dev;
  99. struct drm_i915_private *dev_priv = dev->dev_private;
  100. u32 temp;
  101. u32 mask = DBI_FIFO_EMPTY;
  102. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 50))
  103. DRM_ERROR("Timeout waiting for DBI FIFO empty\n");
  104. temp = I915_READ(MIPI_HS_LP_DBI_ENABLE(port));
  105. temp &= DBI_HS_LP_MODE_MASK;
  106. I915_WRITE(MIPI_HS_LP_DBI_ENABLE(port), enable ? DBI_HS_MODE : DBI_LP_MODE);
  107. intel_dsi->hs = enable;
  108. }