From: York Sun <yorksun@freescale.com>
To: <galak@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org, York Sun <yorksun@freescale.com>,
linux-i2c@vger.kernel.org
Subject: [PATCH 4/7] power/mpc85xx: Add delay after enabling I2C master
Date: Fri, 6 Sep 2013 08:43:16 -0700 [thread overview]
Message-ID: <1378482199-10581-4-git-send-email-yorksun@freescale.com> (raw)
In-Reply-To: <1378482199-10581-1-git-send-email-yorksun@freescale.com>
Erratum A-006037 indicates I2C controller executes the write to I2CCR only
after it sees SCL idle for 64K cycle of internal I2C controller clocks. If
during this waiting period, I2C controller is disabled (I2CCR[MEN] set to
0), then the controller could end in bad state, and hang the future access
to I2C register.
The mpc_i2c_fixup() function tries to recover the bus from a stalled state
where the 9th clock pulse wasn't generated. However, this workaround
disables and enables I2C controller without meeting waiting requirement of
this erratum.
This erratum applies to some 85xx SoCs. It is safe to apply to all of them
for mpc_i2c_fixup().
Signed-off-by: York Sun <yorksun@freescale.com>
Reviewed-by: Wood Scott-B07421 <scottwood@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
CC: linux-i2c@vger.kernel.org
---
drivers/i2c/busses/i2c-mpc.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index b80c768..55dce43 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -106,7 +106,12 @@ static irqreturn_t mpc_i2c_isr(int irq, void *dev_id)
static void mpc_i2c_fixup(struct mpc_i2c *i2c)
{
int k;
- u32 delay_val = 1000000 / i2c->real_clk + 1;
+ u32 delay_val;
+#ifdef CONFIG_PPC_85xx
+ delay_val = 65536 / (fsl_get_sys_freq() / 2000000); /* 64K cycle */
+#else
+ delay_val = 1000000 / i2c->real_clk + 1;
+#endif
if (delay_val < 2)
delay_val = 2;
@@ -116,7 +121,11 @@ static void mpc_i2c_fixup(struct mpc_i2c *i2c)
writeccr(i2c, CCR_MSTA | CCR_MTX | CCR_MEN);
udelay(delay_val);
writeccr(i2c, CCR_MEN);
+#ifdef CONFIG_PPC_85xx
+ udelay(delay_val);
+#else
udelay(delay_val << 1);
+#endif
}
}
--
1.7.9.5
next prev parent reply other threads:[~2013-09-06 15:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 15:43 [PATCH 1/7] powerpc/mpc85xx: Fix EDAC address capture York Sun
2013-09-06 15:43 ` [PATCH 2/7] powerpc/mpc8xxx: Change EDAC for FSL SoC York Sun
2013-09-06 15:43 ` [PATCH 3/7] i2c/rtc-ds3232: Fix irq for probing York Sun
2013-09-10 22:26 ` Scott Wood
2013-09-06 15:43 ` York Sun [this message]
2013-09-06 15:43 ` [PATCH 5/7] powerpc/corenet64_smp_defconfig: Enable most SPI splash York Sun
2013-10-29 0:28 ` [5/7] " Scott Wood
2013-10-29 0:39 ` York Sun
2013-09-06 15:43 ` [PATCH 6/7] powerpc/t4240emu: Add device tree file for t4240emu York Sun
2013-09-06 15:43 ` [PATCH 7/7] powerpc/b4860emu: Add device tree file for b4860emu York Sun
2013-09-10 22:31 ` Scott Wood
2013-09-10 22:25 ` [PATCH 1/7] powerpc/mpc85xx: Fix EDAC address capture Scott Wood
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=1378482199-10581-4-git-send-email-yorksun@freescale.com \
--to=yorksun@freescale.com \
--cc=galak@kernel.crashing.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).