linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] WM97xx updates
@ 2009-03-03 18:24 Mark Brown
  2009-03-03 18:24 ` [PATCH 1/5] Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android Mark Brown
  2009-03-04  9:15 ` [PATCH 0/5] WM97xx updates Dmitry Torokhov
  0 siblings, 2 replies; 13+ messages in thread
From: Mark Brown @ 2009-03-03 18:24 UTC (permalink / raw)
  To: Jiri Slaby, Dmitry Torokhov
  Cc: linux-input, linux-kernel, Hans-Christian Egtvedt

This patch series updates the review feedback from the first round and
rolls in the additional patches from Mike Rapoport.  I've not addressed
any of the comments for the at32 driver since I have no ability to test
any changes to that driver but repost it for completeness.

Hans-Christian Egtvedt (1):
      Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors

Mark Brown (2):
      Input: Use disable_irq_nosync() for Mainstone
      Input: Accelerated touchscreen support for Marvell Zylonite

Mike Rapoport (2):
      Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android
      Input: add BTN_TOUCH event

 drivers/input/touchscreen/Kconfig            |   28 ++
 drivers/input/touchscreen/Makefile           |    2 +
 drivers/input/touchscreen/at32-wm97xx.c      |  416 ++++++++++++++++++++++++++
 drivers/input/touchscreen/at32-wm97xx.h      |   48 +++
 drivers/input/touchscreen/mainstone-wm97xx.c |    3 +-
 drivers/input/touchscreen/ucb1400_ts.c       |    5 +-
 drivers/input/touchscreen/wm97xx-core.c      |    4 +
 drivers/input/touchscreen/zylonite-wm97xx.c  |  239 +++++++++++++++
 8 files changed, 743 insertions(+), 2 deletions(-)
 create mode 100644 drivers/input/touchscreen/at32-wm97xx.c
 create mode 100644 drivers/input/touchscreen/at32-wm97xx.h
 create mode 100644 drivers/input/touchscreen/zylonite-wm97xx.c

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android
  2009-03-03 18:24 [PATCH 0/5] WM97xx updates Mark Brown
@ 2009-03-03 18:24 ` Mark Brown
  2009-03-03 18:24   ` [PATCH 2/5] Input: add BTN_TOUCH event Mark Brown
  2009-03-04  9:15 ` [PATCH 0/5] WM97xx updates Dmitry Torokhov
  1 sibling, 1 reply; 13+ messages in thread
From: Mark Brown @ 2009-03-03 18:24 UTC (permalink / raw)
  To: Jiri Slaby, Dmitry Torokhov
  Cc: linux-input, linux-kernel, Mike Rapoport, Mark Brown

From: Mike Rapoport <mike@compulab.co.il>

Please CC me, I'm not subscribed to linux-input

Android expects BTN_TOUCH events when pen state changes. Add BTN_TOUCH
event reporting to allow use of wm97xx touchscreen controller wiht
Android devices.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/input/touchscreen/wm97xx-core.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index d15aa11..4551f88 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -409,6 +409,7 @@ static int wm97xx_read_samples(struct wm97xx *wm)
 			wm->pen_is_down = 0;
 			dev_dbg(wm->dev, "pen up\n");
 			input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+			input_report_key(wm->input_dev, BTN_TOUCH, 0);
 			input_sync(wm->input_dev);
 		} else if (!(rc & RC_AGAIN)) {
 			/* We need high frequency updates only while
@@ -433,6 +434,7 @@ static int wm97xx_read_samples(struct wm97xx *wm)
 		input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff);
 		input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff);
 		input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff);
+		input_report_key(wm->input_dev, BTN_TOUCH, 1);
 		input_sync(wm->input_dev);
 		wm->pen_is_down = 1;
 		wm->ts_reader_interval = wm->ts_reader_min_interval;
@@ -629,9 +631,11 @@ static int wm97xx_probe(struct device *dev)
 	wm->input_dev->open = wm97xx_ts_input_open;
 	wm->input_dev->close = wm97xx_ts_input_close;
 	set_bit(EV_ABS, wm->input_dev->evbit);
+	set_bit(EV_KEY, wm->input_dev->evbit);
 	set_bit(ABS_X, wm->input_dev->absbit);
 	set_bit(ABS_Y, wm->input_dev->absbit);
 	set_bit(ABS_PRESSURE, wm->input_dev->absbit);
+	set_bit(BTN_TOUCH, wm->input_dev->keybit);
 	input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1],
 			     abs_x[2], 0);
 	input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1],
-- 
1.6.1.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5] Input: add BTN_TOUCH event
  2009-03-03 18:24 ` [PATCH 1/5] Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android Mark Brown
@ 2009-03-03 18:24   ` Mark Brown
  2009-03-03 18:24     ` [PATCH 3/5] Input: Use disable_irq_nosync() for Mainstone Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2009-03-03 18:24 UTC (permalink / raw)
  To: Jiri Slaby, Dmitry Torokhov
  Cc: linux-input, linux-kernel, Mike Rapoport, Mark Brown

From: Mike Rapoport <mike@compulab.co.il>

Add BTN_TOUCH event reporting to ucb1400_ts and accelerated mainstone-wm97xx
touchscreen drivers. Together with previously posted similar patch for
wm97xx-core this will make all touchscreen drivers behave consistently wrt.
BTN_TOUCH.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/input/touchscreen/mainstone-wm97xx.c |    1 +
 drivers/input/touchscreen/ucb1400_ts.c       |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 1d11e2b..4d49690 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -162,6 +162,7 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
 		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_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
 		input_sync(wm->input_dev);
 		reads++;
 	} while (reads < cinfo[sp_idx].reads);
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 5498662..e868264 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -151,12 +151,14 @@ static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16
 	input_report_abs(idev, ABS_X, x);
 	input_report_abs(idev, ABS_Y, y);
 	input_report_abs(idev, ABS_PRESSURE, pressure);
+	input_report_key(idev, BTN_TOUCH, 1);
 	input_sync(idev);
 }
 
 static void ucb1400_ts_event_release(struct input_dev *idev)
 {
 	input_report_abs(idev, ABS_PRESSURE, 0);
+	input_report_key(idev, BTN_TOUCH, 0);
 	input_sync(idev);
 }
 
@@ -377,7 +379,8 @@ static int ucb1400_ts_probe(struct platform_device *dev)
 	ucb->ts_idev->id.product	= ucb->id;
 	ucb->ts_idev->open		= ucb1400_ts_open;
 	ucb->ts_idev->close		= ucb1400_ts_close;
-	ucb->ts_idev->evbit[0]		= BIT_MASK(EV_ABS);
+	ucb->ts_idev->evbit[0]		= BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY);
+	ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
 	ucb1400_adc_enable(ucb->ac97);
 	x_res = ucb1400_ts_read_xres(ucb);
