0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "cyttsp_core.h"
0017
0018 #include <linux/i2c.h>
0019 #include <linux/input.h>
0020
0021 #define CY_I2C_NAME "cyttsp-i2c"
0022
0023 #define CY_I2C_DATA_SIZE 128
0024
0025 static const struct cyttsp_bus_ops cyttsp_i2c_bus_ops = {
0026 .bustype = BUS_I2C,
0027 .write = cyttsp_i2c_write_block_data,
0028 .read = cyttsp_i2c_read_block_data,
0029 };
0030
0031 static int cyttsp_i2c_probe(struct i2c_client *client,
0032 const struct i2c_device_id *id)
0033 {
0034 struct cyttsp *ts;
0035
0036 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
0037 dev_err(&client->dev, "I2C functionality not Supported\n");
0038 return -EIO;
0039 }
0040
0041 ts = cyttsp_probe(&cyttsp_i2c_bus_ops, &client->dev, client->irq,
0042 CY_I2C_DATA_SIZE);
0043
0044 if (IS_ERR(ts))
0045 return PTR_ERR(ts);
0046
0047 i2c_set_clientdata(client, ts);
0048 return 0;
0049 }
0050
0051 static const struct i2c_device_id cyttsp_i2c_id[] = {
0052 { CY_I2C_NAME, 0 },
0053 { }
0054 };
0055 MODULE_DEVICE_TABLE(i2c, cyttsp_i2c_id);
0056
0057 static const struct of_device_id cyttsp_of_i2c_match[] = {
0058 { .compatible = "cypress,cy8ctma340", },
0059 { .compatible = "cypress,cy8ctst341", },
0060 { }
0061 };
0062 MODULE_DEVICE_TABLE(of, cyttsp_of_i2c_match);
0063
0064 static struct i2c_driver cyttsp_i2c_driver = {
0065 .driver = {
0066 .name = CY_I2C_NAME,
0067 .pm = &cyttsp_pm_ops,
0068 .of_match_table = cyttsp_of_i2c_match,
0069 },
0070 .probe = cyttsp_i2c_probe,
0071 .id_table = cyttsp_i2c_id,
0072 };
0073
0074 module_i2c_driver(cyttsp_i2c_driver);
0075
0076 MODULE_LICENSE("GPL");
0077 MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard Product (TTSP) I2C driver");
0078 MODULE_AUTHOR("Cypress");