linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register
@ 2019-02-11 22:57 Tony Lindgren
  2019-02-12  7:50 ` Peter Ujfalusi
  2019-02-14  9:20 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Tony Lindgren @ 2019-02-11 22:57 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-omap, Florian Vaussard, Peter Ujfalusi

I noticed that we can get a -EREMOTEIO errors on at least omap4 duovero:

twl6040 0-004b: Failed to write 2d = 19: -121

And then any following register access will produce errors.

There 2d offset above is register ACCCTL that gets written on twl6040
powerup. With error checking added to the related regcache_sync() call,
the -EREMOTEIO error is reproducable on twl6040 powerup at least
duovero.

To fix the error, we need to wait until twl6040 is accessible after the
powerup. Based on tests on omap4 duovero, we need to wait over 8ms after
powerup before register write will complete without failures. Let's also
make sure we warn about possible errors too.

Note that we have twl6040_patch[] reg_sequence with the ACCCTL register
configuration and regcache_sync() will write the new value to ACCCTL.

Cc: Florian Vaussard <florian.vaussard@epfl.ch>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mfd/twl6040.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
--- a/drivers/mfd/twl6040.c
+++ b/drivers/mfd/twl6040.c
@@ -322,8 +322,19 @@ int twl6040_power(struct twl6040 *twl6040, int on)
 			}
 		}
 
+		/*
+		 * Register access can produce errors after power-up unless we
+		 * wait at least 8ms based on measurements on duovero.
+		 */
+		usleep_range(10000, 12000);
+
 		/* Sync with the HW */
-		regcache_sync(twl6040->regmap);
+		ret = regcache_sync(twl6040->regmap);
+		if (ret) {
+			dev_err(twl6040->dev, "%s register write failed: %i\n",
+				__func__, ret);
+			goto out;
+		}
 
 		/* Default PLL configuration after power up */
 		twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
-- 
2.20.1

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

* Re: [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register
  2019-02-11 22:57 [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register Tony Lindgren
@ 2019-02-12  7:50 ` Peter Ujfalusi
  2019-02-14  9:20 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2019-02-12  7:50 UTC (permalink / raw)
  To: Tony Lindgren, Lee Jones; +Cc: linux-kernel, linux-omap, Florian Vaussard



On 12/02/2019 0.57, Tony Lindgren wrote:
> I noticed that we can get a -EREMOTEIO errors on at least omap4 duovero:
> 
> twl6040 0-004b: Failed to write 2d = 19: -121
> 
> And then any following register access will produce errors.
> 
> There 2d offset above is register ACCCTL that gets written on twl6040
> powerup. With error checking added to the related regcache_sync() call,
> the -EREMOTEIO error is reproducable on twl6040 powerup at least
> duovero.
> 
> To fix the error, we need to wait until twl6040 is accessible after the
> powerup. Based on tests on omap4 duovero, we need to wait over 8ms after
> powerup before register write will complete without failures. Let's also
> make sure we warn about possible errors too.
> 
> Note that we have twl6040_patch[] reg_sequence with the ACCCTL register
> configuration and regcache_sync() will write the new value to ACCCTL.

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> 
> Cc: Florian Vaussard <florian.vaussard@epfl.ch>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/mfd/twl6040.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
> --- a/drivers/mfd/twl6040.c
> +++ b/drivers/mfd/twl6040.c
> @@ -322,8 +322,19 @@ int twl6040_power(struct twl6040 *twl6040, int on)
>  			}
>  		}
>  
> +		/*
> +		 * Register access can produce errors after power-up unless we
> +		 * wait at least 8ms based on measurements on duovero.
> +		 */
> +		usleep_range(10000, 12000);
> +
>  		/* Sync with the HW */
> -		regcache_sync(twl6040->regmap);
> +		ret = regcache_sync(twl6040->regmap);
> +		if (ret) {
> +			dev_err(twl6040->dev, "%s register write failed: %i\n",
> +				__func__, ret);
> +			goto out;
> +		}
>  
>  		/* Default PLL configuration after power up */
>  		twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register
  2019-02-11 22:57 [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register Tony Lindgren
  2019-02-12  7:50 ` Peter Ujfalusi
@ 2019-02-14  9:20 ` Lee Jones
  2019-02-14 16:03   ` Tony Lindgren
  1 sibling, 1 reply; 4+ messages in thread
From: Lee Jones @ 2019-02-14  9:20 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-kernel, linux-omap, Florian Vaussard, Peter Ujfalusi

On Mon, 11 Feb 2019, Tony Lindgren wrote:

> I noticed that we can get a -EREMOTEIO errors on at least omap4 duovero:
> 
> twl6040 0-004b: Failed to write 2d = 19: -121
> 
> And then any following register access will produce errors.
> 
> There 2d offset above is register ACCCTL that gets written on twl6040
> powerup. With error checking added to the related regcache_sync() call,
> the -EREMOTEIO error is reproducable on twl6040 powerup at least
> duovero.
> 
> To fix the error, we need to wait until twl6040 is accessible after the
> powerup. Based on tests on omap4 duovero, we need to wait over 8ms after
> powerup before register write will complete without failures. Let's also
> make sure we warn about possible errors too.
> 
> Note that we have twl6040_patch[] reg_sequence with the ACCCTL register
> configuration and regcache_sync() will write the new value to ACCCTL.
> 
> Cc: Florian Vaussard <florian.vaussard@epfl.ch>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/mfd/twl6040.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
> --- a/drivers/mfd/twl6040.c
> +++ b/drivers/mfd/twl6040.c
> @@ -322,8 +322,19 @@ int twl6040_power(struct twl6040 *twl6040, int on)
>  			}
>  		}
>  
> +		/*
> +		 * Register access can produce errors after power-up unless we
> +		 * wait at least 8ms based on measurements on duovero.
> +		 */
> +		usleep_range(10000, 12000);
> +
>  		/* Sync with the HW */
> -		regcache_sync(twl6040->regmap);
> +		ret = regcache_sync(twl6040->regmap);
> +		if (ret) {
> +			dev_err(twl6040->dev, "%s register write failed: %i\n",
> +				__func__, ret);

Please drop the __func__ and just use the standard format.

Wouldn't something a little more forthcoming be better?

"Failed to sync with the HW" ?

> +			goto out;
> +		}
>  
>  		/* Default PLL configuration after power up */
>  		twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register
  2019-02-14  9:20 ` Lee Jones
@ 2019-02-14 16:03   ` Tony Lindgren
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2019-02-14 16:03 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-omap, Florian Vaussard, Peter Ujfalusi

* Lee Jones <lee.jones@linaro.org> [190214 09:21]:
> On Mon, 11 Feb 2019, Tony Lindgren wrote:
> > +		ret = regcache_sync(twl6040->regmap);
> > +		if (ret) {
> > +			dev_err(twl6040->dev, "%s register write failed: %i\n",
> > +				__func__, ret);
> 
> Please drop the __func__ and just use the standard format.
> 
> Wouldn't something a little more forthcoming be better?
> 
> "Failed to sync with the HW" ?

Sure I'll send an updated patch.

Regards,

Tony

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

end of thread, other threads:[~2019-02-14 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 22:57 [PATCH] mfd: twl6040: Fix device init errors for ACCCTL register Tony Lindgren
2019-02-12  7:50 ` Peter Ujfalusi
2019-02-14  9:20 ` Lee Jones
2019-02-14 16:03   ` Tony Lindgren

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