ld9040.c 2.6 KB

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