sprd_dsi.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020 Unisoc Inc.
  4. */
  5. #ifndef __SPRD_DSI_H__
  6. #define __SPRD_DSI_H__
  7. #include <linux/of.h>
  8. #include <linux/device.h>
  9. #include <linux/regmap.h>
  10. #include <video/videomode.h>
  11. #include <drm/drm_bridge.h>
  12. #include <drm/drm_connector.h>
  13. #include <drm/drm_encoder.h>
  14. #include <drm/drm_mipi_dsi.h>
  15. #include <drm/drm_print.h>
  16. #include <drm/drm_panel.h>
  17. #define encoder_to_dsi(encoder) \
  18. container_of(encoder, struct sprd_dsi, encoder)
  19. enum dsi_work_mode {
  20. DSI_MODE_CMD = 0,
  21. DSI_MODE_VIDEO
  22. };
  23. enum video_burst_mode {
  24. VIDEO_NON_BURST_WITH_SYNC_PULSES = 0,
  25. VIDEO_NON_BURST_WITH_SYNC_EVENTS,
  26. VIDEO_BURST_WITH_SYNC_PULSES
  27. };
  28. enum dsi_color_coding {
  29. COLOR_CODE_16BIT_CONFIG1 = 0,
  30. COLOR_CODE_16BIT_CONFIG2,
  31. COLOR_CODE_16BIT_CONFIG3,
  32. COLOR_CODE_18BIT_CONFIG1,
  33. COLOR_CODE_18BIT_CONFIG2,
  34. COLOR_CODE_24BIT,
  35. COLOR_CODE_20BIT_YCC422_LOOSELY,
  36. COLOR_CODE_24BIT_YCC422,
  37. COLOR_CODE_16BIT_YCC422,
  38. COLOR_CODE_30BIT,
  39. COLOR_CODE_36BIT,
  40. COLOR_CODE_12BIT_YCC420,
  41. COLOR_CODE_COMPRESSTION,
  42. COLOR_CODE_MAX
  43. };
  44. enum pll_timing {
  45. NONE,
  46. REQUEST_TIME,
  47. PREPARE_TIME,
  48. SETTLE_TIME,
  49. ZERO_TIME,
  50. TRAIL_TIME,
  51. EXIT_TIME,
  52. CLKPOST_TIME,
  53. TA_GET,
  54. TA_GO,
  55. TA_SURE,
  56. TA_WAIT,
  57. };
  58. struct dphy_pll {
  59. u8 refin; /* Pre-divider control signal */
  60. u8 cp_s; /* 00: SDM_EN=1, 10: SDM_EN=0 */
  61. u8 fdk_s; /* PLL mode control: integer or fraction */
  62. u8 sdm_en;
  63. u8 div;
  64. u8 int_n; /* integer N PLL */
  65. u32 ref_clk; /* dphy reference clock, unit: MHz */
  66. u32 freq; /* panel config, unit: KHz */
  67. u32 fvco;
  68. u32 potential_fvco;
  69. u32 nint; /* sigma delta modulator NINT control */
  70. u32 kint; /* sigma delta modulator KINT control */
  71. u8 lpf_sel; /* low pass filter control */
  72. u8 out_sel; /* post divider control */
  73. u8 vco_band; /* vco range */
  74. u8 det_delay;
  75. };
  76. struct dsi_context {
  77. void __iomem *base;
  78. struct regmap *regmap;
  79. struct dphy_pll pll;
  80. struct videomode vm;
  81. bool enabled;
  82. u8 work_mode;
  83. u8 burst_mode;
  84. u32 int0_mask;
  85. u32 int1_mask;
  86. /* maximum time (ns) for data lanes from HS to LP */
  87. u16 data_hs2lp;
  88. /* maximum time (ns) for data lanes from LP to HS */
  89. u16 data_lp2hs;
  90. /* maximum time (ns) for clk lanes from HS to LP */
  91. u16 clk_hs2lp;
  92. /* maximum time (ns) for clk lanes from LP to HS */
  93. u16 clk_lp2hs;
  94. /* maximum time (ns) for BTA operation - REQUIRED */
  95. u16 max_rd_time;
  96. /* enable receiving frame ack packets - for video mode */
  97. bool frame_ack_en;
  98. /* enable receiving tear effect ack packets - for cmd mode */
  99. bool te_ack_en;
  100. };
  101. struct sprd_dsi {
  102. struct drm_device *drm;
  103. struct mipi_dsi_host host;
  104. struct mipi_dsi_device *slave;
  105. struct drm_encoder encoder;
  106. struct drm_bridge *panel_bridge;
  107. struct dsi_context ctx;
  108. };
  109. int dphy_pll_config(struct dsi_context *ctx);
  110. void dphy_timing_config(struct dsi_context *ctx);
  111. #endif /* __SPRD_DSI_H__ */