From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=162.62.57.64 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796370551; b=ZttvYK/Gr5xarVp6LqMGnjYWh0/Or/wetlJRxYzndVbYSJ5xedUTsAT2fK79f95aTy/N WmxDMOsxySuHOxQgNvFHtwhotB7In53Wz6wcss/cieRaz15ybPPNJ0flzlBgc2Q4VU1Jb Uc3IHxGmgwmKVmuY2z0E9gSs9oAdtL67inXKbdjaYsKbcnjcuOTk/TokLdLjRH659IYkJ zBigneWYZWDLVtXBrBaG3/SBNczs0h5E6J1H3P7ZbC3ZPBJrtwnaU5DgN52N+uHjEN02O ZdpsAJoRKwajAyv2A740WTyXPF+c3kKPlqaQRoQCbxM2/k8ABF+3+yka45j0ramj0Pg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796370551; h=DMARC-Filter:DKIM-Signature:Received:X-QQ-mid:Message-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:From:To:Cc:Subject:Date:X-OQ-MSGID: MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To: References; bh=jZovu1caXRb4KwZYQYsH/JOktWEKC8UhmEQsNGE1zd8=; b=V23x5SUsw1o0lw8TNP0vXiqCdWE6Szgfv9yhLskX37TEug6lVgVWPySltLa2N8t3MyGU mRDCNEt19QgcxJz8YXCjMgB8sOjswxsXKA12YgFhLYmke7fnDaK02aM0tSQrGthObysXf ueyaQqNDhvmnsDr0hEtOv9mtkEWLIBo4TN4xJMr8otTUHzU8JdRbQJ91l5jH223+cU5kS RkapvajKxzRF81H37COoPWs4BNfS7QpDcuy99UPR4NSdtAmvGdxoQxy7C6GwPFYbzVi6G OekdFMZVfGmhmXOi2gYLJ1EGMfUAIrcS82uXV38Kdj79dZP9JXeyiAMjjd9ftRJ7xQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=s4PCdMIK; arc=none smtp.remote-ip=162.62.57.64 Received: from out162-62-57-64.mail.qq.com (out162-62-57-64.mail.qq.com [162.62.57.64]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 253A8606A322; Fri, 4 Dec 2026 07:49:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 253A8606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=s4PCdMIK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1796370540; bh=jZovu1caXRb4KwZYQYsH/JOktWEKC8UhmEQsNGE1zd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=s4PCdMIKzTqoQByGQ0j2w0T+ZYasiGv/46/sIuOEGcaCzxBjWpjIcbHX2DfCZ+8hA XmZIF5FAtaMomOikvfgmnSeWoWFkoihCDJGMWakqUmxKRMAuJXn7FSiSp152+1NX7p CNBikvBvAPrDPZueUiWeFpXWpHu48G1eaYMq9EUU= Received: from 1.0.0.127.in-addr.arpa ([113.70.96.231]) by newxmesmtplogicsvrszb43-0.qq.com (NewEsmtp) with SMTP id C3234620; Fri, 04 Dec 2026 15:48:50 +0800 X-QQ-mid: xmsmtpt1796370535tnjyqrijh Message-ID: X-QQ-XMAILINFO: NMjBSuGnzB/8uTobS5QlTspI0yQ06bN9i1oLLKX5iKvNI5uByNWXFxKIW3W55E cci6At+lOFwkM9tRPGSdta+5txhsPtrTfs9IMm9uJjuOkXLp5q08GCiUWaddU1B9OmetPyjM3UU5 kvKTwl0eFDFFGzTitZreGTv/CHObQJ9hmW8jl1fzwnC8Fl48qWUPd9O32ABsapzg4woU5FZrW8Mo b0M9w3kqiA7/yLg7Sj6Cbgk3crENVgmzl9hxWWh2Y1OtwIqDmb863UM6FPVCxT6CjcHSRMHMrf8T uQqWzZXgDeE1Mzbv/Kz9CxJgbjWsGW0mPdCikRPYjn7xE9yLS7vtdJT6xKfAfa4Mdwuh2fDt/DeD BMLt+Zm9pwteiFHorGzgAKx1yJeHgRUgaLVwM3iaa1qFvP4z9Uubi8RtFXmZelrFC/ONVUsAEK+0 QlFwgiw+SOdhNvH+AUQ/gbwxVQsTAbADrFojkb8SgnS1bkYpYVdnAKZ/ksZhMLYNYbeEONl2VWXl gFJk32rSQJSTum5TBREQmKD3JNMCza5/nCgXfrj+uLOxXthDyTPrGlU6nj1YiKj7cFaFpwH6pK55 M3eshKWiV0NYpgyPwiJM3gHoFFBnDBbr+3EuCCwTmlADeA04EuCZPr0rNvzxvPQzT9k+52oYedcx w83ZIr/PEHhK0LUZ++tl2c1rHS40d/hksf2uM8PYSTD/4yaQnapnIWgHoGQ4An9axu9ScUA6tOTf 5aKAdZHnNAcp+oyHS0ko/Liu31g0suqHUWlMw0EBQvF/Y9l2cjcbnDxzSVymUoya+yGYgzOzhGzN zzGJ3LYSIk8Z5g/woSEz3ywvogEMQHMuS/kTVGB2sS3oJC2y+skguy0sQbhP6+L1Su7Eyuz8Jhwq Vx70Ok5Pg3jVdGOnAW6kK482WRFsn2Ix72c/thVr4S7z9NZsMmGyBmnLbyGmcx3iFF6Xh5DrgmNd g2dJcAgbfmQ+0fe5gyAwg/birbEtIRMW5oSXpBDnX49wiOuuMjGqCoKyp5JF9ynW0q8/nM9N5q4P pMt8ErMV/7vCIIIyyPfcVmQD0XYqn6LdrQJDGJI2zXpHC1wSa7vUfmgzGOPG8tTJs42B/T6ILbdz QTspQblnjcK70jL69f8/b3NQspDxFLXDoiRuAnVmXhsgJk3LGxCaJsD0Az6Q== X-QQ-XMRINFO: NS+P29fieYNwqS3WCnRCOn9D1NpZuCnCRA== From: sthho law <17236081@qq.com> To: 17236081@qq.com Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Input: add STMicroelectronics FTM5 touchscreen driver Date: Fri, 04 Dec 2026 15:47:20 +0800 X-OQ-MSGID: <1796370440.32551.2@17236081.qq.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable In-Reply-To: <1796370440.32551.0@17236081.qq.com> References: <1796370440.32551.0@17236081.qq.com> Add a driver for the FTM5 generation of the STMicroelectronics FingerTip controllers. The existing stmfts.c speaks the FTM4 protocol, which FTM5 firmware does not answer: the system information command (0x80) returns only zeros and a reset never produces the status event the driver waits for, so probing such a panel fails with -ETIMEDOUT. On the Meizu 16X panel reported here the FTM4 probe timed out after 1.0 s while the chip did acknowledge its I2C address, and the chip identifies itself as 0x3936 when its hardware registers are read out through the FTM5 protocol. FTM5 reaches its hardware registers through the 0xFA command, selects the scan mode with "0xA0 " and reports touch data as fixed size 8 byte records that are read with 0x86. Implement that protocol. The controller drives its interrupt line low while its FIFO is not empty, so a missed edge leaves the panel silent until the next touch. A slow workqueue drain empties the FIFO as well, which keeps the line moving independently of the interrupt state. The panel rails also feed the display and stay enabled, so suspend only stops scanning and resume restarts the firmware and re-enables scanning. Signed-off-by: sthho law <17236081@qq.com> --- drivers/input/touchscreen/Kconfig | 10 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/fts5_touch.c | 478 +++++++++++++++++++++++++ 3 files changed, 489 insertions(+) create mode 100644 drivers/input/touchscreen/fts5_touch.c diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/= Kconfig index 9b9ae8a..32f1026 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -370,6 +370,16 @@ config TOUCHSCREEN_EXC3000 To compile this driver as a module, choose M here: the module will be called exc3000. =20 +config TOUCHSCREEN_FTS5 + tristate "STMicroelectronics FTM5 touchscreen" + depends on I2C + help + Say Y here if you want support for STMicroelectronics FTM5 + (FingerTip) touchscreen controllers. + + To compile this driver as a module, choose M here: the + module will be called fts5_touch. + config TOUCHSCREEN_FUJITSU tristate "Fujitsu serial touchscreen" select SERIO diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen= /Makefile index bfd9de8..0b59a5b 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_TOUCHSCREEN_ELO) +=3D elo.o obj-$(CONFIG_TOUCHSCREEN_EGALAX) +=3D egalax_ts.o obj-$(CONFIG_TOUCHSCREEN_EGALAX_SERIAL) +=3D egalax_ts_serial.o obj-$(CONFIG_TOUCHSCREEN_EXC3000) +=3D exc3000.o +obj-$(CONFIG_TOUCHSCREEN_FTS5) +=3D fts5_touch.o obj-$(CONFIG_TOUCHSCREEN_FUJITSU) +=3D fujitsu_ts.o obj-$(CONFIG_TOUCHSCREEN_GOODIX) +=3D goodix_ts.o obj-$(CONFIG_TOUCHSCREEN_GOODIX_BERLIN_CORE) +=3D goodix_berlin_core.o diff --git a/drivers/input/touchscreen/fts5_touch.c b/drivers/input/touchsc= reen/fts5_touch.c new file mode 100644 index 0000000..60a0f8f --- /dev/null +++ b/drivers/input/touchscreen/fts5_touch.c @@ -0,0 +1,478 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * STMicroelectronics FTM5 (FingerTip) touchscreen driver + * + * The FTM5 firmware generation uses a different command set than the FTM4 + * controllers handled by stmfts.c: hardware registers are accessed through + * the 0xFA command, scanning is started with 0xA0 and + * touch events are fixed size 8 byte records that are pulled out with 0x8= 6. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FTS5_CMD_HW_REG 0xfa +#define FTS5_CMD_SCAN_MODE 0xa0 +#define FTS5_CMD_READ_EVENTS 0x86 + +#define FTS5_REG_CHIP_ID 0x20000000 +#define FTS5_REG_SYSTEM_RESET 0x20000024 +#define FTS5_SYSTEM_RESET 0x81 + +#define FTS5_EVENT_SIZE 8 +#define FTS5_FIFO_DEPTH 32 + +#define FTS5_SCAN_MODE_ACTIVE 0x00 +#define FTS5_SCAN_MODE_LOW_POWER 0x01 +#define FTS5_SCAN_MULTI_TOUCH BIT(0) + +/* the upper nibble of the first event byte selects the event class */ +#define FTS5_EVENT_ID(ev) ((ev)[0] & 0xf0) +#define FTS5_EVENT_ID_READY 0x00 +#define FTS5_EVENT_ID_ENTER 0x10 +#define FTS5_EVENT_ID_MOTION 0x20 +#define FTS5_EVENT_ID_LEAVE 0x30 +#define FTS5_EVENT_ID_ERROR 0xf0 + +#define FTS5_MAX_CONTACTS 10 + +struct fts5_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator_bulk_data supplies[2]; + u8 *buf; + unsigned long contacts; + bool ready; + struct delayed_work poll; +}; + +static int fts5_i2c_write(struct fts5_data *ts, const u8 *data, int len) +{ + struct i2c_msg msg =3D { + .addr =3D ts->client->addr, + .len =3D len, + .buf =3D (u8 *)data, + }; + + if (i2c_transfer(ts->client->adapter, &msg, 1) !=3D 1) + return -EIO; + + return 0; +} + +static int fts5_i2c_wr_rd(struct fts5_data *ts, const u8 *wbuf, int wlen, + u8 *rbuf, int rlen) +{ + struct i2c_msg msg[2] =3D { + { + .addr =3D ts->client->addr, + .len =3D wlen, + .buf =3D (u8 *)wbuf, + }, { + .addr =3D ts->client->addr, + .flags =3D I2C_M_RD, + .len =3D rlen, + .buf =3D rbuf, + }, + }; + + if (i2c_transfer(ts->client->adapter, msg, 2) !=3D 2) + return -EIO; + + return 0; +} + +static int fts5_reg_read(struct fts5_data *ts, u32 reg, u8 *val, int len) +{ + u8 cmd[5] =3D { + FTS5_CMD_HW_REG, + (u8)(reg >> 24), + (u8)(reg >> 16), + (u8)(reg >> 8), + (u8)reg, + }; + + return fts5_i2c_wr_rd(ts, cmd, sizeof(cmd), val, len); +} + +static int fts5_reg_write(struct fts5_data *ts, u32 reg, u8 val) +{ + u8 cmd[6] =3D { + FTS5_CMD_HW_REG, + (u8)(reg >> 24), + (u8)(reg >> 16), + (u8)(reg >> 8), + (u8)reg, + val, + }; + + return fts5_i2c_write(ts, cmd, sizeof(cmd)); +} + +static int fts5_read_events(struct fts5_data *ts, u8 *buf, int count) +{ + u8 cmd =3D FTS5_CMD_READ_EVENTS; + + return fts5_i2c_wr_rd(ts, &cmd, 1, buf, FTS5_EVENT_SIZE * count); +} + +static int fts5_scan_mode(struct fts5_data *ts, u8 mode, u8 settings) +{ + /* select the FTM5 system command page */ + const u8 page[7] =3D { + FTS5_CMD_HW_REG, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + u8 scan[3] =3D { FTS5_CMD_SCAN_MODE, mode, settings }; + int ret; + + ret =3D fts5_i2c_write(ts, page, sizeof(page)); + if (ret) + return ret; + + return fts5_i2c_write(ts, scan, sizeof(scan)); +} + +static void fts5_report_contact(struct fts5_data *ts, const u8 *ev, bool d= own) +{ + struct input_dev *input =3D ts->input; + unsigned int slot =3D ev[1] >> 4; + unsigned int x =3D (((int)ev[3] & 0x0f) << 8) | ev[2]; + unsigned int y =3D ((int)ev[4] << 4) | ((ev[3] & 0xf0) >> 4); + unsigned int pressure =3D ev[5] ? ev[5] : 1; + unsigned int major =3D ((ev[0] & 0x0c) << 2) | (ev[6] >> 4); + unsigned int minor =3D ((ev[7] & 0xc0) >> 2) | (ev[6] & 0x0f); + + if (slot >=3D FTS5_MAX_CONTACTS) + return; + + if (ts->prop.max_x) + x =3D clamp_val(x, 0, ts->prop.max_x); + if (ts->prop.max_y) + y =3D clamp_val(y, 0, ts->prop.max_y); + + input_mt_slot(input, slot); + + if (down) { + __set_bit(slot, &ts->contacts); + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); + touchscreen_report_pos(input, &ts->prop, x, y, true); + input_report_abs(input, ABS_MT_PRESSURE, pressure); + input_report_abs(input, ABS_MT_TOUCH_MAJOR, major); + input_report_abs(input, ABS_MT_TOUCH_MINOR, minor); + input_report_key(input, BTN_TOUCH, 1); + } else { + __clear_bit(slot, &ts->contacts); + input_mt_report_slot_state(input, MT_TOOL_FINGER, false); + if (!ts->contacts) + input_report_key(input, BTN_TOUCH, 0); + } +} + +static void fts5_handle_event(struct fts5_data *ts, const u8 *ev) +{ + switch (FTS5_EVENT_ID(ev)) { + case FTS5_EVENT_ID_ENTER: + case FTS5_EVENT_ID_MOTION: + fts5_report_contact(ts, ev, true); + break; + case FTS5_EVENT_ID_LEAVE: + fts5_report_contact(ts, ev, false); + break; + case FTS5_EVENT_ID_ERROR: + dev_warn_ratelimited(&ts->client->dev, "firmware error %*ph\n", + 6, ev + 1); + break; + default: + break; + } +} + +static int fts5_drain(struct fts5_data *ts) +{ + int count =3D 0; + int i, ret; + + for (i =3D 0; i < 2 * FTS5_FIFO_DEPTH; i++) { + ret =3D fts5_read_events(ts, ts->buf, 1); + if (ret) { + dev_warn_ratelimited(&ts->client->dev, "read events: %d\n", + ret); + break; + } + + if (!FTS5_EVENT_ID(ts->buf)) + break; + + fts5_handle_event(ts, ts->buf); + count++; + } + + if (count) + input_sync(ts->input); + + return count; +} + +/* + * The controller drives nIRQ low while its FIFO is not empty, so a missed + * edge silences the panel until the next event. Empty the FIFO from a sl= ow + * workqueue as well, which keeps the line moving regardless of the IRQ st= ate. + */ +static void fts5_poll(struct work_struct *work) +{ + struct fts5_data *ts =3D container_of(to_delayed_work(work), + struct fts5_data, poll); + + if (ts->ready) + fts5_drain(ts); + + schedule_delayed_work(&ts->poll, msecs_to_jiffies(100)); +} + +static irqreturn_t fts5_irq(int irq, void *data) +{ + struct fts5_data *ts =3D data; + + if (ts->ready) + fts5_drain(ts); + + return IRQ_HANDLED; +} + +static int fts5_startup(struct fts5_data *ts) +{ + struct device *dev =3D &ts->client->dev; + u8 id[4]; + int ret, i; + + ret =3D fts5_reg_read(ts, FTS5_REG_CHIP_ID, id, sizeof(id)); + if (ret) + return ret; + + dev_dbg(dev, "chip id %*ph\n", 4, id); + + ret =3D fts5_reg_write(ts, FTS5_REG_SYSTEM_RESET, FTS5_SYSTEM_RESET); + if (ret) + return ret; + + msleep(150); + + /* + * A freshly reset controller reports CONTROLLER_READY; firmware that is + * already running does not, so a timeout is not fatal. + */ + for (i =3D 0; i < 20; i++) { + ret =3D fts5_read_events(ts, ts->buf, 1); + if (!ret && FTS5_EVENT_ID(ts->buf) =3D=3D FTS5_EVENT_ID_READY) + break; + + msleep(20); + } + + if (i =3D=3D 20) + dev_dbg(dev, "no CONTROLLER_READY event\n"); + + return fts5_scan_mode(ts, FTS5_SCAN_MODE_ACTIVE, FTS5_SCAN_MULTI_TOUCH); +} + +static void fts5_release_contacts(struct fts5_data *ts) +{ + int i; + + for (i =3D 0; i < FTS5_MAX_CONTACTS; i++) { + input_mt_slot(ts->input, i); + input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); + } + + input_report_key(ts->input, BTN_TOUCH, 0); + input_sync(ts->input); + ts->contacts =3D 0; +} + +static int fts5_suspend(struct device *dev) +{ + struct fts5_data *ts =3D dev_get_drvdata(dev); + int ret; + + if (!ts) + return 0; + + ts->ready =3D false; + disable_irq(ts->client->irq); + cancel_delayed_work_sync(&ts->poll); + fts5_release_contacts(ts); + + ret =3D fts5_scan_mode(ts, FTS5_SCAN_MODE_LOW_POWER, 0); + if (ret) + dev_warn(dev, "failed to stop scanning: %d\n", ret); + + return 0; +} + +static int fts5_resume(struct device *dev) +{ + struct fts5_data *ts =3D dev_get_drvdata(dev); + int ret; + + if (!ts) + return 0; + + ret =3D fts5_startup(ts); + if (ret) + dev_err(dev, "failed to resume: %d\n", ret); + + ts->ready =3D !ret; + fts5_drain(ts); + enable_irq(ts->client->irq); + schedule_delayed_work(&ts->poll, msecs_to_jiffies(100)); + + return ret; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(fts5_pm_ops, fts5_suspend, fts5_resume); + +static void fts5_power_off(void *data) +{ + struct fts5_data *ts =3D data; + + regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies); +} + +static void fts5_remove(struct i2c_client *client) +{ + struct fts5_data *ts =3D i2c_get_clientdata(client); + + ts->ready =3D false; + cancel_delayed_work_sync(&ts->poll); + fts5_release_contacts(ts); +} + +static int fts5_probe(struct i2c_client *client) +{ + struct device *dev =3D &client->dev; + struct fts5_data *ts; + struct input_dev *input; + int ret; + + ts =3D devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + ts->client =3D client; + ts->buf =3D devm_kzalloc(dev, FTS5_EVENT_SIZE * FTS5_FIFO_DEPTH, + GFP_KERNEL); + if (!ts->buf) + return -ENOMEM; + + ts->supplies[0].supply =3D "avdd"; + ts->supplies[1].supply =3D "vdd"; + + ret =3D devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies), + ts->supplies); + if (ret) + return ret; + + ret =3D regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies); + if (ret) + return ret; + + ret =3D devm_add_action_or_reset(dev, fts5_power_off, ts); + if (ret) + return ret; + + /* let the rails settle before the controller is talked to */ + msleep(20); + + ret =3D fts5_startup(ts); + if (ret) { + dev_err(dev, "failed to start: %d\n", ret); + return ret; + } + + input =3D devm_input_allocate_device(dev); + if (!input) + return -ENOMEM; + + input->name =3D "STMicroelectronics FTM5 Touchscreen"; + input->id.bustype =3D BUS_I2C; + + /* + * Declare the multi-touch axes before parsing, touchscreen_parse_propert= ies() + * only fills in the limits that the device tree provides. + */ + input_set_abs_params(input, ABS_MT_POSITION_X, 0, 0, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 0, 0, 0); + touchscreen_parse_properties(input, true, &ts->prop); + + input_set_abs_params(input, ABS_MT_PRESSURE, 0, 255, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); + input_set_capability(input, EV_KEY, BTN_TOUCH); + + ret =3D input_mt_init_slots(input, FTS5_MAX_CONTACTS, INPUT_MT_DIRECT); + if (ret) + return ret; + + ret =3D input_register_device(input); + if (ret) + return ret; + + ts->input =3D input; + + /* + * The trigger type comes from the device tree, so request the + * interrupt without IRQF_TRIGGER_* flags. + */ + ret =3D devm_request_threaded_irq(dev, client->irq, NULL, fts5_irq, + IRQF_ONESHOT, dev_name(dev), ts); + if (ret) { + dev_err(dev, "failed to request irq %d: %d\n", client->irq, ret); + return ret; + } + + INIT_DELAYED_WORK(&ts->poll, fts5_poll); + schedule_delayed_work(&ts->poll, msecs_to_jiffies(100)); + ts->ready =3D true; + + i2c_set_clientdata(client, ts); + + return 0; +} + +static const struct of_device_id fts5_of_match[] =3D { + { .compatible =3D "st,fts" }, + { } +}; +MODULE_DEVICE_TABLE(of, fts5_of_match); + +static const struct i2c_device_id fts5_id[] =3D { + { "fts5_touch" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, fts5_id); + +static struct i2c_driver fts5_driver =3D { + .driver =3D { + .name =3D "fts5_touch", + .of_match_table =3D fts5_of_match, + .pm =3D pm_sleep_ptr(&fts5_pm_ops), + }, + .probe =3D fts5_probe, + .remove =3D fts5_remove, + .id_table =3D fts5_id, +}; +module_i2c_driver(fts5_driver); + +MODULE_DESCRIPTION("STMicroelectronics FTM5 touchscreen driver"); +MODULE_LICENSE("GPL");