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