Skip to contentSkip to conversation

TSC2046 toucscreen support

PATCH In review Kevin Hilman 4 participants 11 messages May 4, 2007 – May 8, 2007 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover TSC2046 toucscreen support

Here is support for the TSC2046 touchscreen controller which is on the OMAP2430SDP board. It also includes a patch to add debounce support to the GPIO layer.

Note that SPI driver-model hook-ups are done in the touchscreen driver instead of a separate tsc2046 layer in drivers/spi. It seemed overkill to have drivers/spi/tsc2046.c with only a probe and remove function, so I included them in drivers/input/touchscreen/tsc2046_ts.c.

Kevin

--

#1 lore raw

PATCH 1/2 ARM: OMAP: add 24xx GPIO debounce support

---
 arch/arm/plat-omap/gpio.c        |   39 +++++++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-omap/gpio.h |    5 +++++
 2 files changed, 44 insertions(+)
arch/arm/plat-omap/gpio.c +39 -0
Index: dev/arch/arm/plat-omap/gpio.c
===================================================================
@@ -111,6 +111,8 @@
 #define OMAP24XX_GPIO_LEVELDETECT1	0x0044
 #define OMAP24XX_GPIO_RISINGDETECT	0x0048
 #define OMAP24XX_GPIO_FALLINGDETECT	0x004c
+#define OMAP24XX_GPIO_DEBOUNCE_EN	0x0050
+#define OMAP24XX_GPIO_DEBOUNCE_VAL	0x0054
 #define OMAP24XX_GPIO_CLEARIRQENABLE1	0x0060
 #define OMAP24XX_GPIO_SETIRQENABLE1	0x0064
 #define OMAP24XX_GPIO_CLEARWKUENA	0x0080
@@ -484,6 +486,43 @@ static inline void set_24xx_gpio_trigger
 	/* FIXME: Possibly do 'set_irq_handler(j, handle_level_irq)' if only level
 	 * triggering requested. */
 }
+
+void
+omap_set_gpio_debounce(int gpio, int enable)
+{
+	struct gpio_bank *bank;
+	void __iomem *reg;
+	u32 val, l = 1 << get_gpio_index(gpio);
+
+	bank = get_gpio_bank(gpio);
+	reg = bank->base;
+
+	reg += OMAP24XX_GPIO_DEBOUNCE_EN;
+	val = __raw_readl(reg);
+
+	if (enable)
+		val |= l;
+	else
+		val &= ~l;
+
+	__raw_writel(val, reg);
+}
+EXPORT_SYMBOL(omap_set_gpio_debounce);
+
+void
+omap_set_gpio_debounce_time(int gpio, int enc_time)
+{
+	struct gpio_bank *bank;
+	void __iomem *reg;
+
+	bank = get_gpio_bank(gpio);
+	reg = bank->base;
+
+	enc_time &= 0xff;
+	reg += OMAP24XX_GPIO_DEBOUNCE_VAL;
+	__raw_writel(enc_time, reg);
+}
+EXPORT_SYMBOL(omap_set_gpio_debounce_time);
 #endif
 
 static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
