From: Luca Ceresoli <luca@lucaceresoli.net>
To: Lee Jones <lee.jones@linaro.org>, devicetree@vger.kernel.org
Cc: Luca Ceresoli <luca@lucaceresoli.net>,
Rob Herring <robh+dt@kernel.org>, Keerthy <j-keerthy@ti.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] mfd: lp87565: handle optional reset pin
Date: Fri, 26 Feb 2021 15:28:52 +0100 [thread overview]
Message-ID: <20210226142852.19632-2-luca@lucaceresoli.net> (raw)
In-Reply-To: <20210226142852.19632-1-luca@lucaceresoli.net>
Optionally handle the NRST pin (active low reset) in order to start from a
known state during boot and to shut down the chip when rebooting.
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
drivers/mfd/lp87565.c | 27 +++++++++++++++++++++++++++
include/linux/mfd/lp87565.h | 1 +
2 files changed, 28 insertions(+)
diff --git a/drivers/mfd/lp87565.c b/drivers/mfd/lp87565.c
index 9c21483d9653..a52ab76febb3 100644
--- a/drivers/mfd/lp87565.c
+++ b/drivers/mfd/lp87565.c
@@ -5,6 +5,7 @@
* Author: Keerthy <j-keerthy@ti.com>
*/
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
@@ -64,6 +65,24 @@ static int lp87565_probe(struct i2c_client *client,
return ret;
}
+ lp87565->reset_gpio = devm_gpiod_get_optional(lp87565->dev, "reset",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(lp87565->reset_gpio)) {
+ ret = PTR_ERR(lp87565->reset_gpio);
+ if (ret == -EPROBE_DEFER)
+ return ret;
+ }
+
+ if (lp87565->reset_gpio) {
+ gpiod_set_value_cansleep(lp87565->reset_gpio, 1);
+ /* The minimum assertion time is undocumented, just guess */
+ usleep_range(2000, 4000);
+
+ gpiod_set_value_cansleep(lp87565->reset_gpio, 0);
+ /* Min 1.2 ms before first I2C transaction */
+ usleep_range(1500, 3000);
+ }
+
ret = regmap_read(lp87565->regmap, LP87565_REG_OTP_REV, &otpid);
if (ret) {
dev_err(lp87565->dev, "Failed to read OTP ID\n");
@@ -83,6 +102,13 @@ static int lp87565_probe(struct i2c_client *client,
NULL, 0, NULL);
}
+static void lp87565_shutdown(struct i2c_client *client)
+{
+ struct lp87565 *lp87565 = i2c_get_clientdata(client);
+
+ gpiod_set_value_cansleep(lp87565->reset_gpio, 1);
+}
+
static const struct i2c_device_id lp87565_id_table[] = {
{ "lp87565-q1", 0 },
{ },
@@ -95,6 +121,7 @@ static struct i2c_driver lp87565_driver = {
.of_match_table = of_lp87565_match_table,
},
.probe = lp87565_probe,
+ .shutdown = lp87565_shutdown,
.id_table = lp87565_id_table,
};
module_i2c_driver(lp87565_driver);
diff --git a/include/linux/mfd/lp87565.h b/include/linux/mfd/lp87565.h
index 94cb581af34b..4c895072d91b 100644
--- a/include/linux/mfd/lp87565.h
+++ b/include/linux/mfd/lp87565.h
@@ -252,5 +252,6 @@ struct lp87565 {
u8 rev;
u8 dev_type;
struct regmap *regmap;
+ struct gpio_desc *reset_gpio;
};
#endif /* __LINUX_MFD_LP87565_H */
--
2.30.0
next prev parent reply other threads:[~2021-02-26 14:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-26 14:28 [PATCH 1/2] dt-bindings: mfd: lp875xx: add optional reset GPIO Luca Ceresoli
2021-02-26 14:28 ` Luca Ceresoli [this message]
2021-05-12 9:12 ` [PATCH 2/2] mfd: lp87565: handle optional reset pin Luca Ceresoli
2021-05-19 12:25 ` Lee Jones
2021-03-08 17:22 ` [PATCH 1/2] dt-bindings: mfd: lp875xx: add optional reset GPIO Rob Herring
2021-03-10 9:20 ` Lee Jones
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=20210226142852.19632-2-luca@lucaceresoli.net \
--to=luca@lucaceresoli.net \
--cc=devicetree@vger.kernel.org \
--cc=j-keerthy@ti.com \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).