From 70f570d89080f7382e2fc7418283b17066cd32e3 Mon Sep 17 00:00:00 2001
From: z3deverp <z3@vmsv-debian.(none)>
Date: Sun, 7 Jun 2009 11:32:10 +0900
Subject: [PATCH] support touchscreen(007 only), modify keyboard toggle-key mode

---
 arch/arm/mach-pxa/include/mach/sha_pon.h |   13 +-
 arch/arm/mach-pxa/sha_pon.c              |  238 ++++++++++++------------------
 drivers/input/keyboard/sha_ponkbd.c      |   13 ++-
 drivers/input/touchscreen/ads7846.c      |   27 +++-
 include/linux/spi/ads7846.h              |    4 +
 5 files changed, 141 insertions(+), 154 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/sha_pon.h b/arch/arm/mach-pxa/include/mach/sha_pon.h
index 5d69201..6e6775b 100755
--- a/arch/arm/mach-pxa/include/mach/sha_pon.h
+++ b/arch/arm/mach-pxa/include/mach/sha_pon.h
@@ -140,7 +140,6 @@ void sha_pon_gpio_bit_set(unsigned cpld_bitoffset, int value);
 #define SHA_PON_O_LED_10KEY3		(SHA_PON_GPIO_OFFSET_CPLD_W + 42)	/*I don't know what to use ;-) 0/1=?*/
 #define SHA_PON_O_VIBLATOR		(SHA_PON_GPIO_OFFSET_CPLD_W + 44)	/*Viblator: 0/1=OFF/ON*/
 
-#define SHA_PON007_O_USB_POWER		37	/*USB Host Power: 0/1=OFF/ON*/
 #define SHA_PON007_O_LED_FULLKEY	17	/*LED Fullkeyboard: 0/1=OFF/ON*/
 
 
@@ -159,20 +158,21 @@ void sha_pon_gpio_bit_set(unsigned cpld_bitoffset, int value);
 
 #define SHA_PON003_I_DET_USB_VBUS	103	/*USB VBUS detect: 0/1=yes/no*/
 #define SHA_PON007_I_DET_USB_VBUS	35	/*USB VBUS detect: 0/1=yes/no*/
+#define SHA_PON007_I_DET_USB_MiniA	41	/*USB miniA cable: 0/1=Inserted/Ejected*/
+#define SHA_PON011_I_DET_USB_MiniA	41	/*USB miniA cable: 0/1=Inserted/Ejected*/
+#define SHA_PON007_O_USB_POWER		37	/*USB Host Power: 0/1=OFF/ON*/
 
 #define SHA_PON003_I_DET_BATTERY	35	/*Battery: 0/1=Ejected/Inserted*/
 #define SHA_PON007_I_DET_BATTERY_1	11	/*Battery: 0/1=Ejected/Inserted*/
 #define SHA_PON007_I_DET_BATTERY_2	13	/*Battery: 0/1=Ejected/Inserted*/
 
-
+#define SHA_PON007_I_DET_HSYNC		75	/*L_LCLK_A0 at TFT LCD: 0/1=HSync Enable/Disable*/
 #define SHA_PON007_I_DET_TOUCHSCREEN	21	/*Touchscreen: 0/1=Pressed/Relesed*/
-#define SHA_PON007_I_DET_USB_MiniA	41	/*USB miniA cable: 0/1=Inserted/Ejected*/
+#define SHA_PON007_O_CS_TOUCHSCREEN	33	/*Touchscreen CS: 0/1=Enabel/Disable*/
+
 #define SHA_PON007_I_DET_HEADSET_ANSWER	114	/*Headset answer key: 0/1=pressed/released*/
 #define SHA_PON007_I_DET_HEADSET_CONNECT	116	/*Headset: 0/1=connected/not connected*/
 
-#define SHA_PON011_I_DET_USB_MiniA	41	/*USB miniA cable: 0/1=Inserted/Ejected*/
-
-
 
 #if 0	/* not understand what to do  */
 
@@ -254,7 +254,6 @@ void sha_pon_gpio_bit_set(unsigned cpld_bitoffset, int value);
 #define SHA_PON007_I_	20	/**/
 #define SHA_PON007_I_	22	/**/
 #define SHA_PON007_O_	23	/**/
