Browse Source

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

mlt 14 years ago
parent
commit
a55a73c5d1

+ 1 - 1
arch/arm/mach-s3c2416/Makefile

@@ -19,5 +19,5 @@ obj-$(CONFIG_S3C2416_PM)	+= pm.o
 # Machine support
 
 obj-$(CONFIG_MACH_SMDK2416)	 += mach-smdk2416.o qisda-utils.o cybook.o
-obj-$(CONFIG_MACH_CYBOOK_ORIZON) += mach-cybook_orizon.o cybook.o qisda-utils.o
+obj-$(CONFIG_MACH_CYBOOK_ORIZON) += mach-cybook_orizon.o cybook.o qisda-utils.o orizon-devs.o
 

+ 0 - 32
arch/arm/mach-s3c2416/cyio-dev.c

@@ -1,32 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/list.h>
-#include <linux/timer.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/irq.h>
-#include <asm/arch/fb.h>
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include <asm/arch/regs-serial.h>
-#include <asm/arch/udc.h>
-#include <asm/arch/l3.h>
-#include <asm/arch/audio.h>
-
-#include <asm/arch/buttons.h>
-
-#include "devs.h"
-#include "cpu.h"
-
-struct platform_device s3c_device_cyio = {
-	.name		  = "cyio2",
-	.id		  = -1,
-};
-EXPORT_SYMBOL(s3c_device_cyio);
-

+ 7 - 1
arch/arm/mach-s3c2416/mach-cybook_orizon.c

@@ -109,6 +109,10 @@ static struct s3c2410_uartcfg bkorizon_uartcfgs[] __initdata = {
 	}
 };
 
