From: Tony Lindgren <tony@atomide.com>
To: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
Cc: linux-omap@vger.kernel.org
Subject: Re: [PATCH] I2C: Fix twl4030 timeouts on omap3430
Date: Tue, 1 Apr 2008 17:04:59 +0300 [thread overview]
Message-ID: <20080401140458.GU26502@atomide.com> (raw)
In-Reply-To: <20080401133824.GT26502@atomide.com>
[-- Attachment #1: Type: text/plain, Size: 1843 bytes --]
* Tony Lindgren <tony@atomide.com> [080401 16:39]:
> * Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com> [080401 16:01]:
> > On Tue, Apr 01, 2008 at 03:43:56PM +0300, ext Tony Lindgren wrote:
> > > * Tony Lindgren <tony@atomide.com> [080331 17:30]:
> > > > * Tony Lindgren <tony@atomide.com> [080331 13:43]:
> > > > > * Tony Lindgren <tony@atomide.com> [080328 10:41]:
> > > > > > Hi all,
> > > > > >
> > > > > > This helps with the annoying I2C timeouts. Does anybody have an idea
> > > > > > why the twl4030 chip does not like doing multiple transfers in a row?
> > > > > >
> > > > > > To me the only difference seems to be that clocks are idled between
> > > > > > writing the twl4030 register and reading the register value.
> > > > >
> > > > > I'll push this today with a REVISIT comment added.
> > > >
> > > > Looks like this kills twl4030 interrupts, so I've reverted it.
> > >
> > > After looking into this problem a bit more, looks like twl4030 reads
> > > to anything in "POWER ID" (modules 0x10 and higher) will hang twl4030
> > > eventually and I2C controller gets stuck in mode where STP never clears.
> > >
> > > Repeated reads to "USB ID", "AUD ID" or "AUX ID" will not hang twl4030.
> > >
> >
> > I remember seeing something similar when doing the powerbutton code.
> > Klaus Pedersen found out that leaving CFG_BOOT to its reset value solved
> > the problem. Unfortunately this breaks MADC and USB afaics, so it's not
> > a real solution. CFG_BOOT is programmed in power_companion_init().
>
> Great, this helped a lot! Looks like power_companion_init() tries to get
> osc_ck without checking for clkg_get() return value, and osc_ck does not
> exist in clock34xx.h. So R_CFG_BOOT gets set to default 26MHz value :)
>
> Will post a patch when available.
Thanks again, here's a patch, I've pushed it also.
Tony
[-- Attachment #2: i2c-twl4030-clock.patch --]
[-- Type: text/x-diff, Size: 1317 bytes --]
From: Tony Lindgren <tony@atomide.com>
Date: Tue, 1 Apr 2008 16:58:02 +0300
Subject: [PATCH] I2C: Fix twl4030 clock init
Without this patch twl4030 clock can get programmed to incorrect rate
which can eventually hang twl4030 reads. Also minor formatting fixes.
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/drivers/i2c/chips/twl4030-core.c
+++ b/drivers/i2c/chips/twl4030-core.c
@@ -672,11 +672,20 @@ static int power_companion_init(void)
u32 rate, ctrl = HFCLK_FREQ_26_MHZ;
int e = 0;
- osc = clk_get(NULL,"osc_ck");
+ if (cpu_is_omap2430())
+ osc = clk_get(NULL, "osc_ck");
+ else
+ osc = clk_get(NULL, "osc_sys_ck");
+ if (IS_ERR(osc)) {
+ printk(KERN_ERR "Skipping twl3040 internal clock init and "
+ "using bootloader value (unknown osc rate)\n");
+ return 0;
+ }
+
rate = clk_get_rate(osc);
clk_put(osc);
- switch(rate) {
+ switch (rate) {
case 19200000 : ctrl = HFCLK_FREQ_19p2_MHZ; break;
case 26000000 : ctrl = HFCLK_FREQ_26_MHZ; break;
case 38400000 : ctrl = HFCLK_FREQ_38p4_MHZ; break;
@@ -684,7 +693,7 @@ static int power_companion_init(void)
ctrl |= HIGH_PERF_SQ;
e |= unprotect_pm_master();
- /* effect->MADC+USB ck en */
+ /* effect->MADC+USB ck en */
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
e |= protect_pm_master();
next prev parent reply other threads:[~2008-04-01 14:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-28 8:41 [PATCH] I2C: Fix twl4030 timeouts on omap3430 Tony Lindgren
2008-03-31 10:43 ` Tony Lindgren
2008-03-31 14:30 ` Tony Lindgren
2008-04-01 12:43 ` Tony Lindgren
2008-04-01 13:00 ` Peter 'p2' De Schrijver
2008-04-01 13:38 ` Tony Lindgren
2008-04-01 14:04 ` Tony Lindgren [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-03-28 11:46 [PATCH 0/2] Add sram34xx.S Tony Lindgren
2008-03-28 11:46 ` [PATCH 1/2] ARM: OMAP3: Add 34xx SRAM functions Tony Lindgren
2008-03-28 11:46 ` [PATCH 2/2] ARCH: OMAP3: Make SRAM code from TI CDP compile and work Tony Lindgren
[not found] ` <1206704800-6768-4-git-send-email-tony@atomide.com>
2008-03-28 11:46 ` [PATCH] I2C: Fix twl4030 timeouts on omap3430 Tony Lindgren
2008-03-28 11:46 ` Tony Lindgren
2008-03-28 11:49 ` Tony Lindgren
2008-03-28 11:48 ` Tony Lindgren
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=20080401140458.GU26502@atomide.com \
--to=tony@atomide.com \
--cc=linux-omap@vger.kernel.org \
--cc=peter.de-schrijver@nokia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.