include/asm-arm/arch-omap/gpio.h +5 -0
Index: dev/include/asm-arm/arch-omap/gpio.h
===================================================================
@@ -78,6 +78,11 @@ extern int omap_get_gpio_datain(int gpio
 extern void omap2_gpio_prepare_for_retention(void);
 extern void omap2_gpio_resume_after_retention(void);
 
+#ifdef CONFIG_ARCH_OMAP24XX
+extern void omap_set_gpio_debounce(int gpio, int enable);
+extern void omap_set_gpio_debounce_time(int gpio, int enable);
+#endif
+
 /*-------------------------------------------------------------------------*/
 
 /* wrappers for "new style" GPIO calls. the old OMAP-specfic ones should

--

#2 lore raw

PATCH 2/2 ARM: OMAP: TSC2046 touchscreen support for 2430

In reply to Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

---
 arch/arm/mach-omap2/board-2430sdp.c    |   32 +
 drivers/input/touchscreen/Kconfig      |    6 
 drivers/input/touchscreen/Makefile     |    1 
 drivers/input/touchscreen/tsc2046_ts.c |  555 +++++++++++++++++++++++++++++++++
 include/linux/spi/tsc2046.h            |   60 +++
 5 files changed, 654 insertions(+)
arch/arm/mach-omap2/board-2430sdp.c +32 -0
Index: dev/arch/arm/mach-omap2/board-2430sdp.c
===================================================================
@@ -21,6 +21,8 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2046.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -33,6 +35,7 @@
 #include <asm/arch/board.h>
 #include <asm/arch/common.h>
 #include <asm/arch/gpmc.h>
+#include <asm/arch/mcspi.h>
 #include "prcm-regs.h"
 
 #include <asm/io.h>
@@ -40,6 +43,9 @@
 #define	SDP2430_FLASH_CS	0
 #define	SDP2430_SMC91X_CS	5
 
+/* TSC2046 (touchscreen) */
+#define TS_GPIO                 24
+
 static struct mtd_partition sdp2430_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	{
@@ -119,6 +125,29 @@ static struct platform_device *sdp2430_d
 	&sdp2430_flash_device,
 };
 
+static struct tsc2046_platform_data tsc2046_config = {
+	.dav_gpio       = TS_GPIO,
+	.gpio_debounce  = 0xa,
+};
+
+static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
+	.turbo_mode	= 0,
+	.single_channel = 0,  /* 0: slave, 1: master */
+};
+
+static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
+	[0] = {
+		/* TSC2046 operates at a max freqency of 2MHz, so
+		 * operate slightly below at 1.5MHz */
+		.modalias	= "tsc2046",
+		.bus_num	= 1,
+		.chip_select	= 0,
+		.max_speed_hz   = 1500000,
+		.controller_data= &tsc2046_mcspi_config,
+		.platform_data  = &tsc2046_config,
+	},
+};
+
 static inline void __init sdp2430_init_smc91x(void)
 {
 	int eth_cs;
@@ -198,6 +227,9 @@ static void __init omap_2430sdp_init(voi
 	omap_board_config = sdp2430_config;
 	omap_board_config_size = ARRAY_SIZE(sdp2430_config);
 	omap_serial_init();
+
+	spi_register_board_info(sdp2430_spi_board_info,
+				ARRAY_SIZE(sdp2430_spi_board_info));
 }
 
 static void __init omap_2430sdp_map_io(void)
drivers/input/touchscreen/Kconfig +6 -0
Index: dev/drivers/input/touchscreen/Kconfig
===================================================================
@@ -165,4 +165,10 @@ config TOUCHSCREEN_TSC2301
 	help
 	  Say Y here for if you are using the touchscreen features of TSC2301.
 
+config TOUCHSCREEN_TSC2046
+	tristate "TSC2046 touchscreen support"
+	default MACH_OMAP2430SDP
+	  help
+	  Say Y here for if you are using the touchscreen features of TSC2046
+
 endif
drivers/input/touchscreen/Makefile +1 -0
Index: dev/drivers/input/touchscreen/Makefile
===================================================================
@@ -19,3 +19,4 @@ obj-$(CONFIG_TOUCHSCREEN_UCB1400)	+= ucb
 obj-$(CONFIG_TOUCHSCREEN_TSC2102)	+= tsc2102_ts.o
 obj-$(CONFIG_TOUCHSCREEN_OMAP)	+= omap/
 obj-$(CONFIG_TOUCHSCREEN_TSC2301)	+= tsc2301_ts.o
+obj-$(CONFIG_TOUCHSCREEN_TSC2046)	+= tsc2046_ts.o
drivers/input/touchscreen/tsc2046_ts.c new file +555 -0

555 lines not on this page · raw message

include/linux/spi/tsc2046.h new file +60 -0

60 lines not on this page · raw message

--

#3 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Tony,

Here's a minor update so it applies on the (already pushed) onenand patch.

Kevin

Subject: ARM: OMAP: TSC2046 touchscreen support for 2430

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

---
 arch/arm/mach-omap2/board-2430sdp.c    |   32 +
 drivers/input/touchscreen/Kconfig      |    6 
 drivers/input/touchscreen/Makefile     |    1 
 drivers/input/touchscreen/tsc2046_ts.c |  555 +++++++++++++++++++++++++++++++++
 include/linux/spi/tsc2046.h            |   60 +++
 5 files changed, 654 insertions(+)
arch/arm/mach-omap2/board-2430sdp.c +32 -0
Index: dev/arch/arm/mach-omap2/board-2430sdp.c
===================================================================
@@ -21,6 +21,8 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2046.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -33,6 +35,7 @@
 #include <asm/arch/board.h>
 #include <asm/arch/common.h>
 #include <asm/arch/gpmc.h>
+#include <asm/arch/mcspi.h>
 #include "prcm-regs.h"
 
 #include <asm/io.h>
@@ -40,6 +43,9 @@
 #define	SDP2430_FLASH_CS	0
 #define	SDP2430_SMC91X_CS	5
 
+/* TSC2046 (touchscreen) */
+#define TS_GPIO                 24
+
 static struct mtd_partition sdp2430_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	{
@@ -119,6 +125,29 @@ static struct platform_device *sdp2430_d
 	&sdp2430_flash_device,
 };
 
+static struct tsc2046_platform_data tsc2046_config = {
+	.dav_gpio       = TS_GPIO,
+	.gpio_debounce  = 0xa,
+};
+
+static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
+	.turbo_mode	= 0,
+	.single_channel = 0,  /* 0: slave, 1: master */
+};
+
+static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
+	[0] = {
+		/* TSC2046 operates at a max freqency of 2MHz, so
+		 * operate slightly below at 1.5MHz */
+		.modalias	= "tsc2046",
+		.bus_num	= 1,
+		.chip_select	= 0,
+		.max_speed_hz   = 1500000,
+		.controller_data= &tsc2046_mcspi_config,
+		.platform_data  = &tsc2046_config,
+	},
+};
+
 static inline void __init sdp2430_init_smc91x(void)
 {
 	int eth_cs;
@@ -202,6 +231,9 @@ static void __init omap_2430sdp_init(voi
 	omap_serial_init();
 
 	sdp2430_flash_init();
+
+	spi_register_board_info(sdp2430_spi_board_info,
+				ARRAY_SIZE(sdp2430_spi_board_info));
 }
 
 static void __init omap_2430sdp_map_io(void)
drivers/input/touchscreen/Kconfig +6 -0
Index: dev/drivers/input/touchscreen/Kconfig
===================================================================
@@ -165,4 +165,10 @@ config TOUCHSCREEN_TSC2301
 	help
 	  Say Y here for if you are using the touchscreen features of TSC2301.
 
+config TOUCHSCREEN_TSC2046
+	tristate "TSC2046 touchscreen support"
+	default MACH_OMAP2430SDP
+	  help
+	  Say Y here for if you are using the touchscreen features of TSC2046
+
 endif
drivers/input/touchscreen/Makefile +1 -0
Index: dev/drivers/input/touchscreen/Makefile
===================================================================
@@ -19,3 +19,4 @@ obj-$(CONFIG_TOUCHSCREEN_UCB1400)	+= ucb
 obj-$(CONFIG_TOUCHSCREEN_TSC2102)	+= tsc2102_ts.o
 obj-$(CONFIG_TOUCHSCREEN_OMAP)	+= omap/
 obj-$(CONFIG_TOUCHSCREEN_TSC2301)	+= tsc2301_ts.o
+obj-$(CONFIG_TOUCHSCREEN_TSC2046)	+= tsc2046_ts.o
drivers/input/touchscreen/tsc2046_ts.c new file +555 -0

555 lines not on this page · raw message

include/linux/spi/tsc2046.h new file +60 -0

60 lines not on this page · raw message

maintainer
#4 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Quoted 4 lines · Kevin Hilman

Tony,

Here's a minor update so it applies on the (already pushed) onenand patch.

Thanks, I'll apply these too as they make 2430-sdp more usable. I've split the board update into a separate patch.

Tony

#5 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

In reply to Kevin Hilman

Kevin,

Quoted 4 lines · Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

Very small changes required in order to confirm CodingStyle.

...

arch/arm/mach-omap2/board-2430sdp.c static struct platform_device *sdp2430_d · line 141

Quoted 10 lines
arch/arm/mach-omap2/board-2430sdp.c +10 -0
+
+static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
+       .turbo_mode     = 0,
+       .single_channel = 0,  /* 0: slave, 1: master */
+};
+
+static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
+       [0] = {
+               /* TSC2046 operates at a max freqency of 2MHz, so
+                * operate slightly below at 1.5MHz */

multi-line comments block should be like this:
/*
* TSC2046 operates at a max freqency of 2MHz, so
* operate slightly below at 1.5MHz
*/

arch/arm/mach-omap2/board-2430sdp.c static struct platform_device *sdp2430_d · line 146

Quoted 5 lines
arch/arm/mach-omap2/board-2430sdp.c +5 -0
+               .modalias       = "tsc2046",
+               .bus_num        = 1,
+               .chip_select    = 0,
+               .max_speed_hz   = 1500000,
+               .controller_data= &tsc2046_mcspi_config,

Space before "=".

Quoted 4 lines
arch/arm/mach-omap2/board-2430sdp.c +4 -0
+               .platform_data  = &tsc2046_config,
+       },
+};
+

