TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
An embedded and charset-unspecified text was scrubbed...
Name: thirdparty/inprogress/s3c24xx-touchscreen.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20091118/ebfeea77/attachment.el>
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
2009/11/19 Ben Dooks <[email protected]>:
<snip>
Quoted 105 lines
(quoted diff) +105
-0+static int __init s3c2410ts_probe(struct platform_device *pdev) +{ + struct s3c2410_ts_mach_info *info; + struct device *dev = &pdev->dev; + struct input_dev *input_dev; + struct resource *res; + int ret = -EINVAL; + + /* Initialise input stuff */ + memset(&ts, 0, sizeof(struct s3c2410ts)); + + ts.dev = dev; + + info = pdev->dev.platform_data; + if (!info) { + dev_err(dev, "no platform data, cannot attach\n"); + return -EINVAL; + } + + dev_dbg(dev, "initialising touchscreen\n"); + + ts.clock = clk_get(dev, "adc"); + if (IS_ERR(ts.clock)) { + dev_err(dev, "cannot get adc clock source\n"); + return -ENOENT; + } + + clk_enable(ts.clock); + dev_dbg(dev, "got and enabled clocks\n"); + + ts.irq_tc = ret = platform_get_irq(pdev, 0); + if (ret < 0) { + dev_err(dev, "no resource for interrupt\n"); + goto err_clk; + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "no resource for registers\n"); + ret = -ENOENT; + goto err_clk; + } + + ts.io = ioremap(res->start, resource_size(res)); + if (ts.io == NULL) { + dev_err(dev, "cannot map registers\n"); + ret = -ENOMEM; + goto err_clk; + } + + /* Configure the touchscreen external FETs on the S3C2410 */ + if (!platform_get_device_id(pdev)->driver_data) + s3c2410_ts_connect(); + + ts.client = s3c_adc_register(pdev, s3c24xx_ts_select, + s3c24xx_ts_conversion, 1); + if (IS_ERR(ts.client)) { + dev_err(dev, "failed to register adc client\n"); + ret = PTR_ERR(ts.client); + goto err_iomap; + } + + /* Initialise registers */ + if ((info->delay & 0xffff) > 0) + writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY); + + writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); + + input_dev = input_allocate_device(); + if (!input_dev) { + dev_err(dev, "Unable to allocate the input device !!\n"); + ret = -ENOMEM; + goto err_iomap; + } + + ts.input = input_dev; + ts.input->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); + ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0); + + ts.input->name = s3c2410ts_name; + ts.input->id.bustype = BUS_HOST; + ts.input->id.vendor = 0xDEAD; + ts.input->id.product = 0xBEEF; + ts.input->id.version = S3C2410TSVERSION; + + ts.shift = info->oversampling_shift; + + if (request_irq(ts.irq_tc, stylus_irq, IRQF_DISABLED, + "s3c2410_ts_pen", ts.input)) { + dev_err(dev, "cannot get TC interrupt\n"); + ret = -EIO; + goto err_inputdev; + } + + dev_info(dev, "driver attached, registering input device\n"); + + /* All went ok, so register to the input system */ + ret = input_register_device(ts.input); + if (ret < 0) { + dev_err(dev, "failed to register input device\n"); + ret = -EIO; + goto err_tcirq;
Review
Quoted 10 lines
(quoted diff) +10
-0+ } + + return 0; + + err_tcirq: + free_irq(ts.irq_tc, ts.input); + err_inputdev: + input_unregister_device(ts.input); + err_iomap: + iounmap(ts.io);
Isn't s3c_adc_release() needed for freeing unused adc client?
Quoted 10 lines
+
err_clk:(quoted diff) +9
-0+ clk_put(ts.clock); + return ret; +} + +/** + * s3c2410ts_remove - device core removal entry point + * @pdev: The device we are being removed from. + * + * Free up our state ready to be removed.
Review
Quoted 10 lines
(quoted diff) +10
-0+ */ +static int s3c2410ts_remove(struct platform_device *pdev) +{ + free_irq(ts.irq_tc, ts.input); + + clk_disable(ts.clock); + clk_put(ts.clock); + + input_unregister_device(ts.input); + iounmap(ts.io);
The same reason.
Quoted 9 lines
(quoted diff) +3
-0+ + return 0; +}_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
In reply to Ben DooksHi Ben,
Quoted 7 lines · Ben Dooks
From: Arnaud Patard <[email protected]>
S3C24XX touchscreen driver, originally written by Arnaud Patard and other contributors. This driver is the version from the Simtec Electronics tree, and as such is the best place to start and thus proposed to be merged into the linux input system.
Thank you for the patch. First thing first - do we have an agreement from all Samsung folks and other interested parties that _this_ is the driver? Because it's like 3rd implementation that came across...
Quoted 25 lines
The driver has had substantial testing as well as a number of tidying up passes done by Ben Dooks, as noted:
- added kernel-doc comments to most of the routines
- removed old code from pre adc framework days
- updated device probe code to use platform id list matching
- cleaned up debug, sinceprintk()now has timestamp feature
- ensure code usesdev_()reporting macros where necessarySigned-off-by Arnaud Patard <[email protected]>Signed-off-by Simtec Linux Team <[email protected]>Signed-off-by Ben Dooks <[email protected]>--- drivers/input/touchscreen/Kconfig | 18 + drivers/input/touchscreen/Makefile | 1 drivers/input/touchscreen/s3c2410_ts.c | 464 +++++++++++++++++++++++++++++++++ 3 files changed, 483 insertions(+)Index: b/drivers/input/touchscreen/Kconfig
===================================================================
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_FUJITSU · line 138
Quoted 6 lines
drivers/input/touchscreen/Kconfig +3
-0@@ -133,6 +133,24 @@ config TOUCHSCREEN_FUJITSU To compile this driver as a module, choose M here: the module will be called fujitsu-ts. +config TOUCHSCREEN_S3C2410 + tristate "Samsung S3C2410 touchscreen input driver" + depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN
INPUT && INPUT_TOUCHSCREEN are superfluous.
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_FUJITSU · line 139
Quoted 1 line
drivers/input/touchscreen/Kconfig +1
-0+ select SERIO
I don't think you need SERIO
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_FUJITSU · line 152
Quoted 13 lines
drivers/input/touchscreen/Kconfig +13
-0+ help + Say Y here if you have the s3c2410 touchscreen. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called s3c2410_ts. + +config TOUCHSCREEN_S3C2410_DEBUG + boolean "Samsung S3C2410 touchscreen debug messages" + depends on TOUCHSCREEN_S3C2410 + help + Select this if you want debug messages
Where is this used?
Quoted 45 lines
drivers/input/touchscreen/Kconfig +1
-0+ config TOUCHSCREEN_GUNZE tristate "Gunze AHL-51S touchscreen" select SERIOIndex: b/drivers/input/touchscreen/Makefile
===================================================================drivers/input/touchscreen/Makefile +1
-0@@ -26,6 +26,7 @@ obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jorn obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o +obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.oIndex:
b/drivers/input/touchscreen/s3c2410_ts.c
===================================================================drivers/input/touchscreen/s3c2410_ts.c new file +24
-0@@ -0,0 +1,464 @@ +/* drivers/input/touchscreen/s3c2410_ts.c +* +* Samsung S3C24XX touchscreen driver +* +* This program is free software; you can redistribute it and/or modify +* it under the term of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* Copyright 2004 Arnaud Patard <[email protected]> +* Copyright 2008 Ben Dooks <[email protected]> +* Copyright 2009 Simtec Electronics <[email protected]> +* +* Additional work by Herbert P?tzl <[email protected]> and +* Harald Welte <[email protected]>
drivers/input/touchscreen/s3c2410_ts.c line 34
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+*/ + +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/gpio.h> +#include <linux/input.h> +#include <linux/init.h> +#include <linux/serio.h>
No serio in sight.
Quoted 22 lines
drivers/input/touchscreen/s3c2410_ts.c new file +22
-0+#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/io.h> + +#include <plat/adc.h> +#include <plat/regs-adc.h> + +#include <mach/regs-gpio.h> +#include <mach/ts.h> + +/* For ts.dev.id.version */ +#define S3C2410TSVERSION 0x0101 + +#define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0)) + +#define INT_DOWN (0) +#define INT_UP (1 << 8) + +#define WAIT4INT (S3C2410_ADCTSC_YM_SEN | \ + S3C2410_ADCTSC_YP_SEN | \
drivers/input/touchscreen/s3c2410_ts.c line 66
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+ S3C2410_ADCTSC_XP_SEN | \ + S3C2410_ADCTSC_XY_PST(3)) + +#define AUTOPST (S3C2410_ADCTSC_YM_SEN | \ + S3C2410_ADCTSC_YP_SEN | \ + S3C2410_ADCTSC_XP_SEN | \ + S3C2410_ADCTSC_AUTO_PST | \ + S3C2410_ADCTSC_XY_PST(0)) + +#define DEBUG_LVL KERN_DEBUG
Don't seem to be used.
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c new file +8
-0+ +static char *s3c2410ts_name ="s3c2410 TouchScreen" ; + +/* Per-touchscreen data. */ + +/** +* struct s3c2410ts - driver touchscreen state. +* @client: The ADC client we registered with the core driver.
drivers/input/touchscreen/s3c2410_ts.c line 84
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+* @dev: The device we are bound to. +* @input: The input device we registered with the input subsystem. +* @clock: The clock for the adc. +* @io: Pointer to the IO base. +* @xp: The accumulated X position data. +* @yp: The accumulated Y position data. +* @irq_tc: The interrupt number for pen up/down interrupt +* @count: The number of samples collected. +* @shift: The log2 of the maximum count to read in one go. +*/
These sructures are driver-internal and so don't need to be kernel-doc-ed. Same goes for the driver-private functions.
Quoted 18 lines
drivers/input/touchscreen/s3c2410_ts.c new file +18
-0+struct s3c2410ts { +struct s3c_adc_client *client; +struct device *dev; +struct input_dev *input; +struct clk *clock; +void __iomem *io; +unsigned long xp; +unsigned long yp; +int irq_tc; +int count; +int shift; +}; + +static struct s3c2410ts ts; + +/** +* s3c2410_ts_connect - configure gpio for s3c2410 systems +*
drivers/input/touchscreen/s3c2410_ts.c line 112
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+* Configure the GPIO for the S3C2410 system, where we have external FETs +* connected to the device (later systems such as the S3C2440 integrate +* these into the device). +*/ +static inline void s3c2410_ts_connect (void ) +{ +s3c2410_gpio_cfgpin (S3C2410_GPG (12 ),S3C2410_GPG12_XMON ); +s3c2410_gpio_cfgpin (S3C2410_GPG (13 ), S3C2410_GPG13_nXPON); +s3c2410_gpio_cfgpin (S3C2410_GPG (14 ),S3C2410_GPG14_YMON ); +s3c2410_gpio_cfgpin (S3C2410_GPG (15 ), S3C2410_GPG15_nYPON);
No gpiolib? Also, should it be in the driver or maybe in the platform code?
drivers/input/touchscreen/s3c2410_ts.c line 122
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+} + +/** +* get_down - return the down state of the pen +* @data0: The data read from ADCDAT0 register. +* @data1: The data read from ADCDAT1 register. +* +* Return non-zero if both readings show that the pen is down. +*/ +static inline int get_down (unsigned long data0,unsigned long data1)
bool?
drivers/input/touchscreen/s3c2410_ts.c line 133
Quoted 11 lines
drivers/input/touchscreen/s3c2410_ts.c new file +11
-0+{ +/* returns true if both data values show stylus down */ +return (!(data0 &S3C2410_ADCDAT0_UPDOWN ) && + !(data1 &S3C2410_ADCDAT0_UPDOWN )); +} + +static void touch_timer_fire (unsigned long data) +{ +unsigned long data0; +unsigned long data1; +int down;
bool?
drivers/input/touchscreen/s3c2410_ts.c line 140
Quoted 7 lines
drivers/input/touchscreen/s3c2410_ts.c new file +7
-0+ + data0 =readl (ts.io +S3C2410_ADCDAT0 ); + data1 =readl (ts.io +S3C2410_ADCDAT1 ); + + down =get_down (data0, data1); + +if (ts.count == (1 <<ts.shift)) {
Syyle: x << y
drivers/input/touchscreen/s3c2410_ts.c line 151
Quoted 11 lines
drivers/input/touchscreen/s3c2410_ts.c new file +11
-0+ ts.xp >>= ts.shift; + ts.yp >>= ts.shift; + +dev_dbg (ts.dev,"%s: X=%lu, Y=%lu, count=%d\n" , + __func__, ts.xp, ts.yp, ts.count); + +input_report_abs (ts.input,ABS_X , ts.xp); +input_report_abs (ts.input,ABS_Y , ts.yp); + +input_report_key (ts.input,BTN_TOUCH ,1 ); +input_report_abs (ts.input,ABS_PRESSURE ,1 );
No fake pressure events please, BTN_TOUCH should be enough.
Quoted 11 lines
drivers/input/touchscreen/s3c2410_ts.c new file +11
-0+input_sync (ts.input); + + ts.xp =0 ; + ts.yp =0 ; + ts.count =0 ; + } + +if (down) { +s3c_adc_start (ts.client,0 ,1 << ts.shift); + }else { + ts.count =0 ;
drivers/input/touchscreen/s3c2410_ts.c line 172
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+ +input_report_key (ts.input,BTN_TOUCH ,0 ); +input_report_abs (ts.input,ABS_PRESSURE ,0 ); +input_sync (ts.input); + +writel (WAIT4INT |INT_DOWN , ts.io +S3C2410_ADCTSC ); + } +} + +static struct timer_list touch_timer =TIMER_INITIALIZER (touch_timer_fire,0 ,0 );
static DEFINE_TIMER(...);
Quoted 77 lines
drivers/input/touchscreen/s3c2410_ts.c new file +77
-0+ +/** +* stylus_irq - touchscreen stylus event interrupt +* @irq: The interrupt number +* @dev_id: The device ID. +* +* Called when the IRQ_TC is fired for a pen up or down event. +*/ +static irqreturn_t stylus_irq (int irq,void *dev_id) +{ +unsigned long data0; +unsigned long data1; +int down; + + data0 =readl (ts.io +S3C2410_ADCDAT0 ); + data1 =readl (ts.io +S3C2410_ADCDAT1 ); + + down =get_down (data0, data1); + +/* TODO we should never get an interrupt with down set while +* the timer is running, but maybe we ought to verify that the +* timer isn't running anyways. */ + +if (down) +s3c_adc_start (ts.client,0 ,1 << ts.shift); +else +dev_info (ts.dev,"%s: count=%d\n" , __func__, ts.count); + +return IRQ_HANDLED ; +} + +/** +* s3c24xx_ts_conversion - ADC conversion callback +* @client: The client that was registered with the ADC core. +* @data0: The reading from ADCDAT0. +* @data1: The reading from ADCDAT1. +* @left: The number of samples left. +* +* Called when a conversion has finished. +*/ +static void s3c24xx_ts_conversion (struct s3c_adc_client *client, +unsigned data0,unsigned data1, +unsigned *left) +{ +dev_dbg (ts.dev,"%s: %d,%d\n" , __func__, data0, data1); + + ts.xp += data0; + ts.yp += data1; + + ts.count++; + +/* From tests, it seems that it is unlikely to get a pen-up +* event during the conversion process which means we can +* ignore any pen-up events with less than the requisite +* count done. +* +* In several thousand conversions, no pen-ups where detected +* before count completed. +*/ +} + +/** +* s3c24xx_ts_select - ADC selection callback. +* @client: The client that was registered with the ADC core. +* @select: The reason for select. +* +* Called when the ADC core selects (or deslects) us as a client. +*/ +static void s3c24xx_ts_select (struct s3c_adc_client *client,unsigned select) +{ +if (select) { +writel (S3C2410_ADCTSC_PULL_UP_DISABLE |AUTOPST , + ts.io +S3C2410_ADCTSC ); + }else { +mod_timer (&touch_timer, jiffies+1 ); +writel (WAIT4INT |INT_UP , ts.io +S3C2410_ADCTSC ); + }
drivers/input/touchscreen/s3c2410_ts.c line 259
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+} + +/** +* s3c2410ts_probe - device core probe entry point +* @pdev: The device we are being bound to. +* +* Initialise, find and allocate any resources we need to run and then +* register with the ADC and input systems. +*/ +static int __init s3c2410ts_probe (struct platform_device *pdev)
__devinit or switch to platform_driver_probe().
drivers/input/touchscreen/s3c2410_ts.c line 265
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+{ +struct s3c2410_ts_mach_info *info; +struct device *dev = &pdev->dev; +struct input_dev *input_dev; +struct resource *res; +int ret = -EINVAL ;
Can we call it "error" (since that's what you use it for).
Quoted 26 lines
drivers/input/touchscreen/s3c2410_ts.c new file +26
-0+ +/* Initialise input stuff */ +memset (&ts,0 ,sizeof (struct s3c2410ts )); + + ts.dev = dev; + + info = pdev->dev.platform_data; +if (!info) { +dev_err (dev,"no platform data, cannot attach\n" ); +return -EINVAL ; + } + +dev_dbg (dev,"initialising touchscreen\n" ); + + ts.clock =clk_get (dev,"adc" ); +if (IS_ERR (ts.clock)) { +dev_err (dev,"cannot get adc clock source\n" ); +return -ENOENT ; + } + +clk_enable (ts.clock); +dev_dbg (dev,"got and enabled clocks\n" ); + + ts.irq_tc = ret =platform_get_irq (pdev,0 ); +if (ret <0 ) { +dev_err (dev,"no resource for interrupt\n" );
drivers/input/touchscreen/s3c2410_ts.c line 301
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+ goto err_clk; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (dev,"no resource for registers\n" ); + ret = -ENOENT ; + goto err_clk; + } +
request_mem_region() here?
Quoted 24 lines
drivers/input/touchscreen/s3c2410_ts.c new file +24
-0+ ts.io =ioremap (res->start,resource_size (res)); +if (ts.io ==NULL ) { +dev_err (dev,"cannot map registers\n" ); + ret = -ENOMEM ; + goto err_clk; + } + +/* Configure the touchscreen external FETs on the S3C2410 */ +if (!platform_get_device_id (pdev)->driver_data) +s3c2410_ts_connect (); + + ts.client =s3c_adc_register (pdev, s3c24xx_ts_select, + s3c24xx_ts_conversion,1 ); +if (IS_ERR (ts.client)) { +dev_err (dev,"failed to register adc client\n" ); + ret =PTR_ERR (ts.client); + goto err_iomap; + } + +/* Initialise registers */ +if ((info->delay &0xffff ) >0 ) +writel (info->delay &0xffff , ts.io +S3C2410_ADCDLY ); + +writel (WAIT4INT |INT_DOWN , ts.io +S3C2410_ADCTSC );
drivers/input/touchscreen/s3c2410_ts.c line 335
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+ + input_dev =input_allocate_device (); +if (!input_dev) { +dev_err (dev,"Unable to allocate the input device !!\n" ); + ret = -ENOMEM ; + goto err_iomap; + } + + ts.input = input_dev; + ts.input->evbit[0 ] =BIT_MASK (EV_SYN ) |BIT_MASK (EV_KEY ) |BIT_MASK (EV_ABS );
No need setting EV_SYN explicitely.
drivers/input/touchscreen/s3c2410_ts.c line 339
Quoted 4 lines
drivers/input/touchscreen/s3c2410_ts.c new file +4
-0+ ts.input->keybit[BIT_WORD (BTN_TOUCH )] =BIT_MASK (BTN_TOUCH ); +input_set_abs_params (ts.input,ABS_X ,0 ,0x3FF ,0 ,0 ); +input_set_abs_params (ts.input,ABS_Y ,0 ,0x3FF ,0 ,0 ); +input_set_abs_params (ts.input,ABS_PRESSURE ,0 ,1 ,0 ,0 );
Drop ABS_PRESSURE.
drivers/input/touchscreen/s3c2410_ts.c line 352
Quoted 13 lines
drivers/input/touchscreen/s3c2410_ts.c new file +13
-0+ + ts.input->name = s3c2410ts_name; + ts.input->id.bustype =BUS_HOST ; + ts.input->id.vendor =0xDEAD ; + ts.input->id.product =0xBEEF ; + ts.input->id.version =S3C2410TSVERSION ; + + ts.shift = info->oversampling_shift; + +if (request_irq (ts.irq_tc, stylus_irq,IRQF_DISABLED , +"s3c2410_ts_pen" , ts.input)) { +dev_err (dev,"cannot get TC interrupt\n" ); + ret = -EIO ;
Don't mangle what request_irq returned.
Quoted 7 lines
drivers/input/touchscreen/s3c2410_ts.c new file +7
-0+ goto err_inputdev; + } + +dev_info (dev,"driver attached, registering input device\n" ); + +/* All went ok, so register to the input system */ + ret =input_register_device (ts.input);
drivers/input/touchscreen/s3c2410_ts.c line 369
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+if (ret <0 ) { +dev_err (dev,"failed to register input device\n" ); + ret = -EIO ; + goto err_tcirq; + } + +return 0 ; + + err_tcirq: +free_irq (ts.irq_tc, ts.input);
del_timer_sync().
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c new file +8
-0+ err_inputdev: +input_unregister_device (ts.input); + err_iomap: +iounmap (ts.io); + err_clk: +clk_put (ts.clock); +return ret; +}
drivers/input/touchscreen/s3c2410_ts.c line 387
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+ +/** +* s3c2410ts_remove - device core removal entry point +* @pdev: The device we are being removed from. +* +* Free up our state ready to be removed. +*/ +static int s3c2410ts_remove (struct platform_device *pdev) +{ +free_irq (ts.irq_tc, ts.input);
del_timer_sync().
drivers/input/touchscreen/s3c2410_ts.c line 393
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ +clk_disable (ts.clock); +clk_put (ts.clock); + +input_unregister_device (ts.input); +iounmap (ts.io);
release_mem_region()
Quoted 39 lines
drivers/input/touchscreen/s3c2410_ts.c new file +39
-0+ +return 0 ; +} + +#ifdef CONFIG_PM +static int s3c2410ts_suspend (struct platform_device *pdev,pm_message_t state) +{ +writel (TSC_SLEEP , ts.io +S3C2410_ADCTSC ); +disable_irq (ts.irq_tc); +clk_disable (ts.clock); + +return 0 ; +} + +static int s3c2410ts_resume (struct platform_device *pdev) +{ +struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; + +clk_enable (ts.clock); + +/* Initialise registers */ +if ((info->delay &0xffff ) >0 ) +writel (info->delay &0xffff , ts.io +S3C2410_ADCDLY ); + +writel (WAIT4INT |INT_DOWN , ts.io +S3C2410_ADCTSC ); + +return 0 ; +} + +#else +#define s3c2410ts_suspend NULL +#define s3c2410ts_resume NULL +#endif + +static struct platform_device_id s3cts_driver_ids[] = { + {"s3c2410-ts" ,0 }, + {"s3c2440-ts" ,1 }, + { } +};
drivers/input/touchscreen/s3c2410_ts.c line 442
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+MODULE_DEVICE_TABLE (platform, s3cts_driver_ids); + +static struct platform_driver s3c_ts_driver = { + .driver = { + .name ="s3c24xx-ts" , + .owner =THIS_MODULE , + }, + .id_table = s3cts_driver_ids, + .probe = s3c2410ts_probe, + .remove = s3c2410ts_remove,
__devexit_p()
drivers/input/touchscreen/s3c2410_ts.c line 444
Quoted 2 lines
drivers/input/touchscreen/s3c2410_ts.c new file +2
-0+ .suspend = s3c2410ts_suspend, + .resume = s3c2410ts_resume,
Switch to pm_ops.
Quoted 11 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+}; + +static int __init s3c2410ts_init (void ) +{ +return platform_driver_register (&s3c_ts_driver); +} + +static void __exit s3c2410ts_exit(void) +{ +platform_driver_unregister (&s3c_ts_driver);
drivers/input/touchscreen/s3c2410_ts.c line 464
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+} + +module_init (s3c2410ts_init); +module_exit (s3c2410ts_exit); + +MODULE_AUTHOR ("Arnaud Patard <[email protected]>, " +"Ben Dooks <[email protected]>, " +"Simtec Electronics <[email protected]>" ); +MODULE_DESCRIPTION ("S3C24XX Touchscreen driver" ); +MODULE_LICENSE ("GPL v2" );
Thanks!
Signature · 1 line
Dmitry
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
hi Dmitry,
Quoted 3 lines · Dmitry Torokhov
Thank you for the patch. First thing first - do we have an agreement from all Samsung folks and other interested parties that _this_ is the driver? Because it's like 3rd implementation that came across...
I think it is important we finally merge _a_ driver, giving users a useful touchscreen after many, many years of delay. Whoever has issues with that driver should simply address those issues and propose incremental patches to it.
This is speaking with both my former Openmoko "hat" as well as considering what is most important for Samsung System LSI.
Regards,
Signature · 4 lines
- Harald Welte <[email protected]> http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6)
Hi Ben,
Quoted 48 lines · Dmitry Torokhov
Quoted 35 lines
(quoted diff) +35
-0+#ifdef CONFIG_PM +static int s3c2410ts_suspend(struct platform_device *pdev, pm_message_t state) +{ + writel(TSC_SLEEP, ts.io + S3C2410_ADCTSC); + disable_irq(ts.irq_tc); + clk_disable(ts.clock); + + return 0; +} + +static int s3c2410ts_resume(struct platform_device *pdev) +{ + struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; + + clk_enable(ts.clock); + + /* Initialise registers */ + if ((info->delay & 0xffff) > 0) + writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY); + + writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); + + return 0; +} + +#else +#define s3c2410ts_suspend NULL +#define s3c2410ts_resume NULL +#endif + +static struct platform_device_id s3cts_driver_ids[] = { + { "s3c2410-ts", 0 }, + { "s3c2440-ts", 1 }, + { } +};Review
Quoted 10 lines
(quoted diff) +10
-0+MODULE_DEVICE_TABLE(platform, s3cts_driver_ids); + +static struct platform_driver s3c_ts_driver = { + .driver = { + .name = "s3c24xx-ts", + .owner = THIS_MODULE, + }, + .id_table = s3cts_driver_ids, + .probe = s3c2410ts_probe, + .remove = s3c2410ts_remove,
__devexit_p()
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ .suspend = s3c2410ts_suspend, + .resume = s3c2410ts_resume,Switch to
pm_ops.
For these comments from Dmitry I have implemented in my patch last month send to linux-input. You can refer
http://patchwork.kernel.org/patch/54933/ which maybe save some time for you.
Regards,
Shine Liu
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
In reply to Dmitry TorokhovQuoted 11 lines · Dmitry Torokhov
Hi Ben,
Quoted 7 lines · Ben Dooks
From: Arnaud Patard <[email protected]>
S3C24XX touchscreen driver, originally written by Arnaud Patard and other contributors. This driver is the version from the Simtec Electronics tree, and as such is the best place to start and thus proposed to be merged into the linux input system.
Quoted 3 lines
Thank you for the patch. First thing first - do we have an agreement from all Samsung folks and other interested parties that _this_ is the driver? Because it's like 3rd implementation that came across...
I belive this is the best of the current driver bases, and hopefully after this round of tidying will definitely be the best.
Quoted 28 lines
Quoted 28 lines
The driver has had substantial testing as well as a number of tidying up passes done by Ben Dooks, as noted:
- added kernel-doc comments to most of the routines
- removed old code from pre adc framework days
- updated device probe code to use platform id list matching
- cleaned up debug, sinceprintk()now has timestamp feature
- ensure code usesdev_()reporting macros where necessarySigned-off-by Arnaud Patard <[email protected]>Signed-off-by Simtec Linux Team <[email protected]>Signed-off-by Ben Dooks <[email protected]>--- drivers/input/touchscreen/Kconfig | 18 + drivers/input/touchscreen/Makefile | 1 drivers/input/touchscreen/s3c2410_ts.c | 464 +++++++++++++++++++++++++++++++++ 3 files changed, 483 insertions(+)Index: b/drivers/input/touchscreen/Kconfig
===================================================================drivers/input/touchscreen/Kconfig +0
-0@@ -133,6 +133,24 @@ config TOUCHSCREEN_FUJITSU To compile this driver as a module, choose M here: the module will be called fujitsu-ts.
Quoted 5 lines
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_FUJITSU · line 138
Quoted 3 lines
drivers/input/touchscreen/Kconfig +3
-0+config TOUCHSCREEN_S3C2410 + tristate "Samsung S3C2410 touchscreen input driver" + depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREENINPUT &&
INPUT_TOUCHSCREENare superfluous.
ok, removed
Quoted 1 line
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_FUJITSU · line 139
Quoted 1 line
drivers/input/touchscreen/Kconfig +1
-0+ select SERIO
removed
Quoted 17 lines
I don't think you need SERIO
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_FUJITSU · line 152
Quoted 13 lines
drivers/input/touchscreen/Kconfig +13
-0+ help + Say Y here if you have the s3c2410 touchscreen. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called s3c2410_ts. + +config TOUCHSCREEN_S3C2410_DEBUG + boolean "Samsung S3C2410 touchscreen debug messages" + depends on TOUCHSCREEN_S3C2410 + help + Select this if you want debug messagesWhere is this used?
thought it was used to define DEBUG in the driver, will look at removing this.
Quoted 49 lines
Quoted 49 lines
drivers/input/touchscreen/Kconfig +1
-0+ config TOUCHSCREEN_GUNZE tristate "Gunze AHL-51S touchscreen" select SERIOIndex: b/drivers/input/touchscreen/Makefile
===================================================================drivers/input/touchscreen/Makefile +1
-0@@ -26,6 +26,7 @@ obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jorn obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o +obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.oIndex:
b/drivers/input/touchscreen/s3c2410_ts.c
===================================================================drivers/input/touchscreen/s3c2410_ts.c new file +28
-0@@ -0,0 +1,464 @@ +/* drivers/input/touchscreen/s3c2410_ts.c +* +* Samsung S3C24XX touchscreen driver +* +* This program is free software; you can redistribute it and/or modify +* it under the term of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* Copyright 2004 Arnaud Patard <[email protected]> +* Copyright 2008 Ben Dooks <[email protected]> +* Copyright 2009 Simtec Electronics <[email protected]> +* +* Additional work by Herbert P?tzl <[email protected]> and +* Harald Welte <[email protected]> +*/ + +#include <linux/errno.h> +#include <linux/kernel.h>
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 34
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+#include <linux/module.h> +#include <linux/slab.h> +#include <linux/gpio.h> +#include <linux/input.h> +#include <linux/init.h> +#include <linux/serio.h> No serio in sight.
thanks, removed.
Quoted 26 lines
Quoted 26 lines
drivers/input/touchscreen/s3c2410_ts.c new file +26
-0+#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/io.h> + +#include <plat/adc.h> +#include <plat/regs-adc.h> + +#include <mach/regs-gpio.h> +#include <mach/ts.h> + +/* For ts.dev.id.version */ +#define S3C2410TSVERSION 0x0101 + +#define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0)) + +#define INT_DOWN (0) +#define INT_UP (1 << 8) + +#define WAIT4INT (S3C2410_ADCTSC_YM_SEN | \ + S3C2410_ADCTSC_YP_SEN | \ + S3C2410_ADCTSC_XP_SEN | \ + S3C2410_ADCTSC_XY_PST(3)) + +#define AUTOPST (S3C2410_ADCTSC_YM_SEN | \
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 66
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ S3C2410_ADCTSC_YP_SEN | \ + S3C2410_ADCTSC_XP_SEN | \ + S3C2410_ADCTSC_AUTO_PST | \ + S3C2410_ADCTSC_XY_PST(0)) + +#define DEBUG_LVL KERN_DEBUGDon't seem to be used.
thanks, removed.
Quoted 13 lines
Quoted 13 lines
drivers/input/touchscreen/s3c2410_ts.c new file +13
-0+ +static char *s3c2410ts_name ="s3c2410 TouchScreen" ; + +/* Per-touchscreen data. */ + +/** +* struct s3c2410ts - driver touchscreen state. +* @client: The ADC client we registered with the core driver. +* @dev: The device we are bound to. +* @input: The input device we registered with the input subsystem. +* @clock: The clock for the adc. +* @io: Pointer to the IO base. +* @xp: The accumulated X position data.
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 84
Quoted 5 lines
drivers/input/touchscreen/s3c2410_ts.c new file +5
-0+* @yp: The accumulated Y position data. +* @irq_tc: The interrupt number for pen up/down interrupt +* @count: The number of samples collected. +* @shift: The log2 of the maximum count to read in one go. +*/ These sructures are driver-internal and so don't need to be kernel-doc-ed. Same goes for the driver-private functions.
I like having the documentation, and I would much prefer to leave it in as useful.
Quoted 23 lines
Quoted 23 lines
drivers/input/touchscreen/s3c2410_ts.c new file +23
-0+struct s3c2410ts { +struct s3c_adc_client *client; +struct device *dev; +struct input_dev *input; +struct clk *clock; +void __iomem *io; +unsigned long xp; +unsigned long yp; +int irq_tc; +int count; +int shift; +}; + +static struct s3c2410ts ts; + +/** +* s3c2410_ts_connect - configure gpio for s3c2410 systems +* +* Configure the GPIO for the S3C2410 system, where we have external FETs +* connected to the device (later systems such as the S3C2440 integrate +* these into the device). +*/ +static inline void s3c2410_ts_connect (void )
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 112
Quoted 5 lines
drivers/input/touchscreen/s3c2410_ts.c new file +5
-0+{ +s3c2410_gpio_cfgpin (S3C2410_GPG (12 ),S3C2410_GPG12_XMON ); +s3c2410_gpio_cfgpin (S3C2410_GPG (13 ), S3C2410_GPG13_nXPON); +s3c2410_gpio_cfgpin (S3C2410_GPG (14 ),S3C2410_GPG14_YMON ); +s3c2410_gpio_cfgpin (S3C2410_GPG (15 ), S3C2410_GPG15_nYPON);No gpiolib? Also, should it be in the driver or maybe in the platform code?
gpiolib doesn't deal with pin function configuration past input or output. All these gpios need to be in their special-function mode.
If people really object, this can be removed and the machine support files changed.
Quoted 4 lines
Quoted 4 lines
drivers/input/touchscreen/s3c2410_ts.c new file +4
-0+} + +/** +* get_down - return the down state of the pen
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 122
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+* @data0: The data read from ADCDAT0 register. +* @data1: The data read from ADCDAT1 register. +* +* Return non-zero if both readings show that the pen is down. +*/ +static inline int get_down (unsigned long data0,unsigned long data1)bool?
thanks, fixed.
Quoted 5 lines
Quoted 5 lines
drivers/input/touchscreen/s3c2410_ts.c new file +5
-0+{ +/* returns true if both data values show stylus down */ +return (!(data0 &S3C2410_ADCDAT0_UPDOWN ) && + !(data1 &S3C2410_ADCDAT0_UPDOWN )); +}
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 133
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ +static void touch_timer_fire (unsigned long data) +{ +unsigned long data0; +unsigned long data1; +int down;bool?
thanks, fixed.
Quoted 9 lines
drivers/input/touchscreen/s3c2410_ts.c line 140
Quoted 7 lines
drivers/input/touchscreen/s3c2410_ts.c new file +7
-0+ + data0 =readl (ts.io +S3C2410_ADCDAT0 ); + data1 =readl (ts.io +S3C2410_ADCDAT1 ); + + down =get_down (data0, data1); + +if (ts.count == (1 <<ts.shift)) {Syyle: x << y
thanks, fixed.
Quoted 5 lines
Quoted 5 lines
drivers/input/touchscreen/s3c2410_ts.c new file +5
-0+ ts.xp >>= ts.shift; + ts.yp >>= ts.shift; + +dev_dbg (ts.dev,"%s: X=%lu, Y=%lu, count=%d\n" , + __func__, ts.xp, ts.yp, ts.count);
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 151
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ +input_report_abs (ts.input,ABS_X , ts.xp); +input_report_abs (ts.input,ABS_Y , ts.yp); + +input_report_key (ts.input,BTN_TOUCH ,1 ); +input_report_abs (ts.input,ABS_PRESSURE ,1 );No fake pressure events please,
BTN_TOUCHshould be enough.
I'd have to check, IIRC tslib needs these to function properly.
Quoted 15 lines
Quoted 15 lines
drivers/input/touchscreen/s3c2410_ts.c new file +15
-0+input_sync (ts.input); + + ts.xp =0 ; + ts.yp =0 ; + ts.count =0 ; + } + +if (down) { +s3c_adc_start (ts.client,0 ,1 << ts.shift); + }else { + ts.count =0 ; + +input_report_key (ts.input,BTN_TOUCH ,0 ); +input_report_abs (ts.input,ABS_PRESSURE ,0 ); +input_sync (ts.input);
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 172
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ +writel (WAIT4INT |INT_DOWN , ts.io +S3C2410_ADCTSC ); + } +} + +static struct timer_list touch_timer =TIMER_INITIALIZER (touch_timer_fire,0 ,0 );static
DEFINE_TIMER(...);
ok, thanks.
Quoted 81 lines
Quoted 81 lines
drivers/input/touchscreen/s3c2410_ts.c new file +81
-0+ +/** +* stylus_irq - touchscreen stylus event interrupt +* @irq: The interrupt number +* @dev_id: The device ID. +* +* Called when the IRQ_TC is fired for a pen up or down event. +*/ +static irqreturn_t stylus_irq (int irq,void *dev_id) +{ +unsigned long data0; +unsigned long data1; +int down; + + data0 =readl (ts.io +S3C2410_ADCDAT0 ); + data1 =readl (ts.io +S3C2410_ADCDAT1 ); + + down =get_down (data0, data1); + +/* TODO we should never get an interrupt with down set while +* the timer is running, but maybe we ought to verify that the +* timer isn't running anyways. */ + +if (down) +s3c_adc_start (ts.client,0 ,1 << ts.shift); +else +dev_info (ts.dev,"%s: count=%d\n" , __func__, ts.count); + +return IRQ_HANDLED ; +} + +/** +* s3c24xx_ts_conversion - ADC conversion callback +* @client: The client that was registered with the ADC core. +* @data0: The reading from ADCDAT0. +* @data1: The reading from ADCDAT1. +* @left: The number of samples left. +* +* Called when a conversion has finished. +*/ +static void s3c24xx_ts_conversion (struct s3c_adc_client *client, +unsigned data0,unsigned data1, +unsigned *left) +{ +dev_dbg (ts.dev,"%s: %d,%d\n" , __func__, data0, data1); + + ts.xp += data0; + ts.yp += data1; + + ts.count++; + +/* From tests, it seems that it is unlikely to get a pen-up +* event during the conversion process which means we can +* ignore any pen-up events with less than the requisite +* count done. +* +* In several thousand conversions, no pen-ups where detected +* before count completed. +*/ +} + +/** +* s3c24xx_ts_select - ADC selection callback. +* @client: The client that was registered with the ADC core. +* @select: The reason for select. +* +* Called when the ADC core selects (or deslects) us as a client. +*/ +static void s3c24xx_ts_select (struct s3c_adc_client *client,unsigned select) +{ +if (select) { +writel (S3C2410_ADCTSC_PULL_UP_DISABLE |AUTOPST , + ts.io +S3C2410_ADCTSC ); + }else { +mod_timer (&touch_timer, jiffies+1 ); +writel (WAIT4INT |INT_UP , ts.io +S3C2410_ADCTSC ); + } +} + +/** +* s3c2410ts_probe - device core probe entry point
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 259
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+* @pdev: The device we are being bound to. +* +* Initialise, find and allocate any resources we need to run and then +* register with the ADC and input systems. +*/ +static int __init s3c2410ts_probe (struct platform_device *pdev)
__devinitor switch toplatform_driver_probe().
thanks, fixed.
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 265
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+{ +struct s3c2410_ts_mach_info *info; +struct device *dev = &pdev->dev; +struct input_dev *input_dev; +struct resource *res; +int ret = -EINVAL ;Can we call it "error" (since that's what you use it for).
Is it really necessary to change this?
Quoted 30 lines
Quoted 30 lines
drivers/input/touchscreen/s3c2410_ts.c new file +30
-0+ +/* Initialise input stuff */ +memset (&ts,0 ,sizeof (struct s3c2410ts )); + + ts.dev = dev; + + info = pdev->dev.platform_data; +if (!info) { +dev_err (dev,"no platform data, cannot attach\n" ); +return -EINVAL ; + } + +dev_dbg (dev,"initialising touchscreen\n" ); + + ts.clock =clk_get (dev,"adc" ); +if (IS_ERR (ts.clock)) { +dev_err (dev,"cannot get adc clock source\n" ); +return -ENOENT ; + } + +clk_enable (ts.clock); +dev_dbg (dev,"got and enabled clocks\n" ); + + ts.irq_tc = ret =platform_get_irq (pdev,0 ); +if (ret <0 ) { +dev_err (dev,"no resource for interrupt\n" ); + goto err_clk; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 301
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+if (!res) { +dev_err (dev,"no resource for registers\n" ); + ret = -ENOENT ; + goto err_clk; + } +
request_mem_region()here?
I'll check if it possible for both the adc and this driver to claim this region.
Quoted 28 lines
Quoted 28 lines
drivers/input/touchscreen/s3c2410_ts.c new file +28
-0+ ts.io =ioremap (res->start,resource_size (res)); +if (ts.io ==NULL ) { +dev_err (dev,"cannot map registers\n" ); + ret = -ENOMEM ; + goto err_clk; + } + +/* Configure the touchscreen external FETs on the S3C2410 */ +if (!platform_get_device_id (pdev)->driver_data) +s3c2410_ts_connect (); + + ts.client =s3c_adc_register (pdev, s3c24xx_ts_select, + s3c24xx_ts_conversion,1 ); +if (IS_ERR (ts.client)) { +dev_err (dev,"failed to register adc client\n" ); + ret =PTR_ERR (ts.client); + goto err_iomap; + } + +/* Initialise registers */ +if ((info->delay &0xffff ) >0 ) +writel (info->delay &0xffff , ts.io +S3C2410_ADCDLY ); + +writel (WAIT4INT |INT_DOWN , ts.io +S3C2410_ADCTSC ); + + input_dev =input_allocate_device (); +if (!input_dev) { +dev_err (dev,"Unable to allocate the input device !!\n" );
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 335
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ ret = -ENOMEM ; + goto err_iomap; + } + + ts.input = input_dev; + ts.input->evbit[0 ] =BIT_MASK (EV_SYN ) |BIT_MASK (EV_KEY ) |BIT_MASK (EV_ABS );No need setting
EV_SYNexplicitely.
ok, fixed.
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c line 339
Quoted 4 lines
drivers/input/touchscreen/s3c2410_ts.c new file +4
-0+ ts.input->keybit[BIT_WORD (BTN_TOUCH )] =BIT_MASK (BTN_TOUCH ); +input_set_abs_params (ts.input,ABS_X ,0 ,0x3FF ,0 ,0 ); +input_set_abs_params (ts.input,ABS_Y ,0 ,0x3FF ,0 ,0 ); +input_set_abs_params (ts.input,ABS_PRESSURE ,0 ,1 ,0 ,0 );Drop
ABS_PRESSURE.
ok, see above.
Quoted 7 lines
Quoted 7 lines
drivers/input/touchscreen/s3c2410_ts.c new file +7
-0+ + ts.input->name = s3c2410ts_name; + ts.input->id.bustype =BUS_HOST ; + ts.input->id.vendor =0xDEAD ; + ts.input->id.product =0xBEEF ; + ts.input->id.version =S3C2410TSVERSION ; +
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 352
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ ts.shift = info->oversampling_shift; + +if (request_irq (ts.irq_tc, stylus_irq,IRQF_DISABLED , +"s3c2410_ts_pen" , ts.input)) { +dev_err (dev,"cannot get TC interrupt\n" ); + ret = -EIO ;Don't mangle what
request_irqreturned.
ok, fixed.
Quoted 11 lines
Quoted 11 lines
drivers/input/touchscreen/s3c2410_ts.c new file +11
-0+ goto err_inputdev; + } + +dev_info (dev,"driver attached, registering input device\n" ); + +/* All went ok, so register to the input system */ + ret =input_register_device (ts.input); +if (ret <0 ) { +dev_err (dev,"failed to register input device\n" ); + ret = -EIO ; + goto err_tcirq;
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 369
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ } + +return 0 ; + + err_tcirq: +free_irq (ts.irq_tc, ts.input);
del_timer_sync().
added.
Quoted 12 lines
Quoted 12 lines
drivers/input/touchscreen/s3c2410_ts.c new file +12
-0+ err_inputdev: +input_unregister_device (ts.input); + err_iomap: +iounmap (ts.io); + err_clk: +clk_put (ts.clock); +return ret; +} + +/** +* s3c2410ts_remove - device core removal entry point +* @pdev: The device we are being removed from.
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 387
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+* +* Free up our state ready to be removed. +*/ +static int s3c2410ts_remove (struct platform_device *pdev) +{ +free_irq (ts.irq_tc, ts.input);
del_timer_sync().
added, thanks.
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 393
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +6
-0+ +clk_disable (ts.clock); +clk_put (ts.clock); + +input_unregister_device (ts.input); +iounmap (ts.io);
release_mem_region()
see above.
Quoted 52 lines
Quoted 39 lines
drivers/input/touchscreen/s3c2410_ts.c new file +39
-0+ +return 0 ; +} + +#ifdef CONFIG_PM +static int s3c2410ts_suspend (struct platform_device *pdev,pm_message_t state) +{ +writel (TSC_SLEEP , ts.io +S3C2410_ADCTSC ); +disable_irq (ts.irq_tc); +clk_disable (ts.clock); + +return 0 ; +} + +static int s3c2410ts_resume (struct platform_device *pdev) +{ +struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; + +clk_enable (ts.clock); + +/* Initialise registers */ +if ((info->delay &0xffff ) >0 ) +writel (info->delay &0xffff , ts.io +S3C2410_ADCDLY ); + +writel (WAIT4INT |INT_DOWN , ts.io +S3C2410_ADCTSC ); + +return 0 ; +} + +#else +#define s3c2410ts_suspend NULL +#define s3c2410ts_resume NULL +#endif + +static struct platform_device_id s3cts_driver_ids[] = { + {"s3c2410-ts" ,0 }, + {"s3c2440-ts" ,1 }, + { } +};drivers/input/touchscreen/s3c2410_ts.c line 442
Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c new file +10
-0+MODULE_DEVICE_TABLE (platform, s3cts_driver_ids); + +static struct platform_driver s3c_ts_driver = { + .driver = { + .name ="s3c24xx-ts" , + .owner =THIS_MODULE , + }, + .id_table = s3cts_driver_ids, + .probe = s3c2410ts_probe, + .remove = s3c2410ts_remove,
__devexit_p()
Quoted 4 lines
drivers/input/touchscreen/s3c2410_ts.c line 444
Quoted 2 lines
drivers/input/touchscreen/s3c2410_ts.c new file +2
-0+ .suspend = s3c2410ts_suspend, + .resume = s3c2410ts_resume,Switch to
pm_ops.
ok, will do. may as well remove the #ifdef CONFIG_PM for such small amount of code too.
Quoted 15 lines
Quoted 15 lines
drivers/input/touchscreen/s3c2410_ts.c new file +15
-0+}; + +static int __init s3c2410ts_init (void ) +{ +return platform_driver_register (&s3c_ts_driver); +} + +static void __exit s3c2410ts_exit(void) +{ +platform_driver_unregister (&s3c_ts_driver); +} + +module_init (s3c2410ts_init); +module_exit (s3c2410ts_exit); +
Quoted 8 lines
drivers/input/touchscreen/s3c2410_ts.c line 464
Quoted 6 lines
drivers/input/touchscreen/s3c2410_ts.c new file +5
-0+MODULE_AUTHOR ("Arnaud Patard <[email protected]>, " +"Ben Dooks <[email protected]>, " +"Simtec Electronics <[email protected]>" ); +MODULE_DESCRIPTION ("S3C24XX Touchscreen driver" ); +MODULE_LICENSE ("GPL v2" );Thanks!
I'll try and work on the to-do items and do another round of testing before the weekend.
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Quoted 4 lines · Ben Dooks
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ input_report_key(ts.input, BTN_TOUCH, 1); + input_report_abs(ts.input, ABS_PRESSURE, 1);No fake pressure events please,
BTN_TOUCHshould be enough.I'd have to check, IIRC tslib needs these to function properly.
Indeed it does -- otherwise it won't work. Yes you could try going around and patching TSLIB but so many people use it that it is principle-of-least-surprise to produce pressure events.
Quoted 6 lines
Quoted 5 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);Drop
ABS_PRESSURE.ok, see above.
The same applies here -- claim ABS_PRESSURE or tslib won't operate with the touchscreen.
While it is tempting to be 100% exactly correct to what the hardware reports (which is only TOUCH not PRESSURE) it is preferable to work with the software which the majority of people use -- namely tslib.
I would strongly argue against removing the ABS_PRESSURE stuff personally, despite it being essentially a lie.
Regards,
Daniel.
Signature · 1 line
Daniel Silverstone http://www.simtec.co.uk/
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Quoted 20 lines · Daniel Silverstone
Quoted 4 lines · Ben Dooks
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ input_report_key(ts.input, BTN_TOUCH, 1); + input_report_abs(ts.input, ABS_PRESSURE, 1);No fake pressure events please,
BTN_TOUCHshould be enough.I'd have to check, IIRC tslib needs these to function properly.
Indeed it does -- otherwise it won't work. Yes you could try going around and patching TSLIB but so many people use it that it is principle-of-least-surprise to produce pressure events.
Quoted 6 lines
Quoted 5 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);Drop
ABS_PRESSURE.ok, see above.
The same applies here -- claim
ABS_PRESSUREor tslib won't operate with the touchscreen.
Quoted 7 lines
While it is tempting to be 100% exactly correct to what the hardware reports (which is only TOUCH not PRESSURE) it is preferable to work with the software which the majority of people use -- namely tslib.
I would strongly argue against removing the
ABS_PRESSUREstuff personally, despite it being essentially a lie.
And I would strongly argue that you just need to update your tslib, especially given the fact that this issue was dealt with there about a year ago. And if you really need that fix to be in released (read 'tagged') version of tslib - please speak to its maintainer.
Why everyone thinks that it is a good idea to pile workarounds for software issues in the kernel but updating the other parts of software stack is a big no-no?
Signature · 1 line
Dmitry
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Quoted 3 lines · Dmitry Torokhov
Why everyone thinks that it is a good idea to pile workarounds for software issues in the kernel but updating the other parts of software stack is a big no-no?
It's probably because pressing 'reset' and have your board TFTP the new kernel straight from your development machine is far easier than going through the hoops to regenerate a root filesystem and reflashing it.
Note that I'm not condoning it, just pointing out why it happens. And yes, we must resist the temptation to merge such workarounds.
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
In reply to Dmitry TorokhovQuoted 19 lines · Dmitry Torokhov
Quoted 18 lines · Daniel Silverstone
Quoted 4 lines · Ben Dooks
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ input_report_key(ts.input, BTN_TOUCH, 1); + input_report_abs(ts.input, ABS_PRESSURE, 1);No fake pressure events please,
BTN_TOUCHshould be enough.I'd have to check, IIRC tslib needs these to function properly.
Indeed it does -- otherwise it won't work. Yes you could try going around and patching TSLIB but so many people use it that it is principle-of-least-surprise to produce pressure events.
Quoted 6 lines
Quoted 5 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);Drop
ABS_PRESSURE.ok, see above.
The same applies here -- claim
ABS_PRESSUREor tslib won't operate with the touchscreen.
Quoted 6 lines
Quoted 6 lines
While it is tempting to be 100% exactly correct to what the hardware reports (which is only TOUCH not PRESSURE) it is preferable to work with the software which the majority of people use -- namely tslib.
I would strongly argue against removing the
ABS_PRESSUREstuff personally, despite it being essentially a lie.
ok, i'll remove it and anyone who can't be bothered to update their tslib can hack in their own solution if they really care about it.
Quoted 8 lines
And I would strongly argue that you just need to update your tslib, especially given the fact that this issue was dealt with there about a year ago. And if you really need that fix to be in released (read 'tagged') version of tslib - please speak to its maintainer.
Why everyone thinks that it is a good idea to pile workarounds for software issues in the kernel but updating the other parts of software stack is a big no-no?
it can be much more difficult to update a userland than to hack the kernel...
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
In reply to Ben DooksQuoted 4 lines · Ben Dooks
Quoted 2 lines · Dmitry Torokhov
Review
Quoted 2 lines
(quoted diff) +2
-0+ +static char *s3c2410ts_name = "s3c2410 TouchScreen";
Btw, "static char s3c2410ts_name[]" will save you a pointer. But, it looks like it is used only once, in probe(), so just put it there.
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +11
-0+ +/* Per-touchscreen data. */ + +/** + * struct s3c2410ts - driver touchscreen state. + * @client: The ADC client we registered with the core driver. + * @dev: The device we are bound to. + * @input: The input device we registered with the input subsystem. + * @clock: The clock for the adc. + * @io: Pointer to the IO base. + * @xp: The accumulated X position data.Quoted 8 lines
Quoted 5 lines
+ * @yp: The accumulated Y position data.
+ * @irq_tc: The interrupt number for pen up/down interrupt
+ * @count: The number of samples collected.
+ * @shift: The log2 of the maximum count to read in one go.
+ */These sructures are driver-internal and so don't need to be kernel-doc-ed. Same goes for the driver-private functions.
Quoted 3 lines
I like having the documentation, and I would much prefer to leave it in as useful.
Ah, I wasn't requiesting to remove the documentation, I was just saying that since these data structures and fucntions are driver-provate they don't need to use kernel-doc style.
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ + input_report_key(ts.input, BTN_TOUCH, 1); + input_report_abs(ts.input, ABS_PRESSURE, 1);No fake pressure events please,
BTN_TOUCHshould be enough.I'd have to check, IIRC tslib needs these to function properly.
Just update your tslib, the issue was fixed there last November.
Quoted 11 lines
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+{ + struct s3c2410_ts_mach_info *info; + struct device *dev = &pdev->dev; + struct input_dev *input_dev; + struct resource *res; + int ret = -EINVAL;Can we call it "error" (since that's what you use it for).
Is it really necessary to change this?
No, it is my personal preference/style. In case when it is used like:
var = blah(); if (var) goto err_unblah; return 0;
err_unblah:
unblah(); return var; }
I prefer that var called 'error'. If the value is returned on both error and success paths then I call it 'ret', 'retval', etc.
But no, if you prefer 'ret' that is fine too.
Quoted 9 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ .suspend = s3c2410ts_suspend, + .resume = s3c2410ts_resume,Switch to
pm_ops.ok, will do. may as well remove the #ifdef
CONFIG_PMfor such small amount of code too.
As long as it does not break when CONFIG_PM is not set...
Signature · 1 line
Dmitry
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Hi!
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 5 lines
(quoted diff) +5
-0+/* Per-touchscreen data. */ + +/** + * struct s3c2410ts - driver touchscreen state. + * @client: The ADC client we registered with the core driver.Review
Quoted 10 lines
(quoted diff) +10
-0+ * @dev: The device we are bound to. + * @input: The input device we registered with the input subsystem. + * @clock: The clock for the adc. + * @io: Pointer to the IO base. + * @xp: The accumulated X position data. + * @yp: The accumulated Y position data. + * @irq_tc: The interrupt number for pen up/down interrupt + * @count: The number of samples collected. + * @shift: The log2 of the maximum count to read in one go. + */These sructures are driver-internal and so don't need to be kernel-doc-ed. Same goes for the driver-private functions.
Quoted 6 lines
Quoted 2 lines
I like having the documentation, and I would much prefer to leave it in as useful.
Ah, I wasn't requiesting to remove the documentation, I was just saying that since these data structures and fucntions are driver-provate they don't need to use kernel-doc style.
Well.. consistent style of documentation is nice, be it driver-private or public stuff.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
In reply to Ben DooksHi,Ben
Besides Dmitry's comments,
Review
Quoted 11 lines · Ben Dooks
(quoted diff) +11
-0+config TOUCHSCREEN_S3C2410 + tristate "Samsung S3C2410 touchscreen input driver" + depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN + select SERIO + help + Say Y here if you have the s3c2410 touchscreen. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called s3c2410_ts.
S3C24XX_ADC should be added to the depends.
Quoted 1 line
+#include <
linux/slab.h>
I think this is not really needed because kernel.h is included already.
Review
Quoted 9 lines
(quoted diff) +9
-0+ + ts.clock = clk_get(dev, "adc"); + if (IS_ERR(ts.clock)) { + dev_err(dev, "cannot get adc clock source\n"); + return -ENOENT; + } + + clk_enable(ts.clock); + dev_dbg(dev, "got and enabled clocks\n");
Well, we take 2410_ts as s3c adc client, so these work has been done in s3c_adc_probe function of arch/arm/plat-s3c24xx.c
This should be duplicated.
And "#include <linux/clk.h>" is not needed because we don't use these APIs
Review
Quoted 4 lines
+
err_clk:(quoted diff) +3
-0+ clk_put(ts.clock); + return ret; +}
Above reason and also for those "goto err_clk;"
Review
Quoted 4 lines
);
(quoted diff) +3
-0+ + clk_disable(ts.clock); + clk_put(ts.clock);
Same as above
Review
Quoted 6 lines
(quoted diff) +6
-0+ +#ifdef CONFIG_PM +static int s3c2410ts_suspend(struct platform_device *pdev, pm_message_t state) +{ + writel(TSC_SLEEP, ts.io + S3C2410_ADCTSC); + disable_irq(ts.irq_tc);
Same as above
Review
Quoted 6 lines
(quoted diff) +6
-0+ +static int s3c2410ts_resume(struct platform_device *pdev) +{ + struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; + + clk_enable(ts.clock);
Same as above
Cheers,
Shine
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Quoted 15 lines · Shine Liu
Review
Quoted 11 lines · Ben Dooks
(quoted diff) +11
-0+config TOUCHSCREEN_S3C2410 + tristate "Samsung S3C2410 touchscreen input driver" + depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN + select SERIO + help + Say Y here if you have the s3c2410 touchscreen. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called s3c2410_ts.
S3C24XX_ADCshould be added to the depends.
It's probably more friendly to select rather than depend on it to avoid the option being hidden.
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
Quoted 17 lines · Mark Brown
Quoted 15 lines · Shine Liu
Review
Quoted 11 lines · Ben Dooks
(quoted diff) +11
-0+config TOUCHSCREEN_S3C2410 + tristate "Samsung S3C2410 touchscreen input driver" + depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN + select SERIO + help + Say Y here if you have the s3c2410 touchscreen. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called s3c2410_ts.
S3C24XX_ADCshould be added to the depends.
Quoted 2 lines
It's probably more friendly to select rather than depend on it to avoid the option being hidden.
I prefer the 'select S3C24XX_ADC' and have the symbol available.
Will update the patch.
PATCH 1/1 TOUCHSCREEN: S3C24XX touchscreen driver from Arnaud Patard.
In reply to Ben Dooks? ????????? ?? 19 ?????? 2009 1:29:40 ????? Ben Dooks ???????:
<skipped>
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* Initialise registers */ + if ((info->delay & 0xffff) > 0) + writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY);
As for me, it's not OK to modity ADC-related registers in touchscreen driver, adc driver should be modified to support delay.
Regards
Vasily
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20091119/5890c791/attachment.sig>