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-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* -------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2014-2015, Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Derived from:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  gslX68X.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Copyright (C) 2010-2015, Shanghai Sileadinc Co.Ltd
^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)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/acpi.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/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/firmware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/input/mt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/input/touchscreen.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/pm_runtime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/regulator/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define SILEAD_TS_NAME		"silead_ts"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define SILEAD_REG_RESET	0xE0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define SILEAD_REG_DATA		0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define SILEAD_REG_TOUCH_NR	0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define SILEAD_REG_POWER	0xBC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define SILEAD_REG_CLOCK	0xE4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define SILEAD_REG_STATUS	0xB0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define SILEAD_REG_ID		0xFC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define SILEAD_REG_MEM_CHECK	0xB0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define SILEAD_STATUS_OK	0x5A5A5A5A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define SILEAD_TS_DATA_LEN	44
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define SILEAD_CLOCK		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define SILEAD_CMD_RESET	0x88
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define SILEAD_CMD_START	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define SILEAD_POINT_DATA_LEN	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define SILEAD_POINT_Y_OFF      0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define SILEAD_POINT_Y_MSB_OFF	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define SILEAD_POINT_X_OFF	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define SILEAD_POINT_X_MSB_OFF	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define SILEAD_EXTRA_DATA_MASK	0xF0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define SILEAD_CMD_SLEEP_MIN	10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define SILEAD_CMD_SLEEP_MAX	20000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define SILEAD_POWER_SLEEP	20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define SILEAD_STARTUP_SLEEP	30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define SILEAD_MAX_FINGERS	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) enum silead_ts_power {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	SILEAD_POWER_ON  = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	SILEAD_POWER_OFF = 0
^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) struct silead_ts_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct gpio_desc *gpio_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct regulator_bulk_data regulators[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	char fw_name[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct touchscreen_properties prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u32 max_fingers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u32 chip_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct input_mt_pos pos[SILEAD_MAX_FINGERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	int slots[SILEAD_MAX_FINGERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	int id[SILEAD_MAX_FINGERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) struct silead_fw_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static int silead_ts_request_input_dev(struct silead_ts_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct device *dev = &data->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	data->input = devm_input_allocate_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!data->input) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		dev_err(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			"Failed to allocate input device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	input_set_abs_params(data->input, ABS_MT_POSITION_X, 0, 4095, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0, 4095, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	touchscreen_parse_properties(data->input, true, &data->prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	input_mt_init_slots(data->input, data->max_fingers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			    INPUT_MT_TRACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (device_property_read_bool(dev, "silead,home-button"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		input_set_capability(data->input, EV_KEY, KEY_LEFTMETA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	data->input->name = SILEAD_TS_NAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	data->input->phys = "input/ts";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	data->input->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	error = input_register_device(data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		dev_err(dev, "Failed to register input device: %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static void silead_ts_set_power(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 				enum silead_ts_power state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct silead_ts_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (data->gpio_power) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		gpiod_set_value_cansleep(data->gpio_power, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		msleep(SILEAD_POWER_SLEEP);
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static void silead_ts_read_data(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct silead_ts_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	struct input_dev *input = data->input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	u8 *bufp, buf[SILEAD_TS_DATA_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int touch_nr, softbutton, error, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	bool softbutton_pressed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 					      SILEAD_TS_DATA_LEN, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (error < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		dev_err(dev, "Data read error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (buf[0] > data->max_fingers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		dev_warn(dev, "More touches reported then supported %d > %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			 buf[0], data->max_fingers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		buf[0] = data->max_fingers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	touch_nr = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	bufp = buf + SILEAD_POINT_DATA_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	for (i = 0; i < buf[0]; i++, bufp += SILEAD_POINT_DATA_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		softbutton = (bufp[SILEAD_POINT_Y_MSB_OFF] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			      SILEAD_EXTRA_DATA_MASK) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		if (softbutton) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			 * For now only respond to softbutton == 0x01, some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 			 * tablets *without* a capacative button send 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			 * when crossing the edges of the screen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			if (softbutton == 0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				softbutton_pressed = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		 * Bits 4-7 are the touch id, note not all models have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		 * hardware touch ids so atm we don't use these.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		data->id[touch_nr] = (bufp[SILEAD_POINT_X_MSB_OFF] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 				      SILEAD_EXTRA_DATA_MASK) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		touch_nr++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	for (i = 0; i < touch_nr; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		input_mt_slot(input, data->slots[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		input_report_abs(input, ABS_MT_POSITION_X, data->pos[i].x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		input_report_abs(input, ABS_MT_POSITION_Y, data->pos[i].y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		dev_dbg(dev, "x=%d y=%d hw_id=%d sw_id=%d\n", data->pos[i].x,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			data->pos[i].y, data->id[i], data->slots[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	input_mt_sync_frame(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	input_report_key(input, KEY_LEFTMETA, softbutton_pressed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	input_sync(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static int silead_ts_init(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct silead_ts_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 					  SILEAD_CMD_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_TOUCH_NR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 					data->max_fingers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_CLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 					  SILEAD_CLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 					  SILEAD_CMD_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) i2c_write_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	dev_err(&client->dev, "Registers clear error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static int silead_ts_reset(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 					  SILEAD_CMD_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_CLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 					  SILEAD_CLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 					  SILEAD_CMD_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		goto i2c_write_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) i2c_write_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	dev_err(&client->dev, "Chip reset error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static int silead_ts_startup(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		dev_err(&client->dev, "Startup error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	msleep(SILEAD_STARTUP_SLEEP);
^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 silead_ts_load_fw(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	struct silead_ts_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	unsigned int fw_size, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	const struct firmware *fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	struct silead_fw_data *fw_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	dev_dbg(dev, "Firmware file name: %s", data->fw_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	error = firmware_request_platform(&fw, data->fw_name, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		dev_err(dev, "Firmware request error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	fw_size = fw->size / sizeof(*fw_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	fw_data = (struct silead_fw_data *)fw->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	for (i = 0; i < fw_size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		error = i2c_smbus_write_i2c_block_data(client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 						       fw_data[i].offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 						       4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 						       (u8 *)&fw_data[i].val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			dev_err(dev, "Firmware load error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		}
^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) 	release_firmware(fw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	return error ?: 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static u32 silead_ts_get_status(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	__le32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 					      sizeof(status), (u8 *)&status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	if (error < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		dev_err(&client->dev, "Status read error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	return le32_to_cpu(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) static int silead_ts_get_id(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	struct silead_ts_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	__le32 chip_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 					      sizeof(chip_id), (u8 *)&chip_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	data->chip_id = le32_to_cpu(chip_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) static int silead_ts_setup(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	u32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	 * Some buggy BIOS-es bring up the chip in a stuck state where it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	 * blocks the I2C bus. The following steps are necessary to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	 * unstuck the chip / bus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	 * 1. Turn off the Silead chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	 * 2. Try to do an I2C transfer with the chip, this will fail in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	 *    response to which the I2C-bus-driver will call:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	 *    i2c_recover_bus() which will unstuck the I2C-bus. Note the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	 *    unstuck-ing of the I2C bus only works if we first drop the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	 *    chip off the bus by turning it off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	 * 3. Turn the chip back on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	 * On the x86/ACPI systems were this problem is seen, step 1. and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	 * 3. require making ACPI calls and dealing with ACPI Power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	 * Resources. The workaround below runtime-suspends the chip to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	 * turn it off, leaving it up to the ACPI subsystem to deal with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	 * this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	if (device_property_read_bool(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 				      "silead,stuck-controller-bug")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		pm_runtime_set_active(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		pm_runtime_enable(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		pm_runtime_allow(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		pm_runtime_suspend(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		dev_warn(&client->dev, FW_BUG "Stuck I2C bus: please ignore the next 'controller timed out' error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		silead_ts_get_id(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		/* The forbid will also resume the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		pm_runtime_forbid(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		pm_runtime_disable(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	silead_ts_set_power(client, SILEAD_POWER_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	silead_ts_set_power(client, SILEAD_POWER_ON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	error = silead_ts_get_id(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		dev_err(&client->dev, "Chip ID read error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	error = silead_ts_init(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	error = silead_ts_reset(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	error = silead_ts_load_fw(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	error = silead_ts_startup(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	status = silead_ts_get_status(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	if (status != SILEAD_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		dev_err(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			"Initialization error, status: 0x%X\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	return 0;
^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) static irqreturn_t silead_ts_threaded_irq_handler(int irq, void *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	struct silead_ts_data *data = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	struct i2c_client *client = data->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	silead_ts_read_data(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static void silead_ts_read_props(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	struct silead_ts_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	error = device_property_read_u32(dev, "silead,max-fingers",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 					 &data->max_fingers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		dev_dbg(dev, "Max fingers read error %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		data->max_fingers = 5; /* Most devices handle up-to 5 fingers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	error = device_property_read_string(dev, "firmware-name", &str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		snprintf(data->fw_name, sizeof(data->fw_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 			 "silead/%s", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		dev_dbg(dev, "Firmware file name read error. Using default.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #ifdef CONFIG_ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 					 const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	const struct acpi_device_id *acpi_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	struct device *dev = &data->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	if (ACPI_HANDLE(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		if (!acpi_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 			return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		snprintf(data->fw_name, sizeof(data->fw_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 			 "silead/%s.fw", acpi_id->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		for (i = 0; i < strlen(data->fw_name); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 			data->fw_name[i] = tolower(data->fw_name[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		snprintf(data->fw_name, sizeof(data->fw_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			 "silead/%s.fw", id->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 					 const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	snprintf(data->fw_name, sizeof(data->fw_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		 "silead/%s.fw", id->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static void silead_disable_regulator(void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	struct silead_ts_data *data = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static int silead_ts_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			   const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	struct silead_ts_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	if (!i2c_check_functionality(client->adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 				     I2C_FUNC_I2C |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 				     I2C_FUNC_SMBUS_READ_I2C_BLOCK |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 				     I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		dev_err(dev, "I2C functionality check failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	i2c_set_clientdata(client, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	data->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	error = silead_ts_set_default_fw_name(data, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	silead_ts_read_props(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	/* We must have the IRQ provided by DT or ACPI subsytem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	if (client->irq <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	data->regulators[0].supply = "vddio";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	data->regulators[1].supply = "avdd";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 					data->regulators);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	 * Enable regulators at probe and disable them at remove, we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	 * to keep the chip powered otherwise it forgets its firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	error = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 				      data->regulators);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	error = devm_add_action_or_reset(dev, silead_disable_regulator, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	/* Power GPIO pin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	if (IS_ERR(data->gpio_power)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 		if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 			dev_err(dev, "Shutdown GPIO request failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 		return PTR_ERR(data->gpio_power);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	error = silead_ts_setup(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	error = silead_ts_request_input_dev(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	error = devm_request_threaded_irq(dev, client->irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 					  NULL, silead_ts_threaded_irq_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 					  IRQF_ONESHOT, client->name, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		if (error != -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 			dev_err(dev, "IRQ request failed %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) static int __maybe_unused silead_ts_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	disable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	silead_ts_set_power(client, SILEAD_POWER_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) static int __maybe_unused silead_ts_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	bool second_try = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	int error, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	silead_ts_set_power(client, SILEAD_POWER_ON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)  retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	error = silead_ts_reset(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	if (second_try) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		error = silead_ts_load_fw(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 		if (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 = silead_ts_startup(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	status = silead_ts_get_status(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	if (status != SILEAD_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 		if (!second_try) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 			second_try = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 			dev_dbg(dev, "Reloading firmware after unsuccessful resume\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 			goto retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		dev_err(dev, "Resume error, status: 0x%02x\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		return -ENODEV;
^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) 	enable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) static SIMPLE_DEV_PM_OPS(silead_ts_pm, silead_ts_suspend, silead_ts_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) static const struct i2c_device_id silead_ts_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	{ "gsl1680", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 	{ "gsl1688", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	{ "gsl3670", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	{ "gsl3675", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	{ "gsl3692", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	{ "mssl1680", 0 },
^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) MODULE_DEVICE_TABLE(i2c, silead_ts_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) #ifdef CONFIG_ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) static const struct acpi_device_id silead_ts_acpi_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	{ "GSL1680", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	{ "GSL1688", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	{ "GSL3670", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	{ "GSL3675", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	{ "GSL3692", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	{ "MSSL1680", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	{ "MSSL0001", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	{ "MSSL0002", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	{ "MSSL0017", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) static const struct of_device_id silead_ts_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	{ .compatible = "silead,gsl1680" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	{ .compatible = "silead,gsl1688" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	{ .compatible = "silead,gsl3670" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	{ .compatible = "silead,gsl3675" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	{ .compatible = "silead,gsl3692" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) MODULE_DEVICE_TABLE(of, silead_ts_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) static struct i2c_driver silead_ts_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	.probe = silead_ts_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	.id_table = silead_ts_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		.name = SILEAD_TS_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 		.acpi_match_table = ACPI_PTR(silead_ts_acpi_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		.of_match_table = of_match_ptr(silead_ts_of_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		.pm = &silead_ts_pm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) module_i2c_driver(silead_ts_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) MODULE_AUTHOR("Robert Dolca <robert.dolca@intel.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) MODULE_DESCRIPTION("Silead I2C touchscreen driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) MODULE_LICENSE("GPL");