-- 
1.6.1.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5] Input: Use disable_irq_nosync() for Mainstone
  2009-03-03 18:24   ` [PATCH 2/5] Input: add BTN_TOUCH event Mark Brown
@ 2009-03-03 18:24     ` Mark Brown
  2009-03-03 18:24       ` [PATCH 4/5] Input: Accelerated touchscreen support for Marvell Zylonite Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2009-03-03 18:24 UTC (permalink / raw)
  To: Jiri Slaby, Dmitry Torokhov; +Cc: linux-input, linux-kernel, Mark Brown

This should make no practical difference since the Mainstone can't be
SMP but it is more correct.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/input/touchscreen/mainstone-wm97xx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 4d49690..dfa6a84 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -246,7 +246,7 @@ static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
 	if (enable)
 		enable_irq(wm->pen_irq);
 	else
-		disable_irq(wm->pen_irq);
+		disable_irq_nosync(wm->pen_irq);
 }
 
 static struct wm97xx_mach_ops mainstone_mach_ops = {
-- 
1.6.1.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5] Input: Accelerated touchscreen support for Marvell Zylonite
  2009-03-03 18:24     ` [PATCH 3/5] Input: Use disable_irq_nosync() for Mainstone Mark Brown
@ 2009-03-03 18:24       ` Mark Brown
  2009-03-03 18:24         ` [PATCH 5/5] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2009-03-03 18:24 UTC (permalink / raw)
  To: Jiri Slaby, Dmitry Torokhov; +Cc: linux-input, linux-kernel, Mark Brown

This patch implements accelerated touchscreen support for the Marvell
Zylonite development platform, supporting pen down interrupts and
continuous mode data transfers.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---

Changes since last posting to correct code review issues, primarily:

 - Use disable_irq_nosync().
 - Rewrite pen up MODR drain loop for clarity & correctness.
 - Fixed permissions for pressure module parameter.
 - Don't use schedule_timeout_uninterruptilbe()

 drivers/input/touchscreen/Kconfig           |   13 ++
 drivers/input/touchscreen/Makefile          |    1 +
 drivers/input/touchscreen/zylonite-wm97xx.c |  239 +++++++++++++++++++++++++++
 3 files changed, 253 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/zylonite-wm97xx.c

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index bb6486a..a31d434 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -308,6 +308,19 @@ config TOUCHSCREEN_WM97XX_MAINSTONE
 	  To compile this driver as a module, choose M here: the
 	  module will be called mainstone-wm97xx.
 
