Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Driver for EETI eGalax Multiple Touch Controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2011 Freescale Semiconductor, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * based on max11801_ts.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /* EETI eGalax serial touch screen controller is a I2C based multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * touch screen controller, it supports 5 point multiple touch. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /* TODO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)   - auto idle mode support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^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/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/input/mt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/of_gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Mouse Mode: some panel may configure the controller to mouse mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * which can only report one point at a given time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * This driver will ignore events in this mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define REPORT_MODE_MOUSE		0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Vendor Mode: this mode is used to transfer some vendor specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * This driver will ignore events in this mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define REPORT_MODE_VENDOR		0x3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* Multiple Touch Mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define REPORT_MODE_MTTOUCH		0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define MAX_SUPPORT_POINTS		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define EVENT_VALID_OFFSET	7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define EVENT_VALID_MASK	(0x1 << EVENT_VALID_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define EVENT_ID_OFFSET		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define EVENT_ID_MASK		(0xf << EVENT_ID_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define EVENT_IN_RANGE		(0x1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define EVENT_DOWN_UP		(0X1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define MAX_I2C_DATA_LEN	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define EGALAX_MAX_X	32760
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define EGALAX_MAX_Y	32760
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define EGALAX_MAX_TRIES 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) struct egalax_ts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct i2c_client		*client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct input_dev		*input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	struct egalax_ts *ts = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	struct input_dev *input_dev = ts->input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u8 buf[MAX_I2C_DATA_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	int id, ret, x, y, z;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	int tries = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	bool down, valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u8 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	} while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	if (buf[0] != REPORT_MODE_MTTOUCH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		/* ignore mouse events and vendor events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	state = buf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	x = (buf[3] << 8) | buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	y = (buf[5] << 8) | buf[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	z = (buf[7] << 8) | buf[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	valid = state & EVENT_VALID_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	id = (state & EVENT_ID_MASK) >> EVENT_ID_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	down = state & EVENT_DOWN_UP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	if (!valid || id > MAX_SUPPORT_POINTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		dev_dbg(&client->dev, "point invalid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	input_mt_slot(input_dev, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		down ? "down" : "up", id, x, y, z);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (down) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		input_report_abs(input_dev, ABS_MT_POSITION_X, x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		input_report_abs(input_dev, ABS_MT_PRESSURE, z);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	input_mt_report_pointer_emulation(input_dev, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	input_sync(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /* wake up controller by an falling edge of interrupt gpio.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static int egalax_wake_up_device(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	struct device_node *np = client->dev.of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	int gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	gpio = of_get_named_gpio(np, "wakeup-gpios", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (!gpio_is_valid(gpio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	ret = gpio_request(gpio, "egalax_irq");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		dev_err(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			"request gpio failed, cannot wake up controller: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		return ret;
^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) 	/* wake up controller via an falling edge on IRQ gpio. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	gpio_direction_output(gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	gpio_set_value(gpio, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	/* controller should be waken up, return irq.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	gpio_direction_input(gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	gpio_free(gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static int egalax_firmware_version(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		return ret;
^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 egalax_ts_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			   const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	struct egalax_ts *ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (!ts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		dev_err(&client->dev, "Failed to allocate memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	input_dev = devm_input_allocate_device(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (!input_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		dev_err(&client->dev, "Failed to allocate memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	ts->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	ts->input_dev = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	/* controller may be in sleep, wake it up. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	error = egalax_wake_up_device(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		dev_err(&client->dev, "Failed to wake up the controller\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	error = egalax_firmware_version(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (error < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		dev_err(&client->dev, "Failed to read firmware version\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	input_dev->name = "EETI eGalax Touch Screen";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	input_dev->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	__set_bit(EV_ABS, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	__set_bit(EV_KEY, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	__set_bit(BTN_TOUCH, input_dev->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	input_set_abs_params(input_dev, ABS_X, 0, EGALAX_MAX_X, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	input_set_abs_params(input_dev, ABS_Y, 0, EGALAX_MAX_Y, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	input_set_abs_params(input_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			     ABS_MT_POSITION_X, 0, EGALAX_MAX_X, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	input_set_abs_params(input_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			     ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					  egalax_ts_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 					  IRQF_TRIGGER_LOW | IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 					  "egalax_ts", ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (error < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		dev_err(&client->dev, "Failed to register interrupt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	error = input_register_device(ts->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static const struct i2c_device_id egalax_ts_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	{ "egalax_ts", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) MODULE_DEVICE_TABLE(i2c, egalax_ts_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static int __maybe_unused egalax_ts_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	static const u8 suspend_cmd[MAX_I2C_DATA_LEN] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	if (device_may_wakeup(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		return enable_irq_wake(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	return ret > 0 ? 0 : ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static int __maybe_unused egalax_ts_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (device_may_wakeup(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		return disable_irq_wake(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	return egalax_wake_up_device(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static const struct of_device_id egalax_ts_dt_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	{ .compatible = "eeti,egalax_ts" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	{ /* sentinel */ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) MODULE_DEVICE_TABLE(of, egalax_ts_dt_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static struct i2c_driver egalax_ts_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		.name	= "egalax_ts",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		.pm	= &egalax_ts_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		.of_match_table	= egalax_ts_dt_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	.id_table	= egalax_ts_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	.probe		= egalax_ts_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) module_i2c_driver(egalax_ts_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) MODULE_AUTHOR("Freescale Semiconductor, Inc.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) MODULE_DESCRIPTION("Touchscreen driver for EETI eGalax touch controller");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) MODULE_LICENSE("GPL");