1 From f7dad1cd9c1bd3fce5d228e0b644a51baea50cd9 Mon Sep 17 00:00:00 2001
2 From: Dmitry Baryshkov <dbaryshkov@gmail.com>
3 Date: Fri, 15 Feb 2008 15:35:07 +0300
4 Subject: [PATCH] Preliminary tosa denoiser
6 Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
8 drivers/input/touchscreen/Kconfig | 12 ++
9 drivers/input/touchscreen/Makefile | 1 +
10 drivers/input/touchscreen/tosa-wm97xx.c | 182 +++++++++++++++++++++++++++++++
11 3 files changed, 195 insertions(+), 0 deletions(-)
12 create mode 100644 drivers/input/touchscreen/tosa-wm97xx.c
14 diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
15 index 0be05a2..938aed2 100644
16 --- a/drivers/input/touchscreen/Kconfig
17 +++ b/drivers/input/touchscreen/Kconfig
18 @@ -210,6 +210,18 @@ config TOUCHSCREEN_WM97XX_MAINSTONE
19 To compile this driver as a module, choose M here: the
20 module will be called mainstone-wm97xx
22 +config TOUCHSCREEN_WM97XX_TOSA
23 + tristate "WM97xx Tosa denoiser"
24 + depends on TOUCHSCREEN_WM97XX && MACH_TOSA
26 + Say Y here for support for touchscreen denoising on
27 + Sharl Zaurus SL-6000 (tosa) system.
31 + To compile this driver as a module, choose M here: the
32 + module will be called tosa-wm97xx
34 config TOUCHSCREEN_TOUCHWIN
35 tristate "Touchwin serial touchscreen"
37 diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
38 index d38156e..d86278b 100644
39 --- a/drivers/input/touchscreen/Makefile
40 +++ b/drivers/input/touchscreen/Makefile
41 @@ -23,6 +23,7 @@ obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o
42 obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o
43 obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o
44 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o
45 +obj-$(CONFIG_TOUCHSCREEN_WM97XX_TOSA) += tosa-wm97xx.o
46 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o
47 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
48 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
49 diff --git a/drivers/input/touchscreen/tosa-wm97xx.c b/drivers/input/touchscreen/tosa-wm97xx.c
51 index 0000000..8fd542b
53 +++ b/drivers/input/touchscreen/tosa-wm97xx.c
56 + * tosa_ts.c -- Touchscreen driver for Sharp SL-6000 (Tosa).
58 + * Copyright 2008 Dmitry Baryshkov
59 + * Copyright 2006 Wolfson Microelectronics PLC.
60 + * Author: Mike Arthur
61 + * linux@wolfsonmicro.com
63 + * This program is free software; you can redistribute it and/or modify it
64 + * under the terms of the GNU General Public License as published by the
65 + * Free Software Foundation; either version 2 of the License, or (at your
66 + * option) any later version.
69 + * 1st Sep 2006 Initial version.
73 +#include <linux/kernel.h>
74 +#include <linux/module.h>
75 +#include <linux/platform_device.h>
76 +#include <linux/wm97xx.h>
77 +#include <linux/fb.h>
79 +#include <asm/arch/tosa.h>
80 +#include <asm/gpio.h>
82 +static unsigned long hsync_time = 0;
84 +static void calc_hsync_time(const struct fb_videomode *mode)
86 + /* The 25 and 44 'magic numbers' are from Sharp's 2.4 patches */
87 + if (mode->yres == 640) {
89 + } else if (mode->yres == 320) {
92 + printk(KERN_ERR "unknown video mode res specified: %dx%d!", mode->xres, mode->yres);
96 + printk(KERN_ERR "tosa-wm97xx: using %lu hsync time\n", hsync_time);
99 +static int fb_notifier_callback(struct notifier_block *self,
100 + unsigned long event, void *_data)
102 + if (event != FB_EVENT_MODE_CHANGE && event != FB_EVENT_MODE_CHANGE_ALL)
105 + calc_hsync_time(tosa_lcd_get_mode());
110 +static void tosa_lcd_wait_hsync(void)
112 + /* Waits for a rising edge on the VGA line */
113 + while (gpio_get_value(TOSA_GPIO_VGA_LINE) == 0);
114 + while (gpio_get_value(TOSA_GPIO_VGA_LINE) != 0);
117 +/* Taken from the Sharp 2.4 kernel code */
118 +#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
119 +#define CCNT_ON() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1))
120 +#define CCNT_OFF() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(0))
122 +/* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait
123 + * before sampling the Y axis of the touchscreen */
124 +static void tosa_lcd_sync_on(int adcsel)
126 + unsigned long timer1 = 0, timer2 = 0, wait_time = 0;
127 + if (adcsel & WM97XX_ADCSEL_Y) {
129 + wait_time = hsync_time;
133 + /* wait for LCD rising edge */
134 + tosa_lcd_wait_hsync();
139 + while ((timer2 - timer1) < wait_time) {
146 +static void tosa_lcd_sync_off(int adcsel)
148 + if (adcsel & WM97XX_ADCSEL_Y)
152 +static struct wm97xx_mach_ops tosa_mach_ops = {
153 + .pre_sample = tosa_lcd_sync_on,
154 + .post_sample = tosa_lcd_sync_off,
157 +static int __devinit tosa_ts_probe(struct platform_device *dev) {
158 + struct wm97xx *wm = platform_get_drvdata(dev);
159 + struct notifier_block *notif;
162 + notif = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
166 + notif->notifier_call = fb_notifier_callback;
168 + err = gpio_request(TOSA_GPIO_VGA_LINE, "hsync");
172 + err = gpio_direction_input(TOSA_GPIO_VGA_LINE);
176 + platform_set_drvdata(dev, notif);
178 + err = fb_register_client(notif);
182 + err = wm97xx_register_mach_ops(wm, &tosa_mach_ops);
186 + calc_hsync_time(tosa_lcd_get_mode());
191 + fb_unregister_client(notif);
193 + gpio_free(TOSA_GPIO_VGA_LINE);
201 +static int __devexit tosa_ts_remove(struct platform_device *dev) {
202 + struct wm97xx *wm = platform_get_drvdata(dev);
204 + wm97xx_unregister_mach_ops(wm);
206 + fb_unregister_client(platform_get_drvdata(dev));
207 + gpio_free(TOSA_GPIO_VGA_LINE);
208 + kfree(platform_get_drvdata(dev));
213 +static struct platform_driver tosa_ts_driver = {
214 + .driver.name = "wm97xx-touch",
215 + .driver.owner = THIS_MODULE,
216 + .probe = tosa_ts_probe,
217 + .remove = __devexit_p(tosa_ts_remove),
220 +static int __init tosa_ts_init(void)
222 + return platform_driver_register(&tosa_ts_driver);
225 +static void __exit tosa_ts_exit(void)
227 + platform_driver_unregister(&tosa_ts_driver);
230 +module_init(tosa_ts_init);
231 +module_exit(tosa_ts_exit);
233 +/* Module information */
234 +MODULE_AUTHOR("Dmitry Baryshkov, Mike Arthur, mike@mikearthur.co.uk, www.wolfsonmicro.com");
235 +MODULE_DESCRIPTION("Sharp SL6000 Tosa Touch Screen Denoiser");
236 +MODULE_LICENSE("GPL");