Index: linux-2.6.15/arch/arm/mach-pxa/Makefile
===================================================================
--- linux-2.6.15.orig/arch/arm/mach-pxa/Makefile	2006-03-21 19:54:42.466313424 +0100
+++ linux-2.6.15/arch/arm/mach-pxa/Makefile	2006-03-21 19:54:43.253193800 +0100
@@ -15,7 +15,7 @@
 obj-$(CONFIG_PXA_SHARP_Cxx00)	+= spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o spitz_pm.o
 obj-$(CONFIG_MACH_AKITA)	+= akita-ioexp.o
 obj-$(CONFIG_MACH_POODLE)	+= poodle.o
-obj-$(CONFIG_MACH_TOSA)         += tosa.o sharpsl_pm.o tosa_pm.o
+obj-$(CONFIG_MACH_TOSA)         += tosa.o sharpsl_pm.o tosa_pm.o tosa_lcd.o tosa_nssp.o ssp.o
 obj-$(CONFIG_MACH_HX2750)	+= hx2750.o hx2750_test.o
 
 # Support for blinky lights
Index: linux-2.6.15/arch/arm/mach-pxa/tosa_lcd.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.15/arch/arm/mach-pxa/tosa_lcd.c	2006-03-21 19:58:20.933101424 +0100
@@ -0,0 +1,324 @@
+/*
+ *  LCD / Backlight control code for Sharp SL-6000x (tosa)
+ *
+ *  Copyright (c) 2005		Dirk Opfer
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/fb.h>
+
+#include <asm/hardware.h>
+#include <asm/arch/tosa.h>
+#include <asm/arch/sharpsl.h>
+
+#include <asm/hardware/scoop.h>
+#include <asm/hardware/tmio.h>
+#include <asm/mach/sharpsl_param.h>
+#include <asm/arch/pxa-regs.h>
+
+
+
+#define	DAC_BASE	0x4e
+#define DAC_CH1		0
+#define DAC_CH2		1
+
+#define TG_REG0_VQV	0x0001
+#define TG_REG0_COLOR	0x0002
+#define TG_REG0_UD	0x0004
+#define TG_REG0_LR	0x0008
+#define COMADJ_DEFAULT 	97
+
+
+extern void pxa_nssp_output(unsigned char reg, unsigned char data);
+extern struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data;
+
+static void tosa_i2c_init(void);
+
+
+static void tosa_lcd_tg_init(struct device *dev);
+static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode);
+static void tosa_lcd_tg_off(struct device *dev);
+static void tosa_set_backlight(int intensity);
+
+static struct tmio_lcd_ops tosa_tc6393_lcd_ops = {
+	.init = tosa_lcd_tg_init,
+	.tg_on = tosa_lcd_tg_on,
+	.tg_off = tosa_lcd_tg_off,
+};
+
+static struct i2c_driver tosa_driver;
+static struct i2c_client* tosa_i2c_dac;
+static int initialised = 0;
+static int comadj;
+static int bl_intensity;
+
+static unsigned short normal_i2c[] = {
+	DAC_BASE,
+	I2C_CLIENT_END };
+I2C_CLIENT_INSMOD;
+
+static struct corgibl_machinfo tosa_bl_machinfo = {
+    .max_intensity = 255,
+    .default_intensity = 68,
+    .limit_mask = 0x0b,
+    .set_bl_intensity = tosa_set_backlight,
+};
+
+static void tosabl_release (struct device *dev)
+{
+}
+
+static struct platform_device tosabl_device = {
+	.name	= "corgi-bl",
+	.id	= -1,
+	.dev= {
+	    .release = tosabl_release,
+	    .platform_data  = &tosa_bl_machinfo,
+	},
+};
+
+
+int tosa_bl_intensity(void)
+{
+	return bl_intensity;
+}
+
+static void tosa_i2c_init(void)
+{
+	if (!initialised)
+	{
+		i2c_add_driver(&tosa_driver);
+		initialised = 1;
+	}
+}
+
+static void tosa_set_backlight(int intensity)
+{
+	if (!tosa_i2c_dac)
+		return;
+	bl_intensity = intensity;
+	//SetBacklightDuty	
+	i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH2, (unsigned char)intensity);
+
+	//SetBacklightVR
+	if (intensity) {
+		set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_BL_C20MA);
+	}
+
+	else {
+		reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_BL_C20MA);
+
+	}
+
+	//bl_enable
+	if( intensity)
+		pxa_nssp_output(TG_GPODR2, 0x01);	//GP04=1
+	else 
+		pxa_nssp_output(TG_GPODR2, 0x00);	//GP04=0
+}
+EXPORT_SYMBOL (tosa_set_backlight);
+
+static void tosa_lcd_tg_init(struct device *dev)
+{
+
+	// L3V On
+	set_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); 
+
+	// TG On
+	reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_TG_ON);
+
+	pxa_nssp_output(TG_TPOSCTL,0x00);	// delayed 0clk TCTL signal for VGA
+	pxa_nssp_output(TG_GPOSR,0x02);	// GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL
+
+}
+
+static void tosa_lcd_tg_on(struct device *dev, const struct fb_videomode *mode)
+{
+
+	if ( mode->yres == 320 )  // change to QVGA
+		pxa_nssp_output(TG_PNLCTL, TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR);
+	else
+		pxa_nssp_output(TG_PNLCTL, TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR | TG_REG0_VQV);
+
+
+	// TG LCD pannel power up
+	pxa_nssp_output(TG_PINICTL,0x4);		//tc6393fb_setpnlctl(0x4);
+	
+	mdelay(50);
+
+	// TG LCD GVSS
+	pxa_nssp_output(TG_PINICTL,0x0);		//tc6393fb_setpnlctl(0x0);
+
+	tosa_i2c_init();
+
+	mdelay(50);
+	
+	if (tosa_i2c_dac)
+		//set common voltage
+		i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
+
+}
+
+static void tosa_lcd_tg_off(struct device *dev)
+{
+	// TG LCD VHSA off
+	pxa_nssp_output(TG_PINICTL,0x4);		//tc6393fb_setpnlctl(0x4);
+	mdelay(50);
+	
+	// TG LCD signal off
+	pxa_nssp_output(TG_PINICTL,0x6);		//tc6393fb_setpnlctl(0x6);
+//	wait_vsync();
+	mdelay(50);
+	
+	// TG Off
+	set_tc6393_gpio(&tc6393_device.dev, TOSA_TC6393_TG_ON);
+
+	mdelay(120);
+	
+	// CLK: Stop
+//	FIXME	
+//	tc6393_writew((u16)(0x0), remapped_lcdbase + KH_CLKEN);
+	mdelay(100);
+	
+	// L3V Off
+	reset_scoop_gpio( &tosascoop_jc_device.dev,TOSA_SCOOP_JC_TC3693_L3V_ON); 
+}
+
+
+
+static int tosa_detect_client(struct i2c_adapter* adapter, int address, int kind) {
+	int err = 0;
+
+	printk("Tosa-LCD: DAC detected address:0x%2.2x\n",address);
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA ))
+		goto ERROR0;
+
+	if (!(tosa_i2c_dac = (struct i2c_client*)kmalloc(sizeof(*tosa_i2c_dac),
+			GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto ERROR0;
+	}
+
+	memset(tosa_i2c_dac, 0, sizeof(*tosa_i2c_dac));
+	//i2c_set_clientdata(tosa_i2c_dac, data);
+	tosa_i2c_dac->addr = address;
+	tosa_i2c_dac->adapter = adapter;
+	tosa_i2c_dac->driver = &tosa_driver;
+	tosa_i2c_dac->dev.parent = &tc6393_device.dev;
+	tosa_i2c_dac->flags = 0;
+	strcpy(tosa_i2c_dac->name, "tosa lcd");
+	if ((err = i2c_attach_client(tosa_i2c_dac)))
+		goto ERROR3;
+	
+	// Set parent
+	tosabl_device.dev.parent = &tosa_i2c_dac->dev;
+	platform_device_register(&tosabl_device);	
+
+	//set common voltage
+	i2c_smbus_write_byte_data(tosa_i2c_dac, DAC_CH1, comadj);
+	
+	return 0;
+//ERROR4:;
+	i2c_detach_client(tosa_i2c_dac);
+ERROR3:;
+	kfree(tosa_i2c_dac);
+ERROR0:;
+	return err;
+}
+
+static int tosa_attach_adapter(struct i2c_adapter* adapter) {
+
+	return i2c_probe(adapter, &addr_data, &tosa_detect_client);
+}
+
+static int tosa_detach_client(struct i2c_client* client) {
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		printk(KERN_ERR "tosa: Cannot deregister client\n");
+		return err;
+	}
+	kfree(client);
+	return 0;
+}
+
+static int tosa_command(struct i2c_client* client, unsigned int cmd, void* arg) {
+	return -ENOIOCTLCMD;	/* or -EINVAL, depends on who will call this */
+}
+
+static struct i2c_driver tosa_driver={
+//	.owner		= THIS_MODULE,
+//	.name		= "tosa",
+	.id		= 0x4711,				// FIXME: value
+//	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= tosa_attach_adapter,
+	.detach_client	= tosa_detach_client,
+	.command	= tosa_command,
+};
+
+
+static int tosa_lcd_probe(struct device *dev)
+{
+	/* Set Common Voltage */
+	comadj = -1;
+	comadj = sharpsl_param.comadj;;
+
+	if ( comadj < 0 ) {
+		comadj = COMADJ_DEFAULT;
+	}
+
+	initialised = 0;
+
+	tosa_tc6393_lcd_platform_data.ops = &tosa_tc6393_lcd_ops;
+	
+	return 0;
+}
+
+static int tosa_lcd_remove(struct device *dev)
+{
+	tosa_tc6393_lcd_platform_data.ops = NULL;
+	
+	if (tosa_i2c_dac) {
+		i2c_detach_client(tosa_i2c_dac);
+		kfree(tosa_i2c_dac);
+	}
+
+	return 0;
+}
+
+
+static struct device_driver tosalcd_driver = {
+	.name		= "tosa-lcd",
+	.bus		= &platform_bus_type,
+	.probe		= tosa_lcd_probe,
+	.remove		= tosa_lcd_remove,
+};
+
+static int __init tosa_lcd_init(void)
+{
+	return driver_register(&tosalcd_driver);
+}
+
+static void __exit tosa_lcd_cleanup (void)
+{
+	driver_unregister (&tosalcd_driver);
+}
+
+device_initcall(tosa_lcd_init);
+module_exit (tosa_lcd_cleanup);
+
+MODULE_DESCRIPTION ("Tosa LCD device");
+MODULE_AUTHOR ("Dirk Opfer");
+MODULE_LICENSE ("GPL v2");
Index: linux-2.6.15/arch/arm/mach-pxa/tosa_nssp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.15/arch/arm/mach-pxa/tosa_nssp.c	2006-03-21 19:54:43.254193648 +0100
@@ -0,0 +1,111 @@
+/*
+ *  NSSP control code for Sharp SL-6000x (tosa)
+ *
+ *  Copyright (c) 2005		Dirk Opfer
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <asm/hardware.h>
+
+#include <asm/arch/ssp.h>
+#include <asm/arch/tosa.h>
+#include <asm/arch/pxa-regs.h>
+
+
+
+static spinlock_t tosa_nssp_lock;
+static struct ssp_dev tosa_nssp_dev;
+static struct ssp_state tosa_nssp_state;
+
+void pxa_nssp_output(unsigned char reg, unsigned char data)
+{
+	unsigned long flag;
+	u32 dat = ( ((reg << 5) & 0xe0) | (data & 0x1f) );
+
+	spin_lock_irqsave(&tosa_nssp_lock, flag);
+
+	ssp_config(&tosa_nssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(128));
+	ssp_enable(&tosa_nssp_dev);
+
+	ssp_write_word(&tosa_nssp_dev,dat);
+
+	/* Read null data back from device to prevent SSP overflow */
+	ssp_read_word(&tosa_nssp_dev);
+	ssp_disable(&tosa_nssp_dev);
+
+	spin_unlock_irqrestore(&tosa_nssp_lock, flag);
+
+}
+EXPORT_SYMBOL (pxa_nssp_output);
+
+/*
+ *  Support Routines
+ */
+int __init tosa_nssp_probe(struct device *dev)
+{
+	int ret;
+	
+	spin_lock_init(&tosa_nssp_lock);
+
+	ret=ssp_init(&tosa_nssp_dev,2,0);
+
+	/* initialize SSP */
+	pxa_gpio_mode(GPIO83_NSSP_TX);
+	pxa_gpio_mode(GPIO81_NSSP_CLK_OUT);
+	pxa_gpio_mode(GPIO82_NSSP_FRM_OUT);
+
+	if (ret)
+		printk(KERN_ERR "Unable to register NSSP handler!\n");
+	else {
+		ssp_disable(&tosa_nssp_dev);
+	}
+
+	return ret;
+}
+
+static int tosa_nssp_remove(struct device *dev)
+{
+	ssp_exit(&tosa_nssp_dev);
+	return 0;
+}
+
+static int tosa_nssp_suspend(struct device *dev, pm_message_t state)
+{
+	ssp_flush(&tosa_nssp_dev);
+	ssp_save_state(&tosa_nssp_dev,&tosa_nssp_state);
+	return 0;
+}
+
+static int tosa_nssp_resume(struct device *dev)
+{
+	ssp_restore_state(&tosa_nssp_dev,&tosa_nssp_state);
+	ssp_enable(&tosa_nssp_dev);
+	return 0;
+}
+
+static struct device_driver tosa_nssp_driver = {
+	.name		= "tosa-nssp",
+	.bus		= &platform_bus_type,
+	.probe		= tosa_nssp_probe,
+	.remove		= tosa_nssp_remove,
+	.suspend	= tosa_nssp_suspend,
+	.resume		= tosa_nssp_resume,
+};
+
+int __init tosa_nssp_init(void)
+{
+	return driver_register(&tosa_nssp_driver);
+}
+
+arch_initcall(tosa_nssp_init);
Index: linux-2.6.15/arch/arm/mach-pxa/tosa.c
===================================================================
--- linux-2.6.15.orig/arch/arm/mach-pxa/tosa.c	2006-03-21 19:54:41.315488376 +0100
+++ linux-2.6.15/arch/arm/mach-pxa/tosa.c	2006-03-21 19:54:43.255193496 +0100
@@ -22,6 +22,7 @@
 #include <linux/mmc/host.h>
 #include <linux/mtd/nand.h> 
 #include <linux/mtd/partitions.h> 