....

Quoted 16 lines
drivers/input/touchscreen/tsc2046_ts.c new file +16 -0
+/*
+ * This procedure is called by the SPI framework after the coordinates
+ * have been read from TSC2046
+ */
+static void tsc2046_ts_rx(void *arg)
+{
+       struct tsc2046 *tsc = arg;
+       struct tsc2046_ts *ts = tsc->ts;
+       unsigned int x, y, z1, z2, pressure;
+
+       x  = CONV_DATA(ts->data[2], ts->data[3]);
+       y  = CONV_DATA(ts->data[1], ts->data[2]);
+       z1 = CONV_DATA(ts->data[3], ts->data[4]);
+       z2 = CONV_DATA(ts->data[4], 0);
+
+       if (z1) {

drivers/input/touchscreen/tsc2046_ts.c line 139

Quoted 10 lines
drivers/input/touchscreen/tsc2046_ts.c new file +10 -0
+               pressure = ts->x_plate_ohm * x;
+               pressure /= 4096;
+               pressure *= z2 - z1;
+               pressure /= z1;
+       } else
+               pressure = 0;
+
+       /* If pressure value is above a preset limit (pen is barely
+        * touching the screen) we can't trust the coordinate values.
+        */

same here for multi-line comment block style.

Quoted 17 lines
drivers/input/touchscreen/tsc2046_ts.c new file +17 -0
+       if (pressure < ts->pressure_limit && x < MAX_12BIT && y < MAX_12BIT) {
+               ts->pressure_limit = ts->max_pressure;
+               if (ts->ignore_last) {
+                       if (ts->sample_cnt)
+                               update_pen_state(tsc, ts->x, ts->y, ts->p);
+                       ts->x = x;
+                       ts->y = y;
+                       ts->p = pressure;
+               } else
+                       update_pen_state(tsc, x, y, pressure);
+               ts->sample_cnt++;
+       }
+
+       mod_timer(&ts->timer,
+                 jiffies + msecs_to_jiffies(TSC2046_TS_SCAN_TIME));
+}
+

