1*09c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 25c6a7a62SOlivier Sobrie #include <linux/module.h> 35c6a7a62SOlivier Sobrie #include <linux/i2c.h> 45c6a7a62SOlivier Sobrie #include <linux/interrupt.h> 55c6a7a62SOlivier Sobrie #include <linux/slab.h> 65c6a7a62SOlivier Sobrie #include <linux/input.h> 75c6a7a62SOlivier Sobrie #include <linux/input/mt.h> 8f67cc3e9SMarek Vasut #include <linux/input/touchscreen.h> 95c6a7a62SOlivier Sobrie #include <linux/delay.h> 105c6a7a62SOlivier Sobrie #include <linux/workqueue.h> 11201f3c80SMarek Vasut #include <linux/gpio/consumer.h> 1249588917SMarek Vasut #include <linux/of_device.h> 13e3559442SMarek Vasut #include <asm/unaligned.h> 145c6a7a62SOlivier Sobrie 1549588917SMarek Vasut #define ILI210X_TOUCHES 2 1649588917SMarek Vasut #define ILI251X_TOUCHES 10 175c6a7a62SOlivier Sobrie #define DEFAULT_POLL_PERIOD 20 185c6a7a62SOlivier Sobrie 195c6a7a62SOlivier Sobrie /* Touchscreen commands */ 205c6a7a62SOlivier Sobrie #define REG_TOUCHDATA 0x10 215c6a7a62SOlivier Sobrie #define REG_PANEL_INFO 0x20 225c6a7a62SOlivier Sobrie #define REG_FIRMWARE_VERSION 0x40 235c6a7a62SOlivier Sobrie #define REG_CALIBRATE 0xcc 245c6a7a62SOlivier Sobrie 255c6a7a62SOlivier Sobrie struct firmware_version { 265c6a7a62SOlivier Sobrie u8 id; 275c6a7a62SOlivier Sobrie u8 major; 285c6a7a62SOlivier Sobrie u8 minor; 295c6a7a62SOlivier Sobrie } __packed; 305c6a7a62SOlivier Sobrie 3149588917SMarek Vasut enum ili2xxx_model { 3249588917SMarek Vasut MODEL_ILI210X, 3349588917SMarek Vasut MODEL_ILI251X, 3449588917SMarek Vasut }; 3549588917SMarek Vasut 365c6a7a62SOlivier Sobrie struct ili210x { 375c6a7a62SOlivier Sobrie struct i2c_client *client; 385c6a7a62SOlivier Sobrie struct input_dev *input; 395c6a7a62SOlivier Sobrie unsigned int poll_period; 405c6a7a62SOlivier Sobrie struct delayed_work dwork; 41201f3c80SMarek Vasut struct gpio_desc *reset_gpio; 42f67cc3e9SMarek Vasut struct touchscreen_properties prop; 4349588917SMarek Vasut enum ili2xxx_model model; 4449588917SMarek Vasut unsigned int max_touches; 455c6a7a62SOlivier Sobrie }; 465c6a7a62SOlivier Sobrie 475c6a7a62SOlivier Sobrie static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, 485c6a7a62SOlivier Sobrie size_t len) 495c6a7a62SOlivier Sobrie { 5049588917SMarek Vasut struct ili210x *priv = i2c_get_clientdata(client); 515c6a7a62SOlivier Sobrie struct i2c_msg msg[2] = { 525c6a7a62SOlivier Sobrie { 535c6a7a62SOlivier Sobrie .addr = client->addr, 545c6a7a62SOlivier Sobrie .flags = 0, 555c6a7a62SOlivier Sobrie .len = 1, 565c6a7a62SOlivier Sobrie .buf = ®, 575c6a7a62SOlivier Sobrie }, 585c6a7a62SOlivier Sobrie { 595c6a7a62SOlivier Sobrie .addr = client->addr, 605c6a7a62SOlivier Sobrie .flags = I2C_M_RD, 615c6a7a62SOlivier Sobrie .len = len, 625c6a7a62SOlivier Sobrie .buf = buf, 635c6a7a62SOlivier Sobrie } 645c6a7a62SOlivier Sobrie }; 655c6a7a62SOlivier Sobrie 6649588917SMarek Vasut if (priv->model == MODEL_ILI251X) { 6749588917SMarek Vasut if (i2c_transfer(client->adapter, msg, 1) != 1) { 6849588917SMarek Vasut dev_err(&client->dev, "i2c transfer failed\n"); 6949588917SMarek Vasut return -EIO; 7049588917SMarek Vasut } 7149588917SMarek Vasut 7249588917SMarek Vasut usleep_range(5000, 5500); 7349588917SMarek Vasut 7449588917SMarek Vasut if (i2c_transfer(client->adapter, msg + 1, 1) != 1) { 7549588917SMarek Vasut dev_err(&client->dev, "i2c transfer failed\n"); 7649588917SMarek Vasut return -EIO; 7749588917SMarek Vasut } 7849588917SMarek Vasut } else { 795c6a7a62SOlivier Sobrie if (i2c_transfer(client->adapter, msg, 2) != 2) { 805c6a7a62SOlivier Sobrie dev_err(&client->dev, "i2c transfer failed\n"); 815c6a7a62SOlivier Sobrie return -EIO; 825c6a7a62SOlivier Sobrie } 8349588917SMarek Vasut } 8449588917SMarek Vasut 8549588917SMarek Vasut return 0; 8649588917SMarek Vasut } 8749588917SMarek Vasut 8849588917SMarek Vasut static int ili210x_read(struct i2c_client *client, void *buf, size_t len) 8949588917SMarek Vasut { 9049588917SMarek Vasut struct i2c_msg msg = { 9149588917SMarek Vasut .addr = client->addr, 9249588917SMarek Vasut .flags = I2C_M_RD, 9349588917SMarek Vasut .len = len, 9449588917SMarek Vasut .buf = buf, 9549588917SMarek Vasut }; 9649588917SMarek Vasut 9749588917SMarek Vasut if (i2c_transfer(client->adapter, &msg, 1) != 1) { 9849588917SMarek Vasut dev_err(&client->dev, "i2c transfer failed\n"); 9949588917SMarek Vasut return -EIO; 10049588917SMarek Vasut } 1015c6a7a62SOlivier Sobrie 1025c6a7a62SOlivier Sobrie return 0; 1035c6a7a62SOlivier Sobrie } 1045c6a7a62SOlivier Sobrie 105e3559442SMarek Vasut static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, 106e3559442SMarek Vasut unsigned int finger, 107e3559442SMarek Vasut unsigned int *x, unsigned int *y) 1085c6a7a62SOlivier Sobrie { 10949588917SMarek Vasut if (finger >= ILI210X_TOUCHES) 110e3559442SMarek Vasut return false; 111e3559442SMarek Vasut 112e3559442SMarek Vasut if (touchdata[0] & BIT(finger)) 113e3559442SMarek Vasut return false; 114e3559442SMarek Vasut 115e3559442SMarek Vasut *x = get_unaligned_be16(touchdata + 1 + (finger * 4) + 0); 116e3559442SMarek Vasut *y = get_unaligned_be16(touchdata + 1 + (finger * 4) + 2); 117e3559442SMarek Vasut 118e3559442SMarek Vasut return true; 119e3559442SMarek Vasut } 120e3559442SMarek Vasut 12149588917SMarek Vasut static bool ili251x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, 12249588917SMarek Vasut unsigned int finger, 12349588917SMarek Vasut unsigned int *x, unsigned int *y) 12449588917SMarek Vasut { 12549588917SMarek Vasut if (finger >= ILI251X_TOUCHES) 12649588917SMarek Vasut return false; 12749588917SMarek Vasut 12849588917SMarek Vasut *x = get_unaligned_be16(touchdata + 1 + (finger * 5) + 0); 12949588917SMarek Vasut if (!(*x & BIT(15))) /* Touch indication */ 13049588917SMarek Vasut return false; 13149588917SMarek Vasut 13249588917SMarek Vasut *x &= 0x3fff; 13349588917SMarek Vasut *y = get_unaligned_be16(touchdata + 1 + (finger * 5) + 2); 13449588917SMarek Vasut 13549588917SMarek Vasut return true; 13649588917SMarek Vasut } 13749588917SMarek Vasut 138e3559442SMarek Vasut static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) 139e3559442SMarek Vasut { 140e3559442SMarek Vasut struct input_dev *input = priv->input; 1415c6a7a62SOlivier Sobrie int i; 14249588917SMarek Vasut bool contact = false, touch = false; 14349588917SMarek Vasut unsigned int x = 0, y = 0; 1445c6a7a62SOlivier Sobrie 14549588917SMarek Vasut for (i = 0; i < priv->max_touches; i++) { 14649588917SMarek Vasut if (priv->model == MODEL_ILI210X) { 14749588917SMarek Vasut touch = ili210x_touchdata_to_coords(priv, touchdata, 14849588917SMarek Vasut i, &x, &y); 14949588917SMarek Vasut } else if (priv->model == MODEL_ILI251X) { 15049588917SMarek Vasut touch = ili251x_touchdata_to_coords(priv, touchdata, 15149588917SMarek Vasut i, &x, &y); 15249588917SMarek Vasut if (touch) 15349588917SMarek Vasut contact = true; 15449588917SMarek Vasut } 15549588917SMarek Vasut 156f67cc3e9SMarek Vasut input_mt_slot(input, i); 1575c6a7a62SOlivier Sobrie input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); 158f67cc3e9SMarek Vasut if (!touch) 159f67cc3e9SMarek Vasut continue; 160f67cc3e9SMarek Vasut touchscreen_report_pos(input, &priv->prop, x, y, 161f67cc3e9SMarek Vasut true); 1625c6a7a62SOlivier Sobrie } 1635c6a7a62SOlivier Sobrie 1645c6a7a62SOlivier Sobrie input_mt_report_pointer_emulation(input, false); 1655c6a7a62SOlivier Sobrie input_sync(input); 166e3559442SMarek Vasut 16749588917SMarek Vasut if (priv->model == MODEL_ILI210X) 16849588917SMarek Vasut contact = touchdata[0] & 0xf3; 16949588917SMarek Vasut 17049588917SMarek Vasut return contact; 1715c6a7a62SOlivier Sobrie } 1725c6a7a62SOlivier Sobrie 1735c6a7a62SOlivier Sobrie static void ili210x_work(struct work_struct *work) 1745c6a7a62SOlivier Sobrie { 1755c6a7a62SOlivier Sobrie struct ili210x *priv = container_of(work, struct ili210x, 1765c6a7a62SOlivier Sobrie dwork.work); 1775c6a7a62SOlivier Sobrie struct i2c_client *client = priv->client; 17849588917SMarek Vasut u8 touchdata[64] = { 0 }; 179e3559442SMarek Vasut bool touch; 18049588917SMarek Vasut int error = -EINVAL; 1815c6a7a62SOlivier Sobrie 18249588917SMarek Vasut if (priv->model == MODEL_ILI210X) { 1835c6a7a62SOlivier Sobrie error = ili210x_read_reg(client, REG_TOUCHDATA, 184e3559442SMarek Vasut touchdata, sizeof(touchdata)); 18549588917SMarek Vasut } else if (priv->model == MODEL_ILI251X) { 18649588917SMarek Vasut error = ili210x_read_reg(client, REG_TOUCHDATA, 18749588917SMarek Vasut touchdata, 31); 18849588917SMarek Vasut if (!error && touchdata[0] == 2) 18949588917SMarek Vasut error = ili210x_read(client, &touchdata[31], 20); 19049588917SMarek Vasut } 19149588917SMarek Vasut 1925c6a7a62SOlivier Sobrie if (error) { 1935c6a7a62SOlivier Sobrie dev_err(&client->dev, 1945c6a7a62SOlivier Sobrie "Unable to get touchdata, err = %d\n", error); 1955c6a7a62SOlivier Sobrie return; 1965c6a7a62SOlivier Sobrie } 1975c6a7a62SOlivier Sobrie 198e3559442SMarek Vasut touch = ili210x_report_events(priv, touchdata); 1995c6a7a62SOlivier Sobrie 200e3559442SMarek Vasut if (touch) 2015c6a7a62SOlivier Sobrie schedule_delayed_work(&priv->dwork, 2025c6a7a62SOlivier Sobrie msecs_to_jiffies(priv->poll_period)); 2035c6a7a62SOlivier Sobrie } 2045c6a7a62SOlivier Sobrie 2055c6a7a62SOlivier Sobrie static irqreturn_t ili210x_irq(int irq, void *irq_data) 2065c6a7a62SOlivier Sobrie { 2075c6a7a62SOlivier Sobrie struct ili210x *priv = irq_data; 2085c6a7a62SOlivier Sobrie 2095c6a7a62SOlivier Sobrie schedule_delayed_work(&priv->dwork, 0); 2105c6a7a62SOlivier Sobrie 2115c6a7a62SOlivier Sobrie return IRQ_HANDLED; 2125c6a7a62SOlivier Sobrie } 2135c6a7a62SOlivier Sobrie 2145c6a7a62SOlivier Sobrie static ssize_t ili210x_calibrate(struct device *dev, 2155c6a7a62SOlivier Sobrie struct device_attribute *attr, 2165c6a7a62SOlivier Sobrie const char *buf, size_t count) 2175c6a7a62SOlivier Sobrie { 2185c6a7a62SOlivier Sobrie struct i2c_client *client = to_i2c_client(dev); 2195c6a7a62SOlivier Sobrie struct ili210x *priv = i2c_get_clientdata(client); 2205c6a7a62SOlivier Sobrie unsigned long calibrate; 2215c6a7a62SOlivier Sobrie int rc; 2225c6a7a62SOlivier Sobrie u8 cmd = REG_CALIBRATE; 2235c6a7a62SOlivier Sobrie 2245c6a7a62SOlivier Sobrie if (kstrtoul(buf, 10, &calibrate)) 2255c6a7a62SOlivier Sobrie return -EINVAL; 2265c6a7a62SOlivier Sobrie 2275c6a7a62SOlivier Sobrie if (calibrate > 1) 2285c6a7a62SOlivier Sobrie return -EINVAL; 2295c6a7a62SOlivier Sobrie 2305c6a7a62SOlivier Sobrie if (calibrate) { 2315c6a7a62SOlivier Sobrie rc = i2c_master_send(priv->client, &cmd, sizeof(cmd)); 2325c6a7a62SOlivier Sobrie if (rc != sizeof(cmd)) 2335c6a7a62SOlivier Sobrie return -EIO; 2345c6a7a62SOlivier Sobrie } 2355c6a7a62SOlivier Sobrie 2365c6a7a62SOlivier Sobrie return count; 2375c6a7a62SOlivier Sobrie } 238b27c0d0cSDmitry Torokhov static DEVICE_ATTR(calibrate, S_IWUSR, NULL, ili210x_calibrate); 2395c6a7a62SOlivier Sobrie 2405c6a7a62SOlivier Sobrie static struct attribute *ili210x_attributes[] = { 2415c6a7a62SOlivier Sobrie &dev_attr_calibrate.attr, 2425c6a7a62SOlivier Sobrie NULL, 2435c6a7a62SOlivier Sobrie }; 2445c6a7a62SOlivier Sobrie 2455c6a7a62SOlivier Sobrie static const struct attribute_group ili210x_attr_group = { 2465c6a7a62SOlivier Sobrie .attrs = ili210x_attributes, 2475c6a7a62SOlivier Sobrie }; 2485c6a7a62SOlivier Sobrie 249201f3c80SMarek Vasut static void ili210x_power_down(void *data) 250201f3c80SMarek Vasut { 251201f3c80SMarek Vasut struct gpio_desc *reset_gpio = data; 252201f3c80SMarek Vasut 253201f3c80SMarek Vasut gpiod_set_value_cansleep(reset_gpio, 1); 254201f3c80SMarek Vasut } 255201f3c80SMarek Vasut 2561bdec5d9SMarek Vasut static void ili210x_cancel_work(void *data) 2571bdec5d9SMarek Vasut { 2581bdec5d9SMarek Vasut struct ili210x *priv = data; 2591bdec5d9SMarek Vasut 2601bdec5d9SMarek Vasut cancel_delayed_work_sync(&priv->dwork); 2611bdec5d9SMarek Vasut } 2621bdec5d9SMarek Vasut 2635298cc4cSBill Pemberton static int ili210x_i2c_probe(struct i2c_client *client, 2645c6a7a62SOlivier Sobrie const struct i2c_device_id *id) 2655c6a7a62SOlivier Sobrie { 2665c6a7a62SOlivier Sobrie struct device *dev = &client->dev; 2675c6a7a62SOlivier Sobrie struct ili210x *priv; 268201f3c80SMarek Vasut struct gpio_desc *reset_gpio; 2695c6a7a62SOlivier Sobrie struct input_dev *input; 2705c6a7a62SOlivier Sobrie struct firmware_version firmware; 27149588917SMarek Vasut enum ili2xxx_model model; 2725c6a7a62SOlivier Sobrie int error; 2735c6a7a62SOlivier Sobrie 27449588917SMarek Vasut model = (enum ili2xxx_model)id->driver_data; 27549588917SMarek Vasut 2765c6a7a62SOlivier Sobrie dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver"); 2775c6a7a62SOlivier Sobrie 2785c6a7a62SOlivier Sobrie if (client->irq <= 0) { 2795c6a7a62SOlivier Sobrie dev_err(dev, "No IRQ!\n"); 2805c6a7a62SOlivier Sobrie return -EINVAL; 2815c6a7a62SOlivier Sobrie } 2825c6a7a62SOlivier Sobrie 283201f3c80SMarek Vasut reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 284201f3c80SMarek Vasut if (IS_ERR(reset_gpio)) 285201f3c80SMarek Vasut return PTR_ERR(reset_gpio); 286201f3c80SMarek Vasut 287201f3c80SMarek Vasut if (reset_gpio) { 288201f3c80SMarek Vasut error = devm_add_action_or_reset(dev, ili210x_power_down, 289201f3c80SMarek Vasut reset_gpio); 290201f3c80SMarek Vasut if (error) 291201f3c80SMarek Vasut return error; 292201f3c80SMarek Vasut 293201f3c80SMarek Vasut usleep_range(50, 100); 294201f3c80SMarek Vasut gpiod_set_value_cansleep(reset_gpio, 0); 295201f3c80SMarek Vasut msleep(100); 296201f3c80SMarek Vasut } 297201f3c80SMarek Vasut 29812294577SMarek Vasut priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 29912294577SMarek Vasut if (!priv) 30012294577SMarek Vasut return -ENOMEM; 30112294577SMarek Vasut 30212294577SMarek Vasut input = devm_input_allocate_device(dev); 30312294577SMarek Vasut if (!input) 30412294577SMarek Vasut return -ENOMEM; 30512294577SMarek Vasut 30612294577SMarek Vasut priv->client = client; 30712294577SMarek Vasut priv->input = input; 30812294577SMarek Vasut priv->poll_period = DEFAULT_POLL_PERIOD; 30912294577SMarek Vasut INIT_DELAYED_WORK(&priv->dwork, ili210x_work); 31012294577SMarek Vasut priv->reset_gpio = reset_gpio; 31149588917SMarek Vasut priv->model = model; 31249588917SMarek Vasut if (model == MODEL_ILI210X) 31349588917SMarek Vasut priv->max_touches = ILI210X_TOUCHES; 31449588917SMarek Vasut if (model == MODEL_ILI251X) 31549588917SMarek Vasut priv->max_touches = ILI251X_TOUCHES; 31612294577SMarek Vasut 31712294577SMarek Vasut i2c_set_clientdata(client, priv); 31812294577SMarek Vasut 3195c6a7a62SOlivier Sobrie /* Get firmware version */ 3205c6a7a62SOlivier Sobrie error = ili210x_read_reg(client, REG_FIRMWARE_VERSION, 3215c6a7a62SOlivier Sobrie &firmware, sizeof(firmware)); 3225c6a7a62SOlivier Sobrie if (error) { 3235c6a7a62SOlivier Sobrie dev_err(dev, "Failed to get firmware version, err: %d\n", 3245c6a7a62SOlivier Sobrie error); 3255c6a7a62SOlivier Sobrie return error; 3265c6a7a62SOlivier Sobrie } 3275c6a7a62SOlivier Sobrie 3285c6a7a62SOlivier Sobrie /* Setup input device */ 3295c6a7a62SOlivier Sobrie input->name = "ILI210x Touchscreen"; 3305c6a7a62SOlivier Sobrie input->id.bustype = BUS_I2C; 3315c6a7a62SOlivier Sobrie input->dev.parent = dev; 3325c6a7a62SOlivier Sobrie 3335c6a7a62SOlivier Sobrie /* Multi touch */ 334f67cc3e9SMarek Vasut input_set_abs_params(input, ABS_MT_POSITION_X, 0, 0xffff, 0, 0); 335f67cc3e9SMarek Vasut input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 0xffff, 0, 0); 336f67cc3e9SMarek Vasut touchscreen_parse_properties(input, true, &priv->prop); 337f67cc3e9SMarek Vasut input_mt_init_slots(input, priv->max_touches, INPUT_MT_DIRECT); 3385c6a7a62SOlivier Sobrie 3391bdec5d9SMarek Vasut error = devm_add_action(dev, ili210x_cancel_work, priv); 3401bdec5d9SMarek Vasut if (error) 3411bdec5d9SMarek Vasut return error; 3421bdec5d9SMarek Vasut 3431bdec5d9SMarek Vasut error = devm_request_irq(dev, client->irq, ili210x_irq, 0, 3445c6a7a62SOlivier Sobrie client->name, priv); 3455c6a7a62SOlivier Sobrie if (error) { 3465c6a7a62SOlivier Sobrie dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", 3475c6a7a62SOlivier Sobrie error); 3481bdec5d9SMarek Vasut return error; 3495c6a7a62SOlivier Sobrie } 3505c6a7a62SOlivier Sobrie 351576057bfSDmitry Torokhov error = devm_device_add_group(dev, &ili210x_attr_group); 3525c6a7a62SOlivier Sobrie if (error) { 3535c6a7a62SOlivier Sobrie dev_err(dev, "Unable to create sysfs attributes, err: %d\n", 3545c6a7a62SOlivier Sobrie error); 3551bdec5d9SMarek Vasut return error; 3565c6a7a62SOlivier Sobrie } 3575c6a7a62SOlivier Sobrie 3585c6a7a62SOlivier Sobrie error = input_register_device(priv->input); 3595c6a7a62SOlivier Sobrie if (error) { 360971bd8faSMasanari Iida dev_err(dev, "Cannot register input device, err: %d\n", error); 361576057bfSDmitry Torokhov return error; 3625c6a7a62SOlivier Sobrie } 3635c6a7a62SOlivier Sobrie 364d7ddf154SGuenter Roeck device_init_wakeup(dev, 1); 3655c6a7a62SOlivier Sobrie 3665c6a7a62SOlivier Sobrie dev_dbg(dev, 3675c6a7a62SOlivier Sobrie "ILI210x initialized (IRQ: %d), firmware version %d.%d.%d", 3685c6a7a62SOlivier Sobrie client->irq, firmware.id, firmware.major, firmware.minor); 3695c6a7a62SOlivier Sobrie 3705c6a7a62SOlivier Sobrie return 0; 3715c6a7a62SOlivier Sobrie } 3725c6a7a62SOlivier Sobrie 37302b6a58bSJingoo Han static int __maybe_unused ili210x_i2c_suspend(struct device *dev) 3745c6a7a62SOlivier Sobrie { 3755c6a7a62SOlivier Sobrie struct i2c_client *client = to_i2c_client(dev); 3765c6a7a62SOlivier Sobrie 3775c6a7a62SOlivier Sobrie if (device_may_wakeup(&client->dev)) 3785c6a7a62SOlivier Sobrie enable_irq_wake(client->irq); 3795c6a7a62SOlivier Sobrie 3805c6a7a62SOlivier Sobrie return 0; 3815c6a7a62SOlivier Sobrie } 3825c6a7a62SOlivier Sobrie 38302b6a58bSJingoo Han static int __maybe_unused ili210x_i2c_resume(struct device *dev) 3845c6a7a62SOlivier Sobrie { 3855c6a7a62SOlivier Sobrie struct i2c_client *client = to_i2c_client(dev); 3865c6a7a62SOlivier Sobrie 3875c6a7a62SOlivier Sobrie if (device_may_wakeup(&client->dev)) 3885c6a7a62SOlivier Sobrie disable_irq_wake(client->irq); 3895c6a7a62SOlivier Sobrie 3905c6a7a62SOlivier Sobrie return 0; 3915c6a7a62SOlivier Sobrie } 3925c6a7a62SOlivier Sobrie 3935c6a7a62SOlivier Sobrie static SIMPLE_DEV_PM_OPS(ili210x_i2c_pm, 3945c6a7a62SOlivier Sobrie ili210x_i2c_suspend, ili210x_i2c_resume); 3955c6a7a62SOlivier Sobrie 3965c6a7a62SOlivier Sobrie static const struct i2c_device_id ili210x_i2c_id[] = { 39749588917SMarek Vasut { "ili210x", MODEL_ILI210X }, 39849588917SMarek Vasut { "ili251x", MODEL_ILI251X }, 3995c6a7a62SOlivier Sobrie { } 4005c6a7a62SOlivier Sobrie }; 4015c6a7a62SOlivier Sobrie MODULE_DEVICE_TABLE(i2c, ili210x_i2c_id); 4025c6a7a62SOlivier Sobrie 403c5d0e4b5SMarek Vasut static const struct of_device_id ili210x_dt_ids[] = { 40449588917SMarek Vasut { .compatible = "ilitek,ili210x", .data = (void *)MODEL_ILI210X }, 40549588917SMarek Vasut { .compatible = "ilitek,ili251x", .data = (void *)MODEL_ILI251X }, 406c5d0e4b5SMarek Vasut { }, 407c5d0e4b5SMarek Vasut }; 408c5d0e4b5SMarek Vasut MODULE_DEVICE_TABLE(of, ili210x_dt_ids); 409c5d0e4b5SMarek Vasut 4105c6a7a62SOlivier Sobrie static struct i2c_driver ili210x_ts_driver = { 4115c6a7a62SOlivier Sobrie .driver = { 4125c6a7a62SOlivier Sobrie .name = "ili210x_i2c", 4135c6a7a62SOlivier Sobrie .pm = &ili210x_i2c_pm, 414c5d0e4b5SMarek Vasut .of_match_table = ili210x_dt_ids, 4155c6a7a62SOlivier Sobrie }, 4165c6a7a62SOlivier Sobrie .id_table = ili210x_i2c_id, 4175c6a7a62SOlivier Sobrie .probe = ili210x_i2c_probe, 4185c6a7a62SOlivier Sobrie }; 4195c6a7a62SOlivier Sobrie 4205c6a7a62SOlivier Sobrie module_i2c_driver(ili210x_ts_driver); 4215c6a7a62SOlivier Sobrie 4225c6a7a62SOlivier Sobrie MODULE_AUTHOR("Olivier Sobrie <olivier@sobrie.be>"); 4235c6a7a62SOlivier Sobrie MODULE_DESCRIPTION("ILI210X I2C Touchscreen Driver"); 4245c6a7a62SOlivier Sobrie MODULE_LICENSE("GPL"); 425