33 #include <linux/input.h>
36 #define CY_SPI_WR_OP 0x00
37 #define CY_SPI_RD_OP 0x01
38 #define CY_SPI_CMD_BYTES 4
39 #define CY_SPI_SYNC_BYTE 2
40 #define CY_SPI_SYNC_ACK1 0x62
41 #define CY_SPI_SYNC_ACK2 0x9D
42 #define CY_SPI_DATA_SIZE 128
43 #define CY_SPI_DATA_BUF_SIZE (CY_SPI_CMD_BYTES + CY_SPI_DATA_SIZE)
44 #define CY_SPI_BITS_PER_WORD 8
46 static int cyttsp_spi_xfer(
struct cyttsp *
ts,
52 u8 *wr_buf = &ts->xfer_buf[0];
58 dev_err(ts->
dev,
"%s: length %d is too big.\n",
73 memset(xfer, 0,
sizeof(xfer));
74 spi_message_init(&msg);
85 spi_message_add_tail(&xfer[0], &msg);
90 spi_message_add_tail(&xfer[0], &msg);
94 spi_message_add_tail(&xfer[1], &msg);
98 dev_err(ts->
dev,
"%s: bad operation code=%d\n", __func__, op);
104 dev_dbg(ts->
dev,
"%s: spi_sync() error %d, len=%d, op=%d\n",
105 __func__, retval, xfer[1].
len, op);
117 dev_dbg(ts->
dev,
"%s: operation %d failed\n", __func__, op);
120 dev_dbg(ts->
dev,
"%s: test rd_buf[%d]:0x%02x\n",
121 __func__, i, rd_buf[i]);
122 for (i = 0; i <
length; i++)
124 __func__, i, buf[i]);
132 static int cyttsp_spi_read_block_data(
struct cyttsp *
ts,
135 return cyttsp_spi_xfer(ts,
CY_SPI_RD_OP, addr, data, length);
138 static int cyttsp_spi_write_block_data(
struct cyttsp *
ts,
141 return cyttsp_spi_xfer(ts,
CY_SPI_WR_OP, addr, (
void *)data, length);
146 .write = cyttsp_spi_write_block_data,
147 .read = cyttsp_spi_read_block_data,
160 dev_err(&spi->
dev,
"%s: SPI setup error %d\n",
170 spi_set_drvdata(spi, ts);
177 struct cyttsp *ts = spi_get_drvdata(spi);
184 static struct spi_driver cyttsp_spi_driver = {
190 .probe = cyttsp_spi_probe,