linux/cybook.config:

* Use new epaper driver instead of qisda fb driver

linux/arch/arm/mach-s3c2416/orizon-devs.c:
	* Rename old cyio-dev.c

linux/arch/arm/mach-s3c2416/mach-cybook_orizon.c,
linux/arch/arm/mach-s3c2416/orizon-devs.c:
	+ Add support for new drivers in platform device list

linux/drivers/video/Makefile,
linux/drivers/video/Kconfig,
linux/drivers/video/epaper/*:
	+ Add new epaper driver for tcon (resolve #9)

linux/drivers/input/misc/orizon_tilt.c:
	+ Add new driver for the tilt sensor

linux/drivers/char/s3c-adc.c:
	- Remove bloated code (this code must be audited, see ticket #8)

linux/include/cybook.h:
	* Extend the CAPABILITY Field
This commit is contained in:
mlt
2010-04-27 19:56:15 +00:00
committed by Godzil
parent f2fd2aec61
commit a55a73c5d1
14 changed files with 1358 additions and 743 deletions

View File

@@ -1840,5 +1840,7 @@ if FB || SGI_NEWPORT_CONSOLE
source "drivers/video/logo/Kconfig"
endif
source "drivers/video/epaper/Kconfig"
endmenu

View File

@@ -12,6 +12,7 @@ fb-objs := $(fb-y)
obj-$(CONFIG_VT) += console/
obj-$(CONFIG_LOGO) += logo/
obj-$(CONFIG_) += logo/
obj-y += backlight/
obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o
@@ -124,3 +125,5 @@ obj-$(CONFIG_FB_OF) += offb.o
# the test framebuffer is last
obj-$(CONFIG_FB_VIRTUAL) += vfb.o
obj-y += epaper/

View File

@@ -2289,233 +2289,6 @@ static int _dbgFL = 0;
#define INFO(s) do { printk("%s:%s(): ", __FILE__, __func__); printk s; printk("\n"); } while(0)
#endif
static int rotMode = 0;
//#define GET_COMMAND_PARAM_NUM(command) ((command >> 20) & 0x0F)
//#define GET_COMMAND_HAVE_DATA(command) ((command >> 28) & 0x01)
//#define GET_COMMAND_NEED_WAIT(command) ((command >> 29) & 0x01)
/* On the i80 port,
* i80 TCON
* -----------
* RS -> D/C
* CS0 -> CSEL
* nWE -> HWE
* OE -> HRD
*/
static inline void _InitI80Interface(void)
{
unsigned long tmp;
FUNC_IN();
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);
FUNC_OUT();
}
static inline void _DeinitI80Interface(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0); // command mode disable
tmp &= ~(1<<0);
__raw_writel(tmp, rSIFCCON0);
FUNC_OUT();
}
static inline void _SetWriteToData(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0);
// RS high -> D/nC set Data mode
tmp |= (1<<1);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _SetWriteToCommand(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0);
// RS low -> D/nC set Command mode
tmp &= ~(1<<1);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _EnableWrite(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0);
// nWE -> HWE enable
tmp |= (1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _DisableWrite(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0);
// nWE -> HWE disable
tmp &= ~(1<<6);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _EnableRead(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0); // nRD enable
tmp |= SYS_OE_CON;
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _DisableRead(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0); // nRD disable
tmp &= ~SYS_OE_CON;
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _SelectChip(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0); // Chip Select
tmp |= (1<<8);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
static inline void _UnselectChip(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(rSIFCCON0); // nCS0(Main) enable
tmp &= ~(1<<8);
__raw_writel(tmp, rSIFCCON0);
__uDelay(1);
FUNC_OUT();
}
int Epaper_sendCommandStart(sAUOCommand *cmd)
{
FUNC_IN();
INFOL(INFO_VERBOSE,("cmd #%08lX", cmd->cmd));
/* First: verify that the K1900 is ready */
INFOL(INFO_VERBOSE, ("/* First: verify that the K1900 is ready */"));
if (GET_COMMAND_NEED_WAIT(cmd->cmd) != 0x00)
{
INFOL(INFO_VERBOSE, ("Wait for non BUSY..."));
is_Epaper_Write_Ready();
}
if (cmd->cmd == AUOCMD_INIT_SET)
{
rotMode = ~(cmd->params[0]) & (0x1 << 10);
INFOL(INFO_VERBOSE, ("Rotation set to 0x%08X...", rotMode));
}
/* Second: init the i80 interface */
INFOL(INFO_VERBOSE, ("/* Second: init the i80 interface */"));
_InitI80Interface();
/* Third: Select the chip and set to Command mode */
INFOL(INFO_VERBOSE, ("/* Third: Select the chip and set to Command mode */"));
_SelectChip();
_SetWriteToCommand();
/* Fourth: Send command */
INFOL(INFO_VERBOSE, ("/* Fourth: Send command */"));
if (rotMode)
s3c2416_i80_write(cmd->cmd & 0xFFFF); /* This function already manage HWE, */
else
s3c2416_i80_write_Rotate(cmd->cmd & 0xFFFF); /* This function already manage HWE,
* no need to do it here. */
/* Sixth: If parameters is needed, send them */
INFOL(INFO_VERBOSE, ("/* Sixth: If parameters is needed, send them */"));
if (GET_COMMAND_PARAM_NUM(cmd->cmd) > 0)
{
int i, paramNumbers = GET_COMMAND_PARAM_NUM(cmd->cmd);
INFOL(INFO_VERBOSE, ("YES! We have %d parameters", paramNumbers));
_SetWriteToData();
for (i = 0; i < paramNumbers; i++)
{
INFOL(INFO_VERBOSE, (" parameter [%02d] = 0x%04X", i, cmd->params[i]));
if (rotMode)
s3c2416_i80_write(cmd->params[i]);
else
s3c2416_i80_write_Rotate(cmd->params[i]);
}
}
FUNC_OUT();
return 0;
}
int Epaper_sendData(unsigned short *buffer, unsigned long bufferLen)
{
/* Seventh: Send data if needed */
unsigned long i;
FUNC_IN();
//INFOL(INFO_VERBOSE, ("Bufferlen: %ld", bufferLen));
_SetWriteToData();
for (i = 0; i < bufferLen; i++)
{
if (rotMode)
s3c2416_i80_write(buffer[i]);
else
s3c2416_i80_write_Rotate(buffer[i]);
}
FUNC_OUT();
return 0;
}
int Epaper_sendCommandEnd(sAUOCommand *cmd)
{
FUNC_IN();
INFOL(INFO_VERBOSE,("cmd #%08lX START:[#%08lX]", cmd->cmd, AUOCMD_DISPLAY_START));
if (cmd->cmd == AUOCMD_DISPLAY_START)
{
_SetWriteToCommand();
INFOL(INFO_VERBOSE, ("/* Eight: Send STOP command */"));
if (rotMode)
s3c2416_i80_write(AUOCMD_DISPLAY_STOP & 0xFFFF);
else
s3c2416_i80_write_Rotate(AUOCMD_DISPLAY_STOP & 0xFFFF);
_SetWriteToData();
}
INFOL(INFO_VERBOSE, ("/* Nineth: Close all */"));
_UnselectChip();
_DeinitI80Interface();
FUNC_OUT();
return 0;
}
/* [/MTR] */

View File

@@ -0,0 +1,28 @@
#
#
#
menu "ePaper Devices"
config EPAPER_TCON_K1900
bool "Compile AUO TCON K1900 ePaper Driver"
default y
depends on CPU_S3C2416 && MACH_CYBOOK_ORIZON
help
Compile the kernel with support for TCON/SiPix ePaper display
config EPAPER_EPSON_S1D13521
bool "Compile Epson S1D13521 ePaper Driver"
default y
depends on CPU_S3C2440
help
Compile the kernel with support for S1D13521/Eink ePaper display
config EPAPER_PVI_6001A
bool "Compile PVI 6001A ePaper Driver"
default y
depends on CPU_S3C2440
help
Compile the kernel with support for PVI6001A/Eink ePaper display
endmenu

View File

@@ -0,0 +1,3 @@
# Makefile for the ePaper drivers
obj-$(CONFIG_EPAPER_TCON_K1900) += auo-tcon-k1900.o

View File

@@ -0,0 +1,839 @@
/*
* Disclaimer (blabla)
*
* Author: Manoël Trapier <manoelt@bookeen.com>
* Copyright (c) 2003-2010 Bookeen
*
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/miscdevice.h>
#include <linux/poll.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/pm.h>
#include <linux/proc_fs.h>
#include <asm/hardware.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
#include <asm-arm/irq.h>
#include <asm/arch/gpio.h>
#include <asm/arch/regs-gpio.h>
#include <asm/arch/regs-irq.h>
#include <asm/arch/regs-lcd.h>
#include <asm-arm/arch-s3c2410/irqs.h>
#include <asm-arm/arch-s3c2410/gpio.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <asm/io.h>
#include <linux/ioctl.h>
#include <linux/auofb_ioctl.h>
#include <cybook.h>
//#define DEBUG_MESSAGES
//#define DEBUG_TRACEFUNC
#define MODULE_NAME "AUO-TCON"
#define BUSY_WAIT_TIMEOUT (40*5*2) //panel time out = 1s
#define SYS_WR_CON (1<<6)
#define SYS_OE_CON (1<<7)
// ===========================================================================
#undef MSG
#undef DBG
#ifdef DEBUG_MESSAGES
enum InfoLevel
{
INFO_ERROR = 0,
INFO_WARNING,
INFO_NORMAL,
INFO_DEBUG,
INFO_VERBOSE,
};
# ifndef VERBOSE_LEVEL
# define VERBOSE_LEVEL INFO_VERBOSE
# endif
# ifdef DEBUG_TRACEFUNC
static int _dbg_FunctionLevel = 0;
# define MSG(str) {\
int __i;\
printk(KERN_ALERT "+");\
for (__i = 0; __i < _dbg_FunctionLevel; __i++)\
printk("-");\
printk("||" str "\n");\
}
# define DBG(str, ...) {\
int __i;\
printk(KERN_ALERT "+");\
for (__i = 0; __i < _dbg_FunctionLevel; __i++)\
printk("-");\
printk("||" str "\n", __VA_ARGS__);\
}
# define INFOL(level, s) do {\
if (level <= VERBOSE_LEVEL) {\
int __i;\
printk(KERN_ALERT "+");\
for (__i = 0; __i < _dbg_FunctionLevel; __i++)\
printk("-");\
printk("<%d>%s:%s(): ", level, __FILE__, __func__); printk s; printk("\n");\
}\
} while(0)
# define FUNC_IN() {\
int __i;\
_dbg_FunctionLevel++;\
printk(KERN_ALERT "+");\
for (__i = 0; __i < _dbg_FunctionLevel; __i++)\
printk("-");\
printk(">> %s() >>\n", __func__);\
}
# define FUNC_OUT() {\
int __i;\
printk(KERN_ALERT "+");\
for (__i = 0; __i < _dbg_FunctionLevel; __i++)\
printk("-");\
printk("<< %s() <<\n", __func__);\
_dbg_FunctionLevel--;\
}
# define FUNC_OUTR(val) {\
int __i;\
printk(KERN_ALERT "+");\
for (__i = 0; __i < _dbg_FunctionLevel; __i++)\
printk("-");\
printk("<< %s() = %d <<\n", __func__, val);\
_dbg_FunctionLevel--;\
}
# else /* DEBUG_TRACEFUNC */
# define MSG(str) do {\
printk(KERN_ALERT MODULE_NAME ": " str "\n");\
} while(0)
# define DBG(str, ...) do {\
printk(KERN_ALERT MODULE_NAME ": " str "\n", __VA_ARGS__);\
} while(0)
# define FUNC_IN() do {\
} while(0)
# define FUNC_OUT() do {\
} while(0)
# define FUNC_OUTR(val) do {\
printk(KERN_ALERT MODULE_NAME ": %s() return %d\n", __func__, val);\
} while(0)
#define INFOL(level, s) do {\
if (level <= VERBOSE_LEVEL) {\
printk("<%d>%s:%s(): ", level, __FILE__, __func__); printk s; printk("\n");\
}\
} while(0)
# endif /* DEBUG_TRACEFUNC */
#else /* DEBUG_MESSAGES */
# define MSG(str)
# define DBG(str, ...)
# define FUNC_IN()
# define FUNC_OUT()
# define FUNC_OUTR(val)
# define INFOL(level, s)
# define INFO(s)
#endif /* DEBUG_MESSAGES */
// ===========================================================================
#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 VIDTCON2_LINEVAL_S (11)
static int tcon_inPortraitMode = 0;
typedef enum Tcon_Speedclasses
{
EN_I80_NONE = -1,
EN_I80_LANDSCAPE = 0,
EN_I80_PORTRAIT,
EN_I80_LANDSCAPE_HANDWRITING,
EN_I80_PORTRAIT_HANDWRITING,
} Tcon_Speedclasses;
typedef struct Tcon_SpeedclasseValue
{
u8 cs_setup;
u8 wr_setup;
u8 wr_act;
u8 wr_hold;
} Tcon_SpeedclasseValue;
static Tcon_SpeedclasseValue tcon_speedtable[] =
{
[EN_I80_LANDSCAPE] =
{
.cs_setup = 0,
.wr_setup = 0,
.wr_act = 1,
.wr_hold = 0,
},
[EN_I80_PORTRAIT] =
{
.cs_setup = 0,
.wr_setup = 3,
.wr_act = 8,
.wr_hold = 3,
},
[EN_I80_LANDSCAPE_HANDWRITING] =
{
.cs_setup = 0,
.wr_setup = 1,
.wr_act = 1,
.wr_hold = 0,
},
[EN_I80_PORTRAIT_HANDWRITING] =
{
.cs_setup = 0,
.wr_setup = 2,
.wr_act = 6,
.wr_hold = 2,
},
};
static Tcon_Speedclasses tcon_currentSpeedClass = EN_I80_NONE;
// ===========================================================================
// TCON Related functions
// ===========================================================================
/*
1. loops = 1 --> 25ns
2. loops = 75 --> 1 us
3. loops = 100000 --> 1ms
*/
static inline void tcon_ndelay(unsigned long loops) //in ns
{
__asm__ volatile ("1:\n" "subs %0, %1, #1\n" "bne 1b":"=r" (loops):"0"(loops));
}
static inline void tcon_delay (unsigned long uTime)
{
unsigned long cnt = 0;
for ( cnt = 0; cnt < uTime; cnt++ )
tcon_ndelay(75);
}
static int tcon_wait_ready (void)
{
unsigned long tmp;
int iBusyCnt = 0;
wait_queue_head_t busy_wq;
init_waitqueue_head(&busy_wq);
tmp = __raw_readl(S3C2410_GPBDAT);
while ( (tmp & (1 << 2)) == 0 )
{
sleep_on_timeout(&busy_wq, 4);
iBusyCnt++;
if ( iBusyCnt >= BUSY_WAIT_TIMEOUT )
{
return 0;
}
tmp = __raw_readl(S3C2410_GPBDAT);
}
return 1;
}
/* On the i80 port,
* i80 TCON
* -----------
* RS -> D/C
* CS0 -> CSEL
* nWE -> HWE
* OE -> HRD
*/
static inline void tcon_i80bus_init_interface(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SYSIFCON0); //polarity of RS, set 1 for normal access
tmp |= (1<<2);
__raw_writel(tmp, S3C_SYSIFCON0);
tmp = __raw_readl(S3C_SIFCCON0); // command mode enable
tmp |= (1<<0);
__raw_writel(tmp, S3C_SIFCCON0);
FUNC_OUT();
}
static inline void tcon_i80bus_deinit_interface(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0); // command mode disable
tmp &= ~(1<<0);
__raw_writel(tmp, S3C_SIFCCON0);
FUNC_OUT();
}
void tcon_i80bus_set_speed(Tcon_Speedclasses i80_speed,
unsigned short display_w,
unsigned short display_h,
unsigned char set_clock)
{
unsigned long tmp;
unsigned char clkval = 0;
unsigned short h_cnt, v_cnt;
unsigned long vclk;
struct clk *lcd_clock;
int HCLK;
FUNC_IN();
if ( tcon_currentSpeedClass == EN_I80_NONE)
set_clock = true;
tcon_currentSpeedClass = i80_speed;
if (set_clock == true)
{
INFOL(INFO_VERBOSE, ("Will set clocks..."));
tmp = __raw_readl(S3C_VIDCON0);
tmp = VIDCON0_S_CPU_IF_MAIN | VIDCON0_S_RGB_PAR | \
VIDCON0_S_VCLK_GATING_OFF | \
VIDCON0_S_CLKDIR_DIVIDED | VIDCON0_S_CLKSEL_HCLK;
__raw_writel(tmp, S3C_VIDCON0);
v_cnt = display_h;
h_cnt = display_w;
lcd_clock = clk_get(NULL, "hclk");
HCLK = clk_get_rate(lcd_clock);
clkval = (unsigned int)(HCLK / (display_w * display_h * 50 /* FPS ???? */));
vclk = (HCLK / (clkval + 1)) / 1000;
tmp = __raw_readl(S3C_VIDCON0);
tmp |= (clkval << VIDCON0_CLKVAL_F_SHIFT);
__raw_writel(tmp, S3C_VIDCON0);
}
tmp = __raw_readl(S3C_SYSIFCON0);
tmp = (tcon_speedtable[i80_speed].cs_setup << 16) |
(tcon_speedtable[i80_speed].wr_setup << 12) |
(tcon_speedtable[i80_speed].wr_act << 8) |
(tcon_speedtable[i80_speed].wr_hold << 4) |
(1 << 2) | (1 << 1) | (1);
__raw_writel(tmp, S3C_SYSIFCON0);
tmp = __raw_readl(S3C_SYSIFCON1);
tmp = (tcon_speedtable[i80_speed].cs_setup << 16) |
(tcon_speedtable[i80_speed].wr_setup << 12) |
(tcon_speedtable[i80_speed].wr_act << 8) |
(tcon_speedtable[i80_speed].wr_hold << 4) |
(1 << 2) | (1 << 1) | (1);
__raw_writel(tmp, S3C_SYSIFCON1);
tmp = __raw_readl(S3C_VIDTCON2);
tmp = ((display_h - 1) << VIDTCON2_LINEVAL_S) | ((display_w / 4) - 1);
__raw_writel(tmp, S3C_VIDTCON2);
FUNC_OUT();
}
static inline void tcon_i80bus_write (int data)
{
int tmp;
tmp = __raw_readl(S3C_SIFCCON0); // nWE enable
tmp |= SYS_WR_CON;
__raw_writel(tmp, S3C_SIFCCON0);
if ( !tcon_inPortraitMode )
tcon_ndelay(25);
__raw_writel(data, S3C_SIFCCON1); //rSIFCCON1 = CMD;
tmp = __raw_readl(S3C_SIFCCON0); // nWE disables
tmp &= ~SYS_WR_CON;
__raw_writel(tmp, S3C_SIFCCON0);
}
static inline void tcon_set_write_to_data(void)
{
unsigned long tmp;
//FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0);
// RS high -> D/nC set Data mode
tmp |= (1<<1);
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
//FUNC_OUT();
}
static inline void tcon_set_write_to_command(void)
{
unsigned long tmp;
//FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0);
// RS low -> D/nC set Command mode
tmp &= ~(1<<1);
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
//FUNC_OUT();
}
static inline void tcon_enable_write(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0);
// nWE -> HWE enable
tmp |= (1<<6);
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
FUNC_OUT();
}
static inline void tcon_disable_write(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0);
// nWE -> HWE disable
tmp &= ~(1<<6);
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
FUNC_OUT();
}
static inline void tcon_enable_read(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0); // nRD enable
tmp |= SYS_OE_CON;
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
FUNC_OUT();
}
static inline void tcon_disable_read(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0); // nRD disable
tmp &= ~SYS_OE_CON;
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
FUNC_OUT();
}
static inline void tcon_select_chip(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0); // Chip Select
tmp |= (1<<8);
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
FUNC_OUT();
}
static inline void tcon_unselect_chip(void)
{
unsigned long tmp;
FUNC_IN();
tmp = __raw_readl(S3C_SIFCCON0); // nCS0(Main) enable
tmp &= ~(1<<8);
__raw_writel(tmp, S3C_SIFCCON0);
tcon_delay(1);
FUNC_OUT();
}
int tcon_send_command_start(sAUOCommand *cmd)
{
FUNC_IN();
INFOL(INFO_VERBOSE,("cmd #%08lX", cmd->cmd));
/* First: verify that the K1900 is ready */
INFOL(INFO_VERBOSE, ("/* First: verify that the K1900 is ready */"));
if (GET_COMMAND_NEED_WAIT(cmd->cmd) != 0x00)
{
INFOL(INFO_VERBOSE, ("Wait for non BUSY..."));
tcon_wait_ready();
}
if (cmd->cmd == AUOCMD_INIT_SET)
{
tcon_inPortraitMode = ~(cmd->params[0]) & (0x1 << 10);
if (tcon_inPortraitMode)
tcon_i80bus_set_speed(EN_I80_PORTRAIT, 800, 600, false);
else
tcon_i80bus_set_speed(EN_I80_LANDSCAPE, 600, 800, false);
INFOL(INFO_VERBOSE, ("Rotation set to 0x%08X...", tcon_inPortraitMode));
}
/* Second: init the i80 interface */
INFOL(INFO_VERBOSE, ("/* Second: init the i80 interface */"));
tcon_i80bus_init_interface();
/* Third: Select the chip and set to Command mode */
INFOL(INFO_VERBOSE, ("/* Third: Select the chip and set to Command mode */"));
tcon_select_chip();
tcon_set_write_to_command();
/* Fourth: Send command */
INFOL(INFO_VERBOSE, ("/* Fourth: Send command */"));
tcon_i80bus_write(cmd->cmd & 0xFFFF); /* This function already manage
* no need to do it here. */
/* Sixth: If parameters is needed, send them */
INFOL(INFO_VERBOSE, ("/* Sixth: If parameters is needed, send them */"));
if (GET_COMMAND_PARAM_NUM(cmd->cmd) > 0)
{
int i, paramNumbers = GET_COMMAND_PARAM_NUM(cmd->cmd);
INFOL(INFO_VERBOSE, ("YES! We have %d parameters", paramNumbers));
tcon_set_write_to_data();
for (i = 0; i < paramNumbers; i++)
{
INFOL(INFO_VERBOSE, (" parameter [%02d] = 0x%04X", i, cmd->params[i]));
tcon_i80bus_write(cmd->params[i]);
}
}
FUNC_OUT();
return 0;
}
int tcon_send_data(unsigned short *buffer, unsigned long bufferLen)
{
/* Seventh: Send data if needed */
unsigned long i;
//FUNC_IN();
//INFOL(INFO_VERBOSE, ("Bufferlen: %ld", bufferLen));
tcon_set_write_to_data();
for (i = 0; i < bufferLen; i++)
{
tcon_i80bus_write(buffer[i]);
}
//FUNC_OUT();
return 0;
}
int tcon_send_command_end(sAUOCommand *cmd)
{
FUNC_IN();
INFOL(INFO_VERBOSE,("cmd #%08lX START:[#%08X]", cmd->cmd, AUOCMD_DISPLAY_START));
if (cmd->cmd == AUOCMD_DISPLAY_START)
{
tcon_set_write_to_command();
INFOL(INFO_VERBOSE, ("/* Eight: Send STOP command */"));
tcon_i80bus_write(AUOCMD_DISPLAY_STOP & 0xFFFF);
tcon_set_write_to_data();
}
INFOL(INFO_VERBOSE, ("/* Nineth: Close all */"));
tcon_unselect_chip();
tcon_i80bus_deinit_interface();
FUNC_OUT();
return 0;
}
// ===========================================================================
// Device related functions
// ===========================================================================
static int tcon_open (struct inode *inode, struct file *file)
{
FUNC_IN();
FUNC_OUT();
return 0;
}
// ---------------------------------------------------------------------------
static int tcon_release (struct inode *inode, struct file *file)
{
FUNC_IN();
FUNC_OUT();
return 0;
}
// ---------------------------------------------------------------------------
ssize_t tcon_read (struct file *file, char *buf, size_t count, loff_t *ppos)
{
FUNC_IN();
FUNC_OUT();
return 0;
}
// ---------------------------------------------------------------------------
int tcon_ioctl (struct inode *inode, struct file *file,
unsigned int ioctl_cmd, unsigned long arg)
{
sAUOCommand cmd;
unsigned char buffer[2048];
unsigned char *user_buffer;
unsigned long user_buflen, copysize, copysize16;
unsigned short *ptr16;
void __user *argp = (void __user *)arg;
FUNC_IN();
switch ( ioctl_cmd )
{
/* [MTR] */
case IOCTL_AUO_SENDCOMMAND:
if ( copy_from_user(&cmd, argp, sizeof (cmd)) )
return -EFAULT;
/* Now execute the command */
tcon_send_command_start(&cmd);
///INFOL(INFO_VERBOSE, ("/* Seventh: Send data if needed */"));
if ( GET_COMMAND_HAVE_DATA(cmd.cmd) != 0 )
{
//INFOL(INFO_VERBOSE, ("Yes, we have data to send!"));
user_buflen = cmd.datalen;
user_buffer = (unsigned char *)cmd.data;
while ( user_buflen != 0 )
{
copysize = user_buflen;
if ( user_buflen > sizeof (buffer) )
copysize = sizeof (buffer);
if ( copy_from_user(buffer, user_buffer, copysize) )
return -EFAULT;
copysize16 = (copysize + 1) / 2;
//printk(KERN_ERR "cp16=%ld cp=%ld\n", copysize16, copysize);
ptr16 = (unsigned short *)buffer;
tcon_send_data((unsigned short *)buffer, copysize16);
user_buflen -= copysize;
user_buffer += copysize;
}
}
tcon_send_command_end(&cmd);
break;
}
FUNC_OUT();
return -EINVAL;
}
// ===========================================================================
static struct file_operations s_tcon_fops =
{
owner : THIS_MODULE,
read : tcon_read,
ioctl : tcon_ioctl,
open : tcon_open,
release : tcon_release,
};
static struct miscdevice s_tcon_dev =
{
.minor = 242,
.name = "epaper",
.fops = &s_tcon_fops,
};
// ===========================================================================
// ---------------------------------------------------------------------------
static int tcon_probe (struct platform_device *dev)
{
int ret = -EINVAL;
FUNC_IN();
printk("tcon: probe");
if ( GET_CAPABILITY(PLAT_CAP_VTCON) )
{
unsigned long tmp;
printk(" ok\n");
ret = 0;
// set gpio for lcd
tmp = __raw_readl(S3C2410_GPCCON);
//tmp = (tmp & ~(0xffff03ff))|(0xaaaa02aa);
tmp = (tmp & ~(0xffff033f)) | (0xaaaa022a); //Do not config SYS_CS1(GPC3)
__raw_writel(tmp, S3C2410_GPCCON);
printk("Cybook Orizon Layout\n");
tmp = __raw_readl(S3C2410_GPDCON); //tmp=0x40000
tmp = (tmp & ~(0x0CFFFF)) | (0x04AAAA);
__raw_writel(tmp, S3C2410_GPDCON); // GPD9 is RST_N
__raw_writel(0, S3C2410_GPCUP); //S3C2410_GPCUP = 0;
__raw_writel(0, S3C2410_GPDUP); //S3C2410_GPDUP = 0;
tcon_i80bus_set_speed(EN_I80_LANDSCAPE, 800, 600, true);
// POWER pin config
tmp = __raw_readl(S3C2410_GPBCON);
tmp = (tmp & ~(3 << 6)) | (1 << 6);
__raw_writel(tmp, S3C2410_GPBCON);
// BUSY pin config
tmp = __raw_readl(S3C2410_GPBCON);
tmp = (tmp & ~(3 << 4));
__raw_writel(tmp, S3C2410_GPBCON);
// SLEEP pin config
tmp = __raw_readl(S3C2410_GPBCON);
tmp = (tmp & ~(3 << 2)) | (1 << 2);
__raw_writel(tmp, S3C2410_GPBCON);
mdelay(1);
// Panel power on
tmp = __raw_readl(S3C2410_GPBDAT);
tmp |= (1 << 3);
//SLP_N high
tmp |= (1 << 1);
__raw_writel(tmp, S3C2410_GPBDAT);
msleep(100);
// LCD module reset
tmp = __raw_readl(S3C2410_GPDDAT);
tmp |= (1 << 9);
__raw_writel(tmp, S3C2410_GPDDAT);
tmp = __raw_readl(S3C2410_GPDDAT); // goes to LOW
tmp &= ~(1 << 9);
__raw_writel(tmp, S3C2410_GPDDAT);
tcon_delay(5);
tmp = __raw_readl(S3C2410_GPDDAT); // goes to HIGH
tmp |= (1 << 9);
__raw_writel(tmp, S3C2410_GPDDAT);
// delay about 10ms
msleep(10);
tcon_i80bus_set_speed(EN_I80_PORTRAIT, 800, 600, false);
}
else
printk(" not ok\n");
FUNC_OUTR(ret);
return ret;
}
// ---------------------------------------------------------------------------
static int tcon_remove (struct platform_device *dev)
{
FUNC_IN();
misc_deregister(&s_tcon_dev);
FUNC_OUT();
return 0;
}
// --------------------------------------------------------------------------
static int tcon_resume (struct platform_device *dev)
{
FUNC_IN();
FUNC_OUT();
return 0;
}
// --------------------------------------------------------------------------
static int tcon_suspend (struct platform_device *dev, pm_message_t state)
{
FUNC_IN();
DBG("state event: %X", state.event);
FUNC_OUT();
return 0;
}
// ---------------------------------------------------------------------------
static struct platform_driver tcon_driver ={
.driver =
{
.name = "epaper-tcon",
.owner = THIS_MODULE,
},
.probe = tcon_probe,
.remove = tcon_remove,
.suspend = tcon_suspend,
.resume = tcon_resume,
};
// ---------------------------------------------------------------------------
// ===========================================================================
static int __init tcon_init (void)
{
int ret = 0;
FUNC_IN();
printk("tcon: init\n");
if ( misc_register(&s_tcon_dev) )
{
ret = -EBUSY;
goto exit;
}
platform_driver_register(&tcon_driver);
exit:
FUNC_OUTR(ret);
return ret;
}
// ---------------------------------------------------------------------------
static void __exit tcon_exit (void)
{
FUNC_IN();
printk("tcon: exit\n");
platform_driver_unregister(&tcon_driver);
misc_deregister(&s_tcon_dev);
FUNC_OUT();
}
// ---------------------------------------------------------------------------
module_init (tcon_init);
module_exit (tcon_exit);
// ---------------------------------------------------------------------------
MODULE_LICENSE ("GPL");
MODULE_AUTHOR ("Bookeen <developers@bookeen.com>");
MODULE_DESCRIPTION ("AUO ePaper TCON Driver");
MODULE_VERSION ("1.0");
// ==========================================================================