-#define SHA_PON007_O_	33	/**/
 #define SHA_PON007_O_	34	/**/
 #define SHA_PON007_O_	36	/**/
 #define SHA_PON007_O_	39	/**/
diff --git a/arch/arm/mach-pxa/sha_pon.c b/arch/arm/mach-pxa/sha_pon.c
index 8c1122f..3db86d0 100755
--- a/arch/arm/mach-pxa/sha_pon.c
+++ b/arch/arm/mach-pxa/sha_pon.c
@@ -11,8 +11,6 @@
  * published by the Free Software Foundation.
  */
 
-#define	TS	0	/* 0:disable touchscreen driver */
-
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -20,6 +18,9 @@
 #include <linux/fb.h>
 #include <linux/delay.h>
 #include <linux/sysdev.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
+#include <linux/input.h>
 
 #include <asm/setup.h>
 #include <asm/memory.h>
@@ -34,6 +35,7 @@
 #include <mach/pxa2xx-regs.h>
 #include <mach/mfp-pxa27x.h>
 #include <mach/pxa27x-udc.h>
+#include <mach/pxa2xx_spi.h>
 #include <mach/pxafb.h>
 #include <mach/udc.h>
 #include <mach/ohci.h>
@@ -48,9 +50,6 @@
 #include "devices.h"
 
 #include <mach/sha_pon.h>
-#if TS
-#include "sha_pon.h"
-#endif
 
 
 /* CPLD as external GPIOs. */
@@ -402,13 +401,19 @@ static void sha_pon_init_usbport(void)
 	if( machine_is_sha_pon007() ) {
 		sha_pon_usbscanfunc = sha_pon007_usbscan;
 		sha_pon_usbpowerfunc = sha_pon007_usbpower;
-		sha_pon_usbpowerfunc( sha_pon_usbmode_now );
 	}
 	
 	if( machine_is_sha_pon011() ) {
 		sha_pon_usbscanfunc = sha_pon011_usbscan;
 	}
 	
+	if( machine_is_sha_pon020() ) {
+		/* FIXME */
+	}
+	
+	if( sha_pon_usbpowerfunc != NULL )
+		sha_pon_usbpowerfunc( sha_pon_usbmode_now );
+	
 	init_timer(&usb_timer);
 	mod_timer(&usb_timer, jiffies + USBSCAN_DISCONNECT);
 }
@@ -471,123 +476,111 @@ static struct pxafb_mach_info pxa_sharp_ws011sh = {
 };
 
 
-#if TS
-/* SSP Device */
-struct sha_ponssp_machinfo sha_pon003ssp_machinfo = {	/* not tested */
-        .port		= 2, /* guessed value */
-	.cs_tsc2046	= SHA_PON_GPIO_TSC2046_CS,
-	.clk_tsc2046	= 6, /* datasheet value : div >= source13MHz / dclk2.5MHz(max) = 5.2 */
-	.cs_unknown	= SHA_PON_GPIO_UNKNOWN_CS,
-};
+/*ssp, touchscreen*/
+#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER)
 
+#define	SHA_PON_SSP(n)	(n)	/* bus No. */
 
-struct sha_ponssp_machinfo sha_pon007ssp_machinfo = {
-        .port		= 2, /* guessed value */
-	.cs_tsc2046	= SHA_PON_GPIO_TSC2046_CS,
-	.clk_tsc2046	= 6, /* datasheet value : div >= source13MHz / dclk2.5MHz(max) = 5.2 */
-	.cs_unknown	= SHA_PON_GPIO_UNKNOWN_CS,
-};
-
+#define	SHA_PON007_TS_YMIN	140
+#define	SHA_PON007_TS_YMAX	3850
 
