2 * LCD panel driver for Board based on S5PC100 and S5PC110.
4 * Author: InKi Dae <inki.dae@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 /* these machine specific platform data would be setting at universal.c */
31 struct spi_platform_data *s6d16a0x;
35 gpio_set_value(s6d16a0x->cs_bank, s6d16a0x->cs_num, 0);
40 gpio_set_value(s6d16a0x->cs_bank, s6d16a0x->cs_num, 1);
45 gpio_set_value(s6d16a0x->clk_bank, s6d16a0x->clk_num, 0);
50 gpio_set_value(s6d16a0x->clk_bank, s6d16a0x->clk_num, 1);
55 gpio_set_value(s6d16a0x->si_bank, s6d16a0x->si_num, 0);
60 gpio_set_value(s6d16a0x->si_bank, s6d16a0x->si_num, 1);
65 return gpio_get_value(s6d16a0x->so_bank, s6d16a0x->so_num);
68 static const unsigned short SEQ_PASSWD2_SET[] = {
75 static const unsigned short SEQ_DISCTL_SET[] = {
89 static const unsigned short SEQ_PWRCTL_SET[] = {
106 static const unsigned short SEQ_VCMCTL_SET[] = {
121 static const unsigned short SEQ_SRCCTL_SET[] = {
136 static const unsigned short SEQ_PANELCTL1_SET[] = {
147 static const unsigned short SEQ_PANELCTL2_SET[] = {
169 static const unsigned short SEQ_PANELCTL3_SET[] = {
191 static const unsigned short SEQ_PANELCTL4_SET[] = {
218 static const unsigned short SEQ_PGAMMACTL_SET[] = {
268 static const unsigned short SEQ_NGAMMACTL_SET[] = {
318 static const unsigned short SEQ_CLKCTL3_SET[] = {
326 static const unsigned short SEQ_HOSTCTL1_SET[] = {
333 static const unsigned short SEQ_HOSTCTL2_SET[] = {
340 static const unsigned short SEQ_TEON_SET[] = {
346 static const unsigned short SEQ_CASET[] = {
355 static const unsigned short SEQ_PASET[] = {
364 static const unsigned short SEQ_COLMOD[] = {
366 /* 0x36, 0xC4, */ /* MADCTL : Reverse display */
371 static const unsigned short SEQ_WRCTRLD[] = {
377 static const unsigned short SEQ_SLPOUT[] = {
383 static const unsigned short SEQ_DISPON[] = {
389 static const unsigned short SEQ_DISPOFF[] = {
395 unsigned char Delay=1;
397 static void s6d16a0x_c110_spi_write_byte(unsigned char address, unsigned char command)
401 data = (address << 8) + command;
411 for (j = PACKET_LEN; j >= 0; j--)
415 /* data high or low */
416 if ((data >> j) & 0x0001)
431 #ifdef UNUSED_FUNCTIONS
432 static unsigned char s6d16a0x_c110_spi_read_byte(unsigned char select, unsigned char address)
435 static unsigned int first = 1;
436 unsigned char DELAY=1;
437 unsigned short data = 0;
440 data = (select << 8) + address;
450 for (j = PACKET_LEN + 8; j >= 0; j--)
456 /* data high or low */
457 if ((data >> (j - 8)) & 0x0001)
466 gpio_cfg_pin(s6d16a0x->so_bank, s6d16a0x->so_num, GPIO_INPUT);
487 gpio_cfg_pin(s6d16a0x->so_bank, s6d16a0x->so_num, GPIO_OUTPUT);
493 static void s6d16a0x_spi_write(unsigned char address, unsigned char command)
495 if (address != DATA_ONLY)
496 s6d16a0x_c110_spi_write_byte(0x0, address);
498 if (command != COMMAND_ONLY)
499 s6d16a0x_c110_spi_write_byte(0x1, command);
502 static void s6d16a0x_panel_send_sequence(const unsigned short *wbuf)
506 while ((wbuf[i] & DEFMASK) != ENDDEF) {
507 if ((wbuf[i] & DEFMASK) != SLEEPMSEC)
508 s6d16a0x_spi_write(wbuf[i], wbuf[i+1]);
510 udelay(wbuf[i+1]*1000);
515 void s6d16a0x_cfg_ldo(void)
517 s6d16a0x_panel_send_sequence(SEQ_PASSWD2_SET);
518 s6d16a0x_panel_send_sequence(SEQ_DISCTL_SET);
519 s6d16a0x_panel_send_sequence(SEQ_PWRCTL_SET);
520 s6d16a0x_panel_send_sequence(SEQ_VCMCTL_SET);
521 s6d16a0x_panel_send_sequence(SEQ_SRCCTL_SET);
522 s6d16a0x_panel_send_sequence(SEQ_PANELCTL1_SET);
523 s6d16a0x_panel_send_sequence(SEQ_PANELCTL2_SET);
524 s6d16a0x_panel_send_sequence(SEQ_PANELCTL3_SET);
525 s6d16a0x_panel_send_sequence(SEQ_PANELCTL4_SET);
526 s6d16a0x_panel_send_sequence(SEQ_PGAMMACTL_SET);
527 s6d16a0x_panel_send_sequence(SEQ_NGAMMACTL_SET);
528 s6d16a0x_panel_send_sequence(SEQ_CLKCTL3_SET);
529 s6d16a0x_panel_send_sequence(SEQ_HOSTCTL1_SET);
530 s6d16a0x_panel_send_sequence(SEQ_HOSTCTL2_SET);
531 s6d16a0x_panel_send_sequence(SEQ_TEON_SET);
532 s6d16a0x_panel_send_sequence(SEQ_PASSWD2_SET);
533 s6d16a0x_panel_send_sequence(SEQ_CASET);
534 s6d16a0x_panel_send_sequence(SEQ_PASET);
535 s6d16a0x_panel_send_sequence(SEQ_COLMOD);
536 s6d16a0x_panel_send_sequence(SEQ_WRCTRLD);
537 s6d16a0x_panel_send_sequence(SEQ_SLPOUT);
541 void s6d16a0x_enable_ldo(unsigned int onoff)
544 s6d16a0x_panel_send_sequence(SEQ_DISPON);
548 /* this function would be called at universal.c */
549 void s6d16a0x_set_platform_data(struct spi_platform_data *pd)
552 printf("pd is NULL.\n");