Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1390200 > unrolled thread

Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks

Started byMaxime Coquelin <maxime.coquelin@st.com>
First post2016-04-28 15:40 +0200
Last post2016-05-11 17:30 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Maxime Coquelin <maxime.coquelin@st.com> - 2016-04-28 15:40 +0200
    Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Wolfram Sang <wsa@the-dreams.de> - 2016-04-28 17:00 +0200
      Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Maxime Coquelin <maxime.coquelin@st.com> - 2016-04-29 13:30 +0200
        Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Peter Griffin <peter.griffin@linaro.org> - 2016-04-29 16:10 +0200
          Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Wolfram Sang <wsa@the-dreams.de> - 2016-05-11 17:10 +0200
            Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Peter Griffin <peter.griffin@linaro.org> - 2016-05-11 17:30 +0200

#1390200 — Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks

FromMaxime Coquelin <maxime.coquelin@st.com>
Date2016-04-28 15:40 +0200
SubjectRe: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks
Message-ID<rsUkI-3Su-37@gated-at.bofh.it>
Hi Wolfram,

On 04/24/2016 11:10 PM, Wolfram Sang wrote:
>> +/*
>> + * i2c bus recovery routines
>> + * get_scl and set_scl must be defined to avoid the recover_bus field of
>> + * i2c_bus_recovery_info to be overriden with NULL during the
>> + * i2c_add_adapter call
>> + */
> Oh, that shouldn't be like this. Can you try this patch and remove the
> empty functions please?
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 4979728f7fb2de..604936955807e5 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1595,10 +1595,12 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>   
>   			bri->get_scl = get_scl_gpio_value;
>   			bri->set_scl = set_scl_gpio_value;
> -		} else if (!bri->set_scl || !bri->get_scl) {
> +		} else if (bri->recover_bus == i2c_generic_scl_recovery) {
>   			/* Generic SCL recovery */
> -			dev_err(&adap->dev, "No {get|set}_gpio() found, not using recovery\n");
> -			adap->bus_recovery_info = NULL;
> +			if (!bri->set_scl || !bri->get_scl) {
> +				dev_err(&adap->dev, "No {get|set}_scl() found, not using recovery\n");
> +				adap->bus_recovery_info = NULL;
> +			}
>   		}
>   	}
>   
>
>> +static int st_i2c_recover_bus(struct i2c_adapter *i2c_adap)
>> +{
> Can you describe what the function does? It is not clear to me that it
> generates 9 scl pulses.
I agree, it would need some comments.
This IP is dual-role, it can do either SPI or I2C.
The trick is to switch to SPI mode, 9 bits words and write a 0,
so that 9 clock pulses are generated.

This is easier to manage than switching to GPIO mode,
as we don't need to provide the gpio handles in DT, and no need to 
put/get the pinctrl handle.

Regards,
Maxime

[toc] | [next] | [standalone]


#1390283

FromWolfram Sang <wsa@the-dreams.de>
Date2016-04-28 17:00 +0200
Message-ID<rsVA6-50h-11@gated-at.bofh.it>
In reply to#1390200

[Multipart message — attachments visible in raw view] — view raw

> The trick is to switch to SPI mode, 9 bits words and write a 0,
> so that 9 clock pulses are generated.

Heh. As long as it works :) But as you said, it really needs a comment.

[toc] | [prev] | [next] | [standalone]


#1391023

FromMaxime Coquelin <maxime.coquelin@st.com>
Date2016-04-29 13:30 +0200
Message-ID<rteMq-53Y-13@gated-at.bofh.it>
In reply to#1390283

On 04/28/2016 04:57 PM, Wolfram Sang wrote:
>> The trick is to switch to SPI mode, 9 bits words and write a 0,
>> so that 9 clock pulses are generated.
> Heh. As long as it works :) But as you said, it really needs a comment.
>
:)
I didn't faced the problem myself, but it looks good with an oscilloscope,
and a customer reported it to work.

Peter, will you resend with adding the explanations I provided as comment?

Thanks in advance,
Maxime

[toc] | [prev] | [next] | [standalone]


#1391183

FromPeter Griffin <peter.griffin@linaro.org>
Date2016-04-29 16:10 +0200
Message-ID<rthhh-7lH-35@gated-at.bofh.it>
In reply to#1391023
Hi Maxime,

On Fri, 29 Apr 2016, Maxime Coquelin wrote:

> 
> 
> On 04/28/2016 04:57 PM, Wolfram Sang wrote:
> >>The trick is to switch to SPI mode, 9 bits words and write a 0,
> >>so that 9 clock pulses are generated.
> >Heh. As long as it works :) But as you said, it really needs a comment.
> >
> :)
> I didn't faced the problem myself, but it looks good with an oscilloscope,
> and a customer reported it to work.
> 
> Peter, will you resend with adding the explanations I provided as comment?
>
Yes I'll send a v2 with your comment added.

Peter

[toc] | [prev] | [next] | [standalone]


#1399223

FromWolfram Sang <wsa@the-dreams.de>
Date2016-05-11 17:10 +0200
Message-ID<rxDVU-2hX-23@gated-at.bofh.it>
In reply to#1391183

[Multipart message — attachments visible in raw view] — view raw

> Yes I'll send a v2 with your comment added.

Any news?

[toc] | [prev] | [next] | [standalone]


#1399261

FromPeter Griffin <peter.griffin@linaro.org>
Date2016-05-11 17:30 +0200
Message-ID<rxEfg-2vs-27@gated-at.bofh.it>
In reply to#1399223
Hi Wolfram,

On Wed, 11 May 2016, Wolfram Sang wrote:

> > Yes I'll send a v2 with your comment added.
> 
> Any news?
>
Sorry, I will re-send it in a few minutes.

Peter. 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web