-struct sha_ponssp_machinfo sha_pon011ssp_machinfo = {	/* not tested */
-        .port		= 2, /* guessed value */
-	.cs_tsc2046	= SHA_PON_GPIO_TSC2046_CS,
-	.clk_tsc2046	= 6, /* datasheet value : div >= source13MHz / dclk2.5MHz(max) = 5.2 */
-	.cs_unknown	= SHA_PON_GPIO_UNKNOWN_CS,
-};
-
-
-struct platform_device sha_ponssp_device = {
-	.name		= "sha_pon-ssp",
-	.id		= -1,
-};
-
-
-/* Touch Screen Device */
-static int sha_pon003ts_status(void)
+static void sha_pon007_ts_remap_axis(u16 *x, u16 *y, unsigned *Rt)
 {
-	/* true:pendown, false:penup */
-	return( 0 );	/* FIXME */
+	if( *y < SHA_PON007_TS_YMIN ) {
+		*y = SHA_PON007_TS_YMIN;
+	}
+	if( *y > SHA_PON007_TS_YMAX ) {
+		*y = SHA_PON007_TS_YMAX;
+	}
+	
+	/* Invert Y-axis */
+	*y = SHA_PON007_TS_YMAX - *y + SHA_PON007_TS_YMIN;
 }
 
 
-static int sha_pon007ts_status(void)
+static void sha_pon007_wait_for_hsync(void)
 {
-	/* true:pendown, false:penup */
-	return( (GPLR(SHA_PON007_GPIO_TP) & GPIO_bit(SHA_PON007_GPIO_TP)) == 0 );
+	while( gpio_get_value(SHA_PON007_I_DET_HSYNC) )
+		cpu_relax();
+
+	while( !gpio_get_value(SHA_PON007_I_DET_HSYNC) )
+		cpu_relax();
 }
 
 
-static int sha_pon011ts_status(void)
+static struct ads7846_platform_data sha_pon007_tsc2046_info = {
+	.model			= 7846,
+	.vref_delay_usecs	= 100,
+
+	.x_min			= 160,
+	.x_max			= 3890,
+	.y_min			= SHA_PON007_TS_YMIN,
+	.y_max			= SHA_PON007_TS_YMAX,
+
+	.debounce_max		= 3,
+	.debounce_tol		= 3,
+	
+	.gpio_pendown		= SHA_PON007_I_DET_TOUCHSCREEN,
+	
+	.wait_for_sync		= sha_pon007_wait_for_hsync,
+	.remap_axis		= sha_pon007_ts_remap_axis,
+#if 0
+	.touch_button		= BTN_LEFT,	/* mouse compaible for test */
+#endif
+};
+
+static void sha_pon007_tsc2046_cs(u32 command)
 {
-	/* true:pendown, false:penup */
-	return( 0 );	/* FIXME */
+	gpio_set_value(SHA_PON007_O_CS_TOUCHSCREEN, !(command == PXA2XX_CS_ASSERT));
 }
 
