18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * cyttsp_i2c.c 48c2ecf20Sopenharmony_ci * Cypress TrueTouch(TM) Standard Product (TTSP) I2C touchscreen driver. 58c2ecf20Sopenharmony_ci * For use with Cypress Txx3xx parts. 68c2ecf20Sopenharmony_ci * Supported parts include: 78c2ecf20Sopenharmony_ci * CY8CTST341 88c2ecf20Sopenharmony_ci * CY8CTMA340 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc. 118c2ecf20Sopenharmony_ci * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org> 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * Contact Cypress Semiconductor at www.cypress.com <ttdrivers@cypress.com> 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include "cyttsp_core.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/i2c.h> 198c2ecf20Sopenharmony_ci#include <linux/input.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define CY_I2C_DATA_SIZE 128 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic const struct cyttsp_bus_ops cyttsp_i2c_bus_ops = { 248c2ecf20Sopenharmony_ci .bustype = BUS_I2C, 258c2ecf20Sopenharmony_ci .write = cyttsp_i2c_write_block_data, 268c2ecf20Sopenharmony_ci .read = cyttsp_i2c_read_block_data, 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic int cyttsp_i2c_probe(struct i2c_client *client, 308c2ecf20Sopenharmony_ci const struct i2c_device_id *id) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci struct cyttsp *ts; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 358c2ecf20Sopenharmony_ci dev_err(&client->dev, "I2C functionality not Supported\n"); 368c2ecf20Sopenharmony_ci return -EIO; 378c2ecf20Sopenharmony_ci } 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci ts = cyttsp_probe(&cyttsp_i2c_bus_ops, &client->dev, client->irq, 408c2ecf20Sopenharmony_ci CY_I2C_DATA_SIZE); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci if (IS_ERR(ts)) 438c2ecf20Sopenharmony_ci return PTR_ERR(ts); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci i2c_set_clientdata(client, ts); 468c2ecf20Sopenharmony_ci return 0; 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic const struct i2c_device_id cyttsp_i2c_id[] = { 508c2ecf20Sopenharmony_ci { CY_I2C_NAME, 0 }, 518c2ecf20Sopenharmony_ci { } 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, cyttsp_i2c_id); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic struct i2c_driver cyttsp_i2c_driver = { 568c2ecf20Sopenharmony_ci .driver = { 578c2ecf20Sopenharmony_ci .name = CY_I2C_NAME, 588c2ecf20Sopenharmony_ci .pm = &cyttsp_pm_ops, 598c2ecf20Sopenharmony_ci }, 608c2ecf20Sopenharmony_ci .probe = cyttsp_i2c_probe, 618c2ecf20Sopenharmony_ci .id_table = cyttsp_i2c_id, 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cimodule_i2c_driver(cyttsp_i2c_driver); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 678c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Cypress TrueTouch(R) Standard Product (TTSP) I2C driver"); 688c2ecf20Sopenharmony_ciMODULE_AUTHOR("Cypress"); 69