[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aW0WDhDRSh34TzW6@lizhi-Precision-Tower-5810>
Date: Sun, 18 Jan 2026 12:19:10 -0500
From: Frank Li <Frank.li@....com>
To: Marek Vasut <marek.vasut+renesas@...lbox.org>
Cc: linux-input@...r.kernel.org, Conor Dooley <conor+dt@...nel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Job Noorman <job@...rman.info>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Rob Herring <robh@...nel.org>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-renesas-soc@...r.kernel.org
Subject: Re: [PATCH v4 3/3] Input: ili210x - add support for polling mode
On Sat, Jan 17, 2026 at 01:12:04AM +0100, Marek Vasut wrote:
> There are designs incorporating Ilitek ILI2xxx touch controller that
> do not connect interrupt pin, for example Waveshare 13.3" DSI display.
> To support such systems use polling mode for the input device when I2C
> client does not have interrupt assigned to it.
>
> Factor out ili210x_firmware_update_noirq() to allow conditional scoped
> guard around this code. The scoped guard has to be applied only in case
> the IRQ line is connected, and not applied otherwise.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@...lbox.org>
Reviewed-by: Frank Li <Frank.Li@....com>
> ---
> Cc: Conor Dooley <conor+dt@...nel.org>
> Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
> Cc: Frank Li <Frank.Li@....com>
> Cc: Job Noorman <job@...rman.info>
> Cc: Krzysztof Kozlowski <krzk+dt@...nel.org>
> Cc: Rob Herring <robh@...nel.org>
> Cc: devicetree@...r.kernel.org
> Cc: linux-input@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> Cc: linux-renesas-soc@...r.kernel.org
> ---
> V2: Test client->irq > 0 for IRQ presence
> V3: - Rebase on dev_err_probe() conversion
> - Fix if (client->irq > 0) in ili210x_firmware_update_store()
> V4: No change
> ---
> drivers/input/touchscreen/ili210x.c | 76 +++++++++++++++++++++--------
> 1 file changed, 56 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index 264eee3e61d0a..22917a5825778 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
> @@ -327,9 +327,8 @@ static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
> return contact;
> }
>
> -static irqreturn_t ili210x_irq(int irq, void *irq_data)
> +static void ili210x_process_events(struct ili210x *priv)
> {
> - struct ili210x *priv = irq_data;
> struct i2c_client *client = priv->client;
> const struct ili2xxx_chip *chip = priv->chip;
> u8 touchdata[ILI210X_DATA_SIZE] = { 0 };
> @@ -356,8 +355,22 @@ static irqreturn_t ili210x_irq(int irq, void *irq_data)
> usleep_range(time_delta, time_delta + 1000);
> }
> } while (!priv->stop && keep_polling);
> +}
> +
> +static irqreturn_t ili210x_irq(int irq, void *irq_data)
> +{
> + struct ili210x *priv = irq_data;
> +
> + ili210x_process_events(priv);
>
> return IRQ_HANDLED;
> +};
> +
> +static void ili210x_work_i2c_poll(struct input_dev *input)
> +{
> + struct ili210x *priv = input_get_drvdata(input);
> +
> + ili210x_process_events(priv);
> }
>
> static int ili251x_firmware_update_resolution(struct device *dev)
> @@ -829,12 +842,32 @@ static int ili210x_do_firmware_update(struct ili210x *priv,
> return 0;
> }
>
> +static ssize_t ili210x_firmware_update_noirq(struct device *dev,
> + const u8 *fwbuf, u16 ac_end, u16 df_end)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + struct ili210x *priv = i2c_get_clientdata(client);
> + const char *fwname = ILI251X_FW_FILENAME;
> + int error;
> +
> + dev_dbg(dev, "Firmware update started, firmware=%s\n", fwname);
> +
> + ili210x_hardware_reset(priv->reset_gpio);
> +
> + error = ili210x_do_firmware_update(priv, fwbuf, ac_end, df_end);
> +
> + ili210x_hardware_reset(priv->reset_gpio);
> +
> + dev_dbg(dev, "Firmware update ended, error=%i\n", error);
> +
> + return error;
> +}
> +
> static ssize_t ili210x_firmware_update_store(struct device *dev,
> struct device_attribute *attr,
> const char *buf, size_t count)
> {
> struct i2c_client *client = to_i2c_client(dev);
> - struct ili210x *priv = i2c_get_clientdata(client);
> const char *fwname = ILI251X_FW_FILENAME;
> u16 ac_end, df_end;
> int error;
> @@ -860,16 +893,12 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
> * the touch controller to disable the IRQs during update, so we have
> * to do it this way here.
> */
> - scoped_guard(disable_irq, &client->irq) {
> - dev_dbg(dev, "Firmware update started, firmware=%s\n", fwname);
> -
> - ili210x_hardware_reset(priv->reset_gpio);
> -
> - error = ili210x_do_firmware_update(priv, fwbuf, ac_end, df_end);
> -
> - ili210x_hardware_reset(priv->reset_gpio);
> -
> - dev_dbg(dev, "Firmware update ended, error=%i\n", error);
> + if (client->irq > 0) {
> + scoped_guard(disable_irq, &client->irq) {
> + error = ili210x_firmware_update_noirq(dev, fwbuf, ac_end, df_end);
> + }
> + } else {
> + error = ili210x_firmware_update_noirq(dev, fwbuf, ac_end, df_end);
> }
>
> return error ?: count;
> @@ -945,9 +974,6 @@ static int ili210x_i2c_probe(struct i2c_client *client)
> if (!chip)
> return dev_err_probe(&client->dev, -ENODEV, "unknown device model\n");
>
> - if (client->irq <= 0)
> - return dev_err_probe(dev, -EINVAL, "No IRQ!\n");
> -
> reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> if (IS_ERR(reset_gpio))
> return PTR_ERR(reset_gpio);
> @@ -997,10 +1023,20 @@ static int ili210x_i2c_probe(struct i2c_client *client)
> if (error)
> return dev_err_probe(dev, error, "Unable to set up slots\n");
>
> - error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
> - IRQF_ONESHOT, client->name, priv);
> - if (error)
> - return dev_err_probe(dev, error, "Unable to request touchscreen IRQ\n");
> + input_set_drvdata(input, priv);
> +
> + if (client->irq > 0) {
> + error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
> + IRQF_ONESHOT, client->name, priv);
> + if (error)
> + return dev_err_probe(dev, error, "Unable to request touchscreen IRQ\n");
> + } else {
> + error = input_setup_polling(input, ili210x_work_i2c_poll);
> + if (error)
> + return dev_err_probe(dev, error, "Could not set up polling mode\n");
> +
> + input_set_poll_interval(input, ILI2XXX_POLL_PERIOD);
> + }
>
> error = devm_add_action_or_reset(dev, ili210x_stop, priv);
> if (error)
> --
> 2.51.0
>
Powered by blists - more mailing lists