....

Quoted 27 lines
drivers/input/touchscreen/tsc2046_ts.c new file +27 -0
+
+int __devinit tsc2046_ts_init(struct tsc2046 *tsc,
+                             struct tsc2046_platform_data *pdata)
+{
+       struct tsc2046_ts *ts;
+       struct input_dev *idev;
+       int dav_gpio, r;
+
+       if (pdata->dav_gpio < 0) {
+               dev_err(&tsc->spi->dev, "need DAV GPIO");
+               return -EINVAL;
+       }
+       dav_gpio = pdata->dav_gpio;
+
+       ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+       if (ts == NULL)
+               return -ENOMEM;
+       tsc->ts = ts;
+
+       ts->dav_gpio = dav_gpio;
+#ifdef CONFIG_ARCH_OMAP
+       r = omap_request_gpio(dav_gpio);
+       if (r < 0) {
+               dev_err(&tsc->spi->dev, "unable to get DAV GPIO");
+               goto err1;
+       }
+       omap_set_gpio_direction(dav_gpio, 1);

drivers/input/touchscreen/tsc2046_ts.c line 382

Quoted 10 lines
drivers/input/touchscreen/tsc2046_ts.c new file +10 -0
+       if (pdata->gpio_debounce) {
+               omap_set_gpio_debounce(tsc->gpio, 1);
+               omap_set_gpio_debounce_time(tsc->gpio, pdata->gpio_debounce);
+       }
+
+       ts->irq = OMAP_GPIO_IRQ(dav_gpio);
+#endif
+       init_timer(&ts->timer);
+       ts->timer.data = (unsigned long) tsc;
+       ts->timer.function = tsc2046_ts_timer;

setup_timer ?

drivers/input/touchscreen/tsc2046_ts.c line 387

Quoted 5 lines
drivers/input/touchscreen/tsc2046_ts.c new file +5 -0
+
+       spin_lock_init(&ts->lock);
+
+       ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280;
+       ts->max_pressure= pdata->ts_max_pressure ? : MAX_12BIT;

space before "=".

Quoted 18 lines
drivers/input/touchscreen/tsc2046_ts.c new file +18 -0
+       ts->touch_pressure = pdata->ts_touch_pressure ? : ts->max_pressure;
+       ts->ignore_last = pdata->ts_ignore_last;
+
+       idev = input_allocate_device();
+       if (idev == NULL) {
+               r = -ENOMEM;
+               goto err2;
+       }
+       idev->name = "TSC2046 touchscreen";
+       snprintf(ts->phys, sizeof(ts->phys),
+                "%s/input-ts", tsc->spi->dev.bus_id);
+       idev->phys = ts->phys;
+
+       idev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
+       idev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+       ts->idev = idev;
+
+       tsc2046_ts_setup_spi_xfer(tsc);

drivers/input/touchscreen/tsc2046_ts.c line 415

Quoted 10 lines
drivers/input/touchscreen/tsc2046_ts.c new file +10 -0
+
+       /* These parameters should perhaps be configurable? */
+       input_set_abs_params(idev, ABS_X, 0, 4096, 0, 0);
+       input_set_abs_params(idev, ABS_Y, 0, 4096, 0, 0);
+       input_set_abs_params(idev, ABS_PRESSURE, 0, 1024, 0, 0);
+
+       ts->irq_enabled = 1;
+       r = request_irq(ts->irq, tsc2046_ts_irq_handler,
+                       SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
+                       "tsc2046-ts", tsc);

deprecated SA_* flags.

Quoted 78 lines
drivers/input/touchscreen/tsc2046_ts.c new file +78 -0
+       if (r < 0) {
+               dev_err(&tsc->spi->dev, "unable to get DAV IRQ");
+               goto err3;
+       }
+       set_irq_wake(ts->irq, 1);
+
+       if (device_create_file(&tsc->spi->dev, &dev_attr_pen_down) < 0)
+               goto err4;
+       if (device_create_file(&tsc->spi->dev, &dev_attr_disable_ts) < 0)
+               goto err5;
+
+       r = input_register_device(idev);
+       if (r < 0) {
+               dev_err(&tsc->spi->dev, "can't register touchscreen device\n");
+               goto err6;
+       }
+
+       /* kick off a transaction to enable pen interrupts */
+       spi_async(tsc->spi, &ts->read_msg);
+
+       return 0;
+err6:
+       device_remove_file(&tsc->spi->dev, &dev_attr_disable_ts);
+err5:
+       device_remove_file(&tsc->spi->dev, &dev_attr_pen_down);
+err4:
+       free_irq(ts->irq, tsc);
+err3:
+       input_free_device(idev);
+err2:
+#ifdef CONFIG_ARCH_OMAP
+       omap_free_gpio(dav_gpio);
+#endif
+ err1:
+       kfree(ts);
+       return r;
+}
+EXPORT_SYMBOL(tsc2046_ts_init);
+
+void __devexit tsc2046_ts_exit(struct tsc2046 *tsc)
+{
+       struct tsc2046_ts *ts = tsc->ts;
+       unsigned long flags;
+
+       spin_lock_irqsave(&ts->lock, flags);
+       tsc2046_ts_disable(tsc);
+       spin_unlock_irqrestore(&ts->lock, flags);
+
+       device_remove_file(&tsc->spi->dev, &dev_attr_disable_ts);
+       device_remove_file(&tsc->spi->dev, &dev_attr_pen_down);
+
+       free_irq(ts->irq, tsc);
+       input_unregister_device(ts->idev);
+
+#ifdef CONFIG_ARCH_OMAP
+       omap_free_gpio(ts->dav_gpio);
+#endif
+       kfree(ts);
+}
+EXPORT_SYMBOL(tsc2046_ts_exit);
+
+
+static int __devinit tsc2046_probe(struct spi_device *spi)
+{
+       struct tsc2046                  *tsc;
+       struct tsc2046_platform_data    *pdata = spi->dev.platform_data;
+       int r = -ENODEV;
+
+       dev_dbg(&spi->dev, "%s\n", __FUNCTION__);
+
+       if (!pdata) {
+               dev_dbg(&spi->dev, "no platform data?\n");
+               return -ENODEV;
+       }
+
+       tsc = kzalloc(sizeof(*tsc), GFP_KERNEL);
+       if (tsc == NULL)
+               return -ENOMEM;

drivers/input/touchscreen/tsc2046_ts.c line 503

Quoted 10 lines
drivers/input/touchscreen/tsc2046_ts.c new file +10 -0
+
+       dev_set_drvdata(&spi->dev, tsc);
+       tsc->spi = spi;
+       spi->dev.power.power_state = PMSG_ON;
+
+       spi->mode = SPI_MODE_1;
+       spi->bits_per_word = 16;
+
+       /* The max speed might've been defined by the board-specific
+        * struct */

same comment for multi-line comments style as pointed earlier.

Quoted 11 lines
drivers/input/touchscreen/tsc2046_ts.c new file +11 -0
+       if (!spi->max_speed_hz)
+               spi->max_speed_hz = TSC2046_HZ;
+       spi_setup(spi);
+
+       r = tsc2046_ts_init(tsc, pdata);
+       if (r)
+               goto err1;
+
+       return 0;
+ err1:
+       kfree(tsc);

drivers/input/touchscreen/tsc2046_ts.c line 524

Quoted 10 lines
drivers/input/touchscreen/tsc2046_ts.c new file +10 -0
+       return r;
+}
+
+static int __devexit tsc2046_remove(struct spi_device *spi)
+{
+       struct tsc2046 *tsc = dev_get_drvdata(&spi->dev);
+
+       dev_dbg(&tsc->spi->dev, "%s\n", __FUNCTION__);
+
+        tsc2046_ts_exit(tsc);

This doesn't look to me a tab.

Quoted 4 lines
drivers/input/touchscreen/tsc2046_ts.c new file +4 -0
+       kfree(tsc);
+
+       return 0;
+}
Signature · 2 lines
---Komal Shah
http://komalshah.blogspot.com
#6 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Tony,