+#include <linux/fb.h>
 
 #include <asm/setup.h>
 #include <asm/memory.h>
@@ -73,7 +74,7 @@
 	.num_resources	= ARRAY_SIZE(tosa_scoop_resources),
 	.resource	= tosa_scoop_resources,
 };
-
+EXPORT_SYMBOL (tosascoop_device);
 
 /*
  * SCOOP Device Jacket
@@ -101,6 +102,7 @@
 	.num_resources	= ARRAY_SIZE(tosa_scoop_jc_resources),
 	.resource	= tosa_scoop_jc_resources,
 };
+EXPORT_SYMBOL (tosascoop_jc_device);
 
 /*
  * PCMCIA
@@ -338,7 +340,39 @@
 	.badblock_pattern = &tosa_tc6393_nand_bbt,
 };
 
-extern struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data;
+static struct fb_videomode tosa_tc6393_lcd_mode[] = {
+    {
+        .xres= 480,
+        .yres= 640,
+        .pixclock= 0x002cdf00,/* PLL divisor */
+        .left_margin= 0x004c,
+        .right_margin= 0x005b,
+        .upper_margin= 0x0001,
+        .lower_margin= 0x000d,
+        .hsync_len= 0x0002,
+        .vsync_len= 0x0001,
+        .sync= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+        .vmode= FB_VMODE_NONINTERLACED,
+    },{
+	.xres= 240,
+	.yres= 320,
+	.pixclock= 0x00e7f203,/* PLL divisor */
+	.left_margin= 0x0024,
+	.right_margin= 0x002f,
+	.upper_margin= 0x0001,
+	.lower_margin= 0x000d,
+	.hsync_len= 0x0002,
+	.vsync_len= 0x0001,
+	.sync= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+	.vmode= FB_VMODE_NONINTERLACED,
+}};
+
+struct tmio_lcd_platform_data tosa_tc6393_lcd_platform_data = {
+    .ops= NULL,
+    .modelist= tosa_tc6393_lcd_mode,
+    .num_modes= ARRAY_SIZE(tosa_tc6393_lcd_mode),
+};
+EXPORT_SYMBOL (tosa_tc6393_lcd_platform_data);
 
 static struct tmio_cell tosa_tc6393_cells[] = {
 	{
@@ -378,13 +412,35 @@
 	.num_resources	= ARRAY_SIZE(tc6393_resources),
 	.resource	= tc6393_resources,
 };
+EXPORT_SYMBOL (tc6393_device);
+
+/*
+ * Tosa LCD / Backlight stuff
+ */
+static struct platform_device tosanssp_device = {
+    .name	= "tosa-nssp",
+    .id		= -1,
+    .dev	= {
+	.parent	= &tosascoop_jc_device.dev,
+     },
+};
+
+static struct platform_device tosalcd_device = {
+    .name	= "tosa-lcd",
+    .id		= -1,
+    .dev	= {
+	.parent	= &tc6393_device.dev,
+    },
+};
 
 static struct platform_device *devices[] __initdata = {
 	&tosascoop_device,
 	&tosascoop_jc_device,
 	&tosakbd_device,
 	&tosaled_device,
+	&tosanssp_device,
 	&tc6393_device,
+	&tosalcd_device,
 };
 
 static void __init tosa_init(void)
Index: linux-2.6.15/arch/arm/mach-pxa/Kconfig
===================================================================
--- linux-2.6.15.orig/arch/arm/mach-pxa/Kconfig	2006-03-21 19:54:42.467313272 +0100
+++ linux-2.6.15/arch/arm/mach-pxa/Kconfig	2006-03-21 19:54:43.256193344 +0100
@@ -103,6 +103,8 @@
 	bool "Enable Sharp SL-6000x (Tosa) Support"
 	depends PXA_SHARPSL_25x
 	select TOSHIBA_TC6393XB
+	select I2C
+	select I2C_PXA
 	select SHARPSL_PM	
 
 config PXA25x

