18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * AD7879-1/AD7889-1 touchscreen (I2C bus) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/input.h> /* BUS_I2C */ 98c2ecf20Sopenharmony_ci#include <linux/i2c.h> 108c2ecf20Sopenharmony_ci#include <linux/module.h> 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci#include <linux/of.h> 138c2ecf20Sopenharmony_ci#include <linux/pm.h> 148c2ecf20Sopenharmony_ci#include <linux/regmap.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include "ad7879.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic const struct regmap_config ad7879_i2c_regmap_config = { 218c2ecf20Sopenharmony_ci .reg_bits = 8, 228c2ecf20Sopenharmony_ci .val_bits = 16, 238c2ecf20Sopenharmony_ci .max_register = 15, 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic int ad7879_i2c_probe(struct i2c_client *client, 278c2ecf20Sopenharmony_ci const struct i2c_device_id *id) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci struct regmap *regmap; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci if (!i2c_check_functionality(client->adapter, 328c2ecf20Sopenharmony_ci I2C_FUNC_SMBUS_WORD_DATA)) { 338c2ecf20Sopenharmony_ci dev_err(&client->dev, "SMBUS Word Data not Supported\n"); 348c2ecf20Sopenharmony_ci return -EIO; 358c2ecf20Sopenharmony_ci } 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci regmap = devm_regmap_init_i2c(client, &ad7879_i2c_regmap_config); 388c2ecf20Sopenharmony_ci if (IS_ERR(regmap)) 398c2ecf20Sopenharmony_ci return PTR_ERR(regmap); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci return ad7879_probe(&client->dev, regmap, client->irq, 428c2ecf20Sopenharmony_ci BUS_I2C, AD7879_DEVID); 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic const struct i2c_device_id ad7879_id[] = { 468c2ecf20Sopenharmony_ci { "ad7879", 0 }, 478c2ecf20Sopenharmony_ci { "ad7889", 0 }, 488c2ecf20Sopenharmony_ci { } 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, ad7879_id); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#ifdef CONFIG_OF 538c2ecf20Sopenharmony_cistatic const struct of_device_id ad7879_i2c_dt_ids[] = { 548c2ecf20Sopenharmony_ci { .compatible = "adi,ad7879-1", }, 558c2ecf20Sopenharmony_ci { } 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, ad7879_i2c_dt_ids); 588c2ecf20Sopenharmony_ci#endif 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic struct i2c_driver ad7879_i2c_driver = { 618c2ecf20Sopenharmony_ci .driver = { 628c2ecf20Sopenharmony_ci .name = "ad7879", 638c2ecf20Sopenharmony_ci .pm = &ad7879_pm_ops, 648c2ecf20Sopenharmony_ci .of_match_table = of_match_ptr(ad7879_i2c_dt_ids), 658c2ecf20Sopenharmony_ci }, 668c2ecf20Sopenharmony_ci .probe = ad7879_i2c_probe, 678c2ecf20Sopenharmony_ci .id_table = ad7879_id, 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cimodule_i2c_driver(ad7879_i2c_driver); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciMODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>"); 738c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver"); 748c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 75