aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-06-30 04:40:52 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-07-03 16:13:03 -0400
commit4397c98a8a60ba029f2d0051d0cbafe600f05d8c (patch)
tree8aed8bdd4b811051fc877b1f08e7b68d343a12e4 /drivers/input/touchscreen
parent7cd7a82d16ad5a711338c1baf2316f24121d93aa (diff)
Input: ad7879 - split bus logic out
The ad7879 driver is using the old bus method of only supporting one at a time (I2C or SPI). So refactor it like the other input drivers that support multiple busses simultaneously. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/Kconfig37
-rw-r--r--drivers/input/touchscreen/Makefile2
-rw-r--r--drivers/input/touchscreen/ad7879-i2c.c140
-rw-r--r--drivers/input/touchscreen/ad7879-spi.c190
-rw-r--r--drivers/input/touchscreen/ad7879.c500
-rw-r--r--drivers/input/touchscreen/ad7879.h30
6 files changed, 484 insertions, 415 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index e835f04bc0d0..ff18d896ea6d 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -55,37 +55,36 @@ config TOUCHSCREEN_AD7877
55 To compile this driver as a module, choose M here: the 55 To compile this driver as a module, choose M here: the
56 module will be called ad7877. 56 module will be called ad7877.
57 57
58config TOUCHSCREEN_AD7879_I2C 58config TOUCHSCREEN_AD7879
59 tristate "AD7879 based touchscreens: AD7879-1 I2C Interface" 59 tristate "Analog Devices AD7879-1/AD7889-1 touchscreen interface"
60 depends on I2C
61 select TOUCHSCREEN_AD7879
62 help 60 help
63 Say Y here if you have a touchscreen interface using the 61 Say Y here if you want to support a touchscreen interface using
64 AD7879-1/AD7889-1 controller, and your board-specific 62 the AD7879-1/AD7889-1 controller.
65 initialization code includes that in its table of I2C devices.
66 63
67 If unsure, say N (but it's safe to say "Y"). 64 You should select a bus connection too.
68 65
69 To compile this driver as a module, choose M here: the 66 To compile this driver as a module, choose M here: the
70 module will be called ad7879. 67 module will be called ad7879.
71 68
69config TOUCHSCREEN_AD7879_I2C
70 tristate "support I2C bus connection"
71 depends on TOUCHSCREEN_AD7879 && I2C
72 help
73 Say Y here if you have AD7879-1/AD7889-1 hooked to an I2C bus.
74
75 To compile this driver as a module, choose M here: the
76 module will be called ad7879-i2c.
77
72config TOUCHSCREEN_AD7879_SPI 78config TOUCHSCREEN_AD7879_SPI
73 tristate "AD7879 based touchscreens: AD7879 SPI Interface" 79 tristate "support SPI bus connection"
74 depends on SPI_MASTER && TOUCHSCREEN_AD7879_I2C = n 80 depends on TOUCHSCREEN_AD7879 && SPI_MASTER
75 select TOUCHSCREEN_AD7879
76 help 81 help
77 Say Y here if you have a touchscreen interface using the 82 Say Y here if you have AD7879-1/AD7889-1 hooked to a SPI bus.
78 AD7879/AD7889 controller, and your board-specific initialization
79 code includes that in its table of SPI devices.
80 83
81 If unsure, say N (but it's safe to say "Y"). 84 If unsure, say N (but it's safe to say "Y").
82 85
83 To compile this driver as a module, choose M here: the 86 To compile this driver as a module, choose M here: the
84 module will be called ad7879. 87 module will be called ad7879-spi.
85
86config TOUCHSCREEN_AD7879
87 tristate
88 default n
89 88
90config TOUCHSCREEN_BITSY 89config TOUCHSCREEN_BITSY
91 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" 90 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen"
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 497964a7a214..9efdd4424757 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -9,6 +9,8 @@ wm97xx-ts-y := wm97xx-core.o
9obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o 9obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o
10obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o 10obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o
11obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o 11obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
12obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o
13obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o
12obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 14obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
13obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 15obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
14obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 16obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
new file mode 100644
index 000000000000..85dfdd27df5a
--- /dev/null
+++ b/drivers/input/touchscreen/ad7879-i2c.c
@@ -0,0 +1,140 @@
1/*
2 * AD7879-1/AD7889-1 touchscreen (I2C bus)
3 *
4 * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/input.h> /* BUS_I2C */
10#include <linux/i2c.h>
11#include <linux/module.h>
12#include <linux/types.h>
13
14#include "ad7879.h"
15
16#define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */
17
18#ifdef CONFIG_PM
19static int ad7879_i2c_suspend(struct i2c_client *client, pm_message_t message)
20{
21 struct ad7879 *ts = i2c_get_clientdata(client);
22
23 ad7879_disable(ts);
24
25 return 0;
26}
27
28static int ad7879_i2c_resume(struct i2c_client *client)
29{
30 struct ad7879 *ts = i2c_get_clientdata(client);
31
32 ad7879_enable(ts);
33
34 return 0;
35}
36#else
37# define ad7879_i2c_suspend NULL
38# define ad7879_i2c_resume NULL
39#endif
40
41/* All registers are word-sized.
42 * AD7879 uses a high-byte first convention.
43 */
44static int ad7879_i2c_read(struct device *dev, u8 reg)
45{
46 struct i2c_client *client = to_i2c_client(dev);
47
48 return swab16(i2c_smbus_read_word_data(client, reg));
49}
50
51static int ad7879_i2c_multi_read(struct device *dev,
52 u8 first_reg, u8 count, u16 *buf)
53{
54 u8 idx;
55
56 for (idx = 0; idx < count; ++idx)
57 buf[idx] = ad7879_i2c_read(dev, first_reg + idx);
58
59 return 0;
60}
61
62static int ad7879_i2c_write(struct device *dev, u8 reg, u16 val)
63{
64 struct i2c_client *client = to_i2c_client(dev);
65
66 return i2c_smbus_write_word_data(client, reg, swab16(val));
67}
68
69static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
70 .bustype = BUS_I2C,
71 .read = ad7879_i2c_read,
72 .multi_read = ad7879_i2c_multi_read,
73 .write = ad7879_i2c_write,
74};
75
76static int __devinit ad7879_i2c_probe(struct i2c_client *client,
77 const struct i2c_device_id *id)
78{
79 struct ad7879 *ts;
80
81 if (!i2c_check_functionality(client->adapter,
82 I2C_FUNC_SMBUS_WORD_DATA)) {
83 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
84 return -EIO;
85 }
86
87 ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq,
88 &ad7879_i2c_bus_ops);
89 if (IS_ERR(ts))
90 return PTR_ERR(ts);
91
92 i2c_set_clientdata(client, ts);
93
94 return 0;
95}
96
97static int __devexit ad7879_i2c_remove(struct i2c_client *client)