Index: linux-2.6.15/arch/arm/mach-pxa/Makefile
===================================================================
--- linux-2.6.15.orig/arch/arm/mach-pxa/Makefile	2006-01-30 00:41:04.000000000 +0000
+++ linux-2.6.15/arch/arm/mach-pxa/Makefile	2006-01-30 00:41:47.000000000 +0000
@@ -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 tosa-power.o
+obj-$(CONFIG_MACH_TOSA)         += tosa.o tosa-power.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-01-30 00:41:47.000000000 +0000
@@ -0,0 +1,353 @@
+/*
+ *  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 <video/tc6393fb.h>
+
+#include <asm/hardware.h>
+#include <asm/arch/tosa.h>
+#include <asm/hardware/scoop.h>
+#include <asm/hardware/tc6393.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);
+
+static void tosa_i2c_init(void);
+static void tosa_lcd_tg_init(struct tc6393fb_par* par);
+static void tosa_lcd_tg_on(struct tc6393fb_par* par);
+static void tosa_lcd_tg_off(struct tc6393fb_par* par);
+
+
+static struct i2c_driver tosa_driver;
+static struct i2c_client* tosa_i2c_dac;
+static int initialised = 0;
+static int comadj;
+
+static unsigned short normal_i2c[] = {
+	DAC_BASE,
+	I2C_CLIENT_END };
+I2C_CLIENT_INSMOD;
+
+
+static struct platform_device tosabl_device = {
+	.name	= "tosa-bl",
+	.id	= -1,
+};
+
+static struct tc6393fb_tg_info tosa_lcdtg_info = {
+	.init	= tosa_lcd_tg_init,
+	.tg_on	= tosa_lcd_tg_on,
+	.tg_off	= tosa_lcd_tg_off,
+};
+
+static struct tc6393fb_mode tosa_fb_modes[] = {
+{
+	.xres		= 480,
+	.yres		= 640,
+	.reg_vhlin	= 0x03c0,	 // VHLIN
+        .reg_pldsa_h	= 0x0000,        // PLDSA display start address high
+        .reg_pldsa_l	= 0x0000,        // PLDSA display start address low
+        .reg_plpit_h	= 0x0000,        // PLPIT horizontal pixel high
+        .reg_plpit_l	= 0x03c0,        // PLPIT horizontal pixel low
+        .reg_plht	= 0x0289,        // PLHT  horizontal total
+        .reg_plhds	= 0x004e,        // PLHDS horizontal display start
+        .reg_plhss	= 0x0000,        // PLHSS H-sync start
+        .reg_plhse	= 0x0002,        // PLHSE H-sync end
+        .reg_plhpx	= 0x01e0,        // PLHPX Horizontal number of pixel
+        .reg_plvt	= 0x028f,        // PLVT  Vertical total
+        .reg_plvds	= 0x0002,        // PLVDS Vertical display start
+        .reg_plvss	= 0x0000,        // PLVSS V-sync start
+        .reg_plvse	= 0x0001,        // PLVSE V-sync end
+        .reg_misc	= 0x0003,        // MISC  RGB565 mode
+        .reg_plgmd	= 0x0001,        // PLGMD vram access enable
+        .reg_plcst	= 0x4007,        // PLCST
+        .reg_plmod	= 0x0003,        // PLMOD Sync polarity
+        .reg_pll10	= 0xdf00,
+        .reg_pll11	= 0x002c,
+},{
+	.xres		= 240,
+	.yres		= 320,
+	.reg_vhlin	= 0x01E0,	// VHLIN
+        .reg_pldsa_h	= 0x0000,        // PLDSA display start address high
+        .reg_pldsa_l	= 0x0000,        // PLDSA display start address low
+        .reg_plpit_h	= 0x0000,        // PLPIT horizontal pixel high
+        .reg_plpit_l	= 0x01E0,        // PLPIT horizontal pixel low
+        .reg_plht	= 0x0145,        // PLHT  horizontal total
+        .reg_plhds	= 0x0026,        // PLHDS horizontal display start
+        .reg_plhss	= 0x0000,        // PLHSS H-sync start
+        .reg_plhse	= 0x0002,        // PLHSE H-sync end
+        .reg_plhpx	= 0x00f0,        // PLHPX Horizontal number of pixel
+        .reg_plvt	= 0x014F,        // PLVT  Vertical total
+        .reg_plvds	= 0x0002,        // PLVDS Vertical display start
+        .reg_plvss	= 0x0000,        // PLVSS V-sync start
+        .reg_plvse	= 0x0001,        // PLVSE V-sync end
+        .reg_misc	= 0x0003,        // MISC  RGB565 mode
+        .reg_plgmd	= 0x0001,        // PLGMD vram access enable
+        .reg_plcst	= 0x4007,        // PLCST
+        .reg_plmod	= 0x0003,        // PLMOD Sync polarity
+        .reg_pll10	= 0xf203,
+        .reg_pll11	= 0x00e7,
+  },
+
+};
+
+static struct tc6393fb_mach_info tosa_fb_info = {
+        .tg             = &tosa_lcdtg_info,
+        .modelist	= &tosa_fb_modes[0],
+        .num_modes	= ARRAY_SIZE(tosa_fb_modes),
+	.fb_base	= (void*)TOSA_LCDC_PHYS,
+};
+
+static void tosa_i2c_init(void)
+{
+
+	if (!initialised)
+	{
+		i2c_add_driver(&tosa_driver);
+		initialised = 1;
+	}
+
+}
+
+int tosa_set_backlight(int intensity)
+{
+	if (!tosa_i2c_dac)
+		return -1;
+
+	//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
+
+	return 0;
+}
+
+
+static void tosa_lcd_tg_init(struct tc6393fb_par* par)
+{
+
+	// 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 tc6393fb_par* par)
+{
+
+	if ( par->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 tc6393fb_par* par)
+{
+	// 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;
+
+	return 0;
+}
+
+static int tosa_lcd_remove(struct device *dev)
+{
+	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 int __init tosa_lcd_early_init(void)
+{
+	set_tc6393_platform_data("tc6393-fb",&tosa_fb_info);
+	return 0;
+}
+
+arch_initcall(tosa_lcd_early_init);
+device_initcall(tosa_lcd_init);
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-01-30 00:41:47.000000000 +0000
@@ -0,0 +1,110 @@
+/*
+ *  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);
+
+}
+
+/*
+ *  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-01-30 00:41:04.000000000 +0000
+++ linux-2.6.15/arch/arm/mach-pxa/tosa.c	2006-01-30 00:42:51.000000000 +0000
@@ -305,14 +305,35 @@
 	.id		= -1,
 };
 
+/*
+ * 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,
 	&tosa_audio_device,
+	&tosanssp_device,
 	&tc6393_device,
 	&tosa_battery_device,
+	&tosalcd_device,
 };
 
 static void __init tosa_init(void)
Index: linux-2.6.15/include/asm-arm/arch-pxa/tosa.h
===================================================================
--- linux-2.6.15.orig/include/asm-arm/arch-pxa/tosa.h	2006-01-30 00:41:03.000000000 +0000
+++ linux-2.6.15/include/asm-arm/arch-pxa/tosa.h	2006-01-30 00:41:47.000000000 +0000
@@ -187,4 +187,5 @@
 extern struct platform_device tosascoop_jc_device;
 extern struct platform_device tosascoop_device;
 extern struct platform_device tc6393_device;
+extern struct platform_device tosabl_device;
 #endif /* _ASM_ARCH_TOSA_H_ */

