aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/touchscreen/cyttsp4_core.h12
-rw-r--r--drivers/input/touchscreen/cyttsp4_spi.c20
-rw-r--r--drivers/input/touchscreen/cyttsp_core.h8
-rw-r--r--drivers/input/touchscreen/cyttsp_i2c_common.c30
-rw-r--r--drivers/input/touchscreen/cyttsp_spi.c6
5 files changed, 44 insertions, 32 deletions
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
370struct cyttsp4_bus_ops { 370struct 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
451static inline int cyttsp4_adap_read(struct cyttsp4 *ts, u8 addr, int size, 451static 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
457static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u8 addr, int size, 457static 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,
463extern struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, 463extern 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);
465extern int cyttsp4_remove(struct cyttsp4 *ts); 465extern int cyttsp4_remove(struct cyttsp4 *ts);
466int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u8 addr, 466int 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);
468int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u8 addr, 468int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
469 u8 length, void *values); 469 u8 length, void *values);
470extern const struct dev_pm_ops cyttsp4_pm_ops; 470extern 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
46static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, 46static 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
132static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, 130static 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
145static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, 143static 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.h b/drivers/input/touchscreen/cyttsp_core.h
index 0cf564a79fb5..07074110a902 100644
--- a/drivers/input/touchscreen/cyttsp_core.h
+++ b/drivers/input/touchscreen/cyttsp_core.h
@@ -112,9 +112,9 @@ struct cyttsp;
112 112
113struct cyttsp_bus_ops { 113struct 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);
146void cyttsp_remove(struct cyttsp *ts); 146void cyttsp_remove(struct cyttsp *ts);
147 147
148int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u8 addr, 148int 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);
150int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u8 addr, 150int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
151 u8 length, void *values); 151 u8 length, void *values);
152extern const struct dev_pm_ops cyttsp_pm_ops; 152extern 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
34int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, 34int 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,
60EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data); 62EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data);
61 63
62int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, 64int 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}
75EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data); 89EXPORT_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
43static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, 43static 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
128static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, 128static 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
135static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, 135static 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);