1674 lines
38 KiB
C

/*
* drivers/input/keyboard/epaper.c
* AUO epaper Interface on S3C2416 in Qisda eBook
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#include "epaper.h"
#ifdef EPAPER_BOOT_CODE
#include <common.h>
#include <regs.h>
#include <asm/io.h>
#else //KERNEL
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/delay.h>
#include <asm/irq.h>
#include <asm/arch/regs-gpio.h>
#include <asm/arch/regs-timer.h>
#include <asm/arch/regs-lcd.h>
#include <asm/arch/regs-watchdog.h>
#include <linux/clk.h>
#endif
#define S3C_EPAPER_QISDA_DEBUG
#ifdef S3C_EPAPER_QISDA_DEBUG
#ifdef EPAPER_BOOT_CODE
#define DPRINTK(x...) //Be careful of code size if printf too much
#else //KERNEL
#define DPRINTK(x...) printk("S3C-Epaper-qisda " x)
#endif
#else
#define DPRINTK(x...) /* !!!! */
#endif
#ifdef EPAPER_BOOT_CODE
#define rGPCCON GPCCON
#define rGPCDAT GPCDAT
#define rGPDCON GPDCON
#define rGPDDAT GPDDAT
#define rGPCUDP GPCPU
#define rGPDUDP GPDPU
#define rGPLDAT GPLDAT
#define rGPLCON GPLCON
#define rGPLUDP GPLPU
#define rGPBCON GPBCON
#define rGPBDAT GPBDAT
#define rGPGCON GPGCON
#define rGPGDAT GPGDAT
#define rGPECON GPECON
#define rGPEDAT GPEDAT
#define rGPFCON GPFCON
#define rGPFDAT GPFDAT
#define rVIDCON0 VIDCON0 //VIDEO CONTROL REGTISTER 0
#define rSYSIFCON0 SYSIFCON0 //SYSTEM INTERFACE MAIN LDI
#define rSYSIFCON1 SYSIFCON1 //SYSTEM INTERFACE SUB LDI
#define rSIFCCON0 SIFCCON0 //SYSTEM INTERFACE COMMAND CONTROL
#define rSIFCCON1 SIFCCON1 //SYSTEM IF COMMAND DATA WRITE CONTROL
#define rSIFCCON2 SIFCCON2
#else //KERNEL
#define rGPCCON S3C2410_GPCCON
#define rGPCDAT S3C2410_GPCDAT
#define rGPDCON S3C2410_GPDCON
#define rGPDDAT S3C2410_GPDDAT
#define rGPCUDP S3C2410_GPCUP
#define rGPDUDP S3C2410_GPDUP
#define rGPLDAT S3C2410_GPLDAT
#define rGPLCON S3C2410_GPLCON
#define rGPLUDP S3C2410_GPLUP
#define rGPBCON S3C2410_GPBCON
#define rGPBDAT S3C2410_GPBDAT
#define rGPBUDP S3C2410_GPBUP
#define rGPGCON S3C2410_GPGCON
#define rGPGDAT S3C2410_GPGDAT
#define rGPECON S3C2410_GPECON
#define rGPEDAT S3C2410_GPEDAT
#define rGPFCON S3C2410_GPFCON
#define rGPFDAT S3C2410_GPFDAT
#define rTCFG0 S3C2410_TCFG0 //Configures the two 8-bit presclers
#define rTCFG1 S3C2410_TCFG1 //5-MUX & DMA mode selecton
#define rTCNTB3 S3C2410_TCNTB(3) //Timer 3 count buffer
#define rTCMPB3 S3C2410_TCMPB(3) //Timer 3 compare buffer
#define rTCON S3C2410_TCON //Timer control
#define rVIDCON0 S3C_VIDCON0 //VIDEO CONTROL REGTISTER 0
#define rSYSIFCON0 S3C_SYSIFCON0 //SYSTEM INTERFACE MAIN LDI
#define rSYSIFCON1 S3C_SYSIFCON1 //SYSTEM INTERFACE SUB LDI
#define rSIFCCON0 S3C_SIFCCON0 //SYSTEM INTERFACE COMMAND CONTROL
#define rSIFCCON1 S3C_SIFCCON1 //SYSTEM IF COMMAND DATA WRITE CONTROL
#define rSIFCCON2 S3C_SIFCCON2
#endif
#define VIDCON0_S_CPU_IF_MAIN (2<<22)
#define VIDCON0_S_RGB_PAR (0<<13)
#define VIDCON0_S_VCLK_GATING_OFF (1<<5)
#define VIDCON0_S_CLKDIR_DIVIDED (1<<4)
#define VIDCON0_S_CLKSEL_HCLK (0<<2)
#define VIDCON0_CLKVAL_F_SHIFT (6)
#define VIDCON0_ENVID_ENABLE (1<<1)
#define VIDCON0_ENVID_F_ENABLE (1<<0)
#define SYS_WR_CON (1<<6)
#define SYS_OE_CON (1<<7)
#define rWTCON S3C2410_WTCON //Watch-dog timer mode
#define rWTDAT S3C2410_WTDAT //Watch-dog timer data
#define rWTCNT S3C2410_WTCNT //Watch-dog timer count
#define LCD_DELAY_1MS 18000
#define BUSY_WAIT_TIMEOUT (40*5) //panel time out = 1s
//#ifdef EPAPER_BOOT_CODE
#define PROGRESS_BAR_X (301)
#define PROGRESS_BAR_Y (100)
#define PROGRESS_BAR_W 60
#define PROGRESS_BAR_H 400
#define PROGRESS_BAR_FRAME_LINE_W 8
//#endif
//Global var
/* BAN 20090408 update for WE freq*/
static int delayLoopCount =150;//2M
/* BAN 20090408 update for WE freq*/
//Ivan start
static int partial_update_mode = PARTIAL_DSP_MODE_0;
static int h_resolution = 800;
static int v_resolution = 600;
static int gRotateDegree = 0;
//Ivan end
#ifdef EPAPER_BOOT_CODE
//extern unsigned short Loading_Data[];
#else
extern unsigned short shutdown[];
EXPORT_SYMBOL(Epaper_Shutdown_Logo);
EXPORT_SYMBOL(Epaper_Get_Partial_Update_Mode);
EXPORT_SYMBOL(Epaper_Power);
EXPORT_SYMBOL(Epaper_Draw_Point);
#endif
/*
1. loops = 1 --> 25ns
2. loops = 75 --> 1 us
3. loops = 100000 --> 1ms
*/
static inline void nDelay(unsigned long loops) //in ns
{
int i;
__asm__ volatile ("1:\n" "subs %0, %1, #1\n" "bne 1b":"=r" (loops):"0"(loops));
}
static void __mDelay(unsigned long mTime)
{
unsigned long cnt=0;
for(cnt=0;cnt<mTime;cnt++)
nDelay(100000);
}
static void __uDelay(unsigned long uTime)
{
unsigned long cnt=0;
for(cnt=0;cnt<uTime;cnt++)
nDelay(75);
}
#ifdef EPAPER_BOOT_CODE
void Epaper_Show_Progress(int percent)
{
T_DISPLAY_FRAME stDisFrame;
int i;
unsigned short progress_bar[PROGRESS_BAR_W*PROGRESS_BAR_H/4];
int line_bytes = PROGRESS_BAR_W/4*2;
memset((unsigned char*)progress_bar, 0xff, PROGRESS_BAR_W*PROGRESS_BAR_H/4*2);
//draw top frame line, line width = 8
memset((unsigned char*)progress_bar, 0x0, PROGRESS_BAR_FRAME_LINE_W*line_bytes);
//draw right frame line, line width = 8
for(i=0;i<PROGRESS_BAR_H;i++)
{
memset(((unsigned char*)progress_bar)+((PROGRESS_BAR_W-PROGRESS_BAR_FRAME_LINE_W)/4*2)+(i*line_bytes), 0x0, PROGRESS_BAR_FRAME_LINE_W/4*2);
}
//draw left frame line, line width = 8
for(i=0;i<PROGRESS_BAR_H;i++)
{
memset(((unsigned char*)progress_bar)+(i*line_bytes), 0x0, PROGRESS_BAR_FRAME_LINE_W/4*2);
}
//draw bottom frame line, line width = 8
memset((unsigned char*)progress_bar+(PROGRESS_BAR_H-PROGRESS_BAR_FRAME_LINE_W)*line_bytes, 0x0, PROGRESS_BAR_FRAME_LINE_W*line_bytes);
//draw percent
memset((unsigned char*)progress_bar+(PROGRESS_BAR_H-(PROGRESS_BAR_H/100*percent))*line_bytes, 0x0, (PROGRESS_BAR_H/100*percent)*line_bytes);
//send data
partial_update_mode = 1;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
stDisFrame.tFrameRange.X = PROGRESS_BAR_X;
stDisFrame.tFrameRange.Y = PROGRESS_BAR_Y;
stDisFrame.tFrameRange.W = PROGRESS_BAR_W;
stDisFrame.tFrameRange.H = PROGRESS_BAR_H;
stDisFrame.pFrameData = progress_bar;
if(is_Epaper_Write_Ready())
{
DPRINTK("\nEpaper Progress %d",percent);
Epaper_Disp(stDisFrame);
}
}
void Epaper_Clean_Panel(void)
{
//unsigned short clean_frame[h_resolution*v_resolution/4];
unsigned short clean_frame[AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/4];
T_DISPLAY_FRAME stDisFrame;
partial_update_mode = 0;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
stDisFrame.tFrameRange.X = 1;
stDisFrame.tFrameRange.Y = 1;
stDisFrame.tFrameRange.W = AUO_EPAPER_PHYSICAL_H_RESOLUTION;
stDisFrame.tFrameRange.H = AUO_EPAPER_PHYSICAL_V_RESOLUTION;
memset((unsigned char*)clean_frame, 0xff, AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/4*2);
stDisFrame.pFrameData = clean_frame;
if(is_Epaper_Write_Ready())
{
DPRINTK("\nEpaper clean panel");
Epaper_Disp(stDisFrame);
}
}
#else //KERNEL
void Epaper_Show_Progress(int percent)
{
T_DISPLAY_FRAME stDisFrame;
int i;
static unsigned short progress_bar[PROGRESS_BAR_W*PROGRESS_BAR_H/4];
int line_bytes = PROGRESS_BAR_W/4*2;
memset((unsigned char*)progress_bar, 0xff, PROGRESS_BAR_W*PROGRESS_BAR_H/4*2);
//draw top frame line, line width = 8
memset((unsigned char*)progress_bar, 0x0, PROGRESS_BAR_FRAME_LINE_W*line_bytes);
//draw right frame line, line width = 8
for(i=0;i<PROGRESS_BAR_H;i++)
{
memset(((unsigned char*)progress_bar)+((PROGRESS_BAR_W-PROGRESS_BAR_FRAME_LINE_W)/4*2)+(i*line_bytes), 0x0, PROGRESS_BAR_FRAME_LINE_W/4*2);
}
//draw left frame line, line width = 8
for(i=0;i<PROGRESS_BAR_H;i++)
{
memset(((unsigned char*)progress_bar)+(i*line_bytes), 0x0, PROGRESS_BAR_FRAME_LINE_W/4*2);
}
//draw bottom frame line, line width = 8
memset((unsigned char*)progress_bar+(PROGRESS_BAR_H-PROGRESS_BAR_FRAME_LINE_W)*line_bytes, 0x0, PROGRESS_BAR_FRAME_LINE_W*line_bytes);
//draw percent
memset((unsigned char*)progress_bar+(PROGRESS_BAR_H-(PROGRESS_BAR_H/100*percent))*line_bytes, 0x0, (PROGRESS_BAR_H/100*percent)*line_bytes);
//send data
partial_update_mode = 1;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
stDisFrame.tFrameRange.X = PROGRESS_BAR_X;
stDisFrame.tFrameRange.Y = PROGRESS_BAR_Y;
stDisFrame.tFrameRange.W = PROGRESS_BAR_W;
stDisFrame.tFrameRange.H = PROGRESS_BAR_H;
stDisFrame.pFrameData = progress_bar;
if(is_Epaper_Write_Ready())
{
DPRINTK("\nEpaper Progress %d",percent);
Epaper_Disp(stDisFrame);
}
}
void Epaper_Clean_Panel(void)
{
//unsigned short clean_frame[h_resolution*v_resolution/4];
static unsigned short clean_frame[AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/4];
T_DISPLAY_FRAME stDisFrame;
partial_update_mode = 0;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
stDisFrame.tFrameRange.X = 1;
stDisFrame.tFrameRange.Y = 1;
stDisFrame.tFrameRange.W = AUO_EPAPER_PHYSICAL_H_RESOLUTION;
stDisFrame.tFrameRange.H = AUO_EPAPER_PHYSICAL_V_RESOLUTION;
memset((unsigned char*)clean_frame, 0xff, AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/4*2);
stDisFrame.pFrameData = clean_frame;
if(is_Epaper_Write_Ready())
{
DPRINTK("\nEpaper clean panel");
Epaper_Disp(stDisFrame);
}
}
void Epaper_Shutdown_Logo(void)
{
#if 0
T_DISPLAY_FRAME stDisFrame;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
partial_update_mode = 0;
stDisFrame.tFrameRange.X = 1;
stDisFrame.tFrameRange.Y = 1;
stDisFrame.tFrameRange.W = h_resolution;
stDisFrame.tFrameRange.H = v_resolution;
stDisFrame.pFrameData = shutdown;
if(is_Epaper_Write_Ready())
{
printk("\nEpaper shutdown logo");
Epaper_Disp(stDisFrame);
}
#else
static unsigned short clean_frame[AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/4];
//static unsigned short clean_frame[1024*768/4];
T_DISPLAY_FRAME stDisFrame;
partial_update_mode = 0;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
stDisFrame.tFrameRange.X = 1;
stDisFrame.tFrameRange.Y = 1;
stDisFrame.tFrameRange.W = AUO_EPAPER_PHYSICAL_H_RESOLUTION;
stDisFrame.tFrameRange.H = AUO_EPAPER_PHYSICAL_V_RESOLUTION;
memset((unsigned char*)clean_frame, 0x00, AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/4*2);
stDisFrame.pFrameData = clean_frame;
if(is_Epaper_Write_Ready())
{
DPRINTK("\nEpaper clean panel");
Epaper_Disp(stDisFrame);
}
#endif
}
void Epaper_Draw_Point(int x, int y)
{
unsigned short pint_data[4*4/4];
T_DISPLAY_FRAME stDisFrame;
if( ((x/2)*2) == x)
return;
stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
partial_update_mode = 4;
stDisFrame.tFrameRange.X = x;
stDisFrame.tFrameRange.Y = y;
stDisFrame.tFrameRange.W = 4;
stDisFrame.tFrameRange.H = 4;
stDisFrame.pFrameData = pint_data;
if(is_Epaper_Write_Ready())
{
Epaper_Disp(stDisFrame);
}
}
#endif //EPAPER_BOOT_CODE
void Epaper_Set_Resolution(int h_res, int v_res)
{
h_resolution = h_res;
v_resolution = v_res;
}
int is_Epaper_Write_Ready_No_Wait(void)
{
unsigned long tmp;
int iBusyCnt=0;
#if defined(CONFIG_QISDA_E600_EVT0)
tmp = __raw_readl(rGPGDAT);
if((tmp & (1<<5))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
return 0;
}
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
tmp = __raw_readl(rGPLDAT);
if((tmp & (1<<13))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
return 0;
}
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp = __raw_readl(rGPBDAT);
if((tmp & (1<<2))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
return 0;
}
#endif
return 1;
}
int is_Epaper_Write_Ready(void)
{
unsigned long tmp;
int iBusyCnt=0;
int i=0;
#if defined(CONFIG_QISDA_E600_EVT0)
tmp = __raw_readl(rGPGDAT);
while((tmp & (1<<5))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
//msleep(100);
for(i=0; i<20; i++)
__mDelay(1);
iBusyCnt ++;
if(iBusyCnt>= BUSY_WAIT_TIMEOUT)
{
DPRINTK("<= BAN =>Panel Disp Fail: BUSY time out\n");
return 0;
}
tmp = __raw_readl(rGPGDAT);
}
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
tmp = __raw_readl(rGPLDAT);
while((tmp & (1<<13))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
//msleep(100);
for(i=0; i<20; i++)
__mDelay(1);
iBusyCnt ++;
if(iBusyCnt>= BUSY_WAIT_TIMEOUT)
{
DPRINTK("<= BAN =>Panel Disp Fail: BUSY time out\n");
return 0;
}
tmp = __raw_readl(rGPLDAT);
}
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp = __raw_readl(rGPBDAT);
while((tmp & (1<<2))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
//msleep(100);
for(i=0; i<20; i++)
__mDelay(1);
iBusyCnt ++;
if(iBusyCnt>= BUSY_WAIT_TIMEOUT)
{
DPRINTK("<= BAN =>Panel Disp Fail: BUSY time out\n");
return 0;
}
tmp = __raw_readl(rGPBDAT);
}
#endif
return 1;
}
int is_Epaper_Write_Ready_Wait(unsigned long waitTime) //ms
{
unsigned long tmp;
int iBusyCnt=0;
int i=0;
#if defined(CONFIG_QISDA_E600_EVT0)
tmp = __raw_readl(rGPGDAT);
while((tmp & (1<<5))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
//msleep(100);
for(i=0; i<20; i++)
__mDelay(1);
iBusyCnt ++;
if(iBusyCnt>= (waitTime/20))
{
DPRINTK("<= BAN =>Panel Disp Fail: BUSY time out\n");
return 0;
}
tmp = __raw_readl(rGPGDAT);
}
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
tmp = __raw_readl(rGPLDAT);
while((tmp & (1<<13))==0)
{
DPRINTK("<= BAN =>panel is BUSY\n");
//msleep(100);
for(i=0; i<20; i++)
__mDelay(1);
iBusyCnt ++;
if(iBusyCnt>= (waitTime/20))
{
DPRINTK("<= BAN =>Panel Disp Fail: BUSY time out\n");
return 0;
}
tmp = __raw_readl(rGPLDAT);
}
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp = __raw_readl(rGPBDAT);
while((tmp & (1<<2))==0)
{
//DPRINTK("<= BAN =>panel is BUSY\n");
//msleep(100);
for(i=0; i<20; i++)
__mDelay(1);
iBusyCnt ++;
if(iBusyCnt>= (waitTime/20))
{
DPRINTK("<= BAN =>Panel Disp Fail: BUSY time out\n");
return 0;
}
tmp = __raw_readl(rGPBDAT);
}
#endif
return 1;
}
static inline void s3c2416_i80_write(int data)
{
int tmp;
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
__raw_writel(data, rSIFCCON1); //rSIFCCON1 = CMD;
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
}
static inline void s3c2416_i80_write_Rotate(int data)
{
int tmp;
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
//__uDelay(1);
nDelay(25); //down to 1.5M
__raw_writel(data, rSIFCCON1); //rSIFCCON1 = CMD;
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
}
static inline void s3c2416_i80_write_HandWriting(int data)
{
int tmp;
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
nDelay(15); //down to 2M
__raw_writel(data, rSIFCCON1); //rSIFCCON1 = CMD;
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
}
static inline void s3c2416_i80_write_Rotate_HandWriting(int data)
{
int tmp;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
__raw_writel(data, rSIFCCON1); //rSIFCCON1 = CMD;
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
}
static inline void s3c2416_i80_write_LUT(int data)
{
int tmp;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
__raw_writel(data, rSIFCCON1); //rSIFCCON1 = CMD;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~SYS_WR_CON;
__raw_writel(tmp, rSIFCCON0);
}
static inline void s3c2416_i80_read(unsigned short* data)
{
int tmp;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nRD enable
tmp |= SYS_OE_CON;
__raw_writel(tmp, rSIFCCON0);
//__mDelay(1); //Ivan : must do
__uDelay(1);
*data = __raw_readl(rSIFCCON2); //CMD = rSIFCCON2;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nRD disable
tmp &= ~SYS_OE_CON;
__raw_writel(tmp, rSIFCCON0);
}
static int DISP_CMD_OUT(unsigned short CMD, unsigned short* pdata, int data_length)
{
unsigned long tmp;
unsigned long cnt;
int ret = 0;
tmp = __raw_readl(rSYSIFCON0); //polarity of RS, set 1 for normal access
tmp |= (1<<2);
__raw_writel(tmp, rSYSIFCON0);
tmp = __raw_readl(rSIFCCON0); // command mode enable
tmp |= (1<<0);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) enable
tmp |= (1<<8);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS low
tmp &= ~(1<<1);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= (1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
__raw_writel(CMD, rSIFCCON1); //rSIFCCON1 = CMD;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~(1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
if(data_length > 0)
{
switch(CMD)
{
case AUO_EPAPER_CMD_INIT:
{
s3c2416_i80_write(*pdata);
break;
}
case AUO_EPAPER_CMD_LUT_START:
{
for(cnt=0;cnt<data_length;cnt++)
{
__uDelay(1);
if(is_Epaper_Write_Ready_Wait(10000))
{
__uDelay(1);
s3c2416_i80_write_LUT((unsigned short)pdata[cnt]);
}
else
{
DPRINTK("EPD: Can not send LUT data\n");
ret = -1;
goto DISP_CMD_OUT_ERROR;
}
}
if(is_Epaper_Write_Ready())
{
tmp = __raw_readl(rSIFCCON0); //rSIFCCON0 &= ~(1<<1); // RS low
tmp &= ~(1<<1); // RS low
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
s3c2416_i80_write(AUO_EPAPER_CMD_LUT_STOP);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
}
else
{
DPRINTK("EPD: Can not send AUO_EPAPER_CMD_LUT_STOP\n");
ret = -1;
goto DISP_CMD_OUT_ERROR;
}
break;
}
default:
DPRINTK("unkonwn command\n");
break;
}
}
DISP_CMD_OUT_ERROR:
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) disable
tmp &= ~(1<<8);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // command mode disable
tmp &= ~(1<<0);
__raw_writel(tmp, rSIFCCON0);
}
//Send 1 command and read parameters
static void DISP_DATA_IN(unsigned short CMD, unsigned short* val_array, int val_count)
{
unsigned long tmp;
int cnt;
tmp = __raw_readl(rSYSIFCON0); //polarity of RS, set 1 for normal access
tmp |= (1<<2);
__raw_writel(tmp, rSYSIFCON0);
tmp = __raw_readl(rSIFCCON0); // command mode enable
tmp |= (1<<0);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) enable
tmp |= (1<<8);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS low
tmp &= ~(1<<1);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= (1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
__raw_writel(CMD, rSIFCCON1); //rSIFCCON1 = CMD;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~(1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
switch(CMD)
{
case AUO_EPAPER_CMD_TEMPER:
{
for(cnt=0;cnt<val_count;cnt++)
{
__mDelay(1);
s3c2416_i80_read(&val_array[cnt]);
}
break;
}
case AUO_EPAPER_CMD_LUT_READ:
{
DPRINTK("\nLUT Read");
for(cnt=0;cnt<val_count;cnt++)
{
if(is_Epaper_Write_Ready())
{
s3c2416_i80_read(&val_array[cnt]);
}
}
if(is_Epaper_Write_Ready())
{
tmp = __raw_readl(rSIFCCON0); //rSIFCCON0 &= ~(1<<1); // RS low
tmp &= ~(1<<1); // RS low
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
s3c2416_i80_write(AUO_EPAPER_CMD_LUT_STOP);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
}
break;
}
default:
DPRINTK("unkonwn command\n");
break;
}
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) disable
tmp &= ~(1<<8);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // command mode disable
tmp &= ~(1<<0);
__raw_writel(tmp, rSIFCCON0);
}
static void DISP_DATA_OUT(unsigned short CMD, unsigned short* pdata, T_DISPLAY_REGION REGION)
{
unsigned long tmp;
unsigned long cnt;
tmp = __raw_readl(rSYSIFCON0); //polarity of RS, set 1 for normal access
tmp |= (1<<2);
__raw_writel(tmp, rSYSIFCON0);
tmp = __raw_readl(rSIFCCON0); // command mode enable
tmp |= (1<<0);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) enable
tmp |= (1<<8);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS low
tmp &= ~(1<<1);
__raw_writel(tmp, rSIFCCON0);
//check busy again
if((!is_Epaper_Write_Ready_No_Wait())&&((partial_update_mode == PARTIAL_DSP_MODE_4)||(partial_update_mode == PARTIAL_DSP_MODE_4_W)))
{
if(!is_Epaper_Write_Ready())
{
//busy
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) disable
tmp &= ~(1<<8);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // command mode disable
tmp &= ~(1<<0);
__raw_writel(tmp, rSIFCCON0);
DPRINTK("ERROR, Still BUSY");
return;
}
}
//end
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE enable
tmp |= (1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
__raw_writel(CMD, rSIFCCON1); //rSIFCCON1 = CMD;
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nWE disable
tmp &= ~(1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
/* BAN 20090406 + for test panel*/
switch(CMD)
{
case AUO_EPAPER_CMD_FULLDISP:
{
break;
}
case AUO_EPAPER_CMD_PARTIALDISP:
{
unsigned short current_mode=0;
DPRINTK("<= BAN =>AUO_EPAPER_CMD_PARTIALDISP, region=(%d(%d,%d) %d X %d)\n",partial_update_mode, REGION.X,REGION.Y,REGION.W,REGION.H);
__uDelay(1);
//MOD + X
current_mode = ((unsigned short)partial_update_mode )<<12;
/*if(partial_update_mode == PARTIAL_DSP_MODE_4)
current_mode |= 0x8000; //Set "Write"*/
s3c2416_i80_write(current_mode|REGION.X);
//Y
s3c2416_i80_write(REGION.Y);
//W
s3c2416_i80_write(REGION.W);
//H
s3c2416_i80_write(REGION.H);
if((partial_update_mode == PARTIAL_DSP_MODE_4)||(partial_update_mode == PARTIAL_DSP_MODE_4_W))
{
if(gRotateDegree!=0)
{
DPRINTK("\nHand writing + Rotate");
for(cnt=0; cnt<(REGION.W*REGION.H/4); cnt++)
{
s3c2416_i80_write_Rotate_HandWriting((unsigned short)pdata[cnt]); //rSIFCCON1 = CMD;
}
}
else
{
DPRINTK("\nHand writing");
for(cnt=0; cnt<(REGION.W*REGION.H/4); cnt++)
{
s3c2416_i80_write_HandWriting((unsigned short)pdata[cnt]); //rSIFCCON1 = CMD;
}
}
}
else if(gRotateDegree!=0)
{
DPRINTK("\nRotate");
for(cnt=0; cnt<(REGION.W*REGION.H/4); cnt++)
{
s3c2416_i80_write_Rotate((unsigned short)pdata[cnt]); //rSIFCCON1 = CMD;
}
}
else
{
DPRINTK("\nnormal");
for(cnt=0; cnt<(REGION.W*REGION.H/4); cnt++)
{
s3c2416_i80_write((unsigned short)pdata[cnt]); //rSIFCCON1 = CMD;
}
}
break;
}
case AUO_EPAPER_CMD_STOP:
break;
default:
DPRINTK("unkonwn command\n");
break;
}
/* BAN 20090406 + for test panel*/
// STOP
tmp = __raw_readl(rSIFCCON0); //rSIFCCON0 &= ~(1<<1); // RS low
tmp &= ~(1<<1); // RS low
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
s3c2416_i80_write(AUO_EPAPER_CMD_STOP);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // RS Hi
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) disable
tmp &= ~(1<<8);
__raw_writel(tmp, rSIFCCON0);
tmp = __raw_readl(rSIFCCON0); // command mode disable
tmp &= ~(1<<0);
__raw_writel(tmp, rSIFCCON0);
}
void Epaper_SetLcdPort(void)
{
unsigned long tmp;
DPRINTK("I80 Init \n");
// set gpio for lcd
tmp =__raw_readl(rGPCCON);
//tmp = (tmp & ~(0xffff03ff))|(0xaaaa02aa);
tmp = (tmp & ~(0xffff033f))|(0xaaaa022a); //Do not config SYS_CS1(GPC3)
__raw_writel(tmp, rGPCCON);
#if defined(CONFIG_QISDA_E600_EVT0)
DPRINTK("\nCONFIG_QISDA_E600_EVT0\n");
__raw_writel(0xaaaaaaaa, rGPDCON);
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1) || defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
DPRINTK("\nCONFIG_QISDA_E600_EVT2 || CONFIG_QISDA_E600_DVT1 || CONFIG_QISDA_AS090B00_EVT1 || CONFIG_QISDA_AS090B00_EVT1_1 || CONFIG_QISDA_QD060N00_DVT1_1 || CONFIG_QISDA_QD090B00_EVT1\n");
tmp =__raw_readl(rGPDCON); //tmp=0x40000
tmp = (tmp & ~(0x0CFFFF))|(0x04AAAA);
__raw_writel(tmp, rGPDCON); // GPD9 is RST_N
#endif
__raw_writel(0, rGPCUDP); //rGPCUDP = 0;
__raw_writel(0, rGPDUDP); //rGPDUDP = 0;
#if 1
{
tmp = __raw_readl(rVIDCON0); //rVIDCON0 = rVIDCON0 & ~(0x3<<22) | (0x2<<22);
tmp = (tmp & ~(0x3<<22)) | (0x2<<22) | (0x30 <<VIDCON0_CLKVAL_F_SHIFT);
__raw_writel(tmp, rVIDCON0);
}
#endif
// POWER pin config
tmp =__raw_readl(rGPBCON);
tmp = (tmp & ~(3<<6))|(1<<6);
__raw_writel(tmp, rGPBCON);
// RESET pin config
#if defined(CONFIG_QISDA_E600_EVT0)
tmp =__raw_readl(rGPFCON);
tmp = (tmp & ~(3<<10))|(1<<10);
__raw_writel(tmp, rGPFCON);
#endif
// BUSY pin config
#if defined(CONFIG_QISDA_E600_EVT0)
tmp =__raw_readl(rGPGCON);
tmp = tmp & ~(3<<10);
__raw_writel(tmp, rGPGCON);
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
tmp =__raw_readl(rGPLCON);
tmp = tmp & ~(3<<26);
__raw_writel(tmp, rGPLCON);
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp =__raw_readl(rGPBCON);
tmp = (tmp & ~(3<<4));
__raw_writel(tmp, rGPBCON);
#endif
/*
tmp =__raw_readl(rGPBUDP);
tmp = (tmp & ~(3<<4));
//tmp = 0;
__raw_writel(tmp, rGPBUDP);*/
// SLEEP pin config
#if defined(CONFIG_QISDA_E600_EVT0) || defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
tmp =__raw_readl(rGPECON);
tmp = (tmp & ~(3<<22))|(1<<22);
__raw_writel(tmp, rGPECON);
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp =__raw_readl(rGPBCON);
tmp = (tmp & ~(3<<2))|(1<<2);
__raw_writel(tmp, rGPBCON);
#endif
__mDelay(1);
//SLEEP Pin High
#if defined(CONFIG_QISDA_E600_EVT0) || defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
//can not set high or it system will reset...
tmp =__raw_readl(rGPEDAT);
tmp |= (1<<11);
__raw_writel(tmp, rGPEDAT);
//udelay(1000);
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
/* tmp = __raw_readl(rGPBDAT);
tmp |= (1<<1);
__raw_writel(tmp, rGPBDAT);
udelay(1000);*/
#endif
// Panel power on
tmp = __raw_readl(rGPBDAT);
tmp |= (1<<3);
#if defined(CONFIG_QISDA_E600_EVT0) || defined(CONFIG_QISDA_E600_EVT2)
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
//SLP_N high
tmp |= (1<<1);
#endif
__raw_writel(tmp, rGPBDAT);
__mDelay(100);
// LCD module reset
#if defined(CONFIG_QISDA_E600_EVT0)
tmp = __raw_readl(rGPFDAT);
tmp |= (1<<5);
__raw_writel(tmp, rGPFDAT);
tmp = __raw_readl(rGPFDAT); // goes to LOW
tmp &= ~(1<<5);
__raw_writel(tmp, rGPFDAT);
__mDelay(5);
tmp = __raw_readl(rGPFDAT); // goes to HIGH
tmp |= (1<<5);
__raw_writel(tmp, rGPFDAT);
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1) || defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp = __raw_readl(rGPDDAT);
tmp |= (1<<9);
__raw_writel(tmp, rGPDDAT);
tmp = __raw_readl(rGPDDAT); // goes to LOW
tmp &= ~(1<<9);
__raw_writel(tmp, rGPDDAT);
__uDelay(5);
tmp = __raw_readl(rGPDDAT); // goes to HIGH
tmp |= (1<<9);
__raw_writel(tmp, rGPDDAT);
#endif
// delay about 10ms
__mDelay(10);
}
void EPaper_CloseLcdPort(void)
{
unsigned long tmp;
//gpc0 input
s3c2410_gpio_pullup(S3C2410_GPC0,1);
s3c2410_gpio_cfgpin(S3C2410_GPC0, S3C2410_GPC0_INP);
//gpc1 input
s3c2410_gpio_pullup(S3C2410_GPC1,1);
s3c2410_gpio_cfgpin(S3C2410_GPC1, S3C2410_GPC1_INP);
//gpc2 input
s3c2410_gpio_pullup(S3C2410_GPC2,1);
s3c2410_gpio_cfgpin(S3C2410_GPC2, S3C2410_GPC2_INP);
//gpc4 input
s3c2410_gpio_pullup(S3C2410_GPC4,1);
s3c2410_gpio_cfgpin(S3C2410_GPC4, S3C2410_GPC4_INP);
//gpc8 input
s3c2410_gpio_pullup(S3C2410_GPC8,1);
s3c2410_gpio_cfgpin(S3C2410_GPC8, S3C2410_GPC8_INP);
//gpc9 input
s3c2410_gpio_pullup(S3C2410_GPC9,1);
s3c2410_gpio_cfgpin(S3C2410_GPC9, S3C2410_GPC9_INP);
//gpc10 input
s3c2410_gpio_pullup(S3C2410_GPC10,1);
s3c2410_gpio_cfgpin(S3C2410_GPC10, S3C2410_GPC10_INP);
//gpc11 input
s3c2410_gpio_pullup(S3C2410_GPC11,1);
s3c2410_gpio_cfgpin(S3C2410_GPC11, S3C2410_GPC11_INP);
//gpc12 input
s3c2410_gpio_pullup(S3C2410_GPC12,1);
s3c2410_gpio_cfgpin(S3C2410_GPC12, S3C2410_GPC12_INP);
//gpc13 input
s3c2410_gpio_pullup(S3C2410_GPC13,1);
s3c2410_gpio_cfgpin(S3C2410_GPC13, S3C2410_GPC13_INP);
//gpc14 input
s3c2410_gpio_pullup(S3C2410_GPC14,1);
s3c2410_gpio_cfgpin(S3C2410_GPC14, S3C2410_GPC14_INP);
//gpc15 input
s3c2410_gpio_pullup(S3C2410_GPC15,1);
s3c2410_gpio_cfgpin(S3C2410_GPC15, S3C2410_GPC15_INP);
#if defined(CONFIG_QISDA_E600_EVT0)
//Old HW, do not maintain anymore...
tmp =__raw_readl(rGPDCON);
__raw_writel(0xaaaaaaaa, rGPDCON); //Set GPD to GPIO output
__raw_writel(0x0, rGPDDAT); //GPD goes to LOW
tmp = __raw_readl(rGPFDAT); //reset pin goes to LOW
tmp &= ~(1<<5);
__raw_writel(tmp, rGPFDAT);
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1) || defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
//gpd0 input
s3c2410_gpio_pullup(S3C2410_GPD0,1);
s3c2410_gpio_cfgpin(S3C2410_GPD0, S3C2410_GPD0_INP);
//gpd1 input
s3c2410_gpio_pullup(S3C2410_GPD1,1);
s3c2410_gpio_cfgpin(S3C2410_GPD1, S3C2410_GPD1_INP);
//gpd2 input
s3c2410_gpio_pullup(S3C2410_GPD2,1);
s3c2410_gpio_cfgpin(S3C2410_GPD2, S3C2410_GPD2_INP);
//gpd3 input
s3c2410_gpio_pullup(S3C2410_GPD3,1);
s3c2410_gpio_cfgpin(S3C2410_GPD3, S3C2410_GPD3_INP);
//gpd4 input
s3c2410_gpio_pullup(S3C2410_GPD4,1);
s3c2410_gpio_cfgpin(S3C2410_GPD4, S3C2410_GPD4_INP);
//gpd5 input
s3c2410_gpio_pullup(S3C2410_GPD5,1);
s3c2410_gpio_cfgpin(S3C2410_GPD5, S3C2410_GPD5_INP);
//gpd6 input
s3c2410_gpio_pullup(S3C2410_GPD6,1);
s3c2410_gpio_cfgpin(S3C2410_GPD6, S3C2410_GPD6_INP);
//gpd7 input
s3c2410_gpio_pullup(S3C2410_GPD7,1);
s3c2410_gpio_cfgpin(S3C2410_GPD7, S3C2410_GPD7_INP);
//gpd9 output
s3c2410_gpio_pullup(S3C2410_GPD9,1);
s3c2410_gpio_cfgpin(S3C2410_GPD9, S3C2410_GPD9_OUTP);
s3c2410_gpio_setpin(S3C2410_GPD9,0);
//gpb1 input
s3c2410_gpio_pullup(S3C2410_GPB1,1);
s3c2410_gpio_cfgpin(S3C2410_GPB1, S3C2410_GPB1_INP);
//gpb2 input
s3c2410_gpio_pullup(S3C2410_GPB2,1);
s3c2410_gpio_cfgpin(S3C2410_GPB2, S3C2410_GPB2_INP);
//gpb3 output
s3c2410_gpio_pullup(S3C2410_GPB3,1);
s3c2410_gpio_cfgpin(S3C2410_GPB3, S3C2410_GPB3_OUTP);
s3c2410_gpio_setpin(S3C2410_GPB3,0);
/*tmp = __raw_readl(rGPCDAT);
DPRINTK("\nGPC=0x%x", tmp);
tmp = __raw_readl(rGPDDAT);
DPRINTK("\nGPD=0x%x", tmp);*/
#endif
#if 0
tmp =__raw_readl(rGPCCON);
//tmp = (tmp & ~(0xffff03ff))|(0x55550155); //Set GPC to GPIO output
tmp = (tmp & ~(0xffff033f))|(0x55550115); //Set GPC to GPIO output, do not config GPC3
__raw_writel(tmp, rGPCCON);
tmp = __raw_readl(rGPCDAT); // GPC goes to LOW
//tmp &= ~(0xFF1F);
tmp &= ~(0xFF17); //Do not config GPC3
__raw_writel(tmp, rGPCDAT);
#if defined(CONFIG_QISDA_E600_EVT0)
tmp =__raw_readl(rGPDCON);
__raw_writel(0xaaaaaaaa, rGPDCON); //Set GPD to GPIO output
__raw_writel(0x0, rGPDDAT); //GPD goes to LOW
tmp = __raw_readl(rGPFDAT); //reset pin goes to LOW
tmp &= ~(1<<5);
__raw_writel(tmp, rGPFDAT);
#elif defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1) || defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp =__raw_readl(rGPDCON);
tmp = (tmp & ~(0x0CFFFF))|(0x045555); //Set GPD to GPIO output
__raw_writel(tmp, rGPDCON);
tmp = __raw_readl(rGPDDAT); // GPD goes to LOW
tmp &= ~(0x2FF);
__raw_writel(tmp, rGPDDAT);
#endif
#endif //#if 0
gRotateDegree = 0;
}
DispErrorCode_t Epaper_Disp(T_DISPLAY_FRAME tFrame)
{
unsigned long tmp;
int iBusyCnt=0;
DPRINTK("<= BAN =>I80 Write\n");
DISP_DATA_OUT(tFrame.u16EpaperCommand,tFrame.pFrameData,tFrame.tFrameRange);
return DISP_SUCCESS;
}
void Epaper_Set_Partial_Update_Mode(int mode)
{
partial_update_mode = mode;
}
int Epaper_Get_Partial_Update_Mode(void)
{
return partial_update_mode;
}
void Epaper_Enter_Standby_Mode(int isEnter)
{
unsigned long tmp;
if(isEnter)
{
//send 0x0001 to T-CON to enter standby mode
DISP_CMD_OUT(AUO_EPAPER_CMD_STANDBY, NULL, 0);
}
else
{
//send 0x0002 to T-CON to leave standby mode
DISP_CMD_OUT(AUO_EPAPER_CMD_WAKEUP, NULL, 0);
}
}
void Epaper_Enter_Sleep_Mode(int isEnter)
{
unsigned long tmp;
if(isEnter)
{
#if defined(CONFIG_QISDA_E600_EVT0) || defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
//Set SLP_N to low to enter sleep mode
tmp = __raw_readl(rGPEDAT);
tmp &= ~(1<<11);
__raw_writel(tmp, rGPEDAT);
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp = __raw_readl(rGPBDAT);
tmp &= ~(1<<1);
__raw_writel(tmp, rGPBDAT);
#endif
}
else
{
#if defined(CONFIG_QISDA_E600_EVT0) || defined(CONFIG_QISDA_E600_EVT2) || defined(CONFIG_QISDA_E600_DVT1)
//Set SLP_N to high to leave sleep mode
tmp = __raw_readl(rGPEDAT);
tmp |= (1<<11);
__raw_writel(tmp, rGPEDAT);
#elif defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00_EVT1)
tmp = __raw_readl(rGPBDAT);
tmp |= (1<<1);
__raw_writel(tmp, rGPBDAT);
#endif
}
}
void Epaper_Power(int isEnable)
{
unsigned long tmp;
if(isEnable)
{
tmp = __raw_readl(rGPBDAT);
tmp |= (1<<3);
__raw_writel(tmp, rGPBDAT);
}
else
{
tmp = __raw_readl(rGPBDAT);
tmp &= ~(1<<3);
__raw_writel(tmp, rGPBDAT);
}
}
void Epaper_Read_R_TEMP(unsigned short* val0, unsigned short* val1, unsigned short* val2, unsigned short* val3)
{
unsigned long tmp;
unsigned short val[4];
memset(val, 0x0, 8);
DISP_DATA_IN(AUO_EPAPER_CMD_TEMPER, val, 4);
*val0 = val[0];
*val1 = val[1];
*val2 = val[2];
*val3 = val[3];
}
void Epaper_Display_Refresh(void)
{
DISP_CMD_OUT(AUO_EPAPER_CMD_REFRESH, NULL, 0);
}
int Epaper_Init(int h_Res, int v_Res, int rotation, int data_inverse, int inputdata_arrangement, int outputdata_arrangement,int UD, int SHL)
{
unsigned short u16InitPara=0;
if(is_Epaper_Write_Ready())
{
h_resolution = h_Res;
v_resolution = v_Res;
//TEMP_AVE_EN
u16InitPara = u16InitPara | (1<<13);
//M23_FILTER
//ROT
gRotateDegree = rotation;
if(rotation == 0)
{
}
else if(rotation == 90)
u16InitPara = u16InitPara | (1<<10);
else if(rotation == 180)
u16InitPara = u16InitPara | (2<<10);
else if(rotation == 270)
u16InitPara = u16InitPara | (3<<10);
else
{
}
//DI
//BN
//CHDA
//RES
if(h_resolution==1024 && v_resolution==768)
u16InitPara = u16InitPara | (1<<2);
else if(h_resolution==800 && v_resolution==600)
{
}
else
{
}
//UD
//SHL
u16InitPara = u16InitPara | 1;
DISP_CMD_OUT(AUO_EPAPER_CMD_INIT, &u16InitPara, 1);
DPRINTK("\nInit size=%d, Init data =0x%x\n", sizeof(unsigned short),u16InitPara);
return 0;
}
return -1;
/*
T_INIT init_Para;
T_DISPLAY_REGION empty_REGION;
if(is_Epaper_Write_Ready())
{
h_resolution = h_Res;
v_resolution = v_Res;
init_Para.u16Reserve1 = 0;
gRotateDegree = rotation;
if(rotation == 0)
init_Para.ROT = 0;
else if(rotation == 90)
init_Para.ROT = 1;
else if(rotation == 180)
init_Para.ROT = 2;
else if(rotation == 270)
init_Para.ROT = 3;
else
init_Para.ROT = 0;
init_Para.DI = 0;
init_Para.BN = 0;
init_Para.CHDA = 0;
if(h_resolution==1024 && v_resolution==768)
init_Para.RES = 1;
else if(h_resolution==800 && v_resolution==600)
init_Para.RES = 0;
else
init_Para.RES = 0;
init_Para.UD = 0;
init_Para.SHL = 1;
DISP_CMD_OUT(AUO_EPAPER_CMD_INIT, &init_Para, 1);
DPRINTK("\nInit data =0x%x", init_Para);
return 0;
}
return -1;
*/
}
//u32LUTLength: length in (unsigned short)
int Epaper_Update_LUT(unsigned short* u16LUT, unsigned long u32LUTLength)
{
unsigned long cnt=0;
if(is_Epaper_Write_Ready_Wait(10000))
{
return DISP_CMD_OUT(AUO_EPAPER_CMD_LUT_START, u16LUT, u32LUTLength);
}
else
return -1;
}
//u32LUTLength: length in (unsigned short)
int Epaper_Read_LUT(unsigned short* u16LUT, unsigned long u32LUTLength)
{
DISP_DATA_IN(AUO_EPAPER_CMD_LUT_READ, u16LUT, u32LUTLength);
}
void Epaper_Reset(void)
{
DISP_CMD_OUT(AUO_EPAPER_CMD_RESET, NULL, 0);
}