Quoted 10 lines · Komal Shah

Kevin,

Quoted 4 lines · Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

Very small changes required in order to confirm CodingStyle.

I have attached two patches implementing changes as suggested by Komal. They are compile tested only.

Signature · 1 line
--Trilok Soni

From f34fac46abd0e3c6f9f7760a83e91b64ab602d21 Mon Sep 17 00:00:00 2001
From: Trilok Soni <[email protected]>
Date: Mon, 7 May 2007 17:50:49 +0530
Subject: [PATCH] ARM: OMAP: TSC2046 CodingStyle cleanup.

---
 arch/arm/mach-omap2/board-2430sdp.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/board-2430sdp.c +10 -8
index 5ee970b..ebd2630 100644
@@ -137,14 +137,16 @@ static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
 
 static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
 	[0] = {
-		/* TSC2046 operates at a max freqency of 2MHz, so
-		 * operate slightly below at 1.5MHz */
-		.modalias	= "tsc2046",
-		.bus_num	= 1,
-		.chip_select	= 0,
-		.max_speed_hz   = 1500000,
-		.controller_data= &tsc2046_mcspi_config,
-		.platform_data  = &tsc2046_config,
+		/*
+		 * TSC2046 operates at a max freqency of 2MHz, so
+		 * operate slightly below at 1.5MHz
+		 */
+		.modalias	 = "tsc2046",
+		.bus_num	 = 1,
+		.chip_select	 = 0,
+		.max_speed_hz    = 1500000,
+		.controller_data = &tsc2046_mcspi_config,
+		.platform_data   = &tsc2046_config,
 	},
 };
 
