public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>,
	gregory.clement@bootlin.com, andi.shyti@kernel.org,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, Abel Vesa <abel.vesa@linaro.org>,
	Mark Brown <broonie@kernel.org>
Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] i2c: mv64xxx: add an optional bus-reset-gpios property
Date: Fri, 27 Oct 2023 13:37:05 +0200	[thread overview]
Message-ID: <9eebec9b-e6fd-4a22-89ea-b434f446e061@linaro.org> (raw)
In-Reply-To: <65911ec0-e073-435f-846a-c5501dd5d3a9@linaro.org>

On 27/10/2023 13:27, Krzysztof Kozlowski wrote:
> On 27/10/2023 05:31, Chris Packham wrote:
>> 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

Cc: Mark,

Also this part is not true. If the bus is non-discoverable, then it is
possible to have reset-gpios in each probed device. You can share GPIOs,
so no problem with -EBUSY at all.

The problem is doing reset:
1. in proper moment for all devices
2. without affecting other devices when one unbinds/remove()

The (2) above is not solveable easy in kernel and we already had nice
talks about it just few days ago:
1. Apple case:
https://social.treehouse.systems/@marcan/111268780311634160

2. my WSA884x:
https://lore.kernel.org/alsa-devel/84f9f1c4-0627-4986-8160-b4ab99469b81@linaro.org/

Last,
I would like to apologize to you Chris. I understand that bringing such
feedback at v5 is not that good. I had plenty of time to say something
earlier, so this is not really professional from my side. I am sorry,
just my brain did not connect all these topics together.

I apologize.

Best regards,
Krzysztof

>> this kind of hardware design by associating the bus-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>
>> ---
>>
>> Notes:
>>     Changes in v5:
>>     - Rename reset-gpios and reset-duration-us to bus-reset-gpios and
>>       bus-reset-duration-us as requested by Wolfram
>>     Changes in v4:
>>     - Add missing gpio/consumer.h
>>     - use fsleep() for enforcing reset-duration
>>     Changes in v3:
>>     - Rename reset-delay to reset-duration
>>     - Use reset-duration-us property to control the reset pulse rather than
>>       delaying after the reset
>>     Changes in v2:
>>     - Add a property to cover the length of delay after releasing the reset
>>       GPIO
>>     - Use dev_err_probe() when requesing the GPIO fails
>>
>>  drivers/i2c/busses/i2c-mv64xxx.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
>> index efd28bbecf61..6e2762d22e5a 100644
>> --- a/drivers/i2c/busses/i2c-mv64xxx.c
>> +++ b/drivers/i2c/busses/i2c-mv64xxx.c
>> @@ -13,6 +13,7 @@
>>  #include <linux/slab.h>
>>  #include <linux/module.h>
>>  #include <linux/spinlock.h>
>> +#include <linux/gpio/consumer.h>
>>  #include <linux/i2c.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/mv643xx_i2c.h>
>> @@ -160,6 +161,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 = {
>> @@ -1036,6 +1038,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
>>  	struct mv64xxx_i2c_data		*drv_data;
>>  	struct mv64xxx_i2c_pdata	*pdata = dev_get_platdata(&pd->dev);
>>  	struct resource *res;
>> +	u32	reset_duration;
>>  	int	rc;
>>  
>>  	if ((!pdata && !pd->dev.of_node))
>> @@ -1083,6 +1086,14 @@ 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, "bus-reset", GPIOD_OUT_HIGH);
>> +	if (IS_ERR(drv_data->reset_gpio))
>> +		return dev_err_probe(&pd->dev, PTR_ERR(drv_data->reset_gpio),
>> +				     "Cannot get reset gpio\n");
>> +	rc = device_property_read_u32(&pd->dev, "bus-reset-duration-us", &reset_duration);
>> +	if (rc)
>> +		reset_duration = 1;
> 
> No, this should be solved by core - for entire I2C at minimum. This is
> not specific to this device.


  reply	other threads:[~2023-10-27 11:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27  3:31 [PATCH v5 0/2] i2c: mv64xxx: bus-reset-gpios Chris Packham
2023-10-27  3:31 ` [PATCH v5 1/2] dt-bindings: i2c: mv64xxx: add bus-reset-gpios property Chris Packham
2023-10-27  9:09   ` Wolfram Sang
2023-10-27 11:25     ` Krzysztof Kozlowski
2023-10-27 19:22       ` Rob Herring
2023-10-28  7:51         ` Krzysztof Kozlowski
2023-10-27  3:31 ` [PATCH v5 2/2] i2c: mv64xxx: add an optional " Chris Packham
2023-10-27  8:48   ` Andi Shyti
2023-10-27 11:27   ` Krzysztof Kozlowski
2023-10-27 11:37     ` Krzysztof Kozlowski [this message]
2023-10-29 20:48       ` Chris Packham
2023-10-31  6:01         ` Krzysztof Kozlowski
2023-10-31 19:59           ` Chris Packham
     [not found]       ` <20231027125537.5d5cu3wc4r4c2yb4@zenone.zhora.eu>
2023-10-29 21:02         ` Chris Packham

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=9eebec9b-e6fd-4a22-89ea-b434f446e061@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=abel.vesa@linaro.org \
    --cc=andi.shyti@kernel.org \
    --cc=broonie@kernel.org \
    --cc=chris.packham@alliedtelesis.co.nz \
    --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