-
-static struct platform_device sha_pon003ts_device = {
-	.name		= "sha_pon-ts",
-	.dev		= {
- 		.parent = &sha_ponssp_device.dev,
-		.platform_data	= sha_pon003ts_status,
-	},
-	.id		= -1,
+static struct pxa2xx_spi_chip sha_pon007_tsc2046_chip = {
+	.cs_control	= sha_pon007_tsc2046_cs,
 };
 
-static struct platform_device sha_pon007ts_device = {
-	.name		= "sha_pon-ts",
-	.dev		= {
- 		.parent = &sha_ponssp_device.dev,
-		.platform_data	= sha_pon007ts_status,
+
+static struct spi_board_info sha_pon007_spi_devices[] = {
+	{
+		.modalias	= "ads7846",	/* tsc2048 compatible */
+		.max_speed_hz	= 2000000,
+		.bus_num	= SHA_PON_SSP(2),
+		.chip_select	= 0,
+		.platform_data	= &sha_pon007_tsc2046_info,
+		.controller_data= &sha_pon007_tsc2046_chip,
+		.irq		= gpio_to_irq(SHA_PON007_I_DET_TOUCHSCREEN),
 	},
-	.id		= -1,
 };
 
-static struct platform_device sha_pon011ts_device = {
-	.name		= "sha_pon-ts",
-	.dev		= {
- 		.parent = &sha_ponssp_device.dev,
-		.platform_data	= sha_pon011ts_status,
-	},
-	.id		= -1,
+
+static struct pxa2xx_spi_master sha_pon007_spi_info = {
+	.num_chipselect	= ARRAY_SIZE(sha_pon007_spi_devices),
 };
-#endif
 
-/* W-SIM */
-static void sha_pon_powerup_wsim(void)
+
+static void __init sha_pon007_init_spi(void)
 {
-#if 0	/* comment out, because of 003 hanged. use /sys/class/gpio/xxx control. */
+	int err;
 
-	/*power off at sha_pon_init_cpld(). */
-	
-	mdelay(800*4);		/* tested value=800msec(min) --> margine factor=4 */
-	
-	/* Power-ON-reset W-SIM device as a modem connected to FFUART */
-	sha_pon_gpio_bit_set(SHA_PON_O_WSIM_POWER, 1);
+	err = gpio_request(SHA_PON007_O_CS_TOUCHSCREEN, "TSC2046_CS");
+	if (err)
+		return;
 
-#endif
+	gpio_direction_output(SHA_PON007_O_CS_TOUCHSCREEN, 1);
+
+	pxa2xx_set_spi_info( SHA_PON_SSP(2), &sha_pon007_spi_info);
+	spi_register_board_info(ARRAY_AND_SIZE(sha_pon007_spi_devices));
 }
 
+#else	/* defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER) */
+
+static inline void sha_pon007_init_spi(void) {}
+
+#endif	/* defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER) */
 
-/* USB gadget */
-static void sha_pon_udc_command(int cmd)
-{
-#if 0	/* replace to sha_pon_init_usbport() */
-	switch( cmd ) {
-	case PXA2XX_UDC_CMD_CONNECT:
-		/* enable USB port2, Differencial, Device mode, D+ Pullup(Full speed) */
-		UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
-		break;
-	case PXA2XX_UDC_CMD_DISCONNECT:
-		/* disable USB port2 */
-		UP2OCR = 0;
-		break;
-	}
-#endif
-}
 
+/* USB gadget */
 static struct pxa2xx_udc_mach_info sha_pon_udc_info = {
-	.udc_command = sha_pon_udc_command,
+	.udc_command = NULL,
 };
 
 
@@ -612,7 +605,7 @@ static struct pxaohci_platform_data sha_pon_usb_info = {
 /* MMC */
 static int sha_pon_mci_get_ro(struct device *dev)
 {
-	/* nimiSD or microSD do not have write-protect function */
+	/* miniSD or microSD do not have write-protect function */
 	return 0;	/* read/write */
 }
 
@@ -673,30 +666,8 @@ static struct platform_device sha_pon_led_device = {
 };
 
 
-static struct platform_device *devices003[] __initdata = {
+static struct platform_device *devices[] __initdata = {
 	&sha_ponkbd_device,
-#if TS
-	&sha_ponssp_device,
-	&sha_pon003ts_device,
-#endif
-	&sha_pon_led_device,
-};
-
-static struct platform_device *devices007[] __initdata = {
-	&sha_ponkbd_device,
-#if TS
-	&sha_ponssp_device,
-	&sha_pon007ts_device,
-#endif
-	&sha_pon_led_device,
-};
-
-static struct platform_device *devices011[] __initdata = {
-	&sha_ponkbd_device,
-#if TS
-	&sha_ponssp_device,
-	&sha_pon011ts_device,
-#endif
 	&sha_pon_led_device,
 };
 
@@ -716,17 +687,13 @@ static void __init sha_pon003_init(void)
 	set_pxa_fb_info(&sharp_ls037v7dw01);
 	pxa_set_udc_info(&sha_pon_udc_info);
 	pxa_set_ohci_info(&sha_pon_usb_info);
-#if TS
-	sha_pon_ssp_set_machinfo(&sha_pon003ssp_machinfo);
-#endif
+	sha_pon_init_usbport();
 	pxa_set_mci_info(&sha_pon_mmc_info);
 	pxa_set_camera_info(&sha_pon_camera_info);
 /*
 	pxa_set_ac97_info(&sha_pon_audio_info);
 */
-	platform_add_devices(devices003, ARRAY_SIZE(devices003));
-	sha_pon_init_usbport();
-	sha_pon_powerup_wsim();
+	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
 
@@ -734,20 +701,17 @@ static void __init sha_pon007_init(void)
 {
 	pxa2xx_mfp_config(ARRAY_AND_SIZE(sha_pon_mfp));
 	sha_pon_init_cpld();
+	sha_pon007_init_spi();
 	set_pxa_fb_info(&sharp_ls028v7pw01);
 	pxa_set_udc_info(&sha_pon_udc_info);
 	pxa_set_ohci_info(&sha_pon_usb_info);
-#if TS
-	sha_pon_ssp_set_machinfo(&sha_pon007ssp_machinfo);
-#endif
+	sha_pon_init_usbport();
 	pxa_set_mci_info(&sha_pon_mmc_info);
 	pxa_set_camera_info(&sha_pon_camera_info);
 /*
 	pxa_set_ac97_info(&sha_pon_audio_info);
 */
-	platform_add_devices(devices007, ARRAY_SIZE(devices007));
-	sha_pon_init_usbport();
-	sha_pon_powerup_wsim();
+	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
 
@@ -758,18 +722,14 @@ static void __init sha_pon011_init(void)
 	set_pxa_fb_info(&pxa_sharp_ws011sh);
 	pxa_set_udc_info(&sha_pon_udc_info);
 	pxa_set_ohci_info(&sha_pon_usb_info);
-#if TS
-	sha_pon_ssp_set_machinfo(&sha_pon011ssp_machinfo);
-#endif
+	sha_pon_init_usbport();
 	pxa_set_mci_info(&sha_pon_mmc_info);
 	pxa_set_camera_info(&sha_pon_camera_info);
 /*
 	pxa_set_ac97_info(&sha_pon_audio_info);
 	pxa_set_ficp_info(&sha_pon_irda_info);
 */
-	platform_add_devices(devices011, ARRAY_SIZE(devices011));
-	sha_pon_init_usbport();
-	sha_pon_powerup_wsim();
+	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
 
@@ -795,12 +755,6 @@ static void __init sha_pon_map_io(void)
 #endif
 
 
-#if TS
-#if 0	/* GPIO for detect touchscreen, default:input */
-	pxa_gpio_mode( SHA_PON007_GPIO_TP | GPIO_IN );	/* test for 007 */
-#endif
-#endif
-
 	/* initialize sleep mode regs (wake-up sources, etc) : NOT tested */
 /*
 	PGSR0 = 0x00008800;
diff --git a/drivers/input/keyboard/sha_ponkbd.c b/drivers/input/keyboard/sha_ponkbd.c
old mode 100644
new mode 100755
index 9e1fc89..9cb2e16
--- a/drivers/input/keyboard/sha_ponkbd.c
+++ b/drivers/input/keyboard/sha_ponkbd.c
@@ -11,6 +11,8 @@
  *
  */
 
+#define SHA_PONKBD_TOGGLE	1	/* ALT,CTRL,SHIFT 0/1=normal/toggle */
+
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/init.h>
@@ -79,6 +81,7 @@ struct sha_ponkbd {
 };
 
 
+#if SHA_PONKBD_TOGGLE
 static void sha_pon_clear_toggle(struct sha_ponkbd *sha_ponkbd)
 {
 	unsigned int col, i;
@@ -90,7 +93,7 @@ static void sha_pon_clear_toggle(struct sha_ponkbd *sha_ponkbd)
 		sha_ponkbd->kbdscan_toggle_state[col] = 0;
 	}
 }
-
+#endif
 
 /*
  * Toggle-keys : Shift, Ctrl, Fn(Alt)
@@ -119,6 +122,8 @@ static void sha_pon_report_col(struct sha_ponkbd *sha_ponkbd,
 					keycode, keycode, col, row );
 		}
 #endif
+
+#if SHA_PONKBD_TOGGLE
 		if(togglekey) {
 			if( changed && pressed ) {
 				input_report_key(sha_ponkbd->poll_dev->input, keycode, pressed);
@@ -144,6 +149,12 @@ static void sha_pon_report_col(struct sha_ponkbd *sha_ponkbd,
 				}
 			}
 		}
+#else
+		if( changed ) {
+			input_report_key(sha_ponkbd->poll_dev->input, keycode, pressed);
+		}
+#endif
+
 	}
 }
 
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
old mode 100644
new mode 100755
index 7c27c8b..f9326dd
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -127,6 +127,10 @@ struct ads7846 {
 	void			(*filter_cleanup)(void *data);
 	int			(*get_pendown_state)(void);
 	int			gpio_pendown;
+
+	void			(*wait_for_sync)(void);
+	void			(*remap_axis)(u16 *x, u16 *y, unsigned *Rt);
+	unsigned int		touch_button;
 };
 
 /* leave chip selected when we're done, for quicker re-select? */
@@ -308,7 +312,6 @@ static inline unsigned null_adjust(struct ads7846 *ts, ssize_t v)
 SHOW(temp0, temp0, null_adjust)		/* temp1_input */
 SHOW(temp1, temp1, null_adjust)		/* temp2_input */
 
-
 /* sysfs conventions report voltages in millivolts.  We can convert voltages
  * if we know vREF.  userspace may need to scale vAUX to match the board's
  * external resistors; we assume that vBATT only uses the internal ones.
@@ -511,6 +514,14 @@ static int get_pendown_state(struct ads7846 *ts)
 	return !gpio_get_value(ts->gpio_pendown);
 }
 
+static void null_wait_for_sync(void)
+{
+}
+
+static void null_remap_axis(u16 *x, u16 *y, unsigned *Rt)
+{
+}
+
 /*
  * PENIRQ only kicks the timer.  The timer only reissues the SPI transfer,
  * to retrieve touchscreen status.
@@ -575,6 +586,8 @@ static void ads7846_rx(void *ads)
 			Rt = 0;
 	}
 
+	ts->remap_axis(&x, &y, &Rt);
+
 	/* NOTE: We can't rely on the pressure to determine the pen down
 	 * state, even this controller has a pressure sensor.  The pressure
 	 * value can fluctuate for quite a while after lifting the pen and
@@ -587,7 +600,7 @@ static void ads7846_rx(void *ads)
 		struct input_dev *input = ts->input;
 
 		if (!ts->pendown) {
-			input_report_key(input, BTN_TOUCH, 1);
+			input_report_key(input, ts->touch_button, 1);
 			ts->pendown = 1;
 #ifdef VERBOSE
 			dev_dbg(&ts->spi->dev, "DOWN\n");
@@ -686,6 +699,7 @@ static void ads7846_rx_val(void *ads)
 	default:
 		BUG();
 	}
+	ts->wait_for_sync();
 	status = spi_async(ts->spi, m);
 	if (status)
 		dev_err(&ts->spi->dev, "spi_async --> %d\n",
@@ -704,7 +718,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle)
 		if (ts->pendown) {
 			struct input_dev *input = ts->input;
 
-			input_report_key(input, BTN_TOUCH, 0);
+			input_report_key(input, ts->touch_button, 0);
 			input_report_abs(input, ABS_PRESSURE, 0);
 			input_sync(input);
 
@@ -723,6 +737,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle)
 	} else {
 		/* pen is still down, continue with the measurement */
 		ts->msg_idx = 0;
+		ts->wait_for_sync();
 		status = spi_async(ts->spi, &ts->msg[0]);
 		if (status)
 			dev_err(&ts->spi->dev, "spi_async --> %d\n", status);
@@ -947,6 +962,10 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 		ts->penirq_recheck_delay_usecs =
 				pdata->penirq_recheck_delay_usecs;
 
+	ts->wait_for_sync = (pdata->wait_for_sync) ? : null_wait_for_sync;
+	ts->remap_axis = (pdata->remap_axis) ? : null_remap_axis;
+	ts->touch_button = (pdata->touch_button) ? : BTN_TOUCH;
+
 	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&spi->dev));
 
 	input_dev->name = "ADS784x Touchscreen";
@@ -954,7 +973,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 	input_dev->dev.parent = &spi->dev;
 
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+	input_dev->keybit[BIT_WORD(ts->touch_button)] = BIT_MASK(ts->touch_button);
 	input_set_abs_params(input_dev, ABS_X,
 			pdata->x_min ? : 0,
 			pdata->x_max ? : MAX_12BIT,
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
old mode 100644
new mode 100755
index 05eab2f..854522f
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -51,5 +51,9 @@ struct ads7846_platform_data {
 				 void **filter_data);
 	int	(*filter)	(void *filter_data, int data_idx, int *val);
 	void	(*filter_cleanup)(void *filter_data);
+
+	void	(*wait_for_sync)(void);
+	void	(*remap_axis)(u16 *x, u16 *y, unsigned *Rt);
+	unsigned int	touch_button;
 };
 
-- 
1.4.4.4