Signature · 1 line
1.5.0

From 29d67e3821b3f5e27de5d8247a6fc39f5bad06db Mon Sep 17 00:00:00 2001
From: Trilok Soni <[email protected]>
Date: Mon, 7 May 2007 18:13:43 +0530
Subject: [PATCH] SPI: TSC2046 driver CodingStyle cleanup.

---
 drivers/input/touchscreen/tsc2046_ts.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
drivers/input/touchscreen/tsc2046_ts.c +12 -11
index a56ae5a..a509986 100644
@@ -134,7 +134,8 @@ static void tsc2046_ts_rx(void *arg)
 	} else
 		pressure = 0;
 
-	/* If pressure value is above a preset limit (pen is barely
+	/*
+	 * If pressure value is above a preset limit (pen is barely
 	 * touching the screen) we can't trust the coordinate values.
 	 */
 	if (pressure < ts->pressure_limit && x < MAX_12BIT && y < MAX_12BIT) {
@@ -377,14 +378,12 @@ int __devinit tsc2046_ts_init(struct tsc2046 *tsc,
 
 	ts->irq = OMAP_GPIO_IRQ(dav_gpio);
 #endif
-	init_timer(&ts->timer);
-	ts->timer.data = (unsigned long) tsc;
-	ts->timer.function = tsc2046_ts_timer;
+	setup_timer(&ts->timer, tsc2046_ts_timer, (unsigned long)tsc);
 
 	spin_lock_init(&ts->lock);
 
 	ts->x_plate_ohm	= pdata->ts_x_plate_ohm ? : 280;
-	ts->max_pressure= pdata->ts_max_pressure ? : MAX_12BIT;
+	ts->max_pressure = pdata->ts_max_pressure ? : MAX_12BIT;
 	ts->touch_pressure = pdata->ts_touch_pressure ? : ts->max_pressure;
 	ts->ignore_last	= pdata->ts_ignore_last;
 
@@ -411,7 +410,7 @@ int __devinit tsc2046_ts_init(struct tsc2046 *tsc,
 
 	ts->irq_enabled = 1;
 	r = request_irq(ts->irq, tsc2046_ts_irq_handler,
-			SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
+			IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_FALLING,
 			"tsc2046-ts", tsc);
 	if (r < 0) {
 		dev_err(&tsc->spi->dev, "unable to get DAV IRQ");
@@ -446,7 +445,7 @@ err2:
 #ifdef CONFIG_ARCH_OMAP
 	omap_free_gpio(dav_gpio);
 #endif
- err1:
+err1:
 	kfree(ts);
 	return r;
 }
@@ -499,8 +498,10 @@ static int __devinit tsc2046_probe(struct spi_device *spi)
 	spi->mode = SPI_MODE_1;
 	spi->bits_per_word = 16;
 
-	/* The max speed might've been defined by the board-specific
-	 * struct */
+	/*
+	 * The max speed might've been defined by the board-specific
+	 * struct
+	 */
 	if (!spi->max_speed_hz)
 		spi->max_speed_hz = TSC2046_HZ;
 	spi_setup(spi);
@@ -510,7 +511,7 @@ static int __devinit tsc2046_probe(struct spi_device *spi)
 		goto err1;
 
 	return 0;
- err1:
+err1:
 	kfree(tsc);
 	return r;
 }
@@ -521,7 +522,7 @@ static int __devexit tsc2046_remove(struct spi_device *spi)
 
 	dev_dbg(&tsc->spi->dev, "%s\n", __FUNCTION__);
 
-        tsc2046_ts_exit(tsc);
+	tsc2046_ts_exit(tsc);
 	kfree(tsc);
 
 	return 0;
Signature · 1 line
1.5.0
#7 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Quoted 9 lines · Trilok Soni

Tony,

Quoted 6 lines · Komal Shah

Kevin,

Quoted 3 lines · Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Very small changes required in order to confirm CodingStyle.

I have attached two patches implementing changes as suggested by Komal. They are compile tested only.

Attached 3rd patch fixes suspend/resume functions, as TSC2046 is TS only device not like TSC2301, so we don't need to make non-static functions like TSC2301_TS which gets called from it's core driver on suspend/resume.

This patch is also compile-tested only. Kevin please test it.

Signature · 1 line
--Trilok Soni

From 77d4ae193bdd275bffacd6e446768764c7902dd8 Mon Sep 17 00:00:00 2001
From: Trilok Soni <[email protected]>
Date: Mon, 7 May 2007 21:21:15 +0530
Subject: [PATCH] SPI: TSC2046 Fix supend/resume functions

- Add suspend, resume function to tsc2046 device driver.
- Change tsc2046_suspend/resume function accoradingly, as tsc2046 is TS only device not like TSC2301.

---
 drivers/input/touchscreen/tsc2046_ts.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
drivers/input/touchscreen/tsc2046_ts.c +10 -2
index a509986..4689fb6 100644
@@ -255,8 +255,9 @@ static void tsc2046_ts_enable(struct tsc2046 *tsc)
 }
 
 #ifdef CONFIG_PM
-int tsc2046_ts_suspend(struct tsc2046 *tsc)
+static int tsc2046_suspend(struct spi_device *spi, pm_message_t mesg)
 {
+	struct tsc2046 *tsc = dev_get_drvdata(&spi->dev);
 	struct tsc2046_ts *ts = tsc->ts;
 
 	spin_lock_irq(&ts->lock);
@@ -266,13 +267,16 @@ int tsc2046_ts_suspend(struct tsc2046 *tsc)
 	return 0;
 }
 
-void tsc2046_ts_resume(struct tsc2046 *tsc)
+static int tsc2046_resume(struct spi_device *spi)
 {
+	struct tsc2046 *tsc = dev_get_drvdata(&spi->dev);
 	struct tsc2046_ts *ts = tsc->ts;
 
 	spin_lock_irq(&ts->lock);
 	tsc2046_ts_enable(tsc);
 	spin_unlock_irq(&ts->lock);
+
+	return 0;
 }
 #endif
 
@@ -536,6 +540,10 @@ static struct spi_driver tsc2046_driver = {
 	},
 	.probe = tsc2046_probe,
 	.remove = __devexit_p(tsc2046_remove),
+#ifdef CONFIG_PM
+	.suspend = tsc2046_suspend,
+	.resume = tsc2046_resume,
+#endif
 };
 
 static int __init tsc2046_init(void)
