merge of 425cf1b391611c169a1c3b78f1fe86df088902b9
[vuplus_openembedded] / packages / linux / linux-rp-2.6.17 / tosa-lcdnoise-r0.patch
1 Index: linux-tosa/arch/arm/mach-pxa/tosa.c
2 ===================================================================
3 --- linux-tosa.orig/arch/arm/mach-pxa/tosa.c    2006-08-29 16:52:59.000000000 +0100
4 +++ linux-tosa/arch/arm/mach-pxa/tosa.c 2006-08-29 16:55:25.959706776 +0100
5 @@ -2,6 +2,7 @@
6   *  Support for Sharp SL-C6000x PDAs
7   *  Model: (Tosa)
8   *
9 + *  Copyright (c) 2006 Wolfson Microelectronics PLC.
10   *  Copyright (c) 2005 Dirk Opfer
11   *
12   *     Based on code written by Sharp/Lineo for 2.4 kernels
13 @@ -46,6 +47,8 @@
14  #include <asm/hardware/tmio.h>
15  #include <asm/mach/sharpsl_param.h>
16  
17 +#include <linux/wm97xx.h>
18 +
19  #include "generic.h"
20  
21  /*
22 @@ -428,6 +431,16 @@
23      },
24  };
25  
26 +
27 +/*
28 + * Tosa Touchscreen device
29 + */
30 +
31 +static struct wm97xx_machinfo tosa_ts_machinfo = {
32 +    .get_hsync_time   = tosa_get_hsync_time,
33 +    .wait_hsync       = tosa_wait_hsync,
34 +};
35 +
36  /*
37   * Tosa Blueooth
38   */
39 @@ -457,6 +470,7 @@
40         GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET);
41  
42         mdelay(1000);
43 +    wm97xx_unset_machinfo();
44  }
45  
46  static void tosa_restart(void)
47 @@ -501,6 +515,8 @@
48         platform_scoop_config = &tosa_pcmcia_config;
49  
50         platform_add_devices(devices, ARRAY_SIZE(devices));
51 +
52 +    wm97xx_set_machinfo(&tosa_ts_machinfo);
53  }
54  
55  static void __init fixup_tosa(struct machine_desc *desc,
56 Index: linux-tosa/arch/arm/mach-pxa/tosa_lcd.c
57 ===================================================================
58 --- linux-tosa.orig/arch/arm/mach-pxa/tosa_lcd.c        2006-08-29 16:52:59.000000000 +0100
59 +++ linux-tosa/arch/arm/mach-pxa/tosa_lcd.c     2006-08-29 16:55:32.818664056 +0100
60 @@ -1,6 +1,7 @@
61  /*
62   *  LCD / Backlight control code for Sharp SL-6000x (tosa)
63   *
64 + *  Copyright (c) 2006      Wolfson Microelectronics PLC.
65   *  Copyright (c) 2005         Dirk Opfer
66   *
67   *  This program is free software; you can redistribute it and/or modify
68 @@ -59,6 +60,8 @@
69  static struct ssp_dev tosa_nssp_dev;
70  static struct ssp_state tosa_nssp_state;
71  static spinlock_t tosa_nssp_lock;
72 +static int blanked;
73 +static unsigned long hsync_time;
74  
75  static unsigned short normal_i2c[] = {
76         DAC_BASE,
77 @@ -130,6 +133,17 @@
78         pxa_nssp_output(TG_GPOSR,0x02);         /* GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL */
79  }
80  
81 +static unsigned long calc_hsync_time(const struct fb_videomode *mode) {
82 +    /* The 25 and 44 'magic numbers' are from Sharp's 2.4 patches */
83 +    if (mode->yres == 640) {
84 +        return 25;
85 +    }
86 +    if (mode->yres == 320) {
87 +        return 44;
88 +    }
89 +    return 0;
90 +}
91 +
92  static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode)
93  {
94         const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
95 @@ -154,6 +168,8 @@
96                 /* set common voltage */
97                 i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
98  
99 +    blanked = 0;
100 +    hsync_time = calc_hsync_time(mode);
101  }
102  
103  static void tosa_lcd_tg_off(struct device *dev)
104 @@ -172,6 +188,8 @@
105         
106         /* L3V Off */
107         reset_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); 
108 +
109 +    blanked = 1;
110  }
111  
112  static int tosa_detect_client(struct i2c_adapter* adapter, int address, int kind) {
113 @@ -238,6 +256,23 @@
114         return 0;
115  }
116  
117 +unsigned long tosa_get_hsync_time(void)
118 +{
119 +/* This method should eventually contain the correct algorithm for calculating
120 +   the hsync_time */
121 +    if (blanked)
122 +        return 0;
123 +    else
124 +        return hsync_time;
125 +}
126 +
127 +void tosa_wait_hsync(void)
128 +{
129 +    /* Waits for a rising edge on the VGA line */
130 +    while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) == 0);
131 +    while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) != 0);
132 +}
133 +
134  static struct i2c_driver tosa_driver={
135         .id             = TOSA_LCD_I2C_DEVICEID,
136         .attach_adapter = tosa_attach_adapter,
137 Index: linux-tosa/include/asm-arm/arch-pxa/tosa.h
138 ===================================================================
139 --- linux-tosa.orig/include/asm-arm/arch-pxa/tosa.h     2006-08-29 16:52:59.000000000 +0100
140 +++ linux-tosa/include/asm-arm/arch-pxa/tosa.h  2006-08-29 16:55:12.442761664 +0100
141 @@ -1,6 +1,7 @@
142  /*
143   * Hardware specific definitions for Sharp SL-C6000x series of PDAs
144   *
145 + * Copyright (c) 2006 Wolfson Microelectronics PLC.
146   * Copyright (c) 2005 Dirk Opfer
147   *
148   * Based on Sharp's 2.4 kernel patches
149 @@ -187,4 +188,8 @@
150  extern struct platform_device tosascoop_jc_device;
151  extern struct platform_device tosascoop_device;
152  extern struct platform_device tc6393_device;
153 +
154 +unsigned long tosa_get_hsync_time(void);
155 +void tosa_wait_hsync(void);
156 +
157  #endif /* _ASM_ARCH_TOSA_H_ */