linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync()
@ 2015-10-29  9:37 Kuninori Morimoto
  2015-10-29 11:32 ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2015-10-29  9:37 UTC (permalink / raw)
  To: Simon, linux-i2c, Wolfram Sang; +Cc: Magnus, linux-sh


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

rcar_i2c_init() initializes I2C device, but it should be called
*after* pm_runtime_get_sync(). Otherwise it outputs very hi speed
clock. This patch solved this issue, 
This patch also removes pointless rcar_i2c_init()
from rcar_i2c_probe()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/i2c/busses/i2c-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 616433d..edbfefc 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -474,6 +474,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
 
 	pm_runtime_get_sync(dev);
 
+	rcar_i2c_init(priv);
+
 	ret = rcar_i2c_bus_barrier(priv);
 	if (ret < 0)
 		goto out;
@@ -612,8 +614,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->io))
 		return PTR_ERR(priv->io);
 
-	rcar_i2c_init(priv);
-
 	irq = platform_get_irq(pdev, 0);
 	init_waitqueue_head(&priv->wait);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync()
  2015-10-29  9:37 [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync() Kuninori Morimoto
@ 2015-10-29 11:32 ` Geert Uytterhoeven
  2015-10-29 19:17   ` Wolfram Sang
  2015-10-30  0:13   ` Kuninori Morimoto
  0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2015-10-29 11:32 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Linux I2C, Wolfram Sang, Magnus, Linux-sh list

On Thu, Oct 29, 2015 at 10:37 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> rcar_i2c_init() initializes I2C device, but it should be called
> *after* pm_runtime_get_sync(). Otherwise it outputs very hi speed
> clock. This patch solved this issue,
> This patch also removes pointless rcar_i2c_init()
> from rcar_i2c_probe()
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/i2c/busses/i2c-rcar.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> index 616433d..edbfefc 100644
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -474,6 +474,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
>
>         pm_runtime_get_sync(dev);
>
> +       rcar_i2c_init(priv);

Hence now it's done again for every transfer?

What about moving it just before the call to i2c_add_numbered_adapter(),
and wrapping it inside pm_runtime_get_sync(dev)/pm_runtime_put()?

Wolfram, what do you think?

> +
>         ret = rcar_i2c_bus_barrier(priv);
>         if (ret < 0)
>                 goto out;
> @@ -612,8 +614,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
>         if (IS_ERR(priv->io))
>                 return PTR_ERR(priv->io);
>
> -       rcar_i2c_init(priv);
> -
>         irq = platform_get_irq(pdev, 0);
>         init_waitqueue_head(&priv->wait);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync()
  2015-10-29 11:32 ` Geert Uytterhoeven
@ 2015-10-29 19:17   ` Wolfram Sang
  2015-10-30  0:13   ` Kuninori Morimoto
  1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2015-10-29 19:17 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kuninori Morimoto, Simon, Linux I2C, Magnus, Linux-sh list

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]


> Hence now it's done again for every transfer?
> 
> What about moving it just before the call to i2c_add_numbered_adapter(),
> and wrapping it inside pm_runtime_get_sync(dev)/pm_runtime_put()?
> 
> Wolfram, what do you think?

I'd prefer the latter. Sending a tested patch in a second...


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync()
  2015-10-29 11:32 ` Geert Uytterhoeven
  2015-10-29 19:17   ` Wolfram Sang
@ 2015-10-30  0:13   ` Kuninori Morimoto
  2015-10-30  8:04     ` Geert Uytterhoeven
  1 sibling, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2015-10-30  0:13 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Simon, Linux I2C, Wolfram Sang, Magnus, Linux-sh list


Hi Geert

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> >
> > rcar_i2c_init() initializes I2C device, but it should be called
> > *after* pm_runtime_get_sync(). Otherwise it outputs very hi speed
> > clock. This patch solved this issue,
> > This patch also removes pointless rcar_i2c_init()
> > from rcar_i2c_probe()
> >
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
> >  drivers/i2c/busses/i2c-rcar.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> > index 616433d..edbfefc 100644
> > --- a/drivers/i2c/busses/i2c-rcar.c
> > +++ b/drivers/i2c/busses/i2c-rcar.c
> > @@ -474,6 +474,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
> >
> >         pm_runtime_get_sync(dev);
> >
> > +       rcar_i2c_init(priv);
> 
> Hence now it's done again for every transfer?
> 
> What about moving it just before the call to i2c_add_numbered_adapter(),
> and wrapping it inside pm_runtime_get_sync(dev)/pm_runtime_put()?

In my experience, it should be called again for every transfer.
Because SoC/IP might doesn't keep register setting value if you call pm_runtime_put()
(I fought with this behavior when sh_mobile IP :P )

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync()
  2015-10-30  0:13   ` Kuninori Morimoto
@ 2015-10-30  8:04     ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2015-10-30  8:04 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Linux I2C, Wolfram Sang, Magnus, Linux-sh list

Hi Morimoto-san,

On Fri, Oct 30, 2015 at 1:13 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>> >
>> > rcar_i2c_init() initializes I2C device, but it should be called
>> > *after* pm_runtime_get_sync(). Otherwise it outputs very hi speed
>> > clock. This patch solved this issue,
>> > This patch also removes pointless rcar_i2c_init()
>> > from rcar_i2c_probe()
>> >
>> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>> > ---
>> >  drivers/i2c/busses/i2c-rcar.c | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
>> > index 616433d..edbfefc 100644
>> > --- a/drivers/i2c/busses/i2c-rcar.c
>> > +++ b/drivers/i2c/busses/i2c-rcar.c
>> > @@ -474,6 +474,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
>> >
>> >         pm_runtime_get_sync(dev);
>> >
>> > +       rcar_i2c_init(priv);
>>
>> Hence now it's done again for every transfer?
>>
>> What about moving it just before the call to i2c_add_numbered_adapter(),
>> and wrapping it inside pm_runtime_get_sync(dev)/pm_runtime_put()?
>
> In my experience, it should be called again for every transfer.
> Because SoC/IP might doesn't keep register setting value if you call pm_runtime_put()
> (I fought with this behavior when sh_mobile IP :P )

At least for R-Car Gen1 and Gen2, the datasheet states that register values
are retained during sleep or module standby. I can't seem to find information
about this for Gen3.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-30  8:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29  9:37 [PATCH] i2c: rcar: call rcar_i2c_init() after pm_runtime_get_sync() Kuninori Morimoto
2015-10-29 11:32 ` Geert Uytterhoeven
2015-10-29 19:17   ` Wolfram Sang
2015-10-30  0:13   ` Kuninori Morimoto
2015-10-30  8:04     ` Geert Uytterhoeven

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).