1 // SPDX-License-Identifier: GPL-2.0-only
4 * Cypress TrueTouch(TM) Standard Product (TTSP) I2C touchscreen driver.
5 * For use with Cypress Txx3xx and Txx4xx parts.
6 * Supported parts include:
12 * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
13 * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
15 * Contact Cypress Semiconductor at www.cypress.com <ttdrivers@cypress.com>
18 #include <linux/device.h>
19 #include <linux/export.h>
20 #include <linux/i2c.h>
21 #include <linux/module.h>
22 #include <linux/types.h>
24 #include "cyttsp4_core.h"
26 int cyttsp_i2c_read_block_data(struct device
*dev
, u8
*xfer_buf
,
27 u16 addr
, u8 length
, void *values
)
29 struct i2c_client
*client
= to_i2c_client(dev
);
30 u8 client_addr
= client
->addr
| ((addr
>> 8) & 0x1);
31 u8 addr_lo
= addr
& 0xFF;
32 struct i2c_msg msgs
[] = {
48 retval
= i2c_transfer(client
->adapter
, msgs
, ARRAY_SIZE(msgs
));
52 return retval
!= ARRAY_SIZE(msgs
) ? -EIO
: 0;
54 EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data
);
56 int cyttsp_i2c_write_block_data(struct device
*dev
, u8
*xfer_buf
,
57 u16 addr
, u8 length
, const void *values
)
59 struct i2c_client
*client
= to_i2c_client(dev
);
60 u8 client_addr
= client
->addr
| ((addr
>> 8) & 0x1);
61 u8 addr_lo
= addr
& 0xFF;
62 struct i2c_msg msgs
[] = {
72 xfer_buf
[0] = addr_lo
;
73 memcpy(&xfer_buf
[1], values
, length
);
75 retval
= i2c_transfer(client
->adapter
, msgs
, ARRAY_SIZE(msgs
));
79 return retval
!= ARRAY_SIZE(msgs
) ? -EIO
: 0;
81 EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data
);
84 MODULE_LICENSE("GPL");
85 MODULE_AUTHOR("Cypress");