+
+extern struct platform_device orizon_device_cyio;
+extern struct platform_device orizon_device_tcon;
+
 /*** TODO: Verify this list and remove anything unneeded */
 static struct platform_device *bkorizon_devices[] __initdata = {
 	&s3c_device_spi0,
@@ -125,6 +129,9 @@ static struct platform_device *bkorizon_devices[] __initdata = {
 	&s3c_device_hsmmc1,
 
 	&s3c_device_ts_iic,
+
+        &orizon_device_cyio,
+        &orizon_device_tcon,
 };
 
 static struct s3c24xx_board bkorizon_board __initdata = {
@@ -294,4 +301,3 @@ struct s3c_hsmmc_cfg s3c_hsmmc1_platform = {
 	.clk_name[1] = "esysclk",			/* 2nd clock source hsmmc-epll by Ben Dooks */
 	.clk_name[2] = "hsmmc-ext",			/* 3rd clock source */
 };
-

+ 50 - 0
arch/arm/mach-s3c2416/orizon-devs.c

@@ -0,0 +1,50 @@
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach/arch.h>
+#include <asm/arch/irqs.h>
+
+#if 0
+static struct resource orizon_cyio_resource[] = {
+	[0] = {
+		.start = IRQ_EINT0,
+		.end   = IRQ_EINT0,
+		.flags = IORESOURCE_IRQ,
+	},
+	[1] = {
+		.start = IRQ_EINT7,
+		.end   = IRQ_EINT8,
+		.flags = IORESOURCE_IRQ,
+	},
+        [2] = {
+		.start = IRQ_EINT10,
+		.end   = IRQ_EINT10,
+		.flags = IORESOURCE_IRQ,
+	},
+        [3] = {
+		.start = IRQ_EINT14,
+		.end   = IRQ_EINT15,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+#endif
+struct platform_device orizon_device_cyio = {
+	.name		  = "cyio",
+	.id		  = 0,
+#if 0
+        .num_resources	  = ARRAY_SIZE(orizon_cyio_resource),
+	.resource	  = orizon_cyio_resource,
+#endif
+};
+EXPORT_SYMBOL(orizon_device_cyio);
+
+struct platform_device orizon_device_tcon = {
+	.name		  = "epaper-tcon",
+	.id		  = 0,
+};
+EXPORT_SYMBOL(orizon_device_tcon);

+ 4 - 36
cybook.config

@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.21.5-cfs-v19
-# Wed Apr 21 19:03:09 2010
+# Tue Apr 27 14:38:50 2010
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -878,38 +878,7 @@ CONFIG_SPI_MASTER=y
 # Graphics support
 #
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
-CONFIG_FB=y
-# CONFIG_FIRMWARE_EDID is not set
-# CONFIG_FB_DDC is not set
-# CONFIG_FB_CFB_FILLRECT is not set
-# CONFIG_FB_CFB_COPYAREA is not set
-# CONFIG_FB_CFB_IMAGEBLIT is not set
-# CONFIG_FB_SVGALIB is not set
-# CONFIG_FB_MACMODES is not set
-# CONFIG_FB_BACKLIGHT is not set
-# CONFIG_FB_MODE_HELPERS is not set
-# CONFIG_FB_TILEBLITTING is not set
-
-#
-# Frame buffer hardware drivers
-#
-CONFIG_FB_S3C=y
-# CONFIG_FB_LTD222OV is not set
-# CONFIG_FB_LTE246QV is not set
-# CONFIG_FB_LTS222QV is not set
-# CONFIG_FB_LTV350QV is not set
-# CONFIG_FB_LTE480WV is not set
-# CONFIG_FB_LMS480QC is not set
-# CONFIG_FB_I80 is not set
-# CONFIG_FB_A050VW01 is not set
-# CONFIG_FB_A070VW04 is not set
-CONFIG_FB_AUOEPAPER=y
-CONFIG_FB_AUOEPAPER_6=y
-# CONFIG_FB_AUOEPAPER_9 is not set
-# CONFIG_FB_BPP is not set
-# CONFIG_FB_S1D13XXX is not set
-# CONFIG_FB_S3C2410 is not set
-# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB is not set
 
 #
 # Console display driver support
@@ -917,12 +886,11 @@ CONFIG_FB_AUOEPAPER_6=y
 # CONFIG_VGA_CONSOLE is not set
 # CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FRAMEBUFFER_CONSOLE is not set
 
 #
-# Logo configuration
+# ePaper Devices
 #
-# CONFIG_LOGO is not set
+CONFIG_EPAPER_TCON_K1900=y
 
 #
 # Sound

+ 1 - 426
drivers/char/s3c-adc.c

@@ -546,432 +546,7 @@ static int s3c_adc_ioctl(struct inode *inode, struct file *file,
              ret = put_user(data_mask, (unsigned long __user *)arg);
         break;
         case ADC_SET_PM_FUNCTION_POWER:
-            printk("ADC_SET_PM_FUNCTION_POWER\n");
-#if defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_QD060N00_DVT1_1) ||  defined(CONFIG_QISDA_QD090B00_EVT1)
-            if((arg & ADC_PM_DEBUG_PORT)==0){
-                printk("ADC_PM_DEBUG_PORT, 0\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPB6, S3C2410_GPB6_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPB6, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPH0, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPH1_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPH1, 0);
-            }
-            else if((arg & ADC_PM_DEBUG_PORT)==1){
-                printk("ADC_PM_DEBUG_PORT, 1\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPB6, S3C2410_GPB6_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPB6, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_nCTS0);			 
-                s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPH1_nRTS0);			 
-            }
-            else if((arg & ADC_PM_DEBUG_PORT)==2){
-                printk("ADC_PM_DEBUG_PORT, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_DEBUG_PORT, 3 do nothing\n");
-            }
-
-            //WIFI
-            if(((arg & ADC_PM_WIFI) >> 2)==0){
-                printk("ADC_PM_WIFI, 0\n");
-/*
-                s3c2410_gpio_cfgpin(S3C2410_GPH12, S3C2410_GPH12_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPH12, 0);
-                writel(((readl(S3C2416_GPKCON) & ~(1<<13)) | (1<<12)), S3C2416_GPKCON);
-                writel(((readl(S3C2416_GPKDAT) | 0<<6)), S3C2416_GPKDAT);
-                writel(((readl(S3C2416_GPKCON) & ~(1<<11)) | (1<<10)), S3C2416_GPKCON);
-                writel(((readl(S3C2416_GPKDAT) | 0<<5)), S3C2416_GPKDAT);
-                //Signal        	
-                s3c2410_gpio_cfgpin(S3C2410_GPE11, S3C2410_GPE11_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE11, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE12, S3C2410_GPE12_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE12, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE13, S3C2410_GPE13_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE13, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPF3,  S3C2410_GPF3_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPF3,  0);
-                s3c2410_gpio_cfgpin(S3C2410_GPG4,  S3C2410_GPG4_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPG4,  0);
-                s3c2410_gpio_cfgpin(S3C2410_GPD8,  S3C2410_GPD8_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPD8,  0);
-                s3c2410_gpio_cfgpin(S3C2410_GPL13, S3C2410_GPL13_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPL13, 0);
-*/
-                s3c2410_gpio_cfgpin(S3C2410_GPD8,  S3C2410_GPD8_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPD8,  0);
-				msleep(100);
-                s3c2410_gpio_cfgpin(S3C2410_GPE11, S3C2410_GPE11_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE11, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE12, S3C2410_GPE12_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE12, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE13, S3C2410_GPE13_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE13, 0);
-
-                s3c2410_gpio_cfgpin(S3C2410_GPF3,  S3C2410_GPF3_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPF3,  0);
-                s3c2410_gpio_cfgpin(S3C2410_GPG4,  S3C2410_GPG4_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPG4,  0);
-
-                writel(((readl(S3C2410_GPHCON) & ~(1<<25)) | (1<<24)), S3C2410_GPHCON);     /* GPH12, 3.3V */
-                writel((readl(S3C2410_GPHDAT) & ~(1<<12)), S3C2410_GPHDAT);
-                writel(((readl(S3C2410_GPHUP) & ~(1<<25)) |  (1<<24)), S3C2410_GPHUP);
-				msleep(100);
-
-                s3c2410_gpio_cfgpin(S3C2410_GPL13, S3C2410_GPL13_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPL13, 0);
-				
-                writel(((readl(S3C2416_GPKCON) & ~(1<<13)) | (1<<12)), S3C2416_GPKCON);
-                writel((readl(S3C2416_GPKDAT) & ~(1<<6)), S3C2416_GPKDAT);
-				msleep(100);				
-                writel(((readl(S3C2416_GPKCON) & ~(1<<11)) | (1<<10)), S3C2416_GPKCON);
-                writel((readl(S3C2416_GPKDAT) & ~(1<<5)), S3C2416_GPKDAT);
-				msleep(100);
-            }
-            else if(((arg & ADC_PM_WIFI) >> 2)==1){
-                printk("ADC_PM_WIFI, 1\n");
-                // Powering on wifi is via the script file				
-/*
-                //power
-                s3c2410_gpio_cfgpin(S3C2410_GPH12, S3C2410_GPH12_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPH12, 1);
-                writel(((readl(S3C2416_GPKCON) & ~(1<<13)) | (1<<12)), S3C2416_GPKCON);
-                writel(((readl(S3C2416_GPKDAT) | 1<<6)), S3C2416_GPKDAT);
-                writel(((readl(S3C2416_GPKCON) & ~(1<<11)) | (1<<10)), S3C2416_GPKCON);
-                writel(((readl(S3C2416_GPKDAT) | 1<<5)), S3C2416_GPKDAT);
-                //Signal        	
-                s3c2410_gpio_cfgpin(S3C2410_GPE11, S3C2410_GPE11_SPIMISO0);			 
-                s3c2410_gpio_cfgpin(S3C2410_GPE12, S3C2410_GPE12_SPIMOSI0);			 
-                s3c2410_gpio_cfgpin(S3C2410_GPE13, S3C2410_GPE13_SPICLK0);			 
-                s3c2410_gpio_cfgpin(S3C2410_GPF3,  S3C2410_GPF3_EINT3);			 				
-                s3c2410_gpio_cfgpin(S3C2410_GPG4,  S3C2410_GPG4_EINT12);			 
-                s3c2410_gpio_cfgpin(S3C2410_GPD8,  S3C2410_GPD8_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPD8,  1);
-                s3c2410_gpio_cfgpin(S3C2410_GPL13, S3C2410_GPL13_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPL13, 1);   
-*/
-/*
-				s3c2410_gpio_setpin(S3C2410_GPH12, 1);
-				msleep(100);
-				s3c2410_gpio_setpin(S3C2410_GPIONO(S3C2416_GPIO_BANKK, 5), 1);
-				msleep(100);
-				s3c2410_gpio_setpin(S3C2410_GPIONO(S3C2416_GPIO_BANKK, 6), 1);
-				msleep(100);
-				s3c2410_gpio_setpin(S3C2410_GPD8, 1);
-				msleep(100);
-				s3c2410_gpio_setpin(S3C2410_GPD8, 0);
-				msleep(100);
-				s3c2410_gpio_setpin(S3C2410_GPD8, 1);
-				msleep(100);
-*/
-            }
-            else if(((arg & ADC_PM_WIFI) >> 2)==2){
-                printk("ADC_PM_WIFI, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_WIFI, 3 do nothing\n");
-            } 
-
-            //Audio	ok
-            if(((arg & ADC_PM_AUDIO) >> 4)==0){
-                printk("ADC_PM_AUDIO, 0\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPB10, S3C2410_GPB10_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPB10, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE0, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE1, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE2, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE3, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPE4, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPF4, 0);
-#ifdef CONFIG_QISDA_AS090B00_EVT1
-   	            s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPG3, 0);
-#endif
-#if defined(CONFIG_QISDA_AS090B00_EVT1_1)|| defined (CONFIG_QISDA_QD090B00_EVT1) || defined(CONFIG_QISDA_QD060N00_DVT1_1)
-   	            s3c2410_gpio_cfgpin(S3C2410_GPA1, S3C2410_GPA1_OUT);	//s02	????S3C2410_GPA1_OUT	 
-	            s3c2410_gpio_setpin(S3C2410_GPA1, 0);
-#endif	
-
-            }
-            else if(((arg & ADC_PM_AUDIO) >> 4)==1){
-                printk("ADC_PM_AUDIO, 1\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPB10, S3C2410_GPB10_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPB10, 1);
-	            s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK);
-	            s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_I2SSCLK);
-	            s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_CDCLK);
-	            s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI);
-	            s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO);            
-                s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_EINT4);			 
-             	s3c2410_gpio_pullup(S3C2410_GPF4, 2);
-#ifdef CONFIG_QISDA_AS090B00_EVT1
-   	            s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_OUTP);	//s01		 
-	            s3c2410_gpio_setpin(S3C2410_GPG3, 1);	
-#endif
-#if defined(CONFIG_QISDA_AS090B00_EVT1_1) || defined (CONFIG_QISDA_QD090B00_EVT1) || defined(CONFIG_QISDA_QD060N00_DVT1_1)
-   	            s3c2410_gpio_cfgpin(S3C2410_GPA1, S3C2410_GPA1_OUT);	//s02	????S3C2410_GPA1_OUT	 
-	            s3c2410_gpio_setpin(S3C2410_GPA1, 1);
-#endif	
-            }
-            else if(((arg & ADC_PM_AUDIO) >> 4)==2){
-                printk("ADC_PM_AUDIO, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_AUDIO, 3 do nothing\n");
-            }
-
-
-            //SD ok
-            if(((arg & ADC_PM_SD) >> 6)==0){
-                printk("ADC_PM_SD, 0\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPG2, S3C2410_GPG2_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPG2, 0);
-		        s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE5, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPE6, S3C2410_GPE6_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE6, 0);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2410_GPE7_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE7, 0);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE8, 0);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2410_GPE9_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE9, 0);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2410_GPE10_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE10, 0);
-                s3c2410_gpio_cfgpin(S3C2410_GPF1, S3C2410_GPF1_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPF1, 0);
-
-            }
-            else if(((arg & ADC_PM_SD) >> 6)==1){
-                printk("ADC_PM_SD, 1\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPG2, S3C2410_GPG2_OUTP);			 
-                s3c2410_gpio_setpin(S3C2410_GPG2, 1);
-		        s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2450_GPE5_SD0_CLK);
-                s3c2410_gpio_cfgpin(S3C2410_GPE6, S3C2450_GPE6_SD0_CMD);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2450_GPE7_SD0_DAT0);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2450_GPE8_SD0_DAT1);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2450_GPE9_SD0_DAT2);
-			    s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2450_GPE10_SD0_DAT3);
-                s3c2410_gpio_cfgpin(S3C2410_GPF1, S3C2410_GPF1_EINT1);			 
-                s3c2410_gpio_setpin(S3C2410_GPF1, 0);
-            }
-            else if(((arg & ADC_PM_SD) >> 6)==2){
-                printk("ADC_PM_SD, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_SD, 3 do nothing\n");
-            }
-
-            //TCON ivan interface ok
-            if(((arg & ADC_PM_TCON) >> 8)==0){
-                //power and signal
-                printk("ADC_PM_TCON, 0\n");
-	        //AUO T-CON Standby
-             	Epaper_Enter_Standby_Mode(1);
-	        //AUO T-CON Sleep
-	        Epaper_Enter_Sleep_Mode(1);
-	        msleep(250);
-	        //Shutdown T-CON Power
-	        Epaper_Power(0);
-		//Shutdown i80 of s3c
-	        EPaper_CloseLcdPort();
-                msleep(1000);
-            }
-            else if(((arg & ADC_PM_TCON) >> 8)==1){
-                //power and signal
-                printk("ADC_PM_TCON, 1\n");
- 	            Epaper_SetLcdPort();
-	            msleep(100); //sleep for RST_N pull high
-            }
-            else if(((arg & ADC_PM_TCON) >> 8)==2){
-                printk("ADC_PM_TCON, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_TCON, 3 do nothing\n");
-            }
-
-            //USB ok		
-            if(((arg & ADC_PM_USB) >> 10)==0){
-                printk("ADC_PM_USB, 0\n");
-	            s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPD13_OUTP);
-	            s3c2410_gpio_setpin(S3C2410_GPD13, 0); 	/* usb power enbale */
- 	            s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
-            	s3c2410_gpio_setpin(S3C2443_GPH14, 0);
-            }
-            else if(((arg & ADC_PM_USB) >> 10)==1){
-                printk("ADC_PM_USB, 1\n");
-	            s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPD13_OUTP);
-	            s3c2410_gpio_setpin(S3C2410_GPD13, 1); 	/* usb power enbale */
- 	            s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
-            	s3c2410_gpio_setpin(S3C2443_GPH14, 1);
-            }
-            else if(((arg & ADC_PM_USB) >> 10)==2){
-                printk("ADC_PM_USB, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_USB, 3 do nothing\n");
-            }			
-
-            //Touch	GPIO ok, 12~15
-            if(((arg & ADC_PM_TOUCH) >> 12)==0){
-                printk("ADC_PM_TOUCH, 0\n");
-// 	            s3c2410_gpio_cfgpin(S3C2410_GPB3, S3C2410_GPB3_OUTP);			 
-//              s3c2410_gpio_setpin(S3C2410_GPB3, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPF2, 0);
-
-		#ifdef CONFIG_QISDA_BK060B00
-		
-		s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_OUTP);
-		s3c2410_gpio_setpin(S3C2410_GPD10, 0);
-		#else
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPF5, 0);
-		#endif
-            }
-            else if(((arg & ADC_PM_TOUCH) >> 12)==1){
-                //power on 
-                printk("ADC_PM_TOUCH, 1\n");			 
-// 	            s3c2410_gpio_cfgpin(S3C2410_GPB3, S3C2410_GPB3_OUTP);			 
-//	            s3c2410_gpio_setpin(S3C2410_GPB3, 1);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_INP);	
-
-		#ifdef CONFIG_QISDA_BK060B00
-				
-		s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_OUTP);
-		s3c2410_gpio_setpin(S3C2410_GPD10, 1);
-		#else
-
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPF5, 1);
-		#endif
-            }
-            else if(((arg & ADC_PM_TOUCH) >> 12)==2){
-                //power on () + touch active mode (touch ioctl)
-                printk("ADC_PM_TOUCH, 2 Touch GPIO on and Enter Active\n");
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_INP);			 
-
-		#ifdef CONFIG_QISDA_BK060B00
-		
-		s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_OUTP);
-		s3c2410_gpio_setpin(S3C2410_GPD10, 1);
-		#else
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPF5, 1);				
-		#endif
-            }
-            else if(((arg & ADC_PM_TOUCH) >> 12)==3){
-                //power on + touch sleep mode (via touch ioctl)
-                printk("ADC_PM_TOUCH, 3 Touch GPIO on and Enter Sleep\n");
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_INP);			 
-
-		#ifdef CONFIG_QISDA_BK060B00
-		
-		s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_OUTP);
-		s3c2410_gpio_setpin(S3C2410_GPD10, 1);
-		#else
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPF5, 1);
-		#endif
-            }
-            else if(((arg & ADC_PM_TOUCH) >> 12)==4){
-                //power on + touch deep sleep mode (via touch ioctl)
-                printk("ADC_PM_TOUCH, 4 Touch GPIO on and Enter Deep sleep\n");
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_INP);	
-
-		#ifdef CONFIG_QISDA_BK060B00
-		
-		s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_OUTP);
-		s3c2410_gpio_setpin(S3C2410_GPD10, 1);
-		#else
- 	            s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPF5, 1);
-		#endif
-            }
-            else{
-                printk("ADC_PM_TOUCH, 5~15 do nothing\n");
-            }
-
-            //SMART_CARD ok		
-            if(((arg & ADC_PM_SMART_CARD) >> 16)==0){
-                printk("ADC_PM_SMART_CARD, 0\n");
- 	            s3c2410_gpio_cfgpin(S3C2410_GPC3, S3C2410_GPC3_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPC3, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH2, S3C2410_GPH2_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH2, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH3, S3C2410_GPH3_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH3, 0);
-            }
-            else if(((arg & ADC_PM_SMART_CARD) >> 16)==1){
-                printk("ADC_PM_SMART_CARD, 1\n");
- 	            s3c2410_gpio_cfgpin(S3C2410_GPC3, S3C2410_GPC3_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPC3, 1);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH2, S3C2410_GPH2_TXD0);			 
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH3, S3C2410_GPH3_RXD0);			 
-            }
-            else if(((arg & ADC_PM_SMART_CARD) >> 16)==2){
-                printk("ADC_PM_SMART_CARD, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_SMART_CARD, 3 do nothing\n");
-            }
-
-            //SMART_CARD ok		
-            if(((arg & ADC_PM_3G_MODULE) >> 18)==0){
-                printk("ADC_PM_3G_MODULE, 0\n");
-   	            s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPG3, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH8, S3C2410_GPH8_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH8, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH9, S3C2410_GPH9_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH9, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH11, S3C2410_GPH11_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH11, 0);
-            }
-            else if(((arg & ADC_PM_3G_MODULE) >> 18)==1){
-                printk("ADC_PM_3G_MODULE, 1\n");
-   	            s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPG3, 1);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH8, S3C2410_GPH8_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH8, 1);
-// 	            s3c2410_gpio_cfgpin(S3C2410_GPH9, S3C2410_GPH9_OUTP);			 
-//	            s3c2410_gpio_setpin(S3C2410_GPH9, 0);
- 	            s3c2410_gpio_cfgpin(S3C2410_GPH11, S3C2410_GPH11_OUTP);			 
-	            s3c2410_gpio_setpin(S3C2410_GPH11, 1);
-            }
-            else if(((arg & ADC_PM_3G_MODULE) >> 18)==2){
-                printk("ADC_PM_3G_MODULE, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_3G_MODULE, 3 do nothing\n");
-            }
-
-            //ADC_PM_I2C ok		
-            if(((arg & ADC_PM_I2C) >> 20)==0){
-                printk("ADC_PM_I2C, 0\n");
-                s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_OUTP);
-	            s3c2410_gpio_setpin(S3C2410_GPE14, 0); // IICSCL
-                s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_OUTP);
-                s3c2410_gpio_setpin(S3C2410_GPE15, 0); // IICSDA
-            }
-            else if(((arg & ADC_PM_I2C) >> 20)==1){
-                printk("ADC_PM_I2C, 1\n");
-           	    s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA);
-	            s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);
-            }
-            else if(((arg & ADC_PM_I2C) >> 20)==2){
-                printk("ADC_PM_I2C, 2 do special test\n");
-            }
-            else{
-                printk("ADC_PM_I2C, 3 do nothing\n");
-            }					
-#endif
-             ret = 0;
+          
         break;
 #ifdef CONFIG_PM_CPU_MODE
         case ADC_SET_CPU_PM_MODE:

