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
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
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
20 + * LCD / Backlight control code for Sharp SL-6000x (tosa)
22 + * Copyright (c) 2005 Dirk Opfer
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.
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>
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>
49 +#define DAC_BASE 0x4e
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
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);
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,
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;
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;
81 +static unsigned short normal_i2c[] = {
87 +static struct corgibl_machinfo tosa_bl_machinfo = {
88 + .max_intensity = 255,
89 + .default_intensity = 68,
91 + .set_bl_intensity = tosa_set_backlight,
94 +int tosa_bl_intensity(void)
96 + return bl_intensity;
99 +static void pxa_nssp_output(unsigned char reg, unsigned char data)
102 + unsigned long flag;
103 + u32 dat = ( ((reg << 5) & 0xe0) | (data & 0x1f) );
104 + spin_lock_irqsave(&tosa_nssp_lock, flag);
106 + ssp_config(&tosa_nssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(128));
107 + ssp_enable(&tosa_nssp_dev);
109 + ssp_write_word(&tosa_nssp_dev,dat);
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);
118 +static void tosa_set_backlight(int intensity)
123 + bl_intensity = intensity;
124 + /* SetBacklightDuty */
125 + i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH2, (unsigned char)intensity);
127 + /* SetBacklightVR */
129 + set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_BL_C20MA);
131 + reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_BL_C20MA);
133 + /* bl_enable GP04=1 otherwise GP04=0*/
134 + pxa_nssp_output(TG_GPODR2, intensity ? 0x01 : 0x00);
137 +static void tosa_lcd_tg_init(struct device *dev)
140 + set_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON);
144 + reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_TG_ON);
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 */
151 +static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode)
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));
156 + /* TG LCD pannel power up */
157 + pxa_nssp_output(TG_PINICTL,0x4);
161 + pxa_nssp_output(TG_PINICTL,0x0);
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);
172 + /* set common voltage */
173 + i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
177 +static void tosa_lcd_tg_off(struct device *dev)
179 + /* TG LCD VHSA off */
180 + pxa_nssp_output(TG_PINICTL,0x4);
183 + /* TG LCD signal off */
184 + pxa_nssp_output(TG_PINICTL,0x6);
188 + set_tc6393_gpio(&tc6393_device.dev, TOSA_TC6393_TG_ON);
192 + reset_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON);
195 +static int tosa_detect_client(struct i2c_adapter* adapter, int address, int kind) {
198 + printk("Tosa-LCD: DAC detected address:0x%2.2x\n",address);
199 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA ))
202 + if (!(tosa_i2c_dac = (struct i2c_client*)kzalloc(sizeof(*tosa_i2c_dac), GFP_KERNEL))) {
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)))
216 + /* Now i2c is ready, allocate the backlight device*/
217 + tosabl_device = platform_device_alloc("corgi-bl", -1);
218 + if (!tosabl_device) {
223 + /* set parent device */
224 + tosabl_device->dev.parent = &tosa_i2c_dac->dev;
225 + tosabl_device->dev.platform_data = &tosa_bl_machinfo;
227 + err = platform_device_add(tosabl_device);
230 + platform_device_put(tosabl_device);
232 + /* set common voltage */
233 + i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
237 + i2c_detach_client(tosa_i2c_dac);
239 + kfree(tosa_i2c_dac);
244 +static int tosa_attach_adapter(struct i2c_adapter* adapter) {
245 + return i2c_probe(adapter, &addr_data, &tosa_detect_client);
248 +static int tosa_detach_client(struct i2c_client* client) {
251 + if ((err = i2c_detach_client(client))) {
252 + printk(KERN_ERR "tosa: Cannot deregister client\n");
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,
265 +static int __init tosa_lcd_probe(struct platform_device *pdev)
268 + spin_lock_init(&tosa_nssp_lock);
270 + if (!pdev->dev.platform_data)
273 + /* Set Common Voltage */
274 + comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj;
276 + ret=ssp_init(&tosa_nssp_dev,2,0);
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);
284 + printk(KERN_ERR "Unable to register NSSP handler!\n");
286 + struct tmio_lcd_ops* *tmio_ops = pdev->dev.platform_data;
287 + ssp_disable(&tosa_nssp_dev);
290 + /* Set the lcd functions */
291 + *tmio_ops = (struct tmio_lcd_ops*) &tosa_tc6393_lcd_ops;
297 +static int tosa_lcd_remove(struct platform_device *pdev)
299 + /* delete the lcd functions */
300 + struct tmio_lcd_ops* *tmio_ops = pdev->dev.platform_data;
303 + ssp_exit(&tosa_nssp_dev);
305 + if (tosa_i2c_dac) {
306 + i2c_detach_client(tosa_i2c_dac);
307 + kfree(tosa_i2c_dac);
315 +static int tosa_lcd_suspend(struct platform_device *pdev, pm_message_t state)
317 + ssp_flush(&tosa_nssp_dev);
318 + ssp_save_state(&tosa_nssp_dev,&tosa_nssp_state);
322 +static int tosa_lcd_resume(struct platform_device *pdev)
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");
332 +#define tosa_lcd_suspend NULL
333 +#define tosa_lcd_resume NULL
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,
344 + .name = "tosa-lcd",
348 +static int __init tosa_lcd_init(void)
350 + return platform_driver_register(&tosalcd_driver);
353 +static void __exit tosa_lcd_cleanup (void)
355 + platform_driver_unregister (&tosalcd_driver);
358 +device_initcall(tosa_lcd_init);
359 +module_exit (tosa_lcd_cleanup);
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
369 #include <linux/mtd/partitions.h>
370 #include <linux/pm.h>
371 #include <linux/delay.h>
372 +#include <linux/fb.h>
374 #include <asm/setup.h>
375 #include <asm/memory.h>
385 .badblock_pattern = &tosa_tc6393_nand_bbt,
388 -extern struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data;
389 +static struct fb_videomode tosa_tc6393_lcd_mode[] = {
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,
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,
416 +struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data = {
418 + .modelist = tosa_tc6393_lcd_mode,
419 + .num_modes = ARRAY_SIZE(tosa_tc6393_lcd_mode),
422 static struct tmio_cell tosa_tc6393_cells[] = {
425 .num_resources = ARRAY_SIZE(tc6393_resources),
426 .resource = tc6393_resources,
428 +EXPORT_SYMBOL (tc6393_device);
431 + * Tosa LCD / Backlight stuff
433 +static struct platform_device tosalcd_device = {
434 + .name = "tosa-lcd",
437 + .parent = &tc6393_device.dev,
438 + .platform_data = &tosa_tc6393_lcd_platform_data.ops,
442 static struct platform_device *devices[] __initdata = {
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
457 bool "Enable Sharp SL-6000x (Tosa) Support"
458 depends PXA_SHARPSL_25x
459 select TOSHIBA_TC6393XB