From eada869814636157956641ba1503f0d6cc04e2b7 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Fri, 19 Oct 2007 17:43:51 +0400 Subject: [PATCH] tosa-lcdnoise-r1.patch fixes --- arch/arm/mach-pxa/tosa_lcd.c | 34 ++++++++++++++++++++++++++++++++++ drivers/input/touchscreen/tosa_ts.c | 9 +-------- include/asm-arm/arch-pxa/tosa.h | 5 +++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-pxa/tosa_lcd.c b/arch/arm/mach-pxa/tosa_lcd.c index d52f63f..447ca86 100644 --- a/arch/arm/mach-pxa/tosa_lcd.c +++ b/arch/arm/mach-pxa/tosa_lcd.c @@ -59,6 +59,8 @@ static int bl_intensity; static struct ssp_dev tosa_nssp_dev; static struct ssp_state tosa_nssp_state; static spinlock_t tosa_nssp_lock; +static int blanked; +static unsigned long hsync_time; static unsigned short normal_i2c[] = { DAC_BASE, @@ -130,6 +132,17 @@ static void tosa_lcd_tg_init(struct device *dev) pxa_nssp_output(TG_GPOSR,0x02); /* GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL */ } +static unsigned long calc_hsync_time(const struct fb_videomode *mode) { + /* The 25 and 44 'magic numbers' are from Sharp's 2.4 patches */ + if (mode->yres == 640) { + return 25; + } + if (mode->yres == 320) { + return 44; + } + return 0; +} + static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode) { const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; @@ -154,6 +167,8 @@ static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode) /* set common voltage */ i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj); + blanked = 0; + hsync_time = calc_hsync_time(mode); } static void tosa_lcd_tg_off(struct device *dev) @@ -172,6 +187,8 @@ static void tosa_lcd_tg_off(struct device *dev) /* L3V Off */ reset_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); + + blanked = 1; } static int tosa_detect_client(struct i2c_adapter* adapter, int address, int kind) { @@ -238,6 +255,23 @@ static int tosa_detach_client(struct i2c_client* client) { return 0; } +unsigned long tosa_lcd_get_hsync_time(void) +{ +/* This method should eventually contain the correct algorithm for calculating + the hsync_time */ + if (blanked) + return 0; + else + return hsync_time; +} + +void tosa_lcd_wait_hsync(void) +{ + /* Waits for a rising edge on the VGA line */ + while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) == 0); + while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) != 0); +} + static struct i2c_driver tosa_driver={ .id = TOSA_LCD_I2C_DEVICEID, .attach_adapter = tosa_attach_adapter, diff --git a/drivers/input/touchscreen/tosa_ts.c b/drivers/input/touchscreen/tosa_ts.c index bc733e9..134f8ce 100644 --- a/drivers/input/touchscreen/tosa_ts.c +++ b/drivers/input/touchscreen/tosa_ts.c @@ -25,13 +25,6 @@ #define CCNT_ON() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1)) #define CCNT_OFF() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1)) -static inline void tosa_lcd_wait_hsync(void) -{ - /* Waits for a rising edge on the VGA line */ - while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) == 0); - while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) != 0); -} - /* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait * before sampling the Y axis of the touchscreen */ void tosa_lcd_sync_on(int adcsel) { @@ -54,7 +47,7 @@ void tosa_lcd_sync_on(int adcsel) { } } -void tosa_lcd_sync_off(void) { +void tosa_lcd_sync_off(int adcsel) { CCNT_OFF(); } diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h index ce7322d..7f446fd 100644 --- a/include/asm-arm/arch-pxa/tosa.h +++ b/include/asm-arm/arch-pxa/tosa.h @@ -1,6 +1,7 @@ /* * Hardware specific definitions for Sharp SL-C6000x series of PDAs * + * Copyright (c) 2006 Wolfson Microelectronics PLC. * Copyright (c) 2005 Dirk Opfer * * Based on Sharp's 2.4 kernel patches @@ -187,4 +188,8 @@ extern struct platform_device tosascoop_jc_device; extern struct platform_device tosascoop_device; extern struct platform_device tc6393_device; + +unsigned long tosa_lcd_get_hsync_time(void); +void tosa_lcd_wait_hsync(void); + #endif /* _ASM_ARCH_TOSA_H_ */ -- 1.4.4.4 From eada869814636157956641ba1503f0d6cc04e2b7 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Fri, 19 Oct 2007 17:43:51 +0400 Subject: [PATCH] tosa-lcdnoise-r1.patch fixes --- arch/arm/mach-pxa/tosa_lcd.c | 34 ++++++++++++++++++++++++++++++++++ drivers/input/touchscreen/tosa_ts.c | 9 +-------- include/asm-arm/arch-pxa/tosa.h | 5 +++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-pxa/tosa_lcd.c b/arch/arm/mach-pxa/tosa_lcd.c index d52f63f..447ca86 100644 --- a/arch/arm/mach-pxa/tosa_lcd.c +++ b/arch/arm/mach-pxa/tosa_lcd.c @@ -59,6 +59,8 @@ static int bl_intensity; static struct ssp_dev tosa_nssp_dev; static struct ssp_state tosa_nssp_state; static spinlock_t tosa_nssp_lock; +static int blanked; +static unsigned long hsync_time; static unsigned short normal_i2c[] = { DAC_BASE, @@ -130,6 +132,17 @@ static void tosa_lcd_tg_init(struct device *dev) pxa_nssp_output(TG_GPOSR,0x02); /* GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL */ } +static unsigned long calc_hsync_time(const struct fb_videomode *mode) { + /* The 25 and 44 'magic numbers' are from Sharp's 2.4 patches */ + if (mode->yres == 640) { + return 25; + } + if (mode->yres == 320) { + return 44; + } + return 0; +} + static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode) { const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; @@ -154,6 +167,8 @@ static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode) /* set common voltage */ i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj); + blanked = 0; + hsync_time = calc_hsync_time(mode); } static void tosa_lcd_tg_off(struct device *dev) @@ -172,6 +187,8 @@ static void tosa_lcd_tg_off(struct device *dev) /* L3V Off */ reset_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); + + blanked = 1; } static int tosa_detect_client(struct i2c_adapter* adapter, int address, int kind) { @@ -238,6 +255,23 @@ static int tosa_detach_client(struct i2c_client* client) { return 0; } +unsigned long tosa_lcd_get_hsync_time(void) +{ +/* This method should eventually contain the correct algorithm for calculating + the hsync_time */ + if (blanked) + return 0; + else + return hsync_time; +} + +void tosa_lcd_wait_hsync(void) +{ + /* Waits for a rising edge on the VGA line */ + while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) == 0); + while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) != 0); +} + static struct i2c_driver tosa_driver={ .id = TOSA_LCD_I2C_DEVICEID, .attach_adapter = tosa_attach_adapter, diff --git a/drivers/input/touchscreen/tosa_ts.c b/drivers/input/touchscreen/tosa_ts.c index bc733e9..134f8ce 100644 --- a/drivers/input/touchscreen/tosa_ts.c +++ b/drivers/input/touchscreen/tosa_ts.c @@ -25,13 +25,6 @@ #define CCNT_ON() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1)) #define CCNT_OFF() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1)) -static inline void tosa_lcd_wait_hsync(void) -{ - /* Waits for a rising edge on the VGA line */ - while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) == 0); - while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) != 0); -} - /* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait * before sampling the Y axis of the touchscreen */ void tosa_lcd_sync_on(int adcsel) { @@ -54,7 +47,7 @@ void tosa_lcd_sync_on(int adcsel) { } } -void tosa_lcd_sync_off(void) { +void tosa_lcd_sync_off(int adcsel) { CCNT_OFF(); } diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h index ce7322d..7f446fd 100644 --- a/include/asm-arm/arch-pxa/tosa.h +++ b/include/asm-arm/arch-pxa/tosa.h @@ -1,6 +1,7 @@ /* * Hardware specific definitions for Sharp SL-C6000x series of PDAs * + * Copyright (c) 2006 Wolfson Microelectronics PLC. * Copyright (c) 2005 Dirk Opfer * * Based on Sharp's 2.4 kernel patches @@ -187,4 +188,8 @@ extern struct platform_device tosascoop_jc_device; extern struct platform_device tosascoop_device; extern struct platform_device tc6393_device; + +unsigned long tosa_lcd_get_hsync_time(void); +void tosa_lcd_wait_hsync(void); + #endif /* _ASM_ARCH_TOSA_H_ */ -- 1.4.4.4