ld9040.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * ld9040 AMOLED LCD panel driver.
  3. *
  4. * Copyright (C) 2012 Samsung Electronics
  5. * Donghwa Lee <dh09.lee@samsung.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <spi.h>
  11. static const unsigned char SEQ_SWRESET[] = {
  12. 0x01,
  13. };
  14. static const unsigned char SEQ_USER_SETTING[] = {
  15. 0xF0, 0x5A, 0x5A
  16. };
  17. static const unsigned char SEQ_ELVSS_ON[] = {
  18. 0xB1, 0x0D, 0x00, 0x16,
  19. };
  20. static const unsigned char SEQ_TEMP_SWIRE[] = {
  21. 0xB2, 0x06, 0x06, 0x06, 0x06,
  22. };
  23. static const unsigned char SEQ_GTCON[] = {
  24. 0xF7, 0x09, 0x00, 0x00,
  25. };
  26. static const unsigned char SEQ_PANEL_CONDITION[] = {
  27. 0xF8, 0x05, 0x65, 0x96, 0x71, 0x7D, 0x19, 0x3B,
  28. 0x0D, 0x19, 0x7E, 0x0D, 0xE2, 0x00, 0x00, 0x7E,
  29. 0x7D, 0x07, 0x07, 0x20, 0x20, 0x20, 0x02, 0x02,
  30. };
  31. static const unsigned char SEQ_GAMMA_SET1[] = {
  32. 0xF9, 0x00, 0xA7, 0xB4, 0xAE, 0xBF, 0x00, 0x91,
  33. 0x00, 0xB2, 0xB4, 0xAA, 0xBB, 0x00, 0xAC, 0x00,
  34. 0xB3, 0xB1, 0xAA, 0xBC, 0x00, 0xB3,
  35. };
  36. static const unsigned char SEQ_GAMMA_CTRL[] = {
  37. 0xFB, 0x02, 0x5A,
  38. };
  39. static const unsigned char SEQ_APON[] = {
  40. 0xF3, 0x00, 0x00, 0x00, 0x0A, 0x02,
  41. };
  42. static const unsigned char SEQ_DISPCTL[] = {
  43. 0xF2, 0x02, 0x08, 0x08, 0x10, 0x10,
  44. };
  45. static const unsigned char SEQ_MANPWR[] = {
  46. 0xB0, 0x04,
  47. };
  48. static const unsigned char SEQ_PWR_CTRL[] = {
  49. 0xF4, 0x0A, 0x87, 0x25, 0x6A, 0x44, 0x02, 0x88,
  50. };
  51. static const unsigned char SEQ_SLPOUT[] = {
  52. 0x11,
  53. };
  54. static const unsigned char SEQ_SLPIN[] = {
  55. 0x10,
  56. };
  57. static const unsigned char SEQ_DISPON[] = {
  58. 0x29,
  59. };
  60. static const unsigned char SEQ_DISPOFF[] = {
  61. 0x28,
  62. };
  63. static void ld9040_spi_write(const unsigned char *wbuf, unsigned int size_cmd)
  64. {
  65. int i = 0;
  66. /*
  67. * Data are transmitted in 9-bit words:
  68. * the first bit is command/parameter, the other are the value.
  69. * The value's LSB is shifted to MSB position, to be sent as 9th bit
  70. */
  71. unsigned int data_out = 0, data_in = 0;
  72. for (i = 0; i < size_cmd; i++) {
  73. data_out = wbuf[i] >> 1;
  74. if (i != 0)
  75. data_out += 0x0080;
  76. if (wbuf[i] & 0x01)
  77. data_out += 0x8000;
  78. spi_xfer(NULL, 9, &data_out, &data_in, SPI_XFER_BEGIN);
  79. }
  80. }
  81. void ld9040_cfg_ldo(void)
  82. {
  83. udelay(10);
  84. ld9040_spi_write(SEQ_USER_SETTING,
  85. ARRAY_SIZE(SEQ_USER_SETTING));
  86. ld9040_spi_write(SEQ_PANEL_CONDITION,
  87. ARRAY_SIZE(SEQ_PANEL_CONDITION));
  88. ld9040_spi_write(SEQ_DISPCTL, ARRAY_SIZE(SEQ_DISPCTL));
  89. ld9040_spi_write(SEQ_MANPWR, ARRAY_SIZE(SEQ_MANPWR));
  90. ld9040_spi_write(SEQ_PWR_CTRL, ARRAY_SIZE(SEQ_PWR_CTRL));
  91. ld9040_spi_write(SEQ_ELVSS_ON, ARRAY_SIZE(SEQ_ELVSS_ON));
  92. ld9040_spi_write(SEQ_GTCON, ARRAY_SIZE(SEQ_GTCON));
  93. ld9040_spi_write(SEQ_GAMMA_SET1, ARRAY_SIZE(SEQ_GAMMA_SET1));
  94. ld9040_spi_write(SEQ_GAMMA_CTRL, ARRAY_SIZE(SEQ_GAMMA_CTRL));
  95. ld9040_spi_write(SEQ_SLPOUT, ARRAY_SIZE(SEQ_SLPOUT));
  96. udelay(120);
  97. }
  98. void ld9040_enable_ldo(unsigned int onoff)
  99. {
  100. if (onoff)
  101. ld9040_spi_write(SEQ_DISPON, ARRAY_SIZE(SEQ_DISPON));
  102. else
  103. ld9040_spi_write(SEQ_DISPOFF, ARRAY_SIZE(SEQ_DISPOFF));
  104. }