From: Luka Panio <lukapanio@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Henrik Rydberg <rydberg@bitmath.org>,
Douglas Anderson <dianders@chromium.org>,
linux-input@vger.kernel.org, devicetree@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Luka Panio <lukapanio@gmail.com>
Subject: [PATCH 2/7] Input: edt-ft5x06 - move the controller bring-up into a helper
Date: Sat, 17 Oct 2026 16:07:50 +0200 [thread overview]
Message-ID: <20261017140827.290666-3-lukapanio@gmail.com> (raw)
In-Reply-To: <20261017140827.290666-1-lukapanio@gmail.com>
Move the part of probe that takes the controller out of reset,
identifies it and registers the input device into a helper, so it
can also be run after the probe.
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 154 ++++++++++++++-----------
1 file changed, 86 insertions(+), 68 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 543cc62088c7..536d633d97a7 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -1116,16 +1116,96 @@ static void edt_ft5x06_disable_regulators(void *arg)
regulator_disable(data->iovcc);
}
+/*
+ * Take the controller out of reset, identify it and register the input
+ * device.
+ */
+static int edt_ft5x06_ts_init_hw(struct edt_ft5x06_ts_data *tsdata)
+{
+ struct device *dev = tsdata->dev;
+ struct input_dev *input = tsdata->input;
+ unsigned int val;
+ u32 report_rate;
+ int error;
+
+ if (tsdata->reset_gpio) {
+ usleep_range(5000, 6000);
+ gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
+ msleep(300);
+ }
+
+ error = edt_ft5x06_ts_identify(tsdata);
+ if (error) {
+ dev_err(dev, "touchscreen probe failed\n");
+ return error;
+ }
+
+ /*
+ * Dummy read access. EP0700MLP1 returns bogus data on the first
+ * register read access and ignores writes.
+ */
+ regmap_read(tsdata->regmap, 0x00, &val);
+
+ edt_ft5x06_ts_set_tdata_parameters(tsdata);
+ edt_ft5x06_ts_set_regs(tsdata);
+ edt_ft5x06_ts_get_defaults(dev, tsdata);
+ edt_ft5x06_ts_get_parameters(tsdata);
+
+ if (tsdata->reg_addr.reg_report_rate != NO_REGISTER &&
+ !device_property_read_u32(dev, "report-rate-hz", &report_rate)) {
+ if (tsdata->version == EDT_M06)
+ tsdata->report_rate = clamp_val(report_rate, 30, 140);
+ else
+ tsdata->report_rate = clamp_val(report_rate, 1, 255);
+
+ if (report_rate != tsdata->report_rate)
+ dev_warn(dev,
+ "report-rate %dHz is unsupported, use %dHz\n",
+ report_rate, tsdata->report_rate);
+
+ if (tsdata->version == EDT_M06)
+ tsdata->report_rate /= 10;
+
+ regmap_write(tsdata->regmap, tsdata->reg_addr.reg_report_rate,
+ tsdata->report_rate);
+ }
+
+ dev_dbg(dev, "Model \"%s\", Rev. \"%s\", %dx%d sensors\n",
+ tsdata->name, tsdata->fw_version, tsdata->num_x, tsdata->num_y);
+
+ input->name = tsdata->name;
+
+ input_set_abs_params(input, ABS_MT_POSITION_X,
+ 0, tsdata->num_x * 64 - 1, 0, 0);
+ input_set_abs_params(input, ABS_MT_POSITION_Y,
+ 0, tsdata->num_y * 64 - 1, 0, 0);
+
+ touchscreen_parse_properties(input, true, &tsdata->prop);
+
+ error = input_mt_init_slots(input, tsdata->max_support_points,
+ INPUT_MT_DIRECT);
+ if (error) {
+ dev_err(dev, "Unable to init MT slots.\n");
+ return error;
+ }
+
+ error = input_register_device(input);
+ if (error)
+ return error;
+
+ edt_ft5x06_ts_prepare_debugfs(tsdata);
+
+ return 0;
+}
+
int edt_ft5x06_probe(struct device *dev, struct regmap *regmap, int irq,
const struct edt_ft5x06_chip_data *chip_data, u16 bustype,
struct dentry *debugfs)
{
struct edt_ft5x06_ts_data *tsdata;
- unsigned int val;
struct input_dev *input;
unsigned long irq_flags;
int error;
- u32 report_rate;
tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
if (!tsdata) {
@@ -1225,78 +1305,22 @@ int edt_ft5x06_probe(struct device *dev, struct regmap *regmap, int irq,
usleep_range(5000, 6000);
}
- if (tsdata->reset_gpio) {
- usleep_range(5000, 6000);
- gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
- msleep(300);
- }
-
input = devm_input_allocate_device(dev);
if (!input) {
dev_err(dev, "failed to allocate input device.\n");
return -ENOMEM;
}
+ input->id.bustype = bustype;
+
mutex_init(&tsdata->mutex);
tsdata->input = input;
tsdata->factory_mode = false;
dev_set_drvdata(dev, tsdata);
- error = edt_ft5x06_ts_identify(tsdata);
- if (error) {
- dev_err(dev, "touchscreen probe failed\n");
- return error;
- }
-
- /*
- * Dummy read access. EP0700MLP1 returns bogus data on the first
- * register read access and ignores writes.
- */
- regmap_read(tsdata->regmap, 0x00, &val);
-
- edt_ft5x06_ts_set_tdata_parameters(tsdata);
- edt_ft5x06_ts_set_regs(tsdata);
- edt_ft5x06_ts_get_defaults(dev, tsdata);
- edt_ft5x06_ts_get_parameters(tsdata);
-
- if (tsdata->reg_addr.reg_report_rate != NO_REGISTER &&
- !device_property_read_u32(dev, "report-rate-hz", &report_rate)) {
- if (tsdata->version == EDT_M06)
- tsdata->report_rate = clamp_val(report_rate, 30, 140);
- else
- tsdata->report_rate = clamp_val(report_rate, 1, 255);
-
- if (report_rate != tsdata->report_rate)
- dev_warn(dev,
- "report-rate %dHz is unsupported, use %dHz\n",
- report_rate, tsdata->report_rate);
-
- if (tsdata->version == EDT_M06)
- tsdata->report_rate /= 10;
-
- regmap_write(tsdata->regmap, tsdata->reg_addr.reg_report_rate,
- tsdata->report_rate);
- }
-
- dev_dbg(dev, "Model \"%s\", Rev. \"%s\", %dx%d sensors\n",
- tsdata->name, tsdata->fw_version, tsdata->num_x, tsdata->num_y);
-
- input->name = tsdata->name;
- input->id.bustype = bustype;
-
- input_set_abs_params(input, ABS_MT_POSITION_X,
- 0, tsdata->num_x * 64 - 1, 0, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y,
- 0, tsdata->num_y * 64 - 1, 0, 0);
-
- touchscreen_parse_properties(input, true, &tsdata->prop);
-
- error = input_mt_init_slots(input, tsdata->max_support_points,
- INPUT_MT_DIRECT);
- if (error) {
- dev_err(dev, "Unable to init MT slots.\n");
+ error = edt_ft5x06_ts_init_hw(tsdata);
+ if (error)
return error;
- }
irq_flags = irq_get_trigger_type(irq);
if (irq_flags == IRQF_TRIGGER_NONE)
@@ -1310,12 +1334,6 @@ int edt_ft5x06_probe(struct device *dev, struct regmap *regmap, int irq,
return error;
}
- error = input_register_device(input);
- if (error)
- return error;
-
- edt_ft5x06_ts_prepare_debugfs(tsdata);
-
dev_dbg(dev,
"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
irq,
--
2.55.0
next prev parent reply other threads:[~2026-10-17 14:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 14:07 [PATCH 0/7] Input: edt-ft5x06 - add SPI transport and FocalTech FT8722 support Luka Panio
2026-10-17 14:07 ` [PATCH 1/7] Input: edt-ft5x06 - split the bus independent core from the I2C driver Luka Panio
2026-10-17 14:07 ` Luka Panio [this message]
2026-10-17 14:16 ` [PATCH 2/7] Input: edt-ft5x06 - move the controller bring-up into a helper sashiko-bot
2026-10-17 14:07 ` [PATCH 3/7] Input: edt-ft5x06 - add an optional controller boot hook Luka Panio
2026-10-17 14:07 ` [PATCH 4/7] Input: edt-ft5x06 - allow a chip specific touch data register Luka Panio
2026-10-17 14:07 ` [PATCH 5/7] dt-bindings: input: touchscreen: edt-ft5x06: Add FocalTech FT8722 Luka Panio
2026-10-17 14:07 ` [PATCH 6/7] Input: edt-ft5x06 - add SPI transport and FT8722 support Luka Panio
2026-10-17 14:29 ` sashiko-bot
2026-10-17 14:07 ` [PATCH 7/7] Input: edt-ft5x06 - support following a DRM panel Luka Panio
2026-10-17 14:30 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261017140827.290666-3-lukapanio@gmail.com \
--to=lukapanio@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=krzk+dt@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rydberg@bitmath.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox