conf/distro/jlime-donkey.conf : Added parted & Dialog to distro_rdepends
[vuplus_openembedded] / packages / linux / linux-openzaurus-2.6.18 / tosa-tmio-lcd-r9.patch
1 Index: linux-2.6.18/arch/arm/mach-pxa/Makefile
2 ===================================================================
3 --- linux-2.6.18.orig/arch/arm/mach-pxa/Makefile        2006-09-20 16:19:03.000000000 +0200
4 +++ linux-2.6.18/arch/arm/mach-pxa/Makefile     2006-09-20 16:19:03.000000000 +0200
5 @@ -17,7 +17,7 @@
6  obj-$(CONFIG_PXA_SHARP_Cxx00)  += spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o spitz_pm.o
7  obj-$(CONFIG_MACH_AKITA)       += akita-ioexp.o
8  obj-$(CONFIG_MACH_POODLE)      += poodle.o corgi_ssp.o sharpsl_pm.o poodle_pm.o
9 -obj-$(CONFIG_MACH_TOSA)         += tosa.o sharpsl_pm.o tosa_pm.o
10 +obj-$(CONFIG_MACH_TOSA)         += tosa.o sharpsl_pm.o tosa_pm.o tosa_lcd.o
11  obj-$(CONFIG_MACH_HX2750)      += hx2750.o hx2750_test.o
12  
13  # Support for blinky lights
14 Index: linux-2.6.18/arch/arm/mach-pxa/tosa_lcd.c
15 ===================================================================
16 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
17 +++ linux-2.6.18/arch/arm/mach-pxa/tosa_lcd.c   2006-09-20 16:19:03.000000000 +0200
18 @@ -0,0 +1,345 @@
19 +/*
20 + *  LCD / Backlight control code for Sharp SL-6000x (tosa)
21 + *
22 + *  Copyright (c) 2005         Dirk Opfer
23 + *
24 + *  This program is free software; you can redistribute it and/or modify
25 + *  it under the terms of the GNU General Public License version 2 as
26 + *  published by the Free Software Foundation.
27 + *
28 + */
29 +
30 +#include <linux/module.h>
31 +#include <linux/init.h>
32 +#include <linux/kernel.h>
33 +#include <linux/sched.h>
34 +#include <linux/slab.h>
35 +#include <linux/delay.h>
36 +#include <linux/platform_device.h>
37 +#include <linux/i2c.h>
38 +#include <linux/fb.h>
39 +
40 +#include <asm/mach/sharpsl_param.h>
41 +#include <asm/hardware.h>
42 +#include <asm/hardware/scoop.h>
43 +#include <asm/hardware/tmio.h>
44 +#include <asm/arch/ssp.h>
45 +#include <asm/arch/sharpsl.h>
46 +#include <asm/arch/tosa.h>
47 +#include <asm/arch/pxa-regs.h>
48 +
49 +#define        DAC_BASE        0x4e
50 +#define DAC_CH1                0
51 +#define DAC_CH2                1
52 +
53 +#define TG_REG0_VQV    0x0001
54 +#define TG_REG0_COLOR  0x0002
55 +#define TG_REG0_UD     0x0004
56 +#define TG_REG0_LR     0x0008
57 +#define COMADJ_DEFAULT         97
58 +#define TOSA_LCD_I2C_DEVICEID  0x4711                  // Fixme: new value
59 +
60 +static void tosa_lcd_tg_init(struct device *dev);
61 +static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode);
62 +static void tosa_lcd_tg_off(struct device *dev);
63 +static void tosa_set_backlight(int intensity);
64 +
65 +const static struct tmio_lcd_ops tosa_tc6393_lcd_ops = {
66 +       .init = tosa_lcd_tg_init,
67 +       .tg_on = tosa_lcd_tg_on,
68 +       .tg_off = tosa_lcd_tg_off,
69 +};
70 +
71 +static struct platform_device *tosabl_device;
72 +static struct i2c_driver tosa_driver;
73 +static struct i2c_client* tosa_i2c_dac;
74 +static int initialised;
75 +static int comadj;
76 +static int bl_intensity;
77 +static struct ssp_dev tosa_nssp_dev;
78 +static struct ssp_state tosa_nssp_state;
79 +static spinlock_t tosa_nssp_lock;
80 +
81 +static unsigned short normal_i2c[] = {
82 +       DAC_BASE,
83 +       I2C_CLIENT_END 
84 +};
85 +I2C_CLIENT_INSMOD;
86 +
87 +static struct corgibl_machinfo tosa_bl_machinfo = {
88 +       .max_intensity = 255,
89 +       .default_intensity = 68,
90 +       .limit_mask = 0x0b,
91 +       .set_bl_intensity = tosa_set_backlight,
92 +};
93 +
94 +int tosa_bl_intensity(void)
95 +{
96 +       return bl_intensity;
97 +}
98 +
99 +static void pxa_nssp_output(unsigned char reg, unsigned char data)
100 +{
101 +
102 +       unsigned long flag;
103 +       u32 dat = ( ((reg << 5) & 0xe0) | (data & 0x1f) );
104 +       spin_lock_irqsave(&tosa_nssp_lock, flag);
105 +
106 +       ssp_config(&tosa_nssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(128));
107 +       ssp_enable(&tosa_nssp_dev);
108 +
109 +       ssp_write_word(&tosa_nssp_dev,dat);
110 +
111 +       /* Read null data back from device to prevent SSP overflow */
112 +       ssp_read_word(&tosa_nssp_dev);
113 +       ssp_disable(&tosa_nssp_dev);
114 +       spin_unlock_irqrestore(&tosa_nssp_lock, flag);
115 +
116 +}
117 +
118 +static void tosa_set_backlight(int intensity)
119 +{
120 +       if (!tosa_i2c_dac)
121 +               return;
122 +
123 +       bl_intensity = intensity;
124 +       /* SetBacklightDuty */
125 +       i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH2, (unsigned char)intensity);
126 +
127 +       /* SetBacklightVR */
128 +       if (intensity)
129 +               set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_BL_C20MA);
130 +       else
131 +               reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_BL_C20MA);
132 +
133 +       /* bl_enable GP04=1 otherwise GP04=0*/
134 +       pxa_nssp_output(TG_GPODR2, intensity ? 0x01 : 0x00);    
135 +}
136 +
137 +static void tosa_lcd_tg_init(struct device *dev)
138 +{
139 +       /* L3V On */
140 +       set_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); 
141 +       mdelay(60);
142 +
143 +       /* TG On */
144 +       reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_TG_ON);
145 +       mdelay(60);
146 +
147 +       pxa_nssp_output(TG_TPOSCTL,0x00);       /* delayed 0clk TCTL signal for VGA */
148 +       pxa_nssp_output(TG_GPOSR,0x02);         /* GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL */
149 +}
150 +
151 +static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode)
152 +{
153 +       const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
154 +       pxa_nssp_output(TG_PNLCTL, value | (mode->yres == 320 ? 0 :  TG_REG0_VQV));
155 +
156 +       /* TG LCD pannel power up */
157 +       pxa_nssp_output(TG_PINICTL,0x4);
158 +       mdelay(50);
159 +
160 +       /* TG LCD GVSS */
161 +       pxa_nssp_output(TG_PINICTL,0x0);
162 +
163 +       if (!initialised)
164 +       {
165 +               /* after the pannel is powered up the first time, we can access the i2c bus */
166 +               /* so probe for the DAC */
167 +               i2c_add_driver(&tosa_driver);
168 +               initialised = 1;
169 +               mdelay(50);
170 +       }
171 +       if (tosa_i2c_dac)
172 +               /* set common voltage */
173 +               i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
174 +
175 +}
176 +
177 +static void tosa_lcd_tg_off(struct device *dev)
178 +{
179 +       /* TG LCD VHSA off */
180 +       pxa_nssp_output(TG_PINICTL,0x4);
181 +       mdelay(50);
182 +       
183 +       /* TG LCD signal off */
184 +       pxa_nssp_output(TG_PINICTL,0x6);
185 +       mdelay(50);
186 +       
187 +       /* TG Off */
188 +       set_tc6393_gpio(&tc6393_device.dev, TOSA_TC6393_TG_ON);
189 +       mdelay(100);
190 +       
191 +       /* L3V Off */
192 +       reset_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); 
193 +}
194 +
195 +static int tosa_detect_client(struct i2c_adapter* adapter, int address, int kind) {
196 +       int err = 0;
197 +
198 +       printk("Tosa-LCD: DAC detected address:0x%2.2x\n",address);
199 +       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA ))
200 +               goto ERROR0;
201 +
202 +       if (!(tosa_i2c_dac = (struct i2c_client*)kzalloc(sizeof(*tosa_i2c_dac), GFP_KERNEL))) {
203 +               err = -ENOMEM;
204 +               goto ERROR0;
205 +       }
206 +
207 +       //i2c_set_clientdata(tosa_i2c_dac, data);
208 +       tosa_i2c_dac->addr = address;
209 +       tosa_i2c_dac->adapter = adapter;
210 +       tosa_i2c_dac->driver = &tosa_driver;
211 +       tosa_i2c_dac->dev.parent = &tc6393_device.dev;
212 +       strcpy(tosa_i2c_dac->name, "tosa lcd");
213 +       if ((err = i2c_attach_client(tosa_i2c_dac)))
214 +               goto ERROR3;
215 +
216 +       /* Now i2c is ready, allocate the backlight device*/
217 +       tosabl_device = platform_device_alloc("corgi-bl", -1);
218 +       if (!tosabl_device) {
219 +               err = -ENOMEM;
220 +               goto ERROR4;
221 +       }
222 +
223 +       /* set parent device */
224 +       tosabl_device->dev.parent = &tosa_i2c_dac->dev;
225 +       tosabl_device->dev.platform_data  = &tosa_bl_machinfo;
226 +
227 +       err = platform_device_add(tosabl_device);
228 +
229 +       if (err)
230 +               platform_device_put(tosabl_device);
231 +
232 +       /* set common voltage */
233 +       i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
234 +
235 +       return 0;
236 +ERROR4:
237 +       i2c_detach_client(tosa_i2c_dac);
238 +ERROR3:
239 +       kfree(tosa_i2c_dac);
240 +ERROR0:
241 +       return err;
242 +}
243 +
244 +static int tosa_attach_adapter(struct i2c_adapter* adapter) {
245 +       return i2c_probe(adapter, &addr_data, &tosa_detect_client);
246 +}
247 +
248 +static int tosa_detach_client(struct i2c_client* client) {
249 +       int err;
250 +
251 +       if ((err = i2c_detach_client(client))) {
252 +               printk(KERN_ERR "tosa: Cannot deregister client\n");
253 +               return err;
254 +       }
255 +       kfree(client);
256 +       return 0;
257 +}
258 +
259 +static struct i2c_driver tosa_driver={
260 +       .id             = TOSA_LCD_I2C_DEVICEID,
261 +       .attach_adapter = tosa_attach_adapter,
262 +       .detach_client  = tosa_detach_client,
263 +};
264 +
265 +static int __init tosa_lcd_probe(struct platform_device *pdev)
266 +{
267 +       int ret;
268 +       spin_lock_init(&tosa_nssp_lock);
269 +
270 +       if (!pdev->dev.platform_data)
271 +               return -EINVAL;
272 +
273 +       /* Set Common Voltage */
274 +       comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj;
275 +
276 +       ret=ssp_init(&tosa_nssp_dev,2,0);
277 +
278 +       /* initialize SSP */
279 +       pxa_gpio_mode(GPIO83_NSSP_TX);
280 +       pxa_gpio_mode(GPIO81_NSSP_CLK_OUT);
281 +       pxa_gpio_mode(GPIO82_NSSP_FRM_OUT);
282 +
283 +       if (ret) 
284 +               printk(KERN_ERR "Unable to register NSSP handler!\n");
285 +       else {
286 +               struct tmio_lcd_ops* *tmio_ops = pdev->dev.platform_data;
287 +               ssp_disable(&tosa_nssp_dev);
288 +               initialised = 0;
289 +
290 +               /* Set the lcd functions */
291 +               *tmio_ops = (struct tmio_lcd_ops*) &tosa_tc6393_lcd_ops;
292 +       }
293 +
294 +       return ret;
295 +}
296 +
297 +static int tosa_lcd_remove(struct platform_device *pdev)
298 +{
299 +       /* delete the lcd functions */
300 +       struct tmio_lcd_ops* *tmio_ops = pdev->dev.platform_data;
301 +       *tmio_ops = NULL;
302 +       
303 +       ssp_exit(&tosa_nssp_dev);
304 +       
305 +       if (tosa_i2c_dac) {
306 +               i2c_detach_client(tosa_i2c_dac);
307 +               kfree(tosa_i2c_dac);
308 +       }
309 +
310 +       return 0;
311 +}
312 +
313 +#ifdef CONFIG_PM 
314 +
315 +static int tosa_lcd_suspend(struct platform_device *pdev, pm_message_t state)
316 +{
317 +       ssp_flush(&tosa_nssp_dev);
318 +       ssp_save_state(&tosa_nssp_dev,&tosa_nssp_state);
319 +       return 0;
320 +}
321 +
322 +static int tosa_lcd_resume(struct platform_device *pdev)
323 +{
324 +       printk("tosa_lcd_resume\n");
325 +       ssp_restore_state(&tosa_nssp_dev,&tosa_nssp_state);
326 +       ssp_enable(&tosa_nssp_dev);
327 +       printk("tosa_lcd_resume ok\n"); 
328 +       return 0;
329 +}
330 +#else
331 +
332 +#define tosa_lcd_suspend NULL
333 +#define tosa_lcd_resume NULL
334 +
335 +#endif
336 +
337 +
338 +static struct platform_driver tosalcd_driver = {
339 +       .probe          = tosa_lcd_probe,
340 +       .remove         = tosa_lcd_remove,
341 +       .suspend        = tosa_lcd_suspend,
342 +       .resume         = tosa_lcd_resume,
343 +       .driver         = {
344 +               .name           = "tosa-lcd",
345 +       },
346 +};
347 +
348 +static int __init tosa_lcd_init(void)
349 +{
350 +       return platform_driver_register(&tosalcd_driver);
351 +}
352 +
353 +static void __exit tosa_lcd_cleanup (void)
354 +{
355 +       platform_driver_unregister (&tosalcd_driver);
356 +}
357 +
358 +device_initcall(tosa_lcd_init);
359 +module_exit (tosa_lcd_cleanup);
360 +
361 +MODULE_DESCRIPTION ("Tosa LCD device");
362 +MODULE_AUTHOR ("Dirk Opfer");
363 +MODULE_LICENSE ("GPL v2");
364 Index: linux-2.6.18/arch/arm/mach-pxa/tosa.c
365 ===================================================================
366 --- linux-2.6.18.orig/arch/arm/mach-pxa/tosa.c  2006-09-20 16:19:03.000000000 +0200
367 +++ linux-2.6.18/arch/arm/mach-pxa/tosa.c       2006-09-20 16:19:31.000000000 +0200
368 @@ -24,6 +24,7 @@
369  #include <linux/mtd/partitions.h>
370  #include <linux/pm.h>
371  #include <linux/delay.h>
372 +#include <linux/fb.h>
373  
374  #include <asm/setup.h>
375  #include <asm/memory.h>
376 @@ -48,7 +49,6 @@
377  
378  #include "generic.h"
379  
380 -
381  /*
382   * SCOOP Device
383   */
384 @@ -345,7 +345,38 @@
385         .badblock_pattern = &tosa_tc6393_nand_bbt,
386  };
387  
388 -extern struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data;
389 +static struct fb_videomode tosa_tc6393_lcd_mode[] = {
390 +    {
391 +        .xres = 480,
392 +        .yres = 640,
393 +        .pixclock = 0x002cdf00,/* PLL divisor */
394 +        .left_margin = 0x004c,
395 +        .right_margin = 0x005b,
396 +        .upper_margin = 0x0001,
397 +        .lower_margin = 0x000d,
398 +        .hsync_len = 0x0002,
399 +        .vsync_len = 0x0001,
400 +        .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
401 +        .vmode = FB_VMODE_NONINTERLACED,
402 +    },{
403 +       .xres = 240,
404 +       .yres = 320,
405 +       .pixclock = 0x00e7f203,/* PLL divisor */
406 +       .left_margin = 0x0024,
407 +       .right_margin = 0x002f,
408 +       .upper_margin = 0x0001,
409 +       .lower_margin = 0x000d,
410 +       .hsync_len = 0x0002,
411 +       .vsync_len = 0x0001,
412 +       .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
413 +       .vmode = FB_VMODE_NONINTERLACED,
414 +}};
415 +
416 +struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data = {
417 +    .ops = NULL,
418 +    .modelist = tosa_tc6393_lcd_mode,
419 +    .num_modes = ARRAY_SIZE(tosa_tc6393_lcd_mode),
420 +};
421  
422  static struct tmio_cell tosa_tc6393_cells[] = {
423         {
424 @@ -384,6 +415,19 @@
425         .num_resources  = ARRAY_SIZE(tc6393_resources),
426         .resource       = tc6393_resources,
427  };
428 +EXPORT_SYMBOL (tc6393_device);
429 +
430 +/*
431 + * Tosa LCD / Backlight stuff
432 + */
433 +static struct platform_device tosalcd_device = {
434 +    .name      = "tosa-lcd",
435 +    .id                = -1,
436 +    .dev       = {
437 +       .parent = &tc6393_device.dev,
438 +       .platform_data = &tosa_tc6393_lcd_platform_data.ops,
439 +    },
440 +};
441  
442  static struct platform_device *devices[] __initdata = {
443         &tosascoop_device,
444 @@ -391,6 +435,7 @@
445         &tosakbd_device,
446         &tosaled_device,
447         &tc6393_device,
448 +       &tosalcd_device,
449  };
450  
451  static void tosa_poweroff(void)
452 Index: linux-2.6.18/arch/arm/mach-pxa/Kconfig
453 ===================================================================
454 --- linux-2.6.18.orig/arch/arm/mach-pxa/Kconfig 2006-09-20 16:19:03.000000000 +0200
455 +++ linux-2.6.18/arch/arm/mach-pxa/Kconfig      2006-09-20 16:19:03.000000000 +0200
456 @@ -129,7 +129,10 @@
457         bool "Enable Sharp SL-6000x (Tosa) Support"
458         depends PXA_SHARPSL_25x
459         select TOSHIBA_TC6393XB
460 -       select SHARPSL_PM       
461 +       select I2C
462 +       select I2C_PXA
463 +       select SHARPSL_PM
464 +       select PXA_SSP
465  
466  config PXA25x
467         bool