2 * LCD panel driver for Board based on S5PC100 and S5PC110.
4 * Author: Donghwa Lee <dh09.lee@samsung.com>
6 * Derived from drivers/video/omap/lcd-apollon.c
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <linux/types.h>
26 #include <asm/arch/cpu.h>
27 #include <asm/arch/gpio.h>
30 enum ld9040_panel_type {
36 static enum ld9040_panel_type panel_type;
37 /* these machine specific platform data would be setting at universal.c */
38 struct spi_platform_data *ld9040;
40 static const unsigned char SEQ_SWRESET[] = {
44 static const unsigned char SEQ_USER_SETTING[] = {
50 static const unsigned char SEQ_ELVSS_ON[] = {
57 static const unsigned short SEQ_ELVSS_ON_SM2[] = {
69 static const unsigned char SEQ_TEMP_SWIRE[] = {
77 static const unsigned char SEQ_GTCON[] = {
84 static const unsigned char SEQ_GTCON_REV[] = {
91 static const unsigned char SEQ_PANEL_CONDITION[] = {
118 static const unsigned char SEQ_GAMMA_SET1[] = {
143 static const unsigned char SEQ_GAMMA_CTRL[] = {
149 static const unsigned char SEQ_APON[] = {
158 static const unsigned char SEQ_DISPCTL[] = {
167 static const unsigned char SEQ_MANPWR[] = {
171 static const unsigned char SEQ_PWR_CTRL[] = {
182 static const unsigned char SEQ_PWR_CTRL_SM2_A1[] = {
192 static const unsigned char SEQ_PWR_CTRL_SM2_A2[] = {
202 static const unsigned char SEQ_SLPOUT[] = {
206 static const unsigned char SEQ_SLPIN[] = {
210 static const unsigned char SEQ_DISPON[] = {
214 static const unsigned char SEQ_DISPOFF[] = {
218 static const unsigned char SEQ_VCI1_1ST_EN[] = {
227 static const unsigned char SEQ_VL1_EN[] = {
236 static const unsigned char SEQ_VL2_EN[] = {
245 static const unsigned char SEQ_VCI1_2ND_EN[] = {
254 static const unsigned char SEQ_VL3_EN[] = {
263 static const unsigned char SEQ_VREG1_AMP_EN[] = {
272 static const unsigned char SEQ_VGH_AMP_EN[] = {
281 static const unsigned char SEQ_VGL_AMP_EN[] = {
290 static const unsigned char SEQ_VMOS_AMP_EN[] = {
299 static const unsigned char SEQ_VINT_AMP_EN[] = {
303 /* DATA_ONLY, 0x71, VMOS/VBL/VBH not used */
307 /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */
310 static const unsigned char SEQ_VBH_AMP_EN[] = {
319 static const unsigned char SEQ_VBL_AMP_EN[] = {
328 static const unsigned char SEQ_GAM_AMP_EN[] = {
332 /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */
336 /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */
339 static const unsigned char SEQ_SD_AMP_EN[] = {
343 /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */
347 /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */
350 static const unsigned char SEQ_GLS_EN[] = {
354 /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */
358 /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */
361 static const unsigned char SEQ_ELS_EN[] = {
365 /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */
369 /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */
372 static const unsigned char SEQ_EL_ON[] = {
376 /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */
380 /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */
383 static const unsigned char SEQ_ID1[] = {
387 static const unsigned char SEQ_ID2[] = {
390 static const unsigned char SEQ_ID3[] = {
394 static void ld9040_spi_write(unsigned char address, unsigned char command)
396 if (address != DATA_ONLY)
397 spi_gpio_write(ld9040, (unsigned int) 0x0, (unsigned int) address);
399 if (command != COMMAND_ONLY)
400 spi_gpio_write(ld9040, (unsigned int) 0x1, (unsigned int) command);
403 static void ld9040_panel_send_sequence(const unsigned char *wbuf, unsigned int size_cmd)
407 while (i < size_cmd) {
408 ld9040_spi_write(wbuf[i], wbuf[i+1]);
413 static int ld9040_spi_read(const unsigned char *wbuf, unsigned int size_cmd)
415 ld9040_panel_send_sequence(wbuf, size_cmd);
416 return spi_gpio_read(ld9040);
419 static int ld9040_panel_read_id(void)
423 id[0] = ld9040_spi_read(SEQ_ID1, ARRAY_SIZE(SEQ_ID1));
425 id[1] = ld9040_spi_read(SEQ_ID2, ARRAY_SIZE(SEQ_ID2));
426 id[2] = ld9040_spi_read(SEQ_ID3, ARRAY_SIZE(SEQ_ID3));
427 printf("OLED Module manufacturer : \t%x\n", id[0]);
428 printf("OLED Module/driver version : \t%x\n", id[1]);
429 printf("OLED module/driver : \t\t%x\n", id[2]);
434 panel_type = TYPE_SM2_A2;
437 panel_type = TYPE_SM2_A1;
440 panel_type = TYPE_M2;
445 void ld9040_cfg_ldo(void)
447 ld9040_panel_send_sequence(SEQ_USER_SETTING,
448 ARRAY_SIZE(SEQ_USER_SETTING));
449 ld9040_panel_send_sequence(SEQ_DISPCTL, ARRAY_SIZE(SEQ_DISPCTL));
451 ld9040_panel_send_sequence(SEQ_GTCON_REV, ARRAY_SIZE(SEQ_GTCON_REV));
453 ld9040_panel_send_sequence(SEQ_GTCON, ARRAY_SIZE(SEQ_GTCON));
454 ld9040_panel_send_sequence(SEQ_PANEL_CONDITION,
455 ARRAY_SIZE(SEQ_PANEL_CONDITION));
457 ld9040_panel_read_id();
459 switch (panel_type) {
461 ld9040_panel_send_sequence(SEQ_ELVSS_ON_SM2, ARRAY_SIZE(SEQ_ELVSS_ON_SM2));
462 ld9040_panel_send_sequence(SEQ_PWR_CTRL_SM2_A1, ARRAY_SIZE(SEQ_PWR_CTRL_SM2_A1));
465 ld9040_panel_send_sequence(SEQ_ELVSS_ON_SM2, ARRAY_SIZE(SEQ_ELVSS_ON_SM2));
466 ld9040_panel_send_sequence(SEQ_PWR_CTRL_SM2_A2, ARRAY_SIZE(SEQ_PWR_CTRL_SM2_A2));
471 ld9040_panel_send_sequence(SEQ_MANPWR, ARRAY_SIZE(SEQ_MANPWR));
472 ld9040_panel_send_sequence(SEQ_PWR_CTRL, ARRAY_SIZE(SEQ_PWR_CTRL));
473 ld9040_panel_send_sequence(SEQ_ELVSS_ON, ARRAY_SIZE(SEQ_ELVSS_ON));
477 ld9040_panel_send_sequence(SEQ_GAMMA_SET1, ARRAY_SIZE(SEQ_GAMMA_SET1));
478 ld9040_panel_send_sequence(SEQ_GAMMA_CTRL, ARRAY_SIZE(SEQ_GAMMA_CTRL));
479 ld9040_panel_send_sequence(SEQ_SLPOUT, ARRAY_SIZE(SEQ_SLPOUT));
484 void ld9040_enable_ldo(unsigned int on)
487 ld9040_panel_send_sequence(SEQ_DISPON, ARRAY_SIZE(SEQ_DISPON));
490 /* this function would be called at universal.c */
491 void ld9040_set_platform_data(struct spi_platform_data *pd)
494 puts("pd is NULL.\n");