Skip to contentSkip to conversation

input: AD7879 Touchscreen driver

PATCH In review Bryan Wu 2 participants 2 messages Oct 16, 2008

Subsystems (4)
lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

PATCH 1/1 input: AD7879 Touchscreen driver

From: Michael Hennerich <[email protected]>

---
 drivers/input/touchscreen/Kconfig  |   27 ++
 drivers/input/touchscreen/Makefile |    1 +
 drivers/input/touchscreen/ad7879.c |  794 ++++++++++++++++++++++++++++++++++++
 include/linux/spi/ad7879.h         |   35 ++
 4 files changed, 857 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/ad7879.c
 create mode 100644 include/linux/spi/ad7879.h
drivers/input/touchscreen/Kconfig +27 -0
index 2fc51d0..83403b8 100644
@@ -42,6 +42,33 @@ config TOUCHSCREEN_AD7877
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad7877.
 
+config TOUCHSCREEN_AD7879
+	tristate "AD7879 based touchscreens"
+	depends on SPI_MASTER || I2C
+	help
+	  Say Y here if you have a touchscreen interface using the
+	  AD7879(-1) controller, and your board-specific initialization
+	  code includes that in its table of SPI/I2C devices.
+
+	  If unsure, say N (but it's safe to say "Y").
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad7879.
+
+choice
+	prompt "Interface Selection"
+	depends on TOUCHSCREEN_AD7879
+
+config TOUCHSCREEN_AD7879_I2C
+	bool "AD7879-1 I2C"
+	depends on I2C
+
+config TOUCHSCREEN_AD7879_SPI
+	bool "AD7879 SPI"
+	depends on SPI_MASTER
+endchoice
+
+
 config TOUCHSCREEN_BITSY
 	tristate "Compaq iPAQ H3600 (Bitsy) touchscreen"
 	depends on SA1100_BITSY
drivers/input/touchscreen/Makefile +1 -0
index 89a3660..de249f7 100644
@@ -7,6 +7,7 @@
 wm97xx-ts-y := wm97xx-core.o
 
 obj-$(CONFIG_TOUCHSCREEN_AD7877)	+= ad7877.o
+obj-$(CONFIG_TOUCHSCREEN_AD7879)	+= ad7879.o
 obj-$(CONFIG_TOUCHSCREEN_ADS7846)	+= ads7846.o
 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC)	+= atmel_tsadcc.o
 obj-$(CONFIG_TOUCHSCREEN_BITSY)		+= h3600_ts_input.o
drivers/input/touchscreen/ad7879.c new file +794 -0

794 lines not on this page · raw message

include/linux/spi/ad7879.h new file +35 -0
new file mode 100644
index 0000000..4231104
@@ -0,0 +1,35 @@
+/* linux/spi/ad7879.h */
+
+/* Touchscreen characteristics vary between boards and models.  The
+ * platform_data for the device's "struct device" holds this information.
+ *
+ * It's OK if the min/max values are zero.
+ */
+struct ad7879_platform_data {
+	u16	model;			/* 7879 */
+	u16	x_plate_ohms;
+	u16	x_min, x_max;
+	u16	y_min, y_max;
+	u16	pressure_min, pressure_max;
+
+	/* [0..255] 0=OFF Starts at 1=550us and goes
+	 * all the way to 9.440ms in steps of 35us.
+	 */
+	u8	pen_down_acc_interval;
+	/* [0..15] Starts at 0=128us and goes all the
+	 * way to 4.096ms in steps of 128us.
+	 */
+	u8	first_conversion_delay;
+	/* [0..3] 0 = 2us, 1 = 4us, 2 = 8us, 3 = 16us */
+	u8	acquisition_time;
+	/* [0..3] Average X middle samples 0 = 2, 1 = 4, 2 = 8, 3 = 16 */
+	u8	averaging;
+	/* [0..3] Perform X measurements 0 = OFF,
+	 * 1 = 4, 2 = 8, 3 = 16 (median > averaging)
+	 */
+	u8	median;
+	/* 1 = AUX/VBAT/GPIO set to GPIO Output */
+	u8	gpio_output;
+	/* Initial GPIO pin state (valid if gpio_output = 1) */
+	u8	gpio_default;
+};
Signature · 1 line
1.5.6
#1 lore raw

On Fri, 17 Oct 2008 01:57:16 +0800
Bryan Wu <[email protected]> wrote:

a little thing..

Quoted 24 lines
drivers/input/touchscreen/ad7879.c new file +24 -0
+static void ad7879_disable(struct ad7879 *ts)
+{
+	unsigned long flags;
+
+	if (ts->disabled)
+		return;
+
+	spin_lock_irqsave(&ts->lock, flags);
+	ts->disabled = 1;
+	disable_irq(ts->bus->irq);
+	spin_unlock_irqrestore(&ts->lock, flags);
+
+	cancel_work_sync(&ts->work);
+
+	if (del_timer_sync(&ts->timer))
+		ad7879_ts_event_release(ts);
+
+	/* we know the chip's in lowpower mode since we always
+	 * leave it that way after every request
+	 */
+}
+
+static void ad7879_enable(struct ad7879 *ts)
+{

drivers/input/touchscreen/ad7879.c line 274

Quoted 10 lines
drivers/input/touchscreen/ad7879.c new file +10 -0
+	unsigned long flags;
+
+	if (!ts->disabled)
+		return;
+
+	spin_lock_irqsave(&ts->lock, flags);
+	ts->disabled = 0;
+	enable_irq(ts->bus->irq);
+	spin_unlock_irqrestore(&ts->lock, flags);
+}

It would looks less racy if ts->disabled was tested while the lock was held.

Also, it would be more grammatically pleasing if ad7879_destruct() was called ad7879_destroy(), but the current spelling will still compile and run :)