+config TOUCHSCREEN_WM97XX_ZYLONITE
+	tristate "Zylonite accelerated touch"
+	depends on TOUCHSCREEN_WM97XX && MACH_ZYLONITE
+	select TOUCHSCREEN_WM9713
+	help
+	  Say Y here for support for streaming mode with the touchscreen
+	  on Zylonite systems.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called zylonite-wm97xx.
+
 config TOUCHSCREEN_USB_COMPOSITE
 	tristate "USB Touchscreen Driver"
 	depends on USB_ARCH_HAS_HCD
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index d3375af..82dd918 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -34,3 +34,4 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705)	+= wm9705.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712)	+= wm9712.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713)	+= wm9713.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c
new file mode 100644
index 0000000..abfab4e
--- /dev/null
+++ b/drivers/input/touchscreen/zylonite-wm97xx.c
@@ -0,0 +1,239 @@
+/*
+ * zylonite-wm97xx.c  --  Zylonite Continuous Touch screen driver
+ *
+ * Copyright 2004, 2007, 2008 Wolfson Microelectronics PLC.
+ * Author: Mark Brown <broonie@opensource.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 supporting interrupt driven
+ *     and continuous operation on Marvell Zylonite development systems
+ *     (which have a WM9713 on board).
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/wm97xx.h>
+
+#include <mach/hardware.h>
+#include <mach/mfp.h>
+#include <mach/regs-ac97.h>
+
+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[] = {
+	{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;
+
+/*
+ * 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)");
+
+/*
+ * 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 machines */
+static void wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+	int i;
+
+	msleep(1);
+
+	for (i = 0; i < 16; i++)
+		MODR;
+}
+
+static int wm97xx_acc_pen_down(struct wm97xx *wm)
+{
+	u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
+	int reads = 0;
+	static u16 last, tries;
+
+	/* When the AC97 queue has been drained we need to allow time
+	 * to buffer up samples otherwise we end up spinning polling
+	 * for samples.  The controller can't have a suitably low
+	 * threashold set to use the notifications it gives.
+	 */
+	msleep(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 & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X ||
+		    (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
+		    (p & WM97XX_ADCSRC_MASK) != 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_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
+		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;
+
+	/* 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,
+		 "zylonite accelerated touchscreen driver, %d samples/sec\n",
+		 cinfo[sp_idx].speed);
+
+	return 0;
+}
+
+static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+	if (enable)
+		enable_irq(wm->pen_irq);
+	else
+		disable_irq_nosync(wm->pen_irq);
+}
+
+static struct wm97xx_mach_ops zylonite_mach_ops = {
+	.acc_enabled = 1,
+	.acc_pen_up = wm97xx_acc_pen_up,
+	.acc_pen_down = wm97xx_acc_pen_down,
+	.acc_startup = wm97xx_acc_startup,
+	.irq_enable = wm97xx_irq_enable,
+	.irq_gpio = WM97XX_GPIO_2,
+};
+
+static int zylonite_wm97xx_probe(struct platform_device *pdev)
+{
+	struct wm97xx *wm = platform_get_drvdata(pdev);
+	int gpio_touch_irq;
+
+	if (cpu_is_pxa320())
+		gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO15);
+	else
+		gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO26);
+
+	wm->pen_irq = IRQ_GPIO(gpio_touch_irq);
+	set_irq_type(IRQ_GPIO(gpio_touch_irq), IRQ_TYPE_EDGE_BOTH);
+
+	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);
+
+	return wm97xx_register_mach_ops(wm, &zylonite_mach_ops);
+}
+
+static int zylonite_wm97xx_remove(struct platform_device *pdev)
+{
+	struct wm97xx *wm = platform_get_drvdata(pdev);
+
+	wm97xx_unregister_mach_ops(wm);
+	return 0;
+}
+
+static struct platform_driver zylonite_wm97xx_driver = {
+	.probe = zylonite_wm97xx_probe,
+	.remove = zylonite_wm97xx_remove,
+	.driver = {
+		.name = "wm97xx-touch",
+	},
+};
+
+static int __init zylonite_wm97xx_init(void)
+{
+	return platform_driver_register(&zylonite_wm97xx_driver);
+}
+
+static void __exit zylonite_wm97xx_exit(void)
+{
+	platform_driver_unregister(&zylonite_wm97xx_driver);
+}
+
+module_init(zylonite_wm97xx_init);
+module_exit(zylonite_wm97xx_exit);
+
+/* Module information */
+MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
+MODULE_DESCRIPTION("wm97xx continuous touch driver for Zylonite");
+MODULE_LICENSE("GPL");
-- 
1.6.1.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors
  2009-03-03 18:24       ` [PATCH 4/5] Input: Accelerated touchscreen support for Marvell Zylonite Mark Brown
@ 2009-03-03 18:24         ` Mark Brown
  2009-03-03 20:29           ` Jiri Slaby
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2009-03-03 18:24 UTC (permalink / raw)
  To: Jiri Slaby, Dmitry Torokhov
  Cc: linux-input, linux-kernel, Hans-Christian Egtvedt, Mark Brown

From: Hans-Christian Egtvedt <hcegtvedt@atmel.com>

This patch adds an accelerated driver for Atmel AVR32 AT32AP700X
microprocessors. It uses interrupts on the channel B in the AC97 controller.
Thus, offloading the work queue in the wm97xx-ts driver.

The driver has been tested with Atmel AVR32 AT32AP7000 and Wolfson WM9712
codec.

Signed-off-by: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/input/touchscreen/Kconfig       |   15 ++
 drivers/input/touchscreen/Makefile      |    1 +
 drivers/input/touchscreen/at32-wm97xx.c |  416 +++++++++++++++++++++++++++++++
 drivers/input/touchscreen/at32-wm97xx.h |   48 ++++
 4 files changed, 480 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/at32-wm97xx.c
 create mode 100644 drivers/input/touchscreen/at32-wm97xx.h

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index a31d434..d63fc2f 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -296,6 +296,21 @@ config TOUCHSCREEN_WM9713
 	  Say Y here to enable support for the Wolfson Microelectronics
 	  WM9713 touchscreen controller.
 
+config TOUCHSCREEN_WM97XX_AT32
+	tristate "WM97xx Atmel AVR32 accelerated touch"
+	depends on TOUCHSCREEN_WM97XX && AVR32
+	help
+	  Say Y here for support for streaming mode with WM97xx touchscreens on
+	  Atmel AVR32 systems with an AC97 controller.
+
+	  Be aware that this will use channel B in the controller for streaming
+	  data, this must not conflict with other AC97 drivers.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called at32-wm97xx.
+
 config TOUCHSCREEN_WM97XX_MAINSTONE
 	tristate "WM97xx Mainstone accelerated touch"
 	depends on TOUCHSCREEN_WM97XX && ARCH_PXA
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 82dd918..29a0257 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -33,5 +33,6 @@ obj-$(CONFIG_TOUCHSCREEN_DA9034)	+= da9034-ts.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705)	+= wm9705.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712)	+= wm9712.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713)	+= wm9713.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_AT32)	+= at32-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
diff --git a/drivers/input/touchscreen/at32-wm97xx.c b/drivers/input/touchscreen/at32-wm97xx.c
new file mode 100644
index 0000000..e34edcd
--- /dev/null
+++ b/drivers/input/touchscreen/at32-wm97xx.c
@@ -0,0 +1,416 @@
+/*
+ * Atmel AVR32 continuous touch screen driver for Wolfson WM97xx AC97 codecs.
+ *
+ * Copyright (C) 2008 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.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 <linux/timer.h>
+
+#include <asm/gpio.h>
+
+#include "at32-wm97xx.h"
+
+#ifdef CONFIG_CPU_AT32AP700X
+#define AT32_WM97XX_AC97C_IOMEM		0xfff02800
+#define AT32_WM97XX_AC97C_IRQ		29
+#define AT32_WM97XX_GPIO_DEFAULT	(32+16) /* Pin 16 on port B. */
+#else
+#error Unkown CPU, this driver only supports AT32AP700X CPUs.
+#endif
+
+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;
+
+/*
+ * Pen sampling frequency (Hz) in continuous mode.
+ */
+static int cont_rate = 188;
+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 = 1;
+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");
+
+/*
+ * AT32AP700X GPIO line number.
+ *
+ * Set to GPIO number where the signal from the WM97xx device is hooked up.
+ */
+static int at32_gpio_line = AT32_WM97XX_GPIO_DEFAULT;
+module_param(at32_gpio_line, int, 0);
+MODULE_PARM_DESC(at32_gpio_line,
+		"GPIO line number on AT32AP700X connected to WM97xx");
+
+struct at32_wm97xx {
+	struct wm97xx		*wm;
+	struct timer_list	pen_timer;
+	void __iomem		*regs;
+	unsigned long		ac97c_irq;
+	unsigned long		gpio_pen;
+	unsigned long		gpio_irq;
+	unsigned short		x;
+	unsigned short		y;
+};
+
+static irqreturn_t at32_wm97xx_channel_b_interrupt(int irq, void *dev_id)
+{
+	struct at32_wm97xx *at32_wm97xx = dev_id;
+	struct wm97xx *wm = at32_wm97xx->wm;
+	int status = ac97c_readl(at32_wm97xx, CBSR);
+	int retval = IRQ_NONE;
+
+	if (status & AC97C_OVRUN) {
+		dev_dbg(&wm->touch_dev->dev, "AC97C overrun\n");
+		ac97c_readl(at32_wm97xx, CBRHR);
+		retval = IRQ_HANDLED;
+	} else if (status & AC97C_RXRDY) {
+		u16 data;
+		u16 value;
+		u16 source;
+		u16 pen_down;
+
+		data = ac97c_readl(at32_wm97xx, CBRHR);
+		value = data & 0x0fff;
+		source = data & WM97XX_ADCSRC_MASK;
+		pen_down = (data & WM97XX_PEN_DOWN) >> 8;
+
+		if (source == WM97XX_ADCSEL_X)
+			at32_wm97xx->x = value;
+		if (source == WM97XX_ADCSEL_Y)
+			at32_wm97xx->y = value;
+
+		if (!pressure && source == WM97XX_ADCSEL_Y) {
+			input_report_abs(wm->input_dev, ABS_X, at32_wm97xx->x);
+			input_report_abs(wm->input_dev, ABS_Y, at32_wm97xx->y);
+			input_report_abs(wm->input_dev, ABS_PRESSURE, pen_down);
+			input_report_key(wm->input_dev, BTN_TOUCH,
+					 (pen_down != 0));
+			input_sync(wm->input_dev);
+		} else if (pressure && source == WM97XX_ADCSEL_PRES) {
+			input_report_abs(wm->input_dev, ABS_X, at32_wm97xx->x);
+			input_report_abs(wm->input_dev, ABS_Y, at32_wm97xx->y);
+			input_report_abs(wm->input_dev, ABS_PRESSURE, value);
+			input_report_key(wm->input_dev, BTN_TOUCH,
+					 (value != 0));
+			input_sync(wm->input_dev);
+		}
+
+		retval = IRQ_HANDLED;
+	}
+
+	return retval;
+}
+
+static void at32_wm97xx_pen_timer(unsigned long data)
+{
+	struct at32_wm97xx *at32_wm97xx = (struct at32_wm97xx *)data;
+	struct wm97xx *wm = at32_wm97xx->wm;
+	int pen_down = gpio_get_value(at32_wm97xx->gpio_pen);
+
+	if (pen_down != 0) {
+		mod_timer(&at32_wm97xx->pen_timer, jiffies
+				+ msecs_to_jiffies(1));
+	} else {
+		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_report_key(wm->input_dev, BTN_TOUCH, 0);
+		input_sync(wm->input_dev);
+	}
+}
+
+static void at32_wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+	struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(wm->touch_dev);
+	int pen_down = gpio_get_value(at32_wm97xx->gpio_pen);
+
+	if (pen_down != 0) {
+		mod_timer(&at32_wm97xx->pen_timer, jiffies
+				+ msecs_to_jiffies(1));
+	} else {
+		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_report_key(wm->input_dev, BTN_TOUCH, 0);
+		input_sync(wm->input_dev);
+	}
+}
+
+static int at32_wm97xx_acc_startup(struct wm97xx *wm)
+{
+	struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(wm->touch_dev);
+	int idx = 0;
+
+	if (wm->ac97 == NULL)
+		return -ENODEV;
+
+	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->touch_dev->dev, "atmel accelerated touchscreen driver, "
+			"%d samples/sec\n", cinfo[sp_idx].speed);
+
+	if (pen_int) {
+		unsigned long reg;
+
+		wm->pen_irq = at32_wm97xx->gpio_irq;
+
+		switch (wm->id) {
+		case WM9712_ID2: /* Fall through. */
+		case WM9713_ID2:
+			/*
+			 * Use GPIO 13 (PEN_DOWN) to assert GPIO line 3
+			 * (PENDOWN).
+			 */
+			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_3, WM97XX_GPIO_OUT,
+					WM97XX_GPIO_POL_HIGH,
+					WM97XX_GPIO_NOTSTICKY,
+					WM97XX_GPIO_NOWAKE);
+		case WM9705_ID2: /* Fall through. */
+			/*
+			 * Enable touch data slot in AC97 controller channel B.
+			 */
+			reg = ac97c_readl(at32_wm97xx, ICA);
+			reg &= ~AC97C_CH_MASK(wm->acc_slot);
+			reg |= AC97C_CH_ASSIGN(wm->acc_slot, B);
+			ac97c_writel(at32_wm97xx, ICA, reg);
+
+			/*
+			 * Enable channel and interrupt for RXRDY and OVERRUN.
+			 */
+			ac97c_writel(at32_wm97xx, CBMR, AC97C_CMR_CENA
+					| AC97C_CMR_CEM_BIG
+					| AC97C_CMR_SIZE_16
+					| AC97C_OVRUN
+					| AC97C_RXRDY);
+			/* Dummy read to empty RXRHR. */
+			ac97c_readl(at32_wm97xx, CBRHR);
+			/*
+			 * Enable interrupt for channel B in the AC97
+			 * controller.
+			 */
+			ac97c_writel(at32_wm97xx, IER, AC97C_INT_CBEVT);
+			break;
+		default:
+			dev_err(&wm->touch_dev->dev, "pen down irq not "
+					"supported on this device\n");
+			pen_int = 0;
+			break;
+		}
+	}
+
+	return 0;
+}
+
+static void at32_wm97xx_acc_shutdown(struct wm97xx *wm)
+{
+	if (pen_int) {
+		struct at32_wm97xx *at32_wm97xx =
+			platform_get_drvdata(wm->touch_dev);
+		unsigned long ica;
+
+		switch (wm->id & 0xffff) {
+		case WM9705_ID2: /* Fall through. */
+		case WM9712_ID2: /* Fall through. */
+		case WM9713_ID2:
+			/* Disable slot and turn off channel B interrupts. */
+			ica = ac97c_readl(at32_wm97xx, ICA);
+			ica &= ~AC97C_CH_MASK(wm->acc_slot);
+			ac97c_writel(at32_wm97xx, ICA, ica);
+			ac97c_writel(at32_wm97xx, IDR, AC97C_INT_CBEVT);
+			ac97c_writel(at32_wm97xx, CBMR, 0);
+			wm->pen_irq = 0;
+			break;
+		default:
+			dev_err(&wm->touch_dev->dev, "unknown codec\n");
+			break;
+		}
+	}
+}
+
+static void at32_wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+	/* Intentionally left empty. */
+}
+
+static struct wm97xx_mach_ops at32_mach_ops = {
+	.acc_enabled	= 1,
+	.acc_pen_up	= at32_wm97xx_acc_pen_up,
+	.acc_startup	= at32_wm97xx_acc_startup,
+	.acc_shutdown	= at32_wm97xx_acc_shutdown,
+	.irq_enable	= at32_wm97xx_irq_enable,
+	.irq_gpio	= WM97XX_GPIO_3,
+};
+
+static int __init at32_wm97xx_probe(struct platform_device *pdev)
+{
+	struct wm97xx *wm = platform_get_drvdata(pdev);
+	struct at32_wm97xx *at32_wm97xx;
+	int ret;
+
+	at32_wm97xx = kzalloc(sizeof(struct at32_wm97xx), GFP_KERNEL);
+	if (!at32_wm97xx) {
+		dev_dbg(&pdev->dev, "out of memory\n");
+		return -ENOMEM;
+	}
+
+	at32_wm97xx->wm		= wm;
+	at32_wm97xx->regs	= (void *)AT32_WM97XX_AC97C_IOMEM;
+	at32_wm97xx->ac97c_irq	= AT32_WM97XX_AC97C_IRQ;
+	at32_wm97xx->gpio_pen	= at32_gpio_line;
+	at32_wm97xx->gpio_irq	= gpio_to_irq(at32_wm97xx->gpio_pen);
+
+	setup_timer(&at32_wm97xx->pen_timer, at32_wm97xx_pen_timer,
+			(unsigned long)at32_wm97xx);
+
+	ret = request_irq(at32_wm97xx->ac97c_irq,
+			at32_wm97xx_channel_b_interrupt,
+			IRQF_SHARED, "at32-wm97xx-ch-b", at32_wm97xx);
+	if (ret) {
+		dev_dbg(&pdev->dev, "could not request ac97c irq\n");
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, at32_wm97xx);
+
+	return wm97xx_register_mach_ops(wm, &at32_mach_ops);
+}
+
+static int __exit at32_wm97xx_remove(struct platform_device *pdev)
+{
+	struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(pdev);
+	struct wm97xx *wm = at32_wm97xx->wm;
+
+	ac97c_writel(at32_wm97xx, IDR, AC97C_INT_CBEVT);
+	free_irq(at32_wm97xx->ac97c_irq, at32_wm97xx);
+	wm97xx_unregister_mach_ops(wm);
+	kfree(at32_wm97xx);
+
+	platform_set_drvdata(wm->touch_dev, wm);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int at32_wm97xx_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+	struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(pdev);
+
+	ac97c_writel(at32_wm97xx, IDR, AC97C_INT_CBEVT);
+	disable_irq(at32_wm97xx->gpio_irq);
+
+	return 0;
+}
+
+static int at32_wm97xx_resume(struct platform_device *pdev)
+{
+	struct at32_wm97xx *at32_wm97xx = platform_get_drvdata(pdev);
+	struct wm97xx *wm = at32_wm97xx->wm;
+
+	if (wm->input_dev->users) {
+		enable_irq(at32_wm97xx->gpio_irq);
+		ac97c_writel(at32_wm97xx, IER, AC97C_INT_CBEVT);
+	}
+
+	return 0;
+}
+#else
+#define at32_wm97xx_suspend	NULL
+#define at32_wm97xx_resume	NULL
+#endif
+
+static struct platform_driver at32_wm97xx_driver = {
+	.remove		= __exit_p(at32_wm97xx_remove),
+	.driver		= {
+		.name = "wm97xx-touch",
+	},
+	.suspend	= at32_wm97xx_suspend,
+	.resume		= at32_wm97xx_resume,
+};
+
+static int __init at32_wm97xx_init(void)
+{
+	return platform_driver_probe(&at32_wm97xx_driver, at32_wm97xx_probe);
+}
+module_init(at32_wm97xx_init);
+
+static void __exit at32_wm97xx_exit(void)
+{
+	platform_driver_unregister(&at32_wm97xx_driver);
+}
+module_exit(at32_wm97xx_exit);
+
+MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
+MODULE_DESCRIPTION("wm97xx continuous touch driver for Atmel AVR32");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/at32-wm97xx.h b/drivers/input/touchscreen/at32-wm97xx.h
new file mode 100644
index 0000000..7d754d8
--- /dev/null
+++ b/drivers/input/touchscreen/at32-wm97xx.h
@@ -0,0 +1,48 @@
+/*
+ * Atmel AVR32 continuous touch screen driver for Wolfson WM97xx AC97 codecs.
+ *
+ * Copyright (C) 2008 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _AT32_WM97XX_H
+#define _AT32_WM97XX_H
+
+#define AC97C_ICA		0x10
+#define AC97C_CBRHR		0x30
+#define AC97C_CBSR		0x38
+#define AC97C_CBMR		0x3c
+#define AC97C_IER		0x54
+#define AC97C_IDR		0x58
+
+#define AC97C_RXRDY		(1 << 4)
+#define AC97C_OVRUN		(1 << 5)
+
+#define AC97C_CMR_SIZE_20	(0 << 16)
+#define AC97C_CMR_SIZE_18	(1 << 16)
+#define AC97C_CMR_SIZE_16	(2 << 16)
+#define AC97C_CMR_SIZE_10	(3 << 16)
+#define AC97C_CMR_CEM_LITTLE	(1 << 18)
+#define AC97C_CMR_CEM_BIG	(0 << 18)
+#define AC97C_CMR_CENA		(1 << 21)
+
+#define AC97C_INT_CBEVT		(1 << 4)
+
+#define AC97C_SR_CAEVT		(1 << 3)
+
+#define AC97C_CH_MASK(slot)						\
+	(0x7 << (3 * (slot - 3)))
+#define AC97C_CH_ASSIGN(slot, channel)					\
+	(AC97C_CHANNEL_##channel << (3 * (slot - 3)))
+#define AC97C_CHANNEL_NONE	0x0
+#define AC97C_CHANNEL_B		0x2
+
+#define ac97c_writel(chip, reg, val)			\
+	__raw_writel((val), (chip)->regs + AC97C_##reg)
+#define ac97c_readl(chip, reg)				\
+	__raw_readl((chip)->regs + AC97C_##reg)
+
+#endif /* _AT32_WM97XX_H */
-- 
1.6.1.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/5] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors
  2009-03-03 18:24         ` [PATCH 5/5] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors Mark Brown
@ 2009-03-03 20:29           ` Jiri Slaby
  0 siblings, 0 replies; 13+ messages in thread
From: Jiri Slaby @ 2009-03-03 20:29 UTC (permalink / raw)
  To: Mark Brown
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Hans-Christian Egtvedt

On 3.3.2009 19:24, Mark Brown wrote:
> +static irqreturn_t at32_wm97xx_channel_b_interrupt(int irq, void *dev_id)
> +{
> +	struct at32_wm97xx *at32_wm97xx = dev_id;
> +	struct wm97xx *wm = at32_wm97xx->wm;
> +	int status = ac97c_readl(at32_wm97xx, CBSR);
> +	int retval = IRQ_NONE;

Just a nit, irqreturn_t will become enum one day AFAIK. Use irqreturn_t 
which is guaranteed to be the proper type instead. This rather a 
suggestion for followup fixup.

> +static int __init at32_wm97xx_probe(struct platform_device *pdev)
> +{
> +	struct wm97xx *wm = platform_get_drvdata(pdev);
> +	struct at32_wm97xx *at32_wm97xx;
> +	int ret;
> +
> +	at32_wm97xx = kzalloc(sizeof(struct at32_wm97xx), GFP_KERNEL);
> +	if (!at32_wm97xx) {
> +		dev_dbg(&pdev->dev, "out of memory\n");
> +		return -ENOMEM;
> +	}
> +
> +	at32_wm97xx->wm		= wm;
> +	at32_wm97xx->regs	= (void *)AT32_WM97XX_AC97C_IOMEM;
> +	at32_wm97xx->ac97c_irq	= AT32_WM97XX_AC97C_IRQ;
> +	at32_wm97xx->gpio_pen	= at32_gpio_line;
> +	at32_wm97xx->gpio_irq	= gpio_to_irq(at32_wm97xx->gpio_pen);
> +
> +	setup_timer(&at32_wm97xx->pen_timer, at32_wm97xx_pen_timer,
> +			(unsigned long)at32_wm97xx);
> +
> +	ret = request_irq(at32_wm97xx->ac97c_irq,
> +			at32_wm97xx_channel_b_interrupt,
> +			IRQF_SHARED, "at32-wm97xx-ch-b", at32_wm97xx);
> +	if (ret) {
> +		dev_dbg(&pdev->dev, "could not request ac97c irq\n");

at32_wm97xx leak. I didn't notice last time.

> +		return ret;
> +	}
> +
> +	platform_set_drvdata(pdev, at32_wm97xx);
> +
> +	return wm97xx_register_mach_ops(wm,&at32_mach_ops);

On failure, this will still "leak" irq, I suppose this is what you 
referred as "fix later" in 0/5.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] WM97xx updates
  2009-03-03 18:24 [PATCH 0/5] WM97xx updates Mark Brown
  2009-03-03 18:24 ` [PATCH 1/5] Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android Mark Brown
@ 2009-03-04  9:15 ` Dmitry Torokhov
  2009-03-04  9:26   ` Hans-Christian Egtvedt
  1 sibling, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2009-03-04  9:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Jiri Slaby, linux-input, linux-kernel, Hans-Christian Egtvedt

Hi Mark,

On Tue, Mar 03, 2009 at 06:24:03PM +0000, Mark Brown wrote:
> This patch series updates the review feedback from the first round and
> rolls in the additional patches from Mike Rapoport.  I've not addressed
> any of the comments for the at32 driver since I have no ability to test
> any changes to that driver but repost it for completeness.
> 

I applied first 4 patches to 'next' and will wait for Hans-Christian
comments on the at32 driver.

Thanks!

-- 
Dmitry

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] WM97xx updates
  2009-03-04  9:15 ` [PATCH 0/5] WM97xx updates Dmitry Torokhov
@ 2009-03-04  9:26   ` Hans-Christian Egtvedt
       [not found]     ` <20090304105358.GA32107@rakim.wolfsonmicro.main>
  0 siblings, 1 reply; 13+ messages in thread
From: Hans-Christian Egtvedt @ 2009-03-04  9:26 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mark Brown, Jiri Slaby, linux-input, linux-kernel,
	Hans-Christian Egtvedt

Dmitry Torokhov wrote:
> On Tue, Mar 03, 2009 at 06:24:03PM +0000, Mark Brown wrote:
>> This patch series updates the review feedback from the first round and
>> rolls in the additional patches from Mike Rapoport.  I've not addressed
>> any of the comments for the at32 driver since I have no ability to test
>> any changes to that driver but repost it for completeness.
>>
> 
> I applied first 4 patches to 'next' and will wait for Hans-Christian
> comments on the at32 driver.
> 

The only thing catched by review was a leaking irq line, do you plan to 
fixup that Mark?

I also think the header file could go into the source code, to make it 
one file less.

Also, please note that I've gotten a new email address. The old one is 
quite annoying since it sends email back about my new address...

I'll not be able to test the driver immediately, my hardware is out at 
customers and the eight new prototypes needs some resoldering before I 
can work with them. Nothing has changed in hardware though, so it should 
fly out of the box.

-- 
Best regards,
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] WM97xx updates
       [not found]     ` <20090304105358.GA32107@rakim.wolfsonmicro.main>
@ 2009-03-04 11:29       ` Hans-Christian Egtvedt
  2009-03-04 14:32         ` Mark Brown
  2009-03-09 15:48         ` Hans-Christian Egtvedt
  0 siblings, 2 replies; 13+ messages in thread
From: Hans-Christian Egtvedt @ 2009-03-04 11:29 UTC (permalink / raw)
  To: Mark Brown
  Cc: Dmitry Torokhov, Jiri Slaby, linux-input, linux-kernel,
	Hans-Christian Egtvedt

Mark Brown wrote:
> On Wed, Mar 04, 2009 at 10:26:07AM +0100, Hans-Christian Egtvedt wrote:
> 
>> The only thing catched by review was a leaking irq line, do you plan to  
>> fixup that Mark?
> 
> Jiri also had some further comments from the initial posting (mail
> attached).  I can probably try to fix up most things blind but I'll need
> to at least set up an at32 toolchain to build test.  The workqueue thing
> might be better to test on hardware, though, just in case there's some
> noticable performance impact.  I wouldn't expect so but it'd be safer.
> 

I'll see what I can manage to squeeze in of testing, there is always the 
in-between-time.

What is this patch based against? Linus tree, master branch?

-- 
Best regards,
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] WM97xx updates
  2009-03-04 11:29       ` Hans-Christian Egtvedt
@ 2009-03-04 14:32         ` Mark Brown
  2009-03-09 15:48         ` Hans-Christian Egtvedt
  1 sibling, 0 replies; 13+ messages in thread
From: Mark Brown @ 2009-03-04 14:32 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: Dmitry Torokhov, Jiri Slaby, linux-input, linux-kernel,
	Hans-Christian Egtvedt

On Wed, Mar 04, 2009 at 12:29:03PM +0100, Hans-Christian Egtvedt wrote:

> What is this patch based against? Linus tree, master branch?

This branch:

   git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next

(though the noticable differences should be Makefile and Kconfig ones).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] WM97xx updates
  2009-03-04 11:29       ` Hans-Christian Egtvedt
  2009-03-04 14:32         ` Mark Brown
@ 2009-03-09 15:48         ` Hans-Christian Egtvedt
  2009-03-09 15:57           ` Jiri Slaby
  1 sibling, 1 reply; 13+ messages in thread
From: Hans-Christian Egtvedt @ 2009-03-09 15:48 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: Mark Brown, Dmitry Torokhov, Jiri Slaby, linux-input,
	linux-kernel, Hans-Christian Egtvedt

[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]

On Wed, 04 Mar 2009 12:29:03 +0100
Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> wrote:

> Mark Brown wrote:
> > On Wed, Mar 04, 2009 at 10:26:07AM +0100, Hans-Christian Egtvedt
> > wrote:
> > 
> >> The only thing catched by review was a leaking irq line, do you
> >> plan to fixup that Mark?
> > 

I fixed that in the attached patch, along with using an irqreturn_t
instead of an int for the return value from the interrupt handler.

> > Jiri also had some further comments from the initial posting (mail
> > attached).  I can probably try to fix up most things blind but I'll
> > need to at least set up an at32 toolchain to build test.  The
> > workqueue thing might be better to test on hardware, though, just
> > in case there's some noticable performance impact.  I wouldn't
> > expect so but it'd be safer.
> > 
> 
> I'll see what I can manage to squeeze in of testing, there is always
> the in-between-time.
> 

Please see attached patch. A bit unsure if I should have done an
incremental instead. Mark?

I also made the driver more generic, as it should work fine on AT91
devices as well. AT91 and AVR32 share the same AC97C module.

> What is this patch based against? Linus tree, master branch?
> 

This is against my master branch, but it managed to accept the original
patch so I guess it should go okay the other way as well. Sorry for the
inconvenience.

-- 
Best regards,
Hans-Christian Egtvedt

[-- Attachment #2: 0001-Input-add-wm97xx-accelerated-driver-for-Atmel-micro.patch --]
[-- Type: text/x-patch, Size: 15326 bytes --]

>From ff36d7c4ed71901b745eaf8b104c59a13a00374f Mon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Date: Mon, 9 Mar 2009 16:39:42 +0100
Subject: [PATCH v2 1/1] Input: add wm97xx accelerated driver for Atmel microprocessors

This patch adds an accelerated driver for Atmel AVR32 AT32AP700X
microprocessors. It uses interrupts on the channel B in the AC97
controller. Thus, offloading the work queue in the wm97xx-ts driver.

The driver has been tested with Atmel AVR32 AT32AP7000 and Wolfson
WM9712 codec.

The driver can also be easily modified to support Atmel AT91 devices, as
AT91 and AVR32 share the same AC97C module.

Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
---
 drivers/input/touchscreen/Kconfig        |   15 +
 drivers/input/touchscreen/Makefile       |    1 +
 drivers/input/touchscreen/atmel-wm97xx.c |  450 ++++++++++++++++++++++++++++++
 3 files changed, 466 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/atmel-wm97xx.c

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index bb6486a..c475679 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -296,6 +296,21 @@ config TOUCHSCREEN_WM9713
 	  Say Y here to enable support for the Wolfson Microelectronics
 	  WM9713 touchscreen controller.
 
+config TOUCHSCREEN_WM97XX_ATMEL
+	tristate "WM97xx Atmel accelerated touch"
+	depends on TOUCHSCREEN_WM97XX && (AVR32 || ARCH_AT91)
+	help
+	  Say Y here for support for streaming mode with WM97xx touchscreens
+	  on Atmel AT91 or AVR32 systems with an AC97C module.
+
+	  Be aware that this will use channel B in the controller for
+	  streaming data, this must not conflict with other AC97C drivers.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called atmel-wm97xx.
+
 config TOUCHSCREEN_WM97XX_MAINSTONE
 	tristate "WM97xx Mainstone accelerated touch"
 	depends on TOUCHSCREEN_WM97XX && ARCH_PXA
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index d3375af..4cc4225 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -33,4 +33,5 @@ obj-$(CONFIG_TOUCHSCREEN_DA9034)	+= da9034-ts.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705)	+= wm9705.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712)	+= wm9712.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713)	+= wm9713.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL)	+= atmel-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c
new file mode 100644
index 0000000..82b3366
--- /dev/null
+++ b/drivers/input/touchscreen/atmel-wm97xx.c
@@ -0,0 +1,450 @@
+/*
+ * Atmel AT91 and AVR32 continuous touch screen driver for Wolfson WM97xx AC97
+ * codecs.
+ *
+ * Copyright (C) 2008 - 2009 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/moduleparam.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/timer.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+
+#define AC97C_ICA		0x10
+#define AC97C_CBRHR		0x30
+#define AC97C_CBSR		0x38
+#define AC97C_CBMR		0x3c
+#define AC97C_IER		0x54
+#define AC97C_IDR		0x58
+
+#define AC97C_RXRDY		(1 << 4)
+#define AC97C_OVRUN		(1 << 5)
+
+#define AC97C_CMR_SIZE_20	(0 << 16)
+#define AC97C_CMR_SIZE_18	(1 << 16)
+#define AC97C_CMR_SIZE_16	(2 << 16)
+#define AC97C_CMR_SIZE_10	(3 << 16)
+#define AC97C_CMR_CEM_LITTLE	(1 << 18)
+#define AC97C_CMR_CEM_BIG	(0 << 18)
+#define AC97C_CMR_CENA		(1 << 21)
+
+#define AC97C_INT_CBEVT		(1 << 4)
+
+#define AC97C_SR_CAEVT		(1 << 3)
+
+#define AC97C_CH_MASK(slot)						\
+	(0x7 << (3 * (slot - 3)))
+#define AC97C_CH_ASSIGN(slot, channel)					\
+	(AC97C_CHANNEL_##channel << (3 * (slot - 3)))
+#define AC97C_CHANNEL_NONE	0x0
+#define AC97C_CHANNEL_B		0x2
+
+#define ac97c_writel(chip, reg, val)			\
+	__raw_writel((val), (chip)->regs + AC97C_##reg)
+#define ac97c_readl(chip, reg)				\
+	__raw_readl((chip)->regs + AC97C_##reg)
+
+#ifdef CONFIG_CPU_AT32AP700X
+#define ATMEL_WM97XX_AC97C_IOMEM	(0xfff02800)
+#define ATMEL_WM97XX_AC97C_IRQ		(29)
+#define ATMEL_WM97XX_GPIO_DEFAULT	(32+16) /* Pin 16 on port B. */
+#else
+#error Unkown CPU, this driver only supports AT32AP700X CPUs.
+#endif
+
+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;
+
+/*
+ * Pen sampling frequency (Hz) in continuous mode.
+ */
+static int cont_rate = 188;
+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 = 1;
+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");
+
+/*
+ * GPIO line number.
+ *
+ * Set to GPIO number where the signal from the WM97xx device is hooked up.
+ */
+static int atmel_gpio_line = ATMEL_WM97XX_GPIO_DEFAULT;
+module_param(atmel_gpio_line, int, 0);
+MODULE_PARM_DESC(atmel_gpio_line, "GPIO line number connected to WM97xx");
+
+struct atmel_wm97xx {
+	struct wm97xx		*wm;
+	struct timer_list	pen_timer;
+	void __iomem		*regs;
+	unsigned long		ac97c_irq;
+	unsigned long		gpio_pen;
+	unsigned long		gpio_irq;
+	unsigned short		x;
+	unsigned short		y;
+};
+
+static irqreturn_t atmel_wm97xx_channel_b_interrupt(int irq, void *dev_id)
+{
+	struct atmel_wm97xx *atmel_wm97xx = dev_id;
+	struct wm97xx *wm = atmel_wm97xx->wm;
+	int status = ac97c_readl(atmel_wm97xx, CBSR);
+	irqreturn_t retval = IRQ_NONE;
+
+	if (status & AC97C_OVRUN) {
+		dev_dbg(&wm->touch_dev->dev, "AC97C overrun\n");
+		ac97c_readl(atmel_wm97xx, CBRHR);
+		retval = IRQ_HANDLED;
+	} else if (status & AC97C_RXRDY) {
+		u16 data;
+		u16 value;
+		u16 source;
+		u16 pen_down;
+
+		data = ac97c_readl(atmel_wm97xx, CBRHR);
+		value = data & 0x0fff;
+		source = data & WM97XX_ADCSRC_MASK;
+		pen_down = (data & WM97XX_PEN_DOWN) >> 8;
+
+		if (source == WM97XX_ADCSEL_X)
+			atmel_wm97xx->x = value;
+		if (source == WM97XX_ADCSEL_Y)
+			atmel_wm97xx->y = value;
+
+		if (!pressure && source == WM97XX_ADCSEL_Y) {
+			input_report_abs(wm->input_dev, ABS_X, atmel_wm97xx->x);
+			input_report_abs(wm->input_dev, ABS_Y, atmel_wm97xx->y);
+			input_report_abs(wm->input_dev, ABS_PRESSURE, pen_down);
+			input_report_key(wm->input_dev, BTN_TOUCH,
+					 (pen_down != 0));
+			input_sync(wm->input_dev);
+		} else if (pressure && source == WM97XX_ADCSEL_PRES) {
+			input_report_abs(wm->input_dev, ABS_X, atmel_wm97xx->x);
+			input_report_abs(wm->input_dev, ABS_Y, atmel_wm97xx->y);
+			input_report_abs(wm->input_dev, ABS_PRESSURE, value);
+			input_report_key(wm->input_dev, BTN_TOUCH,
+					 (value != 0));
+			input_sync(wm->input_dev);
+		}
+
+		retval = IRQ_HANDLED;
+	}
+
+	return retval;
+}
+
+static void atmel_wm97xx_pen_timer(unsigned long data)
+{
+	struct atmel_wm97xx *atmel_wm97xx = (struct atmel_wm97xx *)data;
+	struct wm97xx *wm = atmel_wm97xx->wm;
+	int pen_down = gpio_get_value(atmel_wm97xx->gpio_pen);
+
+	if (pen_down != 0) {
+		mod_timer(&atmel_wm97xx->pen_timer, jiffies
+				+ msecs_to_jiffies(1));
+	} else {
+		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_report_key(wm->input_dev, BTN_TOUCH, 0);
+		input_sync(wm->input_dev);
+	}
+}
+
+static void atmel_wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+	struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(wm->touch_dev);
+	int pen_down = gpio_get_value(atmel_wm97xx->gpio_pen);
+
+	if (pen_down != 0) {
+		mod_timer(&atmel_wm97xx->pen_timer, jiffies
+				+ msecs_to_jiffies(1));
+	} else {
+		input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+		input_report_key(wm->input_dev, BTN_TOUCH, 0);
+		input_sync(wm->input_dev);
+	}
+}
+
+static int atmel_wm97xx_acc_startup(struct wm97xx *wm)
+{
+	struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(wm->touch_dev);
+	int idx = 0;
+
+	if (wm->ac97 == NULL)
+		return -ENODEV;
+
+	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->touch_dev->dev, "atmel accelerated touchscreen driver, "
+			"%d samples/sec\n", cinfo[sp_idx].speed);
+
+	if (pen_int) {
+		unsigned long reg;
+
+		wm->pen_irq = atmel_wm97xx->gpio_irq;
+
+		switch (wm->id) {
+		case WM9712_ID2: /* Fall through. */
+		case WM9713_ID2:
+			/*
+			 * Use GPIO 13 (PEN_DOWN) to assert GPIO line 3
+			 * (PENDOWN).
+			 */
+			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_3, WM97XX_GPIO_OUT,
+					WM97XX_GPIO_POL_HIGH,
+					WM97XX_GPIO_NOTSTICKY,
+					WM97XX_GPIO_NOWAKE);
+		case WM9705_ID2: /* Fall through. */
+			/*
+			 * Enable touch data slot in AC97 controller channel B.
+			 */
+			reg = ac97c_readl(atmel_wm97xx, ICA);
+			reg &= ~AC97C_CH_MASK(wm->acc_slot);
+			reg |= AC97C_CH_ASSIGN(wm->acc_slot, B);
+			ac97c_writel(atmel_wm97xx, ICA, reg);
+
+			/*
+			 * Enable channel and interrupt for RXRDY and OVERRUN.
+			 */
+			ac97c_writel(atmel_wm97xx, CBMR, AC97C_CMR_CENA
+					| AC97C_CMR_CEM_BIG
+					| AC97C_CMR_SIZE_16
+					| AC97C_OVRUN
+					| AC97C_RXRDY);
+			/* Dummy read to empty RXRHR. */
+			ac97c_readl(atmel_wm97xx, CBRHR);
+			/*
+			 * Enable interrupt for channel B in the AC97
+			 * controller.
+			 */
+			ac97c_writel(atmel_wm97xx, IER, AC97C_INT_CBEVT);
+			break;
+		default:
+			dev_err(&wm->touch_dev->dev, "pen down irq not "
+					"supported on this device\n");
+			pen_int = 0;
+			break;
+		}
+	}
+
+	return 0;
+}
+
+static void atmel_wm97xx_acc_shutdown(struct wm97xx *wm)
+{
+	if (pen_int) {
+		struct atmel_wm97xx *atmel_wm97xx =
+			platform_get_drvdata(wm->touch_dev);
+		unsigned long ica;
+
+		switch (wm->id & 0xffff) {
+		case WM9705_ID2: /* Fall through. */
+		case WM9712_ID2: /* Fall through. */
+		case WM9713_ID2:
+			/* Disable slot and turn off channel B interrupts. */
+			ica = ac97c_readl(atmel_wm97xx, ICA);
+			ica &= ~AC97C_CH_MASK(wm->acc_slot);
+			ac97c_writel(atmel_wm97xx, ICA, ica);
+			ac97c_writel(atmel_wm97xx, IDR, AC97C_INT_CBEVT);
+			ac97c_writel(atmel_wm97xx, CBMR, 0);
+			wm->pen_irq = 0;
+			break;
+		default:
+			dev_err(&wm->touch_dev->dev, "unknown codec\n");
+			break;
+		}
+	}
+}
+
+static void atmel_wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+	/* Intentionally left empty. */
+}
+
+static struct wm97xx_mach_ops atmel_mach_ops = {
+	.acc_enabled	= 1,
+	.acc_pen_up	= atmel_wm97xx_acc_pen_up,
+	.acc_startup	= atmel_wm97xx_acc_startup,
+	.acc_shutdown	= atmel_wm97xx_acc_shutdown,
+	.irq_enable	= atmel_wm97xx_irq_enable,
+	.irq_gpio	= WM97XX_GPIO_3,
+};
+
+static int __init atmel_wm97xx_probe(struct platform_device *pdev)
+{
+	struct wm97xx *wm = platform_get_drvdata(pdev);
+	struct atmel_wm97xx *atmel_wm97xx;
+	int ret;
+
+	atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL);
+	if (!atmel_wm97xx) {
+		dev_dbg(&pdev->dev, "out of memory\n");
+		return -ENOMEM;
+	}
+
+	atmel_wm97xx->wm	= wm;
+	atmel_wm97xx->regs	= (void *)ATMEL_WM97XX_AC97C_IOMEM;
+	atmel_wm97xx->ac97c_irq	= ATMEL_WM97XX_AC97C_IRQ;
+	atmel_wm97xx->gpio_pen	= atmel_gpio_line;
+	atmel_wm97xx->gpio_irq	= gpio_to_irq(atmel_wm97xx->gpio_pen);
+
+	setup_timer(&atmel_wm97xx->pen_timer, atmel_wm97xx_pen_timer,
+			(unsigned long)atmel_wm97xx);
+
+	ret = request_irq(atmel_wm97xx->ac97c_irq,
+			atmel_wm97xx_channel_b_interrupt,
+			IRQF_SHARED, "atmel-wm97xx-ch-b", atmel_wm97xx);
+	if (ret) {
+		dev_dbg(&pdev->dev, "could not request ac97c irq\n");
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, atmel_wm97xx);
+
+	ret = wm97xx_register_mach_ops(wm, &atmel_mach_ops);
+	if (ret)
+		free_irq(atmel_wm97xx->ac97c_irq, atmel_wm97xx);
+
+	return ret;
+}
+
+static int __exit atmel_wm97xx_remove(struct platform_device *pdev)
+{
+	struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev);
+	struct wm97xx *wm = atmel_wm97xx->wm;
+
+	ac97c_writel(atmel_wm97xx, IDR, AC97C_INT_CBEVT);
+	free_irq(atmel_wm97xx->ac97c_irq, atmel_wm97xx);
+	wm97xx_unregister_mach_ops(wm);
+	kfree(atmel_wm97xx);
+
+	platform_set_drvdata(wm->touch_dev, wm);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int atmel_wm97xx_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+	struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev);
+
+	ac97c_writel(atmel_wm97xx, IDR, AC97C_INT_CBEVT);
+	disable_irq(atmel_wm97xx->gpio_irq);
+
+	return 0;
+}
+
+static int atmel_wm97xx_resume(struct platform_device *pdev)
+{
+	struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev);
+	struct wm97xx *wm = atmel_wm97xx->wm;
+
+	if (wm->input_dev->users) {
+		enable_irq(atmel_wm97xx->gpio_irq);
+		ac97c_writel(atmel_wm97xx, IER, AC97C_INT_CBEVT);
+	}
+
+	return 0;
+}
+#else
+#define atmel_wm97xx_suspend	NULL
+#define atmel_wm97xx_resume	NULL
+#endif
+
+static struct platform_driver atmel_wm97xx_driver = {
+	.remove		= __exit_p(atmel_wm97xx_remove),
+	.driver		= {
+		.name = "wm97xx-touch",
+	},
+	.suspend	= atmel_wm97xx_suspend,
+	.resume		= atmel_wm97xx_resume,
+};
+
+static int __init atmel_wm97xx_init(void)
+{
+	return platform_driver_probe(&atmel_wm97xx_driver, atmel_wm97xx_probe);
+}
+module_init(atmel_wm97xx_init);
+
+static void __exit atmel_wm97xx_exit(void)
+{
+	platform_driver_unregister(&atmel_wm97xx_driver);
+}
+module_exit(atmel_wm97xx_exit);
+
+MODULE_AUTHOR("Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>");
+MODULE_DESCRIPTION("wm97xx continuous touch driver for Atmel AT91 and AVR32");
+MODULE_LICENSE("GPL");
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] WM97xx updates
  2009-03-09 15:48         ` Hans-Christian Egtvedt
@ 2009-03-09 15:57           ` Jiri Slaby
  0 siblings, 0 replies; 13+ messages in thread