Signature · 1 line
1.5.0
#8 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Quoted 19 lines · Trilok Soni
Quoted 9 lines · Trilok Soni

Tony,

Quoted 6 lines · Komal Shah

Kevin,

Quoted 3 lines · Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Very small changes required in order to confirm CodingStyle.

I have attached two patches implementing changes as suggested by Komal. They are compile tested only.

Quoted 6 lines

Attached 3rd patch fixes suspend/resume functions, as TSC2046 is TS only device not like TSC2301, so we don't need to make non-static functions like TSC2301_TS which gets called from it's core driver on suspend/resume.

This patch is also compile-tested only. Kevin please test it.

Trilok,

Thanks for the cleanups and PM support. I have tested all 3 patches and the driver is still working well.

Thanks,

Kevin

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Quoted 26 lines · Tony Lindgren
Quoted 25 lines · Kevin Hilman
Quoted 24 lines · Trilok Soni
Quoted 9 lines · Trilok Soni

Tony,

Quoted 6 lines · Komal Shah

Kevin,

Quoted 3 lines · Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Very small changes required in order to confirm CodingStyle.

I have attached two patches implementing changes as suggested by Komal. They are compile tested only.

Attached 3rd patch fixes suspend/resume functions, as TSC2046 is TS only device not like TSC2301, so we don't need to make non-static functions like TSC2301_TS which gets called from it's core driver on suspend/resume.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

