/*
* S6E63M0 AMOLED LCD panel driver.
*
* Author: InKi Dae <inki.dae@samsung.com>
*
* Derived from drivers/video/omap/lcd-apollon.c
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <linux/wait.h>
#include <linux/fb.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/spi/spi.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/lcd.h>
#include <linux/backlight.h>
#include "s6e63m0_gamma.h"
#define SLEEPMSEC 0x1000
#define ENDDEF 0x2000
#define DEFMASK 0xFF00
#define COMMAND_ONLY 0xFE
#define DATA_ONLY 0xFF
#define MIN_BRIGHTNESS 0
#define MAX_BRIGHTNESS 10
#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
struct s6e63m0 {
struct device *dev;
struct spi_device *spi;
unsigned int power;
unsigned int current_brightness;
unsigned int gamma_mode;
unsigned int gamma_table_count;
struct lcd_device *ld;
struct backlight_device *bd;
struct lcd_platform_data *lcd_pd;
};
static const unsigned short SEQ_PANEL_CONDITION_SET[] = {
0xF8, 0x01,
DATA_ONLY, 0x27,
DATA_ONLY, 0x27,
DATA_ONLY, 0x07,
DATA_ONLY, 0x07,
DATA_ONLY, 0x54,
DATA_ONLY, 0x9f,
DATA_ONLY, 0x63,
DATA_ONLY, 0x86,
DATA_ONLY, 0x1a,
DATA_ONLY, 0x33,
DATA_ONLY, 0x0d,
DATA_ONLY, 0x00,
DATA_ONLY, 0x00,
ENDDEF, 0x0000
};
static const unsigned short SEQ_DISPLAY_CONDITION_SET[] = {
0xf2, 0x02,
DATA_ONLY, 0x03,
DATA_ONLY, 0x1c,
DATA_ONLY, 0x10,
DATA_ONLY, 0x10,
0xf7, 0x03,
DATA_ONLY, 0x00,
DATA_ONLY, 0x00,
ENDDEF, 0x0000
};
static const unsigned short SEQ_GAMMA_SETTING[] = {
0xfa, 0x00,
DATA_ONLY, 0x18,
DATA_ONLY, 0x08,
DATA_ONLY, 0x24,
DATA_ONLY, 0x64,
DATA_ONLY, 0x56,
DATA_ONLY, 0x33,
DATA_ONLY, 0xb6,
DATA_ONLY, 0xba,
DATA_ONLY, 0xa8,
DATA_ONLY, 0xac,
DATA_ONLY, 0xb1,
DATA_ONLY, 0x9d,
DATA_ONLY, 0xc1,
DATA_ONLY, 0xc1,
DATA_ONLY, 0xb7,
DATA_ONLY, 0x00,
DATA_ONLY, 0x9c,
DATA_ONLY, 0x00,
DATA_ONLY, 0x9f,
DATA_ONLY, 0x00,
DATA_ONLY, 0xd6,
0xfa, 0x01,
ENDDEF, 0x0000
};
static const unsigned short SEQ_ETC_CONDITION_SET[] = {
0xf6, 0x00,
DATA_ONLY, 0x8c,
DATA_ONLY, 0x07,
0xb3, 0xc,
0xb5, 0x2c,
DATA_ONLY, 0x12,
DATA_ONLY, 0x0c,
DATA_ONLY, 0x0a,
DATA_ONLY, 0x10,
DATA_ONLY, 0x0e,
DATA_ONLY, 0x17,
DATA_ONLY, 0x13,
DATA_ONLY, 0x1f,
DATA_ONLY, 0x1a,
DATA_ONLY, 0x2a,
DATA_ONLY, 0x24,
DATA_ONLY, 0x1f,
DATA_ONLY, 0x1b,
DATA_ONLY, 0x1a,
DATA_ONLY, 0x17,
DATA_ONLY, 0x2b,
DATA_ONLY, 0x26,
DATA_ONLY, 0x22,
DATA_ONLY, 0x20,
DATA_ONLY, 0x3a,
DATA_ONLY, 0x34,
DATA_ONLY, 0x30,
DATA_ONLY, 0x2c,
DATA_ONLY, 0x29,
DATA_ONLY, 0x26,
DATA_ONLY, 0x25,
DATA_ONLY, 0x23,
DATA_ONLY, 0x21,
DATA_ONLY, 0x20,
DATA_ONLY, 0x1e,
DATA_ONLY, 0x1e,
0xb6, 0x00,
DATA_ONLY, 0x00,
DATA_ONLY, 0x11,
DATA_ONLY, 0x22,
DATA_ONLY, 0x33,
DATA_ONLY, 0x44,
DATA_ONLY, 0x44,
DATA_ONLY, 0x44,
DATA_ONLY, 0x55,
DATA_ONLY, 0x55,
DATA_ONLY, 0x66,
DATA_ONLY, 0x66,
DATA_ONLY, 0x66,
DATA_ONLY, 0x66,
DATA_ONLY, 0x66,
DATA_ONLY, 0x66,
0xb7, 0x2c,
DATA_ONLY, 0x12,
DATA_ONLY, 0x0c,
DATA_ONLY, 0x0a,
DATA_ONLY, 0x10,
DATA_ONLY, 0x0e,
DATA_ONLY, 0x17,
DATA_ONLY, 0x13,
DATA_ONLY, 0x1f,
DATA_ONLY, 0x1a,
DATA_ONLY, 0x2a,
DATA_ONLY, 0x24,
DATA_ONLY, 0x1f,
DATA_ONLY, 0x1b,
DATA_ONLY, 0x1a,
DATA_ONLY, 0x17,
DATA_ONLY, 0x2b,
DATA_ONLY, 0x26,
DATA_ONLY, 0x22,
DATA_ONLY, 0x20,
DATA_ONLY, 0x3a,
DATA_ONLY, 0x34,
DATA_ONLY,