1 /* 2 * ld9040 AMOLED LCD panel driver. 3 * 4 * Copyright (C) 2012 Samsung Electronics 5 * Donghwa Lee <dh09.lee@samsung.com> 6 * 7 * See file CREDITS for list of people who contributed to this 8 * project. 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License as 12 * published by the Free Software Foundation; either version 2 of 13 * the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * MA 02111-1307 USA 24 */ 25 26 #include <common.h> 27 #include <spi.h> 28 29 static const unsigned char SEQ_SWRESET[] = { 30 0x01, 31 }; 32 33 static const unsigned char SEQ_USER_SETTING[] = { 34 0xF0, 0x5A, 0x5A 35 }; 36 37 static const unsigned char SEQ_ELVSS_ON[] = { 38 0xB1, 0x0D, 0x00, 0x16, 39 }; 40 41 static const unsigned char SEQ_TEMP_SWIRE[] = { 42 0xB2, 0x06, 0x06, 0x06, 0x06, 43 }; 44 45 static const unsigned char SEQ_GTCON[] = { 46 0xF7, 0x09, 0x00, 0x00, 47 }; 48 49 static const unsigned char SEQ_PANEL_CONDITION[] = { 50 0xF8, 0x05, 0x65, 0x96, 0x71, 0x7D, 0x19, 0x3B, 51 0x0D, 0x19, 0x7E, 0x0D, 0xE2, 0x00, 0x00, 0x7E, 52 0x7D, 0x07, 0x07, 0x20, 0x20, 0x20, 0x02, 0x02, 53 }; 54 55 static const unsigned char SEQ_GAMMA_SET1[] = { 56 0xF9, 0x00, 0xA7, 0xB4, 0xAE, 0xBF, 0x00, 0x91, 57 0x00, 0xB2, 0xB4, 0xAA, 0xBB, 0x00, 0xAC, 0x00, 58 0xB3, 0xB1, 0xAA, 0xBC, 0x00, 0xB3, 59 }; 60 61 static const unsigned char SEQ_GAMMA_CTRL[] = { 62 0xFB, 0x02, 0x5A, 63 }; 64 65 static const unsigned char SEQ_APON[] = { 66 0xF3, 0x00, 0x00, 0x00, 0x0A, 0x02, 67 }; 68 69 static const unsigned char SEQ_DISPCTL[] = { 70 0xF2, 0x02, 0x08, 0x08, 0x10, 0x10, 71 }; 72 73 static const unsigned char SEQ_MANPWR[] = { 74 0xB0, 0x04, 75 }; 76 77 static const unsigned char SEQ_PWR_CTRL[] = { 78 0xF4, 0x0A, 0x87, 0x25, 0x6A, 0x44, 0x02, 0x88, 79 }; 80 81 static const unsigned char SEQ_SLPOUT[] = { 82 0x11, 83 }; 84 85 static const unsigned char SEQ_SLPIN[] = { 86 0x10, 87 }; 88 89 static const unsigned char SEQ_DISPON[] = { 90 0x29, 91 }; 92 93 static const unsigned char SEQ_DISPOFF[] = { 94 0x28, 95 }; 96 97 static void ld9040_spi_write(const unsigned char *wbuf, unsigned int size_cmd) 98 { 99 int i = 0; 100 101 /* 102 * Data are transmitted in 9-bit words: 103 * the first bit is command/parameter, the other are the value. 104 * The value's LSB is shifted to MSB position, to be sent as 9th bit 105 */ 106 107 unsigned int data_out = 0, data_in = 0; 108 for (i = 0; i < size_cmd; i++) { 109 data_out = wbuf[i] >> 1; 110 if (i != 0) 111 data_out += 0x0080; 112 if (wbuf[i] & 0x01) 113 data_out += 0x8000; 114 spi_xfer(NULL, 9, &data_out, &data_in, SPI_XFER_BEGIN); 115 } 116 } 117 118 void ld9040_cfg_ldo(void) 119 { 120 udelay(10); 121 122 ld9040_spi_write(SEQ_USER_SETTING, 123 ARRAY_SIZE(SEQ_USER_SETTING)); 124 ld9040_spi_write(SEQ_PANEL_CONDITION, 125 ARRAY_SIZE(SEQ_PANEL_CONDITION)); 126 ld9040_spi_write(SEQ_DISPCTL, ARRAY_SIZE(SEQ_DISPCTL)); 127 ld9040_spi_write(SEQ_MANPWR, ARRAY_SIZE(SEQ_MANPWR)); 128 ld9040_spi_write(SEQ_PWR_CTRL, ARRAY_SIZE(SEQ_PWR_CTRL)); 129 ld9040_spi_write(SEQ_ELVSS_ON, ARRAY_SIZE(SEQ_ELVSS_ON)); 130 ld9040_spi_write(SEQ_GTCON, ARRAY_SIZE(SEQ_GTCON)); 131 ld9040_spi_write(SEQ_GAMMA_SET1, ARRAY_SIZE(SEQ_GAMMA_SET1)); 132 ld9040_spi_write(SEQ_GAMMA_CTRL, ARRAY_SIZE(SEQ_GAMMA_CTRL)); 133 ld9040_spi_write(SEQ_SLPOUT, ARRAY_SIZE(SEQ_SLPOUT)); 134 135 udelay(120); 136 } 137 138 void ld9040_enable_ldo(unsigned int onoff) 139 { 140 if (onoff) 141 ld9040_spi_write(SEQ_DISPON, ARRAY_SIZE(SEQ_DISPON)); 142 else 143 ld9040_spi_write(SEQ_DISPOFF, ARRAY_SIZE(SEQ_DISPOFF)); 144 } 145