From: Stefan Eichenberger <eichest@gmail.com>
To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
claudiu.beznea@tuxon.dev, linus.walleij@linaro.org,
francesco.dolcini@toradex.com, joao.goncalves@toradex.com
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Stefan Eichenberger <stefan.eichenberger@toradex.com>
Subject: [PATCH v5 1/4] Input: atmel_mxt_ts - add power off and power on functions
Date: Mon, 8 Jul 2024 09:15:48 +0200 [thread overview]
Message-ID: <20240708071601.7571-2-eichest@gmail.com> (raw)
In-Reply-To: <20240708071601.7571-1-eichest@gmail.com>
From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
Add a separate function for power off and power on instead of calling
regulator_bulk_enable and regulator_bulk_disable directly.
Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
Reviewed-by: Joao Paulo Goncalves <joao.goncalves@toradex.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 59 +++++++++++++++---------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 8a606bd441ae6..4fc83a4cabd9b 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1307,6 +1307,38 @@ static int mxt_soft_reset(struct mxt_data *data)
return 0;
}
+static int mxt_power_on(struct mxt_data *data)
+{
+ int error;
+
+ error = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
+ data->regulators);
+ if (error) {
+ dev_err(&data->client->dev, "failed to enable regulators: %d\n",
+ error);
+ return error;
+ }
+
+ msleep(MXT_BACKUP_TIME);
+
+ if (data->reset_gpio) {
+ /* Wait a while and then de-assert the RESET GPIO line */
+ msleep(MXT_RESET_GPIO_TIME);
+ gpiod_set_value(data->reset_gpio, 0);
+ msleep(MXT_RESET_INVALID_CHG);
+ }
+
+ return 0;
+}
+
+static void mxt_power_off(struct mxt_data *data)
+{
+ if (data->reset_gpio)
+ gpiod_set_value(data->reset_gpio, 1);
+
+ regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
+}
+
static void mxt_update_crc(struct mxt_data *data, u8 cmd, u8 value)
{
/*
@@ -3305,25 +3337,9 @@ static int mxt_probe(struct i2c_client *client)
return error;
}
- error = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
- data->regulators);
- if (error) {
- dev_err(&client->dev, "failed to enable regulators: %d\n",
- error);
+ error = mxt_power_on(data);
+ if (error)
return error;
- }
- /*
- * The device takes 40ms to come up after power-on according
- * to the mXT224 datasheet, page 13.
- */
- msleep(MXT_BACKUP_TIME);
-
- if (data->reset_gpio) {
- /* Wait a while and then de-assert the RESET GPIO line */
- msleep(MXT_RESET_GPIO_TIME);
- gpiod_set_value(data->reset_gpio, 0);
- msleep(MXT_RESET_INVALID_CHG);
- }
/*
* Controllers like mXT1386 have a dedicated WAKE line that could be
@@ -3361,8 +3377,8 @@ static int mxt_probe(struct i2c_client *client)
mxt_free_input_device(data);
mxt_free_object_table(data);
err_disable_regulators:
- regulator_bulk_disable(ARRAY_SIZE(data->regulators),
- data->regulators);
+ mxt_power_off(data);
+
return error;
}
@@ -3374,8 +3390,7 @@ static void mxt_remove(struct i2c_client *client)
sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
mxt_free_input_device(data);
mxt_free_object_table(data);
- regulator_bulk_disable(ARRAY_SIZE(data->regulators),
- data->regulators);
+ mxt_power_off(data);
}
static int mxt_suspend(struct device *dev)
--
2.43.0
next prev parent reply other threads:[~2024-07-08 7:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 7:15 [PATCH v5 0/4] Add a property to turn off the max touch controller if not used Stefan Eichenberger
2024-07-08 7:15 ` Stefan Eichenberger [this message]
2024-07-08 7:15 ` [PATCH v5 2/4] Input: atmel_mxt_ts - move calls to register the input device to separate function Stefan Eichenberger
2024-07-08 7:15 ` [PATCH v5 3/4] dt-bindings: input: atmel,maxtouch: add poweroff-sleep property Stefan Eichenberger
2024-07-08 7:15 ` [PATCH v5 4/4] Input: atmel_mxt_ts - add support for poweroff-sleep Stefan Eichenberger
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=20240708071601.7571-2-eichest@gmail.com \
--to=eichest@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=francesco.dolcini@toradex.com \
--cc=joao.goncalves@toradex.com \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nick@shmanahar.org \
--cc=nicolas.ferre@microchip.com \
--cc=robh@kernel.org \
--cc=stefan.eichenberger@toradex.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.