From: Jiri Slaby @ 2009-03-09 15:57 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: Mark Brown, Dmitry Torokhov, linux-input, linux-kernel,
	Hans-Christian Egtvedt

On 9.3.2009 16:48, Hans-Christian Egtvedt wrote:
> Please see attached patch.

Note that atmel_wm97xx struct still leaks on atmel_wm97xx_probe fail paths.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-03-09 15:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-03 18:24 [PATCH 0/5] WM97xx updates Mark Brown
2009-03-03 18:24 ` [PATCH 1/5] Input: wm97xx: add BTN_TOUCH event to wm97xx to use it with Android Mark Brown
2009-03-03 18:24   ` [PATCH 2/5] Input: add BTN_TOUCH event Mark Brown
2009-03-03 18:24     ` [PATCH 3/5] Input: Use disable_irq_nosync() for Mainstone Mark Brown
2009-03-03 18:24       ` [PATCH 4/5] Input: Accelerated touchscreen support for Marvell Zylonite Mark Brown
2009-03-03 18:24         ` [PATCH 5/5] Input: add wm97xx accelerated driver for AVR32 AT32AP700X microprocessors Mark Brown
2009-03-03 20:29           ` Jiri Slaby
2009-03-04  9:15 ` [PATCH 0/5] WM97xx updates Dmitry Torokhov
2009-03-04  9:26   ` Hans-Christian Egtvedt
     [not found]     ` <20090304105358.GA32107@rakim.wolfsonmicro.main>
2009-03-04 11:29       ` Hans-Christian Egtvedt
2009-03-04 14:32         ` Mark Brown
2009-03-09 15:48         ` Hans-Christian Egtvedt
2009-03-09 15:57           ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).