23 #include <linux/module.h>
24 #include <linux/slab.h>
26 #include <linux/input.h>
27 #include <linux/serio.h>
29 #include <linux/i2c.h>
31 #define TAOS_BUFFER_SIZE 63
33 #define TAOS_STATE_INIT 0
34 #define TAOS_STATE_IDLE 1
35 #define TAOS_STATE_EOFF 2
36 #define TAOS_STATE_RECV 3
38 #define TAOS_CMD_RESET 0x12
39 #define TAOS_CMD_ECHO_ON '+'
40 #define TAOS_CMD_ECHO_OFF '-'
61 if (!
strncmp(adapter->
name,
"TAOS TSL2550 EVM", 16)) {
62 dev_info(&adapter->
dev,
"Instantiating device %s at 0x%02x\n",
63 tsl2550_info.
type, tsl2550_info.
addr);
75 struct taos_data *taos = serio_get_drvdata(serio);
84 if (addr != taos->
addr)
101 dev_warn(&adapter->
dev,
"Unsupported transaction %d\n", size);
107 for (p = taos->
buffer; *p; p++)
108 serio_write(serio, *p);
120 dev_err(&adapter->
dev,
"Transaction timeout (pos=%d)\n",
151 .smbus_xfer = taos_smbus_xfer,
152 .functionality = taos_smbus_func,
155 static irqreturn_t taos_interrupt(
struct serio *serio,
unsigned char data,
158 struct taos_data *taos = serio_get_drvdata(serio);
160 switch (taos->
state) {
189 static char *taos_adapter_name(
char *
buffer)
193 start =
strstr(buffer,
"TAOS ");
197 end =
strchr(start,
'\r');
205 static int taos_connect(
struct serio *serio,
struct serio_driver *drv)
218 serio_set_drvdata(serio, taos);
226 adapter->
algo = &taos_algorithm;
228 adapter->
dev.parent = &serio->
dev;
237 dev_err(&serio->
dev,
"TAOS EVM reset failed (state=%d, "
238 "pos=%d)\n", taos->
state, taos->
pos);
242 name = taos_adapter_name(taos->
buffer);
245 dev_err(&serio->
dev,
"TAOS EVM identification failed\n");
258 dev_err(&serio->
dev,
"TAOS EVM echo off failed "
259 "(state=%d)\n", taos->
state);
268 taos->
client = taos_instantiate_device(adapter);
274 serio_set_drvdata(serio,
NULL);
280 static void taos_disconnect(
struct serio *serio)
282 struct taos_data *taos = serio_get_drvdata(serio);
288 serio_set_drvdata(serio,
NULL);
291 dev_info(&serio->
dev,
"Disconnected from TAOS EVM\n");
309 .description =
"TAOS evaluation module driver",
310 .id_table = taos_serio_ids,
311 .connect = taos_connect,
312 .disconnect = taos_disconnect,
313 .interrupt = taos_interrupt,
316 static int __init taos_init(
void)
321 static void __exit taos_exit(
void)