[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aWZ1pG5RRWlDSCwC@lizhi-Precision-Tower-5810>
Date: Tue, 13 Jan 2026 11:41:08 -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 2/2] Input: ili210x - add support for polling mode
On Tue, Jan 13, 2026 at 12:44:57AM +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>
> ---
> 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
> ---
> drivers/input/touchscreen/ili210x.c | 84 ++++++++++++++++++++---------
> 1 file changed, 60 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index fa38d70aded7b..3220848a4b843 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) {
> + 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;
> @@ -947,11 +976,6 @@ static int ili210x_i2c_probe(struct i2c_client *client)
> return -ENODEV;
> }
>
> - if (client->irq <= 0) {
> - dev_err(dev, "No IRQ!\n");
> - return -EINVAL;
> - }
> -
> reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> if (IS_ERR(reset_gpio))
> return PTR_ERR(reset_gpio);
> @@ -1003,12 +1027,24 @@ static int ili210x_i2c_probe(struct i2c_client *client)
> return error;
> }
>
> - error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
> - IRQF_ONESHOT, client->name, priv);
> - if (error) {
> - dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n",
> - error);
> - return error;
> + input_set_drvdata(input, priv);
> +
> + if (client->irq) {
0 is validated irq number
https://elixir.bootlin.com/linux/v6.19-rc4/source/drivers/base/platform.c#L284
if (irq < 0)
But it is strange that touch don't connect irq line althougth it works,
touch generally is wakeup source of system.
Frank
> + error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
> + IRQF_ONESHOT, client->name, priv);
> + if (error) {
> + dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n",
> + error);
> + return error;
> + }
> + } else {
> + error = input_setup_polling(input, ili210x_work_i2c_poll);
> + if (error) {
> + dev_err(dev, "Could not set up polling mode, err: %d\n",
> + error);
> + return error;
> + }
> + input_set_poll_interval(input, ILI2XXX_POLL_PERIOD);
> }
>
> error = devm_add_action_or_reset(dev, ili210x_stop, priv);
> --
> 2.51.0
>
Powered by blists - more mailing lists