+ 400 - 0
drivers/input/misc/orizon_tilt.c

@@ -0,0 +1,400 @@
+/* ===========================================================================
+ * orizon_tilt.c
+ * Copyright (C) 2009-2010 Bookeen - All rights reserved
+ * ===========================================================================
+ */
+
+/* TODO: Verify if all this includes are necessary */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <asm/atomic.h>
+#include <asm/io.h>
+#include <asm/arch/irqs.h>
+#include <asm/arch/gpio.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/jiffies.h>
+#include <linux/proc_fs.h>
+#include <linux/kthread.h>
+#include <linux/mutex.h>
+#include <linux/spinlock.h>
+
+#include <cybook.h>
+
+#include <linux/cyio.h>
+
+//#define DEBUG_MESSAGES
+//#define DEBUG_TRACEFUNC
+//#define DBG_IRQ
+
+#define MODULE_NAME "CYB_TILT"
+
+#undef MSG
+#undef DBG
+#ifdef DEBUG_MESSAGES
+
+#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 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)
+
+#endif /* DEBUG_TRACEFUNC */
+
+#else /* DEBUG_MESSAGES */
+#define MSG(str)
+#define DBG(str, ...)
+#define FUNC_IN()
+#define FUNC_OUT()
+#define FUNC_OUTR(val)
+#endif /* DEBUG_MESSAGES */
+
+#define GPROCFS_ROOTFOLDER    "cybook"
+#define GPROCFS_MODULEFOLDER  "gsensor"
+#define GPROCFS_IOFILE        "io"
+
+#define TRUE  (1==1)
+#define FALSE (1==0)
+
+static struct proc_dir_entry *rootDir,
+                             *ioProcEntry;
+
+atomic_t                      OrizonTilt_Status;
+atomic_t                      OrizonTilt_IrqSet;
+
+static volatile short         OrizonTilt_CurrentDirection = 270;
+static int SensorsInt[2];
+static DEFINE_SPINLOCK(suspendLock);
+
+static unsigned char          OrizonTilt_finishedWork = 0;
+
+/*============================================================================*/
+/*============================= Prototypes ===================================*/
+/*============================================================================*/
+
+/********************************* PM *****************************************/
+static int orizontilt_suspend(struct device *dev, pm_message_t state);
+static int orizontilt_resume (struct device *dev);
+/************************* Data collection Functions **************************/
+
+/********************** Interrupt Related functions ***************************/
+static void orizontilt_setMode(int mode);
+static int  orizontilt_initIrq(void);
+static void orizontilt_deinitIrq(void);
+static irqreturn_t orizontilt_interrupt(int irq, void *dev_id);
+
+/****************************** ProcFs functions ******************************/
+static int orizontilt_procReadIo (char *page, char **start, off_t off, int count,
+                               int *eof, void *data);
+static int orizontilt_procWriteIo (struct file *file, const char *buffer,
+                                unsigned long count, void *data);
+/****************************** Module functions ******************************/
+static int  __init orizontilt_init(void);
+static void __exit orizontilt_exit(void);
+/*============================= End of prototypes ============================*/
+
+/******************************************************************************/
+/********************** Interrupt Related functions ***************************/
+/******************************************************************************/
+static int orizontilt_initIrq(void)
+{
+   int ret = 0;
+   FUNC_IN();
+
+   if ( atomic_read(&OrizonTilt_IrqSet) != TRUE )
+   {
+      MSG("I will enable IRQ\n");
+
+      set_irq_type(IRQ_EINT11, IRQT_BOTHEDGE);
+      set_irq_type(IRQ_EINT12, IRQT_BOTHEDGE);
+      s3c2410_gpio_pullup(S3C2410_GPG3, 0);
+      s3c2410_gpio_pullup(S3C2410_GPG4, 0);
+      if(request_irq(IRQ_EINT11, orizontilt_interrupt, SA_INTERRUPT, "TILT-SENSOR[1]",  &SensorsInt[0]))
+      {
+         ret = -1;
+         goto exit;
+      }
+      if(request_irq(IRQ_EINT12, orizontilt_interrupt, SA_INTERRUPT, "TILT-SENSOR[2]",  &SensorsInt[1]))
+      {
+         ret = -1;
+         goto exit;
+      }
+   
+      atomic_set(&OrizonTilt_IrqSet, TRUE);
+   }
+
+exit:
+   FUNC_OUTR(ret);
+   return ret;
+}
+
+static void orizontilt_deinitIrq(void)
+{
+   FUNC_IN();
+
+   /* Set the orizontilt to standby mode */
+   if ( atomic_read(&OrizonTilt_IrqSet) == TRUE )
+   {
+      disable_irq_wake(IRQ_EINT11);
+      disable_irq_wake(IRQ_EINT12);
+      free_irq(IRQ_EINT11, NULL);
+      free_irq(IRQ_EINT12, NULL);
+      atomic_set(&OrizonTilt_IrqSet, FALSE);
+   }
+
+   FUNC_OUT();
+}
+
+static irqreturn_t orizontilt_interrupt(int irq, void *dev_id)
+{
+   irqreturn_t ret = IRQ_HANDLED;
+   unsigned long tmpReg;
+   unsigned long calcTilt;
+
+   FUNC_IN();
+
+   spin_lock(&suspendLock);
+   OrizonTilt_finishedWork = 1;
+   spin_unlock(&suspendLock);
+
+
+   /* Do it here */
+   MSG("Will read gpios...");
+   tmpReg = (__raw_readl(S3C2410_GPGDAT) >> 3) & 0x3;
+   DBG("Got reg: %lu", tmpReg);
+   calcTilt = 0;
+   switch(tmpReg)
+   {
+   case 0x00: /*  90 */
+         calcTilt =  90;
+         break;
+
+      case 0x02: /*   0 */
+         calcTilt =   0;
+         break;
+
+      case 0x01: /* 180 */
+         calcTilt = 180;
+         break;
+
+      case 0x03: /* 270 */
+         calcTilt = 270;
+         break;
+   }
+   DBG("New Orientation is: %lu", calcTilt);
+   if (calcTilt != OrizonTilt_CurrentDirection)
+   {
+      MSG("Different from old one, push new event!");
+      OrizonTilt_CurrentDirection = calcTilt;
+      Cyio_PushEvent(CYEVENT_ORIENTATIONCHANGED, true);
+   }
+
+   spin_lock(&suspendLock);
+   OrizonTilt_finishedWork = 0;
+   spin_unlock(&suspendLock);
+
+  FUNC_OUT();
+
+exit:
+  FUNC_OUTR((int)ret);
+  return ret;
+}
+
+static void orizontilt_setMode(int mode)
+{
+   switch(mode)
+   {
+   case G_SENSOR_ON:
+      orizontilt_initIrq();
+      enable_irq_wake(IRQ_EINT11);
+      enable_irq_wake(IRQ_EINT12);
+      /* Switch TILT on */
+      gpio_direction_output(S3C2410_GPC3, 1);
+      atomic_set(&OrizonTilt_Status, CYGSENSOR_STATUS_ENABLED);
+      break;
+   case G_SENSOR_OFF:
+      atomic_set(&OrizonTilt_Status, CYGSENSOR_STATUS_DISABLED);
+      /* Switch TILT off */
+      gpio_direction_output(S3C2410_GPC3, 0);
+      orizontilt_deinitIrq();
+      disable_irq_wake(IRQ_EINT11);
+      disable_irq_wake(IRQ_EINT12);
+      break;
+   }
+}
+
+/******************************************************************************/
+/****************************** ProcFs functions ******************************/
+/******************************************************************************/
+static int orizontilt_procReadIo (char *page, char **start, off_t off, int count,
+                               int *eof, void *data)
+{
+   int len;
+   char tmp = 0;
+
+   
+  /* We are a tilt and need no calibration */
+  tmp |= (1 << 6);
+
+  if ( atomic_read(&OrizonTilt_Status) != CYGSENSOR_STATUS_ENABLED )
+     tmp |= (1 << 4);
+
+  switch (OrizonTilt_CurrentDirection)
+  {
+  case 270:
+     tmp++;
+  case 180:
+     tmp++;
+  case 90:
+     tmp++;
+  default:
+     break;
+  }
+  
+  len = sprintf (page, "%02X", tmp);
+  DBG("io readed value: %02X", tmp);
+  
+  FUNC_OUTR(len);
+  return len;
+}
+
+static int orizontilt_procWriteIo (struct file *file, const char *buffer,
+                                unsigned long count, void *data)
+{
+   char cmd;
+   FUNC_IN();
+
+   /* in case of... */
+   if ( count < 1 )
+      return 0;
+
+   cmd = buffer[0];
+   switch(cmd)
+   {
+      case G_SENSOR_ON:
+      case G_SENSOR_OFF:
+         orizontilt_setMode(cmd);
+         break;
+
+      default:
+         printk(KERN_ERR "ProcIO: Unknown command '%c'\n",cmd);
+         break;
+   }
+
+   FUNC_OUTR((int)count);
+   return count;
+}
+
+/******************************************************************************/
+/****************************** Module functions ******************************/
+/******************************************************************************/
+static int __init orizontilt_init(void)
+{
+
+   FUNC_IN();
+   //printk(KERN_ERR "Platform is Cybook %d\n", platform_type);
+
+   SensorsInt[0] = 1;
+   SensorsInt[1] = 2;
+   
+   if (GET_CAPABILITY(PLAT_CAP_GSENSOR) == PLAT_CAP_GTILT)
+   {
+      atomic_set(&OrizonTilt_Status, CYGSENSOR_STATUS_UNKNOWN);
+      atomic_set(&OrizonTilt_IrqSet, FALSE);
+      
+      rootDir = proc_mkdir(GPROCFS_ROOTFOLDER, NULL);
+
+      rootDir = proc_mkdir(GPROCFS_MODULEFOLDER, proc_root_driver);
+      ioProcEntry     = create_proc_entry(GPROCFS_IOFILE,        0644, rootDir);
+
+      ioProcEntry->read_proc     = orizontilt_procReadIo;
+      ioProcEntry->write_proc    = orizontilt_procWriteIo;
+      ioProcEntry->owner         = THIS_MODULE;
+  }
+
+  FUNC_OUT();
+  return 0;
+}
+// ---------------------------------------------------------------------------
+static void __exit orizontilt_exit(void)
+{
+   FUNC_IN();
+
+   if (GET_CAPABILITY(PLAT_CAP_GSENSOR) == PLAT_CAP_GTILT)
+   {
+      orizontilt_setMode(G_SENSOR_OFF);
+      
+      remove_proc_entry(GPROCFS_IOFILE,       rootDir);
+      remove_proc_entry(GPROCFS_MODULEFOLDER, proc_root_driver);
+   }
+
+   FUNC_OUT();
+}
+// ---------------------------------------------------------------------------
+module_init(orizontilt_init);
+module_exit(orizontilt_exit);
+// ---------------------------------------------------------------------------
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Bookeen <developers@bookeen.com>");
+MODULE_VERSION("1.1");
+MODULE_DESCRIPTION("Orizon Tilt Sensor driver");
+// ===========================================================================

