From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Dmitry Torokhov <dtor@mail.ru>
Cc: linux-input@atrey.karlin.mff.cuni.cz,
linux-kernel@vger.kernel.org,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Liam Girdwood <liam.girdwood@wolfsonmicro.com>,
Graeme Gregory <gg@opensource.wolfsonmicro.com>,
Mike Arthur <mike.arthur@wolfsonmicro.com>,
Dmitry Baryshkov <dbaryshkov@gmail.com>,
Stanley Cai <stanley.cai@intel.com>,
Rodolfo Giometti <giometti@enneenne.com>,
Russell King <rmk@arm.linux.org.uk>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Pete MacKay <linux01@architechnical.net>,
Ian Molton <spyro@f2s.com>, Vince Sanders <vince@kyllikki.org>,
Andrew Zabolotny <zap@homelink.ru>
Subject: [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone
Date: Tue, 12 Feb 2008 10:21:44 +0000 [thread overview]
Message-ID: <1202811705-2303-5-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1202811705-2303-4-git-send-email-broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
Signed-off-by: Graeme Gregory <gg@opensource.wolfsonmicro.com>
Signed-off-by: Mike Arthur <mike.arthur@wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Dmitry Baryshkov <dbaryshkov@gmail.com>
Cc: Stanley Cai <stanley.cai@intel.com>
Cc: Rodolfo Giometti <giometti@enneenne.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Pete MacKay <linux01@architechnical.net>
Cc: Ian Molton <spyro@f2s.com>
Cc: Vince Sanders <vince@kyllikki.org>
Cc: Andrew Zabolotny <zap@homelink.ru>
---
drivers/input/touchscreen/mainstone-wm97xx.c | 298 ++++++++++++++++++++++++++
1 files changed, 298 insertions(+), 0 deletions(-)
create mode 100644 drivers/input/touchscreen/mainstone-wm97xx.c
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
new file mode 100644
index 0000000..8e1c35d
--- /dev/null
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -0,0 +1,298 @@
+/*
+ * mainstone-wm97xx.c -- Mainstone Continuous Touch screen driver for
+ * Wolfson WM97xx AC97 Codecs.
+ *
+ * Copyright 2004, 2007 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ * Parts Copyright : Ian Molton <spyro@f2s.com>
+ * Andrew Zabolotny <zap@homelink.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms 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.
+ *
+ * Notes:
+ * This is a wm97xx extended touch driver to capture touch
+ * data in a continuous manner on the Intel XScale archictecture
+ *
+ * Features:
+ * - codecs supported:- WM9705, WM9712, WM9713
+ * - processors supported:- Intel XScale PXA25x, PXA26x, PXA27x
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/wm97xx.h>
+#include <linux/io.h>
+#include <asm/arch/pxa-regs.h>
+
+#define VERSION "0.13"
+
+struct continuous {
+ u16 id; /* codec id */
+ u8 code; /* continuous code */
+ u8 reads; /* number of coord reads per read cycle */
+ u32 speed; /* number of coords per second */
+};
+
+#define WM_READS(sp) ((sp / HZ) + 1)
+
+static const struct continuous cinfo[] = {
+ {WM9705_ID2, 0, WM_READS(94), 94},
+ {WM9705_ID2, 1, WM_READS(188), 188},
+ {WM9705_ID2, 2, WM_READS(375), 375},
+ {WM9705_ID2, 3, WM_READS(750), 750},
+ {WM9712_ID2, 0, WM_READS(94), 94},
+ {WM9712_ID2, 1, WM_READS(188), 188},
+ {WM9712_ID2, 2, WM_READS(375), 375},
+ {WM9712_ID2, 3, WM_READS(750), 750},
+ {WM9713_ID2, 0, WM_READS(94), 94},
+ {WM9713_ID2, 1, WM_READS(120), 120},
+ {WM9713_ID2, 2, WM_READS(154), 154},
+ {WM9713_ID2, 3, WM_READS(188), 188},
+};
+
+/* continuous speed index */
+static int sp_idx;
+static u16 last, tries;
+
+/*
+ * Pen sampling frequency (Hz) in continuous mode.
+ */
+static int cont_rate = 200;
+module_param(cont_rate, int, 0);
+MODULE_PARM_DESC(cont_rate, "Sampling rate in continuous mode (Hz)");
+
+/*
+ * Pen down detection.
+ *
+ * This driver can either poll or use an interrupt to indicate a pen down
+ * event. If the irq request fails then it will fall back to polling mode.
+ */
+static int pen_int;
+module_param(pen_int, int, 0);
+MODULE_PARM_DESC(pen_int, "Pen down detection (1 = interrupt, 0 = polling)");
+
+/*
+ * Pressure readback.
+ *
+ * Set to 1 to read back pen down pressure
+ */
+static int pressure;
+module_param(pressure, int, 0);
+MODULE_PARM_DESC(pressure, "Pressure readback (1 = pressure, 0 = no pressure)");
+
+/*
+ * AC97 touch data slot.
+ *
+ * Touch screen readback data ac97 slot
+ */
+static int ac97_touch_slot = 5;
+module_param(ac97_touch_slot, int, 0);
+MODULE_PARM_DESC(ac97_touch_slot, "Touch screen data slot AC97 number");
+
+
+/* flush AC97 slot 5 FIFO on pxa machines */
+#ifdef CONFIG_PXA27x
+static void wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+
+ while (MISR & (1 << 2))
+ MODR;
+}
+#else
+static void wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+ int count = 16;
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+
+ while (count < 16) {
+ MODR;
+ count--;
+ }
+}
+#endif
+
+static int wm97xx_acc_pen_down(struct wm97xx *wm)
+{
+ u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
+ int reads = 0;
+
+ /* data is never immediately available after pen down irq */
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+
+ if (tries > 5) {
+ tries = 0;
+ return RC_PENUP;
+ }
+
+ x = MODR;
+ if (x == last) {
+ tries++;
+ return RC_AGAIN;
+ }
+ last = x;
+ do {
+ if (reads)
+ x = MODR;
+ y = MODR;
+ if (pressure)
+ p = MODR;
+
+ /* are samples valid */
+ if ((x & 0x7000) != WM97XX_ADCSEL_X ||
+ (y & 0x7000) != WM97XX_ADCSEL_Y ||
+ (p & 0x7000) != WM97XX_ADCSEL_PRES)
+ goto up;
+
+ /* coordinate is good */
+ tries = 0;
+ input_report_abs(wm->input_dev, ABS_X, x & 0xfff);
+ input_report_abs(wm->input_dev, ABS_Y, y & 0xfff);
+ input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff);
+ input_sync(wm->input_dev);
+ reads++;
+ } while (reads < cinfo[sp_idx].reads);
+up:
+ return RC_PENDOWN | RC_AGAIN;
+}
+
+static int wm97xx_acc_startup(struct wm97xx *wm)
+{
+ int idx = 0;
+
+ /* check we have a codec */
+ if (wm->ac97 == NULL)
+ return -ENODEV;
+
+ /* Go you big red fire engine */
+ for (idx = 0; idx < ARRAY_SIZE(cinfo); idx++) {
+ if (wm->id != cinfo[idx].id)
+ continue;
+ sp_idx = idx;
+ if (cont_rate <= cinfo[idx].speed)
+ break;
+ }
+ wm->acc_rate = cinfo[sp_idx].code;
+ wm->acc_slot = ac97_touch_slot;
+ dev_info(wm->dev,
+ "mainstone accelerated touchscreen driver, %d samples/sec\n",
+ cinfo[sp_idx].speed);
+
+ /* codec specific irq config */
+ if (pen_int) {
+ switch (wm->id) {
+ case WM9705_ID2:
+ wm->pen_irq = IRQ_GPIO(4);
+ set_irq_type(IRQ_GPIO(4), IRQT_BOTHEDGE);
+ break;
+ case WM9712_ID2:
+ case WM9713_ID2:
+ /* enable pen down interrupt */
+ /* use PEN_DOWN GPIO 13 to assert IRQ on GPIO line 2 */
+ wm->pen_irq = MAINSTONE_AC97_IRQ;
+ wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN,
+ WM97XX_GPIO_POL_HIGH,
+ WM97XX_GPIO_STICKY,
+ WM97XX_GPIO_WAKE);
+ wm97xx_config_gpio(wm, WM97XX_GPIO_2, WM97XX_GPIO_OUT,
+ WM97XX_GPIO_POL_HIGH,
+ WM97XX_GPIO_NOTSTICKY,
+ WM97XX_GPIO_NOWAKE);
+ break;
+ default:
+ dev_err(wm->dev,
+ "pen down irq not supported on this device\n");
+ pen_int = 0;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static void wm97xx_acc_shutdown(struct wm97xx *wm)
+{
+ /* codec specific deconfig */
+ if (pen_int) {
+ switch (wm->id & 0xffff) {
+ case WM9705_ID2:
+ wm->pen_irq = 0;
+ break;
+ case WM9712_ID2:
+ case WM9713_ID2:
+ /* disable interrupt */
+ wm->pen_irq = 0;
+ break;
+ }
+ }
+}
+
+static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+ if (enable)
+ enable_irq(wm->pen_irq);
+ else
+ disable_irq(wm->pen_irq);
+}
+
+static struct wm97xx_mach_ops mainstone_mach_ops = {
+ .acc_enabled = 1,
+ .acc_pen_up = wm97xx_acc_pen_up,
+ .acc_pen_down = wm97xx_acc_pen_down,
+ .acc_startup = wm97xx_acc_startup,
+ .acc_shutdown = wm97xx_acc_shutdown,
+ .irq_enable = wm97xx_irq_enable,
+};
+
+static int mainstone_wm97xx_probe(struct platform_device *pdev)
+{
+ struct wm97xx *wm = platform_get_drvdata(pdev);
+ return wm97xx_register_mach_ops(wm, &mainstone_mach_ops);
+}
+
+static int mainstone_wm97xx_remove(struct platform_device *pdev)
+{
+ struct wm97xx *wm = platform_get_drvdata(pdev);
+ wm97xx_unregister_mach_ops(wm);
+ return 0;
+}
+
+static struct platform_driver mainstone_wm97xx_driver = {
+ .probe = mainstone_wm97xx_probe,
+ .remove = mainstone_wm97xx_remove,
+ .driver = {
+ .name = "wm97xx-touch",
+ },
+};
+
+static int __init mainstone_wm97xx_init(void)
+{
+ return platform_driver_register(&mainstone_wm97xx_driver);
+}
+
+static void __exit mainstone_wm97xx_exit(void)
+{
+ platform_driver_unregister(&mainstone_wm97xx_driver);
+}
+
+module_init(mainstone_wm97xx_init);
+module_exit(mainstone_wm97xx_exit);
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>");
+MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone");
+MODULE_LICENSE("GPL");
--
1.5.4
next prev parent reply other threads:[~2008-02-12 10:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-12 10:17 [UPDATED v6] WM97xx touchscreen drivers Mark Brown
2008-02-12 10:21 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-02-12 10:21 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-02-12 10:21 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-02-12 10:21 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-02-12 10:21 ` Mark Brown [this message]
2008-02-12 10:21 ` [PATCH 6/6] Build system and MAINTAINERS entry for WM97xx touchscreen drivers Mark Brown
2008-02-12 22:58 ` [PATCH 1/6] Core driver for WM97xx touchscreens Dmitry Baryshkov
2008-02-13 11:19 ` Mark Brown
2008-02-13 11:32 ` Dmitry
2008-02-13 4:28 ` Pete MacKay
2008-02-13 4:28 ` Pete MacKay
2008-02-13 10:11 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2008-04-01 10:28 WM97xx touchscreen drivers Mark Brown
2008-04-01 10:36 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-04-01 10:36 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-04-01 10:36 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-04-01 10:36 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-04-01 10:36 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-03-20 9:39 WM97xx touchscreen drivers Mark Brown
2008-03-20 9:42 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-03-20 9:42 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-03-20 9:42 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-03-20 9:42 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-03-20 9:42 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-03-04 14:02 WM97xx touchscreen drivers Mark Brown
2008-03-04 14:04 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-03-04 14:04 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-03-04 14:04 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-03-04 14:04 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-03-04 14:04 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-02-29 16:50 WM97xx touchscreen drivers Mark Brown
2008-02-29 16:52 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-02-29 16:52 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-02-29 16:52 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-02-29 16:52 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-02-29 16:52 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-02-26 13:40 [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-02-26 13:40 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-02-26 13:40 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-02-26 13:40 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-02-26 13:40 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-02-26 13:40 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-02-26 13:40 ` Mark Brown
2008-02-28 7:09 ` Andrew Morton
2008-02-29 16:18 ` Mark Brown
2008-02-13 14:06 [UPDATED v7] WM97xx touchscreen drivers Mark Brown
2008-02-13 14:13 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-02-13 14:13 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-02-13 14:13 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-02-13 14:14 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-02-13 14:14 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-01-26 15:18 [UPDATED v4] WM97xx touchscreen drivers Mark Brown
2008-01-26 17:28 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-01-26 17:28 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-01-26 17:28 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-01-26 17:28 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-01-26 17:28 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
2008-01-21 15:24 [UPDATED v3] WM97xx touchscreen drivers Mark Brown
2008-01-21 15:24 ` [PATCH 1/6] Core driver for WM97xx touchscreens Mark Brown
2008-01-21 15:24 ` [PATCH 2/6] Add chip driver for WM9705 touchscreen Mark Brown
2008-01-21 15:24 ` [PATCH 3/6] Add chip driver for WM9712 touchscreen Mark Brown
2008-01-21 15:24 ` [PATCH 4/6] Add chip driver for WM9713 touchscreen Mark Brown
2008-01-21 15:24 ` [PATCH 5/6] Driver for WM97xx touchscreens in streaming mode on Mainstone Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1202811705-2303-5-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=dbaryshkov@gmail.com \
--cc=dtor@mail.ru \
--cc=gg@opensource.wolfsonmicro.com \
--cc=giometti@enneenne.com \
--cc=liam.girdwood@wolfsonmicro.com \
--cc=linux-input@atrey.karlin.mff.cuni.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux01@architechnical.net \
--cc=mike.arthur@wolfsonmicro.com \
--cc=mkl@pengutronix.de \
--cc=rmk@arm.linux.org.uk \
--cc=spyro@f2s.com \
--cc=stanley.cai@intel.com \
--cc=vince@kyllikki.org \
--cc=zap@homelink.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.