Add Atmel AT42QT1070 driver
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 1299575978-16134-1
Add driver for Atmel AT42QT1070 QTouch sensor chip.
The AT42QT1070 QTouch sensor support up to 7 keys.
The driver has been tested on Atmel AT91SAM9M10-G45-EK board, it should work fine on other platform.
Modify the driver according to suggestion from Mohan
--- drivers/input/keyboard/Kconfig | 9 ++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/qt1070.c | 290 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 300 insertions(+), 0 deletions(-)
drivers/input/keyboard/Kconfig +9 -0
@@ -124,6 +124,15 @@ config KEYBOARD_ATKBD_RDI_KEYCODES right-hand column will be interpreted as the key shown in the left-hand column. +config KEYBOARD_QT1070 + tristate "Atmel AT42QT1070 Touch Sensor Chip" + depends on I2C + help + Say Y here if you want to use Atmel AT42QT1070 QTouch + Sensor chip as input device. + To compile this driver as a module, choose M here: + the module will be called qt1070 + config KEYBOARD_QT2160 tristate "Atmel AT42QT2160 Touch Sensor Chip" depends on I2C && EXPERIMENTAL
drivers/input/keyboard/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o +obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
drivers/input/keyboard/qt1070.c new file +290 -0
290 lines not on this page · raw message
Dmitry Torokhov
maintainerHi Shen,
drivers/input/keyboard/qt1070.c line 57
Quoted 3 lines · voice
drivers/input/keyboard/qt1070.c new file +3
-0+ +/* AT42QT1070 support up to 7 keys */ +static unsigned char qt1070_key2code[] = {
This should be const.
drivers/input/keyboard/qt1070.c line 65
Quoted 10 lines
drivers/input/keyboard/qt1070.c new file +8
-0+KEY_0 ,KEY_1 ,KEY_2 ,KEY_3 , + KEY_4, KEY_5, KEY_6, +}; + +struct qt1070_data { +struct i2c_client *client; +struct input_dev *input; +unsigned char keycodes[ARRAY_SIZE (qt1070_key2code)];
This should be unsigned short since we have key values above 255.
Quoted 24 lines
drivers/input/keyboard/qt1070.c new file +24
-0+ +static int qt1070_read_key (struct qt1070_data *data) +{ +struct i2c_client *client = data->client; +struct input_dev *input = data->input; +u8 new_key, old_key, keyval; +int ret, i, mask; + +/* Read the detected status register, using to clear interrupt */ + ret =qt1070_read (client,DET_STATUS ); + +/* Read which key changed */ + ret =qt1070_read (client,KEY_STATUS ); + old_key = data->key; + data->key = new_key = ret; + + mask =0x01 ; +for (i =0 ; i <ARRAY_SIZE (qt1070_key2code); i++) { + keyval = new_key & mask; +if ((old_key & mask) != keyval) +input_report_key (input, data->keycodes[i], keyval); + mask <<=1 ; + } +input_sync (input);
drivers/input/keyboard/qt1070.c line 153
Quoted 10 lines
drivers/input/keyboard/qt1070.c new file +10
-0+ +return 0 ; +} + +static irqreturn_t qt1070_interrupt (int irq,void *dev_id) +{ +struct qt1070_data *data = dev_id; +int ret; + + ret =qt1070_read_key (data);
I'd fold qt1070_read_key into qt1070_interrupt.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + if (client->irq) {
The driver is completely unusable without irq, I'd recommend simply refusing to bind if irq is not supplied.
Otherwise looks very good.
Thanks.
Signature · 1 line
Dmitry