From: Chris Packham <chris.packham@alliedtelesis.co.nz>
To: gregory.clement@bootlin.com, andi.shyti@kernel.org,
robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
conor+dt@kernel.org
Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Chris Packham <chris.packham@alliedtelesis.co.nz>
Subject: [PATCH 2/2] i2c: mv64xxx: add an optional reset-gpios property
Date: Thu, 12 Oct 2023 16:58:38 +1300 [thread overview]
Message-ID: <20231012035838.2804064-3-chris.packham@alliedtelesis.co.nz> (raw)
In-Reply-To: <20231012035838.2804064-1-chris.packham@alliedtelesis.co.nz>
Some hardware designs have a GPIO used to control the reset of all the
devices on and I2C bus. It's not possible for every child node to
declare a reset-gpios property as only the first device probed would be
able to successfully request it (the others will get -EBUSY). Represent
this kind of hardware design by associating the reset-gpios with the
parent I2C bus. The reset line will be released prior to the child I2C
devices being probed.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
drivers/i2c/busses/i2c-mv64xxx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index efd28bbecf61..b2ca31857cbd 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -160,6 +160,7 @@ struct mv64xxx_i2c_data {
bool clk_n_base_0;
struct i2c_bus_recovery_info rinfo;
bool atomic;
+ struct gpio_desc *reset_gpio;
};
static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = {
@@ -1083,6 +1084,10 @@ mv64xxx_i2c_probe(struct platform_device *pd)
if (drv_data->irq < 0)
return drv_data->irq;
+ drv_data->reset_gpio = devm_gpiod_get_optional(&pd->dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(drv_data->reset_gpio))
+ return PTR_ERR(drv_data->reset_gpio);
+
if (pdata) {
drv_data->freq_m = pdata->freq_m;
drv_data->freq_n = pdata->freq_n;
@@ -1121,6 +1126,12 @@ mv64xxx_i2c_probe(struct platform_device *pd)
goto exit_disable_pm;
}
+ if (drv_data->reset_gpio) {
+ udelay(1);
+ gpiod_set_value_cansleep(drv_data->reset_gpio, 0);
+ udelay(1);
+ }
+
rc = request_irq(drv_data->irq, mv64xxx_i2c_intr, 0,
MV64XXX_I2C_CTLR_NAME, drv_data);
if (rc) {
--
2.42.0
next prev parent reply other threads:[~2023-10-12 3:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 3:58 [PATCH 0/2] i2c: mv64xxx: reset-gpios Chris Packham
2023-10-12 3:58 ` [PATCH 1/2] dt-bindings: i2c: mv64xxx: add reset-gpios property Chris Packham
2023-10-12 7:42 ` Krzysztof Kozlowski
2023-10-12 20:55 ` Chris Packham
2023-10-12 3:58 ` Chris Packham [this message]
2023-10-12 10:21 ` [PATCH 2/2] i2c: mv64xxx: add an optional " Andi Shyti
2023-10-12 10:49 ` Peter Rosin
2023-10-12 20:54 ` Chris Packham
[not found] ` <812dd506-c61b-4967-9b0b-ea35a111bc7f@alliedtelesis.co.nz>
2023-10-13 9:34 ` Andi Shyti
2023-10-15 20:20 ` Chris Packham
2023-10-16 7:31 ` Peter Rosin
2023-10-21 7:18 ` kernel test robot
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=20231012035838.2804064-3-chris.packham@alliedtelesis.co.nz \
--to=chris.packham@alliedtelesis.co.nz \
--cc=andi.shyti@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-i2c@vger.kernel.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).