^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Driver for ChipOne icn8318 i2c touchscreen controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2015 Red Hat Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Red Hat authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Hans de Goede <hdegoede@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/input/mt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/input/touchscreen.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define ICN8318_REG_POWER 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define ICN8318_REG_TOUCHDATA 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define ICN8318_POWER_ACTIVE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define ICN8318_POWER_MONITOR 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define ICN8318_POWER_HIBERNATE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define ICN8318_MAX_TOUCHES 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct icn8318_touch {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) __u8 slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) __be16 x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) __be16 y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) __u8 pressure; /* Seems more like finger width then pressure really */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __u8 event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* The difference between 2 and 3 is unclear */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define ICN8318_EVENT_NO_DATA 1 /* No finger seen yet since wakeup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define ICN8318_EVENT_UPDATE1 2 /* New or updated coordinates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define ICN8318_EVENT_UPDATE2 3 /* New or updated coordinates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define ICN8318_EVENT_END 4 /* Finger lifted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct icn8318_touch_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) __u8 softbutton;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) __u8 touch_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct icn8318_touch touches[ICN8318_MAX_TOUCHES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct icn8318_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct gpio_desc *wake_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct touchscreen_properties prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static int icn8318_read_touch_data(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct icn8318_touch_data *touch_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u8 reg = ICN8318_REG_TOUCHDATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct i2c_msg msg[2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .addr = client->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .len = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .buf = ®
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .addr = client->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .flags = I2C_M_RD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .len = sizeof(struct icn8318_touch_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .buf = (u8 *)touch_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return i2c_transfer(client->adapter, msg, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static inline bool icn8318_touch_active(u8 event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return (event == ICN8318_EVENT_UPDATE1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) (event == ICN8318_EVENT_UPDATE2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static irqreturn_t icn8318_irq(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct icn8318_data *data = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct device *dev = &data->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct icn8318_touch_data touch_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ret = icn8318_read_touch_data(data->client, &touch_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) dev_err(dev, "Error reading touch data: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (touch_data.softbutton) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * Other data is invalid when a softbutton is pressed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * This needs some extra devicetree bindings to map the icn8318
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * softbutton codes to evdev codes. Currently no known devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * use this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (touch_data.touch_count > ICN8318_MAX_TOUCHES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) dev_warn(dev, "Too much touches %d > %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) touch_data.touch_count, ICN8318_MAX_TOUCHES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) touch_data.touch_count = ICN8318_MAX_TOUCHES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) for (i = 0; i < touch_data.touch_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct icn8318_touch *touch = &touch_data.touches[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) bool act = icn8318_touch_active(touch->event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) input_mt_slot(data->input, touch->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) input_mt_report_slot_state(data->input, MT_TOOL_FINGER, act);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (!act)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) touchscreen_report_pos(data->input, &data->prop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) be16_to_cpu(touch->x),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) be16_to_cpu(touch->y), true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) input_mt_sync_frame(data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) input_sync(data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static int icn8318_start(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct icn8318_data *data = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) enable_irq(data->client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) gpiod_set_value_cansleep(data->wake_gpio, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static void icn8318_stop(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct icn8318_data *data = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) disable_irq(data->client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) i2c_smbus_write_byte_data(data->client, ICN8318_REG_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ICN8318_POWER_HIBERNATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) gpiod_set_value_cansleep(data->wake_gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static int icn8318_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct icn8318_data *data = i2c_get_clientdata(to_i2c_client(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) mutex_lock(&data->input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (data->input->users)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) icn8318_stop(data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) mutex_unlock(&data->input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int icn8318_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct icn8318_data *data = i2c_get_clientdata(to_i2c_client(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) mutex_lock(&data->input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (data->input->users)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) icn8318_start(data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) mutex_unlock(&data->input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static SIMPLE_DEV_PM_OPS(icn8318_pm_ops, icn8318_suspend, icn8318_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static int icn8318_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct icn8318_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (!client->irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) dev_err(dev, "Error no irq specified\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (IS_ERR(data->wake_gpio)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) error = PTR_ERR(data->wake_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (error != -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) dev_err(dev, "Error getting wake gpio: %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) input = devm_input_allocate_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) input->name = client->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) input->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) input->open = icn8318_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) input->close = icn8318_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) input->dev.parent = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) touchscreen_parse_properties(input, true, &data->prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) dev_err(dev, "Error touchscreen-size-x and/or -y missing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) error = input_mt_init_slots(input, ICN8318_MAX_TOUCHES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) data->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) data->input = input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) input_set_drvdata(input, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) error = devm_request_threaded_irq(dev, client->irq, NULL, icn8318_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) IRQF_ONESHOT, client->name, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dev_err(dev, "Error requesting irq: %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /* Stop device till opened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) icn8318_stop(data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) error = input_register_device(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) i2c_set_clientdata(client, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static const struct of_device_id icn8318_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) { .compatible = "chipone,icn8318" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) MODULE_DEVICE_TABLE(of, icn8318_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* This is useless for OF-enabled devices, but it is needed by I2C subsystem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static const struct i2c_device_id icn8318_i2c_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) MODULE_DEVICE_TABLE(i2c, icn8318_i2c_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static struct i2c_driver icn8318_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) .name = "chipone_icn8318",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) .pm = &icn8318_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) .of_match_table = icn8318_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) .probe = icn8318_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) .id_table = icn8318_i2c_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) module_i2c_driver(icn8318_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) MODULE_DESCRIPTION("ChipOne icn8318 I2C Touchscreen Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) MODULE_LICENSE("GPL");