diff options
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp4_core.c | 15 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp4_core.h | 12 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp4_spi.c | 20 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp_core.c | 28 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp_core.h | 10 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp_i2c_common.c | 30 | ||||
-rw-r--r-- | drivers/input/touchscreen/cyttsp_spi.c | 6 | ||||
-rw-r--r-- | drivers/input/touchscreen/tps6507x-ts.c | 158 |
9 files changed, 127 insertions, 153 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 2d70089c1183..3b9758b5f4d7 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -909,6 +909,7 @@ config TOUCHSCREEN_STMPE | |||
909 | config TOUCHSCREEN_TPS6507X | 909 | config TOUCHSCREEN_TPS6507X |
910 | tristate "TPS6507x based touchscreens" | 910 | tristate "TPS6507x based touchscreens" |
911 | depends on I2C | 911 | depends on I2C |
912 | select INPUT_POLLDEV | ||
912 | help | 913 | help |
913 | Say Y here if you have a TPS6507x based touchscreen | 914 | Say Y here if you have a TPS6507x based touchscreen |
914 | controller. | 915 | controller. |
diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 580004049b9e..d038575f49db 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c | |||
@@ -153,7 +153,7 @@ static int cyttsp4_hw_reset(struct cyttsp4 *cd) | |||
153 | */ | 153 | */ |
154 | static int cyttsp4_bits_2_bytes(unsigned int nbits, size_t *max) | 154 | static int cyttsp4_bits_2_bytes(unsigned int nbits, size_t *max) |
155 | { | 155 | { |
156 | *max = 1 << nbits; | 156 | *max = 1UL << nbits; |
157 | return (nbits + 7) / 8; | 157 | return (nbits + 7) / 8; |
158 | } | 158 | } |
159 | 159 | ||
@@ -1447,11 +1447,6 @@ static void cyttsp4_watchdog_work(struct work_struct *work) | |||
1447 | u8 *mode; | 1447 | u8 *mode; |
1448 | int retval; | 1448 | int retval; |
1449 | 1449 | ||
1450 | if (cd == NULL) { | ||
1451 | dev_err(cd->dev, "%s: NULL context pointer\n", __func__); | ||
1452 | return; | ||
1453 | } | ||
1454 | |||
1455 | mutex_lock(&cd->system_lock); | 1450 | mutex_lock(&cd->system_lock); |
1456 | retval = cyttsp4_load_status_regs(cd); | 1451 | retval = cyttsp4_load_status_regs(cd); |
1457 | if (retval < 0) { | 1452 | if (retval < 0) { |
@@ -2027,7 +2022,7 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, | |||
2027 | if (!cd->xfer_buf) { | 2022 | if (!cd->xfer_buf) { |
2028 | dev_err(dev, "%s: Error, kzalloc\n", __func__); | 2023 | dev_err(dev, "%s: Error, kzalloc\n", __func__); |
2029 | rc = -ENOMEM; | 2024 | rc = -ENOMEM; |
2030 | goto error_alloc_data; | 2025 | goto error_free_cd; |
2031 | } | 2026 | } |
2032 | 2027 | ||
2033 | /* Initialize device info */ | 2028 | /* Initialize device info */ |
@@ -2051,7 +2046,7 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, | |||
2051 | cd->irq = gpio_to_irq(cd->cpdata->irq_gpio); | 2046 | cd->irq = gpio_to_irq(cd->cpdata->irq_gpio); |
2052 | if (cd->irq < 0) { | 2047 | if (cd->irq < 0) { |
2053 | rc = -EINVAL; | 2048 | rc = -EINVAL; |
2054 | goto error_gpio_irq; | 2049 | goto error_free_xfer; |
2055 | } | 2050 | } |
2056 | 2051 | ||
2057 | dev_set_drvdata(dev, cd); | 2052 | dev_set_drvdata(dev, cd); |
@@ -2119,7 +2114,9 @@ error_request_irq: | |||
2119 | if (cd->cpdata->init) | 2114 | if (cd->cpdata->init) |
2120 | cd->cpdata->init(cd->cpdata, 0, dev); | 2115 | cd->cpdata->init(cd->cpdata, 0, dev); |
2121 | dev_set_drvdata(dev, NULL); | 2116 | dev_set_drvdata(dev, NULL); |
2122 | error_gpio_irq: | 2117 | error_free_xfer: |
2118 | kfree(cd->xfer_buf); | ||
2119 | error_free_cd: | ||
2123 | kfree(cd); | 2120 | kfree(cd); |
2124 | error_alloc_data: | 2121 | error_alloc_data: |
2125 | error_no_pdata: | 2122 | error_no_pdata: |
diff --git a/drivers/input/touchscreen/cyttsp4_core.h b/drivers/input/touchscreen/cyttsp4_core.h index 86a254354136..8e0d4d490b20 100644 --- a/drivers/input/touchscreen/cyttsp4_core.h +++ b/drivers/input/touchscreen/cyttsp4_core.h | |||
@@ -369,9 +369,9 @@ struct cyttsp4 { | |||
369 | 369 | ||
370 | struct cyttsp4_bus_ops { | 370 | struct cyttsp4_bus_ops { |
371 | u16 bustype; | 371 | u16 bustype; |
372 | int (*write)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, | 372 | int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, |
373 | const void *values); | 373 | const void *values); |
374 | int (*read)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, | 374 | int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, |
375 | void *values); | 375 | void *values); |
376 | }; | 376 | }; |
377 | 377 | ||
@@ -448,13 +448,13 @@ enum cyttsp4_event_id { | |||
448 | /* y-axis, 0:origin is on top side of panel, 1: bottom */ | 448 | /* y-axis, 0:origin is on top side of panel, 1: bottom */ |
449 | #define CY_PCFG_ORIGIN_Y_MASK 0x80 | 449 | #define CY_PCFG_ORIGIN_Y_MASK 0x80 |
450 | 450 | ||
451 | static inline int cyttsp4_adap_read(struct cyttsp4 *ts, u8 addr, int size, | 451 | static inline int cyttsp4_adap_read(struct cyttsp4 *ts, u16 addr, int size, |
452 | void *buf) | 452 | void *buf) |
453 | { | 453 | { |
454 | return ts->bus_ops->read(ts->dev, ts->xfer_buf, addr, size, buf); | 454 | return ts->bus_ops->read(ts->dev, ts->xfer_buf, addr, size, buf); |
455 | } | 455 | } |
456 | 456 | ||
457 | static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u8 addr, int size, | 457 | static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u16 addr, int size, |
458 | const void *buf) | 458 | const void *buf) |
459 | { | 459 | { |
460 | return ts->bus_ops->write(ts->dev, ts->xfer_buf, addr, size, buf); | 460 | return ts->bus_ops->write(ts->dev, ts->xfer_buf, addr, size, buf); |
@@ -463,9 +463,9 @@ static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u8 addr, int size, | |||
463 | extern struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, | 463 | extern struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, |
464 | struct device *dev, u16 irq, size_t xfer_buf_size); | 464 | struct device *dev, u16 irq, size_t xfer_buf_size); |
465 | extern int cyttsp4_remove(struct cyttsp4 *ts); | 465 | extern int cyttsp4_remove(struct cyttsp4 *ts); |
466 | int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u8 addr, | 466 | int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr, |
467 | u8 length, const void *values); | 467 | u8 length, const void *values); |
468 | int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u8 addr, | 468 | int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr, |
469 | u8 length, void *values); | 469 | u8 length, void *values); |
470 | extern const struct dev_pm_ops cyttsp4_pm_ops; | 470 | extern const struct dev_pm_ops cyttsp4_pm_ops; |
471 | 471 | ||
diff --git a/drivers/input/touchscreen/cyttsp4_spi.c b/drivers/input/touchscreen/cyttsp4_spi.c index f8f891bead34..a71e1141d638 100644 --- a/drivers/input/touchscreen/cyttsp4_spi.c +++ b/drivers/input/touchscreen/cyttsp4_spi.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #define CY_SPI_DATA_BUF_SIZE (CY_SPI_CMD_BYTES + CY_SPI_DATA_SIZE) | 44 | #define CY_SPI_DATA_BUF_SIZE (CY_SPI_CMD_BYTES + CY_SPI_DATA_SIZE) |
45 | 45 | ||
46 | static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, | 46 | static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, |
47 | u8 op, u8 reg, u8 *buf, int length) | 47 | u8 op, u16 reg, u8 *buf, int length) |
48 | { | 48 | { |
49 | struct spi_device *spi = to_spi_device(dev); | 49 | struct spi_device *spi = to_spi_device(dev); |
50 | struct spi_message msg; | 50 | struct spi_message msg; |
@@ -63,14 +63,12 @@ static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, | |||
63 | memset(wr_buf, 0, CY_SPI_DATA_BUF_SIZE); | 63 | memset(wr_buf, 0, CY_SPI_DATA_BUF_SIZE); |
64 | memset(rd_buf, 0, CY_SPI_CMD_BYTES); | 64 | memset(rd_buf, 0, CY_SPI_CMD_BYTES); |
65 | 65 | ||
66 | if (reg > 255) | 66 | wr_buf[0] = op + (((reg >> 8) & 0x1) ? CY_SPI_A8_BIT : 0); |
67 | wr_buf[0] = op + CY_SPI_A8_BIT; | 67 | if (op == CY_SPI_WR_OP) { |
68 | else | 68 | wr_buf[1] = reg & 0xFF; |
69 | wr_buf[0] = op; | 69 | if (length > 0) |
70 | if (op == CY_SPI_WR_OP) | 70 | memcpy(wr_buf + CY_SPI_CMD_BYTES, buf, length); |
71 | wr_buf[1] = reg % 256; | 71 | } |
72 | if (op == CY_SPI_WR_OP && length > 0) | ||
73 | memcpy(wr_buf + CY_SPI_CMD_BYTES, buf, length); | ||
74 | 72 | ||
75 | memset(xfer, 0, sizeof(xfer)); | 73 | memset(xfer, 0, sizeof(xfer)); |
76 | spi_message_init(&msg); | 74 | spi_message_init(&msg); |
@@ -130,7 +128,7 @@ static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, | |||
130 | } | 128 | } |
131 | 129 | ||
132 | static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, | 130 | static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, |
133 | u8 addr, u8 length, void *data) | 131 | u16 addr, u8 length, void *data) |
134 | { | 132 | { |
135 | int rc; | 133 | int rc; |
136 | 134 | ||
@@ -143,7 +141,7 @@ static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, | |||
143 | } | 141 | } |
144 | 142 | ||
145 | static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, | 143 | static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, |
146 | u8 addr, u8 length, const void *data) | 144 | u16 addr, u8 length, const void *data) |
147 | { | 145 | { |
148 | return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data, | 146 | return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data, |
149 | length); | 147 | length); |
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c index 4824fa343897..d53e0b72a407 100644 --- a/drivers/input/touchscreen/cyttsp_core.c +++ b/drivers/input/touchscreen/cyttsp_core.c | |||
@@ -118,6 +118,15 @@ static int ttsp_send_command(struct cyttsp *ts, u8 cmd) | |||
118 | return ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd); | 118 | return ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd); |
119 | } | 119 | } |
120 | 120 | ||
121 | static int cyttsp_handshake(struct cyttsp *ts) | ||
122 | { | ||
123 | if (ts->pdata->use_hndshk) | ||
124 | return ttsp_send_command(ts, | ||
125 | ts->xy_data.hst_mode ^ CY_HNDSHK_BIT); | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
121 | static int cyttsp_load_bl_regs(struct cyttsp *ts) | 130 | static int cyttsp_load_bl_regs(struct cyttsp *ts) |
122 | { | 131 | { |
123 | memset(&ts->bl_data, 0, sizeof(ts->bl_data)); | 132 | memset(&ts->bl_data, 0, sizeof(ts->bl_data)); |
@@ -135,7 +144,7 @@ static int cyttsp_exit_bl_mode(struct cyttsp *ts) | |||
135 | memcpy(bl_cmd, bl_command, sizeof(bl_command)); | 144 | memcpy(bl_cmd, bl_command, sizeof(bl_command)); |
136 | if (ts->pdata->bl_keys) | 145 | if (ts->pdata->bl_keys) |
137 | memcpy(&bl_cmd[sizeof(bl_command) - CY_NUM_BL_KEYS], | 146 | memcpy(&bl_cmd[sizeof(bl_command) - CY_NUM_BL_KEYS], |
138 | ts->pdata->bl_keys, sizeof(bl_command)); | 147 | ts->pdata->bl_keys, CY_NUM_BL_KEYS); |
139 | 148 | ||
140 | error = ttsp_write_block_data(ts, CY_REG_BASE, | 149 | error = ttsp_write_block_data(ts, CY_REG_BASE, |
141 | sizeof(bl_cmd), bl_cmd); | 150 | sizeof(bl_cmd), bl_cmd); |
@@ -169,6 +178,10 @@ static int cyttsp_set_operational_mode(struct cyttsp *ts) | |||
169 | if (error) | 178 | if (error) |
170 | return error; | 179 | return error; |
171 | 180 | ||
181 | error = cyttsp_handshake(ts); | ||
182 | if (error) | ||
183 | return error; | ||
184 | |||
172 | return ts->xy_data.act_dist == CY_ACT_DIST_DFLT ? -EIO : 0; | 185 | return ts->xy_data.act_dist == CY_ACT_DIST_DFLT ? -EIO : 0; |
173 | } | 186 | } |
174 | 187 | ||
@@ -190,6 +203,10 @@ static int cyttsp_set_sysinfo_mode(struct cyttsp *ts) | |||
190 | if (error) | 203 | if (error) |
191 | return error; | 204 | return error; |
192 | 205 | ||
206 | error = cyttsp_handshake(ts); | ||
207 | if (error) | ||
208 | return error; | ||
209 | |||
193 | if (!ts->sysinfo_data.tts_verh && !ts->sysinfo_data.tts_verl) | 210 | if (!ts->sysinfo_data.tts_verh && !ts->sysinfo_data.tts_verl) |
194 | return -EIO; | 211 | return -EIO; |
195 | 212 | ||
@@ -346,12 +363,9 @@ static irqreturn_t cyttsp_irq(int irq, void *handle) | |||
346 | goto out; | 363 | goto out; |
347 | 364 | ||
348 | /* provide flow control handshake */ | 365 | /* provide flow control handshake */ |
349 | if (ts->pdata->use_hndshk) { | 366 | error = cyttsp_handshake(ts); |
350 | error = ttsp_send_command(ts, | 367 | if (error) |
351 | ts->xy_data.hst_mode ^ CY_HNDSHK_BIT); | 368 | goto out; |
352 | if (error) | ||
353 | goto out; | ||
354 | } | ||
355 | 369 | ||
356 | if (unlikely(ts->state == CY_IDLE_STATE)) | 370 | if (unlikely(ts->state == CY_IDLE_STATE)) |
357 | goto out; | 371 | goto out; |
diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h index d0c9e488b05d..07074110a902 100644 --- a/drivers/input/touchscreen/cyttsp_core.h +++ b/drivers/input/touchscreen/cyttsp_core.h | |||
@@ -67,8 +67,8 @@ struct cyttsp_xydata { | |||
67 | /* TTSP System Information interface definition */ | 67 | /* TTSP System Information interface definition */ |
68 | struct cyttsp_sysinfo_data { | 68 | struct cyttsp_sysinfo_data { |
69 | u8 hst_mode; | 69 | u8 hst_mode; |
70 | u8 mfg_cmd; | ||
71 | u8 mfg_stat; | 70 | u8 mfg_stat; |
71 | u8 mfg_cmd; | ||
72 | u8 cid[3]; | 72 | u8 cid[3]; |
73 | u8 tt_undef1; | 73 | u8 tt_undef1; |
74 | u8 uid[8]; | 74 | u8 uid[8]; |
@@ -112,9 +112,9 @@ struct cyttsp; | |||
112 | 112 | ||
113 | struct cyttsp_bus_ops { | 113 | struct cyttsp_bus_ops { |
114 | u16 bustype; | 114 | u16 bustype; |
115 | int (*write)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, | 115 | int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, |
116 | const void *values); | 116 | const void *values); |
117 | int (*read)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, | 117 | int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, |
118 | void *values); | 118 | void *values); |
119 | }; | 119 | }; |
120 | 120 | ||
@@ -145,9 +145,9 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, | |||
145 | struct device *dev, int irq, size_t xfer_buf_size); | 145 | struct device *dev, int irq, size_t xfer_buf_size); |
146 | void cyttsp_remove(struct cyttsp *ts); | 146 | void cyttsp_remove(struct cyttsp *ts); |
147 | 147 | ||
148 | int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u8 addr, | 148 | int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr, |
149 | u8 length, const void *values); | 149 | u8 length, const void *values); |
150 | int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u8 addr, | 150 | int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr, |
151 | u8 length, void *values); | 151 | u8 length, void *values); |
152 | extern const struct dev_pm_ops cyttsp_pm_ops; | 152 | extern const struct dev_pm_ops cyttsp_pm_ops; |
153 | 153 | ||
diff --git a/drivers/input/touchscreen/cyttsp_i2c_common.c b/drivers/input/touchscreen/cyttsp_i2c_common.c index 07c553fbcef2..1d7b6f154168 100644 --- a/drivers/input/touchscreen/cyttsp_i2c_common.c +++ b/drivers/input/touchscreen/cyttsp_i2c_common.c | |||
@@ -32,18 +32,20 @@ | |||
32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | 33 | ||
34 | int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, | 34 | int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, |
35 | u8 addr, u8 length, void *values) | 35 | u16 addr, u8 length, void *values) |
36 | { | 36 | { |
37 | struct i2c_client *client = to_i2c_client(dev); | 37 | struct i2c_client *client = to_i2c_client(dev); |
38 | u8 client_addr = client->addr | ((addr >> 8) & 0x1); | ||
39 | u8 addr_lo = addr & 0xFF; | ||
38 | struct i2c_msg msgs[] = { | 40 | struct i2c_msg msgs[] = { |
39 | { | 41 | { |
40 | .addr = client->addr, | 42 | .addr = client_addr, |
41 | .flags = 0, | 43 | .flags = 0, |
42 | .len = 1, | 44 | .len = 1, |
43 | .buf = &addr, | 45 | .buf = &addr_lo, |
44 | }, | 46 | }, |
45 | { | 47 | { |
46 | .addr = client->addr, | 48 | .addr = client_addr, |
47 | .flags = I2C_M_RD, | 49 | .flags = I2C_M_RD, |
48 | .len = length, | 50 | .len = length, |
49 | .buf = values, | 51 | .buf = values, |
@@ -60,17 +62,29 @@ int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, | |||
60 | EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data); | 62 | EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data); |
61 | 63 | ||
62 | int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, | 64 | int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, |
63 | u8 addr, u8 length, const void *values) | 65 | u16 addr, u8 length, const void *values) |
64 | { | 66 | { |
65 | struct i2c_client *client = to_i2c_client(dev); | 67 | struct i2c_client *client = to_i2c_client(dev); |
68 | u8 client_addr = client->addr | ((addr >> 8) & 0x1); | ||
69 | u8 addr_lo = addr & 0xFF; | ||
70 | struct i2c_msg msgs[] = { | ||
71 | { | ||
72 | .addr = client_addr, | ||
73 | .flags = 0, | ||
74 | .len = length + 1, | ||
75 | .buf = xfer_buf, | ||
76 | }, | ||
77 | }; | ||
66 | int retval; | 78 | int retval; |
67 | 79 | ||
68 | xfer_buf[0] = addr; | 80 | xfer_buf[0] = addr_lo; |
69 | memcpy(&xfer_buf[1], values, length); | 81 | memcpy(&xfer_buf[1], values, length); |
70 | 82 | ||
71 | retval = i2c_master_send(client, xfer_buf, length + 1); | 83 | retval = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); |
84 | if (retval < 0) | ||
85 | return retval; | ||
72 | 86 | ||
73 | return retval < 0 ? retval : 0; | 87 | return retval != ARRAY_SIZE(msgs) ? -EIO : 0; |
74 | } | 88 | } |
75 | EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data); | 89 | EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data); |
76 | 90 | ||
diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c index 1df625337b84..4728bcb1916c 100644 --- a/drivers/input/touchscreen/cyttsp_spi.c +++ b/drivers/input/touchscreen/cyttsp_spi.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #define CY_SPI_BITS_PER_WORD 8 | 41 | #define CY_SPI_BITS_PER_WORD 8 |
42 | 42 | ||
43 | static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, | 43 | static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, |
44 | u8 op, u8 reg, u8 *buf, int length) | 44 | u8 op, u16 reg, u8 *buf, int length) |
45 | { | 45 | { |
46 | struct spi_device *spi = to_spi_device(dev); | 46 | struct spi_device *spi = to_spi_device(dev); |
47 | struct spi_message msg; | 47 | struct spi_message msg; |
@@ -126,14 +126,14 @@ static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, | |||
126 | } | 126 | } |
127 | 127 | ||
128 | static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, | 128 | static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, |
129 | u8 addr, u8 length, void *data) | 129 | u16 addr, u8 length, void *data) |
130 | { | 130 | { |
131 | return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_RD_OP, addr, data, | 131 | return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_RD_OP, addr, data, |
132 | length); | 132 | length); |
133 | } | 133 | } |
134 | 134 | ||
135 | static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, | 135 | static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, |
136 | u8 addr, u8 length, const void *data) | 136 | u16 addr, u8 length, const void *data) |
137 | { | 137 | { |
138 | return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data, | 138 | return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data, |
139 | length); | 139 | length); |
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index 820a066c3b8a..94cde2cb1491 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/workqueue.h> | 17 | #include <linux/workqueue.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/input.h> | 19 | #include <linux/input.h> |
20 | #include <linux/input-polldev.h> | ||
20 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
21 | #include <linux/mfd/tps6507x.h> | 22 | #include <linux/mfd/tps6507x.h> |
22 | #include <linux/input/tps6507x-ts.h> | 23 | #include <linux/input/tps6507x-ts.h> |
@@ -38,20 +39,13 @@ struct ts_event { | |||
38 | }; | 39 | }; |
39 | 40 | ||
40 | struct tps6507x_ts { | 41 | struct tps6507x_ts { |
41 | struct input_dev *input_dev; | ||
42 | struct device *dev; | 42 | struct device *dev; |
43 | struct input_polled_dev *poll_dev; | ||
44 | struct tps6507x_dev *mfd; | ||
43 | char phys[32]; | 45 | char phys[32]; |
44 | struct delayed_work work; | ||
45 | unsigned polling; /* polling is active */ | ||
46 | struct ts_event tc; | 46 | struct ts_event tc; |
47 | struct tps6507x_dev *mfd; | ||
48 | u16 model; | ||
49 | unsigned pendown; | ||
50 | int irq; | ||
51 | void (*clear_penirq)(void); | ||
52 | unsigned long poll_period; /* ms */ | ||
53 | u16 min_pressure; | 47 | u16 min_pressure; |
54 | int vref; /* non-zero to leave vref on */ | 48 | bool pendown; |
55 | }; | 49 | }; |
56 | 50 | ||
57 | static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data) | 51 | static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data) |
@@ -161,18 +155,15 @@ static s32 tps6507x_adc_standby(struct tps6507x_ts *tsc) | |||
161 | return ret; | 155 | return ret; |
162 | } | 156 | } |
163 | 157 | ||
164 | static void tps6507x_ts_handler(struct work_struct *work) | 158 | static void tps6507x_ts_poll(struct input_polled_dev *poll_dev) |
165 | { | 159 | { |
166 | struct tps6507x_ts *tsc = container_of(work, | 160 | struct tps6507x_ts *tsc = poll_dev->private; |
167 | struct tps6507x_ts, work.work); | 161 | struct input_dev *input_dev = poll_dev->input; |
168 | struct input_dev *input_dev = tsc->input_dev; | 162 | bool pendown; |
169 | int pendown; | ||
170 | int schd; | ||
171 | int poll = 0; | ||
172 | s32 ret; | 163 | s32 ret; |
173 | 164 | ||
174 | ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE, | 165 | ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE, |
175 | &tsc->tc.pressure); | 166 | &tsc->tc.pressure); |
176 | if (ret) | 167 | if (ret) |
177 | goto done; | 168 | goto done; |
178 | 169 | ||
@@ -183,7 +174,7 @@ static void tps6507x_ts_handler(struct work_struct *work) | |||
183 | input_report_key(input_dev, BTN_TOUCH, 0); | 174 | input_report_key(input_dev, BTN_TOUCH, 0); |
184 | input_report_abs(input_dev, ABS_PRESSURE, 0); | 175 | input_report_abs(input_dev, ABS_PRESSURE, 0); |
185 | input_sync(input_dev); | 176 | input_sync(input_dev); |
186 | tsc->pendown = 0; | 177 | tsc->pendown = false; |
187 | } | 178 | } |
188 | 179 | ||
189 | if (pendown) { | 180 | if (pendown) { |
@@ -208,76 +199,69 @@ static void tps6507x_ts_handler(struct work_struct *work) | |||
208 | input_report_abs(input_dev, ABS_Y, tsc->tc.y); | 199 | input_report_abs(input_dev, ABS_Y, tsc->tc.y); |
209 | input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure); | 200 | input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure); |
210 | input_sync(input_dev); | 201 | input_sync(input_dev); |
211 | tsc->pendown = 1; | 202 | tsc->pendown = true; |
212 | poll = 1; | ||
213 | } | 203 | } |
214 | 204 | ||
215 | done: | 205 | done: |
216 | /* always poll if not using interrupts */ | 206 | tps6507x_adc_standby(tsc); |
217 | poll = 1; | ||
218 | |||
219 | if (poll) { | ||
220 | schd = schedule_delayed_work(&tsc->work, | ||
221 | msecs_to_jiffies(tsc->poll_period)); | ||
222 | if (schd) | ||
223 | tsc->polling = 1; | ||
224 | else { | ||
225 | tsc->polling = 0; | ||
226 | dev_err(tsc->dev, "re-schedule failed"); | ||
227 | } | ||
228 | } else | ||
229 | tsc->polling = 0; | ||
230 | |||
231 | ret = tps6507x_adc_standby(tsc); | ||
232 | } | 207 | } |
233 | 208 | ||
234 | static int tps6507x_ts_probe(struct platform_device *pdev) | 209 | static int tps6507x_ts_probe(struct platform_device *pdev) |
235 | { | 210 | { |
236 | int error; | ||
237 | struct tps6507x_ts *tsc; | ||
238 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); | 211 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); |
239 | struct touchscreen_init_data *init_data; | 212 | const struct tps6507x_board *tps_board; |
213 | const struct touchscreen_init_data *init_data; | ||
214 | struct tps6507x_ts *tsc; | ||
215 | struct input_polled_dev *poll_dev; | ||
240 | struct input_dev *input_dev; | 216 | struct input_dev *input_dev; |
241 | struct tps6507x_board *tps_board; | 217 | int error; |
242 | int schd; | ||
243 | 218 | ||
244 | /** | 219 | /* |
245 | * tps_board points to pmic related constants | 220 | * tps_board points to pmic related constants |
246 | * coming from the board-evm file. | 221 | * coming from the board-evm file. |
247 | */ | 222 | */ |
248 | 223 | tps_board = dev_get_platdata(tps6507x_dev->dev); | |
249 | tps_board = (struct tps6507x_board *)tps6507x_dev->dev->platform_data; | ||
250 | |||
251 | if (!tps_board) { | 224 | if (!tps_board) { |
252 | dev_err(tps6507x_dev->dev, | 225 | dev_err(tps6507x_dev->dev, |
253 | "Could not find tps6507x platform data\n"); | 226 | "Could not find tps6507x platform data\n"); |
254 | return -EIO; | 227 | return -ENODEV; |
255 | } | 228 | } |
256 | 229 | ||
257 | /** | 230 | /* |
258 | * init_data points to array of regulator_init structures | 231 | * init_data points to array of regulator_init structures |
259 | * coming from the board-evm file. | 232 | * coming from the board-evm file. |
260 | */ | 233 | */ |
261 | |||
262 | init_data = tps_board->tps6507x_ts_init_data; | 234 | init_data = tps_board->tps6507x_ts_init_data; |
263 | 235 | ||
264 | tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); | 236 | tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); |
265 | if (!tsc) { | 237 | if (!tsc) { |
266 | dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); | 238 | dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); |
267 | error = -ENOMEM; | 239 | return -ENOMEM; |
268 | goto err0; | ||
269 | } | 240 | } |
270 | 241 | ||
271 | tps6507x_dev->ts = tsc; | ||
272 | tsc->mfd = tps6507x_dev; | 242 | tsc->mfd = tps6507x_dev; |
273 | tsc->dev = tps6507x_dev->dev; | 243 | tsc->dev = tps6507x_dev->dev; |
274 | input_dev = input_allocate_device(); | 244 | tsc->min_pressure = init_data ? |
275 | if (!input_dev) { | 245 | init_data->min_pressure : TPS_DEFAULT_MIN_PRESSURE; |
276 | dev_err(tsc->dev, "Failed to allocate input device.\n"); | 246 | |
247 | snprintf(tsc->phys, sizeof(tsc->phys), | ||
248 | "%s/input0", dev_name(tsc->dev)); | ||
249 | |||
250 | poll_dev = input_allocate_polled_device(); | ||
251 | if (!poll_dev) { | ||
252 | dev_err(tsc->dev, "Failed to allocate polled input device.\n"); | ||
277 | error = -ENOMEM; | 253 | error = -ENOMEM; |
278 | goto err1; | 254 | goto err_free_mem; |
279 | } | 255 | } |
280 | 256 | ||
257 | tsc->poll_dev = poll_dev; | ||
258 | |||
259 | poll_dev->private = tsc; | ||
260 | poll_dev->poll = tps6507x_ts_poll; | ||
261 | poll_dev->poll_interval = init_data ? | ||
262 | init_data->poll_period : TSC_DEFAULT_POLL_PERIOD; | ||
263 | |||
264 | input_dev = poll_dev->input; | ||
281 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 265 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
282 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | 266 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
283 | 267 | ||
@@ -286,76 +270,42 @@ static int tps6507x_ts_probe(struct platform_device *pdev) | |||
286 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_10BIT, 0, 0); | 270 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_10BIT, 0, 0); |
287 | 271 | ||
288 | input_dev->name = "TPS6507x Touchscreen"; | 272 | input_dev->name = "TPS6507x Touchscreen"; |
289 | input_dev->id.bustype = BUS_I2C; | ||
290 | input_dev->dev.parent = tsc->dev; | ||
291 | |||
292 | snprintf(tsc->phys, sizeof(tsc->phys), | ||
293 | "%s/input0", dev_name(tsc->dev)); | ||
294 | input_dev->phys = tsc->phys; | 273 | input_dev->phys = tsc->phys; |
295 | 274 | input_dev->dev.parent = tsc->dev; | |
296 | dev_dbg(tsc->dev, "device: %s\n", input_dev->phys); | 275 | input_dev->id.bustype = BUS_I2C; |
297 | |||
298 | input_set_drvdata(input_dev, tsc); | ||
299 | |||
300 | tsc->input_dev = input_dev; | ||
301 | |||
302 | INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler); | ||
303 | |||
304 | if (init_data) { | 276 | if (init_data) { |
305 | tsc->poll_period = init_data->poll_period; | ||
306 | tsc->vref = init_data->vref; | ||
307 | tsc->min_pressure = init_data->min_pressure; | ||
308 | input_dev->id.vendor = init_data->vendor; | 277 | input_dev->id.vendor = init_data->vendor; |
309 | input_dev->id.product = init_data->product; | 278 | input_dev->id.product = init_data->product; |
310 | input_dev->id.version = init_data->version; | 279 | input_dev->id.version = init_data->version; |
311 | } else { | ||
312 | tsc->poll_period = TSC_DEFAULT_POLL_PERIOD; | ||
313 | tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE; | ||
314 | } | 280 | } |
315 | 281 | ||
316 | error = tps6507x_adc_standby(tsc); | 282 | error = tps6507x_adc_standby(tsc); |
317 | if (error) | 283 | if (error) |
318 | goto err2; | 284 | goto err_free_polled_dev; |
319 | 285 | ||
320 | error = input_register_device(input_dev); | 286 | error = input_register_polled_device(poll_dev); |
321 | if (error) | 287 | if (error) |
322 | goto err2; | 288 | goto err_free_polled_dev; |
323 | 289 | ||
324 | schd = schedule_delayed_work(&tsc->work, | 290 | platform_set_drvdata(pdev, tsc); |
325 | msecs_to_jiffies(tsc->poll_period)); | ||
326 | |||
327 | if (schd) | ||
328 | tsc->polling = 1; | ||
329 | else { | ||
330 | tsc->polling = 0; | ||
331 | dev_err(tsc->dev, "schedule failed"); | ||
332 | goto err2; | ||
333 | } | ||
334 | platform_set_drvdata(pdev, tps6507x_dev); | ||
335 | 291 | ||
336 | return 0; | 292 | return 0; |
337 | 293 | ||
338 | err2: | 294 | err_free_polled_dev: |
339 | cancel_delayed_work_sync(&tsc->work); | 295 | input_free_polled_device(poll_dev); |
340 | input_free_device(input_dev); | 296 | err_free_mem: |
341 | err1: | ||
342 | kfree(tsc); | 297 | kfree(tsc); |
343 | tps6507x_dev->ts = NULL; | ||
344 | err0: | ||
345 | return error; | 298 | return error; |
346 | } | 299 | } |
347 | 300 | ||
348 | static int tps6507x_ts_remove(struct platform_device *pdev) | 301 | static int tps6507x_ts_remove(struct platform_device *pdev) |
349 | { | 302 | { |
350 | struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); | 303 | struct tps6507x_ts *tsc = platform_get_drvdata(pdev); |
351 | struct tps6507x_ts *tsc = tps6507x_dev->ts; | 304 | struct input_polled_dev *poll_dev = tsc->poll_dev; |
352 | struct input_dev *input_dev = tsc->input_dev; | ||
353 | |||
354 | cancel_delayed_work_sync(&tsc->work); | ||
355 | 305 | ||
356 | input_unregister_device(input_dev); | 306 | input_unregister_polled_device(poll_dev); |
307 | input_free_polled_device(poll_dev); | ||
357 | 308 | ||
358 | tps6507x_dev->ts = NULL; | ||
359 | kfree(tsc); | 309 | kfree(tsc); |
360 | 310 | ||
361 | return 0; | 311 | return 0; |