+ 2 - 0
drivers/video/Kconfig

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

+ 3 - 0
drivers/video/Makefile

@@ -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/

+ 0 - 227
drivers/video/epaper.c

@@ -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] */
 

+ 28 - 0
drivers/video/epaper/Kconfig

@@ -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

+ 3 - 0
drivers/video/epaper/Makefile

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

+ 839 - 0
drivers/video/epaper/auo-tcon-k1900.c

@@ -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");
+// ==========================================================================

+ 20 - 20
include/cybook.h

@@ -20,37 +20,37 @@ extern unsigned int platform_type;
 /* 3322 2222 2222 1111 1111 1100 0000 0000 
  * 1098 7654 3210 9876 5432 1098 7654 3210 
  * ---------------------------------------
- *                               FFGG VVSS
+ *                          FFFG GGVV VSSS
  *
- * FF = Form Factor
- * GG = GSensor mode
- * VV = Video Driver
- * SS = Sound Driver
+ * FFF = Form Factor
+ * GGG = GSensor mode
+ * VVV = Video Driver
+ * SSS = Sound Driver
  */
 extern unsigned long platform_capability;
 
-#define PLAT_CAP_GSENSOR    (3 << 4)
-#define PLAT_CAP_GNONE      (0 << 4)
-#define PLAT_CAP_GMMA7455   (1 << 4)
-#define PLAT_CAP_GMMA7660   (2 << 4)
-#define PLAT_CAP_GTILT      (3 << 4)
+#define PLAT_CAP_GSENSOR    (7 << 6)
+#define PLAT_CAP_GNONE      (0 << 6)
+#define PLAT_CAP_GMMA7455   (1 << 6)
+#define PLAT_CAP_GMMA7660   (2 << 6)
+#define PLAT_CAP_GTILT      (3 << 6)
 