This patch is also compile-tested only. Kevin please test it.

Trilok,

Thanks for the cleanups and PM support. I have tested all 3 patches and the driver is still working well.

Cool, will push today.

Have you applied first two cleanup patches? I can only see PM patch (3rd patch) on master branch.

Signature · 1 line
--Trilok Soni
#11 lore raw

Re: [PATCH 2/2] ARM: OMAP: TSC2046 touchscreen support for 2430

Quoted 31 lines · Trilok Soni
Quoted 30 lines · Tony Lindgren
Quoted 29 lines · Kevin Hilman
Quoted 19 lines · Trilok Soni
Quoted 9 lines · Trilok Soni

Tony,

Quoted 6 lines · Komal Shah

Kevin,

Quoted 3 lines · Kevin Hilman

This is a rework of the tsc2046 driver from TI's tree, based on the tsc2301 driver and using the new SPI framework.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Very small changes required in order to confirm CodingStyle.

I have attached two patches implementing changes as suggested by Komal. They are compile tested only.

Quoted 6 lines

Attached 3rd patch fixes suspend/resume functions, as TSC2046 is TS only device not like TSC2301, so we don't need to make non-static functions like TSC2301_TS which gets called from it's core driver on suspend/resume.

This patch is also compile-tested only. Kevin please test it.

Trilok,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thanks for the cleanups and PM support. I have tested all 3 patches and the driver is still working well.

Cool, will push today.

Have you applied first two cleanup patches? I can only see PM patch (3rd patch) on master branch.

Oops, sorry. I've applied and pushed, can you please check?

Regards,

Tony