ssd2828.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * (C) 2015 Siarhei Siamashka <siarhei.siamashka@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. /*
  7. * Support for the SSD2828 bridge chip, which can take pixel data coming
  8. * from a parallel LCD interface and translate it on the flight into MIPI DSI
  9. * interface for driving a MIPI compatible TFT display.
  10. *
  11. * Implemented as a utility function. To be used from display drivers, which are
  12. * responsible for driving parallel LCD hardware in front of the video pipeline.
  13. */
  14. #ifndef _SSD2828_H
  15. #define _SSD2828_H
  16. struct ctfb_res_modes;
  17. struct ssd2828_config {
  18. /*********************************************************************/
  19. /* SSD2828 configuration */
  20. /*********************************************************************/
  21. /*
  22. * The pins, which are used for SPI communication. This is only used
  23. * for configuring SSD2828, so the performance is irrelevant (only
  24. * around a hundred of bytes is moved). Also these can be any arbitrary
  25. * GPIO pins (not necessarily the pins having hardware SPI function).
  26. * Moreover, the 'sdo' pin may be even not wired up in some devices.
  27. *
  28. * These configuration variables need to be set as pin numbers for
  29. * the standard u-boot GPIO interface (gpio_get_value/gpio_set_value
  30. * functions). Note that -1 value can be used for the pins, which are
  31. * not really wired up.
  32. */
  33. int csx_pin;
  34. int sck_pin;
  35. int sdi_pin;
  36. int sdo_pin;
  37. /* SSD2828 reset pin (shared with LCD panel reset) */
  38. int reset_pin;
  39. /*
  40. * The SSD2828 has its own dedicated clock source 'tx_clk' (connected
  41. * to TX_CLK_XIO/TX_CLK_XIN pins), which is necessary at least for
  42. * clocking SPI after reset. The exact clock speed is not strictly,
  43. * defined, but the datasheet says that it must be somewhere in the
  44. * 8MHz - 30MHz range (see "TX_CLK Timing" section). It can be also
  45. * used as a reference clock for PLL. If the exact clock frequency
  46. * is known, then it can be specified here. If it is unknown, or the
  47. * information is not trustworthy, then it can be set to 0.
  48. *
  49. * If unsure, set to 0.
  50. */
  51. int ssd2828_tx_clk_khz;
  52. /*
  53. * This is not a property of the used LCD panel, but more like a
  54. * property of the SSD2828 wiring. See the "SSD2828QN4 RGB data
  55. * arrangement" table in the datasheet. The SSD2828 pins are arranged
  56. * in such a way that 18bpp and 24bpp configurations are completely
  57. * incompatible with each other.
  58. *
  59. * Depending on the color depth, this must be set to 16, 18 or 24.
  60. */
  61. int ssd2828_color_depth;
  62. /*********************************************************************/
  63. /* LCD panel configuration */
  64. /*********************************************************************/
  65. /*
  66. * The number of lanes in the MIPI DSI interface. May vary from 1 to 4.
  67. *
  68. * This information can be found in the LCD panel datasheet.
  69. */
  70. int mipi_dsi_number_of_data_lanes;
  71. /*
  72. * Data transfer bit rate per lane. Please note that it is expected
  73. * to be higher than the pixel clock rate of the used video mode when
  74. * multiplied by the number of lanes. This is perfectly normal because
  75. * MIPI DSI handles data transfers in periodic bursts, and uses the
  76. * idle time between bursts for sending configuration information and
  77. * commands. Or just for saving power.
  78. *
  79. * The necessary Mbps/lane information can be found in the LCD panel
  80. * datasheet. Note that the transfer rate can't be always set precisely
  81. * and it may be rounded *up* (introducing no more than 10Mbps error).
  82. */
  83. int mipi_dsi_bitrate_per_data_lane_mbps;
  84. /*
  85. * Setting this to 1 enforces packing of 18bpp pixel data in 24bpp
  86. * envelope when sending it over the MIPI DSI link.
  87. *
  88. * If unsure, set to 0.
  89. */
  90. int mipi_dsi_loosely_packed_pixel_format;
  91. /*
  92. * According to the "Example for system sleep in and out" section in
  93. * the SSD2828 datasheet, some LCD panel specific delays are necessary
  94. * after MIPI DCS commands EXIT_SLEEP_MODE and SET_DISPLAY_ON.
  95. *
  96. * For example, Allwinner uses 100 milliseconds delay after
  97. * EXIT_SLEEP_MODE and 200 milliseconds delay after SET_DISPLAY_ON.
  98. */
  99. int mipi_dsi_delay_after_exit_sleep_mode_ms;
  100. int mipi_dsi_delay_after_set_display_on_ms;
  101. };
  102. /*
  103. * Initialize the SSD2828 chip. It needs the 'ssd2828_config' structure
  104. * and also the video mode timings.
  105. *
  106. * The right place to insert this function call is after the parallel LCD
  107. * interface is initialized and before turning on the backlight. This is
  108. * advised in the "Example for system sleep in and out" section of the
  109. * SSD2828 datasheet. And also SS2828 may use 'pclk' as the clock source
  110. * for PLL, which means that the input signal must be already there.
  111. */
  112. int ssd2828_init(const struct ssd2828_config *cfg,
  113. const struct ctfb_res_modes *mode);
  114. #endif