-#define PLAT_CAP_SOUND      (3 << 0)
+#define PLAT_CAP_SOUND      (7 << 0)
 #define PLAT_CAP_SOUNDNO    (0 << 0)
 #define PLAT_CAP_SOUNDL3    (1 << 0)
 
-#define PLAT_CAP_VIDEO      (3 << 2)
-#define PLAT_CAP_VAPOLLO    (0 << 2)
-#define PLAT_CAP_VEPSON     (1 << 2)
-#define PLAT_CAP_VTCON      (2 << 2)
+#define PLAT_CAP_VIDEO      (7 << 3)
+#define PLAT_CAP_VAPOLLO    (0 << 3)
+#define PLAT_CAP_VEPSON     (1 << 3)
+#define PLAT_CAP_VTCON      (2 << 3)
 
-#define PLAT_CAP_FORMFACTOR (3 << 6)
-#define PLAT_CAP_GEN3FORM   (0 << 6)
-#define PLAT_CAP_OPUSFORM   (1 << 6)
-#define PLAT_CAP_ORIZONFORM (2 << 6)
+#define PLAT_CAP_FORMFACTOR (7 << 9)
+#define PLAT_CAP_GEN3FORM   (0 << 9)
+#define PLAT_CAP_OPUSFORM   (1 << 9)
+#define PLAT_CAP_ORIZONFORM (2 << 9)
 
-#define GET_CAPABILITY(CAPAB) (platform_capability & (CAPAB))
 //#define PLAT_CAP_
 
+#define GET_CAPABILITY(CAPAB) (platform_capability & (CAPAB))
 
 #endif /* CYBOOK_H */