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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Driver for AUO in-cell touchscreens
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * loosely based on auo_touch.c from Dell Streak vendor-kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Copyright (c) 2008 QUALCOMM Incorporated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Copyright (c) 2008 QUALCOMM USA, INC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/delay.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/input/auo-pixcir-ts.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/of_gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * Coordinate calculation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * X1 = X1_LSB + X1_MSB*256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Y1 = Y1_LSB + Y1_MSB*256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * X2 = X2_LSB + X2_MSB*256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Y2 = Y2_LSB + Y2_MSB*256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define AUO_PIXCIR_REG_X1_LSB		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define AUO_PIXCIR_REG_X1_MSB		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define AUO_PIXCIR_REG_Y1_LSB		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define AUO_PIXCIR_REG_Y1_MSB		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define AUO_PIXCIR_REG_X2_LSB		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define AUO_PIXCIR_REG_X2_MSB		0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define AUO_PIXCIR_REG_Y2_LSB		0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define AUO_PIXCIR_REG_Y2_MSB		0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define AUO_PIXCIR_REG_STRENGTH		0x0d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define AUO_PIXCIR_REG_STRENGTH_X1_LSB	0x0e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define AUO_PIXCIR_REG_STRENGTH_X1_MSB	0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define AUO_PIXCIR_REG_RAW_DATA_X	0x2b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define AUO_PIXCIR_REG_RAW_DATA_Y	0x4f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define AUO_PIXCIR_REG_X_SENSITIVITY	0x6f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define AUO_PIXCIR_REG_Y_SENSITIVITY	0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define AUO_PIXCIR_REG_INT_SETTING	0x71
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define AUO_PIXCIR_REG_INT_WIDTH	0x72
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define AUO_PIXCIR_REG_POWER_MODE	0x73
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define AUO_PIXCIR_REG_VERSION		0x77
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define AUO_PIXCIR_REG_CALIBRATE	0x78
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define AUO_PIXCIR_REG_TOUCHAREA_X1	0x1e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define AUO_PIXCIR_REG_TOUCHAREA_Y1	0x1f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define AUO_PIXCIR_REG_TOUCHAREA_X2	0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define AUO_PIXCIR_REG_TOUCHAREA_Y2	0x21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define AUO_PIXCIR_REG_EEPROM_CALIB_X	0x42
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define AUO_PIXCIR_REG_EEPROM_CALIB_Y	0xad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define AUO_PIXCIR_INT_TPNUM_MASK	0xe0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define AUO_PIXCIR_INT_TPNUM_SHIFT	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define AUO_PIXCIR_INT_RELEASE		(1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define AUO_PIXCIR_INT_ENABLE		(1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define AUO_PIXCIR_INT_POL_HIGH		(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define AUO_PIXCIR_INT_MODE_MASK	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * Power modes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * active:	scan speed 60Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * sleep:	scan speed 10Hz can be auto-activated, wakeup on 1st touch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * deep sleep:	scan speed 1Hz can only be entered or left manually.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define AUO_PIXCIR_POWER_ACTIVE		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define AUO_PIXCIR_POWER_SLEEP		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define AUO_PIXCIR_POWER_DEEP_SLEEP	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define AUO_PIXCIR_POWER_MASK		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define AUO_PIXCIR_POWER_ALLOW_SLEEP	(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #define AUO_PIXCIR_POWER_IDLE_TIME(ms)	((ms & 0xf) << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #define AUO_PIXCIR_CALIBRATE		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define AUO_PIXCIR_EEPROM_CALIB_X_LEN	62
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define AUO_PIXCIR_EEPROM_CALIB_Y_LEN	36
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define AUO_PIXCIR_RAW_DATA_X_LEN	18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define AUO_PIXCIR_RAW_DATA_Y_LEN	11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define AUO_PIXCIR_STRENGTH_ENABLE	(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /* Touchscreen absolute values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define AUO_PIXCIR_REPORT_POINTS	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define AUO_PIXCIR_MAX_AREA		0xff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define AUO_PIXCIR_PENUP_TIMEOUT_MS	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct auo_pixcir_ts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct i2c_client	*client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct input_dev	*input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	const struct auo_pixcir_ts_platdata *pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	char			phys[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/* special handling for touch_indicate interupt mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	bool			touch_ind_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	wait_queue_head_t	wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	bool			stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct auo_point_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	int	coord_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	int	coord_y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	int	area_major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	int	area_minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	int	orientation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				   struct auo_point_t *point)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	uint8_t raw_coord[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	uint8_t raw_area[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	/* touch coordinates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_X1_LSB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 					    8, raw_coord);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		dev_err(&client->dev, "failed to read coordinate, %d\n", 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) 	/* touch area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_TOUCHAREA_X1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 					    4, raw_area);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		dev_err(&client->dev, "could not read touch area, %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		point[i].coord_x =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			raw_coord[4 * i + 1] << 8 | raw_coord[4 * i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		point[i].coord_y =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		if (point[i].coord_x > pdata->x_max ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		    point[i].coord_y > pdata->y_max) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				point[i].coord_x, point[i].coord_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			point[i].coord_x = point[i].coord_y = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		/* determine touch major, minor and orientation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		point[i].area_major = max(raw_area[2 * i], raw_area[2 * i + 1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		point[i].area_minor = min(raw_area[2 * i], raw_area[2 * i + 1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		point[i].orientation = raw_area[2 * i] > raw_area[2 * i + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct auo_pixcir_ts *ts = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	int fingers = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	int abs = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	while (!ts->stopped) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		/* check for up event in touch touch_ind_mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		if (ts->touch_ind_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			if (gpio_get_value(pdata->gpio_int) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				input_mt_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				input_report_key(ts->input, BTN_TOUCH, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 				break;
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		ret = auo_pixcir_collect_data(ts, point);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			/* we want to loop only in touch_ind_mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			if (!ts->touch_ind_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			wait_event_timeout(ts->wait, ts->stopped,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 			continue;
^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) 		for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			if (point[i].coord_x > 0 || point[i].coord_y > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				input_report_abs(ts->input, ABS_MT_POSITION_X,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 						 point[i].coord_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 				input_report_abs(ts->input, ABS_MT_POSITION_Y,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 						 point[i].coord_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 				input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 						 point[i].area_major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 				input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 						 point[i].area_minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 				input_report_abs(ts->input, ABS_MT_ORIENTATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 						 point[i].orientation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				input_mt_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 				/* use first finger as source for singletouch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 				if (fingers == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 					abs = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				/* number of touch points could also be queried
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				 * via i2c but would require an additional call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				fingers++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		input_report_key(ts->input, BTN_TOUCH, fingers > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		if (abs > -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			input_report_abs(ts->input, ABS_X, point[abs].coord_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			input_report_abs(ts->input, ABS_Y, point[abs].coord_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		/* we want to loop only in touch_ind_mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		if (!ts->touch_ind_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		wait_event_timeout(ts->wait, ts->stopped,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 				 msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  * Set the power mode of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  * Valid modes are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  * - AUO_PIXCIR_POWER_ACTIVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * - AUO_PIXCIR_POWER_DEEP_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_POWER_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		dev_err(&client->dev, "unable to read reg %Xh, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 			AUO_PIXCIR_REG_POWER_MODE, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	ret &= ~AUO_PIXCIR_POWER_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	ret |= mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_POWER_MODE, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		dev_err(&client->dev, "unable to write reg %Xh, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			AUO_PIXCIR_REG_POWER_MODE, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static int auo_pixcir_int_config(struct auo_pixcir_ts *ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 					   int int_setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		dev_err(&client->dev, "unable to read reg %Xh, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			AUO_PIXCIR_REG_INT_SETTING, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	ret &= ~AUO_PIXCIR_INT_MODE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	ret |= int_setting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	ret |= AUO_PIXCIR_INT_POL_HIGH; /* always use high for interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 					ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		dev_err(&client->dev, "unable to write reg %Xh, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			AUO_PIXCIR_REG_INT_SETTING, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /* control the generation of interrupts on the device side */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static int auo_pixcir_int_toggle(struct auo_pixcir_ts *ts, bool enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		dev_err(&client->dev, "unable to read reg %Xh, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			AUO_PIXCIR_REG_INT_SETTING, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	if (enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		ret |= AUO_PIXCIR_INT_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		ret &= ~AUO_PIXCIR_INT_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 					ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		dev_err(&client->dev, "unable to write reg %Xh, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			AUO_PIXCIR_REG_INT_SETTING, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static int auo_pixcir_start(struct auo_pixcir_ts *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_ACTIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		dev_err(&client->dev, "could not set power mode, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	ts->stopped = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	mb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	enable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	ret = auo_pixcir_int_toggle(ts, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		dev_err(&client->dev, "could not enable interrupt, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		disable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) static int auo_pixcir_stop(struct auo_pixcir_ts *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	struct i2c_client *client = ts->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	ret = auo_pixcir_int_toggle(ts, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		dev_err(&client->dev, "could not disable interrupt, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	/* disable receiving of interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	disable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	ts->stopped = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	mb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	wake_up(&ts->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	return auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_DEEP_SLEEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static int auo_pixcir_input_open(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	struct auo_pixcir_ts *ts = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	return auo_pixcir_start(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) static void auo_pixcir_input_close(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	struct auo_pixcir_ts *ts = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	auo_pixcir_stop(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) static int __maybe_unused auo_pixcir_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	struct input_dev *input = ts->input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	mutex_lock(&input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	/* when configured as wakeup source, device should always wake system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	 * therefore start device if necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	if (device_may_wakeup(&client->dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		/* need to start device if not open, to be wakeup source */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		if (!input->users) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 			ret = auo_pixcir_start(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 				goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		enable_irq_wake(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	} else if (input->users) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		ret = auo_pixcir_stop(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	mutex_unlock(&input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) static int __maybe_unused auo_pixcir_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	struct input_dev *input = ts->input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	mutex_lock(&input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	if (device_may_wakeup(&client->dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		disable_irq_wake(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		/* need to stop device if it was not open on suspend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		if (!input->users) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			ret = auo_pixcir_stop(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 			if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 				goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		/* device wakes automatically from SLEEP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	} else if (input->users) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		ret = auo_pixcir_start(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	mutex_unlock(&input->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 			 auo_pixcir_suspend, auo_pixcir_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	struct auo_pixcir_ts_platdata *pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	struct device_node *np = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		return ERR_PTR(-ENOENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	if (!pdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	pdata->gpio_int = of_get_gpio(np, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	if (!gpio_is_valid(pdata->gpio_int)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 		dev_err(dev, "failed to get interrupt gpio\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	pdata->gpio_rst = of_get_gpio(np, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	if (!gpio_is_valid(pdata->gpio_rst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 		dev_err(dev, "failed to get reset gpio\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	if (of_property_read_u32(np, "x-size", &pdata->x_max)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		dev_err(dev, "failed to get x-size property\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		dev_err(dev, "failed to get y-size property\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	/* default to asserting the interrupt when the screen is touched */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	return pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) static void auo_pixcir_reset(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	struct auo_pixcir_ts *ts = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	gpio_set_value(ts->pdata->gpio_rst, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) static int auo_pixcir_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 			    const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	const struct auo_pixcir_ts_platdata *pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	struct auo_pixcir_ts *ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	int version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	pdata = dev_get_platdata(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	if (!pdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 		pdata = auo_pixcir_parse_dt(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		if (IS_ERR(pdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 			return PTR_ERR(pdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	ts = devm_kzalloc(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 			  sizeof(struct auo_pixcir_ts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	if (!ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	input_dev = devm_input_allocate_device(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	if (!input_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		dev_err(&client->dev, "could not allocate input device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	ts->pdata = pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	ts->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	ts->input = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	ts->touch_ind_mode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	ts->stopped = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	init_waitqueue_head(&ts->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	snprintf(ts->phys, sizeof(ts->phys),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 		 "%s/input0", dev_name(&client->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	input_dev->name = "AUO-Pixcir touchscreen";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	input_dev->phys = ts->phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	input_dev->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	input_dev->open = auo_pixcir_input_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	input_dev->close = auo_pixcir_input_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	__set_bit(EV_ABS, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	__set_bit(EV_KEY, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	__set_bit(BTN_TOUCH, input_dev->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	/* For single touch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	/* For multi touch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 			     pdata->x_max, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 			     pdata->y_max, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 			     AUO_PIXCIR_MAX_AREA, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 			     AUO_PIXCIR_MAX_AREA, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	input_set_drvdata(ts->input, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	error = devm_gpio_request_one(&client->dev, pdata->gpio_int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 				      GPIOF_DIR_IN, "auo_pixcir_ts_int");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 		dev_err(&client->dev, "request of gpio %d failed, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 			pdata->gpio_int, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	error = devm_gpio_request_one(&client->dev, pdata->gpio_rst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 				      GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 				      "auo_pixcir_ts_rst");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		dev_err(&client->dev, "request of gpio %d failed, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 			pdata->gpio_rst, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		dev_err(&client->dev, "failed to register reset action, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 			error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	msleep(200);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	version = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	if (version < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		error = version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	dev_info(&client->dev, "firmware version 0x%X\n", version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	error = auo_pixcir_int_config(ts, pdata->int_setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	error = devm_request_threaded_irq(&client->dev, client->irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 					  NULL, auo_pixcir_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 					  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 					  input_dev->name, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		dev_err(&client->dev, "irq %d requested failed, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 			client->irq, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	/* stop device and put it into deep sleep until it is opened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	error = auo_pixcir_stop(ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	error = input_register_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 		dev_err(&client->dev, "could not register input device, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 			error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	i2c_set_clientdata(client, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) static const struct i2c_device_id auo_pixcir_idtable[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	{ "auo_pixcir_ts", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) static const struct of_device_id auo_pixcir_ts_dt_idtable[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	{ .compatible = "auo,auo_pixcir_ts" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) MODULE_DEVICE_TABLE(of, auo_pixcir_ts_dt_idtable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) static struct i2c_driver auo_pixcir_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 		.name	= "auo_pixcir_ts",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		.pm	= &auo_pixcir_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 		.of_match_table	= of_match_ptr(auo_pixcir_ts_dt_idtable),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	.probe		= auo_pixcir_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	.id_table	= auo_pixcir_idtable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) module_i2c_driver(auo_pixcir_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");